From 68e8cb844a8f39bcb0b3700586bb22c8d467e574 Mon Sep 17 00:00:00 2001 From: Stefan Holst Date: Fri, 16 Feb 2024 09:48:52 +0900 Subject: [PATCH] pass line id to inject_cb --- src/kyupy/logic_sim.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/kyupy/logic_sim.py b/src/kyupy/logic_sim.py index a5b3039..26a1c76 100644 --- a/src/kyupy/logic_sim.py +++ b/src/kyupy/logic_sim.py @@ -51,7 +51,7 @@ class LogicSim(sim.SimOps): """ self.c[self.pippi_c_locs] = self.s[0, self.pippi_s_locs, :self.mdim] - def c_prop(self, inject_cb=None): + def c_prop(self, sims=None, inject_cb=None): """Propagate the input values through the combinational circuit towards the outputs. Performs all logic operations in topological order. @@ -69,8 +69,8 @@ class LogicSim(sim.SimOps): if inject_cb is None: _prop_cpu(self.ops, self.c_locs, self.c) else: - for op, o0, i0, i1, i2, i3 in self.ops[:,:6]: - o0, i0, i1, i2, i3 = [self.c_locs[x] for x in (o0, i0, i1, i2, i3)] + for op, o0l, i0l, i1l, i2l, i3l in self.ops[:,:6]: + o0, i0, i1, i2, i3 = [self.c_locs[x] for x in (o0l, i0l, i1l, i2l, i3l)] if op == sim.BUF1: self.c[o0]=self.c[i0] elif op == sim.INV1: self.c[o0] = ~self.c[i0] elif op == sim.AND2: self.c[o0] = self.c[i0] & self.c[i1] @@ -105,10 +105,10 @@ class LogicSim(sim.SimOps): elif op == sim.OAI211:self.c[o0] = ~((self.c[i0] | self.c[i1]) & self.c[i2] & self.c[i3]) elif op == sim.MUX21: self.c[o0] = (self.c[i0] & ~self.c[i2]) | (self.c[i1] & self.c[i2]) else: print(f'unknown op {op}') - inject_cb(o0, self.c[o0]) + inject_cb(o0l, self.c[o0]) elif self.m == 4: - for op, o0, i0, i1, i2, i3 in self.ops[:,:6]: - o0, i0, i1, i2, i3 = [self.c_locs[x] for x in (o0, i0, i1, i2, i3)] + for op, o0l, i0l, i1l, i2l, i3l in self.ops[:,:6]: + o0, i0, i1, i2, i3 = [self.c_locs[x] for x in (o0l, i0l, i1l, i2l, i3l)] if op == sim.BUF1: self.c[o0]=self.c[i0] elif op == sim.INV1: logic.bp4v_not(self.c[o0], self.c[i0]) elif op == sim.AND2: logic.bp4v_and(self.c[o0], self.c[i0], self.c[i1]) @@ -181,10 +181,10 @@ class LogicSim(sim.SimOps): logic.bp4v_and(self.c[t1], self.c[i1], self.c[i2]) logic.bp4v_or(self.c[o0], self.c[t0], self.c[t1]) else: print(f'unknown op {op}') - if inject_cb is not None: inject_cb(o0, self.c[o0]) + if inject_cb is not None: inject_cb(o0l, self.c[o0]) else: - for op, o0, i0, i1, i2, i3 in self.ops[:,:6]: - o0, i0, i1, i2, i3 = [self.c_locs[x] for x in (o0, i0, i1, i2, i3)] + for op, o0l, i0l, i1l, i2l, i3l in self.ops[:,:6]: + o0, i0, i1, i2, i3 = [self.c_locs[x] for x in (o0l, i0l, i1l, i2l, i3l)] if op == sim.BUF1: self.c[o0]=self.c[i0] elif op == sim.INV1: logic.bp8v_not(self.c[o0], self.c[i0]) elif op == sim.AND2: logic.bp8v_and(self.c[o0], self.c[i0], self.c[i1]) @@ -257,7 +257,7 @@ class LogicSim(sim.SimOps): logic.bp8v_and(self.c[t1], self.c[i1], self.c[i2]) logic.bp8v_or(self.c[o0], self.c[t0], self.c[t1]) else: print(f'unknown op {op}') - if inject_cb is not None: inject_cb(o0, self.c[o0]) + if inject_cb is not None: inject_cb(o0l, self.c[o0]) def c_to_s(self): """Copies (captures) the results of the combinational portion to ``s[1]``.