Skip to content

Commit d549267

Browse files
committed
Test async FIFO with different clock periods
1 parent 6c23426 commit d549267

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tb/axis_async_fifo/test_axis_async_fifo.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ def __init__(self, dut):
4646
self.log = logging.getLogger("cocotb.tb")
4747
self.log.setLevel(logging.DEBUG)
4848

49-
cocotb.fork(Clock(dut.s_clk, 10, units="ns").start())
50-
cocotb.fork(Clock(dut.m_clk, 11, units="ns").start())
49+
s_clk = int(os.getenv("S_CLK", "10"))
50+
m_clk = int(os.getenv("M_CLK", "11"))
51+
52+
cocotb.fork(Clock(dut.s_clk, s_clk, units="ns").start())
53+
cocotb.fork(Clock(dut.m_clk, m_clk, units="ns").start())
5154

5255
self.source = AxiStreamSource(AxiStreamBus.from_prefix(dut, "s_axis"), dut.s_clk, dut.async_rst)
5356
self.sink = AxiStreamSink(AxiStreamBus.from_prefix(dut, "m_axis"), dut.m_clk, dut.async_rst)
@@ -307,10 +310,13 @@ def incrementing_payload(length):
307310
rtl_dir = os.path.abspath(os.path.join(tests_dir, '..', '..', 'rtl'))
308311

309312

313+
@pytest.mark.parametrize(("s_clk", "m_clk"), [(10, 10), (10, 11), (11, 10)])
310314
@pytest.mark.parametrize(("frame_fifo", "drop_oversize_frame", "drop_bad_frame", "drop_when_full"),
311315
[(0, 0, 0, 0), (1, 0, 0, 0), (1, 1, 0, 0), (1, 1, 1, 0)])
312316
@pytest.mark.parametrize("data_width", [8, 16, 32, 64])
313-
def test_axis_async_fifo(request, data_width, frame_fifo, drop_oversize_frame, drop_bad_frame, drop_when_full):
317+
def test_axis_async_fifo(request, data_width, frame_fifo, drop_oversize_frame, drop_bad_frame,
318+
drop_when_full, s_clk, m_clk):
319+
314320
dut = "axis_async_fifo"
315321
module = os.path.splitext(os.path.basename(__file__))[0]
316322
toplevel = dut
@@ -342,6 +348,9 @@ def test_axis_async_fifo(request, data_width, frame_fifo, drop_oversize_frame, d
342348

343349
extra_env = {f'PARAM_{k}': str(v) for k, v in parameters.items()}
344350

351+
extra_env['S_CLK'] = str(s_clk)
352+
extra_env['M_CLK'] = str(m_clk)
353+
345354
sim_build = os.path.join(tests_dir, "sim_build",
346355
request.node.name.replace('[', '-').replace(']', ''))
347356

0 commit comments

Comments
 (0)