|
|
@ -11,50 +11,6 @@ from itertools import product |
|
|
|
from . import bench |
|
|
|
from . import bench |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TechLibOld: |
|
|
|
|
|
|
|
@staticmethod |
|
|
|
|
|
|
|
def pin_index(kind, pin): |
|
|
|
|
|
|
|
if isinstance(pin, int): |
|
|
|
|
|
|
|
return max(0, pin-1) |
|
|
|
|
|
|
|
if kind[:3] in ('OAI', 'AOI'): |
|
|
|
|
|
|
|
if pin[0] == 'A': return int(pin[1]) - 1 |
|
|
|
|
|
|
|
if pin == 'B': return int(kind[3]) |
|
|
|
|
|
|
|
if pin[0] == 'B': return int(pin[1]) - 1 + int(kind[3]) |
|
|
|
|
|
|
|
for prefix, pins, index in [('HADD', ('B0', 'SO'), 1), |
|
|
|
|
|
|
|
('HADD', ('A0', 'C1'), 0), |
|
|
|
|
|
|
|
('MUX21', ('S', 'S0'), 2), |
|
|
|
|
|
|
|
('MX2', ('S0',), 2), |
|
|
|
|
|
|
|
('TBUF', ('OE',), 1), |
|
|
|
|
|
|
|
('TINV', ('OE',), 1), |
|
|
|
|
|
|
|
('LATCH', ('D',), 0), |
|
|
|
|
|
|
|
('LATCH', ('QN',), 1), |
|
|
|
|
|
|
|
('DFF', ('D',), 0), |
|
|
|
|
|
|
|
('DFF', ('QN',), 1), |
|
|
|
|
|
|
|
('SDFF', ('D',), 0), |
|
|
|
|
|
|
|
('SDFF', ('QN',), 1), |
|
|
|
|
|
|
|
('SDFF', ('CLK',), 3), |
|
|
|
|
|
|
|
('SDFF', ('RSTB', 'RN'), 4), |
|
|
|
|
|
|
|
('SDFF', ('SETB',), 5), |
|
|
|
|
|
|
|
('ISOL', ('ISO',), 0), |
|
|
|
|
|
|
|
('ISOL', ('D',), 1)]: |
|
|
|
|
|
|
|
if kind.startswith(prefix) and pin in pins: return index |
|
|
|
|
|
|
|
for index, pins in enumerate([('A1', 'IN1', 'A', 'S', 'INP', 'I', 'Q', 'QN', 'Y', 'Z', 'ZN'), |
|
|
|
|
|
|
|
('A2', 'IN2', 'B', 'CK', 'CLK', 'CO', 'SE'), |
|
|
|
|
|
|
|
('A3', 'IN3', 'C', 'RN', 'RSTB', 'CI', 'SI'), |
|
|
|
|
|
|
|
('A4', 'IN4', 'D', 'SN', 'SETB'), |
|
|
|
|
|
|
|
('A5', 'IN5', 'E'), |
|
|
|
|
|
|
|
('A6', 'IN6', 'F')]): |
|
|
|
|
|
|
|
if pin in pins: return index |
|
|
|
|
|
|
|
raise ValueError(f'Unknown pin index for {kind}.{pin}') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
|
|
|
|
def pin_is_output(kind, pin): |
|
|
|
|
|
|
|
if isinstance(pin, int): |
|
|
|
|
|
|
|
return pin == 0 |
|
|
|
|
|
|
|
if 'MUX' in kind and pin == 'S': return False |
|
|
|
|
|
|
|
return pin in ('Q', 'QN', 'Z', 'ZN', 'Y', 'CO', 'S', 'SO', 'C1') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TechLib: |
|
|
|
class TechLib: |
|
|
|
"""Class for standard cell library definitions. |
|
|
|
"""Class for standard cell library definitions. |
|
|
|
|
|
|
|
|
|
|
@ -93,6 +49,14 @@ class TechLib: |
|
|
|
assert pin in self.cells[kind][1], f'Unknown pin: {pin} for cell {kind}' |
|
|
|
assert pin in self.cells[kind][1], f'Unknown pin: {pin} for cell {kind}' |
|
|
|
return self.cells[kind][1][pin][0] |
|
|
|
return self.cells[kind][1][pin][0] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def pin_name(self, kind, pos, output=False): |
|
|
|
|
|
|
|
"""Returns the pin name for a given node kind, list position, and direction.""" |
|
|
|
|
|
|
|
assert kind in self.cells, f'Unknown cell: {kind}' |
|
|
|
|
|
|
|
for name, (ppos, isout) in self.cells[kind][1].items(): |
|
|
|
|
|
|
|
if isout == output and ppos == pos: |
|
|
|
|
|
|
|
return name |
|
|
|
|
|
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
def pin_is_output(self, kind, pin): |
|
|
|
def pin_is_output(self, kind, pin): |
|
|
|
"""Returns True, if given pin name of a node kind is an output.""" |
|
|
|
"""Returns True, if given pin name of a node kind is an output.""" |
|
|
|
assert kind in self.cells, f'Unknown cell: {kind}' |
|
|
|
assert kind in self.cells, f'Unknown cell: {kind}' |
|
|
|