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

@@ -1,22 +1,31 @@
PYTHON ?= python
MODULE_TESTS := cam_core_banked candidate_fifo match_engine_pipeline cam_write_noise cam_read_noise popcount_pipeline topk_tracker result_serializer
TOP_CONFIGS := no_noise write_noise read_noise
.PHONY: help test-all test-top test-modules test-module test-model test-perf clean $(MODULE_TESTS:%=test-module-%)
.PHONY: help test-all test-top test-top-all test-modules test-module test-model test-perf clean $(MODULE_TESTS:%=test-module-%) $(TOP_CONFIGS:%=test-top-%)
help:
@echo "Available hw/sim targets:"
@echo " make test-model"
@echo " make test-top"
@echo " make test-top # 只运行默认顶层配置 (no_noise)"
@echo " make test-top-all # 运行所有顶层噪声配置"
@echo " make test-top-no_noise # 无噪声集成测试"
@echo " make test-top-write_noise # 写入噪声集成测试"
@echo " make test-top-read_noise # 读取噪声集成测试"
@echo " make test-module MODULE=cam_core_banked"
@echo " make test-modules"
@echo " make test-perf"
@echo " make test-all"
@echo " make clean"
test-all: test-model test-top test-modules
test-all: test-model test-top-all test-modules
test-top:
$(MAKE) -C tests/top
test-top: test-top-no_noise
test-top-all: $(TOP_CONFIGS:%=test-top-%)
$(TOP_CONFIGS:%=test-top-%):
$(MAKE) -C tests/top/$(@:test-top-%=%)
test-modules: $(MODULE_TESTS:%=test-module-%)
@@ -34,7 +43,9 @@ test-perf:
$(MAKE) -C tests/perf
clean:
$(MAKE) -C tests/top clean
@for config in $(TOP_CONFIGS); do \
$(MAKE) -C tests/top/$$config clean || exit $$?; \
done
@for module in $(MODULE_TESTS); do \
$(MAKE) -C tests/modules/$$module clean || exit $$?; \
done