Browse Source

fix sim model generation for circuits with dangling nodes

devel
Stefan Holst 3 days ago
parent
commit
dd4e5c861a
  1. 6
      src/kyupy/sim.py
  2. 16
      tests/test_logic_sim.py

6
src/kyupy/sim.py

@ -188,10 +188,10 @@ class SimOps:
levels = [] levels = []
ppio2idx = dict((n, i) for i, n in enumerate(circuit.s_nodes)) ppio2idx = dict((n, i) for i, n in enumerate(circuit.s_nodes))
ppos = set([n for n in circuit.s_nodes if len(n.ins) > 0]) root_nodes = set([n for n in circuit.s_nodes if len(n.ins) > 0] + [n for n in circuit.nodes if len(n.outs) == 0]) # start from POs, PPOs, and any dangling nodes
readers = np.array([1 if l.reader in ppos else len(l.reader.outs) for l in circuit.lines], dtype=np.int32) # for ref-counting forks readers = np.array([1 if l.reader in root_nodes else len(l.reader.outs) for l in circuit.lines], dtype=np.int32) # for ref-counting forks
level_lines = [n.ins[0] for n in ppos] # start from PPOs level_lines = [n.ins[0] for n in root_nodes]
# FIXME: Should probably instanciate buffers for PPOs and attach DFF clocks # FIXME: Should probably instanciate buffers for PPOs and attach DFF clocks
while len(level_lines) > 0: # traverse the circuit level-wise back towards (P)PIs while len(level_lines) > 0: # traverse the circuit level-wise back towards (P)PIs

16
tests/test_logic_sim.py

@ -3,6 +3,22 @@ import numpy as np
from kyupy.logic_sim import LogicSim, LogicSim2V, LogicSim4V, LogicSim6V from kyupy.logic_sim import LogicSim, LogicSim2V, LogicSim4V, LogicSim6V
from kyupy import bench, logic, sim, verilog from kyupy import bench, logic, sim, verilog
from kyupy.logic import mvarray, bparray, bp_to_mv, mv_to_bp from kyupy.logic import mvarray, bparray, bp_to_mv, mv_to_bp
from kyupy.techlib import SAED90
def test_dangling():
c = verilog.parse('''
module test(i, o);
input i; output o; wire dangling;
INVX0 dff1 (.INP(i),.ZN(o));
assign dangling=o;
endmodule
''', tlib=SAED90)
c.resolve_tlib_cells(SAED90)
sim = LogicSim2V(c)
p = sim.allocate()
p[...] = 0
sim.simulate(p)
assert p[1,0] == logic.ONE
def assert_equal_shape_and_contents(actual, desired): def assert_equal_shape_and_contents(actual, desired):
desired = np.array(desired, dtype=np.uint8) desired = np.array(desired, dtype=np.uint8)

Loading…
Cancel
Save