Skip to content

Commit

Permalink
base: added method for parsing bins.csv files
Browse files Browse the repository at this point in the history
Signed-off-by: Grzegorz Latosinski <[email protected]>
  • Loading branch information
glatosinski committed Nov 25, 2020
1 parent 561e274 commit 9dd0dbb
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions scripts/python-skywater-pdk/skywater_pdk/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@
from dataclasses import dataclass
from dataclasses_json import dataclass_json
from enum import Enum
from typing import Optional, Union, Tuple
from typing import Optional, Union, Tuple, List
from collections import namedtuple
from pathlib import Path
import csv

from .utils import comparable_to_none
from .utils import dataclass_json_passthru_config as dj_pass_cfg


FETBin = namedtuple('FETBin', ['device', 'bin', 'w', 'l'])
LibraryOrCell = Union['Library', 'Cell']


Expand Down Expand Up @@ -545,6 +549,24 @@ def fullname(self):
self))
return "{}__{}".format(self.library.fullname, self.name)

@classmethod
def parse_bins(cls, binsfile) -> List[FETBin]:
"""
Parse bins.csv file.
Parameters
----------
binsfile: path to the bins.csv file
"""
with open(binsfile, 'r') as f:
reader = csv.reader(f)
next(reader)
res = []
for line in reader:
res.append(FETBin(line[0], int(line[1]), float(line[2]), float(line[3])))
return res


@classmethod
def parse(cls, s):
kw = {}
Expand All @@ -555,7 +577,6 @@ def parse(cls, s):
return cls(**kw)



if __name__ == "__main__":
import doctest
doctest.testmod()

0 comments on commit 9dd0dbb

Please sign in to comment.