| 1 |
import os |
| 2 |
import pickle |
| 3 |
from apycula import chipdb |
| 4 |
|
| 5 |
device = os.getenv("DEVICE") |
| 6 |
if not device: |
| 7 |
raise Exception("DEVICE not set") |
| 8 |
|
| 9 |
timing_class = "C6/I5" |
| 10 |
|
| 11 |
with importlib.resources.open_binary("apycula", f"{device}.pickle") as f: |
| 12 |
db = pickle.load(f) |
| 13 |
|
| 14 |
timing = db.timing[timing_class] |
| 15 |
|
| 16 |
for cname, cell in ctx.cells: |
| 17 |
if cell.type != "GENERIC_SLICE": |
| 18 |
continue |
| 19 |
if cname in ("$PACKER_GND", "$PACKER_VCC"): |
| 20 |
continue |
| 21 |
ports = ['a', 'b', 'c', 'd'] |
| 22 |
ctx.addCellTimingClock(cell=cname, port="CLK") |
| 23 |
for i, port in enumerate(ports): |
| 24 |
setup = ctx.getDelayFromNS(max(timing['dff']['di_clksetpos'])) |
| 25 |
hold = ctx.getDelayFromNS(max(timing['dff']['di_clkholdpos'])) |
| 26 |
ctx.addCellTimingSetupHold(cell=cname, port="I[%d]" % i, clock="CLK", setup=setup, hold=hold) |
| 27 |
clkout = ctx.getDelayFromNS(max(timing['dff']['clk_qpos'])) |
| 28 |
ctx.addCellTimingClockToOut(cell=cname, port="Q", clock="CLK", clktoq=clkout) |
| 29 |
for i, port in enumerate(ports): |
| 30 |
delay = ctx.getDelayFromNS(max(timing['lut'][f'{port}_f'])) |
| 31 |
ctx.addCellTimingDelay(cell=cname, fromPort="I[%d]" % i, toPort="F", delay=delay) |