Skip to content

Commit 67aaa79

Browse files
committed
Testbench cleanup for cocotb 2.0
Signed-off-by: Alex Forencich <[email protected]>
1 parent 4497a86 commit 67aaa79

File tree

2 files changed

+9
-21
lines changed

2 files changed

+9
-21
lines changed

tests/i2c/Makefile

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,23 @@ COCOTB_HDL_TIMEUNIT = 1ns
2727
COCOTB_HDL_TIMEPRECISION = 1ns
2828

2929
DUT = test_i2c
30-
TOPLEVEL = $(DUT)
31-
MODULE = $(DUT)
30+
COCOTB_TEST_MODULES = $(DUT)
31+
COCOTB_TOPLEVEL = $(DUT)
32+
MODULE = $(COCOTB_TEST_MODULES)
33+
TOPLEVEL = $(COCOTB_TOPLEVEL)
3234
VERILOG_SOURCES += $(DUT).v
3335

3436
ifeq ($(SIM), icarus)
3537
PLUSARGS += -fst
3638

37-
ifeq ($(WAVES), 1)
38-
VERILOG_SOURCES += iverilog_dump.v
39-
COMPILE_ARGS += -s iverilog_dump
40-
endif
39+
COMPILE_ARGS += $(foreach v,$(filter PARAM_%,$(.VARIABLES)),-P $(COCOTB_TOPLEVEL).$(subst PARAM_,,$(v))=$($(v)))
4140
else ifeq ($(SIM), verilator)
42-
COMPILE_ARGS += -Wno-SELRANGE -Wno-WIDTH
41+
COMPILE_ARGS += $(foreach v,$(filter PARAM_%,$(.VARIABLES)),-G$(subst PARAM_,,$(v))=$($(v)))
4342

4443
ifeq ($(WAVES), 1)
4544
COMPILE_ARGS += --trace-fst
45+
VERILATOR_TRACE = 1
4646
endif
4747
endif
4848

49-
include $(shell cocotb-config --makefiles)/Makefile.sim
50-
51-
iverilog_dump.v:
52-
echo 'module iverilog_dump();' > $@
53-
echo 'initial begin' >> $@
54-
echo ' $$dumpfile("$(TOPLEVEL).fst");' >> $@
55-
echo ' $$dumpvars(0, $(TOPLEVEL));' >> $@
56-
echo 'end' >> $@
57-
echo 'endmodule' >> $@
58-
59-
clean::
60-
@rm -rf iverilog_dump.v
61-
@rm -rf dump.fst $(TOPLEVEL).fst
49+
include $(shell cocotb-config --makefiles)/Makefile.sim

tests/i2c/test_i2c.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ async def run_test(dut, payload_lengths=None, payload_data=None):
7070
assert test_data == data
7171

7272

73-
if cocotb.SIM_NAME:
73+
if getattr(cocotb, 'top', None) is not None:
7474

7575
factory = TestFactory(run_test)
7676
factory.generate_tests()

0 commit comments

Comments
 (0)