Testbench cleanup for cocotb 2.0

Signed-off-by: Alex Forencich <alex@alexforencich.com>
This commit is contained in:
Alex Forencich
2025-09-07 10:59:38 -07:00
parent 884fe1a006
commit 40908b1b92
83 changed files with 83 additions and 83 deletions

View File

@@ -171,7 +171,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
data_width = len(cocotb.top.s_axi.wdata)
byte_lanes = data_width // 8

View File

@@ -171,7 +171,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
data_width = len(cocotb.top.s_axi.wdata)
byte_lanes = data_width // 8

View File

@@ -172,7 +172,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
data_width = len(cocotb.top.s_axi.wdata)
byte_lanes = data_width // 8

View File

@@ -163,7 +163,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
data_width = len(cocotb.top.s_axi.wdata)
byte_lanes = data_width // 8

View File

@@ -171,7 +171,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
data_width = len(cocotb.top.s_axi.wdata)
byte_lanes = data_width // 8

View File

@@ -163,7 +163,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_write, run_test_read]:

View File

@@ -163,7 +163,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_write, run_test_read]:

View File

@@ -196,7 +196,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_write, run_test_read]:

View File

@@ -155,7 +155,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_write, run_test_read, run_stress_test]:

View File

@@ -163,7 +163,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_write, run_test_read, run_stress_test]:

View File

@@ -177,7 +177,7 @@ def incrementing_payload(length):
return bytearray(itertools.islice(itertools.cycle(range(256)), length))
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.add_option("payload_lengths", [size_list])

View File

@@ -266,7 +266,7 @@ def incrementing_payload(length):
return bytearray(itertools.islice(itertools.cycle(range(256)), length))
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
ports = len(cocotb.top.s_axis)

View File

@@ -612,7 +612,7 @@ def incrementing_payload(length):
return bytearray(itertools.islice(itertools.cycle(range(256)), length))
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.add_option("payload_lengths", [size_list])

View File

@@ -612,7 +612,7 @@ def incrementing_payload(length):
return bytearray(itertools.islice(itertools.cycle(range(256)), length))
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.add_option("payload_lengths", [size_list])

View File

@@ -112,7 +112,7 @@ def incrementing_payload(length):
return bytearray(itertools.islice(itertools.cycle(range(256)), length))
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.add_option("payload_lengths", [size_list])

View File

@@ -180,7 +180,7 @@ def prbs_payload(length):
return bytearray([next(gen) for x in range(length)])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.add_option("payload_lengths", [size_list])

View File

@@ -187,7 +187,7 @@ def prbs_payload(length):
return bytearray([next(gen) for x in range(length)])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.add_option("payload_lengths", [size_list])

View File

@@ -160,7 +160,7 @@ def incrementing_payload(length):
return bytearray(itertools.islice(itertools.cycle(range(256)), length))
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.add_option("payload_lengths", [size_list])

View File

@@ -124,7 +124,7 @@ def incrementing_payload(length):
return bytearray(itertools.islice(itertools.cycle(range(256)), length))
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
ports = len(cocotb.top.m_axis)

View File

@@ -400,7 +400,7 @@ def incrementing_payload(length):
return bytearray(itertools.islice(itertools.cycle(range(256)), length))
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.add_option("payload_lengths", [size_list])

View File

@@ -398,7 +398,7 @@ def incrementing_payload(length):
return bytearray(itertools.islice(itertools.cycle(range(256)), length))
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.add_option("payload_lengths", [size_list])

View File

@@ -140,7 +140,7 @@ def incrementing_payload(length):
return bytearray(itertools.islice(itertools.cycle(range(256)), length))
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
ports = len(cocotb.top.s_axis)

View File

@@ -257,7 +257,7 @@ def incrementing_payload(length):
return bytearray(itertools.islice(itertools.cycle(range(256)), length))
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.add_option("payload_lengths", [size_list])

View File

@@ -173,7 +173,7 @@ def incrementing_payload(length):
return bytearray(itertools.islice(itertools.cycle(range(256)), length))
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.add_option("payload_lengths", [size_list])

View File

@@ -173,7 +173,7 @@ def incrementing_payload(length):
return bytearray(itertools.islice(itertools.cycle(range(256)), length))
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.add_option("payload_lengths", [size_list])

View File

@@ -278,7 +278,7 @@ def incrementing_payload(length):
return bytearray(itertools.islice(itertools.cycle(range(256)), length))
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
s_count = len(cocotb.top.s_axis)
m_count = len(cocotb.top.m_axis)

View File

@@ -163,7 +163,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_write, run_test_read, run_stress_test]:

View File

@@ -168,7 +168,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_write, run_test_read, run_stress_test]:

View File

@@ -281,7 +281,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
gbx_cfgs = [None]

View File

@@ -281,7 +281,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
gbx_cfgs = [None]

View File

@@ -395,7 +395,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
gbx_cfgs = [None]

View File

@@ -508,7 +508,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
gbx_cfgs = [None]

View File

@@ -286,7 +286,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.add_option("payload_lengths", [size_list])

View File

@@ -394,7 +394,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.add_option("payload_lengths", [size_list])

View File

@@ -256,7 +256,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.add_option("payload_lengths", [size_list])

View File

@@ -257,7 +257,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.add_option("payload_lengths", [size_list])

View File

@@ -457,7 +457,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.add_option("payload_lengths", [size_list])

View File

@@ -459,7 +459,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.add_option("payload_lengths", [size_list])

View File

@@ -681,7 +681,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_rx, run_test_tx]:

View File

@@ -292,7 +292,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_rx, run_test_tx]:

View File

@@ -756,7 +756,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [
run_test_rx,

View File

@@ -204,7 +204,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_rx, run_test_tx]:

View File

@@ -620,7 +620,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_rx, run_test_tx]:

View File

@@ -158,7 +158,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_rx, run_test_tx]:

View File

@@ -624,7 +624,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_rx, run_test_tx]:

View File

@@ -174,7 +174,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_rx, run_test_tx]:

View File

@@ -911,7 +911,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_rx, run_test_tx]:

View File

@@ -584,7 +584,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_rx, run_test_tx]:

View File

@@ -134,7 +134,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_rx, run_test_tx]:

View File

@@ -819,7 +819,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
gbx_cfgs = [None]

View File

@@ -405,7 +405,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
gbx_cfgs = [None]

View File

@@ -203,7 +203,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_rx, run_test_tx]:

View File

@@ -505,7 +505,7 @@ def incrementing_payload(length):
return bytes(itertools.islice(itertools.cycle(range(256)), length))
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test_data)
factory.add_option("payload_lengths", [size_list])

View File

@@ -387,7 +387,7 @@ def incrementing_payload(length):
return bytes(itertools.islice(itertools.cycle(range(256)), length))
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test_data)
factory.add_option("payload_lengths", [size_list])

View File

@@ -364,7 +364,7 @@ async def run_test_pfc(dut):
await RisingEdge(dut.clk)
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_lfc, run_test_pfc]:

View File

@@ -315,7 +315,7 @@ async def run_test_pfc(dut):
await RisingEdge(dut.clk)
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_lfc, run_test_pfc]:

View File

@@ -188,7 +188,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.add_option("payload_lengths", [size_list])

View File

@@ -188,7 +188,7 @@ def cycle_en():
return itertools.cycle([0, 0, 0, 1])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.add_option("payload_lengths", [size_list])

View File

@@ -149,7 +149,7 @@ async def run_test_prbs(dut, ref_prbs):
await Timer(10, 'ns')
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
if cocotb.top.LFSR_POLY.value == 0x4c11db7:
factory = TestFactory(run_test_crc)

View File

@@ -112,7 +112,7 @@ async def run_test_crc(dut, ref_crc):
await RisingEdge(dut.clk)
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
if int(cocotb.top.LFSR_POLY.value) == 0x4c11db7:
factory = TestFactory(run_test_crc)

View File

@@ -145,7 +145,7 @@ async def run_test_descramble(dut, ref_scramble, ref_descramble):
await RisingEdge(dut.clk)
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
# if cocotb.top.LFSR_POLY.value == 0x8000000001:
if int(cocotb.top.LFSR_W.value) == 58:

View File

@@ -146,7 +146,7 @@ async def run_test_prbs(dut, ref_prbs):
assert err_cnt == 3
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
if int(cocotb.top.LFSR_POLY.value) == 0x021:
factory = TestFactory(run_test_prbs)

View File

@@ -150,7 +150,7 @@ async def run_test_scramble(dut, ref_scramble):
await RisingEdge(dut.clk)
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
if int(cocotb.top.LFSR_POLY.value) == 0x021:
factory = TestFactory(run_test_prbs)

View File

@@ -128,7 +128,7 @@ async def run_test_scramble(dut, ref_scramble):
await RisingEdge(dut.clk)
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
# if cocotb.top.LFSR_POLY.value == 0x8000000001:
if int(cocotb.top.LFSR_W.value) == 58:

View File

@@ -160,7 +160,7 @@ async def run_test_nack(dut):
await RisingEdge(dut.clk)
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [
run_test_write,

View File

@@ -131,7 +131,7 @@ async def run_test_nack(dut):
await RisingEdge(dut.clk)
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [
run_test_write,

View File

@@ -95,7 +95,7 @@ async def run_test(dut, payload_lengths=None, payload_data=None):
await RisingEdge(dut.clk)
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.generate_tests()

View File

@@ -131,7 +131,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_write, run_test_read]:

View File

@@ -126,7 +126,7 @@ def prbs_payload(length):
return bytearray([next(gen) for x in range(length)])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_tx, run_test_rx]:
factory = TestFactory(test)

View File

@@ -285,7 +285,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [
run_test_write,

View File

@@ -320,7 +320,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [
run_test_write,

View File

@@ -387,7 +387,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [
run_test_write,

View File

@@ -275,7 +275,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [
run_test_acc,

View File

@@ -155,7 +155,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_acc]:

View File

@@ -113,7 +113,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_strings]:

View File

@@ -138,7 +138,7 @@ def incrementing_payload(length):
return bytearray(itertools.islice(itertools.cycle(range(256)), length))
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_tx, run_test_rx]:
factory = TestFactory(test)

View File

@@ -191,7 +191,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_write, run_test_read, run_test_id]:

View File

@@ -191,7 +191,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [run_test_write, run_test_read, run_test_id]:

View File

@@ -297,7 +297,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
for test in [
run_test_write,

View File

@@ -168,7 +168,7 @@ def cycle_pause():
return itertools.cycle([1, 1, 1, 0])
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
ports = len(cocotb.top.xfcp_dsp_us)

View File

@@ -224,7 +224,7 @@ async def run_test(dut):
await RisingEdge(dut.clk)
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.generate_tests()

View File

@@ -472,7 +472,7 @@ async def run_test(dut):
await RisingEdge(dut.clk)
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.generate_tests()

View File

@@ -328,7 +328,7 @@ async def run_test(dut):
await RisingEdge(dut.clk)
if cocotb.SIM_NAME:
if getattr(cocotb, 'top', None) is not None:
factory = TestFactory(run_test)
factory.generate_tests()