refactor(hw/sim): reorganize CAM top-level tests into per-noise-config suites

Split the monolithic test_cam_basic.py into separate test suites
organized by noise configuration (no_noise, write_noise, read_noise),
with shared utilities extracted to tests/top/utils.py.

- Remove test_cam_basic.py; add no_noise/, write_noise/, read_noise/
  test suites with Makefiles that set noise parameters statically
- Extract helpers (reset_dut, write_rows, query_once, collect_topk,
  etc.) into tests/top/utils.py
- Update hw/sim/Makefile with per-config test targets and a
  test-top-all meta-target
- Update scripts/run_cam_correctness.py to build per-directory
  instead of centrally, removing inline parameter overrides
- Add __init__.py for result_serializer and topk_tracker module tests
- Expand docstrings in test_ref_model_noise.py with architectural
  context and test rationale
This commit is contained in:
2026-05-21 21:19:33 +08:00
parent 5a1d3ea977
commit 424cf6e1d3
16 changed files with 1197 additions and 712 deletions

View File

@@ -0,0 +1,29 @@
SIM_ROOT := $(abspath ../../..)
RTL_ROOT := $(abspath $(SIM_ROOT)/../rtl)
include $(SIM_ROOT)/mk/rtl-sources.mk
TOPLEVEL := cam_top
COCOTB_TEST_MODULES := tests.top.write_noise.test_write_noise
VERILOG_SOURCES := $(RTL_CAM_TOP)
# 写入噪声 ~1% 默认速率
WRITE_NOISE_EN := 1
WRITE_NOISE_RATE_NUM := 1
WRITE_NOISE_RATE_DEN := 100
READ_NOISE_EN := 0
include $(SIM_ROOT)/mk/cocotb-common.mk
# ── 速率变体子目标 ─────────────────────────────────────────────────
.PHONY: test-zero-rate test-full-rate
test-zero-rate:
$(MAKE) -B -f Makefile results.xml WRITE_NOISE_RATE_NUM=0 \
COCOTB_TEST_FILTER=zero_rate_noise
test-full-rate:
$(MAKE) -B -f Makefile results.xml WRITE_NOISE_RATE_NUM=1 WRITE_NOISE_RATE_DEN=1 \
COCOTB_TEST_FILTER=full_rate_noise
clean::
rm -rf sim_build