mirror of
https://github.com/SikongJueluo/Mini-Nav.git
synced 2026-07-12 20:15:31 +08:00
refactor(hw/sim): extract common cocotb make infrastructure into shared mk/ directory
- Split monolithic hw/sim/Makefile into modular include files (mk/cocotb-common.mk, mk/rtl-sources.mk) - Add per-module test Makefiles (cam_core_banked, cam_read_noise, cam_write_noise, match_engine_pipeline, perf, top) - Add missing simulation tools (yosys, graphviz, xdot) to devenv.nix - Fix path handling in sweep_noise.py and test modules to be HASH_BITS-aware
This commit is contained in:
82
hw/sim/mk/cocotb-common.mk
Normal file
82
hw/sim/mk/cocotb-common.mk
Normal file
@@ -0,0 +1,82 @@
|
||||
ifndef SIM_ROOT
|
||||
$(error SIM_ROOT must be set before including mk/cocotb-common.mk)
|
||||
endif
|
||||
|
||||
ifndef RTL_ROOT
|
||||
$(error RTL_ROOT must be set before including mk/cocotb-common.mk)
|
||||
endif
|
||||
|
||||
ifndef TOPLEVEL
|
||||
$(error TOPLEVEL must be set before including mk/cocotb-common.mk)
|
||||
endif
|
||||
|
||||
ifndef COCOTB_TEST_MODULES
|
||||
$(error COCOTB_TEST_MODULES must be set before including mk/cocotb-common.mk)
|
||||
endif
|
||||
|
||||
ifndef VERILOG_SOURCES
|
||||
$(error VERILOG_SOURCES must be set before including mk/cocotb-common.mk)
|
||||
endif
|
||||
|
||||
SIM ?= verilator
|
||||
TOPLEVEL_LANG ?= verilog
|
||||
|
||||
NUM_ROWS ?= 4096
|
||||
HASH_BITS ?= 512
|
||||
LANES ?= 8
|
||||
|
||||
EXTRA_ARGS += +define+NUM_ROWS=$(NUM_ROWS) +define+HASH_BITS=$(HASH_BITS) +define+LANES=$(LANES)
|
||||
EXTRA_ARGS += --trace --trace-fst --trace-structs
|
||||
|
||||
COMPILE_ARGS += -Wall -Wno-fatal
|
||||
COMPILE_ARGS += -I$(RTL_ROOT) -I$(RTL_ROOT)/core -I$(RTL_ROOT)/noise -I$(RTL_ROOT)/random
|
||||
COMPILE_ARGS += +define+SIM_DEBUG
|
||||
COMPILE_ARGS += $(EXTRA_DEFINES)
|
||||
|
||||
WRITE_NOISE_EN ?= $(NOISE_EN)
|
||||
WRITE_NOISE_RATE_NUM ?= $(NOISE_RATE_NUM)
|
||||
WRITE_NOISE_RATE_DEN ?= $(NOISE_RATE_DEN)
|
||||
WRITE_NOISE_BITS ?= $(NOISE_BITS)
|
||||
READ_NOISE_EN ?=
|
||||
READ_NOISE_RATE_NUM ?=
|
||||
READ_NOISE_RATE_DEN ?=
|
||||
READ_NOISE_BITS ?=
|
||||
|
||||
ifneq ($(strip $(WRITE_NOISE_EN)),)
|
||||
COMPILE_ARGS += -GWRITE_NOISE_EN=$(WRITE_NOISE_EN)
|
||||
endif
|
||||
ifneq ($(strip $(WRITE_NOISE_RATE_NUM)),)
|
||||
COMPILE_ARGS += -GWRITE_NOISE_RATE_NUM=$(WRITE_NOISE_RATE_NUM)
|
||||
endif
|
||||
ifneq ($(strip $(WRITE_NOISE_RATE_DEN)),)
|
||||
COMPILE_ARGS += -GWRITE_NOISE_RATE_DEN=$(WRITE_NOISE_RATE_DEN)
|
||||
endif
|
||||
ifneq ($(strip $(WRITE_NOISE_BITS)),)
|
||||
COMPILE_ARGS += -GWRITE_NOISE_BITS=$(WRITE_NOISE_BITS)
|
||||
endif
|
||||
ifneq ($(strip $(READ_NOISE_EN)),)
|
||||
COMPILE_ARGS += -GREAD_NOISE_EN=$(READ_NOISE_EN)
|
||||
endif
|
||||
ifneq ($(strip $(READ_NOISE_RATE_NUM)),)
|
||||
COMPILE_ARGS += -GREAD_NOISE_RATE_NUM=$(READ_NOISE_RATE_NUM)
|
||||
endif
|
||||
ifneq ($(strip $(READ_NOISE_RATE_DEN)),)
|
||||
COMPILE_ARGS += -GREAD_NOISE_RATE_DEN=$(READ_NOISE_RATE_DEN)
|
||||
endif
|
||||
ifneq ($(strip $(READ_NOISE_BITS)),)
|
||||
COMPILE_ARGS += -GREAD_NOISE_BITS=$(READ_NOISE_BITS)
|
||||
endif
|
||||
|
||||
export PYTHONPATH := $(SIM_ROOT):$(PYTHONPATH)
|
||||
export QUIET ?= 1
|
||||
export VERBOSE ?= 0
|
||||
export COCOTB_LOG_LEVEL ?= INFO
|
||||
export PYTHONWARNINGS ?= ignore::pytest.PytestDeprecationWarning
|
||||
|
||||
SUPPRESS_VERILATOR_WARNINGS ?= 0
|
||||
ifeq ($(SUPPRESS_VERILATOR_WARNINGS),1)
|
||||
COMPILE_ARGS += -Wno-WIDTHEXPAND
|
||||
COMPILE_ARGS += -Wno-UNOPTFLAT
|
||||
endif
|
||||
|
||||
include $(shell uv run cocotb-config --makefiles)/Makefile.sim
|
||||
23
hw/sim/mk/rtl-sources.mk
Normal file
23
hw/sim/mk/rtl-sources.mk
Normal file
@@ -0,0 +1,23 @@
|
||||
ifndef RTL_ROOT
|
||||
$(error RTL_ROOT must be set before including mk/rtl-sources.mk)
|
||||
endif
|
||||
|
||||
RTL_RANDOM := $(RTL_ROOT)/random/random128.sv
|
||||
|
||||
RTL_NOISE_MASK := $(RTL_ROOT)/noise/noise_mask_grouped.sv
|
||||
RTL_WRITE_NOISE := $(RTL_NOISE_MASK) $(RTL_RANDOM) $(RTL_ROOT)/noise/cam_write_noise.sv
|
||||
RTL_READ_NOISE := $(RTL_NOISE_MASK) $(RTL_RANDOM) $(RTL_ROOT)/noise/cam_read_noise.sv
|
||||
|
||||
RTL_CAM_CORE_BANKED := $(RTL_ROOT)/core/cam_core_banked.sv
|
||||
RTL_MATCH_ENGINE := \
|
||||
$(RTL_ROOT)/core/popcount_pipeline.sv \
|
||||
$(RTL_ROOT)/core/match_engine_pipeline.sv
|
||||
|
||||
RTL_CAM_NOISY := \
|
||||
$(RTL_CAM_CORE_BANKED) \
|
||||
$(RTL_WRITE_NOISE) \
|
||||
$(RTL_READ_NOISE) \
|
||||
$(RTL_MATCH_ENGINE) \
|
||||
$(RTL_ROOT)/cam_noisy.sv
|
||||
|
||||
RTL_CAM_TOP := $(RTL_CAM_NOISY) $(RTL_ROOT)/cam_top.sv
|
||||
Reference in New Issue
Block a user