

@pytest.mark.parametrize('stall_prob,latency', [(0, 0), (0.2, 2), (0.5, 4)])
def test(dump_vcd, stall_prob, latency):
    data = [random.randint(0, 4294967295) for _ in range(8)]
    data_bytes = struct.pack('<{}I'.format(len(data)), *data)
    th = TestHarness(4096, 8192, len(data_bytes), stall_prob, latency)
    th.vcd_file = dump_vcd
    th.elaborate()
    th.mem.write_mem(4096, data_bytes)
    sim = SimulationTool(th)
    print()
    sim.reset()
    while (not data_bytes.done()):
        sim.print_line_trace()
        sim.cycle()
    sim.cycle()
    sim.cycle()
    sim.cycle()
    result_bytes = th.mem.read_mem(8192, len(data_bytes))
    result = list(struct.unpack('<{}I'.format(len(data)), buffer(result_bytes)))
    assert (result == data)

dataset/ETHPy150Open cornell-brg/pymtl/pclib/fl/BytesMemPortAdapter_test.py test/VarMisuse@145/184 `th`->`data_bytes`