mirror of
https://github.com/SikongJueluo/Mini-Nav.git
synced 2026-07-12 20:15:31 +08:00
refactor(cam): rename read-noise path to read-pass-through and reorganize test module structure
- Rename `read_noise` scenarios and noise_mode to `read_pass_through` across run_cam_correctness.py, test_run_cam_correctness.py, and Makefiles - Update RTL comment in match_engine_pipeline.sv to reflect pass-through behavior - Move unit-level cocotb tests from `tests.test_*` flat namespace to `tests.modules.*` and `tests.top.*` subdirectory layout, matching actual Makefile paths (hw/sim/tests/modules/..., hw/sim/tests/top/...) - Remove redundant dual-noise subtarget from read_noise/Makefile - Update help text and docs to reflect read-path pass-through semantics - Add .codegraph to .gitignore
This commit is contained in:
@@ -92,11 +92,11 @@ class TestRunnerContract:
|
||||
assert names == [
|
||||
"cam_top_basic",
|
||||
"cam_top_write_noise",
|
||||
"cam_top_read_noise",
|
||||
"cam_top_read_path",
|
||||
"cam_core_banked",
|
||||
"match_engine_pipeline",
|
||||
"cam_write_noise",
|
||||
"cam_read_noise",
|
||||
"cam_read_path",
|
||||
"ref_model_noise",
|
||||
]
|
||||
|
||||
@@ -106,7 +106,7 @@ class TestRunnerContract:
|
||||
s = sc["cam_top_basic"]
|
||||
assert s.name == "cam_top_basic"
|
||||
assert s.kind == "cocotb"
|
||||
assert s.module == "tests.test_cam_basic"
|
||||
assert s.module == "tests.top.no_noise.test_no_noise"
|
||||
assert s.testcase is None
|
||||
assert s.params == {}
|
||||
assert s.noise_mode == "none"
|
||||
@@ -116,37 +116,27 @@ class TestRunnerContract:
|
||||
s = sc["cam_top_write_noise"]
|
||||
assert s.name == "cam_top_write_noise"
|
||||
assert s.kind == "cocotb"
|
||||
assert s.module == "tests.test_cam_basic"
|
||||
assert s.module == "tests.top.write_noise.test_write_noise"
|
||||
assert s.testcase is None
|
||||
assert s.params == {
|
||||
"WRITE_NOISE_EN": "1",
|
||||
"WRITE_NOISE_RATE_NUM": "1",
|
||||
"WRITE_NOISE_RATE_DEN": "100",
|
||||
"READ_NOISE_EN": "0",
|
||||
}
|
||||
assert s.params == {}
|
||||
assert s.noise_mode == "write_noise"
|
||||
assert s.expected == "bit_flip_injected"
|
||||
|
||||
# --- cam_top_read_noise ---
|
||||
s = sc["cam_top_read_noise"]
|
||||
assert s.name == "cam_top_read_noise"
|
||||
# --- cam_top_read_path ---
|
||||
s = sc["cam_top_read_path"]
|
||||
assert s.name == "cam_top_read_path"
|
||||
assert s.kind == "cocotb"
|
||||
assert s.module == "tests.test_cam_basic"
|
||||
assert s.module == "tests.top.read_noise.test_read_noise"
|
||||
assert s.testcase is None
|
||||
assert s.params == {
|
||||
"WRITE_NOISE_EN": "0",
|
||||
"READ_NOISE_EN": "1",
|
||||
"READ_NOISE_RATE_NUM": "1",
|
||||
"READ_NOISE_RATE_DEN": "100",
|
||||
}
|
||||
assert s.noise_mode == "read_noise"
|
||||
assert s.expected == "read_perturbed"
|
||||
assert s.params == {}
|
||||
assert s.noise_mode == "read_pass_through"
|
||||
assert s.expected == "pure_matching"
|
||||
|
||||
# --- cam_core_banked ---
|
||||
s = sc["cam_core_banked"]
|
||||
assert s.name == "cam_core_banked"
|
||||
assert s.kind == "cocotb"
|
||||
assert s.module == "tests.test_cam_core_banked"
|
||||
assert s.module == "tests.modules.cam_core_banked.test_cam_core_banked"
|
||||
assert s.testcase is None
|
||||
assert s.params == {}
|
||||
assert s.noise_mode == "none"
|
||||
@@ -156,7 +146,7 @@ class TestRunnerContract:
|
||||
s = sc["match_engine_pipeline"]
|
||||
assert s.name == "match_engine_pipeline"
|
||||
assert s.kind == "cocotb"
|
||||
assert s.module == "tests.test_match_engine_pipeline"
|
||||
assert s.module == "tests.modules.match_engine_pipeline.test_match_engine_pipeline"
|
||||
assert s.testcase is None
|
||||
assert s.params == {}
|
||||
assert s.noise_mode == "none"
|
||||
@@ -166,21 +156,21 @@ class TestRunnerContract:
|
||||
s = sc["cam_write_noise"]
|
||||
assert s.name == "cam_write_noise"
|
||||
assert s.kind == "cocotb"
|
||||
assert s.module == "tests.test_cam_write_noise"
|
||||
assert s.module == "tests.modules.cam_write_noise.test_cam_write_noise"
|
||||
assert s.testcase is None
|
||||
assert s.params == {}
|
||||
assert s.noise_mode == "write_noise"
|
||||
assert s.expected == "bit_flip_injected"
|
||||
|
||||
# --- cam_read_noise ---
|
||||
s = sc["cam_read_noise"]
|
||||
assert s.name == "cam_read_noise"
|
||||
# --- cam_read_path ---
|
||||
s = sc["cam_read_path"]
|
||||
assert s.name == "cam_read_path"
|
||||
assert s.kind == "cocotb"
|
||||
assert s.module == "tests.test_cam_read_noise"
|
||||
assert s.module == "tests.modules.cam_read_noise.test_cam_read_noise"
|
||||
assert s.testcase is None
|
||||
assert s.params == {}
|
||||
assert s.noise_mode == "read_noise"
|
||||
assert s.expected == "read_perturbed"
|
||||
assert s.noise_mode == "read_pass_through"
|
||||
assert s.expected == "pass_through"
|
||||
|
||||
# --- ref_model_noise ---
|
||||
s = sc["ref_model_noise"]
|
||||
@@ -207,7 +197,7 @@ class TestRunnerContract:
|
||||
assert cmd == [
|
||||
"make",
|
||||
"-C",
|
||||
"hw/sim",
|
||||
"hw/sim/tests/top/write_noise",
|
||||
"NUM_ROWS=512",
|
||||
"HASH_BITS=512",
|
||||
"LANES=8",
|
||||
@@ -217,32 +207,35 @@ class TestRunnerContract:
|
||||
"WRITE_NOISE_RATE_NUM=1",
|
||||
]
|
||||
|
||||
def test_build_cocotb_command_includes_toplevel_for_unit_scenarios(self):
|
||||
"""Unit-level cocotb scenarios get explicit TOPLEVEL override matching scenario name."""
|
||||
def test_build_cocotb_command_uses_correct_make_directory(self):
|
||||
"""Unit-level cocotb scenarios build in hw/sim/tests/modules/...,
|
||||
top-level scenarios in hw/sim/tests/top/..."""
|
||||
runner = load_runner()
|
||||
sc = {s.name: s for s in runner.default_scenarios}
|
||||
|
||||
# Unit scenarios should get TOPLEVEL override matching their scenario name
|
||||
unit_names = [
|
||||
"cam_core_banked",
|
||||
"match_engine_pipeline",
|
||||
"cam_write_noise",
|
||||
"cam_read_noise",
|
||||
]
|
||||
for name in unit_names:
|
||||
# Unit scenarios — make -C hw/sim/tests/modules/<subpath>
|
||||
for name, subpath in [
|
||||
("cam_core_banked", "modules/cam_core_banked"),
|
||||
("match_engine_pipeline", "modules/match_engine_pipeline"),
|
||||
("cam_write_noise", "modules/cam_write_noise"),
|
||||
("cam_read_path", "modules/cam_read_noise"),
|
||||
]:
|
||||
cmd = runner.build_scenario_command(sc[name])
|
||||
toplevel_kvp = f"TOPLEVEL={name}"
|
||||
assert toplevel_kvp in cmd, (
|
||||
f"Expected {toplevel_kvp!r} in command for {name!r}, got {cmd}"
|
||||
c_flag = cmd[cmd.index("-C") + 1]
|
||||
assert c_flag == f"hw/sim/tests/{subpath}", (
|
||||
f"Expected -C hw/sim/tests/{subpath} for {name!r}, got -C {c_flag}"
|
||||
)
|
||||
|
||||
# cam_top_* scenarios should NOT get explicit TOPLEVEL (use Makefile default)
|
||||
top_names = ["cam_top_basic", "cam_top_write_noise", "cam_top_read_noise"]
|
||||
for name in top_names:
|
||||
# Top-level scenarios — make -C hw/sim/tests/top/<subpath>
|
||||
for name, subpath in [
|
||||
("cam_top_basic", "top/no_noise"),
|
||||
("cam_top_write_noise", "top/write_noise"),
|
||||
("cam_top_read_path", "top/read_noise"),
|
||||
]:
|
||||
cmd = runner.build_scenario_command(sc[name])
|
||||
toplevel_flags = [arg for arg in cmd if arg.startswith("TOPLEVEL=")]
|
||||
assert len(toplevel_flags) == 0, (
|
||||
f"Unexpected TOPLEVEL override in command for {name!r}: {cmd}"
|
||||
c_flag = cmd[cmd.index("-C") + 1]
|
||||
assert c_flag == f"hw/sim/tests/{subpath}", (
|
||||
f"Expected -C hw/sim/tests/{subpath} for {name!r}, got -C {c_flag}"
|
||||
)
|
||||
|
||||
def test_build_pytest_command_uses_reference_model_test(self):
|
||||
@@ -261,7 +254,7 @@ class TestRunnerContract:
|
||||
"uv",
|
||||
"run",
|
||||
"pytest",
|
||||
"hw/sim/tests/test_ref_model_noise.py",
|
||||
"hw/sim/tests/model/test_ref_model_noise.py",
|
||||
"-q",
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user