Browse Source

ff transitions switch

devel
Stefan Holst 2 years ago
parent
commit
faf41f0863
  1. 26
      src/kyupy/logic_sim.py

26
src/kyupy/logic_sim.py

@ -91,13 +91,16 @@ class LogicSim: @@ -91,13 +91,16 @@ class LogicSim:
if line is not None: self.state_epoch[line.reader] = self.epoch
return stimuli
def capture(self, responses):
def capture(self, responses, ff_transitions=False):
"""Capture the current values at the primary outputs and in the state-elements (flip-flops).
For primary outputs, the logic value is stored unmodified in the given target array.
For flip-flops, the logic value is constructed from the previous state and the new state.
For flip-flops, the logic value is either stored unmodified (`ff_transitions=False`)
or constructed from the previous state and the new state (`ff_transitions=True`).
:param responses: A bit-parallel storage target for the responses in a compatible shape.
:type responses: :py:class:`~kyupy.logic.BPArray`
:param ff_transitions: If true, calculate and store the transitions between the previous state
(the currently assigned pattern) and the new state.
:returns: The given responses object.
"""
for node, resp in zip(self.interface, responses.data if hasattr(responses, 'data') else responses):
@ -106,15 +109,16 @@ class LogicSim: @@ -106,15 +109,16 @@ class LogicSim:
resp[...] = self.state[node.outs[0]]
else:
resp[...] = self.state[node.ins[0]]
# FIXME: unclear why we should use outs for DFFs
#if self.m > 2 and 'dff' in node.kind.lower() and len(node.outs) > 0:
# if node.outs[0] is None:
# resp[1, :] = ~self.state[node.outs[1], 0, :] # assume QN is connected, take inverse of that.
# else:
# resp[1, :] = self.state[node.outs[0], 0, :]
# if self.m > 4:
# resp[..., 2, :] = resp[..., 0, :] ^ resp[..., 1, :]
# # We don't handle X or - correctly.
if not ff_transitions: continue
# outs of DFFs contain the previously assigned value (previous state)
if self.m > 2 and 'dff' in node.kind.lower() and len(node.outs) > 0:
if node.outs[0] is None:
resp[1, :] = ~self.state[node.outs[1], 0, :] # assume QN is connected, take inverse of that.
else:
resp[1, :] = self.state[node.outs[0], 0, :]
if self.m > 4:
resp[..., 2, :] = resp[..., 0, :] ^ resp[..., 1, :]
# FIXME: We don't handle X or - correctly.
return responses

Loading…
Cancel
Save