diff --git a/tests/apb/Makefile b/tests/apb/Makefile index 25a807e..6a387dd 100644 --- a/tests/apb/Makefile +++ b/tests/apb/Makefile @@ -27,8 +27,10 @@ COCOTB_HDL_TIMEUNIT = 1ns COCOTB_HDL_TIMEPRECISION = 1ns DUT = test_apb -TOPLEVEL = $(DUT) -MODULE = $(DUT) +COCOTB_TEST_MODULES = $(DUT) +COCOTB_TOPLEVEL = $(DUT) +MODULE = $(COCOTB_TEST_MODULES) +TOPLEVEL = $(COCOTB_TOPLEVEL) VERILOG_SOURCES += $(DUT).v # module parameters @@ -39,32 +41,14 @@ export PARAM_STRB_W := $(shell expr $(PARAM_DATA_W) / 8 ) ifeq ($(SIM), icarus) PLUSARGS += -fst - COMPILE_ARGS += $(foreach v,$(filter PARAM_%,$(.VARIABLES)),-P $(TOPLEVEL).$(subst PARAM_,,$(v))=$($(v))) - - ifeq ($(WAVES), 1) - VERILOG_SOURCES += iverilog_dump.v - COMPILE_ARGS += -s iverilog_dump - endif + COMPILE_ARGS += $(foreach v,$(filter PARAM_%,$(.VARIABLES)),-P $(COCOTB_TOPLEVEL).$(subst PARAM_,,$(v))=$($(v))) else ifeq ($(SIM), verilator) - COMPILE_ARGS += -Wno-SELRANGE -Wno-WIDTH - COMPILE_ARGS += $(foreach v,$(filter PARAM_%,$(.VARIABLES)),-G$(subst PARAM_,,$(v))=$($(v))) ifeq ($(WAVES), 1) COMPILE_ARGS += --trace-fst + VERILATOR_TRACE = 1 endif endif include $(shell cocotb-config --makefiles)/Makefile.sim - -iverilog_dump.v: - echo 'module iverilog_dump();' > $@ - echo 'initial begin' >> $@ - echo ' $$dumpfile("$(TOPLEVEL).fst");' >> $@ - echo ' $$dumpvars(0, $(TOPLEVEL));' >> $@ - echo 'end' >> $@ - echo 'endmodule' >> $@ - -clean:: - @rm -rf iverilog_dump.v - @rm -rf dump.fst $(TOPLEVEL).fst diff --git a/tests/apb/test_apb.py b/tests/apb/test_apb.py index 1d766e2..5b9db93 100644 --- a/tests/apb/test_apb.py +++ b/tests/apb/test_apb.py @@ -277,7 +277,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]: diff --git a/tests/axi/Makefile b/tests/axi/Makefile index 932e8b9..d182169 100644 --- a/tests/axi/Makefile +++ b/tests/axi/Makefile @@ -27,8 +27,10 @@ COCOTB_HDL_TIMEUNIT = 1ns COCOTB_HDL_TIMEPRECISION = 1ns DUT = test_axi -TOPLEVEL = $(DUT) -MODULE = $(DUT) +COCOTB_TEST_MODULES = $(DUT) +COCOTB_TOPLEVEL = $(DUT) +MODULE = $(COCOTB_TEST_MODULES) +TOPLEVEL = $(COCOTB_TOPLEVEL) VERILOG_SOURCES += $(DUT).v # module parameters @@ -45,32 +47,14 @@ export PARAM_RUSER_WIDTH := 1 ifeq ($(SIM), icarus) PLUSARGS += -fst - COMPILE_ARGS += $(foreach v,$(filter PARAM_%,$(.VARIABLES)),-P $(TOPLEVEL).$(subst PARAM_,,$(v))=$($(v))) - - ifeq ($(WAVES), 1) - VERILOG_SOURCES += iverilog_dump.v - COMPILE_ARGS += -s iverilog_dump - endif + COMPILE_ARGS += $(foreach v,$(filter PARAM_%,$(.VARIABLES)),-P $(COCOTB_TOPLEVEL).$(subst PARAM_,,$(v))=$($(v))) else ifeq ($(SIM), verilator) - COMPILE_ARGS += -Wno-SELRANGE -Wno-WIDTH -Wno-CASEINCOMPLETE - COMPILE_ARGS += $(foreach v,$(filter PARAM_%,$(.VARIABLES)),-G$(subst PARAM_,,$(v))=$($(v))) ifeq ($(WAVES), 1) COMPILE_ARGS += --trace-fst + VERILATOR_TRACE = 1 endif endif include $(shell cocotb-config --makefiles)/Makefile.sim - -iverilog_dump.v: - echo 'module iverilog_dump();' > $@ - echo 'initial begin' >> $@ - echo ' $$dumpfile("$(TOPLEVEL).fst");' >> $@ - echo ' $$dumpvars(0, $(TOPLEVEL));' >> $@ - echo 'end' >> $@ - echo 'endmodule' >> $@ - -clean:: - @rm -rf iverilog_dump.v - @rm -rf dump.fst $(TOPLEVEL).fst diff --git a/tests/axi/test_axi.py b/tests/axi/test_axi.py index 1595912..f4d5ef1 100644 --- a/tests/axi/test_axi.py +++ b/tests/axi/test_axi.py @@ -296,7 +296,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.axi_wdata) byte_lanes = data_width // 8 diff --git a/tests/axil/Makefile b/tests/axil/Makefile index da366a4..bf62e70 100644 --- a/tests/axil/Makefile +++ b/tests/axil/Makefile @@ -27,8 +27,10 @@ COCOTB_HDL_TIMEUNIT = 1ns COCOTB_HDL_TIMEPRECISION = 1ns DUT = test_axil -TOPLEVEL = $(DUT) -MODULE = $(DUT) +COCOTB_TEST_MODULES = $(DUT) +COCOTB_TOPLEVEL = $(DUT) +MODULE = $(COCOTB_TEST_MODULES) +TOPLEVEL = $(COCOTB_TOPLEVEL) VERILOG_SOURCES += $(DUT).v # module parameters @@ -39,32 +41,14 @@ export PARAM_STRB_WIDTH := $(shell expr $(PARAM_DATA_WIDTH) / 8 ) ifeq ($(SIM), icarus) PLUSARGS += -fst - COMPILE_ARGS += $(foreach v,$(filter PARAM_%,$(.VARIABLES)),-P $(TOPLEVEL).$(subst PARAM_,,$(v))=$($(v))) - - ifeq ($(WAVES), 1) - VERILOG_SOURCES += iverilog_dump.v - COMPILE_ARGS += -s iverilog_dump - endif + COMPILE_ARGS += $(foreach v,$(filter PARAM_%,$(.VARIABLES)),-P $(COCOTB_TOPLEVEL).$(subst PARAM_,,$(v))=$($(v))) else ifeq ($(SIM), verilator) - COMPILE_ARGS += -Wno-SELRANGE -Wno-WIDTH - COMPILE_ARGS += $(foreach v,$(filter PARAM_%,$(.VARIABLES)),-G$(subst PARAM_,,$(v))=$($(v))) ifeq ($(WAVES), 1) COMPILE_ARGS += --trace-fst + VERILATOR_TRACE = 1 endif endif include $(shell cocotb-config --makefiles)/Makefile.sim - -iverilog_dump.v: - echo 'module iverilog_dump();' > $@ - echo 'initial begin' >> $@ - echo ' $$dumpfile("$(TOPLEVEL).fst");' >> $@ - echo ' $$dumpvars(0, $(TOPLEVEL));' >> $@ - echo 'end' >> $@ - echo 'endmodule' >> $@ - -clean:: - @rm -rf iverilog_dump.v - @rm -rf dump.fst $(TOPLEVEL).fst diff --git a/tests/axil/test_axil.py b/tests/axil/test_axil.py index 548840c..3f34184 100644 --- a/tests/axil/test_axil.py +++ b/tests/axil/test_axil.py @@ -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, run_test_read]: diff --git a/tests/axis/Makefile b/tests/axis/Makefile index 4724e0c..858e44b 100644 --- a/tests/axis/Makefile +++ b/tests/axis/Makefile @@ -27,8 +27,10 @@ COCOTB_HDL_TIMEUNIT = 1ns COCOTB_HDL_TIMEPRECISION = 1ns DUT = test_axis -TOPLEVEL = $(DUT) -MODULE = $(DUT) +COCOTB_TEST_MODULES = $(DUT) +COCOTB_TOPLEVEL = $(DUT) +MODULE = $(COCOTB_TEST_MODULES) +TOPLEVEL = $(COCOTB_TOPLEVEL) VERILOG_SOURCES += $(DUT).v # module parameters @@ -41,32 +43,14 @@ export PARAM_USER_WIDTH := 1 ifeq ($(SIM), icarus) PLUSARGS += -fst - COMPILE_ARGS += $(foreach v,$(filter PARAM_%,$(.VARIABLES)),-P $(TOPLEVEL).$(subst PARAM_,,$(v))=$($(v))) - - ifeq ($(WAVES), 1) - VERILOG_SOURCES += iverilog_dump.v - COMPILE_ARGS += -s iverilog_dump - endif + COMPILE_ARGS += $(foreach v,$(filter PARAM_%,$(.VARIABLES)),-P $(COCOTB_TOPLEVEL).$(subst PARAM_,,$(v))=$($(v))) else ifeq ($(SIM), verilator) - COMPILE_ARGS += -Wno-SELRANGE -Wno-WIDTH - COMPILE_ARGS += $(foreach v,$(filter PARAM_%,$(.VARIABLES)),-G$(subst PARAM_,,$(v))=$($(v))) ifeq ($(WAVES), 1) COMPILE_ARGS += --trace-fst + VERILATOR_TRACE = 1 endif endif include $(shell cocotb-config --makefiles)/Makefile.sim - -iverilog_dump.v: - echo 'module iverilog_dump();' > $@ - echo 'initial begin' >> $@ - echo ' $$dumpfile("$(TOPLEVEL).fst");' >> $@ - echo ' $$dumpvars(0, $(TOPLEVEL));' >> $@ - echo 'end' >> $@ - echo 'endmodule' >> $@ - -clean:: - @rm -rf iverilog_dump.v - @rm -rf dump.fst $(TOPLEVEL).fst diff --git a/tests/axis/test_axis.py b/tests/axis/test_axis.py index 7ed0aab..4b5740c 100644 --- a/tests/axis/test_axis.py +++ b/tests/axis/test_axis.py @@ -135,7 +135,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])