Skip to content

Commit 2a89fb9

Browse files
committed
Testbench parameter cleanup
1 parent e4b4762 commit 2a89fb9

File tree

8 files changed

+27
-27
lines changed

8 files changed

+27
-27
lines changed

tb/axis_arb_mux/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ WAVES ?= 0
2626
COCOTB_HDL_TIMEUNIT = 1ns
2727
COCOTB_HDL_TIMEPRECISION = 1ps
2828

29-
export PARAM_PORTS ?= 4
29+
export PORTS ?= 4
3030

3131
DUT = axis_arb_mux
32-
WRAPPER = $(DUT)_wrap_$(PARAM_PORTS)
32+
WRAPPER = $(DUT)_wrap_$(PORTS)
3333
TOPLEVEL = $(WRAPPER)
3434
MODULE = test_$(DUT)
3535
VERILOG_SOURCES += $(WRAPPER).v
@@ -43,7 +43,7 @@ export PARAM_KEEP_ENABLE ?= $(shell expr $(PARAM_DATA_WIDTH) \> 8 )
4343
export PARAM_KEEP_WIDTH ?= $(shell expr $(PARAM_DATA_WIDTH) / 8 )
4444
export PARAM_ID_ENABLE ?= 1
4545
export PARAM_S_ID_WIDTH ?= 8
46-
export PARAM_M_ID_WIDTH ?= $(shell python -c "print($(PARAM_S_ID_WIDTH) + ($(PARAM_PORTS)-1).bit_length())")
46+
export PARAM_M_ID_WIDTH ?= $(shell python -c "print($(PARAM_S_ID_WIDTH) + ($(PORTS)-1).bit_length())")
4747
export PARAM_DEST_ENABLE ?= 1
4848
export PARAM_DEST_WIDTH ?= 8
4949
export PARAM_USER_ENABLE ?= 1
@@ -101,7 +101,7 @@ endif
101101
include $(shell cocotb-config --makefiles)/Makefile.sim
102102

103103
$(WRAPPER).v: ../../rtl/$(DUT)_wrap.py
104-
$< -p $(PARAM_PORTS)
104+
$< -p $(PORTS)
105105

106106
iverilog_dump.v:
107107
echo 'module iverilog_dump();' > $@

tb/axis_arb_mux/test_axis_arb_mux.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,6 @@ def test_axis_arb_mux(request, ports, data_width, round_robin):
342342

343343
parameters = {}
344344

345-
parameters['PORTS'] = ports
346-
347345
parameters['DATA_WIDTH'] = data_width
348346
parameters['KEEP_ENABLE'] = int(parameters['DATA_WIDTH'] > 8)
349347
parameters['KEEP_WIDTH'] = parameters['DATA_WIDTH'] // 8
@@ -361,6 +359,8 @@ def test_axis_arb_mux(request, ports, data_width, round_robin):
361359

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

362+
extra_env['PORTS'] = str(ports)
363+
364364
sim_build = os.path.join(tests_dir, "sim_build",
365365
request.node.name.replace('[', '-').replace(']', ''))
366366

tb/axis_demux/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export PARAM_ID_ENABLE ?= 1
4343
export PARAM_ID_WIDTH ?= 8
4444
export PARAM_DEST_ENABLE ?= 1
4545
export PARAM_M_DEST_WIDTH ?= 8
46-
export PARAM_S_DEST_WIDTH ?= $(shell python -c "print($(PARAM_M_DEST_WIDTH) + ($(PARAM_PORTS)-1).bit_length())")
46+
export PARAM_S_DEST_WIDTH ?= $(shell python -c "print($(PARAM_M_DEST_WIDTH) + ($(PORTS)-1).bit_length())")
4747
export PARAM_USER_ENABLE ?= 1
4848
export PARAM_USER_WIDTH ?= 1
4949
export PARAM_TDEST_ROUTE ?= 1

tb/axis_demux/test_axis_demux.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class TB(object):
4343
def __init__(self, dut):
4444
self.dut = dut
4545

46-
ports = int(os.getenv("PORTS"))
46+
ports = len(dut.axis_demux_inst.m_axis_tvalid)
4747

4848
self.log = logging.getLogger("cocotb.tb")
4949
self.log.setLevel(logging.DEBUG)
@@ -143,7 +143,7 @@ def incrementing_payload(length):
143143

144144
if cocotb.SIM_NAME:
145145

146-
ports = int(os.getenv("PORTS"))
146+
ports = len(cocotb.top.axis_demux_inst.m_axis_tvalid)
147147

148148
factory = TestFactory(run_test)
149149
factory.add_option("payload_lengths", [size_list])

tb/axis_ram_switch/Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ WAVES ?= 0
2626
COCOTB_HDL_TIMEUNIT = 1ns
2727
COCOTB_HDL_TIMEPRECISION = 1ps
2828

29-
export PARAM_S_COUNT ?= 4
30-
export PARAM_M_COUNT ?= 4
29+
export S_COUNT ?= 4
30+
export M_COUNT ?= 4
3131

3232
DUT = axis_ram_switch
33-
WRAPPER = $(DUT)_wrap_$(PARAM_S_COUNT)x$(PARAM_M_COUNT)
33+
WRAPPER = $(DUT)_wrap_$(S_COUNT)x$(M_COUNT)
3434
TOPLEVEL = $(WRAPPER)
3535
MODULE = test_$(DUT)
3636
VERILOG_SOURCES += $(WRAPPER).v
@@ -51,9 +51,9 @@ export PARAM_M_KEEP_ENABLE ?= $(shell expr $(PARAM_M_DATA_WIDTH) \> 8 )
5151
export PARAM_M_KEEP_WIDTH ?= $(shell expr $(PARAM_M_DATA_WIDTH) / 8 )
5252
export PARAM_ID_ENABLE ?= 1
5353
export PARAM_S_ID_WIDTH ?= 16
54-
export PARAM_M_ID_WIDTH ?= $(shell python -c "print($(PARAM_S_ID_WIDTH) + ($(PARAM_S_COUNT)-1).bit_length())")
54+
export PARAM_M_ID_WIDTH ?= $(shell python -c "print($(PARAM_S_ID_WIDTH) + ($(S_COUNT)-1).bit_length())")
5555
export PARAM_M_DEST_WIDTH ?= 8
56-
export PARAM_S_DEST_WIDTH ?= $(shell python -c "print($(PARAM_M_DEST_WIDTH) + ($(PARAM_M_COUNT)-1).bit_length())")
56+
export PARAM_S_DEST_WIDTH ?= $(shell python -c "print($(PARAM_M_DEST_WIDTH) + ($(M_COUNT)-1).bit_length())")
5757
export PARAM_USER_ENABLE ?= 1
5858
export PARAM_USER_WIDTH ?= 1
5959
export PARAM_USER_BAD_FRAME_VALUE ?= 1
@@ -133,7 +133,7 @@ endif
133133
include $(shell cocotb-config --makefiles)/Makefile.sim
134134

135135
$(WRAPPER).v: ../../rtl/$(DUT)_wrap.py
136-
$< -p $(PARAM_S_COUNT) $(PARAM_M_COUNT)
136+
$< -p $(S_COUNT) $(M_COUNT)
137137

138138
iverilog_dump.v:
139139
echo 'module iverilog_dump();' > $@

tb/axis_ram_switch/test_axis_ram_switch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,6 @@ def test_axis_ram_switch(request, s_count, m_count, s_data_width, m_data_width):
351351

352352
parameters = {}
353353

354-
parameters['S_COUNT'] = s_count
355-
parameters['M_COUNT'] = m_count
356-
357354
parameters['FIFO_DEPTH'] = 4096
358355
parameters['CMD_FIFO_DEPTH'] = 32
359356
parameters['SPEEDUP'] = 0
@@ -381,6 +378,9 @@ def test_axis_ram_switch(request, s_count, m_count, s_data_width, m_data_width):
381378

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

381+
extra_env['S_COUNT'] = str(s_count)
382+
extra_env['M_COUNT'] = str(m_count)
383+
384384
sim_build = os.path.join(tests_dir, "sim_build",
385385
request.node.name.replace('[', '-').replace(']', ''))
386386

tb/axis_switch/Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ WAVES ?= 0
2626
COCOTB_HDL_TIMEUNIT = 1ns
2727
COCOTB_HDL_TIMEPRECISION = 1ps
2828

29-
export PARAM_S_COUNT ?= 4
30-
export PARAM_M_COUNT ?= 4
29+
export S_COUNT ?= 4
30+
export M_COUNT ?= 4
3131

3232
DUT = axis_switch
33-
WRAPPER = $(DUT)_wrap_$(PARAM_S_COUNT)x$(PARAM_M_COUNT)
33+
WRAPPER = $(DUT)_wrap_$(S_COUNT)x$(M_COUNT)
3434
TOPLEVEL = $(WRAPPER)
3535
MODULE = test_$(DUT)
3636
VERILOG_SOURCES += $(WRAPPER).v
@@ -45,9 +45,9 @@ export PARAM_KEEP_ENABLE ?= $(shell expr $(PARAM_DATA_WIDTH) \> 8 )
4545
export PARAM_KEEP_WIDTH ?= $(shell expr $(PARAM_DATA_WIDTH) / 8 )
4646
export PARAM_ID_ENABLE ?= 1
4747
export PARAM_S_ID_WIDTH ?= 16
48-
export PARAM_M_ID_WIDTH ?= $(shell python -c "print($(PARAM_S_ID_WIDTH) + ($(PARAM_S_COUNT)-1).bit_length())")
48+
export PARAM_M_ID_WIDTH ?= $(shell python -c "print($(PARAM_S_ID_WIDTH) + ($(S_COUNT)-1).bit_length())")
4949
export PARAM_M_DEST_WIDTH ?= 8
50-
export PARAM_S_DEST_WIDTH ?= $(shell python -c "print($(PARAM_M_DEST_WIDTH) + ($(PARAM_M_COUNT)-1).bit_length())")
50+
export PARAM_S_DEST_WIDTH ?= $(shell python -c "print($(PARAM_M_DEST_WIDTH) + ($(M_COUNT)-1).bit_length())")
5151
export PARAM_USER_ENABLE ?= 1
5252
export PARAM_USER_WIDTH ?= 1
5353
export PARAM_UPDATE_TID ?= 1
@@ -106,7 +106,7 @@ endif
106106
include $(shell cocotb-config --makefiles)/Makefile.sim
107107

108108
$(WRAPPER).v: ../../rtl/$(DUT)_wrap.py
109-
$< -p $(PARAM_S_COUNT) $(PARAM_M_COUNT)
109+
$< -p $(S_COUNT) $(M_COUNT)
110110

111111
iverilog_dump.v:
112112
echo 'module iverilog_dump();' > $@

tb/axis_switch/test_axis_switch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,6 @@ def test_axis_switch(request, s_count, m_count, data_width):
349349

350350
parameters = {}
351351

352-
parameters['S_COUNT'] = s_count
353-
parameters['M_COUNT'] = m_count
354-
355352
parameters['DATA_WIDTH'] = data_width
356353
parameters['KEEP_ENABLE'] = int(parameters['DATA_WIDTH'] > 8)
357354
parameters['KEEP_WIDTH'] = parameters['DATA_WIDTH'] // 8
@@ -370,6 +367,9 @@ def test_axis_switch(request, s_count, m_count, data_width):
370367

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

370+
extra_env['S_COUNT'] = str(s_count)
371+
extra_env['M_COUNT'] = str(m_count)
372+
373373
sim_build = os.path.join(tests_dir, "sim_build",
374374
request.node.name.replace('[', '-').replace(']', ''))
375375

0 commit comments

Comments
 (0)