示例#1
0
basic_msgs = [
    mk_req_msg(0x1034, 1, 4),
    None,
    mk_req_msg(0x2015, 0, 4),
    mk_resp_msg(0x4, 0, 4),
    mk_req_msg(0x1f31, 0, 4),
    mk_resp_msg(0x6, 0, 4),
    mk_req_msg(0xf752, 0, 4),
    mk_resp_msg(0xa, 0, 4),
]

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
    ("msgs       src_delay  sink_delay"),
    ["basic_0x0", basic_msgs, 0, 0],
])

#-------------------------------------------------------------------------
# Test cases
#-------------------------------------------------------------------------


@pytest.mark.parametrize(**test_case_table)
def test(test_params, dump_vcd):
    run_sim(
        TestHarness(MapperPRTL, test_params.msgs[::2], test_params.msgs[3::2],
                    test_params.src_delay, test_params.sink_delay), dump_vcd)
示例#2
0
sink_delay = random.randint(0,7)


#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
  (                      "msgs                 src_delay sink_delay"),
  [ "small_pos_pos",     small_pos_pos_msgs,   0,        0          ],
  [ "small_pos_neg",     small_pos_neg_msgs,   0,        0          ],
  [ "small_neg_pos",     small_neg_pos_msgs,   0,        0          ],
  [ "small_neg_neg",     small_neg_neg_msgs,   0,        0          ],
  [ "large_pos_pos",     large_pos_pos_msgs,   0,        0          ],
  [ "large_pos_neg",     large_pos_neg_msgs,   0,        0          ],
  [ "large_neg_pos",     large_neg_pos_msgs,   0,        0          ],
  [ "large_neg_neg",     large_neg_neg_msgs,   0,        0          ],
  [ "zero_mul",          zero_mul_msgs,        0,        0          ],
  [ "low_bit_masked",    low_mask_msgs,        0,        0          ],
  [ "mid_bit_masked",    mid_mask_msgs,        0,        0          ],
  [ "sparse_num_mul",    sparse_num_msgs,      0,        0          ],
  [ "dense_num_mul",     dense_num_msgs,       0,        0          ],
  [ "random_mul",        random_msgs,          0,        0          ],
  [ "random_mul_delay",  random_msgs,          src_delay,sink_delay ],
])
#-------------------------------------------------------------------------
# Test cases
#-------------------------------------------------------------------------

@pytest.mark.parametrize( **test_case_table )
def test( test_params, dump_vcd ):
  run_sim( TestHarness( IntMulFL(),
示例#3
0
#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
# LAB TASK:
#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

#-------------------------------------------------------------------------
# Test table for generic test
#-------------------------------------------------------------------------

test_case_table_generic = mk_test_case_table([
    ("msg_func               mem_data_func         nbank stall lat src sink"),
    ["read_hit_1word_clean", read_hit_1word_clean, None, 0, 0.0, 0, 0, 0],
    [
        "read_miss_1word", read_miss_1word_msg, read_miss_1word_mem, 0, 0.0, 0,
        0, 0
    ],
    ["read_hit_1word_4bank", read_hit_1word_clean, None, 4, 0.0, 0, 0, 0],

    #'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    # LAB TASK: Add test cases to this table
    #'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
])


@pytest.mark.parametrize(**test_case_table_generic)
def test_generic(test_params, dump_vcd):
    msgs = test_params.msg_func(0)
    if test_params.mem_data_func != None:
        mem = test_params.mem_data_func(0)
    # Instantiate testharness
    harness = TestHarness(msgs[::2], msgs[1::2], test_params.stall,
      new_data = rgen.randint(0,0xffffffffffffffffffffffffffffffff)
      vmem[idx] = new_data
      msgs.extend([
        req( 'wr', i%20, base_addr+16*idx, 0, new_data ), resp( 'wr', i%20, 0, 0 ),
      ])

  return msgs

#-------------------------------------------------------------------------
# Test table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
  (                "msg_func     mem_data_func   stall lat src sink"),
  [ "stream",       stream_msgs, None,           0.0,  0,  0,  0    ],
  [ "stream_stall", stream_msgs, None,           0.5,  4,  3,  14    ],
  [ "random",       random_msgs, None,           0.0,  0,  0,  0    ],
  [ "random_stall", random_msgs, None,           0.5,  4,  3,  14    ],
])

@pytest.mark.parametrize( **test_case_table )
def test_memnet( test_params, dump_vcd ):
  msgs = test_params.msg_func( 0 )
  if test_params.mem_data_func != None:
    mem = test_params.mem_data_func( 0 )
  # Instantiate testharness
  harness = TestHarness( msgs[::2], msgs[1::2],
                         test_params.stall, test_params.lat,
                         test_params.src, test_params.sink,
                         dump_vcd )
  # Load memory before the test
示例#5
0
random_msgs = []
for i in xrange(20):
    a = random.randint(0, 0xffff)
    b = random.randint(0, 0xffff)
    c = gcd(a, b)
    random_msgs.extend([[a, b, c]])

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
    #             delays
    #             --------
    ("msgs         src sink"),
    ["basic0x0", basic_msgs, 0, 0],
    ["basic0x5", basic_msgs, 0, 5],
    ["basic3x0", basic_msgs, 3, 0],
    ["basic2x1", basic_msgs, 2, 1],
    ["random0x0", random_msgs, 0, 0],
])

#-------------------------------------------------------------------------
# run_test
#-------------------------------------------------------------------------


def run_test(xcel, test_params, dump_vcd, test_verilog=False):

    # Protocol messages

    xreqs = list()
  return msg

#-------------------------------------------------------------------------
# Test Case: basic
#-------------------------------------------------------------------------

basic_msgs = [
  mk_req_msg( 1, 1 ), mk_resp_msg( 1 ), 
  mk_req_msg( 0, 1 ), mk_resp_msg( 0 ),
]

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
  (               "msgs       src_delay  sink_delay" ),
  [ "basic_0x0",  basic_msgs, 0,         0           ], 
])

#-------------------------------------------------------------------------
# Test cases
#-------------------------------------------------------------------------

@pytest.mark.parametrize( **test_case_table )
def test( test_params, dump_vcd ):
  run_sim( TestHarness( ReducerPRTL,
                        test_params.msgs[::2], test_params.msgs[1::2],
                        test_params.src_delay, test_params.sink_delay ),
           dump_vcd )
random.seed(0xdeadbeef)
random_msgs = []
for i in xrange(20):
  a = random.randint(0,0xffff)
  b = random.randint(0,0xffff)
  c = gcd( a, b )
  random_msgs.extend([ mk_req_msg( a, b ), c ])

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
  (               "msgs       src_delay sink_delay"),
  [ "basic_0x0",  basic_msgs, 0,        0          ],
  [ "basic_5x0",  basic_msgs, 5,        0          ],
  [ "basic_0x5",  basic_msgs, 0,        5          ],
  [ "basic_3x9",  basic_msgs, 3,        9          ],
  [ "random_3x9", basic_msgs, 3,        9          ],
])

#-------------------------------------------------------------------------
# Test cases
#-------------------------------------------------------------------------

@pytest.mark.parametrize( **test_case_table )
def test( test_params, dump_vcd ):
  run_sim( TestHarness( GcdUnitFL,
                        test_params.msgs[::2], test_params.msgs[1::2],
                        test_params.src_delay, test_params.sink_delay ),
           dump_vcd )
    data.append(L.split(','))
  for row in data:
    test_data.append(int(row[0], 16))
    result_data.append(int(row[1]))

small_test_data = []
small_result_data = []
for i in xrange(TEST_SIZE):
  small_test_data.append(int(data[i * (180/TEST_SIZE)][0],16))
  small_result_data.append(int(data[i * (180/TEST_SIZE)][1]))

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------
test_case_table = mk_test_case_table([
  (                  "data            result       stall  latency  src_delay  sink_delay" ),
  [ "small_0x0x0",   small_test_data, 1,           0,     0,       0,         0         ],
])

#-------------------------------------------------------------------------
# Run Test
#-------------------------------------------------------------------------

def run_test( digitrec, test_params, dump_vcd, test_verilog=False ):

  data       = test_params.data
  result     = test_params.result
  data_bytes = struct.pack("<{}Q".format(len(data)), *data)
  
  digitrec_protocol_msgs = gen_protocol_msgs( len(data), result )
  digitrec_reqs          = digitrec_protocol_msgs[::2]
  digitrec_resps         = digitrec_protocol_msgs[1::2]
        test_vector_table.append([input_, last_results.popleft()])
        last_results.append(Bits(8, input_ + nstages, trunc=True))

    return test_vector_table


#-------------------------------------------------------------------------
# Parameterized Testing with Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
    ("nstages inputs                "),
    ["2stage_small", 2, [0x00, 0x03, 0x06]],
    ["2stage_large", 2, [0xa0, 0xb3, 0xc6]],
    ["2stage_overflow", 2, [0x00, 0xfe, 0xff]],
    ["2stage_random", 2, sample(range(0xff), 20)],
    ["3stage_small", 3, [0x00, 0x03, 0x06]],
    ["3stage_large", 3, [0xa0, 0xb3, 0xc6]],
    ["3stage_overflow", 3, [0x00, 0xfe, 0xff]],
    ["3stage_random", 3, sample(range(0xff), 20)],
])


@pytest.mark.parametrize(**test_case_table)
def test(test_params, dump_vcd):
    nstages = test_params.nstages
    inputs = test_params.inputs
    run_test_vector_sim(RegIncrNstage(nstages),
                        mk_test_vector_table(nstages, inputs), dump_vcd)

#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
# LAB TASK: Add new test cases
#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
    ("msgs                routerid  src_delay sink_delay"),
    ["vbasic_0", very_basic_msgs(0), 0, 0, 0],
    ["vbasic_1", very_basic_msgs(1), 1, 0, 0],
    ["vbasic_2", very_basic_msgs(2), 2, 0, 0],
    ["vbasic_3", very_basic_msgs(3), 3, 0, 0],

    # ''' LAB TASK '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    # Add more rows to the test case table to leverage the additional lists
    # of request/response messages defined above, but also to test
    # different source/sink random delays.
    # ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
])

#-------------------------------------------------------------------------
# Run tests
#-------------------------------------------------------------------------


@pytest.mark.parametrize(**test_case_table)
def test(test_params, dump_vcd, test_verilog):
    run_router_test(RouterRTL(), test_params.routerid, test_params.src_delay,
small_data    = [ random.randint(0,0xffff)     for i in xrange(32) ]
large_data    = [ random.randint(0,0x7fffffff) for i in xrange(32) ]
sort_fwd_data = sorted(small_data)
sort_rev_data = list(reversed(sorted(small_data)))

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
                         #                delays   test mem
                         #                -------- ---------
  (                      "data            src sink stall lat"),
  [ "mini",               mini,           0,  0,   0,    0   ],
  [ "mini_delay_x4",      mini,           3, 14,   0.5,  2   ],
  [ "small_data",         small_data,     0,  0,   0,    0   ],
  [ "large_data",         large_data,     0,  0,   0,    0   ],
  [ "sort_fwd_data",      sort_fwd_data,  0,  0,   0,    0   ],
  [ "sort_rev_data",      sort_rev_data,  0,  0,   0,    0   ],
  [ "small_data_3x14x0",  small_data,     3, 14,   0,    0   ],
  [ "small_data_0x0x4",   small_data,     0,  0,   0.5,  4   ],
  [ "small_data_3x14x4",  small_data,     3, 14,   0.5,  4   ],
])

#-------------------------------------------------------------------------
# run_test
#-------------------------------------------------------------------------

def run_test( xcel, test_params, dump_vcd, test_verilog=False ):

  # Convert test data into byte array
    with open(filename, "r") as f:
        count = 0
        for L in f:
            small_train_data.append(int(L.replace(",\n", ""), 16))
            count += 1
            if count >= 10:
                break


# -------------------------------------------------------------------------
# Test Case Table
# -------------------------------------------------------------------------
test_case_table = mk_test_case_table(
    [
        ("data             ref              result       stall  latency  src_delay  sink_delay"),
        ["basic1_0x0x0", training_data, 0x3041060800, 1, 0, 0, 0, 0],
        ["small4_0x0x0", small_train_data, 0x41C3830408, 1, 0, 0, 0, 0],
    ]
)

# -------------------------------------------------------------------------
# Run Test
# -------------------------------------------------------------------------


def run_test(digitrec, test_params, dump_vcd, test_verilog=False):

    data = test_params.data
    ref = test_params.ref
    result = test_params.result
    data_bytes = struct.pack("<{}Q".format(len(data)), *data)
示例#13
0
  testHarness = TestHarness(dut, test_verilog)

  # Run the simulation
  run_sim(testHarness, False, max_cycles = max_cycles)

#-------------------------------------------------------------------------
# Test case: all
#-------------------------------------------------------------------------

all_msgs  = [
               # inst                    ex_id          ex_fn           v0 p0 tag0 data0 v1 p1 tag1 data1   wen wtag
]

#-------------------------------------------------------------------------
# Test case table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
  (             ),
  [ "default"   ],
])

#-------------------------------------------------------------------------
# Test cases
#-------------------------------------------------------------------------

@pytest.mark.parametrize( **test_case_table )
def test( test_params, dump_vcd, test_verilog ):
  run_test( modAll(), test_params, dump_vcd, test_verilog )
random.seed(0xdeadbeef)

basic_msgs  = [ 0, 1, 2, 3, 4 ]
random_msgs = [ random.randint(0,0xffff) for _ in range(20) ]

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
  (                       "msgs         stall_prob src_delay sink_delay"),
  [ "basic_stall0.0_0x0",  basic_msgs,  0,         0,        0          ],
  [ "random_stall0.0_0x0", random_msgs, 0,         0,        0          ],
  [ "random_stall0.0_9x0", random_msgs, 0,         9,        0          ],
  [ "random_stall0.0_0x9", random_msgs, 0,         0,        9          ],
  [ "random_stall0.0_9x9", random_msgs, 0,         9,        9          ],
  [ "random_stall0.5_0x0", random_msgs, 0.5,       0,        0          ],
  [ "random_stall0.5_9x0", random_msgs, 0.5,       9,        0          ],
  [ "random_stall0.5_0x9", random_msgs, 0.5,       0,        9          ],
  [ "random_stall0.5_9x9", random_msgs, 0.5,       9,        9          ],
])

#-------------------------------------------------------------------------
# Test cases
#-------------------------------------------------------------------------

@pytest.mark.parametrize( **test_case_table )
def test( test_params, dump_vcd ):
  run_sim( TestHarness( test_params.msgs, test_params.stall_prob,
                        test_params.src_delay, test_params.sink_delay ),
           dump_vcd )
  for input_ in inputs:
    test_vector_table.append( [ input_, last_results.popleft() ] )
    last_results.append( Bits( 8, input_ + nstages, trunc=True ) )

  return test_vector_table

#-------------------------------------------------------------------------
# Parameterized Testing with Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
  (                    "nstages inputs                "),
  [ "2stage_small",    2,       [ 0x00, 0x03, 0x06 ]   ],
  [ "2stage_large",    2,       [ 0xa0, 0xb3, 0xc6 ]   ],
  [ "2stage_overflow", 2,       [ 0x00, 0xfe, 0xff ]   ],
  [ "2stage_random",   2,       sample(range(0xff),20) ],
  [ "3stage_small",    3,       [ 0x00, 0x03, 0x06 ]   ],
  [ "3stage_large",    3,       [ 0xa0, 0xb3, 0xc6 ]   ],
  [ "3stage_overflow", 3,       [ 0x00, 0xfe, 0xff ]   ],
  [ "3stage_random",   3,       sample(range(0xff),20) ],
])

@pytest.mark.parametrize( **test_case_table )
def test( test_params, dump_vcd ):
  nstages = test_params.nstages
  inputs  = test_params.inputs
  run_test_vector_sim( RegIncrNstage( nstages ),
    mk_test_vector_table( nstages, inputs ), dump_vcd )

#-------------------------------------------------------------------------
# Parameterized Testing of With nstages = [ 1, 2, 3, 4, 5, 6 ]
示例#16
0
test_case_table = mk_test_case_table([
    ("msgs                routerid  src_delay sink_delay"),
    ["vbasic_0", very_basic_msgs(0), 0, 0, 0],
    ["vbasic_1", very_basic_msgs(1), 1, 0, 0],
    ["vbasic_2", very_basic_msgs(2), 2, 0, 0],
    ["vbasic_3", very_basic_msgs(3), 3, 0, 0],

    # ''' LAB TASK '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    # Add more rows to the test case table to leverage the additional lists
    # of request/response messages defined above, but also to test
    # different source/sink random delays.
    # ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ["basic_dest_0", basic_dest(0), 0, 0, 0],
    ["basic_dest_1", basic_dest(1), 1, 0, 0],
    ["basic_dest_2", basic_dest(2), 2, 0, 0],
    ["basic_dest_3", basic_dest(3), 3, 0, 0],
    ["pass_back_0", pass_back(0), 0, 0, 0],
    ["pass_back_1", pass_back(1), 1, 0, 0],
    ["pass_back_2", pass_back(2), 2, 0, 0],
    ["pass_back_3", pass_back(3), 3, 0, 0],
    ["to_self0", to_self(0), 0, 0, 0],
    ["to_self1", to_self(1), 1, 0, 0],
    ["to_self2", to_self(2), 2, 0, 0],
    ["to_self3", to_self(3), 3, 0, 0],
    ["route_neighbor0", route_neighbor(0), 0, 0, 0],
    ["route_neighbor1", route_neighbor(1), 1, 0, 0],
    ["route_neighbor2", route_neighbor(2), 2, 0, 0],
    ["route_neighbor3", route_neighbor(3), 3, 0, 0],
    ["break_ties0", break_ties(0), 0, 0, 0],
    ["break_ties1", break_ties(1), 1, 0, 0],
    ["break_ties2", break_ties(2), 2, 0, 0],
    ["break_ties3", break_ties(3), 3, 0, 0],
    ["back_pressure0", back_pressure(0), 0, 0, 45],
    ["back_pressure1", back_pressure(1), 1, 0, 45],
    ["back_pressure2", back_pressure(2), 2, 0, 45],
    ["back_pressure3", back_pressure(3), 3, 0, 45],
    ["dest_0_src_delay", basic_dest(0), 0, 6, 0],
    ["dest_1_src_delay", basic_dest(1), 1, 6, 0],
    ["dest_2_src_delay", basic_dest(2), 2, 6, 0],
    ["dest_3_src_delay", basic_dest(3), 3, 6, 0],
    ["dest_0_sink_delay", basic_dest(0), 0, 0, 3],
    ["dest_1_sink_delay", basic_dest(1), 1, 0, 1],
    ["dest_2_sink_delay", basic_dest(2), 2, 0, 1],
    ["dest_3_sink_delay", basic_dest(3), 3, 0, 1],
    ["basic_dest_0_delay", basic_dest(0), 0, 5, 5],
    ["basic_dest_1_delay", basic_dest(1), 1, 5, 5],
    ["basic_dest_2_delay", basic_dest(2), 2, 5, 5],
    ["basic_dest_3_delay", basic_dest(3), 3, 5, 5],
    ["back_0_src_delay", pass_back(0), 0, 6, 0],
    ["back_1_src_delay", pass_back(1), 1, 6, 0],
    ["back_2_src_delay", pass_back(2), 2, 6, 0],
    ["back_3_src_delay", pass_back(3), 3, 6, 0],
    ["back_0_sink_delay", pass_back(0), 0, 0, 6],
    ["back_1_sink_delay", pass_back(1), 1, 0, 6],
    ["back_2_sink_delay", pass_back(2), 2, 0, 6],
    ["back_3_sink_delay", pass_back(3), 3, 0, 6],
    ["pass_back_0_delay", pass_back(0), 0, 7, 6],
    ["pass_back_1_delay", pass_back(1), 1, 7, 6],
    ["pass_back_2_delay", pass_back(2), 2, 7, 6],
    ["pass_back_3_delay", pass_back(3), 3, 7, 6],
    ["to_self0_src_delay", to_self(0), 0, 6, 0],
    ["to_self1_src_delay", to_self(1), 1, 6, 0],
    ["to_self2_src_delay", to_self(2), 2, 6, 0],
    ["to_self3_src_delay", to_self(3), 3, 6, 0],
    ["route_neighbor0_src_src_delay",
     route_neighbor(0), 0, 4, 0],
    ["route_neighbor1_src_src_delay",
     route_neighbor(1), 1, 3, 0],
    ["route_neighbor2_src_src_delay",
     route_neighbor(2), 2, 6, 0],
    ["route_neighbor3_src_src_delay",
     route_neighbor(3), 3, 7, 0],
    ["route_neighbor0_src_sink_delay",
     route_neighbor(0), 0, 0, 6],
    ["route_neighbor1_src_sink_delay",
     route_neighbor(1), 1, 0, 4],
    ["route_neighbor2_src_sink_delay",
     route_neighbor(2), 2, 0, 2],
    ["route_neighbor3_src_sink_delay",
     route_neighbor(3), 3, 0, 7],
    ["break_ties0_src_sink_delays",
     break_ties(0), 0, 6, 8],
    ["break_ties1_src_sink_delays",
     break_ties(1), 1, 4, 5],
    ["break_ties2_src_sink_delays",
     break_ties(2), 2, 5, 7],
    ["break_ties3_src_sink_delays",
     break_ties(3), 3, 8, 2],
])
# Parameterized Testing with Test Case Table
#-------------------------------------------------------------------------

tvec_stream = [[4, 3, 2, 1], [9, 6, 7, 1], [4, 8, 0, 9]]
tvec_dups = [[2, 8, 9, 9], [2, 8, 2, 8], [1, 1, 1, 1]]
tvec_sorted = [[1, 2, 3, 4], [1, 3, 5, 7], [4, 3, 2, 1]]
tvec_random = [[randint(0, 0xff) for i in xr(4)] for y in xr(20)]

test_case_table = mk_test_case_table([
    ("nstages inputs      "),
    ["1stage_stream", 1, tvec_stream],
    ["1stage_dups", 1, tvec_dups],
    ["1stage_sorted", 1, tvec_sorted],
    ["1stage_random", 1, tvec_random],
    ["2stage_stream", 2, tvec_stream],
    ["2stage_dups", 2, tvec_dups],
    ["2stage_sorted", 2, tvec_sorted],
    ["2stage_random", 2, tvec_random],
    ["3stage_stream", 3, tvec_stream],
    ["3stage_dups", 3, tvec_dups],
    ["3stage_sorted", 3, tvec_sorted],
    ["3stage_random", 3, tvec_random],
])


@pytest.mark.parametrize(**test_case_table)
def test(test_params, dump_vcd):
    nstages = test_params.nstages
    inputs = test_params.inputs
    run_test_vector_sim(SortUnitCL(nstages=nstages),
                        mk_test_vector_table(nstages, inputs), dump_vcd)
            random_msgs.extend([mk_req_msg(knn_value), None])
        if (knn_value < min_value):
            min_value = knn_value
            min_idx = i

    random_msgs.extend(
        [mk_req_msg(knn_value),
         mk_resp_msg(min_value, min_idx)])

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
    ("msgs         src_delay  sink_delay"),
    ["basic_1", basic_msgs_1, 0, 0],
    ["basic_ranom", random_msgs, 0, 0],
])

#-------------------------------------------------------------------------
# Test cases
#-------------------------------------------------------------------------


@pytest.mark.parametrize(**test_case_table)
def test(test_params, dump_vcd):
    run_sim(
        TestHarness(FindMinPRTL, test_params.msgs[::2],
                    test_params.msgs[19::20], test_params.src_delay,
                    test_params.sink_delay), dump_vcd)
示例#19
0
result_8data = dot(vectorR, vectorToMatrix(test_8data, 8))

# transpose test_8data, and combine 4 of them into 1
matrix_test = vectorToMatrix(test_8data, 8)
matrix_test = transpose(matrix_test)
test_8data = matrixToVector(matrix_test, 8)

test_8data = fourElementsToOne(test_8data)
result_8data = fourElementsToOne(result_8data)
vectorR = fourElementsToOne(vectorR)

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------
test_case_table = mk_test_case_table([
  (                  "G_data       R_data         result       stall  latency  src_delay  sink_delay" ),
  [ "test8_0x0x0",   test_8data,   vectorR,         1,           0,     0,       0,         0         ],
])

#-------------------------------------------------------------------------
# Run Test
#-------------------------------------------------------------------------

def run_test( pageRank, test_params, dump_vcd, test_verilog=False ):

  G_data       = test_params.G_data
  R_data       = test_params.R_data
  result       = test_params.result
  G_data_bytes = struct.pack("<{}L".format(len(G_data)), *G_data)
  R_data_bytes = struct.pack("<{}L".format(len(R_data)), *R_data)
  
  pageRank_protocol_msgs = gen_protocol_msgs( len(G_data), len(R_data), result )
test_case_table = mk_test_case_table([
  (                      "msgs                 src_delay sink_delay"),
  [ "small_pos_pos",     small_pos_pos_msgs,   0,        0          ],
  # ''' LAB TASK '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  # Add more rows to the test case table to leverage the additional lists
  # of request/response messages defined above, but also to test
  # different source/sink random delays.
  # ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  [ "small_neg_neg",     small_neg_neg_msgs,   0,        0          ],
  [ "small_neg_pos",     small_neg_pos_msgs,   0,        0          ],
  [ "small_pos_neg",     small_pos_neg_msgs,   0,        0          ],
  [ "zero",              zero_msgs,            0,        0          ],
  [ "pos_one",           pos_one_msgs,         0,        0          ],
  [ "neg_one",           neg_one_msgs,         0,        0          ],
  [ "large_pos_pos",     large_pos_pos_msgs,   0,        0          ],
  [ "large_neg_neg",     large_neg_neg_msgs,   0,        0          ],
  [ "large_neg_pos",     large_neg_pos_msgs,   0,        0          ],
  [ "large_pos_neg",     large_pos_neg_msgs,   0,        0          ],
  [ "lower_mask",        lower_mask_msgs,      0,        0          ],
  [ "middle_mask",       middle_mask_msgs,     0,        0          ],
  [ "sparse_mask",       sparse_msgs,          0,        0          ],
  [ "dense_mask",        dense_msgs,           0,        0          ],
  [ "alt_corner_cases",  alt_design_corner_cases_msgs, 0,    0      ],
  # Same tests as above but with source/sink delay
  [ "delay_small_pos_pos",     small_pos_pos_msgs,   1,        5          ],
  [ "delay_small_neg_neg",     small_neg_neg_msgs,   3,        6          ],
  [ "delay_small_neg_pos",     small_neg_pos_msgs,   5,        1          ],
  [ "delay_small_pos_neg",     small_pos_neg_msgs,   2,        4          ],
  [ "delay_zero",              zero_msgs,            10,        0         ],
  [ "delay_pos_one",           pos_one_msgs,         3,        5          ],
  [ "delay_neg_one",           neg_one_msgs,         7,        7          ],
  [ "delay_large_pos_pos",     large_pos_pos_msgs,   1,        8          ],
  [ "delay_large_neg_neg",     large_neg_neg_msgs,   2,        9          ],
  [ "delay_large_neg_pos",     large_neg_pos_msgs,   8,        4          ],
  [ "delay_large_pos_neg",     large_pos_neg_msgs,   9,        11         ],
  [ "delay_lower_mask",        lower_mask_msgs,      8,        3          ],
  [ "delay_middle_mask",       middle_mask_msgs,     0,        5          ],
  [ "delay_sparse_mask",       sparse_msgs,          1,        43         ],
  [ "delay_dense_mask",        dense_msgs,           3,        2          ],
  [ "delay_alt_corner_cases",  alt_design_corner_cases_msgs, 10,    1     ],
  # Random test cases
  # Random source and sink delay is anywhere between 0 and 19 (inclusive)
  [ "random_small_pos_pos",     random_small_pos_pos_msgs,   random.randint(1,20),        random.randint(1,20)          ],
  [ "random_small_neg_neg",     random_small_neg_neg_msgs,   random.randint(1,20),        random.randint(1,20)          ],
  [ "random_small_neg_pos",     random_small_neg_pos_msgs,   random.randint(1,20),        random.randint(1,20)          ],
  [ "random_small_pos_neg",     random_small_pos_neg_msgs,   random.randint(1,20),        random.randint(1,20)          ],
  [ "random_zero",              random_zero_msgs,            random.randint(1,20),        random.randint(1,20)          ],
  [ "random_pos_one",           random_pos_one_msgs,         random.randint(1,20),        random.randint(1,20)          ],
  [ "random_neg_one",           random_neg_one_msgs,         random.randint(1,20),        random.randint(1,20)          ],
  [ "random_large_pos_pos",     random_large_pos_pos_msgs,   random.randint(1,20),        random.randint(1,20)          ],
  [ "random_large_neg_neg",     random_large_neg_neg_msgs,   random.randint(1,20),        random.randint(1,20)          ],
  [ "random_large_neg_pos",     random_large_neg_pos_msgs,   random.randint(1,20),        random.randint(1,20)          ],
  [ "random_large_pos_neg",     random_large_pos_neg_msgs,   random.randint(1,20),        random.randint(1,20)          ],
  [ "random_lower_mask",        random_lower_mask_msgs,      random.randint(1,20),        random.randint(1,20)          ],
  [ "random_middle_mask",       random_middle_mask_msgs,     random.randint(1,20),        random.randint(1,20)          ],
  [ "random_sparse_mask",       random_sparse_msgs,          random.randint(1,20),        random.randint(1,20)          ],
  [ "random_dense_mask",        random_dense_msgs,           random.randint(1,20),        random.randint(1,20)          ],

])
# ''' LAB TASK '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
# Define additional lists of request/response messages to create
# additional directed and random test cases.
# ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
  (                      "msgs                 src_delay sink_delay"),
  [ "small_pos_pos",     small_pos_pos_msgs,   0,        0          ],

  # ''' LAB TASK '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  # Add more rows to the test case table to leverage the additional lists
  # of request/response messages defined above, but also to test
  # different source/sink random delays.
  # ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

])

#-------------------------------------------------------------------------
# Test cases
#-------------------------------------------------------------------------

@pytest.mark.parametrize( **test_case_table )
def test( test_params, dump_vcd ):
  run_sim( TestHarness( IntMulFL(),
                        test_params.msgs[::2], test_params.msgs[1::2],
                        test_params.src_delay, test_params.sink_delay ),
test_8data = []
result_8data = []
for i in xrange(8):
  for j in xrange(8):
    test_8data.append(i)

for i in xrange(8):
  vectorR.append(i)

result_8data = dot(vectorR, vectorToMatrix(test_8data, 8))

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------
test_case_table = mk_test_case_table([
  (                  "data            result       stall  latency  src_delay  sink_delay" ),
  [ "test8_0x0x0",   test_8data,        1,           0,     0,       0,         0         ],
])

#-------------------------------------------------------------------------
# Run Test
#-------------------------------------------------------------------------

def run_test( pageRank, test_params, dump_vcd, test_verilog=False ):

  data       = test_params.data
  result     = test_params.result
  data_bytes = struct.pack("<{}Q".format(len(data)), *data)
  
  pageRank_protocol_msgs = gen_protocol_msgs( len(data), result )
  pageRank_reqs          = pageRank_protocol_msgs[::2]
  pageRank_resps         = pageRank_protocol_msgs[1::2]
for i in xrange(500):
  a = random.randint(0,0x1f)
  random_data.append(a)
  if ( a == ref_rdm ):
    result_rdm = result_rdm + 1

  


#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
  (                 "data            ref    result       stall  latency  src_delay  sink_delay" ),
  [ "vbasic_0x0x0", very_basic_data, 0x02,    2,           0,     0,       0,         0         ], 
  [ "basic_0x0x0",  basic_data,      0x41,    2,           0,     0,       0,         0         ],
  [ "random_0x0x0", random_data,     ref_rdm, result_rdm,  0,     0,       0,         0         ], 
])

#-------------------------------------------------------------------------
# Run Test
#-------------------------------------------------------------------------

def run_test( wordcount, test_params, dump_vcd, test_verilog=False ):

  data       = test_params.data
  ref        = test_params.ref
  result     = test_params.result
  data_bytes = struct.pack("<{}I".format(len(data)), *data)
  
  wordcount_protocol_msgs = gen_protocol_msgs( len(data), ref, result )
test_case_table = mk_test_case_table([
  (                      "msgs                 src_delay sink_delay"),
  [ "one_pkt",            one_pkt_msgs(),      0,        0          ],
  [ "single_dest",        single_dest_msgs(),  0,        0          ],

  # ''' LAB TASK '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  # Add more rows to the test case table to leverage the additional lists
  # of request/response messages defined above, but also to test
  # different source/sink random delays.
  # ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''\/
  [ "single_src",         single_src_msgs(),   0,        0          ],
  [ "neighbor",           neighbor_msgs(),     0,        0          ],
  [ "str_neighbor",       str_neighbor_msgs(), 0,        0          ],
  [ "hot_spot",           hot_spot_msgs(),     0,        0          ],
  [ "short_seq",          short_seq_msgs(),    0,        0          ],
  [ "opposite",           opposite_msgs(),     0,        0          ],
  [ "urandom",            urandom_msgs(),      0,        0          ],

  [ "single_src_delay",   single_src_msgs(),   3,        10         ],
  [ "single_dest_delay",  single_dest_msgs(),  3,        10         ],
  [ "neighbor_delay",     neighbor_msgs(),     3,        10         ],
  [ "str_neighbor_delay", str_neighbor_msgs(), 3,        10         ],
  [ "hot_spot_delay",     hot_spot_msgs(),     3,        10         ],
  [ "short_seq_delay",    short_seq_msgs(),    3,        10         ],
  [ "opposite_delay",     opposite_msgs(),     3,        10         ],
  [ "urandom_delay",      urandom_msgs(),      3,        10         ],

  # ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''/\

])
示例#25
0
small_data = [random.randint(0, 0xffff) for i in xrange(32)]
large_data = [random.randint(0, 0x7fffffff) for i in xrange(32)]
sort_fwd_data = sorted(small_data)
sort_rev_data = list(reversed(sorted(small_data)))

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
    #                delays   test mem
    #                -------- ---------
    ("data            src sink stall lat"),
    ["mini", mini, 0, 0, 0, 0],
    ["mini_delay_x4", mini, 3, 14, 0.5, 2],
    ["small_data", small_data, 0, 0, 0, 0],
    ["large_data", large_data, 0, 0, 0, 0],
    ["sort_fwd_data", sort_fwd_data, 0, 0, 0, 0],
    ["sort_rev_data", sort_rev_data, 0, 0, 0, 0],
    ["small_data_3x14x0", small_data, 3, 14, 0, 0],
    ["small_data_0x0x4", small_data, 0, 0, 0.5, 4],
    ["small_data_3x14x4", small_data, 3, 14, 0.5, 4],
])

#-------------------------------------------------------------------------
# run_test
#-------------------------------------------------------------------------


def run_test(xcel, test_params, dump_vcd, test_verilog=False):

    # Convert test data into byte array
示例#26
0
#-------------------------------------------------------------------------

rgen = random.Random()
rgen.seed(0x21a0728b)

basic_msgs = [0, 1, 2, 3, 4]
random_msgs = [rgen.randint(0, 0xffff) for _ in xrange(20)]

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
    ("msgs         src_delay sink_delay"),
    ["basic_0x0", basic_msgs, 0, 0],
    ["random_0x0", random_msgs, 0, 0],
    ["random_9x0", random_msgs, 9, 0],
    ["random_0x9", random_msgs, 0, 9],
    ["random_9x9", random_msgs, 9, 9],
])

#-------------------------------------------------------------------------
# Test cases
#-------------------------------------------------------------------------


@pytest.mark.parametrize(**test_case_table)
def test(test_params, dump_vcd):
    run_sim(
        TestHarness(test_params.msgs, test_params.src_delay,
                    test_params.sink_delay), dump_vcd)
test_case_table_generic = mk_test_case_table([
    ("msg_func               mem_data_func         stall lat src sink"),
    ["gets_after_inits", gets_after_inits, None, 0.0, 0, 0, 0],
    [
        "gets_after_gets", gets_after_gets_msg, gets_after_gets_mem, 0.0, 0, 0,
        0
    ],
    ["I_S_I", I_S_I_msg, I_S_I_mem, 0.0, 0, 0, 0],
    ["I_S_S_I", I_S_S_I_msg, I_S_S_I_mem, 0.0, 0, 0, 0],
    ["I_M_I", I_M_I_msg, I_M_I_mem, 0.0, 0, 0, 0],
    ["I_S_M_I", I_S_M_I_msg, I_S_M_I_mem, 0.0, 0, 0, 0],
    ["puts_IM", puts_IM_msg, puts_IM_mem, 0.0, 0, 0, 0],
    ["putm_I", putm_I_msg, putm_I_mem, 0.0, 0, 0, 0],
    ["putm_M", putm_M_msg, putm_M_mem, 0.0, 0, 0, 0],
    ["I_S_M_I_20x", I_S_M_I_20x_msg, I_S_M_I_20x_mem, 0.0, 0, 0, 0],
    ["I_S_M_I_20x_lat4", I_S_M_I_20x_msg, I_S_M_I_20x_mem, 0.0, 4, 0, 0],
    ["I_S_M_I_20x_stall0.5", I_S_M_I_20x_msg, I_S_M_I_20x_mem, 0.5, 0, 0, 0],
    ["I_S_M_I_20x_both", I_S_M_I_20x_msg, I_S_M_I_20x_mem, 0.5, 5, 0, 0],

    #'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    # LAB TASK: Add test cases to this table
    #'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''\/
    #[ "random",                random_msgs,           None,                 0.0,  0,  0,  0    ],
    #[ "random_stall0.5_lat0",  random_msgs,           None,                 0.5,  0,  0,  0    ],
    #[ "random_stall0.0_lat4",  random_msgs,           None,                 0.0,  4,  0,  0    ],
    #[ "random_stall0.5_lat4",  random_msgs,           None,                 0.5,  4,  0,  0    ],
    #[ "stream",                stream_msgs,           None,                 0.0,  0,  0,  0    ],
    #[ "stream_stall0.5_lat0",  stream_msgs,           None,                 0.5,  0,  0,  0    ],
    #[ "stream_stall0.0_lat4",  stream_msgs,           None,                 0.0,  4,  0,  0    ],
    #[ "stream_stall0.5_lat4",  stream_msgs,           None,                 0.5,  4,  0,  0    ],
    #[ "write_miss_1word",      write_miss_1word_msg,  write_miss_1word_mem, 0.0,  0,  0,  0    ],
    #[ "evict",                 evict_msg,             None,                 0.0,  0,  0,  0    ],
    #[ "evict_stall0.5_lat0",   evict_msg,             None,                 0.5,  0,  0,  0    ],
    #[ "evict_stall0.0_lat4",   evict_msg,             None,                 0.0,  4,  0,  0    ],
    #[ "evict_stall0.5_lat4",   evict_msg,             None,                 0.5,  4,  0,  0    ],

    #'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''/\
])
示例#28
0
            pos_x,
            pos_y,
            dimension,
            # src_x,  src_y, dest_x, dest_y, opaque, payload
            [  #(   0,      0,      1,      1,      0, 0xc001d00d),
                (1, 1, 0, 0, 0, 0xc001d00d),
            ]))


#-------------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------------

test_case_table = mk_test_case_table([
    ("msg_func    routing  mesh_wid mesh_ht pos_x pos_y src_delay sink_delay"),
    ["DOR_y_1pkt", basic_msgs, 'DOR_Y', 2, 2, 1, 1, 0, 0],
    ["DOR_x_1pkt", basic_msgs, 'DOR_X', 2, 2, 0, 0, 0, 0]
])

#-------------------------------------------------------------------------------
# Run tests
#-------------------------------------------------------------------------------


# Direct tests
@pytest.mark.parametrize(**test_case_table)
def test_direct(test_params, dump_vcd, test_verilog):
    dimension = ''
    if test_params.routing == 'DOR_X':
        dimension = 'x'
    elif test_params.routing == 'DOR_Y':
示例#29
0
    req( 'rd', 0x2, base_addr+8192, 0, 0          ), resp( 'rd', 0x2, 0, 0xcafeface ),
  ]


#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
  (                             "msg_func          stall lat src sink"),
  [ "basic",                     basic_msgs,       0.0,  0,  0,  0    ],
  [ "stream",                    stream_msgs,      0.0,  0,  0,  0    ],
  [ "subword_rd",                subword_rd_msgs,  0.0,  0,  0,  0    ],
  [ "subword_wr",                subword_wr_msgs,  0.0,  0,  0,  0    ],
  [ "random",                    random_msgs,      0.0,  0,  0,  0    ],
  [ "random_3x14",               random_msgs,      0.0,  0,  3,  14   ],
  [ "stream_stall0.5_lat0",      stream_msgs,      0.5,  0,  0,  0    ],
  [ "stream_stall0.0_lat4",      stream_msgs,      0.0,  4,  0,  0    ],
  [ "stream_stall0.5_lat4",      stream_msgs,      0.5,  4,  0,  0    ],
  [ "random_stall0.5_lat4_3x14", random_msgs,      0.5,  4,  3,  14   ],
  # [ "init_read_write",           init_read_write,  0.0,  0,  0,  0    ],
  [ "evict_test",                evict_test,       0.5,  2,  10,  105    ],
  [ "evict_test",                evict_test,       0,  0,  0,  0    ],
])

#-------------------------------------------------------------------------
# Test cases
#-------------------------------------------------------------------------

@pytest.mark.parametrize( **test_case_table )
def test_1port( test_params, dump_vcd ):
  msgs = test_params.msg_func(0x1000)
for i in xrange(10):
    filename = 'data/training_set_' + str(i) + '.dat'
    with open(filename, 'r') as f:
        count = 0
        for L in f:
            small_train_data.append(int(L.replace(',\n', ''), 16))
            count += 1
            if count >= 10:
                break

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------
test_case_table = mk_test_case_table([
    ("data             ref              result       stall  latency  src_delay  sink_delay"
     ),
    ["basic1_0x0x0", training_data, 0x3041060800, 1, 0, 0, 0, 0],
    ["small4_0x0x0", small_train_data, 0x41c3830408, 1, 0, 0, 0, 0],
])

#-------------------------------------------------------------------------
# Run Test
#-------------------------------------------------------------------------


def run_test(digitrec, test_params, dump_vcd, test_verilog=False):

    data = test_params.data
    ref = test_params.ref
    result = test_params.result
    data_bytes = struct.pack("<{}Q".format(len(data)), *data)
test_8data_1run = fourElementsToOne(test_8data_1run)
result_8data_1run = fourElementsToOne(result_8data_1run)
vectorR_1run = fourElementsToOne(vectorR_1run)

test_8data_4run = fourElementsToOne(test_8data_4run)
result_8data_4run = fourElementsToOne(result_8data_4run)
vectorR_4run = fourElementsToOne(vectorR_4run)

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------
test_case_table = mk_test_case_table([
  (                       "matrixG            vectorR      result   runs   stall  latency  src_delay  sink_delay" ),
   [ "test8_1_0x0x0",    test_8data_1run,    vectorR_1run,    1,      1,      0,     0,       0,         0         ],
#  [ "test8_2_0x0x0",    test_8data_1run,    vectorR_1run,    1,      2,      0,     0,       0,         0         ],
#  [ "test8_3_0x0x0",    test_8data_1run,    vectorR_1run,    1,      3,      0,     0,       0,         0         ],
   [ "test8_4_0x0x0",    test_8data_4run,    vectorR_4run,    1,      4,      0,     0,       0,         0         ],
])

#-------------------------------------------------------------------------
# Run Test
#-------------------------------------------------------------------------

def run_test( pageRank, test_params, dump_vcd, test_verilog=False ):

  G_data       = test_params.matrixG
  result       = test_params.result
  R_data       = test_params.vectorR
  runs         = test_params.runs
  G_data_bytes = struct.pack("<{}L".format(len(G_data)), *G_data)
    for i in xrange(32):
        is_masked = random.randint(0, 1)
        if is_masked:
            b = b & ((~(1 << i)) & 0xffff)

    random_sparse_msgs.extend([req(a, b), resp(a * b)])

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
    ("msgs                 src_delay sink_delay"),
    #  [ "small_pos_pos",     small_pos_pos_msgs,   0,        0          ],
    ["large_pos_pos", large_pos_pos_msgs, 0, 0],
    #  [ "zeros",             zeros_msgs,           0,        0          ],
    #  [ "random_small",      random_small_msgs,    0,        0          ],
    #  [ "random_large",      random_large_msgs,    0,        0          ],
])

#-------------------------------------------------------------------------
# Test cases
#-------------------------------------------------------------------------


@pytest.mark.parametrize(**test_case_table)
def test(test_params, dump_vcd):
    run_sim(
        TestHarness(IntMulFL(), test_params.msgs[::2], test_params.msgs[1::2],
                    test_params.src_delay, test_params.sink_delay), dump_vcd)
示例#33
0
test_case_table = mk_test_case_table([
  (                        "msgs                      src_delay         sink_delay" ),
  [ "one_pkt",              one_pkt_msgs(),           [0,0,0,0],        [0,0,0,0]   ],
  [ "single_dest",          single_dest_msgs(),       [0,0,0,0],        [0,0,0,0]   ],

  # ''' LAB TASK '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  # Add more rows to the test case table to leverage the additional lists
  # of request/response messages defined above, but also to test
  # different source/sink random delays.
  # ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  [ "one_pkt_one_self",     one_pkt_one_self(),       [0,0,0,0],        [0,0,0,0]   ],
  [ "one_pkt_self",         one_pkt_self(),           [0,0,0,0],        [0,0,0,0]   ],
  [ "four_pkt_self",        four_pkt_self(),          [0,0,0,0],        [0,0,0,0]   ],
  [ "single_dest_2router",  single_dest_2router(),    [0,0,0,0],        [0,0,0,0]   ],  
  [ "var_pkt_self",         var_pkt_self(),           [0,0,0,0],        [0,0,0,0]   ],
  [ "dead_lock",            dead_lock(),              [0,0,0,0],        [30,30,30,30]   ],
  [ "deadlock_pro",         deadlock_pro(),           [0,0,0,0],        [30,30,11,13]   ],
  [ "a2b_1pkt",             a2b_1pkt(),               [0,0,0,0],        [0,0,0,0]   ],
  [ "a2b_4pkt",             a2b_4pkt(),               [0,0,0,0],        [0,0,0,0]   ],
  [ "a2b_all",              a2b_all(),                [0,0,0,0],        [0,0,0,0]   ],

  [ "a2b_b2a_1pkt",         a2b_b2a_1pkt(),           [0,0,0,0],        [0,0,0,0]   ],
  [ "a2b_b2a_4pkt",         a2b_b2a_4pkt(),           [0,0,0,0],        [0,0,0,0]   ],
  [ "a2b_b2a_all",          a2b_b2a_all(),            [0,0,0,0],        [0,0,0,0]   ],
  
  [ "single_src_basic",     single_src_basic(),       [0,0,0,0],        [0,0,0,0]   ],
  [ "single_src_4pkt",      single_src_4pkt(),        [0,0,0,0],        [0,0,0,0]   ],
  [ "single_src_1pkt_all",  single_src_1pkt_all(),    [0,0,0,0],        [0,0,0,0]   ],
  [ "single_src_4pkt_all",  single_src_4pkt_all(),    [0,0,0,0],        [0,0,0,0]   ],

  [ "single_dest_basic",    single_dest_basic(),      [0,0,0,0],        [0,0,0,0]   ],
  [ "single_dest_4pkt",     single_dest_4pkt(),       [0,0,0,0],        [0,0,0,0]   ],
  [ "single_dest_1pkt_all", single_dest_1pkt_all(),   [0,0,0,0],        [0,0,0,0]   ],
  [ "single_dest_4pkt_all", single_dest_4pkt_all(),   [0,0,0,0],        [0,0,0,0]   ],

  [ "single_neighbor_basic",single_neighbor_basic(),  [0,0,0,0],        [0,0,0,0]   ],
  [ "both_neighbor_basic",  both_neighbor_basic(),    [0,0,0,0],        [0,0,0,0]   ],
  [ "single_neighbor_4pkt", single_neighbor_4pkt(),   [0,0,0,0],        [0,0,0,0]   ],
  [ "both_neighbor_4pkt",   both_neighbor_4pkt(),     [0,0,0,0],        [0,0,0,0]   ],
  
  [ "crazy_pressure",       crazy_pressure(),         [0,0,0,0],        [0,0,0,0]   ],
  [ "sink0_pressure",       single_sink_pressure(0),  [0,0,0,0],        [20,0,0,0]  ],
  [ "sink1_pressure",       single_sink_pressure(1),  [0,0,0,0],        [0,20,0,0]  ],
  [ "sink2_pressure",       single_sink_pressure(2),  [0,0,0,0],        [0,0,20,0]  ],
  [ "sink3_pressure",       single_sink_pressure(3),  [0,0,0,0],        [0,0,0,20]  ],
  [ "0_to_0_pressure",      one_to_one_pressure(0,0), [0,0,0,0],        [20,0,0,0]  ],
  [ "0_to_1_pressure",      one_to_one_pressure(0,1), [0,0,0,0],        [0,20,0,0]  ],
  [ "0_to_2_pressure",      one_to_one_pressure(0,2), [0,0,0,0],        [0,0,20,0]  ],
  [ "0_to_3_pressure",      one_to_one_pressure(0,3), [0,0,0,0],        [0,0,0,20]  ],
  [ "1_to_0_pressure",      one_to_one_pressure(1,0), [0,0,0,0],        [20,0,0,0]  ],
  [ "1_to_1_pressure",      one_to_one_pressure(1,1), [0,0,0,0],        [0,20,0,0]  ],
  [ "1_to_2_pressure",      one_to_one_pressure(1,2), [0,0,0,0],        [0,0,20,0]  ],
  [ "1_to_3_pressure",      one_to_one_pressure(1,3), [0,0,0,0],        [0,0,0,20]  ],
  [ "2_to_0_pressure",      one_to_one_pressure(2,0), [0,0,0,0],        [20,0,0,0]  ],
  [ "2_to_1_pressure",      one_to_one_pressure(2,1), [0,0,0,0],        [0,20,0,0]  ],
  [ "2_to_2_pressure",      one_to_one_pressure(2,2), [0,0,0,0],        [0,0,20,0]  ],
  [ "2_to_3_pressure",      one_to_one_pressure(2,3), [0,0,0,0],        [0,0,0,20]  ],
  [ "3_to_0_pressure",      one_to_one_pressure(3,0), [0,0,0,0],        [20,0,0,0]  ],
  [ "3_to_1_pressure",      one_to_one_pressure(3,1), [0,0,0,0],        [0,20,0,0]  ],
  [ "3_to_2_pressure",      one_to_one_pressure(3,2), [0,0,0,0],        [0,0,20,0]  ],
  [ "3_to_3_pressure",      one_to_one_pressure(3,3), [0,0,0,0],        [0,0,0,20]  ],

  [ "rand_src_to_0",        rand_src_to_0(),          [0,0,0,0],        [0,0,0,0]   ],
  [ "rand_src_to_1",        rand_src_to_1(),          [0,0,0,0],        [0,0,0,0]   ],
  [ "rand_src_to_2",        rand_src_to_2(),          [0,0,0,0],        [0,0,0,0]   ],
  [ "rand_src_to_3",        rand_src_to_3(),          [0,0,0,0],        [0,0,0,0]   ],

  [ "rand_dest_from_0",     rand_dest_from_0(),       [0,0,0,0],        [0,0,0,0]   ],
  [ "rand_dest_from_1",     rand_dest_from_1(),       [0,0,0,0],        [0,0,0,0]   ],
  [ "rand_dest_from_2",     rand_dest_from_2(),       [0,0,0,0],        [0,0,0,0]   ],
  [ "rand_dest_from_3",     rand_dest_from_3(),       [0,0,0,0],        [0,0,0,0]   ],

  [ "rand_src_rand_dest",   rand_src_2_rand_dest(),   [0,0,0,0],        [0,0,0,0]   ],
  
  [ "nearest_neighbour",    nearest_neighbour(),      [0,0,0,0],        [0,0,0,0]   ],
  [ "hotspot",              hotspot(),                [1,2,3,4],        [0,0,0,0]   ],
  [ "oversubscribed_hotspot",oversubscribed_hotspot(),[0,0,0,0],        [0,0,0,0]   ],
  [ "opposite",             opposite(),               [0,0,0,0],        [0,0,0,0]   ],
# Delay test
  [ "one_pkt_src_delay",    one_pkt_msgs(),           [0,3,0,0],        [0,0,0,0]   ],
  [ "one_pkt_sink_delay",   one_pkt_msgs(),           [0,0,0,0],        [5,0,0,0]   ],
  [ "one_pkt_long_delay",   one_pkt_msgs(),           [100,0,0,0],      [0,0,99,0]  ],
  [ "4_pkt_self_dealy",     four_pkt_self(),          [2,3,3,3],        [7,9,11,13] ],
  [ "var_pkt_self_delay",   var_pkt_self(),           [5,7,9,11],       [0,0,10,0]  ],
  [ "a2b_all_dalay",        a2b_all(),                [1,2,3,4],        [4,3,2,1]   ],
  [ "a2b_b2a_all_delay",    a2b_b2a_all(),            [16,8,4,2],       [1,2,4,8]   ],
  [ "single_src_4pkt_delay",single_src_4pkt_all(),    [99,1,2,3],       [1,4,8,12]  ],
  [ "both_neighbor_delay",  both_neighbor_4pkt(),     [0,1,2,3],        [1,3,5,7]   ],
  [ "ran_src_ran_des_delay",rand_src_2_rand_dest(),   [5,6,7,1],        [89,4,4,3]  ],
  [ "nearest_nbr_delay",    nearest_neighbour(),      [1,3,5,7],        [8,10,12,4] ],
  [ "hotspot_delay",        hotspot(),                [5,6,7,8],        [2,2,2,2]   ],
  [ "over_hotspot_delay",   oversubscribed_hotspot(), [5,3,1,1],        [11,1,0,9]  ],
  [ "opposite_delay",       opposite(),               [2,3,3,3],        [3,3,3,3]   ],
  [ "crazy_delay",          crazy_pressure(),         [0,0,0,0],        [99,98,97,9]],
])
  random_sparse_msgs.extend([ req( a, b ), resp( a * b ) ])

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
  (                      "msgs                 src_delay sink_delay"),
  [ "small_pos_pos",     small_pos_pos_msgs,   0,        0          ],
  [ "small_neg_pos",     small_neg_pos_msgs,   0,        0          ],
  [ "small_pos_neg",     small_pos_neg_msgs,   0,        0          ],
  [ "small_neg_neg",     small_neg_neg_msgs,   0,        0          ],
  [ "large_pos_pos",     large_pos_pos_msgs,   0,        0          ],
  [ "large_neg_neg",     large_neg_neg_msgs,   0,        0          ],
  [ "zeros",             zeros_msgs,           0,        0          ],
  [ "random_small",      random_small_msgs,    0,        0          ],
  [ "random_large",      random_large_msgs,    0,        0          ],
  [ "random_lomask",     random_lomask_msgs,   0,        0          ],
  [ "random_himask",     random_himask_msgs,   0,        0          ],
  [ "random_lohimask",   random_lohimask_msgs, 0,        0          ],
  [ "random_sparse",     random_sparse_msgs,   0,        0          ],
  [ "random_small_3x14", random_small_msgs,    3,        14         ],
  [ "random_large_3x14", random_large_msgs,    3,        14         ],
])

#-------------------------------------------------------------------------
# Test cases
#-------------------------------------------------------------------------

@pytest.mark.parametrize( **test_case_table )
def test( test_params, dump_vcd ):
示例#35
0
        req( 'wr', base_addr+4*idx, 0, new_data ), resp( 'wr', 0, 0 ),
      ])

  return msgs

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
  (                             "msg_func          stall lat src sink"),
  [ "basic",                     basic_msgs,       0.0,  0,  0,  0    ],
  [ "stream",                    stream_msgs,      0.0,  0,  0,  0    ],
  [ "subword_rd",                subword_rd_msgs,  0.0,  0,  0,  0    ],
  [ "subword_wr",                subword_wr_msgs,  0.0,  0,  0,  0    ],
  [ "random",                    random_msgs,      0.0,  0,  0,  0    ],
  [ "random_3x14",               random_msgs,      0.0,  0,  3,  14   ],
  [ "stream_stall0.5_lat0",      stream_msgs,      0.5,  0,  0,  0    ],
  [ "stream_stall0.0_lat4",      stream_msgs,      0.0,  4,  0,  0    ],
  [ "stream_stall0.5_lat4",      stream_msgs,      0.5,  4,  0,  0    ],
  [ "random_stall0.5_lat4_3x14", random_msgs,      0.5,  4,  3,  14   ],
])

#-------------------------------------------------------------------------
# Test cases for 1 port
#-------------------------------------------------------------------------

@pytest.mark.parametrize( **test_case_table )
def test_1port( test_params, dump_vcd ):
  msgs = test_params.msg_func(0x1000)
  run_sim( TestHarness( 1, [ msgs[::2] ], [ msgs[1::2] ],
# Parameterized Testing with Test Case Table
#-------------------------------------------------------------------------

tvec_stream = [ [ 4, 3, 2, 1 ], [ 9, 6, 7, 1 ], [ 4, 8, 0, 9 ] ]
tvec_dups   = [ [ 2, 8, 9, 9 ], [ 2, 8, 2, 8 ], [ 1, 1, 1, 1 ] ]
tvec_sorted = [ [ 1, 2, 3, 4 ], [ 1, 3, 5, 7 ], [ 4, 3, 2, 1 ] ]
tvec_random = [ [ randint(0,0xff) for i in xr(4) ] for y in xr(20) ]

test_case_table = mk_test_case_table([
  (                 "nstages inputs      "),
  [ "1stage_stream", 1,      tvec_stream  ],
  [ "1stage_dups",   1,      tvec_dups    ],
  [ "1stage_sorted", 1,      tvec_sorted  ],
  [ "1stage_random", 1,      tvec_random  ],
  [ "2stage_stream", 2,      tvec_stream  ],
  [ "2stage_dups",   2,      tvec_dups    ],
  [ "2stage_sorted", 2,      tvec_sorted  ],
  [ "2stage_random", 2,      tvec_random  ],
  [ "3stage_stream", 3,      tvec_stream  ],
  [ "3stage_dups",   3,      tvec_dups    ],
  [ "3stage_sorted", 3,      tvec_sorted  ],
  [ "3stage_random", 3,      tvec_random  ],
])

@pytest.mark.parametrize( **test_case_table )
def test( test_params, dump_vcd ):
  nstages = test_params.nstages
  inputs  = test_params.inputs
  run_test_vector_sim( SortUnitCL( nstages=nstages ),
    mk_test_vector_table( nstages, inputs ), dump_vcd )
示例#37
0
            (0x2, 0x1, 3, 1, 0x01, 0xff),
            (0x2, 0x1, 3, 1, 0x01, 0xff),
            (0x2, 0x1, 3, 1, 0x01, 0xff),
            #( 0x4, 0x4,  0,   0,   0x01,  0xff ),
            #( 0x2, 0x4,  1,   0,   0x02,  0xde ),
            #( 0x2, 0x4,  3,   0,   0x03,  0xad ),
            #( 0x4, 0x4,  0,   0,   0x04,  0xdd ),
        ])


#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
    ("msgs                routerid  src_delay sink_delay"),
    ["vbasic_0", very_basic_msgs(0), 0, 0, 0]
])

#-------------------------------------------------------------------------
# Run tests
#-------------------------------------------------------------------------


@pytest.mark.parametrize(**test_case_table)
def test_default(test_params, dump_vcd, test_verilog):
    nrouters = 4
    run_router_test(RingRouterRTL(num_routers=nrouters),
                    test_params.routerid,
                    test_params.src_delay,
                    test_params.sink_delay,
                    test_params.msgs,
示例#38
0
                resp('wr', i, 0, 0),
            ])

    return msgs


#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
    ("msg_func          stall lat src sink"),
    ["basic", basic_msgs, 0.0, 0, 0, 0],
    ["basic_hit", basic_hit_msgs, 0.0, 5, 0, 0],
    ["stream", stream_msgs, 0.0, 0, 0, 0],
    ["random", random_msgs, 0.0, 0, 0, 0],
    ["random_3x14", random_msgs, 0.0, 0, 3, 14],
    ["stream_stall0.5_lat0", stream_msgs, 0.5, 0, 0, 0],
    ["stream_stall0.0_lat4", stream_msgs, 0.0, 4, 0, 0],
    ["stream_stall0.5_lat4", stream_msgs, 0.5, 4, 0, 0],
    ["random_stall0.5_lat4_3x14", random_msgs, 0.5, 4, 3, 14],
])

#-------------------------------------------------------------------------
# Test cases
#-------------------------------------------------------------------------


@pytest.mark.parametrize(**test_case_table)
def test_1port(test_params, dump_vcd):
    msgs = test_params.msg_func(0x1000)
    run_sim(
basic_msgs = [0, 1, 2, 3, 4]
random_msgs = [rgen.randint(0, 0xffff) for _ in range(20)]

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
    ("msgs         nstages src_delay sink_delay"),
    ["basic_nstages0_0x0", basic_msgs, 0, 0, 0],
    ["random_nstages0_0x0", random_msgs, 0, 0, 0],
    ["random_nstages0_9x0", random_msgs, 0, 9, 0],
    ["random_nstages0_0x9", random_msgs, 0, 0, 9],
    ["random_nstages0_9x9", random_msgs, 0, 9, 9],
    ["basic_nstages1_0x0", basic_msgs, 1, 0, 0],
    ["random_nstages1_0x0", random_msgs, 1, 0, 0],
    ["random_nstages1_9x0", random_msgs, 1, 9, 0],
    ["random_nstages1_0x9", random_msgs, 1, 0, 9],
    ["random_nstages1_9x9", random_msgs, 1, 9, 9],
    ["basic_nstages4_0x0", basic_msgs, 4, 0, 0],
    ["random_nstages4_0x0", random_msgs, 4, 0, 0],
    ["random_nstages4_9x0", random_msgs, 4, 9, 0],
    ["random_nstages4_0x9", random_msgs, 4, 0, 9],
    ["random_nstages4_9x9", random_msgs, 4, 9, 9],
])

#-------------------------------------------------------------------------
# Test cases
#-------------------------------------------------------------------------


@pytest.mark.parametrize(**test_case_table)
示例#40
0
        else:
            in_mem = find_addr(mem, addr)
            print("in_mem = ", in_mem)
            if (in_mem == None):
                data = 0x00000000
            else:
                data = mem[in_mem][1]
            #print(hex(data), i)
            res.append(req('rd', i % 16, addr, 0, 0))
            res.append(resp('rd', i % 16, 0, 0, data))
    print(res)
    return res


test_case_table_random = mk_test_case_table([
    ("msg_func               mem_data_func         nbank stall lat src sink"),
    ["random_accesses", random_accesses_msg, None, 1, 0.0, 0, 0, 0],
])

#----------------------------------------------------------------------
# Banked cache test
#----------------------------------------------------------------------
# The test field in the response message: 0 == MISS, 1 == HIT

# This test case is to test if the bank offset is implemented correctly.
#
# The idea behind this test case is to differentiate between a cache
# with no bank bits and a design has one/two bank bits by looking at cache
# request hit/miss status.

#-------------------------------------------------------------------------
# Test table for generic test
示例#41
0
            ])

    return msgs


#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
    ("msg_func          stall lat src sink"),
    ["basic", basic_msgs, 0.0, 0, 0, 0],
    ["stream", stream_msgs, 0.0, 0, 0, 0],
    ["subword_rd", subword_rd_msgs, 0.0, 0, 0, 0],
    ["subword_wr", subword_wr_msgs, 0.0, 0, 0, 0],
    ["amo", amo_msgs, 0.0, 0, 0, 0],
    ["random", random_msgs, 0.0, 0, 0, 0],
    ["random_3x14", random_msgs, 0.0, 0, 3, 14],
    ["stream_stall0.5_lat0", stream_msgs, 0.5, 0, 0, 0],
    ["stream_stall0.0_lat4", stream_msgs, 0.0, 4, 0, 0],
    ["stream_stall0.5_lat4", stream_msgs, 0.5, 4, 0, 0],
    ["random_stall0.5_lat4_3x14", random_msgs, 0.5, 4, 3, 14],
])

#-------------------------------------------------------------------------
# Test cases for 1 port
#-------------------------------------------------------------------------


@pytest.mark.parametrize(**test_case_table)
def test_1port(test_params, dump_vcd):
    msgs = test_params.msg_func(0x1000)
示例#42
0
        data.append(L.split(','))
    for row in data:
        test_data.append(int(row[0], 16))
        result_data.append(int(row[1]))

small_test_data = []
small_result_data = []
for i in xrange(TEST_SIZE):
    small_test_data.append(int(data[i * (180 / TEST_SIZE)][0], 16))
    small_result_data.append(int(data[i * (180 / TEST_SIZE)][1]))

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------
test_case_table = mk_test_case_table([
    ("data            result       stall  latency  src_delay  sink_delay"),
    ["small_0x0x0", small_test_data, 1, 0, 0, 0, 0],
])

#-------------------------------------------------------------------------
# Run Test
#-------------------------------------------------------------------------


def run_test(digitrec, test_params, dump_vcd, test_verilog=False):

    data = test_params.data
    result = test_params.result
    data_bytes = struct.pack("<{}Q".format(len(data)), *data)

    digitrec_protocol_msgs = gen_protocol_msgs(len(data), result)
    digitrec_reqs = digitrec_protocol_msgs[::2]
示例#43
0
    max_idx   = 1
  if (knn_value_2 > max_value):
    max_value = knn_value_2
    max_idx   = 2
   
  random_msgs.extend([ mk_req_msg( knn_value_2 ), mk_resp_msg( max_value, max_idx )])

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
  (               "msgs         src_delay  sink_delay" ),
  [ "basic_0",    basic_msgs_0, 0,         0           ], 
  [ "basic_1",    basic_msgs_1, 0,         0           ], 
  [ "basic_2",    basic_msgs_2, 0,         0           ], 
  [ "basic_same", basic_msgs_same, 0,         0           ], 
  [ "basic",      basic_msgs,   0,         0           ], 
  [ "random",     random_msgs,  0,         0           ], 
])

#-------------------------------------------------------------------------
# Test cases
#-------------------------------------------------------------------------

@pytest.mark.parametrize( **test_case_table )
def test( test_params, dump_vcd ):
  run_sim( TestHarness( FindMaxPRTL,
                        test_params.msgs[::2], test_params.msgs[5::6],
                        test_params.src_delay, test_params.sink_delay ),
           dump_vcd )
  for i in xrange(32):
    is_masked = random.randint(0,1)
    if is_masked:
      b = b & ( (~(1 << i)) & 0xffff )

  random_sparse_msgs.extend([ req( a, b ), resp( a * b ) ])

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
  (                      "msgs                 src_delay sink_delay"),
#  [ "small_pos_pos",     small_pos_pos_msgs,   0,        0          ],
  [ "large_pos_pos",     large_pos_pos_msgs,   0,        0          ],
#  [ "zeros",             zeros_msgs,           0,        0          ],
#  [ "random_small",      random_small_msgs,    0,        0          ],
#  [ "random_large",      random_large_msgs,    0,        0          ],
])

#-------------------------------------------------------------------------
# Test cases
#-------------------------------------------------------------------------

@pytest.mark.parametrize( **test_case_table )
def test( test_params, dump_vcd ):
  run_sim( TestHarness( IntMulFL(),
                        test_params.msgs[::2], test_params.msgs[1::2],
                        test_params.src_delay, test_params.sink_delay ),
           dump_vcd )
示例#45
0
random.seed(0xdeadbeef)
random_msgs = []
for i in xrange(20):
    a = random.randint(0, 0xffff)
    b = random.randint(0, 0xffff)
    c = gcd(a, b)
    random_msgs.extend([mk_req_msg(a, b), c])

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
    ("msgs        src_delay sink_delay"),
    ["basic_0x0", basic_msgs, 0, 0],
    ["basic_5x0", basic_msgs, 5, 0],
    ["basic_0x5", basic_msgs, 0, 5],
    ["basic_3x9", basic_msgs, 3, 9],
    ["random_3x9", random_msgs, 3, 9],
])

#-------------------------------------------------------------------------
# Test cases
#-------------------------------------------------------------------------


@pytest.mark.parametrize(**test_case_table)
def test(test_params, dump_vcd):
    run_sim(
        TestHarness(GcdUnitFL, test_params.msgs[::2], test_params.msgs[1::2],
                    test_params.src_delay, test_params.sink_delay), dump_vcd)
示例#46
0
random_msgs = []
for i in xrange(20):
  a = random.randint(0,0xffff)
  b = random.randint(0,0xffff)
  c = gcd( a, b )
  random_msgs.extend([[ a, b , c ]])

#-------------------------------------------------------------------------
# Test Case Table
#-------------------------------------------------------------------------

test_case_table = mk_test_case_table([
                         #             delays
                         #             --------
  (                      "msgs         src sink"),
  [ "basic0x0",           basic_msgs,  0,  0    ],
  [ "basic0x5",           basic_msgs,  0,  5    ],
  [ "basic3x0",           basic_msgs,  3,  0    ],
  [ "basic2x1",           basic_msgs,  2,  1    ],
  [ "random0x0",          random_msgs, 0,  0    ],
])

#-------------------------------------------------------------------------
# run_test
#-------------------------------------------------------------------------

def run_test( xcel, test_params, dump_vcd, test_verilog=False ):

  # Protocol messages

  xreqs  = list()
  xresps = list()