From 2a89fb9332291b7367c3064a3ee16f1bb0be4734 Mon Sep 17 00:00:00 2001 From: Alex Forencich Date: Mon, 29 Nov 2021 01:01:45 -0800 Subject: [PATCH] Testbench parameter cleanup --- tb/axis_arb_mux/Makefile | 8 ++++---- tb/axis_arb_mux/test_axis_arb_mux.py | 4 ++-- tb/axis_demux/Makefile | 2 +- tb/axis_demux/test_axis_demux.py | 4 ++-- tb/axis_ram_switch/Makefile | 12 ++++++------ tb/axis_ram_switch/test_axis_ram_switch.py | 6 +++--- tb/axis_switch/Makefile | 12 ++++++------ tb/axis_switch/test_axis_switch.py | 6 +++--- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/tb/axis_arb_mux/Makefile b/tb/axis_arb_mux/Makefile index b4448a5a6..962af950f 100644 --- a/tb/axis_arb_mux/Makefile +++ b/tb/axis_arb_mux/Makefile @@ -26,10 +26,10 @@ WAVES ?= 0 COCOTB_HDL_TIMEUNIT = 1ns COCOTB_HDL_TIMEPRECISION = 1ps -export PARAM_PORTS ?= 4 +export PORTS ?= 4 DUT = axis_arb_mux -WRAPPER = $(DUT)_wrap_$(PARAM_PORTS) +WRAPPER = $(DUT)_wrap_$(PORTS) TOPLEVEL = $(WRAPPER) MODULE = test_$(DUT) VERILOG_SOURCES += $(WRAPPER).v @@ -43,7 +43,7 @@ export PARAM_KEEP_ENABLE ?= $(shell expr $(PARAM_DATA_WIDTH) \> 8 ) export PARAM_KEEP_WIDTH ?= $(shell expr $(PARAM_DATA_WIDTH) / 8 ) export PARAM_ID_ENABLE ?= 1 export PARAM_S_ID_WIDTH ?= 8 -export PARAM_M_ID_WIDTH ?= $(shell python -c "print($(PARAM_S_ID_WIDTH) + ($(PARAM_PORTS)-1).bit_length())") +export PARAM_M_ID_WIDTH ?= $(shell python -c "print($(PARAM_S_ID_WIDTH) + ($(PORTS)-1).bit_length())") export PARAM_DEST_ENABLE ?= 1 export PARAM_DEST_WIDTH ?= 8 export PARAM_USER_ENABLE ?= 1 @@ -101,7 +101,7 @@ endif include $(shell cocotb-config --makefiles)/Makefile.sim $(WRAPPER).v: ../../rtl/$(DUT)_wrap.py - $< -p $(PARAM_PORTS) + $< -p $(PORTS) iverilog_dump.v: echo 'module iverilog_dump();' > $@ diff --git a/tb/axis_arb_mux/test_axis_arb_mux.py b/tb/axis_arb_mux/test_axis_arb_mux.py index eb9fb334d..dfe264b94 100644 --- a/tb/axis_arb_mux/test_axis_arb_mux.py +++ b/tb/axis_arb_mux/test_axis_arb_mux.py @@ -342,8 +342,6 @@ def test_axis_arb_mux(request, ports, data_width, round_robin): parameters = {} - parameters['PORTS'] = ports - parameters['DATA_WIDTH'] = data_width parameters['KEEP_ENABLE'] = int(parameters['DATA_WIDTH'] > 8) parameters['KEEP_WIDTH'] = parameters['DATA_WIDTH'] // 8 @@ -361,6 +359,8 @@ def test_axis_arb_mux(request, ports, data_width, round_robin): extra_env = {f'PARAM_{k}': str(v) for k, v in parameters.items()} + extra_env['PORTS'] = str(ports) + sim_build = os.path.join(tests_dir, "sim_build", request.node.name.replace('[', '-').replace(']', '')) diff --git a/tb/axis_demux/Makefile b/tb/axis_demux/Makefile index 2b081297d..6fd45472c 100644 --- a/tb/axis_demux/Makefile +++ b/tb/axis_demux/Makefile @@ -43,7 +43,7 @@ export PARAM_ID_ENABLE ?= 1 export PARAM_ID_WIDTH ?= 8 export PARAM_DEST_ENABLE ?= 1 export PARAM_M_DEST_WIDTH ?= 8 -export PARAM_S_DEST_WIDTH ?= $(shell python -c "print($(PARAM_M_DEST_WIDTH) + ($(PARAM_PORTS)-1).bit_length())") +export PARAM_S_DEST_WIDTH ?= $(shell python -c "print($(PARAM_M_DEST_WIDTH) + ($(PORTS)-1).bit_length())") export PARAM_USER_ENABLE ?= 1 export PARAM_USER_WIDTH ?= 1 export PARAM_TDEST_ROUTE ?= 1 diff --git a/tb/axis_demux/test_axis_demux.py b/tb/axis_demux/test_axis_demux.py index ee997976a..355eac808 100644 --- a/tb/axis_demux/test_axis_demux.py +++ b/tb/axis_demux/test_axis_demux.py @@ -43,7 +43,7 @@ class TB(object): def __init__(self, dut): self.dut = dut - ports = int(os.getenv("PORTS")) + ports = len(dut.axis_demux_inst.m_axis_tvalid) self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) @@ -143,7 +143,7 @@ def incrementing_payload(length): if cocotb.SIM_NAME: - ports = int(os.getenv("PORTS")) + ports = len(cocotb.top.axis_demux_inst.m_axis_tvalid) factory = TestFactory(run_test) factory.add_option("payload_lengths", [size_list]) diff --git a/tb/axis_ram_switch/Makefile b/tb/axis_ram_switch/Makefile index 6f8ebfd20..adfea859f 100644 --- a/tb/axis_ram_switch/Makefile +++ b/tb/axis_ram_switch/Makefile @@ -26,11 +26,11 @@ WAVES ?= 0 COCOTB_HDL_TIMEUNIT = 1ns COCOTB_HDL_TIMEPRECISION = 1ps -export PARAM_S_COUNT ?= 4 -export PARAM_M_COUNT ?= 4 +export S_COUNT ?= 4 +export M_COUNT ?= 4 DUT = axis_ram_switch -WRAPPER = $(DUT)_wrap_$(PARAM_S_COUNT)x$(PARAM_M_COUNT) +WRAPPER = $(DUT)_wrap_$(S_COUNT)x$(M_COUNT) TOPLEVEL = $(WRAPPER) MODULE = test_$(DUT) VERILOG_SOURCES += $(WRAPPER).v @@ -51,9 +51,9 @@ export PARAM_M_KEEP_ENABLE ?= $(shell expr $(PARAM_M_DATA_WIDTH) \> 8 ) export PARAM_M_KEEP_WIDTH ?= $(shell expr $(PARAM_M_DATA_WIDTH) / 8 ) export PARAM_ID_ENABLE ?= 1 export PARAM_S_ID_WIDTH ?= 16 -export PARAM_M_ID_WIDTH ?= $(shell python -c "print($(PARAM_S_ID_WIDTH) + ($(PARAM_S_COUNT)-1).bit_length())") +export PARAM_M_ID_WIDTH ?= $(shell python -c "print($(PARAM_S_ID_WIDTH) + ($(S_COUNT)-1).bit_length())") export PARAM_M_DEST_WIDTH ?= 8 -export PARAM_S_DEST_WIDTH ?= $(shell python -c "print($(PARAM_M_DEST_WIDTH) + ($(PARAM_M_COUNT)-1).bit_length())") +export PARAM_S_DEST_WIDTH ?= $(shell python -c "print($(PARAM_M_DEST_WIDTH) + ($(M_COUNT)-1).bit_length())") export PARAM_USER_ENABLE ?= 1 export PARAM_USER_WIDTH ?= 1 export PARAM_USER_BAD_FRAME_VALUE ?= 1 @@ -133,7 +133,7 @@ endif include $(shell cocotb-config --makefiles)/Makefile.sim $(WRAPPER).v: ../../rtl/$(DUT)_wrap.py - $< -p $(PARAM_S_COUNT) $(PARAM_M_COUNT) + $< -p $(S_COUNT) $(M_COUNT) iverilog_dump.v: echo 'module iverilog_dump();' > $@ diff --git a/tb/axis_ram_switch/test_axis_ram_switch.py b/tb/axis_ram_switch/test_axis_ram_switch.py index e66c4e99e..e0071deb9 100644 --- a/tb/axis_ram_switch/test_axis_ram_switch.py +++ b/tb/axis_ram_switch/test_axis_ram_switch.py @@ -351,9 +351,6 @@ def test_axis_ram_switch(request, s_count, m_count, s_data_width, m_data_width): parameters = {} - parameters['S_COUNT'] = s_count - parameters['M_COUNT'] = m_count - parameters['FIFO_DEPTH'] = 4096 parameters['CMD_FIFO_DEPTH'] = 32 parameters['SPEEDUP'] = 0 @@ -381,6 +378,9 @@ def test_axis_ram_switch(request, s_count, m_count, s_data_width, m_data_width): extra_env = {f'PARAM_{k}': str(v) for k, v in parameters.items()} + extra_env['S_COUNT'] = str(s_count) + extra_env['M_COUNT'] = str(m_count) + sim_build = os.path.join(tests_dir, "sim_build", request.node.name.replace('[', '-').replace(']', '')) diff --git a/tb/axis_switch/Makefile b/tb/axis_switch/Makefile index 77501e3bb..9cf555993 100644 --- a/tb/axis_switch/Makefile +++ b/tb/axis_switch/Makefile @@ -26,11 +26,11 @@ WAVES ?= 0 COCOTB_HDL_TIMEUNIT = 1ns COCOTB_HDL_TIMEPRECISION = 1ps -export PARAM_S_COUNT ?= 4 -export PARAM_M_COUNT ?= 4 +export S_COUNT ?= 4 +export M_COUNT ?= 4 DUT = axis_switch -WRAPPER = $(DUT)_wrap_$(PARAM_S_COUNT)x$(PARAM_M_COUNT) +WRAPPER = $(DUT)_wrap_$(S_COUNT)x$(M_COUNT) TOPLEVEL = $(WRAPPER) MODULE = test_$(DUT) VERILOG_SOURCES += $(WRAPPER).v @@ -45,9 +45,9 @@ export PARAM_KEEP_ENABLE ?= $(shell expr $(PARAM_DATA_WIDTH) \> 8 ) export PARAM_KEEP_WIDTH ?= $(shell expr $(PARAM_DATA_WIDTH) / 8 ) export PARAM_ID_ENABLE ?= 1 export PARAM_S_ID_WIDTH ?= 16 -export PARAM_M_ID_WIDTH ?= $(shell python -c "print($(PARAM_S_ID_WIDTH) + ($(PARAM_S_COUNT)-1).bit_length())") +export PARAM_M_ID_WIDTH ?= $(shell python -c "print($(PARAM_S_ID_WIDTH) + ($(S_COUNT)-1).bit_length())") export PARAM_M_DEST_WIDTH ?= 8 -export PARAM_S_DEST_WIDTH ?= $(shell python -c "print($(PARAM_M_DEST_WIDTH) + ($(PARAM_M_COUNT)-1).bit_length())") +export PARAM_S_DEST_WIDTH ?= $(shell python -c "print($(PARAM_M_DEST_WIDTH) + ($(M_COUNT)-1).bit_length())") export PARAM_USER_ENABLE ?= 1 export PARAM_USER_WIDTH ?= 1 export PARAM_UPDATE_TID ?= 1 @@ -106,7 +106,7 @@ endif include $(shell cocotb-config --makefiles)/Makefile.sim $(WRAPPER).v: ../../rtl/$(DUT)_wrap.py - $< -p $(PARAM_S_COUNT) $(PARAM_M_COUNT) + $< -p $(S_COUNT) $(M_COUNT) iverilog_dump.v: echo 'module iverilog_dump();' > $@ diff --git a/tb/axis_switch/test_axis_switch.py b/tb/axis_switch/test_axis_switch.py index 3cbf32d71..6bc84d1a7 100644 --- a/tb/axis_switch/test_axis_switch.py +++ b/tb/axis_switch/test_axis_switch.py @@ -349,9 +349,6 @@ def test_axis_switch(request, s_count, m_count, data_width): parameters = {} - parameters['S_COUNT'] = s_count - parameters['M_COUNT'] = m_count - parameters['DATA_WIDTH'] = data_width parameters['KEEP_ENABLE'] = int(parameters['DATA_WIDTH'] > 8) parameters['KEEP_WIDTH'] = parameters['DATA_WIDTH'] // 8 @@ -370,6 +367,9 @@ def test_axis_switch(request, s_count, m_count, data_width): extra_env = {f'PARAM_{k}': str(v) for k, v in parameters.items()} + extra_env['S_COUNT'] = str(s_count) + extra_env['M_COUNT'] = str(m_count) + sim_build = os.path.join(tests_dir, "sim_build", request.node.name.replace('[', '-').replace(']', ''))