|
|
|
@ -95,7 +95,15 @@ class LogicSim(sim.SimOps):
@@ -95,7 +95,15 @@ class LogicSim(sim.SimOps):
|
|
|
|
|
elif op == sim.XNOR2: self.c[o0] = ~(self.c[i0] ^ self.c[i1]) |
|
|
|
|
elif op == sim.XNOR3: self.c[o0] = ~(self.c[i0] ^ self.c[i1] ^ self.c[i2]) |
|
|
|
|
elif op == sim.XNOR4: self.c[o0] = ~(self.c[i0] ^ self.c[i1] ^ self.c[i2] ^ self.c[i3]) |
|
|
|
|
elif op == sim.AO21: self.c[o0] = (self.c[i0] & self.c[i1]) | self.c[i2] |
|
|
|
|
elif op == sim.AOI21: self.c[o0] = ~((self.c[i0] & self.c[i1]) | self.c[i2]) |
|
|
|
|
elif op == sim.OA21: self.c[o0] = (self.c[i0] | self.c[i1]) & self.c[i2] |
|
|
|
|
elif op == sim.OAI21: self.c[o0] = ~((self.c[i0] | self.c[i1]) & self.c[i2]) |
|
|
|
|
elif op == sim.AO22: self.c[o0] = (self.c[i0] & self.c[i1]) | (self.c[i2] & self.c[i3]) |
|
|
|
|
elif op == sim.AOI22: self.c[o0] = ~((self.c[i0] & self.c[i1]) | (self.c[i2] & self.c[i3])) |
|
|
|
|
elif op == sim.OA22: self.c[o0] = (self.c[i0] | self.c[i1]) & (self.c[i2] | self.c[i3]) |
|
|
|
|
elif op == sim.OAI22: 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.s[o0]) |
|
|
|
|
elif self.m == 4: |
|
|
|
@ -121,10 +129,43 @@ class LogicSim(sim.SimOps):
@@ -121,10 +129,43 @@ class LogicSim(sim.SimOps):
|
|
|
|
|
elif op == sim.XNOR2: logic.bp4v_xor(self.c[o0], self.c[i0], self.c[i1]); logic.bp4v_not(self.c[o0], self.c[o0]) |
|
|
|
|
elif op == sim.XNOR3: logic.bp4v_xor(self.c[o0], self.c[i0], self.c[i1], self.c[i2]); logic.bp4v_not(self.c[o0], self.c[o0]) |
|
|
|
|
elif op == sim.XNOR4: logic.bp4v_xor(self.c[o0], self.c[i0], self.c[i1], self.c[i2], self.c[i3]); logic.bp4v_not(self.c[o0], self.c[o0]) |
|
|
|
|
elif op == sim.AO21: |
|
|
|
|
logic.bp4v_and(self.c[self.c_locs[self.tmp_idx]], self.c[i0], self.c[i1]) |
|
|
|
|
logic.bp4v_or(self.c[o0], self.c[self.c_locs[self.tmp_idx]], self.c[i2]) |
|
|
|
|
elif op == sim.AOI21: |
|
|
|
|
logic.bp4v_and(self.c[self.c_locs[self.tmp_idx]], self.c[i0], self.c[i1]) |
|
|
|
|
logic.bp4v_or(self.c[o0], self.c[self.c_locs[self.tmp_idx]], self.c[i2]) |
|
|
|
|
logic.bp4v_not(self.c[o0], self.c[o0]) |
|
|
|
|
elif op == sim.OA21: |
|
|
|
|
logic.bp4v_or(self.c[self.c_locs[self.tmp_idx]], self.c[i0], self.c[i1]) |
|
|
|
|
logic.bp4v_and(self.c[o0], self.c[self.c_locs[self.tmp_idx]], self.c[i2]) |
|
|
|
|
elif op == sim.OAI21: |
|
|
|
|
logic.bp4v_or(self.c[self.c_locs[self.tmp_idx]], self.c[i0], self.c[i1]) |
|
|
|
|
logic.bp4v_and(self.c[o0], self.c[self.c_locs[self.tmp_idx]], self.c[i2]) |
|
|
|
|
logic.bp4v_not(self.c[o0], self.c[o0]) |
|
|
|
|
elif op == sim.AO22: |
|
|
|
|
logic.bp4v_and(self.c[self.c_locs[self.tmp_idx]], self.c[i0], self.c[i1]) |
|
|
|
|
logic.bp4v_and(self.c[self.c_locs[self.tmp2_idx]], self.c[i2], self.c[i3]) |
|
|
|
|
logic.bp4v_or(self.c[o0], self.c[self.c_locs[self.tmp_idx]], self.c[self.c_locs[self.tmp2_idx]]) |
|
|
|
|
elif op == sim.AOI22: |
|
|
|
|
logic.bp4v_and(self.c[self.c_locs[self.tmp_idx]], self.c[i0], self.c[i1]) |
|
|
|
|
logic.bp4v_and(self.c[self.c_locs[self.tmp2_idx]], self.c[i2], self.c[i3]) |
|
|
|
|
logic.bp4v_or(self.c[o0], self.c[self.c_locs[self.tmp_idx]], self.c[self.c_locs[self.tmp2_idx]]) |
|
|
|
|
logic.bp4v_not(self.c[o0], self.c[o0]) |
|
|
|
|
elif op == sim.OA22: |
|
|
|
|
logic.bp4v_or(self.c[self.c_locs[self.tmp_idx]], self.c[i0], self.c[i1]) |
|
|
|
|
logic.bp4v_or(self.c[self.c_locs[self.tmp2_idx]], self.c[i2], self.c[i3]) |
|
|
|
|
logic.bp4v_and(self.c[o0], self.c[self.c_locs[self.tmp_idx]], self.c[self.c_locs[self.tmp2_idx]]) |
|
|
|
|
elif op == sim.OAI22: |
|
|
|
|
logic.bp4v_or(self.c[self.c_locs[self.tmp_idx]], self.c[i0], self.c[i1]) |
|
|
|
|
logic.bp4v_or(self.c[self.c_locs[self.tmp2_idx]], self.c[i2], self.c[i3]) |
|
|
|
|
logic.bp4v_and(self.c[o0], self.c[self.c_locs[self.tmp_idx]], self.c[self.c_locs[self.tmp2_idx]]) |
|
|
|
|
logic.bp4v_not(self.c[o0], self.c[o0]) |
|
|
|
|
elif op == sim.MUX21: |
|
|
|
|
logic.bp4v_not(self.c[self.c_locs[self.tmp2_idx]], self.c[i2]) |
|
|
|
|
logic.bp4v_and(self.c[self.c_locs[self.tmp_idx]], self.c[i0], self.c[self.c_locs[self.tmp2_idx]]) |
|
|
|
|
logic.bp4v_and(self.c[self.c_locs[self.tmp2_idx]], self.c[i1], self.c[i2]) |
|
|
|
|
logic.bp4v_or(self.c[o0], self.c[self.c_locs[self.tmp_idx]], self.c[self.c_locs[self.tmp2_idx]]) |
|
|
|
|
else: print(f'unknown op {op}') |
|
|
|
|
else: |
|
|
|
|
for op, o0, i0, i1, i2, i3 in self.ops: |
|
|
|
@ -149,10 +190,43 @@ class LogicSim(sim.SimOps):
@@ -149,10 +190,43 @@ class LogicSim(sim.SimOps):
|
|
|
|
|
elif op == sim.XNOR2: logic.bp8v_xor(self.c[o0], self.c[i0], self.c[i1]); logic.bp8v_not(self.c[o0], self.c[o0]) |
|
|
|
|
elif op == sim.XNOR3: logic.bp8v_xor(self.c[o0], self.c[i0], self.c[i1], self.c[i2]); logic.bp8v_not(self.c[o0], self.c[o0]) |
|
|
|
|
elif op == sim.XNOR4: logic.bp8v_xor(self.c[o0], self.c[i0], self.c[i1], self.c[i2], self.c[i3]); logic.bp8v_not(self.c[o0], self.c[o0]) |
|
|
|
|
elif op == sim.AO21: |
|
|
|
|
logic.bp8v_and(self.c[self.c_locs[self.tmp_idx]], self.c[i0], self.c[i1]) |
|
|
|
|
logic.bp8v_or(self.c[o0], self.c[self.c_locs[self.tmp_idx]], self.c[i2]) |
|
|
|
|
elif op == sim.AOI21: |
|
|
|
|
logic.bp8v_and(self.c[self.c_locs[self.tmp_idx]], self.c[i0], self.c[i1]) |
|
|
|
|
logic.bp8v_or(self.c[o0], self.c[self.c_locs[self.tmp_idx]], self.c[i2]) |
|
|
|
|
logic.bp8v_not(self.c[o0], self.c[o0]) |
|
|
|
|
elif op == sim.OA21: |
|
|
|
|
logic.bp8v_or(self.c[self.c_locs[self.tmp_idx]], self.c[i0], self.c[i1]) |
|
|
|
|
logic.bp8v_and(self.c[o0], self.c[self.c_locs[self.tmp_idx]], self.c[i2]) |
|
|
|
|
elif op == sim.OAI21: |
|
|
|
|
logic.bp8v_or(self.c[self.c_locs[self.tmp_idx]], self.c[i0], self.c[i1]) |
|
|
|
|
logic.bp8v_and(self.c[o0], self.c[self.c_locs[self.tmp_idx]], self.c[i2]) |
|
|
|
|
logic.bp8v_not(self.c[o0], self.c[o0]) |
|
|
|
|
elif op == sim.AO22: |
|
|
|
|
logic.bp8v_and(self.c[self.c_locs[self.tmp_idx]], self.c[i0], self.c[i1]) |
|
|
|
|
logic.bp8v_and(self.c[self.c_locs[self.tmp2_idx]], self.c[i2], self.c[i3]) |
|
|
|
|
logic.bp8v_or(self.c[o0], self.c[self.c_locs[self.tmp_idx]], self.c[self.c_locs[self.tmp2_idx]]) |
|
|
|
|
elif op == sim.AOI22: |
|
|
|
|
logic.bp8v_and(self.c[self.c_locs[self.tmp_idx]], self.c[i0], self.c[i1]) |
|
|
|
|
logic.bp8v_and(self.c[self.c_locs[self.tmp2_idx]], self.c[i2], self.c[i3]) |
|
|
|
|
logic.bp8v_or(self.c[o0], self.c[self.c_locs[self.tmp_idx]], self.c[self.c_locs[self.tmp2_idx]]) |
|
|
|
|
logic.bp8v_not(self.c[o0], self.c[o0]) |
|
|
|
|
elif op == sim.OA22: |
|
|
|
|
logic.bp8v_or(self.c[self.c_locs[self.tmp_idx]], self.c[i0], self.c[i1]) |
|
|
|
|
logic.bp8v_or(self.c[self.c_locs[self.tmp2_idx]], self.c[i2], self.c[i3]) |
|
|
|
|
logic.bp8v_and(self.c[o0], self.c[self.c_locs[self.tmp_idx]], self.c[self.c_locs[self.tmp2_idx]]) |
|
|
|
|
elif op == sim.OAI22: |
|
|
|
|
logic.bp8v_or(self.c[self.c_locs[self.tmp_idx]], self.c[i0], self.c[i1]) |
|
|
|
|
logic.bp8v_or(self.c[self.c_locs[self.tmp2_idx]], self.c[i2], self.c[i3]) |
|
|
|
|
logic.bp8v_and(self.c[o0], self.c[self.c_locs[self.tmp_idx]], self.c[self.c_locs[self.tmp2_idx]]) |
|
|
|
|
logic.bp8v_not(self.c[o0], self.c[o0]) |
|
|
|
|
elif op == sim.MUX21: |
|
|
|
|
logic.bp8v_not(self.c[self.c_locs[self.tmp2_idx]], self.c[i2]) |
|
|
|
|
logic.bp8v_and(self.c[self.c_locs[self.tmp_idx]], self.c[i0], self.c[self.c_locs[self.tmp2_idx]]) |
|
|
|
|
logic.bp8v_and(self.c[self.c_locs[self.tmp2_idx]], self.c[i1], self.c[i2]) |
|
|
|
|
logic.bp8v_or(self.c[o0], self.c[self.c_locs[self.tmp_idx]], self.c[self.c_locs[self.tmp2_idx]]) |
|
|
|
|
else: print(f'unknown op {op}') |
|
|
|
|
if inject_cb is not None: inject_cb(o0, self.s[o0]) |
|
|
|
|
|
|
|
|
@ -211,5 +285,13 @@ def _prop_cpu(ops, c_locs, c):
@@ -211,5 +285,13 @@ def _prop_cpu(ops, c_locs, c):
|
|
|
|
|
elif op == sim.XNOR2: c[o0] = ~(c[i0] ^ c[i1]) |
|
|
|
|
elif op == sim.XNOR3: c[o0] = ~(c[i0] ^ c[i1] ^ c[i2]) |
|
|
|
|
elif op == sim.XNOR4: c[o0] = ~(c[i0] ^ c[i1] ^ c[i2] ^ c[i3]) |
|
|
|
|
elif op == sim.AO21: c[o0] = (c[i0] & c[i1]) | c[i2] |
|
|
|
|
elif op == sim.AOI21: c[o0] = ~((c[i0] & c[i1]) | c[i2]) |
|
|
|
|
elif op == sim.OA21: c[o0] = (c[i0] | c[i1]) & c[i2] |
|
|
|
|
elif op == sim.OAI21: c[o0] = ~((c[i0] | c[i1]) & c[i2]) |
|
|
|
|
elif op == sim.AO22: c[o0] = (c[i0] & c[i1]) | (c[i2] & c[i3]) |
|
|
|
|
elif op == sim.AOI22: c[o0] = ~((c[i0] & c[i1]) | (c[i2] & c[i3])) |
|
|
|
|
elif op == sim.OA22: c[o0] = (c[i0] | c[i1]) & (c[i2] | c[i3]) |
|
|
|
|
elif op == sim.OAI22: c[o0] = ~((c[i0] | c[i1]) & (c[i2] | c[i3])) |
|
|
|
|
elif op == sim.MUX21: c[o0] = (c[i0] & ~c[i2]) | (c[i1] & c[i2]) |
|
|
|
|
else: print(f'unknown op {op}') |
|
|
|
|