فهرست منبع

chore(6400-v1.1): drop historical door-product and cross-product test assets

WorkBuddy 1 روز پیش
والد
کامیت
85a9f20275
35فایلهای تغییر یافته به همراه0 افزوده شده و 3533 حذف شده
  1. 0 79
      tests/cocotb/bmc_ascii_snapshot_cocotb_top.v
  2. 0 50
      tests/cocotb/prod2u_door_temp_uart_top.v
  3. 0 58
      tests/cocotb/run_6400_bmc_fuzz.py
  4. 0 68
      tests/cocotb/run_6400_pi_differential.py
  5. 0 419
      tests/cocotb/run_prod2u_door_temp_uart_e2e.py
  6. 0 224
      tests/cocotb/test_6400_bmc_parser_fuzz.py
  7. 0 264
      tests/cocotb/test_prod2u_door_temp_uart_e2e.py
  8. 0 22
      tests/formal/6400_bmc_bank_properties.sby
  9. 0 30
      tests/formal/6400_bmc_bank_properties_formal.v
  10. 0 17
      tests/formal/6400_bmc_bank_reachability.sby
  11. 0 23
      tests/formal/door_axis_cal.sby
  12. 0 164
      tests/formal/door_axis_cal_formal.v
  13. 0 23
      tests/formal/door_axis_motion_contract.sby
  14. 0 147
      tests/formal/door_axis_motion_contract_formal.v
  15. 0 23
      tests/formal/door_axis_request_limit_race.sby
  16. 0 189
      tests/formal/door_axis_request_limit_race_formal.v
  17. 0 23
      tests/formal/door_axis_request_planner_collision.sby
  18. 0 165
      tests/formal/door_axis_request_planner_collision_formal.v
  19. 0 23
      tests/formal/door_axis_source_limit_lingering.sby
  20. 0 203
      tests/formal/door_axis_source_limit_lingering_formal.v
  21. 0 23
      tests/formal/door_axis_watchdog.sby
  22. 0 23
      tests/formal/door_axis_watchdog_drain.sby
  23. 0 168
      tests/formal/door_axis_watchdog_drain_formal.v
  24. 0 164
      tests/formal/door_axis_watchdog_formal.v
  25. 0 43
      tests/formal/door_motion_status_snapshot.sby
  26. 0 137
      tests/formal/door_motion_status_snapshot_formal.v
  27. 0 25
      tests/formal/door_mse_serial_dda.sby
  28. 0 92
      tests/formal/door_mse_serial_dda_formal.v
  29. 0 23
      tests/formal/door_percent_planner.sby
  30. 0 87
      tests/formal/door_percent_planner_formal.v
  31. 0 24
      tests/formal/door_rate_quantum_builder.sby
  32. 0 92
      tests/formal/door_rate_quantum_builder_formal.v
  33. 0 26
      tests/formal/door_rate_quantum_dispatcher.sby
  34. 0 207
      tests/formal/door_rate_quantum_dispatcher_formal.v
  35. 0 185
      tools/build_mrdimm_diag_bitstreams.py

+ 0 - 79
tests/cocotb/bmc_ascii_snapshot_cocotb_top.v

@@ -1,79 +0,0 @@
-`timescale 1ns/1ps
-
-module bmc_ascii_snapshot_cocotb_top (
-    input  wire        tick_1s_test,
-    input  wire        rx_valid,
-    input  wire [7:0]  rx_data,
-    input  wire        rx_framing_error,
-    input  wire        snapshot_lock,
-    input  wire        snapshot_lock_bank,
-    input  wire [4:0]  rd_index,
-    output wire        sys_clk,
-    output reg         rst_n_mon = 1'b0,
-    output wire        snapshot_commit,
-    output wire        parser_error,
-    output wire [15:0] epoch,
-    output wire [15:0] age_seconds,
-    output wire        stale,
-    output wire        active_bank,
-    output wire [23:0] active_valid_mask,
-    output wire [15:0] rd_raw,
-    output wire        rd_valid,
-    output reg  [15:0] commit_count_mon = 0,
-    output reg  [15:0] error_count_mon = 0
-);
-    reg clk = 1'b0;
-    reg [3:0] reset_count = 0;
-    always #20 clk = ~clk;
-    assign sys_clk = clk;
-
-    always @(posedge clk) begin
-        if (reset_count < 8) begin
-            reset_count <= reset_count + 1'b1;
-            rst_n_mon <= 1'b0;
-        end else begin
-            rst_n_mon <= 1'b1;
-        end
-    end
-
-    bmc_ascii_snapshot #(
-        .STALE_SECONDS(2),
-        .INTER_BYTE_TIMEOUT_CLKS(64)
-    ) u_dut (
-        .clk(clk),
-        .rst_n(rst_n_mon),
-        .tick_1s(tick_1s_test),
-        .rx_valid(rx_valid),
-        .rx_data(rx_data),
-        .rx_framing_error(rx_framing_error),
-        .snapshot_lock(snapshot_lock),
-        .snapshot_lock_bank(snapshot_lock_bank),
-        .snapshot_commit(snapshot_commit),
-        .parser_error(parser_error),
-        .epoch(epoch),
-        .age_seconds(age_seconds),
-        .stale(stale),
-        .active_bank(active_bank),
-        .active_valid_mask(active_valid_mask),
-        .control_bank(active_bank),
-        .control_index(rd_index),
-        .control_raw(rd_raw),
-        .control_valid(rd_valid),
-        .snapshot_bank(active_bank),
-        .snapshot_index(5'd0),
-        .snapshot_raw(),
-        .snapshot_valid()
-    );
-
-    always @(posedge clk) begin
-        if (!rst_n_mon) begin
-            commit_count_mon <= 0;
-            error_count_mon <= 0;
-        end else begin
-            if (snapshot_commit)
-                commit_count_mon <= commit_count_mon + 1'b1;
-            if (parser_error)
-                error_count_mon <= error_count_mon + 1'b1;
-        end
-    end
-endmodule

+ 0 - 50
tests/cocotb/prod2u_door_temp_uart_top.v

@@ -1,50 +0,0 @@
-`timescale 1ns/1ps
-
-// Simulation wrapper: real UART bit timing; accelerated control enables.
-module prod2u_door_temp_uart_top (
-    input  wire       host_uart_rx,
-    output wire       host_uart_tx,
-    output wire [7:0] ptc_pwm_out,
-    output wire [3:0] fan_pwm_out,
-    output wire       motor_en_n,
-    output wire       x_step,
-    output wire       x_dir,
-    output wire       y_step,
-    output wire       y_dir,
-    output wire       z_step,
-    output wire       z_dir,
-    input  wire       x_limit_ls,
-    input  wire       x_limit_hs,
-    input  wire       y_limit_ls,
-    input  wire       y_limit_hs,
-    input  wire       z_limit_ls,
-    input  wire       z_limit_hs,
-    inout  wire       temp_scl,
-    inout  wire       temp_sda
-);
-    reg sys_clk = 1'b0;
-    always #20 sys_clk = ~sys_clk;
-
-    prod2u_p4_normal_v3_top #(
-        .SHARED_TICK_CLOCK_HZ(200_000),
-        .MOTION_SERVICE_CLKS(1)
-    ) u_dut (
-        .sys_clk(sys_clk), .host_uart_rx(host_uart_rx), .host_uart_tx(host_uart_tx),
-        .ptc_pwm_out(ptc_pwm_out), .fan_pwm_out(fan_pwm_out),
-        .motor_en_n(motor_en_n),
-        .x_step(x_step), .x_dir(x_dir), .y_step(y_step), .y_dir(y_dir),
-        .z_step(z_step), .z_dir(z_dir),
-        .x_limit_ls(x_limit_ls), .x_limit_hs(x_limit_hs),
-        .y_limit_ls(y_limit_ls), .y_limit_hs(y_limit_hs),
-        .z_limit_ls(z_limit_ls), .z_limit_hs(z_limit_hs),
-        .temp_scl(temp_scl), .temp_sda(temp_sda)
-    );
-
-    initial begin
-`ifdef COCOTB_WAVES
-        $dumpfile("cocotb_debug.vcd");
-        $dumpvars(0, prod2u_door_temp_uart_top);
-`endif
-    end
-
-endmodule

+ 0 - 58
tests/cocotb/run_6400_bmc_fuzz.py

@@ -1,58 +0,0 @@
-#!/usr/bin/env python3
-"""Run fail-closed byte-level BMC parser replay/fuzz coverage."""
-
-from __future__ import annotations
-
-import os
-from pathlib import Path
-import tempfile
-import xml.etree.ElementTree as ET
-
-try:
-    from cocotb_tools.runner import get_runner
-except ModuleNotFoundError:
-    from cocotb.runner import get_runner
-
-
-ROOT = Path(__file__).resolve().parents[2]
-TEST_DIR = Path(__file__).resolve().parent
-
-
-def main() -> int:
-    with tempfile.TemporaryDirectory(prefix="prod2u-6400-bmc-fuzz-") as directory:
-        build_dir = Path(directory)
-        os.environ["HYPOTHESIS_STORAGE_DIRECTORY"] = str(build_dir / "hypothesis")
-        runner = get_runner("icarus")
-        runner.build(
-            sources=[
-                ROOT / "src/common/ef2_bram_dp.v",
-                ROOT / "src/acquisition/bmc_ascii_snapshot.v",
-                TEST_DIR / "bmc_ascii_snapshot_cocotb_top.v",
-            ],
-            hdl_toplevel="bmc_ascii_snapshot_cocotb_top",
-            build_dir=build_dir,
-            build_args=["-g2012"],
-            always=True,
-        )
-        result = Path(runner.test(
-            hdl_toplevel="bmc_ascii_snapshot_cocotb_top",
-            test_module="test_6400_bmc_parser_fuzz",
-            test_dir=TEST_DIR,
-            build_dir=build_dir,
-            results_xml=str(build_dir / "results.xml"),
-        ))
-        root = ET.parse(result).getroot()
-        cases = root.findall(".//testcase")
-        failures = root.findall(".//failure") + root.findall(".//error")
-        skipped = root.findall(".//skipped")
-        if not cases or failures or skipped:
-            raise RuntimeError(
-                f"BMC fuzz incomplete: cases={len(cases)} failures={len(failures)} "
-                f"skipped={len(skipped)} results={result}"
-            )
-    print("PASS: 6400 BMC parser replay/fuzz")
-    return 0
-
-
-if __name__ == "__main__":
-    raise SystemExit(main())

+ 0 - 68
tests/cocotb/run_6400_pi_differential.py

@@ -1,68 +0,0 @@
-#!/usr/bin/env python3
-"""Run L7 bit-exact thermal-control-lab versus production RTL differential."""
-
-from __future__ import annotations
-
-import os
-from pathlib import Path
-import tempfile
-import xml.etree.ElementTree as ET
-
-try:
-    from cocotb_tools.runner import get_runner
-except ModuleNotFoundError:
-    from cocotb.runner import get_runner
-
-
-ROOT = Path(__file__).resolve().parents[2]
-TEST_DIR = Path(__file__).resolve().parent
-LAB_ROOT = Path(os.environ.get(
-    "THERMAL_CONTROL_LAB_ROOT", "/root/workspaces/thermal-system/thermal-control-lab"
-))
-
-
-def main() -> int:
-    lab = LAB_ROOT / "thermal_control_lab" / "fixed_point" / "pi.py"
-    if not lab.is_file():
-        raise RuntimeError(f"thermal-control-lab reference model is missing: {lab}")
-    with tempfile.TemporaryDirectory(prefix="prod2u-6400-pi-differential-") as directory:
-        build_dir = Path(directory)
-        os.environ["HYPOTHESIS_STORAGE_DIRECTORY"] = str(build_dir / "hypothesis")
-        os.environ["THERMAL_CONTROL_LAB_ROOT"] = str(LAB_ROOT)
-        runner = get_runner("icarus")
-        runner.build(
-            sources=[
-                ROOT / "src/common/ef2_bram_dp.v",
-                ROOT / "src/control/thermal_output_banks.v",
-                ROOT / "src/control/manual_set_all_bank.v",
-                ROOT / "src/control/thermal_control_core.v",
-                TEST_DIR / "thermal_control_core_cocotb_top.v",
-            ],
-            hdl_toplevel="thermal_control_core_cocotb_top",
-            build_dir=build_dir,
-            includes=[ROOT],
-            build_args=["-g2012"],
-            always=True,
-        )
-        result = Path(runner.test(
-            hdl_toplevel="thermal_control_core_cocotb_top",
-            test_module="test_6400_pi_differential",
-            test_dir=TEST_DIR,
-            build_dir=build_dir,
-            results_xml=str(build_dir / "results.xml"),
-        ))
-        root = ET.parse(result).getroot()
-        cases = root.findall(".//testcase")
-        failures = root.findall(".//failure") + root.findall(".//error")
-        skipped = root.findall(".//skipped")
-        if not cases or failures or skipped:
-            raise RuntimeError(
-                f"PI differential incomplete: cases={len(cases)} failures={len(failures)} "
-                f"skipped={len(skipped)} results={result}"
-            )
-    print("PASS: L7 bit-exact Python/RTL PI differential")
-    return 0
-
-
-if __name__ == "__main__":
-    raise SystemExit(main())

+ 0 - 419
tests/cocotb/run_prod2u_door_temp_uart_e2e.py

@@ -1,419 +0,0 @@
-#!/usr/bin/env python3
-"""Run the current project's real-UART cocotb scenario.
-
-Forces the verification-venv Python into VPI (blocks OSS CAD tabbypy3 /
-PYTHONEXECUTABLE poisoning) and keeps the Icarus build tree under an
-independent TEMP/build directory.
-"""
-
-from __future__ import annotations
-
-import os
-from pathlib import Path
-import shutil
-import sys
-import xml.etree.ElementTree as ET
-
-
-ROOT = Path(__file__).resolve().parents[2]
-TEST_DIR = Path(__file__).resolve().parent
-sys.path.insert(0, str(ROOT))
-
-def _default_verify_python() -> Path:
-    for key in ("PROD2U_P4_COCOTB_PYTHON", "PRODU2_VERIFY_PYTHON"):
-        value = os.environ.get(key, "").strip()
-        if value:
-            return Path(value).expanduser()
-    for candidate in (
-        Path("/data/prod2u/venvs/verify/bin/python"),
-        Path.home() / ".cache" / "prod2u" / "venvs" / "verify" / "bin" / "python",
-    ):
-        if candidate.is_file():
-            return candidate
-    return Path("/data/prod2u/venvs/verify/bin/python")
-
-
-DEFAULT_VERIFY_PYTHON = _default_verify_python()
-
-# Poisonous env vars exported by OSS CAD tabbypy3 / environment scripts.
-_OSS_CAD_POISON = (
-    "PYTHONEXECUTABLE",
-    "PYTHONHOME",
-    "PYTHONNOUSERSITE",
-)
-
-
-def _resolve_build_dir() -> Path:
-    explicit = os.environ.get("PROD2U_COCOTB_BUILD_DIR", "").strip()
-    if explicit:
-        return Path(explicit).expanduser()
-    temp_root = Path(os.environ.get("TEMP", ROOT / "tmp"))
-    return temp_root / "cocotb" / "prod2u_door_temp_uart_e2e"
-
-
-BUILD_DIR = _resolve_build_dir()
-RESULTS_XML = BUILD_DIR / "results.xml"
-
-
-def rtl_sources() -> list[Path]:
-    from tools.prod2u_p4_normal_v3_build import PRODUCTION_RTL_SOURCES
-
-    return [ROOT / relative for relative in PRODUCTION_RTL_SOURCES]
-
-
-def results_xml_has_failures(results: Path) -> bool:
-    root = ET.parse(results).getroot()
-    return bool(
-        root.findall(".//failure")
-        or root.findall(".//error")
-        or sum(int(node.attrib.get("failures", "0")) for node in root.findall(".//testsuite"))
-        or sum(int(node.attrib.get("errors", "0")) for node in root.findall(".//testsuite"))
-        or int(root.attrib.get("failures", "0"))
-        or int(root.attrib.get("errors", "0"))
-    )
-
-
-def _python_has_cocotb(python_exe: Path) -> bool:
-    import subprocess
-
-    completed = subprocess.run(
-        [str(python_exe), "-B", "-c", "import cocotb, cocotb_tools"],
-        cwd=str(ROOT),
-        env={k: v for k, v in os.environ.items() if k not in _OSS_CAD_POISON},
-        text=True,
-        stdout=subprocess.PIPE,
-        stderr=subprocess.PIPE,
-        timeout=20,
-        check=False,
-    )
-    return completed.returncode == 0
-
-
-def _select_python() -> Path:
-    candidates: list[Path] = []
-    configured = os.environ.get("PROD2U_P4_COCOTB_PYTHON", "").strip()
-    if configured:
-        candidates.append(Path(configured).expanduser())
-    candidates.append(DEFAULT_VERIFY_PYTHON)
-    # The persistent OSS Python wrapper carries the matching shared library
-    # and bundled cocotb.  Prefer its non-tabbypy3 entrypoint before falling
-    # back to a poisoned sys.executable reported by the vendor wrapper.
-    candidates.append(Path("/data/prod2u/oss-cad-suite/latest/py3bin/python3.11"))
-    # Prefer configured/verify venv over a possibly poisoned sys.executable.
-    seen: set[str] = set()
-    for candidate in candidates:
-        key = str(candidate)
-        if key in seen:
-            continue
-        seen.add(key)
-        if candidate.is_file() and _python_has_cocotb(candidate):
-            return candidate
-    if Path(sys.executable).is_file() and _python_has_cocotb(Path(sys.executable)):
-        return Path(sys.executable)
-    return DEFAULT_VERIFY_PYTHON
-
-
-def _is_oss_cad_bin(part: str) -> bool:
-    normalized = part.rstrip("/")
-    return normalized.endswith("oss-cad-suite/latest/bin") or normalized.endswith(
-        "oss-cad-suite/bin"
-    )
-
-
-def _tool_bin_dirs(shim_dir: Path | None = None, python_exe: Path | None = None) -> list[str]:
-    """Dirs with iverilog/vvp without exposing OSS CAD python shims on PATH.
-
-    Host often only has Icarus inside oss-cad-suite/bin. Putting that whole bin
-    on PATH resurrects tabbypy3 for VPI; instead symlink iverilog/vvp into a
-    private shim dir when no system install exists.
-    """
-    dirs: list[str] = []
-    if shim_dir is not None:
-        shim_dir.mkdir(parents=True, exist_ok=True)
-        oss_top = Path("/data/prod2u/oss-cad-suite/latest")
-        for name in ("iverilog", "vvp"):
-            resolved = shutil.which(name)
-            # A controlled Python re-exec preserves this run's shim directory
-            # on PATH.  Never regenerate a shim that execs itself.
-            if resolved and Path(resolved).parent.resolve() == shim_dir.resolve():
-                resolved = None
-            if not resolved:
-                for candidate in (
-                    oss_top / "bin" / name,
-                    Path("/usr/local/bin") / name,
-                    Path("/usr/bin") / name,
-                ):
-                    if candidate.is_file() and os.access(candidate, os.X_OK):
-                        resolved = str(candidate)
-                        break
-            if not resolved:
-                continue
-            wrapper = shim_dir / name
-            if wrapper.exists() or wrapper.is_symlink():
-                wrapper.unlink()
-            resolved_path = Path(resolved)
-            libexec = oss_top / "libexec" / name
-            if (
-                name == "vvp"
-                and python_exe is not None
-                and libexec.is_file()
-                and "oss-cad-suite" in resolved_path.as_posix()
-            ):
-                # OSS bin/vvp exports PYTHONEXECUTABLE=tabbypy3; bypass that wrapper.
-                py = python_exe.expanduser()
-                wrapper.write_text(
-                    "#!/bin/sh\n"
-                    f'export PYGPI_PYTHON_BIN="{py}"\n'
-                    f'export PYTHONEXECUTABLE="{py}"\n'
-                    f'export PRODU2_VERIFY_PYTHON="{py}"\n'
-                    "unset PYTHONHOME\n"
-                    f'exec "{oss_top}/lib/ld-linux-x86-64.so.2" --inhibit-cache --inhibit-rpath "" '
-                    f'--library-path "{oss_top}/lib" "{libexec}" "$@"\n',
-                    encoding="ascii",
-                )
-            else:
-                wrapper.write_text(
-                    "#!/bin/sh\n"
-                    f'exec "{resolved}" "$@"\n',
-                    encoding="ascii",
-                )
-            wrapper.chmod(0o755)
-        dirs.append(str(shim_dir))
-    for name in ("iverilog", "vvp"):
-        resolved = shutil.which(name)
-        if resolved:
-            parent = str(Path(resolved).parent)
-            if parent not in dirs and not _is_oss_cad_bin(parent):
-                dirs.append(parent)
-    for fallback in ("/usr/local/bin", "/usr/bin", "/bin"):
-        if fallback not in dirs:
-            dirs.append(fallback)
-    return dirs
-
-
-def _sanitize_env(python_exe: Path, build_dir: Path) -> dict[str, str]:
-    """Bind VPI to verification Python and hide OSS CAD python shims.
-
-    OSS CAD ``bin`` must stay off PATH: even without PYTHONEXECUTABLE, having
-    ``tabbypy3`` visible makes the VPI-embedded interpreter report
-    sys.executable as tabbypy3 (cocotb gpi_embed sanity check fails).
-    """
-    env = {k: v for k, v in os.environ.items() if k not in _OSS_CAD_POISON}
-    python_bin = str(python_exe.parent)
-    shim_dir = build_dir / "path-shim"
-    shim_dir.mkdir(parents=True, exist_ok=True)
-    for shim_name in ("python", "python3", "python3.13", "tabbypy3", "tabby"):
-        shim_path = shim_dir / shim_name
-        if shim_path.exists() or shim_path.is_symlink():
-            shim_path.unlink()
-        shim_path.symlink_to(python_exe)
-
-    path_parts: list[str] = [python_bin, str(shim_dir), *_tool_bin_dirs(shim_dir, python_exe)]
-    for part in env.get("PATH", "").split(os.pathsep):
-        if not part or _is_oss_cad_bin(part):
-            continue
-        if part not in path_parts:
-            path_parts.append(part)
-    env["PATH"] = os.pathsep.join(path_parts)
-    env["VIRTUAL_ENV"] = str(python_exe.parent.parent)
-    env["PYGPI_PYTHON_BIN"] = str(python_exe)
-    env["PROD2U_P4_COCOTB_PYTHON"] = str(python_exe)
-    # Keep TEMP under the lane build root; cocotb_tools uses build_dir directly.
-    env["TEMP"] = str(build_dir)
-    env["TMP"] = str(build_dir)
-    env["TMPDIR"] = str(build_dir)
-    for key in _OSS_CAD_POISON:
-        env.pop(key, None)
-    # find_libpython may be unavailable while PYTHONEXECUTABLE still poisons this
-    # process; LIBPYTHON_LOC is filled after re-exec in main().
-    return env
-
-
-def _already_under_selected_python(python_exe: Path) -> bool:
-    """True when this process was launched via the LD-safe wrapper for python_exe.
-
-    OSS CAD wrappers report sys.executable as bare libexec/python3.11 even when
-    argv0 was venv/bin/python or py3bin/python3.11. Re-execing on that mismatch
-    loops forever.
-    """
-    if os.environ.get("PROD2U_COCOTB_REEXEC_DONE") == "1":
-        return True
-    current = Path(sys.executable).expanduser()
-    selected = python_exe.expanduser()
-    if str(current) == str(selected):
-        return True
-    if current.parent == selected.parent and current.name.startswith("python"):
-        return True
-    # Same wrapper family: venv/bin/python -> py3bin -> libexec
-    try:
-        if current.resolve() == selected.resolve():
-            return True
-    except OSError:
-        pass
-    marker = os.environ.get("PROD2U_P4_COCOTB_PYTHON", "").strip()
-    if marker and Path(marker).expanduser() == selected and "libexec" in current.as_posix():
-        return True
-    return False
-
-
-def _ensure_running_under(python_exe: Path, build_dir: Path) -> None:
-    """Re-exec under the selected interpreter with a sanitized environment.
-
-    PYTHONEXECUTABLE poisons sys.executable for the whole process lifetime; the
-    only fix is a clean execve before cocotb_tools/VPI start.
-    """
-    if os.environ.get("PROD2U_COCOTB_REEXEC_DONE") == "1":
-        # OSS CAD's selected wrapper legitimately injects these again while
-        # launching libexec/python.  The marker proves the one controlled
-        # re-exec already happened; clear the wrapper residue here instead of
-        # recursively execing the same wrapper forever.
-        for key in _OSS_CAD_POISON:
-            os.environ.pop(key, None)
-        return
-    need_reexec = False
-    if "tabbypy3" in Path(sys.executable).name:
-        need_reexec = True
-    if os.environ.get("PYTHONEXECUTABLE"):
-        need_reexec = True
-    if not _already_under_selected_python(python_exe):
-        need_reexec = True
-    if not need_reexec:
-        return
-    env = _sanitize_env(python_exe, build_dir)
-    env["PROD2U_COCOTB_REEXEC_DONE"] = "1"
-    os.execve(
-        str(python_exe),
-        [str(python_exe), "-B", str(Path(__file__).resolve()), *sys.argv[1:]],
-        env,
-    )
-
-
-def main() -> int:
-    build_dir = _resolve_build_dir()
-    build_dir.mkdir(parents=True, exist_ok=True)
-    results_xml = build_dir / "results.xml"
-    python_exe = _select_python()
-
-    # Re-exec first when poisoned so subsequent imports see a healthy venv.
-    _ensure_running_under(python_exe, build_dir)
-
-    sanitized = _sanitize_env(python_exe, build_dir)
-    try:
-        import find_libpython
-
-        libpython = find_libpython.find_libpython()
-        if libpython:
-            sanitized["LIBPYTHON_LOC"] = libpython
-    except Exception:
-        pass
-    os.environ.clear()
-    os.environ.update(sanitized)
-
-    # Guard: refuse to proceed if poison remains.
-    if os.environ.get("PYTHONEXECUTABLE"):
-        print(
-            "error: PYTHONEXECUTABLE is set; refusing to run VPI under OSS CAD poison: "
-            f"{os.environ['PYTHONEXECUTABLE']}",
-            file=sys.stderr,
-        )
-        return 2
-    if (
-        "tabbypy3" in Path(sys.executable).name
-        and os.environ.get("PROD2U_COCOTB_REEXEC_DONE") != "1"
-    ):
-        print(f"error: sys.executable is OSS CAD tabbypy3: {sys.executable}", file=sys.stderr)
-        return 2
-    if any(_is_oss_cad_bin(part) for part in os.environ.get("PATH", "").split(os.pathsep)):
-        print("error: OSS CAD bin still on PATH after sanitize", file=sys.stderr)
-        return 2
-
-    from cocotb_tools.runner import get_runner
-
-    runner = get_runner("icarus")
-
-    # cocotb_tools hard-codes -g2012 before user build_args.  Replace that
-    # single dialect selection so the command exactly matches the passing
-    # Legacy Icarus lane instead of passing two conflicting -g options.
-    _orig_build_command = runner._build_command
-
-    def _build_command_g2005_sv():
-        commands = _orig_build_command()
-        return [
-            ["-g2005-sv" if arg == "-g2012" else arg for arg in command]
-            for command in commands
-        ]
-
-    runner._build_command = _build_command_g2005_sv  # type: ignore[method-assign]
-
-    _orig_set_env_common = getattr(runner, "_set_env_common", None)
-
-    def _set_env_common_without_oss_cad_poison() -> None:
-        _orig_set_env_common()
-        for key in _OSS_CAD_POISON:
-            runner.env.pop(key, None)
-        # Re-assert PATH without OSS CAD python shims (cocotb may append libs_dir only).
-        path_parts = [
-            part
-            for part in runner.env.get("PATH", "").split(os.pathsep)
-            if part and not _is_oss_cad_bin(part)
-        ]
-        runner.env["PATH"] = os.pathsep.join(path_parts)
-        # Prefer LD-safe wrapper; bare libexec sys.executable breaks VPI children.
-        runner.env["PYGPI_PYTHON_BIN"] = str(python_exe)
-        runner.env.pop("PYTHONEXECUTABLE", None)
-        audit = build_dir / "vpi-env-audit.txt"
-        audit.write_text(
-            "\n".join(
-                [
-                    f"os.PYTHONEXECUTABLE={os.environ.get('PYTHONEXECUTABLE')!r}",
-                    f"runner.PYTHONEXECUTABLE={runner.env.get('PYTHONEXECUTABLE')!r}",
-                    f"runner.PYGPI_PYTHON_BIN={runner.env.get('PYGPI_PYTHON_BIN')!r}",
-                    f"sys.executable={sys.executable!r}",
-                    f"PATH_has_oss_cad={any(_is_oss_cad_bin(p) for p in runner.env.get('PATH', '').split(os.pathsep))}",
-                ]
-            )
-            + "\n",
-            encoding="utf-8",
-        )
-        if "tabbypy3" in runner.env.get("PYGPI_PYTHON_BIN", ""):
-            raise RuntimeError("PYGPI_PYTHON_BIN resolved to OSS CAD tabbypy3")
-        if runner.env.get("PYTHONEXECUTABLE"):
-            raise RuntimeError(
-                "PYTHONEXECUTABLE still present in runner.env after sanitize: "
-                f"{runner.env['PYTHONEXECUTABLE']}"
-            )
-
-    if _orig_set_env_common is not None:
-        runner._set_env_common = _set_env_common_without_oss_cad_poison  # type: ignore[method-assign]
-
-    runner.build(
-        sources=[*rtl_sources(), TEST_DIR / "prod2u_door_temp_uart_top.v"],
-        hdl_toplevel="prod2u_door_temp_uart_top",
-        build_dir=build_dir,
-        build_args=["-I", str(ROOT)],
-        always=True,
-        verbose=False,
-    )
-    results = Path(
-        runner.test(
-            hdl_toplevel="prod2u_door_temp_uart_top",
-            test_module="test_prod2u_door_temp_uart_e2e",
-            build_dir=build_dir,
-            test_dir=TEST_DIR,
-            results_xml=str(results_xml),
-            extra_env={
-                "PYGPI_PYTHON_BIN": str(python_exe),
-                "PATH": os.environ["PATH"],
-                "VIRTUAL_ENV": os.environ.get("VIRTUAL_ENV", ""),
-            },
-        )
-    )
-    if not results.is_file() or results_xml_has_failures(results):
-        print(f"cocotb fail results={results}", file=sys.stderr)
-        return 1
-    print(f"cocotb pass results={results} python={python_exe}")
-    return 0
-
-
-if __name__ == "__main__":
-    raise SystemExit(main())

+ 0 - 224
tests/cocotb/test_6400_bmc_parser_fuzz.py

@@ -1,224 +0,0 @@
-"""Hypothesis replay/fuzz coverage for the production BMC ASCII bank parser."""
-
-from __future__ import annotations
-
-from dataclasses import dataclass
-import warnings
-
-import cocotb
-from cocotb.triggers import FallingEdge, RisingEdge, Timer, with_timeout
-from hypothesis import HealthCheck, given, settings, strategies as st
-from hypothesis.errors import HypothesisSideeffectWarning
-
-
-@dataclass(frozen=True)
-class SnapshotCase:
-    channels: tuple[tuple[int, int] | None, ...]
-    lower: bool
-    separator: bytes
-
-    @property
-    def raw(self) -> bytes:
-        values = bytearray()
-        for channel in self.channels:
-            values.extend((0xFF, 0xFF) if channel is None else channel)
-        return bytes(values)
-
-    @property
-    def line(self) -> bytes:
-        words = [f"{value:02x}" if self.lower else f"{value:02X}" for value in self.raw]
-        return self.separator.join(value.encode("ascii") for value in words)
-
-
-@st.composite
-def snapshot_cases(draw) -> SnapshotCase:
-    channel = st.one_of(
-        st.none(),
-        st.tuples(st.integers(min_value=0, max_value=99), st.integers(min_value=0, max_value=99)),
-    )
-    channels = tuple(draw(st.lists(channel, min_size=24, max_size=24)))
-    return SnapshotCase(
-        channels=channels,
-        lower=draw(st.booleans()),
-        separator=draw(st.sampled_from((b"", b" ", b"\t"))),
-    )
-
-
-def generated_cases() -> list[SnapshotCase]:
-    values: list[SnapshotCase] = []
-
-    @settings(
-        max_examples=48,
-        derandomize=True,
-        database=None,
-        deadline=None,
-        suppress_health_check=(HealthCheck.too_slow,),
-    )
-    @given(snapshot_cases())
-    def collect(value: SnapshotCase) -> None:
-        values.append(value)
-
-    with warnings.catch_warnings():
-        warnings.simplefilter("ignore", HypothesisSideeffectWarning)
-        collect()
-    return values
-
-
-async def clock_cycles(dut, count: int) -> None:
-    for _ in range(count):
-        await RisingEdge(dut.sys_clk)
-
-
-async def send_char(dut, value: int) -> None:
-    await FallingEdge(dut.sys_clk)
-    dut.rx_data.value = value
-    dut.rx_valid.value = 1
-    await FallingEdge(dut.sys_clk)
-    dut.rx_valid.value = 0
-
-
-async def send_bytes(dut, values: bytes) -> None:
-    for value in values:
-        await send_char(dut, value)
-
-
-async def pulse_tick(dut, count: int = 1) -> None:
-    for _ in range(count):
-        await FallingEdge(dut.sys_clk)
-        dut.tick_1s_test.value = 1
-        await FallingEdge(dut.sys_clk)
-        dut.tick_1s_test.value = 0
-
-
-async def read_channels(dut) -> tuple[list[int], int]:
-    raw: list[int] = []
-    valid_mask = 0
-    for index in range(24):
-        dut.rd_index.value = index
-        await RisingEdge(dut.sys_clk)
-        await Timer(1, units="ns")
-        raw.append(int(dut.rd_raw.value))
-        valid_mask |= int(dut.rd_valid.value) << index
-    return raw, valid_mask
-
-
-async def expect_commit(dut, case: SnapshotCase, terminator: bytes) -> None:
-    commits = int(dut.commit_count_mon.value)
-    epoch = int(dut.epoch.value)
-    bank = int(dut.active_bank.value)
-    await send_bytes(dut, case.line + terminator)
-    await clock_cycles(dut, 3)
-    assert int(dut.commit_count_mon.value) == commits + 1
-    assert int(dut.epoch.value) == (epoch + 1) & 0xFFFF
-    assert int(dut.active_bank.value) == 1 - bank
-    assert int(dut.age_seconds.value) == 0
-    expected_raw = [int.from_bytes(case.raw[index : index + 2], "big") for index in range(0, 48, 2)]
-    expected_valid = sum(
-        (case.raw[index : index + 2] != b"\xFF\xFF") << (index // 2)
-        for index in range(0, 48, 2)
-    )
-    observed_raw, observed_valid = await read_channels(dut)
-    assert observed_raw == expected_raw
-    assert observed_valid == expected_valid
-    assert int(dut.active_valid_mask.value) == expected_valid
-
-
-async def expect_reject(dut, line: bytes, *, timeout: bool = False) -> None:
-    commits = int(dut.commit_count_mon.value)
-    errors = int(dut.error_count_mon.value)
-    epoch = int(dut.epoch.value)
-    bank = int(dut.active_bank.value)
-    raw_before, valid_before = await read_channels(dut)
-    await send_bytes(dut, line)
-    if timeout:
-        await clock_cycles(dut, 70)
-    else:
-        await clock_cycles(dut, 3)
-    assert int(dut.commit_count_mon.value) == commits
-    assert int(dut.error_count_mon.value) == errors + 1
-    assert int(dut.epoch.value) == epoch
-    assert int(dut.active_bank.value) == bank
-    raw_after, valid_after = await read_channels(dut)
-    assert (raw_after, valid_after) == (raw_before, valid_before)
-
-
-@cocotb.test()
-async def test_bmc_replay_fuzz_timeout_banks_epoch_and_freshness(dut):
-    dut.tick_1s_test.value = 0
-    dut.rx_valid.value = 0
-    dut.rx_data.value = 0
-    dut.rx_framing_error.value = 0
-    dut.snapshot_lock.value = 0
-    dut.snapshot_lock_bank.value = 0
-    dut.rd_index.value = 0
-    await with_timeout(RisingEdge(dut.rst_n_mon), 1, "ms")
-    await clock_cycles(dut, 27)
-    assert int(dut.age_seconds.value) == 0xFFFF
-    assert int(dut.stale.value) == 1
-
-    cases = generated_cases()
-    baseline = SnapshotCase(
-        channels=tuple((30, 0) for _ in range(24)),
-        lower=False,
-        separator=b" ",
-    )
-
-    # The optional six-byte command echo is a separate non-committing line.
-    await send_bytes(dut, b"36 6c DF dd 00 03\r\n")
-    await clock_cycles(dut, 3)
-    assert int(dut.commit_count_mon.value) == 0
-    assert int(dut.error_count_mon.value) == 0
-
-    # Mixed upper/lower hex, space/tab/no separators, CR, LF, CRLF, FF FF,
-    # consecutive snapshots, atomic bank flips, and exact epochs.
-    for index, case in enumerate(cases):
-        terminator = (b"\r", b"\n", b"\r\n")[index % 3]
-        await expect_commit(dut, case, terminator)
-
-        # Each valid replay also seeds a guaranteed-invalid-character mutation
-        # which must preserve the previously active bank byte-for-byte.
-        mutated = bytearray(case.line)
-        mutated[0] = ord("G")
-        await expect_reject(dut, bytes(mutated) + b"\r")
-
-    # Freshness is reset by a commit, ages on distinct one-second ticks, and
-    # becomes stale at the configured threshold.  A new snapshot clears it.
-    await pulse_tick(dut, 1)
-    assert int(dut.age_seconds.value) == 1 and int(dut.stale.value) == 0
-    await pulse_tick(dut, 1)
-    assert int(dut.age_seconds.value) == 2 and int(dut.stale.value) == 1
-    await expect_commit(dut, baseline, b"\r")
-    assert int(dut.age_seconds.value) == 0 and int(dut.stale.value) == 0
-
-    raw = baseline.raw
-    hex_line = b" ".join(f"{value:02X}".encode("ascii") for value in raw)
-    await expect_reject(dut, b" ".join(f"{value:02X}".encode("ascii") for value in raw[:-1]) + b"\r")
-    await expect_reject(dut, hex_line + b" 00\r")
-    await expect_reject(dut, b"FF" + hex_line[2:] + b"\r")
-    await expect_reject(dut, hex_line[:1] + b" " + hex_line[1:] + b"\r")
-
-    # A UART framing error taints the complete line even when all ASCII bytes
-    # that follow would otherwise be valid.
-    commits = int(dut.commit_count_mon.value)
-    errors = int(dut.error_count_mon.value)
-    await FallingEdge(dut.sys_clk)
-    dut.rx_framing_error.value = 1
-    await FallingEdge(dut.sys_clk)
-    dut.rx_framing_error.value = 0
-    await send_bytes(dut, hex_line + b"\r")
-    await clock_cycles(dut, 3)
-    assert int(dut.commit_count_mon.value) == commits
-    assert int(dut.error_count_mon.value) == errors + 1
-
-    # A half reply with no CR/LF is discarded by the inter-byte timeout.  The
-    # following complete reply starts from a clean nibble/count/echo state.
-    await expect_reject(dut, hex_line[:20], timeout=True)
-    await expect_commit(dut, baseline, b"\n")
-
-    # Snapshot ownership of the inactive bank blocks partial writes and bank
-    # flips until the lock is released.
-    dut.snapshot_lock.value = 1
-    dut.snapshot_lock_bank.value = 1 - int(dut.active_bank.value)
-    await expect_reject(dut, hex_line + b"\r")
-    dut.snapshot_lock.value = 0
-    await expect_commit(dut, baseline, b"\r")

+ 0 - 264
tests/cocotb/test_prod2u_door_temp_uart_e2e.py

@@ -1,264 +0,0 @@
-"""Real UART-bit e2e: startup_complete, SET_ALL percent, GET_TEMPERATURE, GET_MOTOR_STATUS."""
-
-import cocotb
-import cocotb.simulator as simulator
-from cocotb.triggers import FallingEdge, NextTimeStep, ReadWrite, RisingEdge, SimTimeoutError, Timer, with_timeout
-from cocotb.utils import get_sim_time
-
-
-CLKS_PER_BIT = 217
-SET_ALL = 0x01
-GET_TEMPERATURE = 0x02
-GET_MOTOR_STATUS = 0x03
-TEMPERATURE_DATA = 0x82
-MOTOR_STATUS_DATA = 0x83
-# Serial X→Y→Z measure-open + profile; DDA service is real-time (tick_500us only is accelerated).
-STARTUP_TIMEOUT_MS = 30000
-TEMPERATURE_BYTE_TIMEOUT_MS = 100
-STATUS_BYTE_TIMEOUT_MS = 100
-FRAME_ACCEPT_TIMEOUT_MS = 100
-
-
-def crc16(data: bytes) -> int:
-    crc = 0xFFFF
-    for value in data:
-        crc ^= value << 8
-        for _ in range(8):
-            crc = ((crc << 1) ^ 0x1021) & 0xFFFF if crc & 0x8000 else (crc << 1) & 0xFFFF
-    return crc
-
-
-def frame(kind: int, payload: bytes) -> bytes:
-    body = bytes((kind, len(payload))) + payload
-    return b"\xA5\x5A" + body + crc16(body).to_bytes(2, "little")
-
-
-def _sim_time_ns() -> str:
-    try:
-        return f"{get_sim_time(unit='ns'):.0f}ns"
-    except Exception:
-        return "unknown"
-
-
-def checkpoint(stage: str, **fields) -> None:
-    extra = " ".join(f"{key}={value}" for key, value in fields.items())
-    suffix = f" {extra}" if extra else ""
-    cocotb.log.info("checkpoint stage=%s sim_time=%s%s", stage, _sim_time_ns(), suffix)
-
-
-async def clocks(dut, count: int) -> None:
-    clk = getattr(getattr(dut, "u_dut", None), "sys_clk", None)
-    if clk is None:
-        await Timer(count * 40, unit="ns")
-        return
-    for _ in range(count):
-        await RisingEdge(clk)
-
-
-async def send_uart_byte(dut, value: int) -> None:
-    await ReadWrite()
-    dut.host_uart_rx.value = 0
-    await clocks(dut, CLKS_PER_BIT)
-    for bit in range(8):
-        dut.host_uart_rx.value = (value >> bit) & 1
-        await clocks(dut, CLKS_PER_BIT)
-    dut.host_uart_rx.value = 1
-    await clocks(dut, CLKS_PER_BIT)
-
-
-async def send_frame(dut, packet: bytes) -> None:
-    await NextTimeStep()
-    for value in packet:
-        await send_uart_byte(dut, value)
-
-
-async def receive_uart_byte(dut) -> int:
-    # Idle-high then start bit. Caller may arm this before send completes so the
-    # first response start edge is not missed (DUT can TX during last RX stop).
-    if int(dut.host_uart_tx.value) != 1:
-        await RisingEdge(dut.host_uart_tx)
-    await FallingEdge(dut.host_uart_tx)
-    await clocks(dut, CLKS_PER_BIT + CLKS_PER_BIT // 2)
-    value = 0
-    for bit in range(8):
-        value |= int(dut.host_uart_tx.value) << bit
-        await clocks(dut, CLKS_PER_BIT)
-    stop = int(dut.host_uart_tx.value)
-    if stop != 1:
-        raise AssertionError(
-            f"uart stop-bit framing error value=0x{value:02x} stop={stop} "
-            f"sim_time={_sim_time_ns()}"
-        )
-    return value
-
-
-async def receive_exact(dut, nbytes: int, timeout_ms: int, stage: str) -> bytes:
-    out = bytearray()
-    for byte_index in range(nbytes):
-        out.append(
-            await wait_for_stage(
-                receive_uart_byte(dut),
-                timeout_ms,
-                stage,
-                byte_index,
-            )
-        )
-    return bytes(out)
-
-
-async def wait_for_stage(awaitable, timeout_ms: int, stage: str, byte_index: int = -1, **fields):
-    try:
-        return await with_timeout(awaitable, timeout_ms, "ms")
-    except SimTimeoutError as exc:
-        suffix = "" if byte_index < 0 else f" byte_index={byte_index}"
-        extra = "".join(f" {key}={value}" for key, value in fields.items())
-        raise AssertionError(
-            f"timeout stage={stage} timeout_ms={timeout_ms} sim_time={_sim_time_ns()}"
-            f"{suffix}{extra}"
-        ) from exc
-
-
-async def wait_level_or_edge(signal, *, want: int, timeout_ms: int, stage: str) -> None:
-    current = int(signal.value) if signal.value.is_resolvable else None
-    if current == want:
-        checkpoint(stage, already=want)
-        return
-    edge = RisingEdge(signal) if want else FallingEdge(signal)
-    await wait_for_stage(edge, timeout_ms, stage, signal_level=current, want=want)
-
-
-
-async def wait_measure_rises_then_open(
-    dut,
-    *,
-    step_sig,
-    limit_ls,
-    limit_hs,
-    axis_name: str,
-    min_rises: int = 2,
-) -> int:
-    """Serial-cal friendly: wait for this axis's measure-open STEP rises, then hit open only."""
-    # Let the simulator advance directly to STEP activity.  Iterating every
-    # sys_clk edge here made the same bounded check take hundreds of seconds
-    # of Python/VPI wall time despite only needing to observe two rises.
-    rises = 0
-    for rise_index in range(min_rises):
-        await wait_for_stage(
-            RisingEdge(step_sig),
-            5000,
-            f"cal_measure_{axis_name}",
-            rise_index,
-        )
-        rises += 1
-    limit_hs.value = 1
-    limit_ls.value = 0
-    checkpoint(f"cal_open_{axis_name}", rises=rises)
-    # Allow limit sync + terminal handoff before the next axis starts.
-    await clocks(dut, 4000)
-    return rises
-
-
-@cocotb.test()
-async def test_set_all_get_temperature_over_real_uart(dut):
-    try:
-        checkpoint("test_start")
-        dut.host_uart_rx.value = 1
-        # Begin on close limits so each serial axis can finish seek-close immediately.
-        dut.x_limit_ls.value = 1
-        dut.x_limit_hs.value = 0
-        dut.y_limit_ls.value = 1
-        dut.y_limit_hs.value = 0
-        dut.z_limit_ls.value = 1
-        dut.z_limit_hs.value = 0
-        dut.temp_scl.value = 1
-        dut.temp_sda.value = 1
-        await clocks(dut, 2000)
-
-        # A2 serial X→Y→Z: stimulate open limit per axis after its own measure-open rises.
-        # Do not assert Y/Z open early — that strands seek-close and burns MAX_CAL_STEPS.
-        x_rises = await wait_measure_rises_then_open(
-            dut, step_sig=dut.x_step, limit_ls=dut.x_limit_ls, limit_hs=dut.x_limit_hs, axis_name="x"
-        )
-        y_rises = await wait_measure_rises_then_open(
-            dut, step_sig=dut.y_step, limit_ls=dut.y_limit_ls, limit_hs=dut.y_limit_hs, axis_name="y"
-        )
-        z_rises = await wait_measure_rises_then_open(
-            dut, step_sig=dut.z_step, limit_ls=dut.z_limit_ls, limit_hs=dut.z_limit_hs, axis_name="z"
-        )
-        await wait_level_or_edge(
-            dut.u_dut.startup_complete,
-            want=1,
-            timeout_ms=STARTUP_TIMEOUT_MS,
-            stage="startup_complete",
-        )
-        checkpoint("startup_complete", x_rises=x_rises, y_rises=y_rises, z_rises=z_rises)
-
-        # Clear limits for mid motion
-        dut.x_limit_ls.value = 0
-        dut.x_limit_hs.value = 0
-        dut.y_limit_ls.value = 0
-        dut.y_limit_hs.value = 0
-        dut.z_limit_ls.value = 0
-        dut.z_limit_hs.value = 0
-        await clocks(dut, 16)
-
-        # Z/X/Y percents = 50/50/50 (not jog 01/02)
-        payload = bytes((10, 20, 30, 40, 0, 0, 0, 0, 50, 50, 50))
-        checkpoint("set_all_tx")
-        await send_frame(dut, frame(SET_ALL, payload))
-        await clocks(dut, CLKS_PER_BIT * 16)
-        assert int(dut.motor_en_n.value) == 1
-
-        await wait_level_or_edge(
-            dut.u_dut.frame_accept_enable,
-            want=1,
-            timeout_ms=FRAME_ACCEPT_TIMEOUT_MS,
-            stage="frame_accept_enable",
-        )
-
-        checkpoint("get_motor_status_tx")
-        # Arm RX before/during TX so DUT's first start bit is not missed.
-        status_task = cocotb.start_soon(
-            receive_exact(dut, 37, STATUS_BYTE_TIMEOUT_MS, "motor_status_response")
-        )
-        await send_frame(dut, frame(GET_MOTOR_STATUS, b""))
-        status = await status_task
-        assert status[:4] == bytes((0xA5, 0x5A, MOTOR_STATUS_DATA, 31))
-        assert len(status) == 37
-        payload = status[4:35]
-        assert len(payload) == 31
-        assert status[-2:] == crc16(status[2:-2]).to_bytes(2, "little")
-        assert payload[0] & 0x40  # startup_complete
-        # Byte-exact regions: X@1..10, Y@11..20, Z@21..30 (SET_ALL 50/50/50)
-        assert payload[3] == 50  # X requested percent
-        assert payload[13] == 50  # Y
-        assert payload[23] == 50  # Z
-        # Anti-misalign: first two payload bytes must not be a false duplicate
-        # of a non-equal snap[0]/snap[1] pattern when state differs.
-        assert payload[1] & 0x07 in range(0, 7)  # X state nibble
-        # Last byte is Z fault_code (cal success → 0)
-        assert payload[30] == 0
-        checkpoint("motor_status_ok")
-
-        await wait_level_or_edge(
-            dut.u_dut.frame_accept_enable,
-            want=1,
-            timeout_ms=FRAME_ACCEPT_TIMEOUT_MS,
-            stage="frame_accept_enable_2",
-        )
-        checkpoint("get_temperature_tx")
-        temp_task = cocotb.start_soon(
-            receive_exact(dut, 33, TEMPERATURE_BYTE_TIMEOUT_MS, "temperature_response")
-        )
-        await send_frame(dut, frame(GET_TEMPERATURE, b""))
-        response = await temp_task
-        assert response[:4] == bytes((0xA5, 0x5A, TEMPERATURE_DATA, 27))
-        assert len(response) == 33
-        assert response[-2:] == crc16(response[2:-2]).to_bytes(2, "little")
-        assert set(response[4:31]) == {0xFF}
-        checkpoint("temperature_response_ok", bytes=len(response))
-    finally:
-        try:
-            simulator.stop_simulator()
-        except Exception:
-            pass

+ 0 - 22
tests/formal/6400_bmc_bank_properties.sby

@@ -1,22 +0,0 @@
-[tasks]
-boolector
-z3
-
-[options]
-mode prove
-depth 8
-
-[engines]
-boolector: smtbmc boolector
-z3: smtbmc z3 -- --noincr
-
-[script]
-read_verilog -formal ef2_bram_dp.v
-read_verilog -formal -D FORMAL bmc_ascii_snapshot.v
-read_verilog -formal 6400_bmc_bank_properties_formal.v
-prep -top thermal_6400_bmc_bank_properties_formal
-
-[files]
-../../src/common/ef2_bram_dp.v
-../../src/acquisition/bmc_ascii_snapshot.v
-6400_bmc_bank_properties_formal.v

+ 0 - 30
tests/formal/6400_bmc_bank_properties_formal.v

@@ -1,30 +0,0 @@
-module thermal_6400_bmc_bank_properties_formal (
-    input wire clk,
-    input wire rst_n
-);
-    (* anyseq *) reg tick_1s;
-    (* anyseq *) reg rx_valid;
-    (* anyseq *) reg [7:0] rx_data;
-    (* anyseq *) reg rx_error;
-    (* anyseq *) reg snapshot_lock;
-    (* anyseq *) reg snapshot_lock_bank;
-
-    bmc_ascii_snapshot #(.STALE_SECONDS(3)) dut (
-        .clk(clk), .rst_n(rst_n), .tick_1s(tick_1s),
-        .rx_valid(rx_valid), .rx_data(rx_data), .rx_framing_error(rx_error),
-        .snapshot_lock(snapshot_lock), .snapshot_lock_bank(snapshot_lock_bank),
-        .snapshot_commit(), .parser_error(), .epoch(), .age_seconds(), .stale(),
-        .active_bank(), .active_valid_mask(), .control_bank(1'b0),
-        .control_index(5'd0), .control_raw(), .control_valid(),
-        .snapshot_bank(1'b0), .snapshot_index(5'd0),
-        .snapshot_raw(), .snapshot_valid()
-    );
-
-    reg [1:0] reset_cycles = 0;
-    always @(posedge clk) begin
-        if (reset_cycles < 2) begin
-            assume(!rst_n);
-            reset_cycles <= reset_cycles + 1'b1;
-        end else assume(rst_n);
-    end
-endmodule

+ 0 - 17
tests/formal/6400_bmc_bank_reachability.sby

@@ -1,17 +0,0 @@
-[options]
-mode cover
-depth 128
-
-[engines]
-smtbmc boolector
-
-[script]
-read_verilog -formal ef2_bram_dp.v
-read_verilog -formal -D FORMAL bmc_ascii_snapshot.v
-read_verilog -formal 6400_bmc_bank_properties_formal.v
-prep -top thermal_6400_bmc_bank_properties_formal
-
-[files]
-../../src/common/ef2_bram_dp.v
-../../src/acquisition/bmc_ascii_snapshot.v
-6400_bmc_bank_properties_formal.v

+ 0 - 23
tests/formal/door_axis_cal.sby

@@ -1,23 +0,0 @@
-[tasks]
-bmc
-cover
-
-[options]
-bmc: mode bmc
-bmc: depth 40
-cover: mode cover
-cover: depth 40
-
-[engines]
-smtbmc z3
-
-[script]
-read_verilog -formal door_axis_controller.v
-read_verilog -formal door_axis_cal_formal.v
-proc
-setundef -zero
-prep -top door_axis_cal_formal
-
-[files]
-../../src/modules/door_axis_controller.v
-door_axis_cal_formal.v

+ 0 - 164
tests/formal/door_axis_cal_formal.v

@@ -1,164 +0,0 @@
-// DUT-connected calibration BMC on door_axis_controller (scaled MAX_CAL_STEPS).
-// Proves: success/fault mutex; per-phase gated-rise budgets; Nth-rise+limit
-// prefers limit success over timeout; tiny-travel fault; legal travel success.
-// Bounded BMC — not an unbounded proof. Vacuous assume(terminal==...) forbidden.
-module door_axis_cal_formal (
-    input wire clk,
-    input wire rst_n,
-    input wire tick_500us,
-    input wire open_limit,
-    input wire close_limit,
-    input wire force_rise
-);
-    localparam integer MAX_CAL = 6;
-    localparam [2:0] ST_CAL_SEEK_CLOSE = 3'd0;
-    localparam [2:0] ST_CAL_MEASURE_OPEN = 3'd1;
-    localparam [2:0] ST_IDLE = 3'd2;
-    localparam [2:0] ST_FAULT = 3'd6;
-    localparam [2:0] FC_TINY_TRAVEL = 3'd4;
-    localparam [2:0] FC_CAL_CLOSE_TIMEOUT = 3'd2;
-    localparam [2:0] FC_CAL_OPEN_TIMEOUT = 3'd3;
-
-    wire dut_rst_n = rst_n;
-    wire planner_req;
-    wire [7:0] planner_percent;
-    wire [12:0] planner_travel;
-    wire step;
-    wire dir_close;
-    wire [2:0] status_state;
-    wire [7:0] status_flags;
-    wire [7:0] status_requested_percent;
-    wire [12:0] status_current;
-    wire [12:0] status_target;
-    wire [12:0] status_travel;
-    wire [7:0] status_fault_code;
-    wire calibrated;
-    wire faulted;
-    wire terminal;
-
-    wire gated_step = step;
-    reg prev_gated;
-    wire gated_step_rise = force_rise & gated_step & ~prev_gated;
-
-    reg [1:0] reset_cycles;
-    reg [3:0] rise_seek;
-    reg [3:0] rise_measure;
-    reg [3:0] rise_total;
-
-    door_axis_controller #(
-        .AXIS_ID(0),
-        .MAX_CAL_STEPS(MAX_CAL),
-        .MIN_TRAVEL(2),
-        .ENDPOINT_GUARD_EXTRA(2),
-        .DIR_SETUP_TICKS(1),
-        .PERCENT_MAX(100)
-    ) dut (
-        .clk(clk), .rst_n(dut_rst_n),
-        .open_limit(open_limit), .close_limit(close_limit),
-        .limit_sync_valid(1'b1),
-        .cal_enable(1'b1),
-        .gated_step(gated_step), .gated_step_rise(gated_step_rise),
-        .tick_500us(tick_500us),
-        .step_toggle_pulse(tick_500us),
-        .rate_quantum_in(21'd0),
-        .rate_quantum_valid(1'b0),
-        .request_valid(1'b0),
-        .requested_percent_in(8'd0),
-        .watchdog_stop(1'b0),
-        .planner_req(planner_req),
-        .planner_percent(planner_percent),
-        .planner_travel(planner_travel),
-        .planner_done(1'b0),
-        .planner_done_axis(2'd0),
-        .planner_done_percent(8'd0),
-        .planner_result(13'd0),
-        .step(step), .dir_close(dir_close),
-        .status_state(status_state), .status_flags(status_flags),
-        .status_requested_percent(status_requested_percent),
-        .status_current(status_current), .status_target(status_target),
-        .status_travel(status_travel), .status_fault_code(status_fault_code),
-        .calibrated(calibrated), .faulted(faulted), .terminal(terminal),
-        .axis_moving(), .axis_allow_rise(), .axis_in_calibration(), .axis_endpoint_crawl(),
-        .axis_dda_run(),
-        .profile_level(), .profile_distance(), .profile_done_steps(), .profile_ramp_unit(),
-        .rate_quantum()
-    );
-
-    initial begin
-        reset_cycles = 2'd0;
-        prev_gated = 1'b0;
-        rise_seek = 4'd0;
-        rise_measure = 4'd0;
-        rise_total = 4'd0;
-    end
-
-    always @(posedge clk) begin
-        assume (rst_n == 1'b0 || rst_n == 1'b1);
-        assume (tick_500us == 1'b0 || tick_500us == 1'b1);
-        assume (open_limit == 1'b0 || open_limit == 1'b1);
-        assume (close_limit == 1'b0 || close_limit == 1'b1);
-        assume (force_rise == 1'b0 || force_rise == 1'b1);
-        assume (!(tick_500us && $past(tick_500us)));
-        // both-limits path covered by cover only; keep main BMC free of both.
-        assume (!(open_limit && close_limit));
-
-        if ($initstate || reset_cycles < 2) begin
-            assume (!dut_rst_n);
-            reset_cycles <= reset_cycles + 1'b1;
-        end else begin
-            assume (dut_rst_n);
-        end
-
-        if (!dut_rst_n) begin
-            prev_gated <= 1'b0;
-            rise_seek <= 4'd0;
-            rise_measure <= 4'd0;
-            rise_total <= 4'd0;
-        end else begin
-            prev_gated <= gated_step;
-            if (gated_step_rise) begin
-                rise_total <= rise_total + 1'b1;
-                if (status_state == ST_CAL_SEEK_CLOSE)
-                    rise_seek <= rise_seek + 1'b1;
-                if (status_state == ST_CAL_MEASURE_OPEN)
-                    rise_measure <= rise_measure + 1'b1;
-            end
-
-            assert (!(calibrated && faulted));
-            if (terminal)
-                assert (faulted || calibrated);
-
-            // Per-phase budgets: never emit the (MAX+1)-th rise in a phase.
-            assert (rise_seek <= MAX_CAL[3:0]);
-            assert (rise_measure <= MAX_CAL[3:0]);
-            assert (rise_total <= (MAX_CAL * 2));
-
-            // Nth rise + target limit same edge → limit success, not timeout fault.
-            if (status_state == ST_CAL_SEEK_CLOSE && gated_step_rise &&
-                close_limit && !open_limit && (rise_seek + 1'b1 == MAX_CAL[3:0])) begin
-                assert (status_fault_code[2:0] != FC_CAL_CLOSE_TIMEOUT);
-            end
-            if (status_state == ST_CAL_MEASURE_OPEN && gated_step_rise &&
-                open_limit && !close_limit && (rise_measure + 1'b1 == MAX_CAL[3:0])) begin
-                assert (status_fault_code[2:0] != FC_CAL_OPEN_TIMEOUT);
-            end
-
-            // Tiny travel: open_limit completing measure with travel < MIN → fault.
-            if (faulted && (status_fault_code[2:0] == FC_TINY_TRAVEL))
-                assert (!calibrated);
-
-            // Legal success: calibrated idle with travel in [MIN, MAX].
-            if (calibrated && !faulted && (status_state == ST_IDLE) && terminal) begin
-                assert (status_travel >= 13'd2);
-                assert (status_travel <= MAX_CAL[12:0]);
-            end
-
-            cover (calibrated && terminal && !faulted);
-            cover (faulted && terminal);
-            cover (gated_step_rise);
-            cover (faulted && (status_fault_code[2:0] == FC_TINY_TRAVEL));
-            cover (status_state == ST_CAL_MEASURE_OPEN && gated_step_rise &&
-                   open_limit && (rise_measure + 1'b1 == MAX_CAL[3:0]));
-        end
-    end
-endmodule

+ 0 - 23
tests/formal/door_axis_motion_contract.sby

@@ -1,23 +0,0 @@
-[tasks]
-bmc
-cover
-
-[options]
-bmc: mode bmc
-bmc: depth 40
-cover: mode cover
-cover: depth 40
-
-[engines]
-smtbmc z3
-
-[script]
-read_verilog -formal door_axis_controller.v
-read_verilog -formal door_axis_motion_contract_formal.v
-proc
-setundef -zero
-prep -top door_axis_motion_contract_formal
-
-[files]
-../../src/modules/door_axis_controller.v
-door_axis_motion_contract_formal.v

+ 0 - 147
tests/formal/door_axis_motion_contract_formal.v

@@ -1,147 +0,0 @@
-// DUT-connected motion safety: DIR stable while STEP high.
-// stop_latched is cover-only (drain behavior proved in door_axis_watchdog_drain).
-// Bounded BMC with scaled params. Not an unbounded proof.
-module door_axis_motion_contract_formal (
-    input wire clk,
-    input wire rst_n,
-    input wire tick_500us,
-    input wire request_valid,
-    input wire [7:0] requested_percent_in,
-    input wire watchdog_stop,
-    input wire open_limit,
-    input wire close_limit
-);
-    wire dut_rst_n = rst_n;
-    wire planner_req;
-    wire [7:0] planner_percent;
-    wire [12:0] planner_travel;
-    reg planner_done;
-    reg [1:0] planner_done_axis;
-    reg [7:0] planner_done_percent;
-    reg [12:0] planner_result;
-
-    wire step;
-    wire dir_close;
-    wire [2:0] status_state;
-    wire [7:0] status_flags;
-    wire [7:0] status_requested_percent;
-    wire [12:0] status_current;
-    wire [12:0] status_target;
-    wire [12:0] status_travel;
-    wire [7:0] status_fault_code;
-    wire calibrated;
-    wire faulted;
-    wire terminal;
-
-    wire gated_step = step & ~((dir_close ? close_limit : open_limit));
-    reg prev_gated;
-    wire gated_step_rise = gated_step & ~prev_gated;
-
-    reg [1:0] reset_cycles;
-    reg prev_dir;
-    reg prev_step;
-    reg stop_latched;
-
-    door_axis_controller #(
-        .AXIS_ID(0),
-        .MAX_CAL_STEPS(8),
-        .MIN_TRAVEL(2),
-        .ENDPOINT_GUARD_EXTRA(4),
-        .DIR_SETUP_TICKS(2),
-        .PERCENT_MAX(100)
-    ) dut (
-        .clk(clk), .rst_n(dut_rst_n),
-        .open_limit(open_limit), .close_limit(close_limit),
-        .limit_sync_valid(1'b1),
-        .cal_enable(1'b1),
-        .gated_step(gated_step), .gated_step_rise(gated_step_rise),
-        .tick_500us(tick_500us),
-        .step_toggle_pulse(tick_500us),
-        .rate_quantum_in(21'd0),
-        .rate_quantum_valid(1'b0),
-        .request_valid(request_valid),
-        .requested_percent_in(requested_percent_in),
-        .watchdog_stop(watchdog_stop),
-        .planner_req(planner_req),
-        .planner_percent(planner_percent),
-        .planner_travel(planner_travel),
-        .planner_done(planner_done),
-        .planner_done_axis(planner_done_axis),
-        .planner_done_percent(planner_done_percent),
-        .planner_result(planner_result),
-        .step(step), .dir_close(dir_close),
-        .status_state(status_state), .status_flags(status_flags),
-        .status_requested_percent(status_requested_percent),
-        .status_current(status_current), .status_target(status_target),
-        .status_travel(status_travel), .status_fault_code(status_fault_code),
-        .calibrated(calibrated), .faulted(faulted), .terminal(terminal),
-        .axis_moving(), .axis_allow_rise(), .axis_in_calibration(), .axis_endpoint_crawl(),
-        .axis_dda_run(),
-        .profile_level(), .profile_distance(), .profile_done_steps(), .profile_ramp_unit(),
-        .rate_quantum()
-    );
-
-    initial begin
-        reset_cycles = 2'd0;
-        prev_gated = 1'b0;
-        prev_dir = 1'b0;
-        prev_step = 1'b0;
-        stop_latched = 1'b0;
-        planner_done = 1'b0;
-        planner_done_axis = 2'd0;
-        planner_done_percent = 8'd0;
-        planner_result = 13'd0;
-    end
-
-    always @(posedge clk) begin
-        assume (rst_n == 1'b0 || rst_n == 1'b1);
-        assume (tick_500us == 1'b0 || tick_500us == 1'b1);
-        assume (request_valid == 1'b0 || request_valid == 1'b1);
-        assume (watchdog_stop == 1'b0 || watchdog_stop == 1'b1);
-        assume (open_limit == 1'b0 || open_limit == 1'b1);
-        assume (close_limit == 1'b0 || close_limit == 1'b1);
-        assume (requested_percent_in <= 8'd100);
-        assume (!(tick_500us && $past(tick_500us)));
-        assume (!(open_limit && close_limit));
-
-        if ($initstate || reset_cycles < 2) begin
-            assume (!dut_rst_n);
-            reset_cycles <= reset_cycles + 1'b1;
-        end else begin
-            assume (dut_rst_n);
-        end
-
-        planner_done <= 1'b0;
-        if (planner_req) begin
-            planner_done <= 1'b1;
-            planner_done_axis <= 2'd0;
-            planner_done_percent <= planner_percent;
-            planner_result <= 13'd2;
-        end
-
-        if (!dut_rst_n) begin
-            prev_gated <= 1'b0;
-            prev_dir <= 1'b0;
-            prev_step <= 1'b0;
-            stop_latched <= 1'b0;
-        end else begin
-            prev_gated <= gated_step;
-            // Only latch stop when DUT can accept watchdog.
-            if (watchdog_stop && !request_valid && calibrated && !faulted)
-                stop_latched <= 1'b1;
-            if (request_valid)
-                stop_latched <= 1'b0;
-
-            // DIR must not toggle while STEP is high (runtime / cal moving).
-            // Exclude the first cycle after reset release.
-            if (prev_step && calibrated)
-                assert (dir_close == prev_dir);
-
-            cover (prev_step && (dir_close == prev_dir) && calibrated);
-            cover (stop_latched && (step == 1'b0) && watchdog_stop);
-
-            prev_dir <= dir_close;
-            prev_step <= step;
-        end
-    end
-endmodule

+ 0 - 23
tests/formal/door_axis_request_limit_race.sby

@@ -1,23 +0,0 @@
-[tasks]
-bmc
-cover
-
-[options]
-bmc: mode bmc
-bmc: depth 48
-cover: mode cover
-cover: depth 48
-
-[engines]
-smtbmc z3
-
-[script]
-read_verilog -formal door_axis_controller.v
-read_verilog -formal door_axis_request_limit_race_formal.v
-proc
-setundef -zero
-prep -top door_axis_request_limit_race_formal
-
-[files]
-../../src/modules/door_axis_controller.v
-door_axis_request_limit_race_formal.v

+ 0 - 189
tests/formal/door_axis_request_limit_race_formal.v

@@ -1,189 +0,0 @@
-// DUT-connected: accepted one-shot limit snap precedes same-cycle host replan.
-// Bounded BMC (scaled params). Not an unbounded proof.
-module door_axis_request_limit_race_formal (
-    input wire clk,
-    input wire rst_n,
-    input wire tick_500us,
-    input wire request_valid,
-    input wire [7:0] requested_percent_in,
-    input wire open_limit,
-    input wire close_limit
-);
-    localparam integer MAX_CAL = 8;
-    localparam [2:0] ST_WAIT_REPLAN = 3'd5;
-    localparam [2:0] ST_MOVE_OPEN = 3'd3;
-    localparam [2:0] ST_MOVE_CLOSE = 3'd4;
-
-    wire dut_rst_n = rst_n;
-    wire planner_req;
-    wire [7:0] planner_percent;
-    wire [12:0] planner_travel;
-    reg planner_done;
-    reg [1:0] planner_done_axis;
-    reg [7:0] planner_done_percent;
-    reg [12:0] planner_result;
-
-    wire step;
-    wire dir_close;
-    wire [2:0] status_state;
-    wire [7:0] status_flags;
-    wire [7:0] status_requested_percent;
-    wire [12:0] status_current;
-    wire [12:0] status_target;
-    wire [12:0] status_travel;
-    wire [7:0] status_fault_code;
-    wire calibrated;
-    wire faulted;
-    wire terminal;
-
-    wire gated_step = step & ~open_limit & ~close_limit;
-    reg prev_gated;
-    wire gated_step_rise = gated_step & ~prev_gated;
-
-    reg [1:0] reset_cycles;
-    // Mirror DUT one-shot arming (no hierarchical probes — Yosys formal).
-    reg open_limit_armed;
-    reg close_limit_armed;
-    wire moving = status_flags[3];
-    wire in_calibration = (status_state == 3'd0) || (status_state == 3'd1);
-    wire departing_close_source =
-        calibrated && !in_calibration &&
-        ((status_state == ST_MOVE_OPEN) || (moving && !dir_close));
-    wire departing_open_source =
-        calibrated && !in_calibration &&
-        ((status_state == ST_MOVE_CLOSE) || (moving && dir_close));
-    wire open_assert_event = open_limit && open_limit_armed;
-    wire close_assert_event = close_limit && close_limit_armed;
-    wire close_snap_accept =
-        calibrated && !in_calibration &&
-        close_assert_event && !departing_close_source;
-    wire open_snap_accept =
-        calibrated && !in_calibration &&
-        open_assert_event && !departing_open_source;
-
-    door_axis_controller #(
-        .AXIS_ID(0),
-        .MAX_CAL_STEPS(MAX_CAL),
-        .MIN_TRAVEL(2),
-        .ENDPOINT_GUARD_EXTRA(4),
-        .DIR_SETUP_TICKS(1),
-        .PERCENT_MAX(100)
-    ) dut (
-        .clk(clk), .rst_n(dut_rst_n),
-        .open_limit(open_limit), .close_limit(close_limit),
-        .limit_sync_valid(1'b1),
-        .cal_enable(1'b1),
-        .gated_step(gated_step), .gated_step_rise(gated_step_rise),
-        .tick_500us(tick_500us),
-        .step_toggle_pulse(tick_500us),
-        .rate_quantum_in(21'd0),
-        .rate_quantum_valid(1'b0),
-        .request_valid(request_valid),
-        .requested_percent_in(requested_percent_in),
-        .watchdog_stop(1'b0),
-        .planner_req(planner_req),
-        .planner_percent(planner_percent),
-        .planner_travel(planner_travel),
-        .planner_done(planner_done),
-        .planner_done_axis(planner_done_axis),
-        .planner_done_percent(planner_done_percent),
-        .planner_result(planner_result),
-        .step(step), .dir_close(dir_close),
-        .status_state(status_state), .status_flags(status_flags),
-        .status_requested_percent(status_requested_percent),
-        .status_current(status_current), .status_target(status_target),
-        .status_travel(status_travel), .status_fault_code(status_fault_code),
-        .calibrated(calibrated), .faulted(faulted), .terminal(terminal),
-        .axis_moving(), .axis_allow_rise(), .axis_in_calibration(), .axis_endpoint_crawl(),
-        .axis_dda_run(),
-        .profile_level(), .profile_distance(), .profile_done_steps(), .profile_ramp_unit(),
-        .rate_quantum()
-    );
-
-    initial begin
-        reset_cycles = 2'd0;
-        prev_gated = 1'b0;
-        open_limit_armed = 1'b1;
-        close_limit_armed = 1'b1;
-        planner_done = 1'b0;
-        planner_done_axis = 2'd0;
-        planner_done_percent = 8'd0;
-        planner_result = 13'd0;
-    end
-
-    always @(posedge clk) begin
-        assume (rst_n == 1'b0 || rst_n == 1'b1);
-        assume (tick_500us == 1'b0 || tick_500us == 1'b1);
-        assume (request_valid == 1'b0 || request_valid == 1'b1);
-        assume (open_limit == 1'b0 || open_limit == 1'b1);
-        assume (close_limit == 1'b0 || close_limit == 1'b1);
-        assume (requested_percent_in <= 8'd100);
-        assume (!(tick_500us && $past(tick_500us)));
-        assume (!(open_limit && close_limit));
-
-        if ($initstate || reset_cycles < 2) begin
-            assume (!dut_rst_n);
-            reset_cycles <= reset_cycles + 1'b1;
-        end else begin
-            assume (dut_rst_n);
-        end
-
-        planner_done <= 1'b0;
-        if (planner_req) begin
-            planner_done <= 1'b1;
-            planner_done_axis <= 2'd0;
-            planner_done_percent <= planner_percent;
-            planner_result <= (planner_travel > 13'd2) ? (planner_travel >> 1) : 13'd1;
-        end
-
-        if (!dut_rst_n) begin
-            prev_gated <= 1'b0;
-            open_limit_armed <= 1'b1;
-            close_limit_armed <= 1'b1;
-        end else begin
-            prev_gated <= gated_step;
-            if (!open_limit)
-                open_limit_armed <= 1'b1;
-            else if (open_assert_event)
-                open_limit_armed <= 1'b0;
-            if (!close_limit)
-                close_limit_armed <= 1'b1;
-            else if (close_assert_event)
-                close_limit_armed <= 1'b0;
-
-            // NBA-safe: one cycle after accepted snap event.
-            if ($past(dut_rst_n) && $past(calibrated) && !$past(faulted) &&
-                $past(close_snap_accept))
-                assert (status_current == status_travel);
-
-            if ($past(dut_rst_n) && $past(calibrated) && !$past(faulted) &&
-                $past(open_snap_accept))
-                assert (status_current == 13'd0);
-
-            if ($past(dut_rst_n) && $past(calibrated) && !$past(faulted) &&
-                $past(request_valid) && $past(close_snap_accept) &&
-                ($past(requested_percent_in) > 8'd0) &&
-                ($past(requested_percent_in) < 8'd100)) begin
-                assert (status_current == status_travel);
-                assert ((status_state == ST_WAIT_REPLAN) || planner_req ||
-                        (status_state == 3'd3) || (status_state == 3'd4) ||
-                        (status_state == 3'd2));
-            end
-
-            if ($past(dut_rst_n) && $past(calibrated) && !$past(faulted) &&
-                $past(request_valid) && $past(open_snap_accept) &&
-                ($past(requested_percent_in) > 8'd0) &&
-                ($past(requested_percent_in) < 8'd100)) begin
-                assert (status_current == 13'd0);
-                assert ((status_state == ST_WAIT_REPLAN) || planner_req ||
-                        (status_state == 3'd3) || (status_state == 3'd4) ||
-                        (status_state == 3'd2));
-            end
-
-            cover (calibrated && request_valid && close_snap_accept);
-            cover (calibrated && request_valid && open_snap_accept);
-            cover (calibrated && (status_state == ST_WAIT_REPLAN) &&
-                   close_snap_accept && (status_current == status_travel));
-        end
-    end
-endmodule

+ 0 - 23
tests/formal/door_axis_request_planner_collision.sby

@@ -1,23 +0,0 @@
-[tasks]
-bmc
-cover
-
-[options]
-bmc: mode bmc
-bmc: depth 48
-cover: mode cover
-cover: depth 48
-
-[engines]
-smtbmc z3
-
-[script]
-read_verilog -formal door_axis_controller.v
-read_verilog -formal door_axis_request_planner_collision_formal.v
-proc
-setundef -zero
-prep -top door_axis_request_planner_collision_formal
-
-[files]
-../../src/modules/door_axis_controller.v
-door_axis_request_planner_collision_formal.v

+ 0 - 165
tests/formal/door_axis_request_planner_collision_formal.v

@@ -1,165 +0,0 @@
-// DUT-connected: matching planner_done retires planner_req; close-limit accept
-// uses effective endpoint coordinate (no MOVE_CLOSE toward mid). Bounded BMC.
-module door_axis_request_planner_collision_formal (
-    input wire clk,
-    input wire rst_n,
-    input wire tick_500us,
-    input wire request_valid,
-    input wire [7:0] requested_percent_in,
-    input wire open_limit,
-    input wire close_limit
-);
-    localparam integer MAX_CAL = 8;
-    localparam [2:0] ST_WAIT_REPLAN = 3'd5;
-    localparam [2:0] ST_MOVE_CLOSE = 3'd4;
-
-    wire planner_req;
-    wire [7:0] planner_percent;
-    wire [12:0] planner_travel;
-    reg planner_done;
-    reg [1:0] planner_done_axis;
-    reg [7:0] planner_done_percent;
-    reg [12:0] planner_result;
-
-    wire step;
-    wire dir_close;
-    wire [2:0] status_state;
-    wire [7:0] status_flags;
-    wire [7:0] status_requested_percent;
-    wire [12:0] status_current;
-    wire [12:0] status_target;
-    wire [12:0] status_travel;
-    wire [7:0] status_fault_code;
-    wire calibrated;
-    wire faulted;
-    wire terminal;
-
-    wire gated_step = step & ~open_limit & ~close_limit;
-    reg prev_gated;
-    wire gated_step_rise = gated_step & ~prev_gated;
-    reg [1:0] reset_cycles;
-    reg req_seen_d;
-
-    // Mirror DUT planner_accept (mid + matching done + need).
-    wire mid_req = (status_requested_percent > 8'd0) &&
-                   (status_requested_percent < 8'd100);
-    // need_planner is internal; approximate via WAIT_REPLAN && planner_req && !target_valid
-    wire need_approx = (status_state == ST_WAIT_REPLAN) && planner_req && !status_flags[5];
-    wire planner_accept = planner_done && (planner_done_axis == 2'd0) &&
-        (planner_done_percent == status_requested_percent) && calibrated &&
-        mid_req && need_approx && (status_state != 3'd6);
-
-    door_axis_controller #(
-        .AXIS_ID(0),
-        .MAX_CAL_STEPS(MAX_CAL),
-        .MIN_TRAVEL(2),
-        .ENDPOINT_GUARD_EXTRA(4),
-        .DIR_SETUP_TICKS(1),
-        .PERCENT_MAX(100)
-    ) dut (
-        .clk(clk), .rst_n(rst_n),
-        .open_limit(open_limit), .close_limit(close_limit),
-        .limit_sync_valid(1'b1),
-        .cal_enable(1'b1),
-        .gated_step(gated_step), .gated_step_rise(gated_step_rise),
-        .tick_500us(tick_500us),
-        .step_toggle_pulse(tick_500us),
-        .rate_quantum_in(21'd0),
-        .rate_quantum_valid(1'b0),
-        .request_valid(request_valid),
-        .requested_percent_in(requested_percent_in),
-        .watchdog_stop(1'b0),
-        .planner_req(planner_req),
-        .planner_percent(planner_percent),
-        .planner_travel(planner_travel),
-        .planner_done(planner_done),
-        .planner_done_axis(planner_done_axis),
-        .planner_done_percent(planner_done_percent),
-        .planner_result(planner_result),
-        .step(step), .dir_close(dir_close),
-        .status_state(status_state), .status_flags(status_flags),
-        .status_requested_percent(status_requested_percent),
-        .status_current(status_current), .status_target(status_target),
-        .status_travel(status_travel), .status_fault_code(status_fault_code),
-        .calibrated(calibrated), .faulted(faulted), .terminal(terminal),
-        .axis_moving(), .axis_allow_rise(), .axis_in_calibration(), .axis_endpoint_crawl(),
-        .axis_dda_run(),
-        .profile_level(), .profile_distance(), .profile_done_steps(), .profile_ramp_unit(),
-        .rate_quantum()
-    );
-
-    initial begin
-        reset_cycles = 2'd0;
-        prev_gated = 1'b0;
-        planner_done = 1'b0;
-        planner_done_axis = 2'd0;
-        planner_done_percent = 8'd0;
-        planner_result = 13'd0;
-        req_seen_d = 1'b0;
-    end
-
-    always @(posedge clk) begin
-        assume (rst_n == 1'b0 || rst_n == 1'b1);
-        assume (tick_500us == 1'b0 || tick_500us == 1'b1);
-        assume (request_valid == 1'b0 || request_valid == 1'b1);
-        assume (open_limit == 1'b0 || open_limit == 1'b1);
-        assume (close_limit == 1'b0 || close_limit == 1'b1);
-        assume (requested_percent_in <= 8'd100);
-        assume (!(tick_500us && $past(tick_500us)));
-        assume (!(open_limit && close_limit));
-
-        if ($initstate || reset_cycles < 2) begin
-            assume (!rst_n);
-            reset_cycles <= reset_cycles + 1'b1;
-        end else begin
-            assume (rst_n);
-        end
-
-        if (!rst_n) begin
-            prev_gated <= 1'b0;
-            planner_done <= 1'b0;
-            req_seen_d <= 1'b0;
-        end else begin
-            prev_gated <= gated_step;
-            req_seen_d <= planner_req;
-
-            if (req_seen_d && planner_req) begin
-                planner_done <= 1'b1;
-                planner_done_axis <= 2'd0;
-                planner_done_percent <= planner_percent;
-                if (planner_travel > 13'd2)
-                    planner_result <= (planner_travel >> 1);
-                else
-                    planner_result <= 13'd1;
-            end else begin
-                planner_done <= 1'b0;
-            end
-
-            // Accept retires request.
-            if ($past(planner_accept))
-                assert (!planner_req);
-
-            // Same-% heartbeat does not block a matching accept.
-            if ($past(calibrated) && $past(planner_done) && $past(need_approx) &&
-                $past(planner_done_percent) == $past(status_requested_percent) &&
-                $past(mid_req) &&
-                $past(request_valid) &&
-                $past(requested_percent_in) == $past(status_requested_percent)) begin
-                assert ($past(planner_accept) || !planner_req ||
-                        ($past(requested_percent_in) != $past(status_requested_percent)));
-            end
-
-            // close_limit + accept toward mid → not MOVE_CLOSE next cycle.
-            if ($past(planner_accept) && $past(close_limit) && !$past(open_limit) &&
-                $past(planner_result) < $past(status_travel) &&
-                $past(planner_result) > 13'd0) begin
-                assert (status_state != ST_MOVE_CLOSE);
-            end
-
-            cover (calibrated && request_valid && planner_done &&
-                   (requested_percent_in == planner_done_percent));
-            cover (calibrated && close_limit && planner_accept);
-            cover (calibrated && request_valid && tick_500us);
-        end
-    end
-endmodule

+ 0 - 23
tests/formal/door_axis_source_limit_lingering.sby

@@ -1,23 +0,0 @@
-[tasks]
-bmc
-cover
-
-[options]
-bmc: mode bmc
-bmc: depth 48
-cover: mode cover
-cover: depth 48
-
-[engines]
-smtbmc z3
-
-[script]
-read_verilog -formal door_axis_controller.v
-read_verilog -formal door_axis_source_limit_lingering_formal.v
-proc
-setundef -zero
-prep -top door_axis_source_limit_lingering_formal
-
-[files]
-../../src/modules/door_axis_controller.v
-door_axis_source_limit_lingering_formal.v

+ 0 - 203
tests/formal/door_axis_source_limit_lingering_formal.v

@@ -1,203 +0,0 @@
-// DUT-connected: consumed source-limit must not overwrite gated_step_rise ±1.
-// Instantiates door_axis_controller. Bounded BMC — not an unbounded proof.
-`timescale 1ns/1ps
-
-module door_axis_source_limit_lingering_formal (
-    input wire clk,
-    input wire rst_n,
-    input wire tick_500us,
-    input wire request_valid,
-    input wire [7:0] requested_percent_in,
-    input wire open_limit,
-    input wire close_limit,
-    input wire force_rise
-);
-    localparam integer MAX_CAL = 8;
-    localparam [2:0] ST_MOVE_OPEN = 3'd3;
-    localparam [2:0] ST_MOVE_CLOSE = 3'd4;
-
-    wire dut_rst_n = rst_n;
-    wire planner_req;
-    wire [7:0] planner_percent;
-    wire [12:0] planner_travel;
-    reg planner_done;
-    reg [1:0] planner_done_axis;
-    reg [7:0] planner_done_percent;
-    reg [12:0] planner_result;
-
-    wire step;
-    wire dir_close;
-    wire [2:0] status_state;
-    wire [7:0] status_flags;
-    wire [7:0] status_requested_percent;
-    wire [12:0] status_current;
-    wire [12:0] status_target;
-    wire [12:0] status_travel;
-    wire [7:0] status_fault_code;
-    wire calibrated;
-    wire faulted;
-    wire terminal;
-
-    wire selected_limit = dir_close ? close_limit : open_limit;
-    wire gated_step = step & ~selected_limit;
-    reg prev_gated;
-    wire gated_step_rise = force_rise & gated_step & ~prev_gated;
-
-    reg [1:0] reset_cycles;
-    reg past_valid;
-    reg [2:0] linger_rises;
-    // Next-cycle checkers avoid same-edge combo/NBA sampling races on status_current.
-    reg pending_dec;
-    reg pending_inc;
-    reg [12:0] pos_before;
-
-    door_axis_controller #(
-        .AXIS_ID(0),
-        .MAX_CAL_STEPS(MAX_CAL),
-        .MIN_TRAVEL(2),
-        .ENDPOINT_GUARD_EXTRA(4),
-        .DIR_SETUP_TICKS(1),
-        .PERCENT_MAX(100)
-    ) dut (
-        .clk(clk), .rst_n(dut_rst_n),
-        .open_limit(open_limit), .close_limit(close_limit),
-        .limit_sync_valid(1'b1),
-        .cal_enable(1'b1),
-        .gated_step(gated_step), .gated_step_rise(gated_step_rise),
-        .tick_500us(tick_500us),
-        .step_toggle_pulse(tick_500us),
-        .rate_quantum_in(21'd0),
-        .rate_quantum_valid(1'b0),
-        .request_valid(request_valid),
-        .requested_percent_in(requested_percent_in),
-        .watchdog_stop(1'b0),
-        .planner_req(planner_req),
-        .planner_percent(planner_percent),
-        .planner_travel(planner_travel),
-        .planner_done(planner_done),
-        .planner_done_axis(planner_done_axis),
-        .planner_done_percent(planner_done_percent),
-        .planner_result(planner_result),
-        .step(step), .dir_close(dir_close),
-        .status_state(status_state), .status_flags(status_flags),
-        .status_requested_percent(status_requested_percent),
-        .status_current(status_current), .status_target(status_target),
-        .status_travel(status_travel), .status_fault_code(status_fault_code),
-        .calibrated(calibrated), .faulted(faulted), .terminal(terminal),
-        .axis_moving(), .axis_allow_rise(), .axis_in_calibration(), .axis_endpoint_crawl(),
-        .axis_dda_run(),
-        .profile_level(), .profile_distance(), .profile_done_steps(), .profile_ramp_unit(),
-        .rate_quantum()
-    );
-
-    initial begin
-        reset_cycles = 2'd0;
-        prev_gated = 1'b0;
-        past_valid = 1'b0;
-        linger_rises = 3'd0;
-        pending_dec = 1'b0;
-        pending_inc = 1'b0;
-        pos_before = 13'd0;
-        planner_done = 1'b0;
-        planner_done_axis = 2'd0;
-        planner_done_percent = 8'd0;
-        planner_result = 13'd0;
-    end
-
-    always @(posedge clk) begin
-        assume (rst_n == 1'b0 || rst_n == 1'b1);
-        assume (tick_500us == 1'b0 || tick_500us == 1'b1);
-        assume (request_valid == 1'b0 || request_valid == 1'b1);
-        assume (open_limit == 1'b0 || open_limit == 1'b1);
-        assume (close_limit == 1'b0 || close_limit == 1'b1);
-        assume (force_rise == 1'b0 || force_rise == 1'b1);
-        assume (requested_percent_in <= 8'd100);
-        assume (!(tick_500us && $past(tick_500us)));
-        assume (!(open_limit && close_limit));
-
-        if ($initstate || reset_cycles < 2) begin
-            assume (!dut_rst_n);
-            reset_cycles <= reset_cycles + 1'b1;
-        end else begin
-            assume (dut_rst_n);
-        end
-
-        planner_done <= 1'b0;
-        if (planner_req) begin
-            planner_done <= 1'b1;
-            planner_done_axis <= 2'd0;
-            planner_done_percent <= planner_percent;
-            planner_result <= (planner_travel > 13'd2) ? (planner_travel >> 1) : 13'd1;
-        end
-
-        if (!dut_rst_n) begin
-            prev_gated <= 1'b0;
-            past_valid <= 1'b0;
-            linger_rises <= 3'd0;
-            pending_dec <= 1'b0;
-            pending_inc <= 1'b0;
-            pos_before <= 13'd0;
-        end else begin
-            prev_gated <= gated_step;
-            past_valid <= 1'b1;
-            pending_dec <= 1'b0;
-            pending_inc <= 1'b0;
-
-            // Arm next-cycle check when a consumed source-limit linger rise occurs.
-            if (past_valid && gated_step_rise && calibrated && !faulted &&
-                (status_state == ST_MOVE_OPEN) &&
-                ($past(status_state) == ST_MOVE_OPEN) &&
-                close_limit && $past(close_limit) &&
-                !open_limit && !$past(open_limit) &&
-                !dir_close && !$past(dir_close) &&
-                ($past(status_current) > 13'd0) &&
-                (status_travel >= 13'd2) &&
-                !request_valid && !$past(request_valid)) begin
-                pending_dec <= 1'b1;
-                pos_before <= $past(status_current);
-            end
-
-            if (past_valid && gated_step_rise && calibrated && !faulted &&
-                (status_state == ST_MOVE_CLOSE) &&
-                ($past(status_state) == ST_MOVE_CLOSE) &&
-                open_limit && $past(open_limit) &&
-                !close_limit && !$past(close_limit) &&
-                dir_close && $past(dir_close) &&
-                ($past(status_current) < status_travel) &&
-                (status_travel >= 13'd2) &&
-                !request_valid && !$past(request_valid)) begin
-                pending_inc <= 1'b1;
-                pos_before <= $past(status_current);
-            end
-
-            // After the rise edge settles, coordinate must have moved by exactly 1.
-            // Keep the linger context on the check cycle (source still high, no target).
-            if ($past(pending_dec) && !faulted &&
-                (status_state == ST_MOVE_OPEN) && close_limit && !open_limit)
-                assert (status_current == ($past(pos_before) - 13'd1));
-            if ($past(pending_inc) && !faulted &&
-                (status_state == ST_MOVE_CLOSE) && open_limit && !close_limit)
-                assert (status_current == ($past(pos_before) + 13'd1));
-
-            if ($past(pending_dec) && (status_state == ST_MOVE_OPEN) &&
-                close_limit && !open_limit &&
-                (status_current == ($past(pos_before) - 13'd1)) &&
-                (linger_rises < 3'd7))
-                linger_rises <= linger_rises + 1'b1;
-            if ($past(pending_inc) && (status_state == ST_MOVE_CLOSE) &&
-                open_limit && !close_limit &&
-                (status_current == ($past(pos_before) + 13'd1)) &&
-                (linger_rises < 3'd7))
-                linger_rises <= linger_rises + 1'b1;
-
-            cover ($past(pending_dec) && (status_state == ST_MOVE_OPEN) &&
-                   close_limit && !open_limit &&
-                   (status_current == ($past(pos_before) - 13'd1)));
-            cover ($past(pending_inc) && (status_state == ST_MOVE_CLOSE) &&
-                   open_limit && !close_limit &&
-                   (status_current == ($past(pos_before) + 13'd1)));
-            cover (calibrated && (linger_rises >= 3'd2) && !close_limit && !open_limit &&
-                   (status_current != 13'd0) && (status_current != status_travel));
-        end
-    end
-endmodule

+ 0 - 23
tests/formal/door_axis_watchdog.sby

@@ -1,23 +0,0 @@
-[tasks]
-bmc
-cover
-
-[options]
-bmc: mode bmc
-bmc: depth 40
-cover: mode cover
-cover: depth 40
-
-[engines]
-smtbmc z3
-
-[script]
-read_verilog -formal door_axis_controller.v
-read_verilog -formal door_axis_watchdog_formal.v
-proc
-setundef -zero
-prep -top door_axis_watchdog_formal
-
-[files]
-../../src/modules/door_axis_controller.v
-door_axis_watchdog_formal.v

+ 0 - 23
tests/formal/door_axis_watchdog_drain.sby

@@ -1,23 +0,0 @@
-[tasks]
-bmc
-cover
-
-[options]
-bmc: mode bmc
-bmc: depth 48
-cover: mode cover
-cover: depth 48
-
-[engines]
-smtbmc boolector
-
-[script]
-read_verilog -formal door_axis_controller.v
-read_verilog -formal door_axis_watchdog_drain_formal.v
-proc
-setundef -zero
-prep -top door_axis_watchdog_drain_formal
-
-[files]
-../../src/modules/door_axis_controller.v
-door_axis_watchdog_drain_formal.v

+ 0 - 168
tests/formal/door_axis_watchdog_drain_formal.v

@@ -1,168 +0,0 @@
-// DUT-connected: door_axis_controller watchdog high-pulse drain.
-// Bounded BMC (scaled params). Not an unbounded proof.
-module door_axis_watchdog_drain_formal (
-    input wire clk,
-    input wire rst_n,
-    input wire tick_500us,
-    input wire request_valid,
-    input wire [7:0] requested_percent_in,
-    input wire watchdog_stop,
-    input wire open_limit,
-    input wire close_limit
-);
-    localparam integer MAX_CAL = 8;
-    localparam [2:0] ST_IDLE = 3'd2;
-    localparam [2:0] ST_WAIT_REPLAN = 3'd5;
-
-    wire dut_rst_n = rst_n;
-    wire planner_req;
-    wire [7:0] planner_percent;
-    wire [12:0] planner_travel;
-    reg planner_done;
-    reg [1:0] planner_done_axis;
-    reg [7:0] planner_done_percent;
-    reg [12:0] planner_result;
-
-    wire step;
-    wire dir_close;
-    wire [2:0] status_state;
-    wire [7:0] status_flags;
-    wire [7:0] status_requested_percent;
-    wire [12:0] status_current;
-    wire [12:0] status_target;
-    wire [12:0] status_travel;
-    wire [7:0] status_fault_code;
-    wire calibrated;
-    wire faulted;
-    wire terminal;
-
-    // Environment: gated STEP mirrors internal STEP when limits clear (no hard gate).
-    wire gated_step = step & ~(open_limit | close_limit);
-    reg prev_gated;
-    wire gated_step_rise = gated_step & ~prev_gated;
-
-    reg [1:0] reset_cycles;
-    reg saw_wd_accept;
-    reg [3:0] ticks_since_wd;
-    reg step_was_high_at_wd;
-    reg prev_step;
-
-    door_axis_controller #(
-        .AXIS_ID(0),
-        .MAX_CAL_STEPS(MAX_CAL),
-        .MIN_TRAVEL(2),
-        .ENDPOINT_GUARD_EXTRA(4),
-        .DIR_SETUP_TICKS(1),
-        .PERCENT_MAX(100)
-    ) dut (
-        .clk(clk), .rst_n(dut_rst_n),
-        .open_limit(open_limit), .close_limit(close_limit),
-        .limit_sync_valid(1'b1),
-        .cal_enable(1'b1),
-        .gated_step(gated_step), .gated_step_rise(gated_step_rise),
-        .tick_500us(tick_500us),
-        .step_toggle_pulse(tick_500us),
-        .rate_quantum_in(21'd0),
-        .rate_quantum_valid(1'b0),
-        .request_valid(request_valid),
-        .requested_percent_in(requested_percent_in),
-        .watchdog_stop(watchdog_stop),
-        .planner_req(planner_req),
-        .planner_percent(planner_percent),
-        .planner_travel(planner_travel),
-        .planner_done(planner_done),
-        .planner_done_axis(planner_done_axis),
-        .planner_done_percent(planner_done_percent),
-        .planner_result(planner_result),
-        .step(step), .dir_close(dir_close),
-        .status_state(status_state), .status_flags(status_flags),
-        .status_requested_percent(status_requested_percent),
-        .status_current(status_current), .status_target(status_target),
-        .status_travel(status_travel), .status_fault_code(status_fault_code),
-        .calibrated(calibrated), .faulted(faulted), .terminal(terminal),
-        .axis_moving(), .axis_allow_rise(), .axis_in_calibration(), .axis_endpoint_crawl(),
-        .axis_dda_run(),
-        .profile_level(), .profile_distance(), .profile_done_steps(), .profile_ramp_unit(),
-        .rate_quantum()
-    );
-
-    initial begin
-        reset_cycles = 2'd0;
-        prev_gated = 1'b0;
-        planner_done = 1'b0;
-        planner_done_axis = 2'd0;
-        planner_done_percent = 8'd0;
-        planner_result = 13'd0;
-        saw_wd_accept = 1'b0;
-        ticks_since_wd = 4'd0;
-        step_was_high_at_wd = 1'b0;
-        prev_step = 1'b0;
-    end
-
-    always @(posedge clk) begin
-        assume (rst_n == 1'b0 || rst_n == 1'b1);
-        assume (tick_500us == 1'b0 || tick_500us == 1'b1);
-        assume (request_valid == 1'b0 || request_valid == 1'b1);
-        assume (watchdog_stop == 1'b0 || watchdog_stop == 1'b1);
-        assume (open_limit == 1'b0 || open_limit == 1'b1);
-        assume (close_limit == 1'b0 || close_limit == 1'b1);
-        assume (requested_percent_in <= 8'd100);
-        assume (!(tick_500us && $past(tick_500us)));
-        assume (!(open_limit && close_limit));
-        assume (!(request_valid && watchdog_stop));
-
-        if ($initstate || reset_cycles < 2) begin
-            assume (!dut_rst_n);
-            reset_cycles <= reset_cycles + 1'b1;
-        end else begin
-            assume (dut_rst_n);
-        end
-
-        planner_done <= 1'b0;
-        if (planner_req) begin
-            planner_done <= 1'b1;
-            planner_done_axis <= 2'd0;
-            planner_done_percent <= planner_percent;
-            planner_result <= 13'd2;
-        end
-
-        if (!dut_rst_n) begin
-            prev_gated <= 1'b0;
-            saw_wd_accept <= 1'b0;
-            ticks_since_wd <= 4'd0;
-            step_was_high_at_wd <= 1'b0;
-            prev_step <= 1'b0;
-        end else begin
-            prev_gated <= gated_step;
-            prev_step <= step;
-
-            // Capture first accepted watchdog while calibrated/runtime.
-            if (watchdog_stop && calibrated && !faulted && !request_valid && !saw_wd_accept) begin
-                saw_wd_accept <= 1'b1;
-                step_was_high_at_wd <= step;
-                ticks_since_wd <= 4'd0;
-            end else if (saw_wd_accept && tick_500us && ticks_since_wd != 4'hF) begin
-                ticks_since_wd <= ticks_since_wd + 1'b1;
-            end
-
-            // End window on stop release or new request (latest-wins).
-            if (saw_wd_accept && (!watchdog_stop || request_valid)) begin
-                saw_wd_accept <= 1'b0;
-                ticks_since_wd <= 4'd0;
-                step_was_high_at_wd <= 1'b0;
-            end else if (saw_wd_accept && watchdog_stop && !request_valid) begin
-                // No new STEP rising edge while stop held.
-                assert (!(step && !prev_step));
-                // If STEP was high at accept, it must fall within a few half-ticks.
-                if (step_was_high_at_wd && (ticks_since_wd >= 4'd2))
-                    assert (step == 1'b0);
-                // Eventually idle / wd-stopped after drain window.
-                if (ticks_since_wd >= 4'd3)
-                    assert ((status_state == ST_IDLE) || (status_state == ST_WAIT_REPLAN) || (step == 1'b0));
-            end
-
-            cover (saw_wd_accept && step_was_high_at_wd && (step == 1'b0));
-            cover (saw_wd_accept && !step_was_high_at_wd);
-        end
-    end
-endmodule

+ 0 - 164
tests/formal/door_axis_watchdog_formal.v

@@ -1,164 +0,0 @@
-// DUT-connected watchdog drain BMC on real door_axis_controller.
-// After watchdog_stop is accepted with STEP high, STEP returns low within
-// one half-tick window and no new STEP rise occurs while stop remains.
-// Bounded BMC — not an unbounded mathematical proof.
-module door_axis_watchdog_formal (
-    input wire clk,
-    input wire rst_n,
-    input wire tick_500us,
-    input wire watchdog_stop,
-    input wire request_valid,
-    input wire [7:0] requested_percent_in,
-    input wire open_limit,
-    input wire close_limit
-);
-    wire dut_rst_n = rst_n;
-    wire step;
-    wire dir_close;
-    wire [2:0] status_state;
-    wire [7:0] status_flags;
-    wire [7:0] status_requested_percent;
-    wire [12:0] status_current;
-    wire [12:0] status_target;
-    wire [12:0] status_travel;
-    wire [7:0] status_fault_code;
-    wire calibrated;
-    wire faulted;
-    wire terminal;
-    wire planner_req;
-    wire [7:0] planner_percent;
-    wire [12:0] planner_travel;
-
-    reg [1:0] reset_cycles;
-    reg step_q;
-    reg wd_seen;
-    reg wd_seen_while_high;
-    reg [3:0] ticks_since_wd_high;
-    reg dir_at_wd;
-
-    wire gated_step = step;
-    wire gated_step_rise = step && !step_q;
-
-    door_axis_controller #(
-        .AXIS_ID(0),
-        .MAX_CAL_STEPS(8),
-        .MIN_TRAVEL(2),
-        .ENDPOINT_GUARD_EXTRA(2),
-        .DIR_SETUP_TICKS(1),
-        .PERCENT_MAX(100)
-    ) dut (
-        .clk(clk),
-        .rst_n(dut_rst_n),
-        .open_limit(open_limit),
-        .close_limit(close_limit),
-        .limit_sync_valid(1'b1),
-        .cal_enable(1'b1),
-        .gated_step(gated_step),
-        .gated_step_rise(gated_step_rise),
-        .tick_500us(tick_500us),
-        .step_toggle_pulse(tick_500us),
-        .rate_quantum_in(21'd0),
-        .rate_quantum_valid(1'b0),
-        .request_valid(request_valid),
-        .requested_percent_in(requested_percent_in),
-        .watchdog_stop(watchdog_stop),
-        .planner_req(planner_req),
-        .planner_percent(planner_percent),
-        .planner_travel(planner_travel),
-        // Instant planner reply for mid targets (combinational-style next-cycle).
-        .planner_done(planner_req),
-        .planner_done_axis(2'd0),
-        .planner_done_percent(planner_percent),
-        .planner_result(13'd2),
-        .step(step),
-        .dir_close(dir_close),
-        .status_state(status_state),
-        .status_flags(status_flags),
-        .status_requested_percent(status_requested_percent),
-        .status_current(status_current),
-        .status_target(status_target),
-        .status_travel(status_travel),
-        .status_fault_code(status_fault_code),
-        .calibrated(calibrated),
-        .faulted(faulted),
-        .terminal(terminal),
-        .axis_moving(), .axis_allow_rise(), .axis_in_calibration(), .axis_endpoint_crawl(),
-        .axis_dda_run(),
-        .profile_level(), .profile_distance(), .profile_done_steps(), .profile_ramp_unit(),
-        .rate_quantum()
-    );
-
-    initial begin
-        reset_cycles = 2'd0;
-        step_q = 1'b0;
-        wd_seen = 1'b0;
-        wd_seen_while_high = 1'b0;
-        ticks_since_wd_high = 4'd0;
-        dir_at_wd = 1'b0;
-    end
-
-    always @(posedge clk) begin
-        assume (rst_n == 1'b0 || rst_n == 1'b1);
-        assume (tick_500us == 1'b0 || tick_500us == 1'b1);
-        assume (watchdog_stop == 1'b0 || watchdog_stop == 1'b1);
-        assume (request_valid == 1'b0 || request_valid == 1'b1);
-        assume (requested_percent_in <= 8'd100);
-        assume (open_limit == 1'b0 || open_limit == 1'b1);
-        assume (close_limit == 1'b0 || close_limit == 1'b1);
-        assume (!(open_limit && close_limit));
-        assume (!(tick_500us && $past(tick_500us)));
-
-        if ($initstate || reset_cycles < 2) begin
-            assume (!dut_rst_n);
-            reset_cycles <= reset_cycles + 1'b1;
-        end else begin
-            assume (dut_rst_n);
-        end
-
-        if (!dut_rst_n) begin
-            step_q <= 1'b0;
-            wd_seen <= 1'b0;
-            wd_seen_while_high <= 1'b0;
-            ticks_since_wd_high <= 4'd0;
-        end else begin
-            step_q <= step;
-
-            // Same-cycle request vs watchdog: request/feed wins (env constraint).
-            assume (!(request_valid && watchdog_stop));
-
-            // Only latch when DUT can accept watchdog (post-cal runtime).
-            if (watchdog_stop && calibrated && !faulted && !wd_seen) begin
-                wd_seen <= 1'b1;
-                if (step) begin
-                    wd_seen_while_high <= 1'b1;
-                    ticks_since_wd_high <= 4'd0;
-                    dir_at_wd <= dir_close;
-                end
-            end
-
-            // Property window: only while stop stays held after first accept.
-            // Release or a later request ends the window (latest-wins restart).
-            if (wd_seen && (!watchdog_stop || request_valid)) begin
-                wd_seen <= 1'b0;
-                wd_seen_while_high <= 1'b0;
-                ticks_since_wd_high <= 4'd0;
-            end else if (wd_seen_while_high && watchdog_stop) begin
-                if (tick_500us && ticks_since_wd_high < 4'd15)
-                    ticks_since_wd_high <= ticks_since_wd_high + 4'd1;
-                // DIR stable while draining high pulse.
-                if (step)
-                    assert (dir_close == dir_at_wd);
-                // After at most one half-tick following accept, STEP must be low.
-                if (ticks_since_wd_high >= 4'd1)
-                    assert (step == 1'b0);
-            end
-
-            // Once stop accepted and STEP low, no new rises while stop held.
-            if (wd_seen && watchdog_stop && !request_valid && !step_q)
-                assert (!(step && !step_q));
-
-            cover (wd_seen_while_high && (step == 1'b0) && watchdog_stop);
-            cover (calibrated);
-        end
-    end
-endmodule

+ 0 - 43
tests/formal/door_motion_status_snapshot.sby

@@ -1,43 +0,0 @@
-[tasks]
-bmc
-cover
-
-[options]
-bmc: mode bmc
-bmc: depth 32
-cover: mode cover
-cover: depth 32
-
-[engines]
-smtbmc z3
-
-[script]
-read_verilog -formal frame_tx.v
-read_verilog -formal crc16_serial.v
-read_verilog -formal door_percent_planner.v
-read_verilog -formal door_motion_service_tick.v
-read_verilog -formal door_calibration_sequencer.v
-read_verilog -formal door_profile_quantum_builder.v
-read_verilog -formal door_rate_quantum_builder.v
-read_verilog -formal door_rate_quantum_dispatcher.v
-read_verilog -formal door_shared_dda_scheduler.v
-read_verilog -formal door_axis_controller.v
-read_verilog -formal door_motion_controller.v
-read_verilog -formal door_motion_status_snapshot_formal.v
-proc
-setundef -zero
-prep -top door_motion_status_snapshot_formal
-
-[files]
-../../src/common/frame_tx.v
-../../src/common/crc16_serial.v
-../../src/modules/door_percent_planner.v
-../../src/modules/door_motion_service_tick.v
-../../src/modules/door_calibration_sequencer.v
-../../src/modules/door_profile_quantum_builder.v
-../../src/modules/door_rate_quantum_builder.v
-../../src/modules/door_rate_quantum_dispatcher.v
-../../src/modules/door_shared_dda_scheduler.v
-../../src/modules/door_axis_controller.v
-../../src/modules/door_motion_controller.v
-door_motion_status_snapshot_formal.v

+ 0 - 137
tests/formal/door_motion_status_snapshot_formal.v

@@ -1,137 +0,0 @@
-// DUT-connected: combinational status_rd_data OOB + frame_tx payload binding.
-// Bounded BMC. Hierarchical snap[] is not a reliable Yosys formal probe.
-module door_motion_status_snapshot_formal (
-    input wire clk,
-    input wire rst_n,
-    input wire status_capture,
-    input wire [7:0] status_rd_addr,
-    input wire tx_start,
-    input wire byte_ready
-);
-    wire dut_rst_n = rst_n;
-    wire [2:0] step;
-    wire [2:0] dir_close;
-    wire startup_complete;
-    wire [2:0] calibrated_mask;
-    wire [2:0] fault_mask;
-    wire [7:0] status_rd_data;
-
-    wire tx_busy;
-    wire byte_valid;
-    wire [7:0] byte_data;
-    wire [7:0] payload_addr;
-    wire tx_done;
-
-    reg [1:0] reset_cycles;
-    reg settled;
-    reg [7:0] held_data;
-    reg held_valid;
-    reg [7:0] held_addr;
-
-    door_motion_controller #(
-        .MAX_CAL_STEPS(4),
-        .MIN_TRAVEL(2),
-        .ENDPOINT_GUARD_EXTRA(2),
-        .DIR_SETUP_TICKS(1),
-        .PERCENT_MAX(100),
-        .STATUS_PAYLOAD_LENGTH(31)
-    ) motion (
-        .clk(clk), .rst_n(dut_rst_n),
-        .tick_500us(1'b0),
-        .limit_sync_valid(1'b1),
-        .open_limit(3'b000),
-        .close_limit(3'b111),
-        .gated_step(3'b000),
-        .gated_step_rise(3'b000),
-        .motor_request_valid(1'b0),
-        .percent_x(8'd0), .percent_y(8'd0), .percent_z(8'd0),
-        .watchdog_stop(1'b0),
-        .watchdog_tripped(1'b0),
-        .step(step), .dir_close(dir_close),
-        .startup_complete(startup_complete),
-        .calibrated_mask(calibrated_mask),
-        .fault_mask(fault_mask),
-        .status_capture(status_capture),
-        .status_rd_addr(status_rd_addr),
-        .status_rd_data(status_rd_data)
-    );
-
-    frame_tx tx (
-        .clk(clk), .rst_n(dut_rst_n),
-        .start(tx_start),
-        .frame_type(8'h83),
-        .payload_length(8'd31),
-        .busy(tx_busy),
-        .byte_valid(byte_valid),
-        .byte_data(byte_data),
-        .byte_ready(byte_ready),
-        .payload_addr(payload_addr),
-        .payload_data(status_rd_data),
-        .done(tx_done)
-    );
-
-    initial begin
-        reset_cycles = 2'd0;
-        settled = 1'b0;
-        held_data = 8'd0;
-        held_valid = 1'b0;
-        held_addr = 8'd0;
-    end
-
-    always @(posedge clk) begin
-        assume (rst_n == 1'b0 || rst_n == 1'b1);
-        assume (status_capture == 1'b0 || status_capture == 1'b1);
-        assume (tx_start == 1'b0 || tx_start == 1'b1);
-        assume (byte_ready == 1'b0 || byte_ready == 1'b1);
-        // Allow OOB addr=31 for cover/assert; TX path still binds to payload_addr.
-        assume (status_rd_addr <= 8'd31);
-        assume (!(tx_busy && tx_start));
-        assume (!(status_capture && tx_start));
-        // Only force addr==payload while TX is actively streaming payload bytes.
-        if (tx_busy && (tx.state == 4'd7))
-            assume (status_rd_addr == payload_addr);
-
-        if ($initstate || reset_cycles < 2) begin
-            assume (!dut_rst_n);
-            reset_cycles <= reset_cycles + 1'b1;
-        end else begin
-            assume (dut_rst_n);
-        end
-
-        if (!dut_rst_n) begin
-            settled <= 1'b0;
-            held_valid <= 1'b0;
-        end else begin
-            if (status_capture) begin
-                settled <= 1'b0;
-                held_valid <= 1'b0;
-            end else if (!settled) begin
-                settled <= 1'b1;
-            end
-
-            // OOB → 0
-            if (status_rd_addr >= 8'd31)
-                assert (status_rd_data == 8'd0);
-
-            // Hold one in-range sample; same-addr re-read must match (combo, not reg).
-            if (settled && !held_valid && (status_rd_addr < 8'd31) && !status_capture) begin
-                held_data <= status_rd_data;
-                held_addr <= status_rd_addr;
-                held_valid <= 1'b1;
-            end
-            if (held_valid && settled && !status_capture && (status_rd_addr == held_addr))
-                assert (status_rd_data == held_data);
-
-            // Payload phase (ST_PAYLOAD=7) byte_data follows status_rd_data.
-            if (tx_busy && byte_valid && settled && (tx.state == 4'd7))
-                assert (byte_data == status_rd_data);
-
-            cover (settled && (status_rd_addr == 8'd0));
-            cover (settled && (status_rd_addr == 8'd30));
-            // OOB probe: require idle TX so payload_addr binding cannot exclude addr=31.
-            cover (dut_rst_n && !tx_busy && (status_rd_addr == 8'd31));
-            // TX payload-phase cover is depth-expensive; BMC asserts byte_data match.
-            cover (tx_busy);
-        end
-    end
-endmodule

+ 0 - 25
tests/formal/door_mse_serial_dda.sby

@@ -1,25 +0,0 @@
-[tasks]
-bmc
-cover
-
-[options]
-bmc: mode bmc
-bmc: depth 30
-cover: mode cover
-cover: depth 30
-
-[engines]
-smtbmc z3
-
-[script]
-read_verilog -formal door_shared_dda_scheduler.v
-read_verilog -formal door_calibration_sequencer.v
-read_verilog -formal -DFORMAL door_mse_serial_dda_formal.v
-proc
-setundef -zero
-prep -top door_mse_serial_dda_formal
-
-[files]
-../../src/modules/door_shared_dda_scheduler.v
-../../src/modules/door_calibration_sequencer.v
-door_mse_serial_dda_formal.v

+ 0 - 92
tests/formal/door_mse_serial_dda_formal.v

@@ -1,92 +0,0 @@
-`timescale 1ns/1ps
-
-// Bounded BMC/cover for MSE serial cal exclusion + DDA service completion.
-// Honest bounded check — not an unbounded proof.
-module door_mse_serial_dda_formal (
-    input wire clk,
-    input wire rst_n,
-    input wire service_ce,
-    input wire [2:0] active,
-    input wire [2:0] allow_toggle,
-    input wire [2:0] cal_mode,
-    input wire [20:0] rate0,
-    input wire [20:0] rate1,
-    input wire [20:0] rate2,
-    input wire [24:0] phase_threshold,
-    input wire limit_sync_valid,
-    input wire term_x,
-    input wire term_y,
-    input wire term_z,
-    input wire cal_ok_x,
-    input wire cal_ok_y,
-    input wire cal_ok_z,
-    input wire profile_busy,
-    input wire profile_done
-);
-    wire [2:0] toggle_pulse;
-    wire dda_busy;
-    wire service_overrun;
-    wire [2:0] cal_enable;
-    wire profile_start;
-    wire profile_ready;
-    wire all_axes_terminal;
-
-    door_shared_dda_scheduler #(.CAL_PHASE_THRESHOLD(64)) u_dda (
-        .clk(clk), .rst_n(rst_n),
-        .service_ce(service_ce),
-        .active(active),
-        .allow_toggle(allow_toggle),
-        .cal_mode(cal_mode),
-        .rate0(rate0), .rate1(rate1), .rate2(rate2),
-        .phase_threshold(phase_threshold),
-        .toggle_pulse(toggle_pulse),
-        .busy(dda_busy),
-        .service_overrun(service_overrun)
-    );
-
-    door_calibration_sequencer u_seq (
-        .clk(clk), .rst_n(rst_n),
-        .limit_sync_valid(limit_sync_valid),
-        .term_x(term_x), .term_y(term_y), .term_z(term_z),
-        .cal_ok_x(cal_ok_x), .cal_ok_y(cal_ok_y), .cal_ok_z(cal_ok_z),
-        .profile_busy(profile_busy), .profile_done(profile_done),
-        .cal_enable(cal_enable),
-        .profile_start(profile_start),
-        .profile_ready(profile_ready),
-        .all_axes_terminal(all_axes_terminal)
-    );
-
-    reg [1:0] reset_cycles;
-    initial reset_cycles = 2'd0;
-
-    always @(posedge clk) begin
-        assume (rst_n == 1'b0 || rst_n == 1'b1);
-        assume (service_ce == 1'b0 || service_ce == 1'b1);
-        assume (limit_sync_valid == 1'b0 || limit_sync_valid == 1'b1);
-        assume (rate0 <= 21'd256);
-        assume (rate1 <= 21'd256);
-        assume (rate2 <= 21'd256);
-        assume (phase_threshold >= 25'd8);
-        assume (phase_threshold <= 25'd1024);
-        // Contract: next service must not arrive while previous incomplete.
-        assume (!(service_ce && dda_busy));
-
-        if ($initstate || reset_cycles < 2) begin
-            assume (!rst_n);
-            reset_cycles <= reset_cycles + 1'b1;
-        end else begin
-            assume (rst_n);
-        end
-
-        if (rst_n) begin
-            assert ((cal_enable[0] + cal_enable[1] + cal_enable[2]) <= 1);
-            assert (!service_overrun);
-            cover (cal_enable == 3'b001);
-            cover (cal_enable == 3'b010);
-            cover (cal_enable == 3'b100);
-            cover (profile_ready);
-            cover (toggle_pulse[0]);
-            cover (term_x && cal_enable[1]);
-        end
-    end
-endmodule

+ 0 - 23
tests/formal/door_percent_planner.sby

@@ -1,23 +0,0 @@
-[tasks]
-bmc
-cover
-
-[options]
-bmc: mode bmc
-bmc: depth 64
-cover: mode cover
-cover: depth 64
-
-[engines]
-smtbmc z3
-
-[script]
-read_verilog -formal door_percent_planner.v
-read_verilog -formal door_percent_planner_formal.v
-proc
-setundef -zero
-prep -top door_percent_planner_formal
-
-[files]
-../../src/modules/door_percent_planner.v
-door_percent_planner_formal.v

+ 0 - 87
tests/formal/door_percent_planner_formal.v

@@ -1,87 +0,0 @@
-// DUT-connected planner BMC: result must match half-up reference.
-// Bounded: travel 2..8, percent 1..99. Not an unbounded proof.
-module door_percent_planner_formal (
-    input wire clk,
-    input wire rst_n,
-    input wire start,
-    input wire [1:0] axis_id,
-    input wire [7:0] percent,
-    input wire [12:0] travel
-);
-    function automatic [12:0] expected_half_up;
-        input [12:0] travel_i;
-        input [7:0] percent_i;
-        reg [20:0] raw;
-        begin
-            raw = (travel_i * percent_i) + 21'd50;
-            raw = raw / 21'd100;
-            if (raw < 21'd1)
-                expected_half_up = 13'd1;
-            else if (raw > (travel_i - 13'd1))
-                expected_half_up = travel_i - 13'd1;
-            else
-                expected_half_up = raw[12:0];
-        end
-    endfunction
-
-    wire busy;
-    wire done;
-    wire [12:0] result;
-    wire [1:0] done_axis_id;
-    wire [7:0] done_percent;
-    reg [1:0] reset_cycles;
-    reg [12:0] latched_travel;
-    reg [7:0] latched_percent;
-    reg [1:0] latched_axis;
-    reg pending;
-
-    door_percent_planner dut (
-        .clk(clk), .rst_n(rst_n),
-        .start(start), .axis_id(axis_id), .percent(percent), .travel(travel),
-        .busy(busy), .done(done), .result(result),
-        .done_axis_id(done_axis_id), .done_percent(done_percent)
-    );
-
-    initial begin
-        reset_cycles = 2'd0;
-        latched_travel = 13'd0;
-        latched_percent = 8'd0;
-        latched_axis = 2'd0;
-        pending = 1'b0;
-    end
-
-    always @(posedge clk) begin
-        assume (rst_n == 1'b0 || rst_n == 1'b1);
-        assume (start == 1'b0 || start == 1'b1);
-        assume (travel >= 13'd2 && travel <= 13'd8);
-        assume (percent >= 8'd1 && percent <= 8'd99);
-        assume (axis_id <= 2'd2);
-        assume (!(start && busy));
-
-        if (!rst_n) begin
-            reset_cycles <= 2'd0;
-            pending <= 1'b0;
-        end else if (reset_cycles < 2'd3) begin
-            reset_cycles <= reset_cycles + 1'b1;
-        end else begin
-            // Avoid start/done same-cycle race vs NBA latches.
-            assume (!(start && done));
-            if (start && !busy) begin
-                latched_travel <= travel;
-                latched_percent <= percent;
-                latched_axis <= axis_id;
-                pending <= 1'b1;
-            end
-            if (done && pending) begin
-                assert (result == expected_half_up(latched_travel, latched_percent));
-                assert (done_axis_id == latched_axis);
-                assert (done_percent == latched_percent);
-                assert (result >= 13'd1);
-                assert (result <= (latched_travel - 13'd1));
-                pending <= 1'b0;
-            end
-            cover (done && pending && (result == expected_half_up(latched_travel, latched_percent)));
-            cover (busy);
-        end
-    end
-endmodule

+ 0 - 24
tests/formal/door_rate_quantum_builder.sby

@@ -1,24 +0,0 @@
-[tasks]
-bmc
-cover
-
-[options]
-bmc: mode bmc
-bmc: depth 40
-cover: mode cover
-cover: depth 40
-timeout 120
-
-[engines]
-smtbmc boolector
-
-[script]
-read_verilog -formal door_rate_quantum_builder.v
-read_verilog -formal -DFORMAL door_rate_quantum_builder_formal.v
-proc
-setundef -zero
-prep -top door_rate_quantum_builder_formal
-
-[files]
-../../src/modules/door_rate_quantum_builder.v
-door_rate_quantum_builder_formal.v

+ 0 - 92
tests/formal/door_rate_quantum_builder_formal.v

@@ -1,92 +0,0 @@
-`timescale 1ns/1ps
-
-// DUT-connected rate builder BMC (bounded scales). Full domain closed by Icarus 79984.
-module door_rate_quantum_builder_formal (
-    input  wire        clk,
-    input  wire        rst_n,
-    input  wire        start,
-    input  wire [1:0]  axis_id_in,
-    input  wire [12:0] travel_in,
-    input  wire [8:0]  scale_in
-);
-    wire        busy;
-    wire        done;
-    wire [1:0]  axis_id_out;
-    wire [12:0] travel_out;
-    wire [8:0]  scale_out;
-    wire [20:0] product;
-
-    reg [1:0] reset_cycles;
-    reg pending;
-    reg [1:0]  latched_axis;
-    reg [12:0] latched_travel;
-    reg [8:0]  latched_scale;
-    reg [20:0] latched_expect;
-
-    door_rate_quantum_builder dut (
-        .clk(clk), .rst_n(rst_n),
-        .start(start),
-        .axis_id_in(axis_id_in),
-        .travel_in(travel_in),
-        .scale_in(scale_in),
-        .busy(busy),
-        .done(done),
-        .axis_id_out(axis_id_out),
-        .travel_out(travel_out),
-        .scale_out(scale_out),
-        .product(product)
-    );
-
-`ifdef FORMAL
-    initial begin
-        reset_cycles = 2'd0;
-        pending = 1'b0;
-        latched_axis = 2'd0;
-        latched_travel = 13'd0;
-        latched_scale = 9'd0;
-        latched_expect = 21'd0;
-    end
-
-    always @(posedge clk) begin
-        assume (rst_n == 1'b0 || rst_n == 1'b1);
-        assume (start == 1'b0 || start == 1'b1);
-        assume (travel_in >= 13'd2 && travel_in <= 13'd5000);
-        assume (scale_in == 9'd64 || scale_in == 9'd128 || scale_in == 9'd256 ||
-                scale_in == 9'd66 || scale_in == 9'd170);
-        assume (axis_id_in <= 2'd2);
-        assume (!(start && busy));
-
-        if (!rst_n) begin
-            reset_cycles <= 2'd0;
-            pending <= 1'b0;
-        end else if (reset_cycles < 2'd3) begin
-            reset_cycles <= reset_cycles + 1'b1;
-            assume (start == 1'b0);
-        end else begin
-            if (start && !busy) begin
-                pending <= 1'b1;
-                latched_axis <= axis_id_in;
-                latched_travel <= travel_in;
-                latched_scale <= scale_in;
-                latched_expect <= travel_in * scale_in;
-            end
-            if (pending && done) begin
-                assert (axis_id_out == latched_axis);
-                assert (travel_out == latched_travel);
-                assert (scale_out == latched_scale);
-                assert (product == latched_expect);
-                assert (product <= 21'd1280000);
-                assert (product != 21'd0);
-                pending <= 1'b0;
-            end
-        end
-    end
-
-    always @(posedge clk) begin
-        cover (reset_cycles >= 2'd3 && done && (latched_travel == 13'd5000) &&
-               (latched_scale == 9'd256) && (product == 21'd1280000));
-        cover (reset_cycles >= 2'd3 && done && (latched_travel == 13'd4096) &&
-               (latched_scale == 9'd256) && (product == 21'd1048576));
-    end
-`endif
-endmodule

+ 0 - 26
tests/formal/door_rate_quantum_dispatcher.sby

@@ -1,26 +0,0 @@
-[tasks]
-bmc
-cover
-
-[options]
-bmc: mode bmc
-bmc: depth 60
-cover: mode cover
-cover: depth 80
-timeout 180
-
-[engines]
-smtbmc boolector
-
-[script]
-read_verilog -formal door_rate_quantum_builder.v
-read_verilog -formal door_rate_quantum_dispatcher.v
-read_verilog -formal -DFORMAL door_rate_quantum_dispatcher_formal.v
-proc
-setundef -zero
-prep -top door_rate_quantum_dispatcher_formal
-
-[files]
-../../src/modules/door_rate_quantum_builder.v
-../../src/modules/door_rate_quantum_dispatcher.v
-door_rate_quantum_dispatcher_formal.v

+ 0 - 207
tests/formal/door_rate_quantum_dispatcher_formal.v

@@ -1,207 +0,0 @@
-`timescale 1ns/1ps
-
-// Production door_rate_quantum_dispatcher BMC/cover (Round-5, bounded).
-// Atomic launch record, X→Y→Z done order, product, one-hot valid,
-// in-flight input immunity, cal travel=1 on selected axis.
-module door_rate_quantum_dispatcher_formal (
-    input  wire        clk,
-    input  wire        rst_n,
-    input  wire [12:0] travel_x,
-    input  wire [12:0] travel_y,
-    input  wire [12:0] travel_z,
-    input  wire [8:0]  scale_x,
-    input  wire [8:0]  scale_y,
-    input  wire [8:0]  scale_z,
-    input  wire        cal_x,
-    input  wire        cal_y,
-    input  wire        cal_z
-);
-    wire        busy;
-    wire        done;
-    wire        rate_valid_x;
-    wire        rate_valid_y;
-    wire        rate_valid_z;
-    wire [1:0]  axis_id_out;
-    wire [12:0] travel_out;
-    wire [8:0]  scale_out;
-    wire [20:0] product;
-
-    reg [2:0]  reset_cycles;
-    reg        pending;
-    reg [1:0]  latched_axis;
-    reg [12:0] latched_travel;
-    reg [8:0]  latched_scale;
-    reg [7:0]  done_count;  // cover: >=6 completions
-    reg        saw_cal;
-    reg        saw_busy_input_change;
-    reg        saw_x_done, saw_y_done, saw_z_done;
-    reg [12:0] travel_x_d, travel_y_d, travel_z_d;
-    reg [8:0]  scale_x_d, scale_y_d, scale_z_d;
-    reg [1:0]  expect_seq;
-    reg        seq_armed;
-    reg        busy_d;
-
-    door_rate_quantum_dispatcher dut (
-        .clk(clk), .rst_n(rst_n),
-        .travel_x(travel_x), .travel_y(travel_y), .travel_z(travel_z),
-        .scale_x(scale_x), .scale_y(scale_y), .scale_z(scale_z),
-        .cal_x(cal_x), .cal_y(cal_y), .cal_z(cal_z),
-        .busy(busy), .done(done),
-        .rate_valid_x(rate_valid_x),
-        .rate_valid_y(rate_valid_y),
-        .rate_valid_z(rate_valid_z),
-        .axis_id_out(axis_id_out),
-        .travel_out(travel_out),
-        .scale_out(scale_out),
-        .product(product)
-    );
-
-`ifdef FORMAL
-    initial begin
-        reset_cycles = 3'd0;
-        pending = 1'b0;
-        latched_axis = 2'd0;
-        latched_travel = 13'd0;
-        latched_scale = 9'd0;
-        done_count = 8'd0;
-        saw_cal = 1'b0;
-        saw_busy_input_change = 1'b0;
-        saw_x_done = 1'b0;
-        saw_y_done = 1'b0;
-        saw_z_done = 1'b0;
-        travel_x_d = 13'd0;
-        travel_y_d = 13'd0;
-        travel_z_d = 13'd0;
-        scale_x_d = 9'd0;
-        scale_y_d = 9'd0;
-        scale_z_d = 9'd0;
-        expect_seq = 2'd0;
-        seq_armed = 1'b0;
-        busy_d = 1'b0;
-    end
-
-    always @(posedge clk) begin
-        assume (rst_n == 1'b0 || rst_n == 1'b1);
-        assume (cal_x == 1'b0 || cal_x == 1'b1);
-        assume (cal_y == 1'b0 || cal_y == 1'b1);
-        assume (cal_z == 1'b0 || cal_z == 1'b1);
-        assume (travel_x >= 13'd2 && travel_x <= 13'd5000);
-        assume (travel_y >= 13'd2 && travel_y <= 13'd5000);
-        assume (travel_z >= 13'd2 && travel_z <= 13'd5000);
-        assume (scale_x == 9'd64 || scale_x == 9'd128 || scale_x == 9'd256 ||
-                scale_x == 9'd66 || scale_x == 9'd170);
-        assume (scale_y == 9'd64 || scale_y == 9'd128 || scale_y == 9'd256 ||
-                scale_y == 9'd66 || scale_y == 9'd170);
-        assume (scale_z == 9'd64 || scale_z == 9'd128 || scale_z == 9'd256 ||
-                scale_z == 9'd66 || scale_z == 9'd170);
-
-        if (reset_cycles < 3'd2)
-            assume (rst_n == 1'b0);
-        else
-            assume (rst_n == 1'b1);
-
-        if (!rst_n) begin
-            reset_cycles <= (reset_cycles < 3'd7) ? (reset_cycles + 1'b1) : reset_cycles;
-            pending <= 1'b0;
-            done_count <= 8'd0;
-            saw_cal <= 1'b0;
-            saw_busy_input_change <= 1'b0;
-            saw_x_done <= 1'b0;
-            saw_y_done <= 1'b0;
-            saw_z_done <= 1'b0;
-            expect_seq <= 2'd0;
-            seq_armed <= 1'b0;
-            busy_d <= 1'b0;
-        end else begin
-            if (reset_cycles < 3'd7)
-                reset_cycles <= reset_cycles + 1'b1;
-
-            // Structural: builder .axis_id_in is wired to rate_launch_axis in RTL
-            // (never rate_next_axis). Prove launch record drives done payload.
-            if (busy && (
-                travel_x != travel_x_d || travel_y != travel_y_d || travel_z != travel_z_d ||
-                scale_x != scale_x_d || scale_y != scale_y_d || scale_z != scale_z_d
-            ))
-                saw_busy_input_change <= 1'b1;
-
-            // Capture on busy rising — launch record already stable.
-            if (busy && !busy_d) begin
-                latched_axis <= dut.rate_launch_axis;
-                latched_travel <= dut.rate_launch_travel;
-                latched_scale <= dut.rate_launch_scale;
-                pending <= 1'b1;
-                if (dut.rate_launch_travel == 13'd1 && (
-                    (dut.rate_launch_axis == 2'd0 && cal_x) ||
-                    (dut.rate_launch_axis == 2'd1 && cal_y) ||
-                    (dut.rate_launch_axis == 2'd2 && cal_z)
-                ))
-                    saw_cal <= 1'b1;
-            end
-
-            // While builder is busy and not yet done, the accepted launch
-            // record must not change (atomic in-flight transaction).
-            if (busy && !done) begin
-                if (!pending) begin
-                    // first observed busy cycle — seed reference
-                end else begin
-                    assert (dut.rate_launch_axis == latched_axis);
-                    assert (dut.rate_launch_travel == latched_travel);
-                    assert (dut.rate_launch_scale == latched_scale);
-                end
-            end
-
-            if (done) begin
-                assert (axis_id_out <= 2'd2);
-                assert (product == (travel_out * scale_out));
-                assert (product <= 21'd1280000);
-                // In-flight input changes must not corrupt this completion.
-                if (saw_busy_input_change) begin
-                    assert (product == (travel_out * scale_out));
-                end
-                if (!seq_armed) begin
-                    assert (axis_id_out == 2'd0);
-                    seq_armed <= 1'b1;
-                    expect_seq <= 2'd1;
-                end else begin
-                    assert (axis_id_out == expect_seq);
-                    expect_seq <= (expect_seq == 2'd2) ? 2'd0 : (expect_seq + 1'b1);
-                end
-                pending <= 1'b0;
-                done_count <= done_count + 1'b1;
-                if (axis_id_out == 2'd0) saw_x_done <= 1'b1;
-                if (axis_id_out == 2'd1) saw_y_done <= 1'b1;
-                if (axis_id_out == 2'd2) saw_z_done <= 1'b1;
-            end
-
-            if (rate_valid_x || rate_valid_y || rate_valid_z)
-                assert ((rate_valid_x + rate_valid_y + rate_valid_z) == 2'd1);
-            assert (!rate_valid_x || !rate_valid_y);
-            assert (!rate_valid_x || !rate_valid_z);
-            assert (!rate_valid_y || !rate_valid_z);
-
-            busy_d <= busy;
-        end
-
-        travel_x_d <= travel_x;
-        travel_y_d <= travel_y;
-        travel_z_d <= travel_z;
-        scale_x_d <= scale_x;
-        scale_y_d <= scale_y;
-        scale_z_d <= scale_z;
-    end
-
-    always @(posedge clk) begin
-        cover (done_count >= 8'd6);
-        cover (done && (axis_id_out == 2'd0));
-        cover (done && (axis_id_out == 2'd1));
-        cover (done && (axis_id_out == 2'd2));
-        cover (saw_x_done && saw_y_done && saw_z_done);
-        cover (saw_cal);
-        cover (saw_busy_input_change && done);
-        cover (done && (scale_out == 9'd64));
-        cover (done && (scale_out == 9'd256));
-        cover (done && ((scale_out == 9'd66) || (scale_out == 9'd128) ||
-                        (scale_out == 9'd170)));
-    end
-`endif
-endmodule

+ 0 - 185
tools/build_mrdimm_diag_bitstreams.py

@@ -1,185 +0,0 @@
-#!/usr/bin/env python3
-"""Build minimal safe UART diagnostic bitstreams (921600 and 115200) for MRDIMM V1.2.
-
-Saves bitstreams and metadata into _维护/诊断固件/MRDIMM-V1.2/<run_id>/
-"""
-from __future__ import annotations
-
-import datetime
-import hashlib
-import json
-import os
-import shutil
-import subprocess
-import sys
-from pathlib import Path
-
-ROOT = Path(__file__).resolve().parents[1]
-TD_EXE = ROOT / "tools/td2026"
-
-
-def sha256_file(p: Path) -> str:
-    return hashlib.sha256(p.read_bytes()).hexdigest()
-
-
-def run_stage(name: str, cmd: list[str], cwd: Path, env: dict) -> dict:
-    log_file = cwd / f"{name}.log"
-    with log_file.open("w") as f:
-        proc = subprocess.run(cmd, cwd=cwd, stdout=f, stderr=subprocess.STDOUT, env=env)
-    return {
-        "stage": name,
-        "exit_code": proc.returncode,
-        "log": str(log_file),
-    }
-
-
-def build_profile(baud: int, top_module: str, top_file: str, out_dir: Path) -> dict:
-    run_dir = out_dir / f"td_diag_{baud}"
-    run_dir.mkdir(parents=True, exist_ok=True)
-    syn_dir = run_dir / "syn"
-    phy_dir = run_dir / "phy"
-    bit_dir = run_dir / "bitgen"
-    syn_dir.mkdir(exist_ok=True)
-    phy_dir.mkdir(exist_ok=True)
-    bit_dir.mkdir(exist_ok=True)
-
-    adc_path = ROOT / "constraints/prod2u_mrdimm.adc"
-    sdc_path = ROOT / "constraints/prod2u_mrdimm.sdc"
-
-    sources = [
-        ROOT / "src/common/uart_rx_byte.v",
-        ROOT / "src/common/uart_tx_byte.v",
-        ROOT / "src/diag/prod2u_mrdimm_uart_diag_top.v",
-        ROOT / top_file,
-    ]
-
-    syn_tcl = syn_dir / "syn.tcl"
-    analyze_cmds = "\n".join([f"analyze -file {s}" for s in sources])
-    syn_tcl.write_text(f"""
-import_device ef2_4.db -package EF2L45BG256B
-set_param rtl directive:async_reg on
-set_param place async_reg on
-
-{analyze_cmds}
-
-elaborate -top {{{top_module}}}
-read_adc {{{adc_path}}}
-optimize_rtl
-read_sdc {{{sdc_path}}}
-report_area -io_info -file diag_{baud}_rtl.area
-set_param gate opt_area high
-set_param gate pack_effort high
-optimize_gate diag_{baud}_gate.area
-report_area -io_info -file diag_{baud}_gate.area
-export_db diag_{baud}_gate.db
-puts {{DIAG_SYN_DONE=1}}
-exit
-""")
-
-    phy_tcl = phy_dir / "phy.tcl"
-    phy_tcl.write_text(f"""
-import_device ef2_4.db -package EF2L45BG256B
-set synthesized_db ../syn/diag_{baud}_gate.db
-if {{![file isfile $synthesized_db]}} {{
-    error "DIAG_PHY_BLOCKED|missing $synthesized_db"
-}}
-import_db $synthesized_db
-set_param place seed 2
-place
-update_timing
-report_area -io_info -file diag_{baud}_place.area
-report_timing_summary -file diag_{baud}_place.timing
-export_db diag_{baud}_place.db
-
-route
-update_timing
-report_area -io_info -file diag_{baud}_phy.area
-report_timing_summary -file diag_{baud}_pr.timing
-export_db diag_{baud}_pr.db
-puts "DIAG_PHY_DONE=1"
-exit
-""")
-
-    bit_tcl = bit_dir / "bitgen.tcl"
-    bit_name = f"mrdimm_diag_{baud}.bit"
-    bit_tcl.write_text(f"""
-import_device ef2_4.db -package EF2L45BG256B
-set routed_db ../phy/diag_{baud}_pr.db
-if {{![file isfile $routed_db]}} {{
-    error "DIAG_BITGEN_BLOCKED|missing $routed_db"
-}}
-import_db $routed_db
-bitgen -bit {bit_name}
-puts "DIAG_BITGEN_DONE=1"
-exit
-""")
-
-    env = os.environ.copy()
-    env["PROD2U_SOURCE_ROOT"] = str(ROOT)
-
-    print(f"Building diagnostic profile {baud} bps (top={top_module})...")
-    res_syn = run_stage("syn", [str(TD_EXE), "syn.tcl"], syn_dir, env)
-    assert res_syn["exit_code"] == 0, f"Synthesis failed for {baud}, see {res_syn['log']}"
-
-    res_phy = run_stage("phy", [str(TD_EXE), "phy.tcl"], phy_dir, env)
-    assert res_phy["exit_code"] == 0, f"Place&Route failed for {baud}, see {res_phy['log']}"
-
-    res_bit = run_stage("bitgen", [str(TD_EXE), "bitgen.tcl"], bit_dir, env)
-    assert res_bit["exit_code"] == 0, f"Bitgen failed for {baud}, see {res_bit['log']}"
-
-    out_bit = bit_dir / bit_name
-    assert out_bit.is_file(), f"Output bitstream not generated: {out_bit}"
-
-    final_bit = out_dir / bit_name
-    shutil.copy2(out_bit, final_bit)
-    sha = sha256_file(final_bit)
-    print(f"  -> {bit_name} built successfully! SHA256: {sha}")
-
-    return {
-        "baud": baud,
-        "top_module": top_module,
-        "bitstream": str(final_bit),
-        "bitstream_sha256": sha,
-        "status": "BUILT",
-    }
-
-
-def main():
-    utc_str = datetime.datetime.now(datetime.timezone.utc).strftime("%Y%m%dT%H%M%SZ")
-    run_id = f"diag-{utc_str}"
-    out_dir = ROOT / f"_维护/诊断固件/MRDIMM-V1.2/{run_id}"
-    out_dir.mkdir(parents=True, exist_ok=True)
-
-    print(f"=== Building MRDIMM V1.2 Diagnostic Bitstreams into {out_dir} ===")
-
-    p921600 = build_profile(
-        baud=921600,
-        top_module="prod2u_mrdimm_uart_diag_921600_top",
-        top_file="src/diag/prod2u_mrdimm_uart_diag_921600_top.v",
-        out_dir=out_dir
-    )
-
-    p115200 = build_profile(
-        baud=115200,
-        top_module="prod2u_mrdimm_uart_diag_115200_top",
-        top_file="src/diag/prod2u_mrdimm_uart_diag_115200_top.v",
-        out_dir=out_dir
-    )
-
-    meta = {
-        "run_id": run_id,
-        "generated_at": datetime.datetime.now(datetime.timezone.utc).isoformat(),
-        "profiles": {
-            "921600": p921600,
-            "115200": p115200,
-        },
-        "description": "Minimal safe UART diagnostic firmware for MRDIMM V1.2. PTC outputs safe 0, motor disabled, fan safe. Periodic 55/AA/00/FF pattern + ASCII info + frame.",
-    }
-
-    meta_file = out_dir / "diag_metadata.json"
-    meta_file.write_text(json.dumps(meta, indent=2) + "\n")
-    print(f"\nDiagnostic build complete. Metadata saved to {meta_file}")
-
-
-if __name__ == "__main__":
-    main()