コード例 #1
0
  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         ],
])

#-------------------------------------------------------------------------
# TestHarness
#-------------------------------------------------------------------------

@pytest.mark.parametrize( **test_case_table )
def test( test_params, dump_vcd, test_verilog ):
コード例 #2
0
test_case_table = mk_test_case_table([
    ("msgs         src_delay sink_delay"),
    [
        "basic_0x0",
        basic_msgs,
        0,
        0,
    ],
    [
        "stream_0x0",
        stream_msgs,
        0,
        0,
    ],
    [
        "random_0x0",
        random_msgs,
        0,
        0,
    ],
    [
        "random_5x0",
        random_msgs,
        5,
        0,
    ],
    [
        "random_0x5",
        random_msgs,
        0,
        5,
    ],
    [
        "random_3x9",
        random_msgs,
        3,
        9,
    ],
])
コード例 #3
0
    else:
      msgs.extend([
        req( 'wr', i, base_addr+4*idx, 0, num ), resp( 'wr', i, 0, 0 ),
      ])

  return msgs

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

test_case_table = mk_test_case_table([
  (                       "msg_func             src sink"),
  [ "basic_single_msgs",   basic_single_msgs,   0,  0    ],
  [ "basic_multiple_msgs", basic_multiple_msgs, 0,  0    ],
  [ "random",              random_msgs,         0,  0    ],
  [ "random_0_3",          random_msgs,         0,  3    ],
  [ "random_3_0",          random_msgs,         3,  0    ],
  [ "random_3_5",          random_msgs,         3,  5    ],
])

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

@pytest.mark.parametrize( **test_case_table )
def test( test_params, dump_vcd, test_verilog ):

  # instantiate test harness

  top = TestHarness( SramMinionRTL() )
コード例 #4
0
ファイル: MemoryCL_test.py プロジェクト: yxd97/pymtl3
            ])

    return msgs


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

test_case_table = mk_test_case_table([
    ("msg_func          stall lat src_init src_intv sink_init sink_intv"),
    ["basic", basic_msgs, 0.0, 1, 0, 0, 0, 0],
    ["stream", stream_msgs, 0.0, 1, 0, 0, 0, 0],
    ["subword_rd", subword_rd_msgs, 0.0, 1, 0, 0, 0, 0],
    ["subword_wr", subword_wr_msgs, 0.0, 1, 0, 0, 0, 0],
    ["amo", amo_msgs, 0.0, 1, 0, 0, 0, 0],
    ["random", random_msgs, 0.0, 1, 0, 0, 0, 0],
    ["random_3x14", random_msgs, 0.0, 1, 5, 3, 7, 14],
    ["stream_stall0.5_lat0", stream_msgs, 0.5, 1, 0, 0, 0, 0],
    ["stream_stall0.0_lat4", stream_msgs, 0.0, 4, 0, 0, 0, 0],
    ["stream_stall0.5_lat4", stream_msgs, 0.5, 4, 0, 0, 0, 0],
    ["random_stall0.5_lat4_3x14", random_msgs, 0.5, 4, 5, 14, 7, 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] ],
コード例 #5
0
    (1, 0, 0),
    (0, -1, 0),
    (-1, 0, 0),
]

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

test_case_table = mk_test_case_table([
    ("msgs             "),
    ["small_pos_pos", small_pos_pos_msgs],
    ["small_neg_pos", small_neg_pos_msgs],
    ["small_pos_neg", small_pos_neg_msgs],
    ["small_neg_neg", small_neg_neg_msgs],
    ["large_pos_pos", large_pos_pos_msgs],
    ["large_neg_neg", large_neg_neg_msgs],
    [
        "zeros",
        zeros_msgs,
    ],
])

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


@pytest.mark.parametrize(**test_case_table)
def test(test_params):
    for a, b, result in test_params.msgs:
コード例 #6
0
# 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_3x14x4", mini, 3, 14, 0.5, 2],
    ["mini_delay_5x7", mini, 5, 7, 0.5, 4],
    ["small_data", small_data, 0, 0, 0, 0],
    ["small_data1", small_data1, 4, 11, 0.5, 2],
    ["small_data2", small_data2, 0, 9, 0.5, 3],
    ["small_data3", small_data3, 2, 4, 0.5, 1],
    ["small_data4", small_data4, 1, 12, 0.5, 1],
    ["small_data5", small_data5, 4, 13, 0.5, 4],
    ["small_data6", small_data6, 2, 4, 0.5, 5],
    ["small_data7", small_data7, 1, 1, 0.5, 6],
    ["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],
    ["nonpow2_size", nonpow2_size, 0, 0, 0, 0],
    ["small_data_3x14x0", small_data, 3, 14, 0, 0],
    ["small_data_5x7x0", small_data, 5, 7, 0, 0],
    ["small_data_0x0x4", small_data, 0, 0, 0.5, 4],
    ["small_data_3x14x4", small_data, 3, 14, 0.5, 4],
    ["small_data_5x7x4", small_data, 5, 7, 0.5, 4],
])

#-------------------------------------------------------------------------
# run_test
コード例 #7
0
random_cases = []
for i in range(30):
    a = random.randint(0, 0xffff)
    b = random.randint(0, 0xffff)
    c = gcd(a, b)
    random_cases.append((a, b, c))

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

test_case_table = mk_test_case_table([
    ("cases      "),
    [
        "basic",
        basic_cases,
    ],
    ["random", random_cases],
])


@pytest.mark.parametrize(**test_case_table)
def test_gcd_fl(test_params, dump_vcd):
    print()
    for a, b, result in test_params.cases:
        print(
            f"gcd_fl({b16(a)}, {b16(b)}) = {gcd_fl(b16(a), b16(b))} (ref = {b16(result)})"
        )
        assert gcd_fl(b16(a), b16(b)) == b16(result)
コード例 #8
0
ファイル: DelayPipeCL_test.py プロジェクト: hsqforfun/pymtl3
    8, 8,
    9, 9,
    10, 10,
  ]

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

@pytest.mark.parametrize( **mk_test_case_table([
  (                      "msg_func        lat   src_lat sink_lat  "),
  [ "basic",             basic_msgs,      0,    0,      0          ],
  [ "basic_lat1",        basic_msgs,      1,    0,      0          ],
  [ "basic_lat2",        basic_msgs,      2,    0,      0          ],
  [ "basic_lat3",        basic_msgs,      3,    0,      0          ],
  [ "basic_lat4",        basic_msgs,      4,    0,      0          ],
  [ "basic_lat10",       basic_msgs,      10,   0,      0          ],
  [ "basic_3_14",        basic_msgs,      0,    3,      14         ],
  [ "basic_lat1_3_14",   basic_msgs,      1,    3,      14         ],
  [ "basic_lat4_3_14",   basic_msgs,      4,    3,      14         ],
  [ "basic_lat10_3_14",  basic_msgs,      10,   3,      14         ],
]) )
def test_delay_pipe_deq( test_params, dump_vcd ):
  msgs = test_params.msg_func()
  run_cl_sim( TestHarness( DelayPipeDeqCL, msgs[::2], msgs[1::2],
                           test_params.lat,
                           test_params.src_lat, test_params.sink_lat ) )

@pytest.mark.parametrize( **mk_test_case_table([
  (                      "msg_func        lat   src_lat sink_lat  "),
  [ "basic",             basic_msgs,      0,    0,      0          ],
コード例 #9
0
        210, 307, 956, 554, 246, 898, 12, 750, 670, 86, 446, 622, 772, 400,
        238, 619, 676, 267, 676, 239, 262, 343, 896, 978, 356, 51, 461, 280,
        150, 722, 206, 777, 160, 953, 886, 81, 449, 601, 153, 394, 671
    ], [4, 4, 6, 6, 8, 8, 6, 5, 8, 6, 6, 6, 7, 7, 7],
    [3, 4, 5, 6, 7, 8, 4, 5, 7, 6, 6, 6, 7, 7, 7]
]

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

test_case_table = mk_test_case_table([
    #                delays   test mem
    #                -------- ---------
    ("basic_data            src sink stall lat"),
    ["data", basic_data, 0, 0, 0, 0],
    ["data_delay1", basic_data, 3, 3, 0.5, 2],
    ["data_delay2", basic_data, 3, 14, 0.5, 4],
    ["data_delay3", basic_data, 3, 10, 0.6, 4],
])

test_case_table_small = mk_test_case_table([
    #                delays   test mem
    #                -------- ---------
    ("small_data            src sink stall lat"),
    ["small_data", small_data, 0, 0, 0, 0],
    ["small_data_delay", small_data, 3, 3, 0, 0],
    ["small_data_delay2", small_data, 3, 3, 0.5, 0],
    ["small_data_delay2", small_data, 3, 10, 0.5, 0],
])
コード例 #10
0
sort_rev_data = list(reversed(sorted(small_data)))
nonpow2_size = [random.randint(0, 0xffff) for i in range(35)]

#-------------------------------------------------------------------------
# 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_3x14x4", mini, 3, 14, 0.5, 2],
    # [ "mini_delay_5x7",     mini,           5,  7,   0.5,  4   ],
    ["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],
    ["nonpow2_size", nonpow2_size, 0, 0, 0, 0],
    ["small_data_3x14x0", small_data, 3, 14, 0, 0],
    # [ "small_data_5x7x0",   small_data,     5,  7,   0,    0   ],
    ["small_data_0x0x4", small_data, 0, 0, 0.5, 4],
    ["small_data_3x14x4", small_data, 3, 14, 0.5, 4],
    # [ "small_data_5x7x4",   small_data,     5,  7,   0.5,  4   ],
])

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


def run_test(pytestconfig,
コード例 #11
0
test_case_table_generic = mk_test_case_table([
  (                         "msg_func               mem_data_func         stall lat src sink"),
  [ "read_hit_1word_clean",  read_hit_1word_clean,  None,                 0.0,  0,  0,  0    ],
  [ "read_miss_1word",       read_miss_1word_msg,   read_miss_1word_mem,  0.0,  0,  0,  0    ],

  #'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  # LAB TASK: Add test cases to this table
  #'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''\/
  [ "read_hit_many_clean",   read_hit_many_clean,   None,                 0.0,  0,  0,  0    ],
  [ "read_capacity",         read_capacity,         read_capacity_mem,    0.0,  0,  0,  0    ],
  [ "read_hit_1word_dirty",  read_hit_1word_dirty,  None,                 0.0,  0,  0,  0    ],
#  [ "read_hit_1line_clean",  read_hit_1line_clean,  None,                 0.0,  0,  0,  0    ],
  [ "write_hit_1word_clean", write_hit_1word_clean, None,                 0.0,  0,  0,  0    ],
  [ "write_hit_1word_dirty", write_hit_1word_dirty, None,                 0.0,  0,  0,  0    ],
  [ "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    ],

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

])