base: added method for parsing bins.csv files
Signed-off-by: Grzegorz Latosinski <glatosinski@antmicro.com>
This commit is contained in:
parent
77bad0df65
commit
ee006e4a3f
|
@ -22,12 +22,16 @@ import os
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from dataclasses_json import dataclass_json
|
from dataclasses_json import dataclass_json
|
||||||
from enum import Enum
|
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 comparable_to_none
|
||||||
from .utils import dataclass_json_passthru_config as dj_pass_cfg
|
from .utils import dataclass_json_passthru_config as dj_pass_cfg
|
||||||
|
|
||||||
|
|
||||||
|
FETBin = namedtuple('FETBin', ['device', 'bin', 'w', 'l'])
|
||||||
LibraryOrCell = Union['Library', 'Cell']
|
LibraryOrCell = Union['Library', 'Cell']
|
||||||
|
|
||||||
|
|
||||||
|
@ -545,6 +549,24 @@ class Cell:
|
||||||
self))
|
self))
|
||||||
return "{}__{}".format(self.library.fullname, self.name)
|
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
|
@classmethod
|
||||||
def parse(cls, s):
|
def parse(cls, s):
|
||||||
kw = {}
|
kw = {}
|
||||||
|
@ -555,7 +577,6 @@ class Cell:
|
||||||
return cls(**kw)
|
return cls(**kw)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import doctest
|
import doctest
|
||||||
doctest.testmod()
|
doctest.testmod()
|
||||||
|
|
Loading…
Reference in New Issue