Example #1
0
def generate_random_test_vectors(circuit,
                                 functional_model,
                                 num_vectors=10,
                                 input_mapping=None):
    tester = fault.Tester(circuit)

    for i in range(num_vectors):
        inputs = []
        for name, port in circuit.interface.items():
            if port.is_input():
                inputs.append(get_random_input(name, port))
                tester.poke(getattr(circuit, name), inputs[-1])
        tester.eval()
        # Used to handle differences between circuit's interface and
        # functional_model interface. For example, the simple_cb interface
        # is packed for the genesis version
        if input_mapping:
            inputs = input_mapping(*inputs)
        functional_model(*inputs)
        for name, port in circuit.interface.items():
            if port.is_output():
                # Handle renamed output ports
                fn_model_port = get_renamed_port(circuit, name)
                tester.expect(getattr(circuit, name),
                              getattr(functional_model, fn_model_port))
    return tester.test_vectors
Example #2
0
 def eval(self):
     super().eval()
     for name, port in self._circuit.interface.ports.items():
         if port.is_input():
             fn_model_port = get_renamed_port(self._circuit, name)
             super().expect(port,
                            getattr(self.functional_model, fn_model_port))
Example #3
0
def generate_actions_from_streams(circuit,
                                  functional_model,
                                  streams,
                                  num_vectors=10,
                                  input_mapping=None):
    tester = fault.Tester(circuit)

    for i in range(num_vectors):
        inputs = []
        for name, stream in streams.items():
            if callable(stream):
                val = stream(name, getattr(circuit, name))
            else:
                val = stream
            inputs.append(val)
            # stream_port = get_renamed_port(circuit, name)
            tester.poke(getattr(circuit, name), inputs[-1])
        tester.eval()
        # Used to handle differences between circuit's interface and
        # functional_model interface. For example, the simple_cb interface
        # is packed for the genesis version
        if input_mapping:
            inputs = input_mapping(*inputs)
        functional_model(*inputs)
        for name, port in circuit.interface.items():
            if port.isoutput():
                # Handle renamed output ports
                fn_model_port = get_renamed_port(circuit, name)
                tester.expect(getattr(circuit, name),
                              getattr(functional_model, fn_model_port))
    return tester.actions
Example #4
0
 def expect_any_outputs(self):
     for name, port in self._circuit.interface.ports.items():
         if port.is_input():
             fn_model_port = get_renamed_port(self._circuit, name)
             setattr(self.functional_model, fn_model_port, AnyValue)