Skip to content

Commit

Permalink
Add support for file list files
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Forencich <[email protected]>
  • Loading branch information
alexforencich committed Aug 6, 2024
1 parent c1c3dc0 commit 664ab9f
Show file tree
Hide file tree
Showing 24 changed files with 207 additions and 48 deletions.
3 changes: 3 additions & 0 deletions rtl/axis_arb_mux.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
axis_arb_mux.v
arbiter.v
priority_encoder.v
3 changes: 3 additions & 0 deletions rtl/axis_async_fifo_adapter.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
axis_async_fifo_adapter.v
axis_async_fifo.v
axis_adapter.v
2 changes: 2 additions & 0 deletions rtl/axis_cobs_encode.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
axis_cobs_encode.v
axis_fifo.v
3 changes: 3 additions & 0 deletions rtl/axis_fifo_adapter.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
axis_fifo_adapter.v
axis_fifo.v
axis_adapter.v
3 changes: 3 additions & 0 deletions rtl/axis_frame_length_adjust_fifo.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
axis_frame_length_adjust_fifo.v
axis_frame_length_adjust.v
axis_fifo.v
2 changes: 2 additions & 0 deletions rtl/axis_pipeline_register.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
axis_pipeline_register.v
axis_register.v
4 changes: 4 additions & 0 deletions rtl/axis_ram_switch.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
axis_ram_switch.v
axis_adapter.v
arbiter.v
priority_encoder.v
4 changes: 4 additions & 0 deletions rtl/axis_switch.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
axis_switch.v
axis_register.v
arbiter.v
priority_encoder.v
10 changes: 7 additions & 3 deletions tb/axis_arb_mux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ WRAPPER = $(DUT)_wrap_$(PORTS)
TOPLEVEL = $(WRAPPER)
MODULE = test_$(DUT)
VERILOG_SOURCES += $(WRAPPER).v
VERILOG_SOURCES += ../../rtl/$(DUT).v
VERILOG_SOURCES += ../../rtl/arbiter.v
VERILOG_SOURCES += ../../rtl/priority_encoder.v
VERILOG_SOURCES += ../../rtl/$(DUT).f

# handle file list files
process_f_file = $(call process_f_files,$(addprefix $(dir $1),$(shell cat $1)))
process_f_files = $(foreach f,$1,$(if $(filter %.f,$f),$(call process_f_file,$f),$f))
uniq_base = $(if $1,$(call uniq_base,$(foreach f,$1,$(if $(filter-out $(notdir $(lastword $1)),$(notdir $f)),$f,))) $(lastword $1))
VERILOG_SOURCES := $(call uniq_base,$(call process_f_files,$(VERILOG_SOURCES)))

# module parameters
export PARAM_DATA_WIDTH := 8
Expand Down
19 changes: 16 additions & 3 deletions tb/axis_arb_mux/test_axis_arb_mux.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,19 @@ def incrementing_payload(length):
rtl_dir = os.path.abspath(os.path.join(tests_dir, '..', '..', 'rtl'))


def process_f_files(files):
lst = {}
for f in files:
if f[-2:].lower() == '.f':
with open(f, 'r') as fp:
l = fp.read().split()
for f in process_f_files([os.path.join(os.path.dirname(f), x) for x in l]):
lst[os.path.basename(f)] = f
else:
lst[os.path.basename(f)] = f
return list(lst.values())


@pytest.mark.parametrize("round_robin", [0, 1])
@pytest.mark.parametrize("data_width", [8, 16, 32])
@pytest.mark.parametrize("ports", [1, 4])
Expand All @@ -335,11 +348,11 @@ def test_axis_arb_mux(request, ports, data_width, round_robin):

verilog_sources = [
wrapper_file,
os.path.join(rtl_dir, f"{dut}.v"),
os.path.join(rtl_dir, "arbiter.v"),
os.path.join(rtl_dir, "priority_encoder.v"),
os.path.join(rtl_dir, f"{dut}.f"),
]

verilog_sources = process_f_files(verilog_sources)

parameters = {}

parameters['DATA_WIDTH'] = data_width
Expand Down
10 changes: 7 additions & 3 deletions tb/axis_async_fifo_adapter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ COCOTB_HDL_TIMEPRECISION = 1ps
DUT = axis_async_fifo_adapter
TOPLEVEL = $(DUT)
MODULE = test_$(DUT)
VERILOG_SOURCES += ../../rtl/$(DUT).v
VERILOG_SOURCES += ../../rtl/axis_async_fifo.v
VERILOG_SOURCES += ../../rtl/axis_adapter.v
VERILOG_SOURCES += ../../rtl/$(DUT).f

# handle file list files
process_f_file = $(call process_f_files,$(addprefix $(dir $1),$(shell cat $1)))
process_f_files = $(foreach f,$1,$(if $(filter %.f,$f),$(call process_f_file,$f),$f))
uniq_base = $(if $1,$(call uniq_base,$(foreach f,$1,$(if $(filter-out $(notdir $(lastword $1)),$(notdir $f)),$f,))) $(lastword $1))
VERILOG_SOURCES := $(call uniq_base,$(call process_f_files,$(VERILOG_SOURCES)))

# module parameters
export PARAM_S_DATA_WIDTH := 8
Expand Down
19 changes: 16 additions & 3 deletions tb/axis_async_fifo_adapter/test_axis_async_fifo_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,19 @@ def incrementing_payload(length):
rtl_dir = os.path.abspath(os.path.join(tests_dir, '..', '..', 'rtl'))


def process_f_files(files):
lst = {}
for f in files:
if f[-2:].lower() == '.f':
with open(f, 'r') as fp:
l = fp.read().split()
for f in process_f_files([os.path.join(os.path.dirname(f), x) for x in l]):
lst[os.path.basename(f)] = f
else:
lst[os.path.basename(f)] = f
return list(lst.values())


@pytest.mark.parametrize(("frame_fifo", "drop_oversize_frame", "drop_bad_frame",
"drop_when_full", "mark_when_full"),
[(0, 0, 0, 0, 0), (1, 0, 0, 0, 0), (1, 1, 0, 0, 0), (1, 1, 1, 0, 0),
Expand All @@ -676,11 +689,11 @@ def test_axis_async_fifo_adapter(request, s_data_width, m_data_width,
toplevel = dut

verilog_sources = [
os.path.join(rtl_dir, f"{dut}.v"),
os.path.join(rtl_dir, "axis_async_fifo.v"),
os.path.join(rtl_dir, "axis_adapter.v"),
os.path.join(rtl_dir, f"{dut}.f"),
]

verilog_sources = process_f_files(verilog_sources)

parameters = {}

parameters['S_DATA_WIDTH'] = s_data_width
Expand Down
9 changes: 7 additions & 2 deletions tb/axis_cobs_encode/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ COCOTB_HDL_TIMEPRECISION = 1ps
DUT = axis_cobs_encode
TOPLEVEL = $(DUT)
MODULE = test_$(DUT)
VERILOG_SOURCES += ../../rtl/$(DUT).v
VERILOG_SOURCES += ../../rtl/axis_fifo.v
VERILOG_SOURCES += ../../rtl/$(DUT).f

# handle file list files
process_f_file = $(call process_f_files,$(addprefix $(dir $1),$(shell cat $1)))
process_f_files = $(foreach f,$1,$(if $(filter %.f,$f),$(call process_f_file,$f),$f))
uniq_base = $(if $1,$(call uniq_base,$(foreach f,$1,$(if $(filter-out $(notdir $(lastword $1)),$(notdir $f)),$f,))) $(lastword $1))
VERILOG_SOURCES := $(call uniq_base,$(call process_f_files,$(VERILOG_SOURCES)))

# module parameters
export PARAM_APPEND_ZERO := 0
Expand Down
18 changes: 16 additions & 2 deletions tb/axis_cobs_encode/test_axis_cobs_encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,31 @@ def prbs_payload(length):
rtl_dir = os.path.abspath(os.path.join(tests_dir, '..', '..', 'rtl'))


def process_f_files(files):
lst = {}
for f in files:
if f[-2:].lower() == '.f':
with open(f, 'r') as fp:
l = fp.read().split()
for f in process_f_files([os.path.join(os.path.dirname(f), x) for x in l]):
lst[os.path.basename(f)] = f
else:
lst[os.path.basename(f)] = f
return list(lst.values())


@pytest.mark.parametrize("append_zero", [0, 1])
def test_axis_cobs_encode(request, append_zero):
dut = "axis_cobs_encode"
module = os.path.splitext(os.path.basename(__file__))[0]
toplevel = dut

verilog_sources = [
os.path.join(rtl_dir, f"{dut}.v"),
os.path.join(rtl_dir, "axis_fifo.v"),
os.path.join(rtl_dir, f"{dut}.f"),
]

verilog_sources = process_f_files(verilog_sources)

parameters = {}

parameters['APPEND_ZERO'] = append_zero
Expand Down
10 changes: 7 additions & 3 deletions tb/axis_fifo_adapter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ COCOTB_HDL_TIMEPRECISION = 1ps
DUT = axis_fifo_adapter
TOPLEVEL = $(DUT)
MODULE = test_$(DUT)
VERILOG_SOURCES += ../../rtl/$(DUT).v
VERILOG_SOURCES += ../../rtl/axis_fifo.v
VERILOG_SOURCES += ../../rtl/axis_adapter.v
VERILOG_SOURCES += ../../rtl/$(DUT).f

# handle file list files
process_f_file = $(call process_f_files,$(addprefix $(dir $1),$(shell cat $1)))
process_f_files = $(foreach f,$1,$(if $(filter %.f,$f),$(call process_f_file,$f),$f))
uniq_base = $(if $1,$(call uniq_base,$(foreach f,$1,$(if $(filter-out $(notdir $(lastword $1)),$(notdir $f)),$f,))) $(lastword $1))
VERILOG_SOURCES := $(call uniq_base,$(call process_f_files,$(VERILOG_SOURCES)))

# module parameters
export PARAM_S_DATA_WIDTH := 8
Expand Down
19 changes: 16 additions & 3 deletions tb/axis_fifo_adapter/test_axis_fifo_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,19 @@ def incrementing_payload(length):
rtl_dir = os.path.abspath(os.path.join(tests_dir, '..', '..', 'rtl'))


def process_f_files(files):
lst = {}
for f in files:
if f[-2:].lower() == '.f':
with open(f, 'r') as fp:
l = fp.read().split()
for f in process_f_files([os.path.join(os.path.dirname(f), x) for x in l]):
lst[os.path.basename(f)] = f
else:
lst[os.path.basename(f)] = f
return list(lst.values())


@pytest.mark.parametrize(("frame_fifo", "drop_oversize_frame", "drop_bad_frame",
"drop_when_full", "mark_when_full"),
[(0, 0, 0, 0, 0), (1, 0, 0, 0, 0), (1, 1, 0, 0, 0), (1, 1, 1, 0, 0),
Expand All @@ -459,11 +472,11 @@ def test_axis_fifo_adapter(request, s_data_width, m_data_width,
toplevel = dut

verilog_sources = [
os.path.join(rtl_dir, f"{dut}.v"),
os.path.join(rtl_dir, "axis_fifo.v"),
os.path.join(rtl_dir, "axis_adapter.v"),
os.path.join(rtl_dir, f"{dut}.f"),
]

verilog_sources = process_f_files(verilog_sources)

parameters = {}

parameters['S_DATA_WIDTH'] = s_data_width
Expand Down
10 changes: 7 additions & 3 deletions tb/axis_frame_length_adjust_fifo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ COCOTB_HDL_TIMEPRECISION = 1ps
DUT = axis_frame_length_adjust_fifo
TOPLEVEL = $(DUT)
MODULE = test_$(DUT)
VERILOG_SOURCES += ../../rtl/$(DUT).v
VERILOG_SOURCES += ../../rtl/axis_frame_length_adjust.v
VERILOG_SOURCES += ../../rtl/axis_fifo.v
VERILOG_SOURCES += ../../rtl/$(DUT).f

# handle file list files
process_f_file = $(call process_f_files,$(addprefix $(dir $1),$(shell cat $1)))
process_f_files = $(foreach f,$1,$(if $(filter %.f,$f),$(call process_f_file,$f),$f))
uniq_base = $(if $1,$(call uniq_base,$(foreach f,$1,$(if $(filter-out $(notdir $(lastword $1)),$(notdir $f)),$f,))) $(lastword $1))
VERILOG_SOURCES := $(call uniq_base,$(call process_f_files,$(VERILOG_SOURCES)))

# module parameters
export PARAM_DATA_WIDTH := 8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,18 +290,31 @@ def incrementing_payload(length):
rtl_dir = os.path.abspath(os.path.join(tests_dir, '..', '..', 'rtl'))


def process_f_files(files):
lst = {}
for f in files:
if f[-2:].lower() == '.f':
with open(f, 'r') as fp:
l = fp.read().split()
for f in process_f_files([os.path.join(os.path.dirname(f), x) for x in l]):
lst[os.path.basename(f)] = f
else:
lst[os.path.basename(f)] = f
return list(lst.values())


@pytest.mark.parametrize("data_width", [8, 16, 32])
def test_axis_frame_length_adjust_fifo(request, data_width):
dut = "axis_frame_length_adjust_fifo"
module = os.path.splitext(os.path.basename(__file__))[0]
toplevel = dut

verilog_sources = [
os.path.join(rtl_dir, f"{dut}.v"),
os.path.join(rtl_dir, f"axis_frame_length_adjust.v"),
os.path.join(rtl_dir, f"axis_fifo.v"),
os.path.join(rtl_dir, f"{dut}.f"),
]

verilog_sources = process_f_files(verilog_sources)

parameters = {}

parameters['DATA_WIDTH'] = data_width
Expand Down
9 changes: 7 additions & 2 deletions tb/axis_pipeline_register/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ COCOTB_HDL_TIMEPRECISION = 1ps
DUT = axis_pipeline_register
TOPLEVEL = $(DUT)
MODULE = test_$(DUT)
VERILOG_SOURCES += ../../rtl/$(DUT).v
VERILOG_SOURCES += ../../rtl/axis_register.v
VERILOG_SOURCES += ../../rtl/$(DUT).f

# handle file list files
process_f_file = $(call process_f_files,$(addprefix $(dir $1),$(shell cat $1)))
process_f_files = $(foreach f,$1,$(if $(filter %.f,$f),$(call process_f_file,$f),$f))
uniq_base = $(if $1,$(call uniq_base,$(foreach f,$1,$(if $(filter-out $(notdir $(lastword $1)),$(notdir $f)),$f,))) $(lastword $1))
VERILOG_SOURCES := $(call uniq_base,$(call process_f_files,$(VERILOG_SOURCES)))

# module parameters
export PARAM_DATA_WIDTH := 8
Expand Down
18 changes: 16 additions & 2 deletions tb/axis_pipeline_register/test_axis_pipeline_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,19 @@ def incrementing_payload(length):
rtl_dir = os.path.abspath(os.path.join(tests_dir, '..', '..', 'rtl'))


def process_f_files(files):
lst = {}
for f in files:
if f[-2:].lower() == '.f':
with open(f, 'r') as fp:
l = fp.read().split()
for f in process_f_files([os.path.join(os.path.dirname(f), x) for x in l]):
lst[os.path.basename(f)] = f
else:
lst[os.path.basename(f)] = f
return list(lst.values())


@pytest.mark.parametrize("reg_type", [0, 1, 2])
@pytest.mark.parametrize("data_width", [8, 16, 32])
@pytest.mark.parametrize("length", [0, 1, 2])
Expand All @@ -221,10 +234,11 @@ def test_axis_pipeline_register(request, length, data_width, reg_type):
toplevel = dut

verilog_sources = [
os.path.join(rtl_dir, f"{dut}.v"),
os.path.join(rtl_dir, "axis_register.v"),
os.path.join(rtl_dir, f"{dut}.f"),
]

verilog_sources = process_f_files(verilog_sources)

parameters = {}

parameters['DATA_WIDTH'] = data_width
Expand Down
11 changes: 7 additions & 4 deletions tb/axis_ram_switch/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ WRAPPER = $(DUT)_wrap_$(S_COUNT)x$(M_COUNT)
TOPLEVEL = $(WRAPPER)
MODULE = test_$(DUT)
VERILOG_SOURCES += $(WRAPPER).v
VERILOG_SOURCES += ../../rtl/$(DUT).v
VERILOG_SOURCES += ../../rtl/axis_adapter.v
VERILOG_SOURCES += ../../rtl/arbiter.v
VERILOG_SOURCES += ../../rtl/priority_encoder.v
VERILOG_SOURCES += ../../rtl/$(DUT).f

# handle file list files
process_f_file = $(call process_f_files,$(addprefix $(dir $1),$(shell cat $1)))
process_f_files = $(foreach f,$1,$(if $(filter %.f,$f),$(call process_f_file,$f),$f))
uniq_base = $(if $1,$(call uniq_base,$(foreach f,$1,$(if $(filter-out $(notdir $(lastword $1)),$(notdir $f)),$f,))) $(lastword $1))
VERILOG_SOURCES := $(call uniq_base,$(call process_f_files,$(VERILOG_SOURCES)))

# module parameters
export PARAM_FIFO_DEPTH := 4096
Expand Down
20 changes: 16 additions & 4 deletions tb/axis_ram_switch/test_axis_ram_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,19 @@ def incrementing_payload(length):
rtl_dir = os.path.abspath(os.path.join(tests_dir, '..', '..', 'rtl'))


def process_f_files(files):
lst = {}
for f in files:
if f[-2:].lower() == '.f':
with open(f, 'r') as fp:
l = fp.read().split()
for f in process_f_files([os.path.join(os.path.dirname(f), x) for x in l]):
lst[os.path.basename(f)] = f
else:
lst[os.path.basename(f)] = f
return list(lst.values())


@pytest.mark.parametrize("m_data_width", [8, 32])
@pytest.mark.parametrize("s_data_width", [8, 32])
@pytest.mark.parametrize("m_count", [1, 4])
Expand All @@ -343,12 +356,11 @@ def test_axis_ram_switch(request, s_count, m_count, s_data_width, m_data_width):

verilog_sources = [
wrapper_file,
os.path.join(rtl_dir, f"{dut}.v"),
os.path.join(rtl_dir, "axis_adapter.v"),
os.path.join(rtl_dir, "arbiter.v"),
os.path.join(rtl_dir, "priority_encoder.v"),
os.path.join(rtl_dir, f"{dut}.f"),
]

verilog_sources = process_f_files(verilog_sources)

parameters = {}

parameters['FIFO_DEPTH'] = 4096
Expand Down
Loading

0 comments on commit 664ab9f

Please sign in to comment.