Exemple #1
0
def test_shift_ts():
    no = 2
    io = 0
    ni = 4
    test_vals = [[0, 1, 2, 3], [4, 5, 6, 7]]
    shifted_test_vals = [[int_to_ignore, int_to_ignore, 0, 1], [2, 3, 4, 5]]
    shift_amount = 2
    in_type = ST_TSeq(no, io, ST_SSeq(ni, ST_Int()))

    rshift = DefineShift_TS(no,
                            io,
                            ni,
                            shift_amount,
                            in_type.t.t,
                            has_valid=True)

    tester = fault.Tester(rshift, rshift.CLK)

    tester.circuit.valid_up = 1
    for clk in range(len(test_vals)):
        tester.print("clk: {}".format(clk))
        set_nested_port(tester, tester.circuit.I, test_vals[clk], 1, 0)
        print_nested_port(tester, tester.circuit.I, 1)
        tester.print("\n")
        tester.eval()
        #for i, val in enumerate(test_vals[i*ni+shift_amount:(i+1)*ni+shift_amount]):
        print_nested_port(tester, tester.circuit.O, 1)
        tester.print("\n")
        expect_nested_port(tester, tester.circuit.O, shifted_test_vals[clk], 1,
                           0)
        tester.circuit.valid_down.expect(1)
        tester.step(2)
    compile_and_run(tester)
        fault_helpers.print_nested_port(
            tester, tester.circuit.fst_conv_in,
            num_nested_space_layers(
                ST_TSeq(32, 32, ST_SSeq(2, ST_SSeq(3, ST_TSeq(3, 0,
                                                              ST_Int()))))))
        tester.print("\n")
        tester.print("first down in: ")
        fault_helpers.print_nested_port(
            tester, tester.circuit.fst_down_in,
            num_nested_space_layers(
                ST_TSeq(32, 32, ST_SSeq(2, ST_SSeq(1, ST_TSeq(1, 2,
                                                              ST_Int()))))))
        tester.print("\n")
        tester.print("first down out: ")
        fault_helpers.print_nested_port(
            tester, tester.circuit.fst_down_out,
            num_nested_space_layers(
                ST_TSeq(32, 32, ST_SSeq(1, ST_SSeq(1, ST_TSeq(1, 2,
                                                              ST_Int()))))))
        tester.print("\n")
        if f_clk >= 118:
            tester.circuit.valid_down.expect(1)
        if f_clk >= 118 and fault_output_valid[output_counter]:
            fault_helpers.expect_nested_port(
                tester, tester.circuit.O, fault_output[output_counter],
                num_nested_space_layers(
                    ST_TSeq(4, 60, ST_SSeq(1, ST_TSeq(1, 2, ST_Int())))), 0)
        tester.step(2)
    tester.circuit.valid_down.expect(0)
    fault_helpers.compile_and_run(tester)