|
|
|
@ -95,7 +95,7 @@ class LogicSim(SimOps):
@@ -95,7 +95,7 @@ class LogicSim(SimOps):
|
|
|
|
|
:type stimuli: :py:class:`~kyupy.logic.BPArray` |
|
|
|
|
:returns: The given stimuli object. |
|
|
|
|
""" |
|
|
|
|
self.c[self.pippi_c_locs] = self.s[0, self.pippi_s_locs] |
|
|
|
|
self.c[self.pippi_c_locs] = self.s[0, self.pippi_s_locs, :self.mdim] |
|
|
|
|
# for node, stim in zip(self.interface, stimuli.data if hasattr(stimuli, 'data') else stimuli): |
|
|
|
|
# if len(node.outs) == 0: continue |
|
|
|
|
# if node.index in self.latch_dict: |
|
|
|
@ -125,7 +125,10 @@ class LogicSim(SimOps):
@@ -125,7 +125,10 @@ class LogicSim(SimOps):
|
|
|
|
|
(the currently assigned pattern) and the new state. |
|
|
|
|
:returns: The given responses object. |
|
|
|
|
""" |
|
|
|
|
self.s[1, self.poppo_s_locs] = self.c[self.poppo_c_locs] |
|
|
|
|
self.s[1, self.poppo_s_locs, :self.mdim] = self.c[self.poppo_c_locs] |
|
|
|
|
if self.mdim == 1: |
|
|
|
|
self.s[1, self.poppo_s_locs, 1:2] = self.c[self.poppo_c_locs] |
|
|
|
|
|
|
|
|
|
# for node, resp in zip(self.interface, responses.data if hasattr(responses, 'data') else responses): |
|
|
|
|
# if len(node.ins) == 0: continue |
|
|
|
|
# if node.index in self.latch_dict: |
|
|
|
@ -165,18 +168,35 @@ class LogicSim(SimOps):
@@ -165,18 +168,35 @@ class LogicSim(SimOps):
|
|
|
|
|
resumes with the manipulated values after the callback returns. |
|
|
|
|
:type inject_cb: ``f(Line, ndarray)`` |
|
|
|
|
""" |
|
|
|
|
for op, o0, i0, i1, i2, i3 in self.ops: |
|
|
|
|
o0, i0, i1, i2, i3 = [self.vat[x,0] for x in (o0, i0, i1, i2, i3)] |
|
|
|
|
if op == SimPrim.BUF1: self.c[o0]=self.c[i0] |
|
|
|
|
elif op == SimPrim.INV1: logic.bp_not(self.c[o0], self.c[i0]) |
|
|
|
|
elif op == SimPrim.AND2: logic.bp_and(self.c[o0], self.c[i0], self.c[i1]) |
|
|
|
|
elif op == SimPrim.NAND2: logic.bp_and(self.c[o0], self.c[i0], self.c[i1]); logic.bp_not(self.c[o0], self.c[o0]) |
|
|
|
|
elif op == SimPrim.OR2: logic.bp_or(self.c[o0], self.c[i0], self.c[i1]) |
|
|
|
|
elif op == SimPrim.NOR2: logic.bp_or(self.c[o0], self.c[i0], self.c[i1]); logic.bp_not(self.c[o0], self.c[o0]) |
|
|
|
|
elif op == SimPrim.XOR2: logic.bp_xor(self.c[o0], self.c[i0], self.c[i1]) |
|
|
|
|
elif op == SimPrim.XNOR2: logic.bp_xor(self.c[o0], self.c[i0], self.c[i1]); logic.bp_not(self.c[o0], self.c[o0]) |
|
|
|
|
else: print(f'unknown SimPrim {op}') |
|
|
|
|
if inject_cb is not None: inject_cb(o0, self.s[o0]) |
|
|
|
|
if self.m == 2: |
|
|
|
|
for op, o0, i0, i1, i2, i3 in self.ops: |
|
|
|
|
o0, i0, i1, i2, i3 = [self.vat[x,0] for x in (o0, i0, i1, i2, i3)] |
|
|
|
|
if op == SimPrim.BUF1: self.c[o0]=self.c[i0] |
|
|
|
|
elif op == SimPrim.INV1: self.c[o0] = ~self.c[i0] |
|
|
|
|
elif op == SimPrim.AND2: self.c[o0] = self.c[i0] & self.c[i1] |
|
|
|
|
elif op == SimPrim.NAND2: self.c[o0] = ~(self.c[i0] & self.c[i1]) |
|
|
|
|
elif op == SimPrim.OR2: self.c[o0] = self.c[i0] | self.c[i1] |
|
|
|
|
elif op == SimPrim.NOR2: self.c[o0] = ~(self.c[i0] | self.c[i1]) |
|
|
|
|
elif op == SimPrim.XOR2: self.c[o0] = self.c[i0] ^ self.c[i1] |
|
|
|
|
elif op == SimPrim.XNOR2: self.c[o0] = ~(self.c[i0] ^ self.c[i1]) |
|
|
|
|
else: print(f'unknown SimPrim {op}') |
|
|
|
|
if inject_cb is not None: inject_cb(o0, self.s[o0]) |
|
|
|
|
pass |
|
|
|
|
elif self.m == 4: |
|
|
|
|
pass |
|
|
|
|
else: |
|
|
|
|
for op, o0, i0, i1, i2, i3 in self.ops: |
|
|
|
|
o0, i0, i1, i2, i3 = [self.vat[x,0] for x in (o0, i0, i1, i2, i3)] |
|
|
|
|
if op == SimPrim.BUF1: self.c[o0]=self.c[i0] |
|
|
|
|
elif op == SimPrim.INV1: logic.bp_not(self.c[o0], self.c[i0]) |
|
|
|
|
elif op == SimPrim.AND2: logic.bp_and(self.c[o0], self.c[i0], self.c[i1]) |
|
|
|
|
elif op == SimPrim.NAND2: logic.bp_and(self.c[o0], self.c[i0], self.c[i1]); logic.bp_not(self.c[o0], self.c[o0]) |
|
|
|
|
elif op == SimPrim.OR2: logic.bp_or(self.c[o0], self.c[i0], self.c[i1]) |
|
|
|
|
elif op == SimPrim.NOR2: logic.bp_or(self.c[o0], self.c[i0], self.c[i1]); logic.bp_not(self.c[o0], self.c[o0]) |
|
|
|
|
elif op == SimPrim.XOR2: logic.bp_xor(self.c[o0], self.c[i0], self.c[i1]) |
|
|
|
|
elif op == SimPrim.XNOR2: logic.bp_xor(self.c[o0], self.c[i0], self.c[i1]); logic.bp_not(self.c[o0], self.c[o0]) |
|
|
|
|
else: print(f'unknown SimPrim {op}') |
|
|
|
|
if inject_cb is not None: inject_cb(o0, self.s[o0]) |
|
|
|
|
# for node in self.circuit.topological_order(): |
|
|
|
|
# if self.state_epoch[node] != self.epoch: continue |
|
|
|
|
# inputs = [self.state[line] if line else self.zero for line in node.ins] |
|
|
|
|