| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -91,13 +91,16 @@ class LogicSim: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    if line is not None: self.state_epoch[line.reader] = self.epoch | 
					 | 
					 | 
					 | 
					                    if line is not None: self.state_epoch[line.reader] = self.epoch | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return stimuli | 
					 | 
					 | 
					 | 
					        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). | 
					 | 
					 | 
					 | 
					        """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 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. | 
					 | 
					 | 
					 | 
					        :param responses: A bit-parallel storage target for the responses in a compatible shape. | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        :type responses: :py:class:`~kyupy.logic.BPArray` | 
					 | 
					 | 
					 | 
					        :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. | 
					 | 
					 | 
					 | 
					        :returns: The given responses object. | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        """ | 
					 | 
					 | 
					 | 
					        """ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        for node, resp in zip(self.interface, responses.data if hasattr(responses, 'data') else responses): | 
					 | 
					 | 
					 | 
					        for node, resp in zip(self.interface, responses.data if hasattr(responses, 'data') else responses): | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -106,15 +109,16 @@ class LogicSim: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                resp[...] = self.state[node.outs[0]] | 
					 | 
					 | 
					 | 
					                resp[...] = self.state[node.outs[0]] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            else: | 
					 | 
					 | 
					 | 
					            else: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                resp[...] = self.state[node.ins[0]] | 
					 | 
					 | 
					 | 
					                resp[...] = self.state[node.ins[0]] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            # FIXME: unclear why we should use outs for DFFs | 
					 | 
					 | 
					 | 
					            if not ff_transitions: continue | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            #if self.m > 2 and 'dff' in node.kind.lower() and len(node.outs) > 0: | 
					 | 
					 | 
					 | 
					            # outs of DFFs contain the previously assigned value (previous state) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            #    if node.outs[0] is None: | 
					 | 
					 | 
					 | 
					            if self.m > 2 and 'dff' in node.kind.lower() and len(node.outs) > 0: | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            #        resp[1, :] = ~self.state[node.outs[1], 0, :]  # assume QN is connected, take inverse of that. | 
					 | 
					 | 
					 | 
					                if node.outs[0] is None: | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            #    else: | 
					 | 
					 | 
					 | 
					                    resp[1, :] = ~self.state[node.outs[1], 0, :]  # assume QN is connected, take inverse of that. | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            #        resp[1, :] = self.state[node.outs[0], 0, :] | 
					 | 
					 | 
					 | 
					                else: | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            #    if self.m > 4: | 
					 | 
					 | 
					 | 
					                    resp[1, :] = self.state[node.outs[0], 0, :] | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            #        resp[..., 2, :] = resp[..., 0, :] ^ resp[..., 1, :] | 
					 | 
					 | 
					 | 
					                if self.m > 4: | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            #    # We don't handle X or - correctly. | 
					 | 
					 | 
					 | 
					                    resp[..., 2, :] = resp[..., 0, :] ^ resp[..., 1, :] | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                # FIXME: We don't handle X or - correctly. | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return responses | 
					 | 
					 | 
					 | 
					        return responses | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |