Просмотр исходного кода

fix-6400-single-product-30s-control

root 3 месяцев назад
Родитель
Сommit
a59dff592a
56 измененных файлов с 1105 добавлено и 1667 удалено
  1. 72 0
      ACTIVE_FIX_LOCK.yaml
  2. 4 3
      AGENTS.md
  3. 24 14
      QUICK_PROGRESS.md
  4. 2 1
      contracts/fan-control-parameters.yaml
  5. 9 18
      docs/audits/01-requirements-product-boundary.md
  6. 9 25
      docs/audits/02-board-electrical-evidence.md
  7. 8 19
      docs/audits/03-rtl-reuse-resource-structure.md
  8. 10 20
      docs/audits/04-protocol-state-safety.md
  9. 9 20
      docs/audits/05-multirepo-environment-replay.md
  10. 1 1
      docs/generated/6400-channel-map.md
  11. 1 1
      generated/6400/channel-map.json
  12. 1 1
      generated/6400/contract-sha256.txt
  13. 1 1
      generated/6400/controller-coefficients.json
  14. 3 2
      generated/6400/fan-control-parameters.json
  15. 1 1
      generated/6400/fixed-point.json
  16. 1 1
      generated/6400/golden-vectors.json
  17. 5 4
      generated/6400/host-contract.json
  18. 1 1
      generated/6400/prod2u_6400_v1_params.vh
  19. 1 1
      generated/6400/snapshot-layout.json
  20. 31 0
      products/6400-front-rear/analysis-replay-closure.json
  21. 1 1
      src/common/AGENTS.md
  22. 13 11
      src/common/frame_rx.v
  23. 160 98
      src/control/thermal_control_core.v
  24. 2 2
      src/generated/6400/td-source-manifest.json
  25. 11 24
      src/top/prod2u_6400_v1_top.v
  26. 15 61
      src/transport/thermal_host_command.v
  27. 0 1
      td/syn/prod2u_6400_front_back.tcl
  28. 0 4
      tests/cocotb/prod2u_6400_v1_cocotb_top.v
  29. 7 2
      tests/cocotb/run_6400_pi_differential.py
  30. 6 8
      tests/cocotb/run_6400_v1_integration.py
  31. 112 269
      tests/cocotb/test_6400_pi_differential.py
  32. 67 300
      tests/cocotb/test_6400_v1_control_integration.py
  33. 17 0
      tests/cocotb/test_6400_v1_host_protocol_integration.py
  34. 0 248
      tests/cocotb/test_6400_v1_identification_integration.py
  35. 2 1
      tests/cocotb/thermal_6400_uart.py
  36. 21 13
      tests/cocotb/thermal_control_core_cocotb_top.v
  37. 29 35
      tests/formal/6400-properties.json
  38. 20 0
      tests/formal/6400_board_adapter_properties.sby
  39. 16 0
      tests/formal/6400_board_adapter_properties_formal.v
  40. 25 5
      tests/sim/frame_rx_tb.v
  41. 5 6
      tests/sim/thermal_control_core_tb.v
  42. 104 0
      tests/sim/thermal_control_hard_race_tb.v
  43. 25 7
      tests/sim/thermal_host_command_v2_tb.v
  44. 15 0
      tests/unit/test_6400_closure_separation.py
  45. 4 4
      tests/unit/test_6400_contract.py
  46. 47 235
      tests/unit/test_6400_formal_contract.py
  47. 47 114
      tests/unit/test_6400_profile_package.py
  48. 19 46
      tests/unit/test_6400_td_parser.py
  49. 16 28
      tests/unit/test_6400_v1_contract.py
  50. 1 1
      tests/unit/test_fw_multiproject.py
  51. 5 4
      tests/unit/test_multiproject_targets.py
  52. 93 0
      tools/check_6400_closures.py
  53. 1 1
      tools/generate_6400.py
  54. 1 1
      tools/generate_target.py
  55. 1 0
      tools/requirements-verify.txt
  56. 3 3
      tools/run_6400_formal.py

+ 72 - 0
ACTIVE_FIX_LOCK.yaml

@@ -0,0 +1,72 @@
+schema: prod2u-6400-active-fix-lock-v1
+workspace: /data/prod2u/worktrees/6400-front-rear-v11-30s
+authoritative_repo: /root/workspaces/thermal-system/cpld-temperature-control
+branch: feature/6400-front-rear-v11-30s
+baseline_commit: a00a5b673f6007ba4602221393aa4dce1e75e51e
+product: 6400-front-rear
+board: FCB V1.1
+device: EF2L45BG256B
+clock_hz: 25000000
+pll: forbidden
+host_uart: 921600-8N1
+bmc_uart: 115200-8N1
+pwm:
+  ptc_hz: 500
+  fan_hz: 500
+  clocks_per_period: 50000
+pins:
+  front: [B1, C4, B5, A14]
+  rear: [P15, N15, M14, P5]
+  ptc: V1.1_ADC_24_channels_no_drift
+polarity:
+  fan_duty_semantics: connector_high_duty
+  fan_board_invert_mask: 0x0F
+  front: board_inverted
+  rear: direct
+  ptc: active_high
+safe_output:
+  ptc_percent: 0
+  fan_connector_percent: 20
+control:
+  owners: [OWNER_SAFE, OWNER_MANUAL, OWNER_PID]
+  watchdog_seconds: 30
+  default_pid_target_c: 70
+  set_all_timeout_priority: SET_ALL
+  manual_without_bmc: allowed_open_loop
+  pid_requires_new_valid_bmc_epoch: true
+safety:
+  dimm_clamp_c: 76
+  lane_latch_c: 77
+  lane_release_c: 72
+  lane_release_epochs: 3
+protocol:
+  frame: A5_5A_TYPE_LENGTH_PAYLOAD_CRC_LO_CRC_HI
+  crc: CRC16_CCITT_FALSE
+  commands:
+    SET_ALL: 0x01
+    GET_SNAPSHOT: 0x02
+    SET_STIMULUS_RESERVED_UNSUPPORTED: 0x03
+    SET_PID_TARGET: 0x04
+    ACK_NACK: 0x06
+    SNAPSHOT_DATA: 0x82
+q0_findings:
+  single_product_cleanup: PASS_active_registry_td_gui_tests_front_rear_only
+  fan_contract: fixed_manual_independent_pid_safe20_hard100
+  fixed_point_contract: present_incremental_pi_q4_12_q8_8
+  pi_rtl: fixed_shared_incremental_pi_bram_state
+  hard_fault_steady_state: fixed_new_fault_once_then_lane_clamp
+  pid_stale_hold: fixed_single_safe_commit_hold
+  set_all_hard_fault_race: PASS_inflight_manual_cancel_before_output_apply
+  oversized_frame: fixed_and_icarus_PASS_length34_embedded_header_bad_crc
+  source_closure: PASS_production_analysis_separated_hash_recomputed
+  package_replay: Q4_pending_base_current_delivery_fresh_extraction
+  host_ttl_physical_pins: BLOCKED_EVIDENCE
+execution:
+  phase: Q2_PASS_pre_commit
+  long_tests_before_quick: forbidden
+  hardware: NOT_RUN
+  com: NOT_RUN
+  jtag: NOT_RUN
+  pre_configuration_output: NOT_VERIFIED
+last_test: Q2_PASS_64unit_lint_icarus_pwm_pi_host_control_formal_smoke_generator_closure
+next: commit_clean_then_fresh_TD2026_and_quick_package

+ 4 - 3
AGENTS.md

@@ -21,9 +21,10 @@ This repository contains profile-isolated CPLD products. The active 6400 contrac
 
 - Four lanes of six DIMMs and zones 6+12+6; 24 PTC, four front fans, four rear fans, 27 CT values, and 24 BMC values.
 - All 24 channels are controlled/protected. The 18+6 split is modelling-only.
-- No door motor, limit, calibration, solenoid, fan FG, Host watchdog, MCU/SoC, or online learning in 6400 profiles.
-- Production has target/ACK/snapshot only. Identification alone adds finite stimulus; safety always overrides it.
-- Host disconnection never stops autonomous control.
+- No door motor, limit, calibration, solenoid, fan FG, MCU/SoC, or online learning in the 6400 product.
+- The only active 6400 product is `6400-front-rear`; historical profile files are not build, TD, GUI, test, or release inputs.
+- The firmware supports SET_ALL, GET_SNAPSHOT and SET_PID_TARGET. The retained 0x03 SET_STIMULUS identity always returns unified UNSUPPORTED NACK.
+- A successful SET_ALL owns MANUAL for the single 30-second control watchdog lease. Expiry transfers ownership to PID; MANUAL output is intentionally independent of BMC availability.
 
 ## Resource policy
 

+ 24 - 14
QUICK_PROGRESS.md

@@ -1,18 +1,28 @@
-# 6400 V1.1 Quick Progress
+# 6400 V1.1 Bounded Fix Progress
 
 - Workspace: `/data/prod2u/worktrees/6400-front-rear-v11-30s`
 - Branch: `feature/6400-front-rear-v11-30s`
-- Baseline: `127db8eef879a6c0cad0e97b485c28d59944afa9`
-- Product: `6400-front-rear`; Board: `FCB V1.1`
-- Q0: PASS with `HOST_TTL_PHYSICAL_PINS=BLOCKED_EVIDENCE`.
-- Q1: PASS; single product contract/generator/RTL/HEX GUI implementation complete.
-- Q2: PASS; deterministic generation, command collision/hash checks, Verilator/Yosys, 21 unit tests, focused Icarus, three-period reset PWM, polarity and Host Cocotb passed.
-- Registry: `01 SET_ALL`, `02 GET_SNAPSHOT`, `03 SET_STIMULUS` reserved, `04 SET_PID_TARGET`, `06 ACK_NACK`, `82 SNAPSHOT_DATA`.
-- UART: Host RS232/TTL 921600 8N1; BMC RS232 115200 8N1. RS232 pins confirmed; physical TTL pins unconfirmed.
-- Pins: Front `B1/C4/B5/A14`; Rear `P15/N15/M14/P5`; all PTC constrained by V1.1 ADC.
-- Polarity: connector-side FAN duty; board adapter only; `FAN_BOARD_INVERT_MASK=0x0F`; PTC active high.
-- Safe/reset/boot/PID-wait: PTC 0%, Front 20%, Rear 20%; 500 Hz, 50,000 clocks/period.
-- Control: owner only SAFE/MANUAL/PID; watchdog 30 s; target 70 C; SET_ALL wins same-cycle timeout.
-- Last result: `FOCUSED_TESTS_PASS`; no Formal/Fuzz/Soak/Legacy run.
-- Next: Q3 clean commit and Fresh TD2026 synthesis/place/route/setup/hold/bitgen.
+- Baseline/HEAD: `a00a5b673f6007ba4602221393aa4dce1e75e51e`
+- Initial Git status: clean.
+- Product: `6400-front-rear`; Board: `FCB V1.1`.
+- Phase: Q2 focused verification PASS; preparing clean Q3 commit.
+- Prior Quick artifacts are historical evidence only and will not be reused.
+- Fixed-point YAML exists and specifies incremental PI Q4.12/Q8.8, half-away rounding, slew 1280, Kd 0.
+- Fixed: production Top/Core/Command stimulus parameter, RAM, ports and states removed; 0x03 remains UNSUPPORTED.
+- Fixed: fan contract split into manual independence and PID safe20/hard100 policy.
+- Fixed: one sequential incremental PI datapath, Q4.12/Q8.8 and BRAM-resident 24-channel state.
+- Fixed: new hard fault global-safe once; persistent fault and stale no repeated global Bank churn.
+- Fixed: SET_ALL final commit handshake returns SAFETY_LOCKED if a new hard lock cancels apply.
+- PASS: bounded oversized-frame RX audit and source-closure hash/separation checks.
+- Implemented: bounded oversized-frame CRC/discard path; length-34 embedded-header and bad-CRC Icarus PASS.
+- Implemented: unambiguous manual/PID fan-policy contract; deterministic generator rebuild and `--check` PASS.
+- Toolchain: OSS CAD Suite restored at `/data/prod2u/oss-cad-suite/latest`; no global PATH or driver changes.
+- PASS: deterministic generator check, Verilator lint, Frame RX Icarus, Host Command Icarus, Core Icarus.
+- PASS: canonical Python-vs-RTL PI differential including EDGE/CENTER, rounding, slew, saturation, epoch hold, MANUAL freeze, timeout clear and stale hold.
+- PASS: current-contract full-top control Cocotb: SAFE 0/20, MANUAL without BMC, 76 clamp, 77 lane lock, SAFETY_LOCKED, three-epoch release, persistent stale hold.
+- PASS: full-UART oversized Length 34/255, embedded A5 5A, one BAD_LENGTH/UNSUPPORTED response and no ghost command.
+- PASS: active Formal manifest is single-product; bounded Boolector board-adapter smoke proves Front inverse/Rear direct.
+- PASS: 64 focused unit tests, Verilator/Yosys lint, all focused Icarus, PWM three-period reset, Host/control Cocotb, PI differential, closure checks and two deterministic generator checks.
+- Registry: `01 SET_ALL`, `02 GET_SNAPSHOT`, `03 SET_STIMULUS reserved`, `04 SET_PID_TARGET`, `06 ACK_NACK`, `82 SNAPSHOT_DATA`.
 - Hardware/COM/JTAG: NOT RUN. Pre-configuration pin state: NOT VERIFIED.
+- Next: create exact clean commit, locate/verify td2026, run Fresh synthesis/place/route/setup/hold/bitgen, then build and immediately report Quick Candidate.

+ 2 - 1
contracts/fan-control-parameters.yaml

@@ -2,7 +2,8 @@ schema: prod2u-6400-fan-control-v3
 truth_label: EXPERIMENTAL_UNVERIFIED
 duty: {reset: 20, boot: 20, standby: 20, watchdog: 20, pid_wait_sensor: 20, ordinary_fault: 20, hard: 100}
 temperature_centi_degC: {channel_clamp: 7600, lane_hard: 7700, lane_release: 7200}
-front_rear_independent: false
+manual_front_rear_independent: true
+pid_fan_policy: safe20_hard100
 connector_duty_semantics: high_level_percent
 board_invert_mask: 0x0F
 pwm:

+ 9 - 18
docs/audits/01-requirements-product-boundary.md

@@ -1,21 +1,12 @@
-# Audit 1 - requirements and product boundary
+# Q0 Audit 1 - Product, Owner and Watchdog
 
-Result: PASS at design-lock level. Production implementation remains to be verified.
+Result: PASS, current source and focused-test evidence.
 
-## Independent checks
+- The active target registry has one 6400 entry: `6400-front-rear`; historical product directories are not active registry, TD, GUI or release inputs.
+- Production owner values are SAFE, MANUAL and PID. Hard protection is an Applied-output override rather than a fourth owner.
+- Production `CONTROL_WATCHDOG_SECONDS` is 30. The counter is shared by SAFE/MANUAL; PID does not count it.
+- Only a successful applied SET_ALL reloads the lease. GET, SET_PID_TARGET, 0x03, invalid frames and NACK do not.
+- SET_ALL commit has priority over same-cycle timeout. MANUAL does not depend on BMC; PID requires a new complete valid BMC epoch.
+- Production Top/Core/Command no longer contain ENABLE_STIMULUS, stimulus RAM/banks/timers/state or stimulus ports. Type 0x03 remains named SET_STIMULUS and returns UNSUPPORTED NACK.
 
-- The old root authority mixes door-percent/MSE priorities into 6400. The new lock confines every motor, limit, calibration, motor-status, 20 Hz PWM, door payload, and legacy watchdog rule to `legacy-door-percent`.
-- The planned 6400 profile contains exactly 24 PTC, four front-fan, four rear-fan, 27 CT, and 24 BMC temperature channels. It does not model “three zones” as three fan channels.
-- The topology distinguishes L0/L1/L2/L3 execution from Z0/Z1/Z2 physical grouping.
-- The modelling split is 18 primary plus 6 holdout; it does not remove acquisition, control, safety, telemetry, or testing from the holdout lane.
-- No RDIMM/MRDIMM coprocessor, MCU/SoC, door hardware, fan FG, PLL, or online algorithm is in V1.
-- The Host wire contract contains no version, project ID, sequence, NACK, capability, or dynamic discovery.
-- `host_target_seen` is telemetry only; Host absence cannot disable autonomous operation.
-
-## Correction made before PASS
-
-The pre-existing 6400 direct-duty SET_ALL/watchdog architecture was rejected rather than treated as an incremental V1 implementation. The lock now defines target-only Host control and autonomous startup.
-
-## Follow-up gates
-
-Generator tests must prove exact counts/profile isolation, and source-closure tests must fail on any motor/limit/watchdog/stimulus leakage into production.
+Evidence: generated Host contract, `thermal_control_core_tb`, current full-top control/Host Cocotb, single-product registry unit tests.

+ 9 - 25
docs/audits/02-board-electrical-evidence.md

@@ -1,28 +1,12 @@
-# Audit 2 - board and electrical evidence
+# Q0 Audit 2 - Board Pin, Polarity and Reset PWM
 
-> Historical pre-V1.1 snapshot. The active fan authority is
-> `contracts/channel-map.yaml` and `docs/electrical/rear-fan-evidence-lock.md`.
-> Current production order is Front0..3 then Rear0..3; Front FPGA balls are
-> active-low through Q99/Q100/Q101/Q102 board inversion, while Rear balls are
-> active-high direct paths. The earlier all-active-low statement is superseded.
+Result: PASS for confirmed V1.1 production outputs; Host TTL physical pins remain BLOCKED_EVIDENCE.
 
-Result: PASS with explicit unresolved TTL and CT placement fields.
+- Device EF2L45BG256B, one 25 MHz clock and no PLL are fixed.
+- Front order B1/C4/B5/A14 is board-inverted; Rear order P15/N15/M14/P5 is direct. `FAN_BOARD_INVERT_MASK=8'h0F` is applied only in `fan_board_output_adapter`.
+- All fan contract, requested and applied duties are connector-side high-level duty. PTC is active high.
+- The V1.1 ADC constrains all 24 PTC, four Front and four Rear outputs with no duplicate ball; CT pins remain fixed.
+- The PWM carrier is FPGA/POR initialized and continues while control reset is held. Three-period simulation proves PTC high 0, connector fan high 10,000, Front ball low 10,000 and Rear ball high 10,000 clocks per 50,000-clock period.
+- Formal smoke proves Front inversion and Rear direct mapping for all logical vectors.
 
-## Independent evidence review
-
-- CON77/UART1 is a real RS-232 path through U22: L10 TX and M9 RX. It is suitable for the contract-assigned BMC port.
-- CON78/UART2 is a separate real RS-232 path through U23: M10 TX and N11 RX. It is suitable for Host RS-232.
-- The old `locked_debug_uart_assignments` using T4/R5/P7/P8 conflict with PTC HEAT pins and are explicitly historical/diagnostic; they are not selected.
-- TTL Host has no complete connector-to-ball chain in current evidence. RTL ports remain, while ADC bindings are absent and marked unknown.
-- PTC and eight logical fan output balls are carried from the committed 6400 board contract. Output polarity is compile-time: Front balls are active-low and Rear balls are active-high.
-- CT7428 I2C M8/N9 is open-drain. No push-pull-high assignment is permitted.
-- The 27 CT register indices are known; physical DIMM placement is not. The map records unknown rather than inventing a permutation.
-- Exact BMC command text and 48 decoded response bytes are recovered from Git history. Fractional temperature semantics are not overclaimed.
-
-## Pin-conflict result
-
-Known 6400 production pins are unique after assigning BMC to UART1 and Host RS-232 to UART2. Unbound TTL pins are excluded from the production ADC until resolved, so the physical TTL portion cannot be called hardware-complete.
-
-## Follow-up gates
-
-The generator must detect duplicate balls, reject a guessed CT map, and make unresolved TTL status visible in the project summary and final report.
+PRE_CONFIGURATION_OUTPUT = NOT VERIFIED. Hardware/COM/JTAG are NOT RUN.

+ 8 - 19
docs/audits/03-rtl-reuse-resource-structure.md

@@ -1,22 +1,11 @@
-# Audit 3 - RTL reuse and resource structure
+# Q0 Audit 3 - PI Fixed Point, BRAM, DSP and LUT Structure
 
-Result: PASS at architecture level.
+Result: PASS for RTL structure and bit-exact focused simulation; TD resource inference remains Q3 evidence.
 
-## Independent structural review
+- Canonical `6400-fixed-point.yaml` and Lab Python reference define incremental PI, Q4.12 coefficients, Q8.8 output, half-away-from-zero rounding, slew 1280, Kd 0 and EDGE/CENTER classes.
+- RTL uses one sequential PI arithmetic path for 24 channels; no per-channel controller generate exists.
+- Previous error/output state is stored in one 24-entry `ef2_bram_dp` state memory. MANUAL freezes state; SAFE/MANUAL expiry clears it; invalid/stale epochs do not integrate.
+- One PWM carrier/scanner/comparator produces one 32-bit bitmap. Requested and Applied output banks remain distinct and switch atomically.
+- Python-vs-RTL differential testing covers coefficient classes, error signs, rounding, slew, saturation, anti-windup, epoch hold, MANUAL freeze and stale behavior.
 
-- The design has one shared incremental-PI arithmetic engine for 24 logical loops and only two coefficient classes. No generate loop may instantiate 24 controllers.
-- PWM has one carrier and comparator, but persistent 32-bit output registers are retained because outputs must remain continuously driven.
-- BMC and Host have independent RX byte frontends for true concurrency; downstream parsing and scheduling remain compact and deterministic.
-- One fixed-priority service scheduler is sufficient; no generic on-chip bus or dynamic interconnect is introduced.
-- BMC, CT, duty, and snapshot state uses inactive-bank writes plus pointer flips. Large FF array copies are rejected.
-- Snapshot transmission is address-streamed from locked banks. A 200-byte FF payload buffer is rejected.
-- RAM/DSP inference will use synchronous coding and isolated wrappers only. The old 32x8 target banks remaining in FFs are historical evidence, not proof that all new arrays should use FFs.
-- Safety is sequentially scanned by the shared comparator but commits final overrides before output application. Static budgets must prove no PWM/UART deadline miss or scheduler starvation.
-
-## Corrective action before PASS
-
-The existing phase scanner updates physical bits one by one. The lock replaces it with `next_bitmap` plus an atomic boundary transfer.
-
-## Follow-up gates
-
-Lint/Yosys hierarchy checks must count physical instances; formal must cover bank isolation, scan completion, scheduler progress, and atomic output switching; TD A/B receipts decide the final encodings.
+Exact DSP/BRAM/LUT/Slice inference is not claimed until Fresh TD.

+ 10 - 20
docs/audits/04-protocol-state-safety.md

@@ -1,23 +1,13 @@
-# Audit 4 - protocol, state machine, and safety
+# Q0 Audit 4 - Protocol, Safety Race and Atomic Commit
 
-Result: PASS at frozen-contract level.
+Result: PASS for implemented focused scope.
 
-## Independent behavior review
+- Registry is 01 SET_ALL, 02 GET_SNAPSHOT, 03 SET_STIMULUS retained/unsupported, 04 SET_PID_TARGET, 06 ACK_NACK and 82 SNAPSHOT_DATA; IDs are unique.
+- Every complete CRC-correct request receives exactly one unified ACK/NACK. Bad header/CRC, partial, timeout and framing-error traffic is silent.
+- Frame RX consumes and CRC-checks lengths through 255 without large payload RAM; embedded A5 5A cannot create a ghost command.
+- SET_ALL validates all 32 values, stages inactive memory, rechecks safety and ACKs only after the safe PWM-boundary output commit.
+- A new 77 C hard lock cancels an in-flight manual vector, returns SAFETY_LOCKED, does not feed the watchdog and cannot restore the cancelled vector after release.
+- New hard fault may make one global safe transition; subsequent valid epochs clamp only fault lanes and resume PID on non-fault lanes. Persistent PID stale performs one safe commit without bank/control-epoch churn.
+- GET locks snapshot banks/port, emits 06 ACK then 82 DATA and unlocks only after the final physical stop bit.
 
-- SET_TARGET accepts only one byte: 0 or 20..70. Legal commit precedes a zero-length `0x81` ACK. All invalid requests are silent drops.
-- GET_SNAPSHOT is zero-length and returns only `0x82` data. There is one outstanding Host transaction and no queue or sequence matching.
-- Port selection locks at the first start bit and survives through response completion; only the selected TX is active.
-- The BMC parser is streaming, case-insensitive, separator-tolerant, and commits exactly 48 bytes. Partial, short, long, invalid, timed-out, echo-only, or UART-error input cannot advance the epoch.
-- PREHEAT depends on valid CT, AUTO depends on three distinct BMC epochs, and repeated GET cannot cause repeated PI integration.
-- Global BMC stale forces all PTC off/all fans 100. Invalid and 74/76/77 C actions are more immediate than normal PI requests.
-- STOPPED keeps acquisition/GET active and requires safe requalification before returning to heat.
-- Identification stimulus has a hardware expiry and is absent from production source closure.
-- Snapshot locks bank and epoch identity for the whole frame.
-
-## Correction made before PASS
-
-The pre-existing Host watchdog and direct 32-duty SET_ALL were removed from the frozen 6400 behavior. Host disconnection now has no autonomous-state effect.
-
-## Follow-up gates
-
-Simulation/fuzz/formal must test bad CRC no target change, ACK-after-commit only, stale/invalid/hard-limit priority, epoch gating, recovery, port lock, stimulus expiry, and reset-safe outputs.
+Evidence: Frame RX, Host Command, Core, hard-race Icarus and full-top Host/control Cocotb.

+ 9 - 20
docs/audits/05-multirepo-environment-replay.md

@@ -1,23 +1,12 @@
-# Audit 5 - repositories, environment, and replay
+# Q0 Audit 5 - Source Closure, Packager and Base/Current Replay
 
-Result: PASS for the migration plan; repository creation and current-run gates remain execution work.
+Result: PASS for source/analysis closure separation; canonical package profile replay remains Q4.
 
-## Independent reproducibility review
+- Production Source Closure contains every current TD RTL input plus generated params, ADC, SDC, TD project and TCL bindings; every listed path exists and hashes are recomputable.
+- Analysis Replay Closure separately lists contract, generator, target registry, GUI, packager and focused-test dependencies, including `tools/target_registry.py` and `contracts/6400-fixed-point.yaml`.
+- The two closures are independently checked and cannot substitute for one another.
+- Generator deterministic replay and `--check` pass from the authoritative worktree; generated fixed-point, params, Host contract and golden vectors share the contract SHA.
+- Canonical packaging entry is `tools/package_target.py`; temporary build/test/formal/TD outputs remain outside Git under `/data/prod2u`.
+- Historical Quick/bitstream receipts are not current PASS evidence and will not be reused.
 
-- Four and only four current-scope repositories are planned: engineering-manifests, cpld-temperature-control, hth-platform, thermal-control-lab.
-- HTH has a substantial Host-bearing history on `origin/dev` and HTH branches. A history split is required; copying the directory and claiming history would fail.
-- Legacy remains a CPLD profile and build target. Its nearest `AGENTS.md` owns door behavior; 6400 authority moves away from the root.
-- Android Repo XML is the single repository inventory. No workspace YAML duplicates repository rows.
-- The authoritative editable workspace is Linux-native under `/root/workspaces/thermal-system`; Windows copies and unknown worktrees remain untouched.
-- The base runtime is Debian, not Ubuntu. Container digest and every tool version must be recorded; TD environment variables are scoped to the TD subprocess.
-- Lab uses only the HTH API and never opens a serial device directly.
-- Snapshot and release manifests bind exact full commits, generated-contract hashes, container digest, TD version, source manifest, commands, statuses, and bitstream hash.
-- Historical receipts are never promoted to current PASS. Clean replay must rebuild from the manifest without cache dependence.
-
-## Corrective action before PASS
-
-The original task branch did not contain the latest Host tree. The migration basis was changed to a Git-history split from the Host-bearing lineage while leaving the dirty Windows worktree untouched.
-
-## Follow-up gates
-
-Each new repository must end on clean `dev`, the snapshot verifier must resolve exact commits, HTH and Lab must pass standalone tests, and L14 must replay generation/test/TD/package from clean detached worktrees.
+Q4 must still prove Base/Current overlay replay, POSIX ZIP members, member-bound SHA256SUMS, deterministic archives, tamper failure and adversarial path tests.

+ 1 - 1
docs/generated/6400-channel-map.md

@@ -1,6 +1,6 @@
 # Generated 6400 channel map
 
-Contract SHA-256: `b5c45e4782fcb4ec926a69870973c811f6a2c4ea3096f7511ce691e11b6fecfc`.
+Contract SHA-256: `35fe2e0602b5bc1ead064b7aaaf66571266fa6c809841fe68fb1c882cb13291b`.
 
 | DIMM | CPU slot | Lane | Zone | PTC | BMC | CT | Cohort |
 | ---: | --- | ---: | ---: | ---: | ---: | --- | --- |

+ 1 - 1
generated/6400/channel-map.json

@@ -488,7 +488,7 @@
       "thermal_zone": 2
     }
   ],
-  "contract_sha256": "b5c45e4782fcb4ec926a69870973c811f6a2c4ea3096f7511ce691e11b6fecfc",
+  "contract_sha256": "35fe2e0602b5bc1ead064b7aaaf66571266fa6c809841fe68fb1c882cb13291b",
   "fan_output_vector_order": [
     "front0",
     "front1",

+ 1 - 1
generated/6400/contract-sha256.txt

@@ -1 +1 @@
-b5c45e4782fcb4ec926a69870973c811f6a2c4ea3096f7511ce691e11b6fecfc
+35fe2e0602b5bc1ead064b7aaaf66571266fa6c809841fe68fb1c882cb13291b

+ 1 - 1
generated/6400/controller-coefficients.json

@@ -17,7 +17,7 @@
       ]
     }
   },
-  "contract_sha256": "b5c45e4782fcb4ec926a69870973c811f6a2c4ea3096f7511ce691e11b6fecfc",
+  "contract_sha256": "35fe2e0602b5bc1ead064b7aaaf66571266fa6c809841fe68fb1c882cb13291b",
   "limits_centi_degC": {
     "channel_clamp": 7600,
     "lane_hard": 7700,

+ 3 - 2
generated/6400/fan-control-parameters.json

@@ -3,7 +3,7 @@
   "actual_rpm_status": "NOT_RUN",
   "board_invert_mask": 15,
   "connector_duty_semantics": "high_level_percent",
-  "contract_sha256": "b5c45e4782fcb4ec926a69870973c811f6a2c4ea3096f7511ce691e11b6fecfc",
+  "contract_sha256": "35fe2e0602b5bc1ead064b7aaaf66571266fa6c809841fe68fb1c882cb13291b",
   "duty": {
     "boot": 20,
     "hard": 100,
@@ -13,7 +13,8 @@
     "standby": 20,
     "watchdog": 20
   },
-  "front_rear_independent": false,
+  "manual_front_rear_independent": true,
+  "pid_fan_policy": "safe20_hard100",
   "pre_configuration_output_status": "NOT_VERIFIED",
   "pwm": {
     "carrier_backend": "shared_equal_frequency_control_reset_independent_v2",

+ 1 - 1
generated/6400/fixed-point.json

@@ -6,7 +6,7 @@
     "integer_bits": 4,
     "signed_bits": 16
   },
-  "contract_sha256": "b5c45e4782fcb4ec926a69870973c811f6a2c4ea3096f7511ce691e11b6fecfc",
+  "contract_sha256": "35fe2e0602b5bc1ead064b7aaaf66571266fa6c809841fe68fb1c882cb13291b",
   "error": {
     "signed_bits": 16,
     "unit": "centi_degC"

+ 1 - 1
generated/6400/golden-vectors.json

@@ -1,5 +1,5 @@
 {
-  "contract_sha256": "b5c45e4782fcb4ec926a69870973c811f6a2c4ea3096f7511ce691e11b6fecfc",
+  "contract_sha256": "35fe2e0602b5bc1ead064b7aaaf66571266fa6c809841fe68fb1c882cb13291b",
   "frames": {
     "bad_length_01_nack": "A55A060400010220C77F",
     "bad_value_01_index_7_nack": "A55A0604000103077318",

+ 5 - 4
generated/6400/host-contract.json

@@ -694,7 +694,7 @@
     "product": "6400-front-rear-v1",
     "schema": "prod2u-6400-channel-map-v1"
   },
-  "contract_sha256": "b5c45e4782fcb4ec926a69870973c811f6a2c4ea3096f7511ce691e11b6fecfc",
+  "contract_sha256": "35fe2e0602b5bc1ead064b7aaaf66571266fa6c809841fe68fb1c882cb13291b",
   "controller_coefficients": {
     "classes": {
       "CENTER": {
@@ -740,7 +740,8 @@
       "standby": 20,
       "watchdog": 20
     },
-    "front_rear_independent": false,
+    "manual_front_rear_independent": true,
+    "pid_fan_policy": "safe20_hard100",
     "pre_configuration_output_status": "NOT_VERIFIED",
     "pwm": {
       "carrier_backend": "shared_equal_frequency_control_reset_independent_v2",
@@ -796,7 +797,7 @@
     }
   },
   "golden_vectors": {
-    "contract_sha256": "b5c45e4782fcb4ec926a69870973c811f6a2c4ea3096f7511ce691e11b6fecfc",
+    "contract_sha256": "35fe2e0602b5bc1ead064b7aaaf66571266fa6c809841fe68fb1c882cb13291b",
     "frames": {
       "bad_length_01_nack": "A55A060400010220C77F",
       "bad_value_01_index_7_nack": "A55A0604000103077318",
@@ -817,7 +818,7 @@
   "schema": "prod2u-6400-host-contract-v3",
   "snapshot": {
     "byte_order": "little",
-    "contract_sha256": "b5c45e4782fcb4ec926a69870973c811f6a2c4ea3096f7511ce691e11b6fecfc",
+    "contract_sha256": "35fe2e0602b5bc1ead064b7aaaf66571266fa6c809841fe68fb1c882cb13291b",
     "fields": [
       {
         "name": "mode",

+ 1 - 1
generated/6400/prod2u_6400_v1_params.vh

@@ -1,6 +1,6 @@
 `ifndef PROD2U_6400_V1_PARAMS_VH
 `define PROD2U_6400_V1_PARAMS_VH
-// Generated contract SHA-256: b5c45e4782fcb4ec926a69870973c811f6a2c4ea3096f7511ce691e11b6fecfc
+// Generated contract SHA-256: 35fe2e0602b5bc1ead064b7aaaf66571266fa6c809841fe68fb1c882cb13291b
 `define FB_CLOCK_HZ 25000000
 `define FB_PTC_COUNT 24
 `define FB_FRONT_FAN_COUNT 4

+ 1 - 1
generated/6400/snapshot-layout.json

@@ -1,6 +1,6 @@
 {
   "byte_order": "little",
-  "contract_sha256": "b5c45e4782fcb4ec926a69870973c811f6a2c4ea3096f7511ce691e11b6fecfc",
+  "contract_sha256": "35fe2e0602b5bc1ead064b7aaaf66571266fa6c809841fe68fb1c882cb13291b",
   "fields": [
     {
       "name": "mode",

+ 31 - 0
products/6400-front-rear/analysis-replay-closure.json

@@ -0,0 +1,31 @@
+{
+  "schema": "prod2u-analysis-replay-closure-v1",
+  "project_id": "6400-front-rear",
+  "paths": [
+    "contracts/6400-fixed-point.yaml",
+    "contracts/6400-wire.yaml",
+    "contracts/channel-map.yaml",
+    "contracts/fan-control-parameters.yaml",
+    "products/6400-front-rear/project.json",
+    "products/6400-front-rear/source-closure.json",
+    "projects/registry.json",
+    "tools/6400_hex_gui.py",
+    "tools/build_6400_hex_gui.py",
+    "tools/check_6400_closures.py",
+    "tools/encode_6400_hex.py",
+    "tools/fw_targets.py",
+    "tools/generate_6400_v1.py",
+    "tools/generate_target.py",
+    "tools/package_target.py",
+    "tools/run_6400_td.py",
+    "tools/target_registry.py",
+    "tests/sim/frame_rx_tb.v",
+    "tests/sim/thermal_control_core_tb.v",
+    "tests/sim/thermal_control_hard_race_tb.v",
+    "tests/sim/thermal_host_command_v2_tb.v",
+    "tests/cocotb/run_6400_pi_differential.py",
+    "tests/cocotb/test_6400_pi_differential.py",
+    "tests/cocotb/thermal_control_core_cocotb_top.v",
+    "tests/unit/test_6400_closure_separation.py"
+  ]
+}

+ 1 - 1
src/common/AGENTS.md

@@ -2,7 +2,7 @@
 
 - Verilog-2001 compatible.
 - UART RX/TX handle byte timing only.
-- CRC is serial and independent in RX and TX paths.
+- Frame RX and TX expose an external serial-CRC handshake. The production Host top arbitrates both directions onto one `crc16_serial`; internal CRC instances are test/standalone fallbacks only.
 - Frame RX/TX handle framing, lengths, payload RAM access, and CRC only.
 - No project counts, pins, motor semantics, temperature semantics, or legacy protocol behavior.
 - Use explicit valid/ready or one-cycle event contracts; no hidden queues.

+ 13 - 11
src/common/frame_rx.v

@@ -44,15 +44,18 @@ module frame_rx #(
     localparam [3:0] ST_CRC_HIGH = 4'd9;
     localparam [3:0] ST_HOLD = 4'd10;
     localparam integer GAP_BITS = (INTER_BYTE_TIMEOUT_CYCLES <= 1) ? 1 : $clog2(INTER_BYTE_TIMEOUT_CYCLES + 1);
-    localparam integer PAYLOAD_IDX_BITS = (MAX_PAYLOAD <= 1) ? 1 : $clog2(MAX_PAYLOAD + 1);
-
+    localparam [7:0] MAX_PAYLOAD_BYTE = MAX_PAYLOAD;
     reg [3:0] state;
-    reg [PAYLOAD_IDX_BITS-1:0] payload_index;
+    // LENGTH is an unsigned byte, so the receive cursor must cover the full
+    // 0..254 payload range even when the local payload RAM is much smaller.
+    // Bytes beyond MAX_PAYLOAD are CRC-checked and discarded, not treated as
+    // a new frame.  This lets the command engine NACK a complete trusted
+    // oversized request without allocating a 255-byte RAM.
+    reg [7:0] payload_index;
     reg [7:0] received_crc_low;
     reg [GAP_BITS-1:0] gap_counter;
     /* verilator lint_off WIDTH */
     wire gap_expired = gap_counter >= INTER_BYTE_TIMEOUT_CYCLES - 1;
-    wire length_oversize = frame_length > MAX_PAYLOAD;
     /* verilator lint_on WIDTH */
 
     wire crc_busy;
@@ -86,7 +89,7 @@ module frame_rx #(
             frame_valid <= 1'b0;
             frame_type <= 8'd0;
             frame_length <= 8'd0;
-            payload_index <= {PAYLOAD_IDX_BITS{1'b0}};
+            payload_index <= 8'd0;
             received_crc_low <= 8'd0;
             gap_counter <= {GAP_BITS{1'b0}};
             payload_wr_en <= 1'b0;
@@ -140,8 +143,8 @@ module frame_rx #(
                     end
                     ST_PAYLOAD: begin
                         if (!crc_busy) begin
-                            payload_wr_en <= 1'b1;
-                            payload_wr_addr <= {{(8-PAYLOAD_IDX_BITS){1'b0}}, payload_index};
+                            payload_wr_en <= payload_index < MAX_PAYLOAD_BYTE;
+                            payload_wr_addr <= payload_index;
                             payload_wr_data <= byte_data;
                             state <= ST_PAYLOAD_CRC_WAIT;
                         end
@@ -167,15 +170,14 @@ module frame_rx #(
                 case (state)
                     ST_TYPE_CRC_WAIT: state <= ST_LENGTH;
                     ST_LENGTH_CRC_WAIT: begin
-                        if (length_oversize) state <= ST_WAIT_A5;
-                        else if (frame_length == 0) state <= ST_CRC_LOW;
+                        if (frame_length == 0) state <= ST_CRC_LOW;
                         else begin
-                            payload_index <= {PAYLOAD_IDX_BITS{1'b0}};
+                            payload_index <= 8'd0;
                             state <= ST_PAYLOAD;
                         end
                     end
                     ST_PAYLOAD_CRC_WAIT: begin
-                        if ({{(8-PAYLOAD_IDX_BITS){1'b0}}, payload_index} + 1'b1 >= frame_length) state <= ST_CRC_LOW;
+                        if (payload_index + 1'b1 >= frame_length) state <= ST_CRC_LOW;
                         else begin
                             payload_index <= payload_index + 1'b1;
                             state <= ST_PAYLOAD;

+ 160 - 98
src/control/thermal_control_core.v

@@ -4,7 +4,6 @@
 // Single-owner controller. Host and PID values are connector-side duties.
 // Safety is an independent applied-output layer; board polarity is external.
 module thermal_control_core #(
-    parameter integer ENABLE_STIMULUS = 0,
     parameter integer WATCHDOG_TICKS_OVERRIDE = 0,
     parameter signed [15:0] CHANNEL_LIMIT = `FB_TEMP_CHANNEL_CLAMP,
     parameter signed [15:0] HARD_LIMIT = `FB_TEMP_LANE_HARD,
@@ -19,13 +18,9 @@ module thermal_control_core #(
     input  wire [7:0]   manual_wr_data,
     input  wire         manual_commit,
     output reg          manual_commit_done,
+    output reg          manual_commit_ok,
     input  wire         pid_target_commit,
     input  wire [7:0]   pid_target_celsius,
-    input  wire         stimulus_wr_en,
-    input  wire [4:0]   stimulus_wr_addr,
-    input  wire [7:0]   stimulus_wr_data,
-    input  wire         stimulus_commit,
-    input  wire [7:0]   stimulus_duration_seconds,
     input  wire [15:0]  bmc_epoch,
     input  wire         bmc_stale,
     input  wire [23:0]  bmc_valid_mask,
@@ -51,7 +46,6 @@ module thermal_control_core #(
     output reg [3:0]    lane_fault_mask,
     output reg          global_fault,
     output reg          output_commit,
-    output wire         stimulus_active,
     output wire         watchdog_active,
     output reg [7:0]    watchdog_remaining,
     output wire         pid_running,
@@ -70,7 +64,7 @@ module thermal_control_core #(
     localparam [3:0] W_INIT = 0, W_IDLE = 1, W_MANUAL_COPY = 2,
         W_PID_PREFETCH = 3, W_PID_WRITE = 4, W_FAN_WRITE = 5,
         W_APPLY_PREFETCH = 6, W_APPLY_WRITE = 7, W_SAFE_FILL = 8,
-        W_COMMIT_WAIT = 9, W_STIM_COPY = 10,
+        W_COMMIT_WAIT = 9,
         W_SAFETY_PREFETCH = 11, W_SAFETY_CHECK = 12;
     localparam [1:0] COMMIT_NONE = 0, COMMIT_MANUAL = 1,
         COMMIT_SAFE = 2, COMMIT_PID = 3;
@@ -84,17 +78,17 @@ module thermal_control_core #(
     reg [1:0] lane_release_count [0:3];
     reg manual_pending;
     reg safe_pending;
-    reg stimulus_running;
-    reg [7:0] stimulus_remaining;
-    reg stimulus_copy_bank;
-    reg [15:0] pi_integral [0:23];
+    reg stale_hold_committed;
+    reg [15:0] manual_request_epoch;
+    reg pi_state_write;
+    reg [4:0] pi_state_write_addr;
+    reg [31:0] pi_state_write_data;
+    wire [31:0] pi_state_read_data;
+    wire [31:0] pi_state_unused_read_data;
 
     wire manual_bank_active;
     wire manual_commit_applied;
     wire [7:0] manual_data;
-    wire stimulus_bank_active;
-    wire stimulus_commit_applied;
-    wire [7:0] stimulus_data;
 
     reg output_init_write;
     reg [4:0] output_init_addr;
@@ -108,12 +102,43 @@ module thermal_control_core #(
     wire [15:0] bmc_integer_scaled = ({8'd0, bmc_rd_raw[15:8]} << 6) +
         ({8'd0, bmc_rd_raw[15:8]} << 5) + ({8'd0, bmc_rd_raw[15:8]} << 2);
     wire signed [15:0] bmc_temperature = $signed(bmc_integer_scaled + {8'd0, bmc_rd_raw[7:0]});
-    wire signed [16:0] pid_error = $signed({1'b0, current_target_celsius}) * 17'sd100 - $signed(bmc_temperature);
-    wire signed [17:0] pid_sum = $signed({1'b0, pi_integral[work_index]}) + (pid_error >>> 3);
-    wire [7:0] pid_duty = (pid_sum <= 0) ? 0 : (pid_sum >= 100) ? 100 : pid_sum[7:0];
+    // One physical incremental-PI datapath services all 24 BRAM-resident
+    // channel states.  Arithmetic matches thermal-control-lab fixed_point/pi.py.
+    wire signed [16:0] pid_error_full =
+        $signed({1'b0, current_target_celsius}) * 17'sd100 - $signed(bmc_temperature);
+    wire signed [15:0] pid_error = pid_error_full[15:0];
+    wire signed [15:0] pi_previous_error = $signed(pi_state_read_data[31:16]);
+    wire signed [15:0] pi_previous_output = $signed(pi_state_read_data[15:0]);
+    wire signed [15:0] pi_delta_error = pid_error - pi_previous_error;
     wire [1:0] channel_lane = (work_index < 6) ? 0 : (work_index < 12) ? 1 :
         (work_index < 18) ? 2 : 3;
     wire [1:0] output_lane = work_index[1:0];
+    wire signed [15:0] pi_kp_q4_12 =
+        (channel_lane == 0 || channel_lane == 3) ? `FB_EDGE_KP_Q4_12 : `FB_CENTER_KP_Q4_12;
+    wire signed [15:0] pi_ki_q4_12 =
+        (channel_lane == 0 || channel_lane == 3) ? `FB_EDGE_KI_Q4_12 : `FB_CENTER_KI_Q4_12;
+    wire signed [31:0] pi_kp_product = pi_kp_q4_12 * pi_delta_error;
+    wire signed [31:0] pi_ki_product = pi_ki_q4_12 * pid_error;
+    wire signed [32:0] pi_product_sum = pi_kp_product + pi_ki_product;
+    wire signed [32:0] pi_delta_q8_8 = (pi_product_sum >= 0) ?
+        ((pi_product_sum + 33'sd8) >>> 4) :
+        -(((-pi_product_sum) + 33'sd8) >>> 4);
+    wire signed [33:0] pi_previous_output_extended =
+        {{18{pi_previous_output[15]}}, pi_previous_output};
+    wire signed [33:0] pi_delta_extended =
+        {{1{pi_delta_q8_8[32]}}, pi_delta_q8_8};
+    wire signed [33:0] pi_candidate = pi_previous_output_extended + pi_delta_extended;
+    wire signed [16:0] pi_slew_low_unclamped = $signed(pi_previous_output) - 17'sd1280;
+    wire signed [16:0] pi_slew_high_unclamped = $signed(pi_previous_output) + 17'sd1280;
+    wire signed [16:0] pi_slew_low = (pi_slew_low_unclamped < 0) ? 0 : pi_slew_low_unclamped;
+    wire signed [16:0] pi_slew_high = (pi_slew_high_unclamped > 17'sd25600) ?
+        17'sd25600 : pi_slew_high_unclamped;
+    wire signed [33:0] pi_slew_low_extended = {{17{pi_slew_low[16]}}, pi_slew_low};
+    wire signed [33:0] pi_slew_high_extended = {{17{pi_slew_high[16]}}, pi_slew_high};
+    wire [15:0] pi_applied_q8_8 = (pi_candidate < pi_slew_low_extended) ? pi_slew_low[15:0] :
+        (pi_candidate > pi_slew_high_extended) ? pi_slew_high[15:0] : pi_candidate[15:0];
+    wire [16:0] pi_rounded_duty = {1'b0, pi_applied_q8_8} + 17'd128;
+    wire [7:0] pid_duty = (pi_rounded_duty[16:8] > 100) ? 8'd100 : pi_rounded_duty[15:8];
     wire complete_valid_bmc = !bmc_stale && (&bmc_valid_mask);
     wire any_valid_bmc = !bmc_stale && (|bmc_valid_mask);
     wire new_bmc_epoch = bmc_epoch != last_bmc_epoch;
@@ -121,9 +146,11 @@ module thermal_control_core #(
     wire channel_over_77 = bmc_rd_valid && bmc_temperature >= HARD_LIMIT;
     wire channel_above_release = bmc_rd_valid && bmc_temperature > `FB_TEMP_LANE_RELEASE;
     wire [3:0] channel_lane_bit = 4'b0001 << channel_lane;
+    wire [3:0] observed_hard_mask = epoch_hard_mask |
+        (channel_over_77 ? channel_lane_bit : 4'd0);
+    wire [3:0] newly_hard_mask = observed_hard_mask & ~lane_fault_mask;
 
     assign bmc_rd_index = work_index;
-    assign stimulus_active = stimulus_running;
     assign watchdog_active = control_state == OWNER_SAFE || control_state == OWNER_MANUAL;
     assign pid_running = control_state == OWNER_PID && complete_valid_bmc;
     assign manual_mode = control_state == OWNER_MANUAL;
@@ -137,19 +164,12 @@ module thermal_control_core #(
         .read_address(work_index), .read_data(manual_data)
     );
 
-    generate if (ENABLE_STIMULUS != 0) begin : g_stimulus
-        stimulus_atomic_bank u_stimulus_bank (
-            .clk(clk), .rst_n(rst_n), .write_enable(stimulus_wr_en),
-            .write_address(stimulus_wr_addr), .write_data(stimulus_wr_data),
-            .stimulus_commit(stimulus_commit), .commit_applied(stimulus_commit_applied),
-            .active_bank(stimulus_bank_active), .read_bank(stimulus_copy_bank),
-            .read_address(work_index), .read_data(stimulus_data)
-        );
-    end else begin : g_no_stimulus
-        assign stimulus_bank_active = 1'b0;
-        assign stimulus_commit_applied = 1'b0;
-        assign stimulus_data = 8'd0;
-    end endgenerate
+    ef2_bram_dp #(.DATA_WIDTH(32), .ADDR_WIDTH(5), .DATA_DEPTH(32)) u_pi_state (
+        .clk(clk), .a_en(1'b1), .a_we(1'b0), .a_addr(work_index),
+        .a_wdata(32'd0), .a_rdata(pi_state_read_data),
+        .b_en(1'b1), .b_we(pi_state_write), .b_addr(pi_state_write_addr),
+        .b_wdata(pi_state_write_data), .b_rdata(pi_state_unused_read_data)
+    );
 
     thermal_output_banks u_output_banks (
         .clk(clk), .active_bank(active_output_bank),
@@ -174,6 +194,7 @@ module thermal_control_core #(
             global_fault <= 0;
             output_commit <= 0;
             manual_commit_done <= 0;
+            manual_commit_ok <= 0;
             watchdog_remaining <= WATCHDOG_LOAD;
             boot_init_complete <= 0;
             work_state <= W_INIT;
@@ -184,9 +205,8 @@ module thermal_control_core #(
             epoch_above_release_mask <= 0;
             manual_pending <= 0;
             safe_pending <= 0;
-            stimulus_running <= 0;
-            stimulus_remaining <= 0;
-            stimulus_copy_bank <= 0;
+            stale_hold_committed <= 0;
+            manual_request_epoch <= 0;
             output_init_write <= 0;
             output_init_addr <= 0;
             output_init_data <= 0;
@@ -194,31 +214,26 @@ module thermal_control_core #(
             output_control_addr <= 0;
             output_control_data <= 0;
             output_control_read_addr <= 0;
-            for (i = 0; i < 24; i = i + 1) pi_integral[i] <= 0;
+            pi_state_write <= 0;
+            pi_state_write_addr <= 0;
+            pi_state_write_data <= 0;
             for (i = 0; i < 4; i = i + 1) lane_release_count[i] <= 0;
         end else begin
             output_commit <= 0;
             manual_commit_done <= 0;
+            manual_commit_ok <= 0;
             output_init_write <= 0;
             output_control_write <= 0;
+            pi_state_write <= 0;
 
             if (pid_target_commit)
                 current_target_celsius <= pid_target_celsius;
-            if (manual_commit_applied)
+            if (manual_commit_applied) begin
                 manual_pending <= 1;
-            if (stimulus_commit_applied) begin
-                stimulus_running <= 1;
-                stimulus_remaining <= stimulus_duration_seconds;
-                stimulus_copy_bank <= stimulus_bank_active;
-            end else if (stimulus_running && tick_1s) begin
-                if (stimulus_remaining > 1) stimulus_remaining <= stimulus_remaining - 1'b1;
-                else begin
-                    stimulus_running <= 0;
-                    stimulus_remaining <= 0;
-                    safe_pending <= 1;
-                end
+                manual_request_epoch <= bmc_epoch;
+                safe_pending <= 0;
+                stale_hold_committed <= 0;
             end
-
             // SET_ALL acceptance dominates a simultaneous final watchdog tick.
             if (manual_commit_applied) begin
                 watchdog_remaining <= WATCHDOG_LOAD;
@@ -236,6 +251,11 @@ module thermal_control_core #(
                     output_init_write <= 1;
                     output_init_addr <= work_index;
                     output_init_data <= (work_index < 24) ? 16'h0000 : {FAN_SAFE_DUTY, FAN_SAFE_DUTY};
+                    if (work_index < 24) begin
+                        pi_state_write <= 1;
+                        pi_state_write_addr <= work_index;
+                        pi_state_write_data <= 32'd0;
+                    end
                     if (work_index == 31) begin
                         work_index <= 0;
                         work_state <= W_IDLE;
@@ -243,7 +263,16 @@ module thermal_control_core #(
                     end else work_index <= work_index + 1'b1;
                 end
                 W_IDLE: begin
-                    if (manual_pending) begin
+                    if (any_valid_bmc && new_bmc_epoch) begin
+                        last_bmc_epoch <= bmc_epoch;
+                        work_index <= 0;
+                        safety_override_mask <= 0;
+                        epoch_hard_mask <= 0;
+                        epoch_above_release_mask <= 0;
+                        global_fault <= 0;
+                        stale_hold_committed <= 0;
+                        work_state <= W_SAFETY_PREFETCH;
+                    end else if (manual_pending || manual_commit_applied) begin
                         manual_pending <= 0;
                         work_index <= 0;
                         global_fault <= 0;
@@ -254,23 +283,11 @@ module thermal_control_core #(
                         work_index <= 0;
                         commit_kind <= COMMIT_SAFE;
                         work_state <= W_SAFE_FILL;
-                    end else if (stimulus_running) begin
-                        work_index <= 0;
-                        commit_kind <= COMMIT_MANUAL;
-                        work_state <= W_STIM_COPY;
-                    end else if (control_state == OWNER_PID && bmc_stale) begin
+                    end else if (control_state == OWNER_PID && bmc_stale && !stale_hold_committed) begin
                         global_fault <= 1;
                         work_index <= 0;
                         commit_kind <= COMMIT_SAFE;
                         work_state <= W_SAFE_FILL;
-                    end else if (any_valid_bmc && new_bmc_epoch) begin
-                        last_bmc_epoch <= bmc_epoch;
-                        work_index <= 0;
-                        safety_override_mask <= 0;
-                        epoch_hard_mask <= 0;
-                        epoch_above_release_mask <= 0;
-                        global_fault <= 0;
-                        work_state <= W_SAFETY_PREFETCH;
                     end
                 end
                 W_SAFETY_PREFETCH: begin
@@ -306,8 +323,13 @@ module thermal_control_core #(
                             end
                         end
                         work_index <= 0;
-                        if (|lane_fault_mask || |epoch_hard_mask || channel_over_77) begin
+                        if (|newly_hard_mask) begin
                             control_state <= OWNER_PID;
+                            if (manual_pending) begin
+                                manual_pending <= 0;
+                                manual_commit_done <= 1;
+                                manual_commit_ok <= 0;
+                            end
                             commit_kind <= COMMIT_SAFE;
                             work_state <= W_SAFE_FILL;
                         end else if (control_state == OWNER_PID && complete_valid_bmc) begin
@@ -327,31 +349,46 @@ module thermal_control_core #(
                         work_state <= W_SAFETY_PREFETCH;
                     end
                 end
-                W_MANUAL_COPY, W_STIM_COPY: begin
-                    output_control_write <= 1;
-                    output_control_addr <= work_index;
-                    if (work_index < 24)
-                        output_control_data <= {
-                            (work_state == W_MANUAL_COPY) ? manual_data : stimulus_data,
-                            (lane_fault_mask[channel_lane] ||
-                             (!bmc_stale && safety_override_mask[work_index])) ? 8'd0 :
-                                ((work_state == W_MANUAL_COPY) ? manual_data : stimulus_data)};
-                    else
-                        output_control_data <= {
-                            (work_state == W_MANUAL_COPY) ? manual_data : stimulus_data,
-                            lane_fault_mask[output_lane] ? 8'd100 :
-                                ((work_state == W_MANUAL_COPY) ? manual_data : stimulus_data)};
-                    if (work_index == 31) begin
+                W_MANUAL_COPY: begin
+                    if (hard_protect) begin
+                        commit_kind <= COMMIT_NONE;
+                        manual_commit_done <= 1;
+                        manual_commit_ok <= 0;
+                        work_state <= W_IDLE;
+                    end else if (any_valid_bmc && bmc_epoch != manual_request_epoch) begin
+                        manual_pending <= 1;
+                        manual_request_epoch <= bmc_epoch;
+                        last_bmc_epoch <= bmc_epoch;
                         work_index <= 0;
-                        work_state <= W_COMMIT_WAIT;
-                    end else work_index <= work_index + 1'b1;
+                        safety_override_mask <= 0;
+                        epoch_hard_mask <= 0;
+                        epoch_above_release_mask <= 0;
+                        commit_kind <= COMMIT_NONE;
+                        work_state <= W_SAFETY_PREFETCH;
+                    end else begin
+                        output_control_write <= 1;
+                        output_control_addr <= work_index;
+                        if (work_index < 24)
+                            output_control_data <= {manual_data,
+                                (!bmc_stale && safety_override_mask[work_index]) ? 8'd0 : manual_data};
+                        else
+                            output_control_data <= {manual_data, manual_data};
+                        if (work_index == 31) begin
+                            work_index <= 0;
+                            work_state <= W_COMMIT_WAIT;
+                        end else work_index <= work_index + 1'b1;
+                    end
                 end
                 W_SAFE_FILL: begin
                     output_control_write <= 1;
                     output_control_addr <= work_index;
                     output_control_data <= (work_index < 24) ? 16'h0000 :
                         {FAN_SAFE_DUTY, lane_fault_mask[output_lane] ? 8'd100 : FAN_SAFE_DUTY};
-                    if (work_index < 24) pi_integral[work_index] <= 0;
+                    if (work_index < 24) begin
+                        pi_state_write <= 1;
+                        pi_state_write_addr <= work_index;
+                        pi_state_write_data <= 32'd0;
+                    end
                     if (work_index == 31) begin
                         work_index <= 0;
                         work_state <= W_COMMIT_WAIT;
@@ -366,10 +403,13 @@ module thermal_control_core #(
                     if (!bmc_rd_valid) begin
                         output_control_data <= 16'h0000;
                         safety_override_mask[work_index] <= 1;
-                        pi_integral[work_index] <= 0;
                     end else begin
                         output_control_data <= {pid_duty, pid_duty};
-                        pi_integral[work_index] <= (pid_sum <= 0) ? 0 : (pid_sum >= 100) ? 100 : pid_sum[15:0];
+                        if (!safety_override_mask[work_index] && !lane_fault_mask[channel_lane]) begin
+                            pi_state_write <= 1;
+                            pi_state_write_addr <= work_index;
+                            pi_state_write_data <= {pid_error, pi_applied_q8_8};
+                        end
                     end
                     if (work_index == 23) begin
                         work_index <= 24;
@@ -421,22 +461,44 @@ module thermal_control_core #(
                         work_state <= W_APPLY_PREFETCH;
                     end
                 end
-                W_COMMIT_WAIT: if (pwm_phase_boundary && pwm_scan_idle && !snapshot_lock) begin
-                    active_output_bank <= ~active_output_bank;
-                    output_commit <= 1;
-                    control_epoch <= control_epoch + 1'b1;
-                    if (commit_kind == COMMIT_MANUAL) begin
+                W_COMMIT_WAIT: begin
+                    if (commit_kind == COMMIT_MANUAL && hard_protect) begin
                         manual_commit_done <= 1;
-                        control_state <= OWNER_MANUAL;
-                        watchdog_remaining <= WATCHDOG_LOAD;
-                    end else if (commit_kind == COMMIT_SAFE) begin
-                        control_state <= OWNER_PID;
-                        watchdog_remaining <= 0;
-                    end else if (commit_kind == COMMIT_PID) begin
-                        control_state <= OWNER_PID;
+                        manual_commit_ok <= 0;
+                        commit_kind <= COMMIT_NONE;
+                        work_state <= W_IDLE;
+                    end else if (commit_kind == COMMIT_MANUAL && any_valid_bmc &&
+                                 bmc_epoch != manual_request_epoch) begin
+                        manual_pending <= 1;
+                        manual_request_epoch <= bmc_epoch;
+                        last_bmc_epoch <= bmc_epoch;
+                        work_index <= 0;
+                        safety_override_mask <= 0;
+                        epoch_hard_mask <= 0;
+                        epoch_above_release_mask <= 0;
+                        commit_kind <= COMMIT_NONE;
+                        work_state <= W_SAFETY_PREFETCH;
+                    end else if (pwm_phase_boundary && pwm_scan_idle && !snapshot_lock) begin
+                        active_output_bank <= ~active_output_bank;
+                        output_commit <= 1;
+                        control_epoch <= control_epoch + 1'b1;
+                        if (commit_kind == COMMIT_MANUAL) begin
+                            manual_commit_done <= 1;
+                            manual_commit_ok <= 1;
+                            control_state <= OWNER_MANUAL;
+                            watchdog_remaining <= WATCHDOG_LOAD;
+                            stale_hold_committed <= 0;
+                        end else if (commit_kind == COMMIT_SAFE) begin
+                            control_state <= OWNER_PID;
+                            watchdog_remaining <= 0;
+                            stale_hold_committed <= 1;
+                        end else if (commit_kind == COMMIT_PID) begin
+                            control_state <= OWNER_PID;
+                            stale_hold_committed <= 0;
+                        end
+                        commit_kind <= COMMIT_NONE;
+                        work_state <= W_IDLE;
                     end
-                    commit_kind <= COMMIT_NONE;
-                    work_state <= W_IDLE;
                 end
                 default: work_state <= W_INIT;
             endcase

+ 2 - 2
src/generated/6400/td-source-manifest.json

@@ -61,7 +61,7 @@
   "project_id": "prod2u-6400-front-back",
   "release_status": "release-ready",
   "schema": "prod2u-simple-source-manifest-template-v1",
-  "source_manifest_sha256": "bca51a21d743da77ac56bc8e63d4b7520f9ec36e0d0ecb61f987bbf07f0b46f6",
+  "source_manifest_sha256": "db89aaa98a646f0ce4f2a9e7779e0d970a8403302b48a1a6fa8ee9623bee8b52",
   "sources": [
     "src/generated/6400/prod2u_6400_front_back_params.vh",
     "src/common/uart_rx_byte.v",
@@ -83,7 +83,7 @@
     "src/rtl/prod2u_p4_i2c_stop_start_read.v",
     "src/top/prod2u_6400_front_back_top.v"
   ],
-  "superseded_by": "products/6400-control/source-closure.json",
+  "superseded_by": "products/6400-front-rear/source-closure.json",
   "target_alias": "6400",
   "top_module": "prod2u_6400_front_back_top",
   "unresolved_pins": []

+ 11 - 24
src/top/prod2u_6400_v1_top.v

@@ -2,7 +2,6 @@
 `include "generated/6400/prod2u_6400_v1_params.vh"
 
 module prod2u_6400_v1_top #(
-    parameter integer ENABLE_STIMULUS = 0,
     parameter integer CT_SCAN_PERIOD_CLKS = 2500000,
     parameter integer HOST_INTER_BYTE_TIMEOUT_CLKS = 250000,
     parameter integer HOST_IDLE_UNLOCK_CLKS = 1250000,
@@ -50,13 +49,9 @@ module prod2u_6400_v1_top #(
     wire [7:0] manual_wr_data;
     wire manual_commit;
     wire manual_commit_done;
+    wire manual_commit_ok;
     wire pid_target_commit;
     wire [7:0] pid_target_celsius;
-    wire stimulus_wr_en;
-    wire [4:0] stimulus_wr_addr;
-    wire [7:0] stimulus_wr_data;
-    wire stimulus_commit;
-    wire [7:0] stimulus_duration;
     wire snapshot_capture;
     wire snapshot_ready;
     wire snapshot_locked;
@@ -158,7 +153,6 @@ module prod2u_6400_v1_top #(
     wire [3:0] lane_fault_mask;
     wire global_fault;
     wire output_commit;
-    wire stimulus_active;
     wire boot_init_complete;
     wire watchdog_active;
     wire [7:0] watchdog_remaining;
@@ -195,7 +189,7 @@ module prod2u_6400_v1_top #(
         .clk(sys_clk), .rst_n(rst_n), .rx_i(selected_host_rx), .byte_valid(host_rx_valid),
         .byte_data(host_rx_data), .framing_error(host_rx_error)
     );
-    frame_rx #(.MAX_PAYLOAD(33),
+    frame_rx #(.MAX_PAYLOAD(32),
         .INTER_BYTE_TIMEOUT_CYCLES(HOST_INTER_BYTE_TIMEOUT_CLKS),
         .EXTERNAL_CRC(1)) u_frame_rx (
         .clk(sys_clk), .rst_n(rst_n), .byte_valid(host_rx_valid), .byte_data(host_rx_data),
@@ -207,21 +201,20 @@ module prod2u_6400_v1_top #(
         .crc_data_o(host_rx_crc_data), .crc_busy_i(host_crc_busy),
         .crc_data_done_i(host_crc_data_done), .crc_value_i(host_crc_value)
     );
-    payload_ram #(.DEPTH(33), .ADDR_WIDTH(8)) u_payload (
+    payload_ram #(.DEPTH(32), .ADDR_WIDTH(8)) u_payload (
         .clk(sys_clk), .wr_en(payload_wr_en), .wr_addr(payload_wr_addr), .wr_data(payload_wr_data),
         .rd_addr(payload_rd_addr), .rd_data(payload_rd_data)
     );
-    thermal_host_command #(.ENABLE_STIMULUS(ENABLE_STIMULUS), .SNAPSHOT_LENGTH(`FB_SNAPSHOT_LENGTH)) u_command (
+    thermal_host_command #(.SNAPSHOT_LENGTH(`FB_SNAPSHOT_LENGTH)) u_command (
         .clk(sys_clk), .rst_n(rst_n), .frame_valid(frame_valid), .frame_ready(frame_ready),
         .frame_accept_enable(frame_accept_enable), .frame_type(frame_type), .frame_length(frame_length),
         .payload_read_addr(payload_rd_addr), .payload_read_data(payload_rd_data),
         .manual_wr_en(manual_wr_en), .manual_wr_addr(manual_wr_addr),
         .manual_wr_data(manual_wr_data), .manual_commit(manual_commit),
-        .manual_commit_done(manual_commit_done), .safety_locked(hard_protect),
+        .manual_commit_done(manual_commit_done), .manual_commit_ok(manual_commit_ok),
+        .safety_locked(hard_protect),
         .pid_target_commit(pid_target_commit), .pid_target_celsius(pid_target_celsius),
-        .stimulus_wr_en(stimulus_wr_en), .stimulus_wr_addr(stimulus_wr_addr),
-        .stimulus_wr_data(stimulus_wr_data), .stimulus_commit(stimulus_commit),
-        .stimulus_duration_seconds(stimulus_duration), .snapshot_capture(snapshot_capture),
+        .snapshot_capture(snapshot_capture),
         .snapshot_ready(snapshot_ready), .tx_start(tx_start), .tx_frame_type(tx_frame_type),
         .tx_payload_length(tx_payload_length), .tx_payload_addr(frame_tx_payload_addr),
         .ack_payload_data(ack_payload_data), .tx_done(host_response_done),
@@ -297,18 +290,12 @@ module prod2u_6400_v1_top #(
         .sda_i(temp_sda), .scl_drive_low(ct_scl_drive_low), .sda_drive_low(ct_sda_drive_low)
     );
 
-    thermal_control_core #(
-        .ENABLE_STIMULUS(ENABLE_STIMULUS),
-        .FAN_SAFE_DUTY(FAN_STANDBY_DUTY)
-    ) u_control (
+    thermal_control_core #(.FAN_SAFE_DUTY(FAN_STANDBY_DUTY)) u_control (
         .clk(sys_clk), .rst_n(rst_n), .tick_1s(tick_1s),
         .manual_wr_en(manual_wr_en), .manual_wr_addr(manual_wr_addr),
         .manual_wr_data(manual_wr_data), .manual_commit(manual_commit),
-        .manual_commit_done(manual_commit_done),
+        .manual_commit_done(manual_commit_done), .manual_commit_ok(manual_commit_ok),
         .pid_target_commit(pid_target_commit), .pid_target_celsius(pid_target_celsius),
-        .stimulus_wr_en(stimulus_wr_en),
-        .stimulus_wr_addr(stimulus_wr_addr), .stimulus_wr_data(stimulus_wr_data),
-        .stimulus_commit(stimulus_commit), .stimulus_duration_seconds(stimulus_duration),
         .bmc_epoch(bmc_epoch), .bmc_stale(bmc_stale), .bmc_valid_mask(bmc_valid_mask),
         .bmc_rd_index(bmc_control_index), .bmc_rd_raw(bmc_control_raw),
         .bmc_rd_valid(bmc_control_valid), .ct_epoch(ct_epoch), .ct_stale(ct_stale),
@@ -320,7 +307,7 @@ module prod2u_6400_v1_top #(
         .control_state(control_state), .current_target_celsius(current_target),
         .control_epoch(control_epoch),
         .safety_override_mask(safety_mask), .lane_fault_mask(lane_fault_mask),
-        .global_fault(global_fault), .output_commit(output_commit), .stimulus_active(stimulus_active),
+        .global_fault(global_fault), .output_commit(output_commit),
         .watchdog_active(watchdog_active), .watchdog_remaining(watchdog_remaining),
         .pid_running(pid_running), .manual_mode(manual_mode), .hard_protect(hard_protect),
         .pwm_phase_boundary(pwm_boundary_advance), .pwm_scan_idle(pwm_scan_idle),
@@ -360,7 +347,7 @@ module prod2u_6400_v1_top #(
         host_rs232_rx_sync, host_ttl_rx_sync, host_command_busy, frame_tx_done, bmc_tx_done,
         bmc_poll_count, bmc_snapshot_commit, ct_snapshot_commit, ct_i2c_busy, ct_control_raw,
         ct_control_valid, bmc_snapshot_valid, ct_snapshot_valid, output_commit,
-        stimulus_active, pwm_boundary, pwm_boundary_advance, pwm_phase, pwm_scan_idle, host_crc_request_conflict,
+        pwm_boundary, pwm_boundary_advance, pwm_phase, pwm_scan_idle, host_crc_request_conflict,
         boot_init_complete, watchdog_active, watchdog_remaining, pid_running, manual_mode, hard_protect};
 
 `ifdef FORMAL

+ 15 - 61
src/transport/thermal_host_command.v

@@ -4,7 +4,6 @@
 // One outstanding Host request. frame_valid is asserted only after the shared
 // frame receiver has accepted a complete CRC-correct request.
 module thermal_host_command #(
-    parameter integer ENABLE_STIMULUS = 0,
     parameter integer SNAPSHOT_LENGTH = `FB_SNAPSHOT_LENGTH
 ) (
     input  wire       clk,
@@ -21,14 +20,10 @@ module thermal_host_command #(
     output reg  [7:0] manual_wr_data,
     output reg        manual_commit,
     input  wire       manual_commit_done,
+    input  wire       manual_commit_ok,
     input  wire       safety_locked,
     output reg        pid_target_commit,
     output reg  [7:0] pid_target_celsius,
-    output reg        stimulus_wr_en,
-    output reg  [4:0] stimulus_wr_addr,
-    output reg  [7:0] stimulus_wr_data,
-    output reg        stimulus_commit,
-    output reg  [7:0] stimulus_duration_seconds,
     output reg        snapshot_capture,
     input  wire       snapshot_ready,
     output reg        tx_start,
@@ -42,8 +37,7 @@ module thermal_host_command #(
 );
     localparam [4:0] ST_IDLE = 0, ST_SET_VALIDATE = 1, ST_SET_WRITE = 2,
         ST_SET_COMMIT = 3, ST_SET_WAIT = 4, ST_PID_READ = 5,
-        ST_STIM_DURATION = 6, ST_STIM_VALIDATE = 7, ST_STIM_WRITE = 8,
-        ST_STIM_COMMIT = 9, ST_SNAPSHOT_WAIT = 10, ST_ACK_TX = 11,
+        ST_SNAPSHOT_WAIT = 10, ST_ACK_TX = 11,
         ST_SNAPSHOT_DATA_TX = 12, ST_DROP = 13;
 
     reg [4:0] state;
@@ -94,11 +88,6 @@ module thermal_host_command #(
             manual_commit <= 0;
             pid_target_commit <= 0;
             pid_target_celsius <= `DEFAULT_PID_TARGET_C;
-            stimulus_wr_en <= 0;
-            stimulus_wr_addr <= 0;
-            stimulus_wr_data <= 0;
-            stimulus_commit <= 0;
-            stimulus_duration_seconds <= 0;
             snapshot_capture <= 0;
             tx_start <= 0;
             tx_frame_type <= `FB_RSP_ACK_NACK;
@@ -112,8 +101,6 @@ module thermal_host_command #(
             manual_wr_en <= 0;
             manual_commit <= 0;
             pid_target_commit <= 0;
-            stimulus_wr_en <= 0;
-            stimulus_commit <= 0;
             snapshot_capture <= 0;
             tx_start <= 0;
             transaction_done <= 0;
@@ -139,13 +126,8 @@ module thermal_host_command #(
                     end else if (frame_type == `FB_CMD_SET_STIMULUS) begin
                         if (frame_length != 8'd33)
                             start_ack(0, frame_type, `FB_STATUS_BAD_LENGTH, 8'd33);
-                        else if (ENABLE_STIMULUS == 0)
+                        else
                             start_ack(0, frame_type, `FB_STATUS_UNSUPPORTED, 0);
-                        else begin
-                            index <= 0;
-                            payload_read_addr <= 0;
-                            state <= ST_STIM_DURATION;
-                        end
                     end else if (frame_type == `FB_CMD_SET_PID_TARGET) begin
                         if (frame_length != 1)
                             start_ack(0, frame_type, `FB_STATUS_BAD_LENGTH, 1);
@@ -180,11 +162,19 @@ module thermal_host_command #(
                     end
                 end
                 ST_SET_COMMIT: begin
-                    manual_commit <= 1;
-                    state <= ST_SET_WAIT;
+                    if (safety_locked)
+                        start_ack(0, `FB_CMD_SET_ALL, `FB_STATUS_SAFETY_LOCKED, 0);
+                    else begin
+                        manual_commit <= 1;
+                        state <= ST_SET_WAIT;
+                    end
+                end
+                ST_SET_WAIT: if (manual_commit_done) begin
+                    if (manual_commit_ok)
+                        start_ack(1, `FB_CMD_SET_ALL, `FB_STATUS_OK, 0);
+                    else
+                        start_ack(0, `FB_CMD_SET_ALL, `FB_STATUS_SAFETY_LOCKED, 0);
                 end
-                ST_SET_WAIT: if (manual_commit_done)
-                    start_ack(1, `FB_CMD_SET_ALL, `FB_STATUS_OK, 0);
                 ST_PID_READ: begin
                     if (payload_read_data < 20 || payload_read_data > 70)
                         start_ack(0, `FB_CMD_SET_PID_TARGET, `FB_STATUS_BAD_VALUE, 0);
@@ -194,42 +184,6 @@ module thermal_host_command #(
                         start_ack(1, `FB_CMD_SET_PID_TARGET, `FB_STATUS_OK, 0);
                     end
                 end
-                ST_STIM_DURATION: begin
-                    stimulus_duration_seconds <= payload_read_data;
-                    if (payload_read_data == 0)
-                        start_ack(0, `FB_CMD_SET_STIMULUS, `FB_STATUS_BAD_VALUE, 0);
-                    else begin
-                        index <= 1;
-                        payload_read_addr <= 1;
-                        state <= ST_STIM_VALIDATE;
-                    end
-                end
-                ST_STIM_VALIDATE: begin
-                    if (payload_read_data > 100)
-                        start_ack(0, `FB_CMD_SET_STIMULUS, `FB_STATUS_BAD_VALUE, {2'd0, index});
-                    else if (index == 32) begin
-                        index <= 1;
-                        payload_read_addr <= 1;
-                        state <= ST_STIM_WRITE;
-                    end else begin
-                        index <= index + 1'b1;
-                        payload_read_addr <= index + 1'b1;
-                    end
-                end
-                ST_STIM_WRITE: begin
-                    stimulus_wr_en <= 1;
-                    stimulus_wr_addr <= index[4:0] - 1'b1;
-                    stimulus_wr_data <= payload_read_data;
-                    if (index == 32) state <= ST_STIM_COMMIT;
-                    else begin
-                        index <= index + 1'b1;
-                        payload_read_addr <= index + 1'b1;
-                    end
-                end
-                ST_STIM_COMMIT: begin
-                    stimulus_commit <= 1;
-                    start_ack(1, `FB_CMD_SET_STIMULUS, `FB_STATUS_OK, 0);
-                end
                 ST_SNAPSHOT_WAIT: if (snapshot_ready)
                     start_ack(1, `FB_CMD_GET_SNAPSHOT, `FB_STATUS_OK, 0);
                 ST_ACK_TX: if (tx_done) begin

+ 0 - 1
td/syn/prod2u_6400_front_back.tcl

@@ -37,7 +37,6 @@ analyze_src {src/acquisition/bmc_ascii_snapshot.v}
 analyze_src {src/acquisition/ct7428_snapshot.v}
 analyze_src {src/control/thermal_output_banks.v}
 analyze_src {src/control/manual_set_all_bank.v}
-analyze_src {src/control/stimulus_atomic_bank.v}
 analyze_src {src/control/thermal_control_core.v}
 analyze_src {src/actuator/pwm_bitmap_engine.v}
 analyze_src {src/actuator/fan_board_output_adapter.v}

+ 0 - 4
tests/cocotb/prod2u_6400_v1_cocotb_top.v

@@ -4,7 +4,6 @@
 // only the CT7428 word-level response is modeled so 27-channel scans remain
 // deterministic and fast enough for integration testing.
 module prod2u_6400_v1_cocotb_top #(
-    parameter integer ENABLE_STIMULUS = 0,
     parameter [15:0] BMC_INITIAL_EPOCH = 16'd0
 ) (
     input  wire        host_rs232_rx,
@@ -31,7 +30,6 @@ module prod2u_6400_v1_cocotb_top #(
     output wire [23:0] safety_mask_mon,
     output wire [3:0]  lane_fault_mask_mon,
     output wire        global_fault_mon,
-    output wire        stimulus_active_mon,
     output wire [7:0]  current_target_mon,
     output wire        host_locked_mon,
     output wire        host_port_sel_mon,
@@ -49,7 +47,6 @@ module prod2u_6400_v1_cocotb_top #(
     tri1 temp_sda;
 
     prod2u_6400_v1_top #(
-        .ENABLE_STIMULUS(ENABLE_STIMULUS),
         .BMC_INITIAL_EPOCH(BMC_INITIAL_EPOCH),
         .CT_SCAN_PERIOD_CLKS(64),
         .HOST_INTER_BYTE_TIMEOUT_CLKS(512),
@@ -110,7 +107,6 @@ module prod2u_6400_v1_cocotb_top #(
     assign safety_mask_mon = u_dut.safety_mask;
     assign lane_fault_mask_mon = u_dut.lane_fault_mask;
     assign global_fault_mon = u_dut.global_fault;
-    assign stimulus_active_mon = u_dut.stimulus_active;
     assign current_target_mon = u_dut.current_target;
     assign host_locked_mon = u_dut.host_locked;
     assign host_port_sel_mon = u_dut.host_port_sel;

+ 7 - 2
tests/cocotb/run_6400_pi_differential.py

@@ -16,26 +16,31 @@ except ModuleNotFoundError:
 
 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 = ROOT.parent / "thermal-control-lab" / "thermal_control_lab" / "fixed_point" / "pi.py"
+    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/stimulus_atomic_bank.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,
         )

+ 6 - 8
tests/cocotb/run_6400_v1_integration.py

@@ -1,5 +1,5 @@
 #!/usr/bin/env python3
-"""Run control and identification full-top cocotb integration profiles."""
+"""Run focused single-product full-top cocotb test suites."""
 
 from __future__ import annotations
 
@@ -18,7 +18,7 @@ except ModuleNotFoundError:  # cocotb 1.9 compatibility in the pinned image
 
 ROOT = Path(__file__).resolve().parents[2]
 TEST_DIR = Path(__file__).resolve().parent
-CLOSURE = ROOT / "products/6400-control/source-closure.json"
+CLOSURE = ROOT / "products/6400-front-rear/source-closure.json"
 WRAPPER = TEST_DIR / "prod2u_6400_v1_cocotb_top.v"
 
 
@@ -27,7 +27,7 @@ def rtl_sources() -> list[Path]:
     return [ROOT / item for item in payload["sources"] if item.endswith(".v")]
 
 
-def run_profile(name: str, enable_stimulus: int, build_dir: Path) -> None:
+def run_suite(name: str, build_dir: Path) -> None:
     os.environ["HYPOTHESIS_STORAGE_DIRECTORY"] = str(build_dir / "hypothesis")
     runner = get_runner("icarus")
     runner.build(
@@ -35,7 +35,6 @@ def run_profile(name: str, enable_stimulus: int, build_dir: Path) -> None:
         hdl_toplevel="prod2u_6400_v1_cocotb_top",
         build_dir=build_dir,
         build_args=["-g2012", "-I", str(ROOT)],
-        parameters={"ENABLE_STIMULUS": enable_stimulus},
         always=True,
     )
     results_path = build_dir / "results.xml"
@@ -66,17 +65,16 @@ def main(argv: list[str] | None = None) -> int:
         metavar="PROFILE",
     )
     args = parser.parse_args(argv)
-    supported = {"control", "identification", "host_protocol"}
+    supported = {"control", "host_protocol"}
     invalid = [profile for profile in args.profiles if profile not in supported]
     if invalid:
         parser.error(f"unsupported profile: {invalid[0]}")
     profiles = args.profiles or ("host_protocol",)
-    stimulus = {"control": 0, "identification": 1, "host_protocol": 0}
     with tempfile.TemporaryDirectory(prefix="prod2u-6400-cocotb-") as directory:
         root = Path(directory)
         for profile in profiles:
-            run_profile(profile, stimulus[profile], root / profile)
-    print(f"PASS: 6400 cocotb integration profiles: {', '.join(profiles)}")
+            run_suite(profile, root / profile)
+    print(f"PASS: 6400-front-rear cocotb suites: {', '.join(profiles)}")
     return 0
 
 

+ 112 - 269
tests/cocotb/test_6400_pi_differential.py

@@ -1,20 +1,20 @@
-"""L7 bit-exact differential checks against the thermal-control-lab model."""
+"""Current 6400 bit-exact PI differential against the canonical lab model."""
 
 from __future__ import annotations
 
 from pathlib import Path
+import os
 import sys
 
 import cocotb
-from cocotb.triggers import FallingEdge, ReadOnly, RisingEdge, Timer, with_timeout
+from cocotb.triggers import FallingEdge, ReadOnly, RisingEdge, with_timeout
 
 
 ROOT = Path(__file__).resolve().parents[2]
-LAB_ROOT = ROOT.parent / "thermal-control-lab"
-if not LAB_ROOT.is_dir():
-    raise RuntimeError(f"thermal-control-lab sibling is required for L7: {LAB_ROOT}")
+LAB_ROOT = Path(os.environ.get(
+    "THERMAL_CONTROL_LAB_ROOT", "/root/workspaces/thermal-system/thermal-control-lab"
+))
 sys.path.insert(0, str(LAB_ROOT))
-
 from thermal_control_lab.fixed_point import ControllerBank, PIConfig  # noqa: E402
 
 
@@ -22,319 +22,162 @@ FULL_VALID = (1 << 24) - 1
 
 
 def raw_from_centi(value: int) -> int:
-    if not 0 <= value <= 25_499:
-        raise ValueError(f"BMC test temperature out of range: {value}")
     integer, fraction = divmod(value, 100)
     return (integer << 8) | fraction
 
 
-def errors_for(target_c: int, temperatures: list[int]) -> list[int]:
-    return [target_c * 100 - value for value in temperatures]
-
-
-async def clock_cycles(dut, count: int) -> None:
+async def cycles(dut, count: int) -> None:
     for _ in range(count):
         await RisingEdge(dut.sys_clk)
 
 
-async def wait_for(dut, predicate, *, cycles: int, label: str) -> None:
-    for _ in range(cycles):
+async def pulse(dut, signal) -> None:
+    await FallingEdge(dut.sys_clk)
+    signal.value = 1
+    await FallingEdge(dut.sys_clk)
+    signal.value = 0
+
+
+async def wait_value(dut, signal, value: int, limit: int, label: str) -> None:
+    for _ in range(limit):
         await RisingEdge(dut.sys_clk)
         await ReadOnly()
-        if predicate():
+        if int(signal.value) == value:
             return
     raise AssertionError(f"timeout waiting for {label}")
 
 
-async def load_temperatures(dut, temperatures: list[int]) -> None:
-    assert len(temperatures) == 24
+async def load_epoch(dut, epoch: int, temperatures: list[int], valid_mask: int = FULL_VALID) -> None:
     await FallingEdge(dut.sys_clk)
     dut.bmc_wr_en.value = 1
-    for index, value in enumerate(temperatures):
+    for index, temperature in enumerate(temperatures):
         dut.bmc_wr_index.value = index
-        dut.bmc_wr_raw.value = raw_from_centi(value)
+        dut.bmc_wr_raw.value = raw_from_centi(temperature)
         await FallingEdge(dut.sys_clk)
     dut.bmc_wr_en.value = 0
-
-
-async def set_epoch(
-    dut,
-    epoch: int,
-    temperatures: list[int],
-    *,
-    valid_mask: int = FULL_VALID,
-) -> None:
-    await load_temperatures(dut, temperatures)
-    await FallingEdge(dut.sys_clk)
     dut.bmc_valid_mask_test.value = valid_mask
-    dut.bmc_epoch_test.value = epoch & 0xFFFF
+    dut.bmc_epoch_test.value = epoch
 
 
-async def wait_commit(dut, previous_count: int, label: str) -> None:
-    await wait_for(
-        dut,
-        lambda: int(dut.commit_count_mon.value) > previous_count,
-        cycles=500,
-        label=label,
-    )
+async def wait_commit(dut, before: int, label: str) -> None:
+    for _ in range(500):
+        await RisingEdge(dut.sys_clk)
+        await ReadOnly()
+        if int(dut.commit_count_mon.value) > before:
+            return
+    raise AssertionError(f"timeout waiting for {label}")
 
 
-async def read_outputs(dut) -> tuple[list[int], list[int], list[int], list[int]]:
-    requested: list[int] = []
-    applied: list[int] = []
-    previous_error: list[int] = []
-    previous_output: list[int] = []
+async def read_outputs_and_state(dut) -> tuple[list[int], list[int], list[int]]:
+    outputs: list[int] = []
+    errors: list[int] = []
+    state_outputs: list[int] = []
     for index in range(32):
         await FallingEdge(dut.sys_clk)
         dut.rd_index.value = index
         await RisingEdge(dut.sys_clk)
         await ReadOnly()
-        requested.append(int(dut.requested_data.value))
-        applied.append(int(dut.applied_data.value))
+        outputs.append(int(dut.applied_data.value))
         if index < 24:
-            error = int(dut.previous_error_data.value)
-            previous_error.append(error - 0x10000 if error & 0x8000 else error)
-            previous_output.append(int(dut.previous_output_data.value))
-    return requested, applied, previous_error, previous_output
-
-
-async def compare_epoch(
-    dut,
-    model: ControllerBank,
-    epoch: int,
-    temperatures: list[int],
-    *,
-    target_c: int = 70,
-    valid_mask: int = FULL_VALID,
-    override: list[bool] | None = None,
-    expected_fans: list[int] | None = None,
-    label: str,
-) -> tuple[list[int], list[int]]:
+            raw_error = int(dut.previous_error_data.value)
+            errors.append(raw_error - 0x10000 if raw_error & 0x8000 else raw_error)
+            state_outputs.append(int(dut.previous_output_data.value))
+    return outputs, errors, state_outputs
+
+
+async def compare_epoch(dut, model: ControllerBank, epoch: int, temperatures: list[int], label: str) -> None:
     before = int(dut.commit_count_mon.value)
-    await set_epoch(dut, epoch, temperatures, valid_mask=valid_mask)
+    await load_epoch(dut, epoch, temperatures)
     await wait_commit(dut, before, label)
-    valid = [bool(valid_mask & (1 << index)) for index in range(24)]
-    expected = model.update(
-        epoch,
-        errors_for(target_c, temperatures),
-        valid,
-        safety_override=override,
-    )
-    requested, applied, previous_error, previous_output = await read_outputs(dut)
-    assert applied[:24] == expected, f"{label}: applied RTL/Python mismatch"
-    assert all(0 <= value <= 100 for value in requested + applied)
-    if override is None and valid_mask == FULL_VALID:
-        assert requested[:24] == expected, f"{label}: requested RTL/Python mismatch"
-        expected_state_error = [state.previous_error_centi for state in model.states]
-        expected_state_output = [state.previous_output_q8_8 for state in model.states]
-        assert previous_error == expected_state_error, f"{label}: error-state mismatch"
-        assert previous_output == expected_state_output, f"{label}: output-state mismatch"
-    fans = expected_fans or [30] * 8
-    assert applied[24:] == fans, f"{label}: fan safety mismatch"
-    return requested, applied
-
-
-async def bootstrap_auto(dut, temperatures: list[int], start_epoch: int = 1) -> int:
-    await wait_for(
-        dut,
-        lambda: int(dut.control_state.value) == 2,
-        cycles=50,
-        label="PREHEAT_CT",
-    )
-    await set_epoch(dut, start_epoch, temperatures)
-    await wait_for(
-        dut,
-        lambda: int(dut.control_state.value) == 3,
-        cycles=50,
-        label="WAIT_BMC_STABLE",
-    )
-    for epoch in (start_epoch + 1, start_epoch + 2):
-        await set_epoch(dut, epoch, temperatures)
-        await clock_cycles(dut, 8)
-    return start_epoch + 3
+    expected = model.update(epoch, [7000 - value for value in temperatures], [True] * 24)
+    outputs, errors, state_outputs = await read_outputs_and_state(dut)
+    assert outputs[:24] == expected, f"{label}: output mismatch"
+    assert outputs[24:] == [20] * 8, f"{label}: fan policy mismatch"
+    assert errors == [state.previous_error_centi for state in model.states]
+    assert state_outputs == [state.previous_output_q8_8 for state in model.states]
 
 
 @cocotb.test()
-async def test_pi_python_rtl_differential_safety_epoch_target_and_recovery(dut):
+async def test_current_incremental_pi_epoch_manual_and_stale_semantics(dut):
     dut.tick_1s_test.value = 0
     dut.target_commit_test.value = 0
     dut.target_celsius_test.value = 70
+    dut.manual_wr_en_test.value = 0
+    dut.manual_wr_addr_test.value = 0
+    dut.manual_wr_data_test.value = 0
+    dut.manual_commit_test.value = 0
     dut.bmc_epoch_test.value = 0
-    dut.bmc_stale_test.value = 0
-    dut.bmc_valid_mask_test.value = FULL_VALID
+    dut.bmc_stale_test.value = 1
+    dut.bmc_valid_mask_test.value = 0
     dut.bmc_wr_en.value = 0
     dut.bmc_wr_index.value = 0
     dut.bmc_wr_raw.value = 0
-    dut.ct_epoch_test.value = 1
-    dut.ct_stale_test.value = 0
-    dut.ct_valid_mask_test.value = (1 << 27) - 1
+    dut.ct_epoch_test.value = 0
+    dut.ct_stale_test.value = 1
+    dut.ct_valid_mask_test.value = 0
     dut.rd_index.value = 0
     await with_timeout(RisingEdge(dut.rst_n_mon), 1, "ms")
 
+    # Three override ticks model the production 30-second lease expiration.
+    for _ in range(3):
+        await pulse(dut, dut.tick_1s_test)
+    await wait_value(dut, dut.control_state, 2, 500, "SAFE to PID")
+    outputs, _, _ = await read_outputs_and_state(dut)
+    assert outputs == [0] * 24 + [20] * 8
+
     model = ControllerBank(PIConfig(32, 4), PIConfig(24, 3))
+    await FallingEdge(dut.sys_clk)
+    dut.bmc_stale_test.value = 0
     temperatures = [6500 + ((index * 37) % 400) for index in range(24)]
-    epoch = await bootstrap_auto(dut, temperatures)
-    await compare_epoch(dut, model, epoch, temperatures, label="initial mixed edge/center pass")
-
-    # The same BMC epoch is a strict hold: no reintegration and no new bank flip.
-    held_commit = int(dut.commit_count_mon.value)
-    held_outputs = (await read_outputs(dut))[1]
-    assert model.update(epoch, errors_for(70, temperatures), [True] * 24) == held_outputs[:24]
-    await clock_cycles(dut, 300)
-    assert int(dut.commit_count_mon.value) == held_commit
-    assert (await read_outputs(dut))[1] == held_outputs
-
-    # Mixed fractional errors cover both coefficient classes and half-away
-    # rounding.  Repeated cold epochs then hit slew and upper anti-windup.
-    epoch += 1
-    temperatures = [6999 - ((index * 7) % 180) for index in range(24)]
-    await compare_epoch(dut, model, epoch, temperatures, label="fractional rounding")
-    for iteration in range(24):
-        epoch += 1
-        temperatures = [2000 + ((index * 11 + iteration) % 90) for index in range(24)]
-        await compare_epoch(dut, model, epoch, temperatures, label=f"positive slew {iteration}")
-    assert max(model.outputs_q8_8) == 25_600
+    await compare_epoch(dut, model, 1, temperatures, "mixed EDGE/CENTER")
+
+    # Same epoch is a strict hold with no Bank churn or repeated integration.
+    held = int(dut.commit_count_mon.value)
+    await cycles(dut, 300)
+    assert int(dut.commit_count_mon.value) == held
 
-    # Hold at saturation, then prove the negative slew path is equally exact.
-    for iteration in range(2):
-        epoch += 1
-        await compare_epoch(dut, model, epoch, temperatures, label=f"anti-windup hold {iteration}")
-    for iteration in range(5):
-        epoch += 1
+    for epoch in range(2, 28):
+        temperatures = [2000 + ((index * 11 + epoch) % 90) for index in range(24)]
+        await compare_epoch(dut, model, epoch, temperatures, f"positive slew {epoch}")
+    assert max(model.outputs_q8_8) == 25_600
+    for epoch in range(28, 34):
         temperatures = [7399 - (index % 5) for index in range(24)]
-        await compare_epoch(dut, model, epoch, temperatures, label=f"negative slew {iteration}")
-
-    # A single invalid channel is off while its PI state freezes.  When the
-    # channel becomes valid, the Python and RTL paths resume from that state.
-    invalid_mask = FULL_VALID ^ 1
-    frozen_state = model.states[0]
-    epoch += 1
-    await compare_epoch(
-        dut,
-        model,
-        epoch,
-        temperatures,
-        valid_mask=invalid_mask,
-        label="single invalid freeze",
-    )
-    assert model.states[0] == frozen_state
-    temperatures = [7100] * 24
-    for iteration in range(3):
-        epoch += 1
-        await compare_epoch(dut, model, epoch, temperatures, label=f"invalid recovery {iteration}")
-    assert int(dut.control_state.value) == 4
-
-    # Pretrip clears one production controller, forces its PTC off, and raises
-    # both lane fans.  The reference is explicitly rebased for safe recovery.
-    epoch += 1
-    temperatures = [6900] * 24
-    temperatures[6] = 7600
-    override = [index == 6 for index in range(24)]
-    await compare_epoch(
-        dut,
-        model,
-        epoch,
-        temperatures,
-        override=override,
-        expected_fans=[30, 80, 30, 30, 30, 80, 30, 30],
-        label="76 C pretrip",
-    )
-    model.clear_channels([6])
-    temperatures = [6900] * 24
-    for iteration in range(3):
-        epoch += 1
-        await compare_epoch(dut, model, epoch, temperatures, label=f"pretrip recovery {iteration}")
-
-    # A 77 C sample clamps and clears the complete six-channel lane.  Three
-    # safe epochs retain zero duty; the next epoch ramps from the cleared state.
-    epoch += 1
-    temperatures[12] = 7700
-    lane_override = [12 <= index < 18 for index in range(24)]
-    await compare_epoch(
-        dut,
-        model,
-        epoch,
-        temperatures,
-        override=lane_override,
-        expected_fans=[30, 30, 100, 30, 30, 30, 100, 30],
-        label="77 C lane hard clamp",
-    )
-    assert int(dut.lane_fault_mask.value) & (1 << 2)
-    model.clear_channels(range(12, 18))
-    temperatures[12] = 6900
-    for iteration in range(3):
-        epoch += 1
-        recovery_fans = (
-            [30, 30, 100, 30, 30, 30, 100, 30]
-            if iteration < 2
-            else [30] * 8
-        )
-        await compare_epoch(
-            dut,
-            model,
-            epoch,
-            temperatures,
-            override=lane_override,
-            expected_fans=recovery_fans,
-            label=f"hard-clamp recovery hold {iteration}",
-        )
-    assert int(dut.lane_fault_mask.value) == 0
-    epoch += 1
-    await compare_epoch(dut, model, epoch, temperatures, label="hard-clamp limited restart")
-
-    # Runtime stale preempts without a new epoch, atomically fills 0/100 safe
-    # outputs, and requires three fresh recovery epochs before limited restart.
-    before = int(dut.commit_count_mon.value)
+        await compare_epoch(dut, model, epoch, temperatures, f"negative rounding {epoch}")
+
+    # Manual SET_ALL freezes hidden PI state while BMC epochs continue.
+    frozen = list(model.states)
     await FallingEdge(dut.sys_clk)
-    dut.bmc_stale_test.value = 1
-    await wait_commit(dut, before, "global stale safe fill")
-    _, stale_applied, _, _ = await read_outputs(dut)
-    assert stale_applied == [0] * 24 + [100] * 8
-    assert model.update(epoch, errors_for(70, temperatures), [True] * 24, stale=True) == [0] * 24
+    dut.manual_wr_en_test.value = 1
+    for index in range(32):
+        dut.manual_wr_addr_test.value = index
+        dut.manual_wr_data_test.value = 40 if index < 24 else 20
+        await FallingEdge(dut.sys_clk)
+    dut.manual_wr_en_test.value = 0
+    await pulse(dut, dut.manual_commit_test)
+    await wait_value(dut, dut.manual_commit_done, 1, 500, "manual commit")
+    assert int(dut.manual_commit_ok.value) == 1
+    await load_epoch(dut, 34, [6000] * 24)
+    await cycles(dut, 300)
+    _, errors, state_outputs = await read_outputs_and_state(dut)
+    assert errors == [state.previous_error_centi for state in frozen]
+    assert state_outputs == [state.previous_output_q8_8 for state in frozen]
+
+    # Manual timeout atomically returns to 0/20 PID wait and clears PI state.
+    for _ in range(3):
+        await pulse(dut, dut.tick_1s_test)
+    await wait_value(dut, dut.control_state, 2, 500, "MANUAL to PID")
+    outputs, errors, state_outputs = await read_outputs_and_state(dut)
+    assert outputs == [0] * 24 + [20] * 8
+    assert errors == [0] * 24 and state_outputs == [0] * 24
+
+    # Resume PID on a new valid epoch, then persistent stale performs exactly
+    # one safe transition and no subsequent Bank churn.
     model.stop()
+    await compare_epoch(dut, model, 35, [6500] * 24, "post-manual PID restart")
     await FallingEdge(dut.sys_clk)
-    dut.bmc_stale_test.value = 0
-    all_override = [True] * 24
-    for iteration in range(3):
-        epoch += 1
-        recovery_fans = [100] * 8 if iteration < 2 else [30] * 8
-        await compare_epoch(
-            dut,
-            model,
-            epoch,
-            temperatures,
-            override=all_override,
-            expected_fans=recovery_fans,
-            label=f"stale recovery hold {iteration}",
-        )
-    assert int(dut.global_fault.value) == 0
-    epoch += 1
-    await compare_epoch(dut, model, epoch, temperatures, label="stale limited restart")
-
-    # Target changes clear the PI path, commit a safe image, and require the
-    # CT/BMC qualification sequence before the new-target Python path runs.
+    dut.bmc_stale_test.value = 1
     before = int(dut.commit_count_mon.value)
-    await FallingEdge(dut.sys_clk)
-    dut.target_celsius_test.value = 60
-    dut.target_commit_test.value = 1
-    await FallingEdge(dut.sys_clk)
-    dut.target_commit_test.value = 0
-    await wait_commit(dut, before, "target-change safe fill")
-    assert (await read_outputs(dut))[1][:24] == [0] * 24
-    model.stop()
-    await FallingEdge(dut.sys_clk)
-    dut.ct_epoch_test.value = 2
-    temperatures = [5500 + (index % 20) for index in range(24)]
-    next_epoch = await bootstrap_auto(dut, temperatures, start_epoch=epoch + 1)
-    await compare_epoch(
-        dut,
-        model,
-        next_epoch,
-        temperatures,
-        target_c=60,
-        label="new-target qualified restart",
-    )
-
-    assert int(dut.current_target_celsius.value) == 60
-    assert int(dut.control_state.value) == 4
-    assert int(dut.work_state_mon.value) == 0
+    await wait_commit(dut, before, "stale safe hold")
+    held = int(dut.commit_count_mon.value)
+    await cycles(dut, 500)
+    assert int(dut.commit_count_mon.value) == held

+ 67 - 300
tests/cocotb/test_6400_v1_control_integration.py

@@ -1,327 +1,94 @@
-"""Production-profile full-top integration over real Host and BMC UART bits."""
+"""Focused current-contract control integration over the production UART top."""
 
 from __future__ import annotations
 
 import cocotb
-from cocotb.triggers import ReadOnly, RisingEdge, Timer, with_timeout
+from cocotb.triggers import RisingEdge, with_timeout
 
 from thermal_6400_uart import (
-    BMC_CLKS_PER_BIT,
-    CLOCK_NS,
-    GET_SNAPSHOT,
-    GET_SNAPSHOT_ACK,
-    HOST_CLKS_PER_BIT,
-    SET_STIMULUS,
-    SET_TARGET,
-    SET_TARGET_ACK,
-    SNAPSHOT_DATA,
-    bring_auto,
-    check_pwm_timing,
-    encode_frame,
+    ACK_NACK,
+    SET_ALL,
+    clock_cycles,
     get_snapshot,
     host_transaction,
     pulse_tick_1s,
-    receive_frame,
     send_bmc_snapshot,
-    send_uart,
     wait_for,
 )
 
 
-def duties(snapshot: dict[str, object], name: str) -> list[int]:
-    value = snapshot[name]
-    assert isinstance(value, list)
-    return [int(item) for item in value]
+def values(snapshot: dict[str, object], field: str) -> list[int]:
+    data = snapshot[field]
+    assert isinstance(data, list)
+    return [int(item) for item in data]
 
 
-@cocotb.test()
-async def test_control_dual_host_sensor_safety_and_snapshot(dut):
-    pwm_timing = cocotb.start_soon(check_pwm_timing(dut))
-    await bring_auto(dut, verify_boot=True)
-
-    # Identical legal GET requests are independent transactions. Each one
-    # must start a fresh zero-length 0x82 ACK followed by a fresh 193-byte
-    # 0x42 DATA frame; no equality-based response suppression is permitted.
-    responses_before_repeated_get = int(dut.host_response_count_mon.value)
-    for transaction_index in (1, 2):
-        repeated = await get_snapshot(dut, "rs232")
-        assert repeated["control_state"] == 4
-        assert int(dut.host_response_count_mon.value) == (
-            responses_before_repeated_get + (2 * transaction_index)
-        )
-
-    # GET is one locked two-frame transaction. Traffic on the alternate Host
-    # after ACK must not change port_sel, unlock snapshot banks, or commit a
-    # command before the 0x42 DATA frame's final physical stop bit retires.
-    get_state = {"ack": False, "done": False}
-
-    async def receive_locked_get() -> tuple[int, bytes]:
-        ack = await receive_frame(dut.host_ttl_tx)
-        assert ack == (GET_SNAPSHOT_ACK, b"")
-        get_state["ack"] = True
-        data = await receive_frame(dut.host_ttl_tx)
-        get_state["done"] = True
-        return data
-
-    target_before_locked_get = int(dut.current_target_mon.value)
-    get_task = cocotb.start_soon(receive_locked_get())
-    await send_uart(dut.host_ttl_rx, encode_frame(GET_SNAPSHOT), HOST_CLKS_PER_BIT)
-    while not get_state["ack"]:
-        await RisingEdge(dut.sys_clk)
-    assert int(dut.host_locked_mon.value) == 1
-    assert int(dut.host_port_sel_mon.value) == 1
-    assert int(dut.u_dut.snapshot_locked.value) == 1
-    alternate = cocotb.start_soon(
-        send_uart(dut.host_rs232_rx, encode_frame(SET_TARGET, b"\x46"), HOST_CLKS_PER_BIT)
-    )
-    while not get_state["done"]:
-        await RisingEdge(dut.sys_clk)
-        await ReadOnly()
-        assert int(dut.host_locked_mon.value) == 1
-        assert int(dut.host_port_sel_mon.value) == 1
-        assert int(dut.u_dut.snapshot_locked.value) == 1
-    data_kind, data_payload = await with_timeout(get_task, 5, "ms")
-    assert data_kind == SNAPSHOT_DATA and len(data_payload) == 193
-    # receive_frame completes at the center of the final stop bit; lock must
-    # still be present until uart_tx byte_done at the end of that stop bit.
-    assert int(dut.host_locked_mon.value) == 1
-    assert int(dut.u_dut.snapshot_locked.value) == 1
-    await alternate
-    await wait_for(
-        dut,
-        lambda: int(dut.host_locked_mon.value) == 0
-        and int(dut.u_dut.snapshot_locked.value) == 0,
-        cycles=100,
-        label="GET final-stop unlock",
-    )
-    assert int(dut.current_target_mon.value) == target_before_locked_get
+def check_ack(kind: int, payload: bytes, request: int, ok: int, status: int) -> None:
+    assert kind == ACK_NACK
+    assert payload == bytes((ok, request, status, 0))
 
-    # Production must silently reject the identification-only command.
-    rejected_payload = bytes([2, *([20] * 32)])
-    responses_before_rejected_stimulus = int(dut.host_response_count_mon.value)
-    for _ in range(2):
-        await send_uart(
-            dut.host_rs232_rx,
-            encode_frame(SET_STIMULUS, rejected_payload),
-            HOST_CLKS_PER_BIT,
-        )
-        await Timer(HOST_CLKS_PER_BIT * CLOCK_NS * 20, units="ns")
-        await wait_for(
-            dut,
-            lambda: int(dut.host_locked_mon.value) == 0,
-            cycles=100,
-            label="Production repeated stimulus silent-drop unlock",
-        )
-        assert int(dut.host_response_count_mon.value) == responses_before_rejected_stimulus
-        assert int(dut.host_rs232_tx.value) == 1
-        assert int(dut.host_ttl_tx.value) == 1
-        assert int(dut.stimulus_active_mon.value) == 0
 
-    # Exercise simultaneous Host and BMC receive frontends.  ACK is routed
-    # only to RS-232 while the BMC commits a complete fifth snapshot.
-    old_control_epoch = int(dut.control_epoch_mon.value)
-    bmc_task = cocotb.start_soon(send_bmc_snapshot(dut, [61] * 24))
-    ack_task = cocotb.start_soon(receive_frame(dut.host_rs232_tx))
-    await send_uart(dut.host_rs232_rx, encode_frame(SET_TARGET, b"\x41"), HOST_CLKS_PER_BIT)
-    ack_kind, ack_payload = await with_timeout(ack_task, 20, "ms")
-    assert (ack_kind, ack_payload) == (SET_TARGET_ACK, b"")
-    assert int(dut.host_ttl_tx.value) == 1
-    await bmc_task
-    # A target change deliberately restarts CT/preheat qualification.  The
-    # concurrent BMC frame enters WAIT_BMC_STABLE; three further new epochs
-    # are required before AUTO resumes.
-    for _ in range(3):
-        await send_bmc_snapshot(dut, [61] * 24)
-    await wait_for(
-        dut,
-        lambda: int(dut.control_state_mon.value) == 4
-        and int(dut.control_epoch_mon.value) > old_control_epoch,
-        cycles=1000,
-        label="target/BMC control commit",
-    )
-    await Timer(HOST_CLKS_PER_BIT * CLOCK_NS * 2, units="ns")
-
-    snapshot = await get_snapshot(dut, "ttl")
-    assert snapshot["control_state"] == 4
-    assert snapshot["current_target"] == 65
-    assert snapshot["host_target_seen"] == 1
-    assert int(snapshot["bmc_epoch"]) >= 5
-    assert int(snapshot["ct_epoch"]) >= 1
-    assert snapshot["bmc_valid_mask"] == (1 << 24) - 1
-    assert snapshot["ct_valid_mask"] == (1 << 27) - 1
-    assert duties(snapshot, "bmc_raw") == [0x3D00] * 24
-    assert duties(snapshot, "ct_raw") == [0x3C00] * 27
-    ptc = duties(snapshot, "ptc_applied")
-    assert len(ptc) == 24 and all(0 <= value <= 100 for value in ptc) and any(ptc)
-    assert duties(snapshot, "front_applied") == [30] * 4
-    assert duties(snapshot, "rear_applied") == [30] * 4
-
-    # A 74 C sample reduces only the matching PTC and raises both fans for
-    # that lane to the contract's 80% protection duty.  The public safety bit
-    # remains telemetry and must not turn the soft action into a full cutoff.
-    old_control_epoch = int(dut.control_epoch_mon.value)
-    await send_bmc_snapshot(dut, [74, *([60] * 23)])
-    await wait_for(
-        dut,
-        lambda: int(dut.control_epoch_mon.value) > old_control_epoch,
-        cycles=1000,
-        label="74 C soft-limit commit",
-    )
-    soft = await get_snapshot(dut, "rs232")
-    soft_ptc = duties(soft, "ptc_applied")
-    assert int(soft["safety_override_mask"]) & 1
-    assert ptc[0] > 1 and soft_ptc[0] == ptc[0] - 1
-    assert duties(soft, "front_applied") == [80, 30, 30, 30]
-    assert duties(soft, "rear_applied") == [80, 30, 30, 30]
+@cocotb.test()
+async def test_safe_manual_pid_and_lane_safety(dut):
+    dut.host_rs232_rx.value = 1
+    dut.host_ttl_rx.value = 1
+    dut.bmc_rs232_rx.value = 1
+    dut.tick_1s_test.value = 0
+    dut.reset_test.value = 0
+    dut.bmc_epoch_override_enable.value = 0
+    dut.bmc_epoch_override_value.value = 0
+    await with_timeout(RisingEdge(dut.rst_n_mon), 1, "ms")
+    await clock_cycles(dut, 50)
+
+    assert int(dut.control_state_mon.value) == 0
+    boot = await get_snapshot(dut, "ttl")
+    assert values(boot, "ptc_applied") == [0] * 24
+    assert values(boot, "front_applied") == [20] * 4
+    assert values(boot, "rear_applied") == [20] * 4
+
+    requested = bytes([40] * 24 + [0, 20, 50, 100, 100, 50, 20, 0])
+    kind, payload = await host_transaction(dut, "rs232", SET_ALL, requested)
+    check_ack(kind, payload, SET_ALL, 1, 0)
+    assert int(dut.control_state_mon.value) == 1
+    manual = await get_snapshot(dut, "ttl")
+    assert values(manual, "ptc_requested") == [40] * 24
+    assert values(manual, "ptc_applied") == [40] * 24
+    assert values(manual, "front_applied") == [0, 20, 50, 100]
+    assert values(manual, "rear_applied") == [100, 50, 20, 0]
 
-    # At 76 C the matching PTC is fully off, but the lane is not yet hard
-    # faulted and therefore remains at 80% rather than 100% airflow.
-    old_control_epoch = int(dut.control_epoch_mon.value)
     await send_bmc_snapshot(dut, [76, *([60] * 23)])
-    await wait_for(
-        dut,
-        lambda: int(dut.control_epoch_mon.value) > old_control_epoch,
-        cycles=1000,
-        label="76 C pretrip commit",
-    )
-    pretrip = await get_snapshot(dut, "ttl")
-    assert int(pretrip["safety_override_mask"]) & 1
-    assert not (int(pretrip["lane_fault_mask"]) & 1)
-    assert duties(pretrip, "ptc_applied")[0] == 0
-    assert duties(pretrip, "front_applied") == [80, 30, 30, 30]
-    assert duties(pretrip, "rear_applied") == [80, 30, 30, 30]
+    await wait_for(dut, lambda: bool(int(dut.safety_mask_mon.value) & 1),
+                   cycles=1200, label="76 C clamp")
+    clamped = await get_snapshot(dut, "rs232")
+    assert int(dut.control_state_mon.value) == 1
+    assert values(clamped, "ptc_applied")[0] == 0
+    assert values(clamped, "ptc_applied")[1:] == [40] * 23
 
-    # One invalid DIMM is quarantined without corrupting the other 23 values.
-    await send_bmc_snapshot(dut, [None, *([60] * 23)])
-    await wait_for(
-        dut,
-        lambda: int(dut.control_state_mon.value) == 5 and bool(int(dut.safety_mask_mon.value) & 1),
-        cycles=1000,
-        label="single-channel invalid override",
-    )
-    invalid = await get_snapshot(dut, "rs232")
-    assert int(invalid["bmc_valid_mask"]) == ((1 << 24) - 2)
-    assert int(invalid["safety_override_mask"]) & 1
-    assert duties(invalid, "ptc_applied")[0] == 0
-
-    # A 77 C sample latches the full L0 hard override and both lane fans.
     await send_bmc_snapshot(dut, [77, *([60] * 23)])
-    await wait_for(
-        dut,
-        lambda: bool(int(dut.lane_fault_mask_mon.value) & 1),
-        cycles=1000,
-        label="lane hard limit",
-    )
+    await wait_for(dut, lambda: bool(int(dut.lane_fault_mask_mon.value) & 1),
+                   cycles=1200, label="77 C lane latch")
     hard = await get_snapshot(dut, "ttl")
     assert int(hard["lane_fault_mask"]) & 1
-    assert duties(hard, "ptc_applied")[:6] == [0] * 6
-    assert duties(hard, "front_applied")[0] == 100
-    assert duties(hard, "rear_applied")[0] == 100
-
-    # Repeating a legal target while the lane hard fault is active must ACK
-    # but cannot reduce its applied airflow or its physical connector request.
-    old_control_epoch = int(dut.control_epoch_mon.value)
-    kind, payload = await host_transaction(dut, "rs232", SET_TARGET, b"\x41")
-    assert (kind, payload) == (SET_TARGET_ACK, b"")
-    await wait_for(
-        dut,
-        lambda: int(dut.control_epoch_mon.value) > old_control_epoch,
-        cycles=1000,
-        label="hard-fault repeated target safe commit",
-    )
-    hard_after_target = await get_snapshot(dut, "ttl")
-    assert int(hard_after_target["lane_fault_mask"]) & 1
-    assert duties(hard_after_target, "front_applied")[0] == 100
-    assert duties(hard_after_target, "rear_applied")[0] == 100
-    for _ in range(2):
-        await wait_for(dut, lambda: int(dut.pwm_boundary_mon.value) == 1,
-                       cycles=600, label="hard-fault physical fan boundary")
-        await Timer(CLOCK_NS, units="ns")
-    assert not (int(dut.front_fan_pwm_out.value) & 0x1)
-    assert int(dut.rear_fan_pwm_out.value) & 0x1
-
-    # Requalify acquisition while retaining the hot lane, so the stale test
-    # below starts from an admitted runtime state rather than startup gating.
-    for _ in range(4):
-        await send_bmc_snapshot(dut, [77, *([60] * 23)])
-    await wait_for(
-        dut,
-        lambda: int(dut.control_state_mon.value) == 5,
-        cycles=1000,
-        label="hard-fault runtime requalification",
-    )
-
-    # Three explicit age ticks without a new BMC epoch create global stale.
-    await pulse_tick_1s(dut, 3)
-    await wait_for(
-        dut,
-        lambda: int(dut.global_fault_mon.value) == 1,
-        cycles=200,
-        label="global BMC stale",
-    )
-    stale = await get_snapshot(dut, "rs232")
-    assert stale["global_fault"] == 1
-    assert duties(stale, "ptc_applied") == [0] * 24
-    assert duties(stale, "front_applied") == [100] * 4
-    assert duties(stale, "rear_applied") == [100] * 4
-
-    # A legal target during global stale also ACKs without weakening the
-    # already-applied all-fan safety request.
-    old_control_epoch = int(dut.control_epoch_mon.value)
-    kind, payload = await host_transaction(dut, "ttl", SET_TARGET, b"\x41")
-    assert (kind, payload) == (SET_TARGET_ACK, b"")
-    await wait_for(
-        dut,
-        lambda: int(dut.control_epoch_mon.value) > old_control_epoch,
-        cycles=1000,
-        label="stale target safe commit",
-    )
-    stale_after_target = await get_snapshot(dut, "rs232")
-    assert stale_after_target["global_fault"] == 1
-    assert duties(stale_after_target, "front_applied") == [100] * 4
-    assert duties(stale_after_target, "rear_applied") == [100] * 4
-    for _ in range(2):
-        await wait_for(dut, lambda: int(dut.pwm_boundary_mon.value) == 1,
-                       cycles=600, label="stale physical fan boundary")
-        await Timer(CLOCK_NS, units="ns")
-    assert int(dut.front_fan_pwm_out.value) == 0x0
-    assert int(dut.rear_fan_pwm_out.value) == 0xF
+    assert values(hard, "ptc_applied")[:6] == [0] * 6
+    assert values(hard, "front_applied")[0] == 100
+    assert values(hard, "rear_applied")[0] == 100
+    kind, payload = await host_transaction(dut, "rs232", SET_ALL, requested)
+    check_ack(kind, payload, SET_ALL, 0, 4)
 
-    # Three complete safe epochs retain the clamp through the release commit;
-    # the following epoch resumes only the normal slew-limited ramp.
     for _ in range(3):
-        await send_bmc_snapshot(dut, [60] * 24)
-        await wait_for(
-            dut,
-            lambda: int(dut.control_epoch_mon.value) >= 1,
-            cycles=1000,
-            label="recovery control pass",
-        )
-    await wait_for(
-        dut,
-        lambda: int(dut.global_fault_mon.value) == 0
-        and int(dut.lane_fault_mask_mon.value) == 0
-        and int(dut.control_state_mon.value) == 4,
-        cycles=1000,
-        label="three-epoch recovery",
-    )
-    released = await get_snapshot(dut, "ttl")
-    assert duties(released, "ptc_applied") == [0] * 24
-    await send_bmc_snapshot(dut, [60] * 24)
-    await wait_for(
-        dut,
-        lambda: int(dut.control_epoch_mon.value) > int(released["control_epoch"]),
-        cycles=1000,
-        label="post-recovery limited ramp",
-    )
-    ramped = await get_snapshot(dut, "rs232")
-    assert all(0 <= value <= 5 for value in duties(ramped, "ptc_applied"))
-    assert any(duties(ramped, "ptc_applied"))
+        await send_bmc_snapshot(dut, [72] * 24)
+    await wait_for(dut, lambda: int(dut.lane_fault_mask_mon.value) == 0,
+                   cycles=2400, label="three-epoch hard release")
+    assert int(dut.control_state_mon.value) == 2
 
-    kind, payload = await host_transaction(dut, "ttl", SET_TARGET, b"\x00")
-    assert (kind, payload) == (SET_TARGET_ACK, b"")
-    stopped = await get_snapshot(dut, "rs232")
-    assert stopped["control_state"] == 6
-    assert duties(stopped, "ptc_applied") == [0] * 24
-
-    await pwm_timing
+    await pulse_tick_1s(dut, 3)
+    await wait_for(dut, lambda: int(dut.global_fault_mon.value) == 1,
+                   cycles=1200, label="PID stale hold")
+    stale = await get_snapshot(dut, "ttl")
+    assert values(stale, "ptc_applied") == [0] * 24
+    assert values(stale, "front_applied") == [20] * 4
+    assert values(stale, "rear_applied") == [20] * 4
+    epoch = int(dut.control_epoch_mon.value)
+    await pulse_tick_1s(dut, 4)
+    await clock_cycles(dut, 100)
+    assert int(dut.control_epoch_mon.value) == epoch

+ 17 - 0
tests/cocotb/test_6400_v1_host_protocol_integration.py

@@ -42,6 +42,23 @@ async def test_host_ack_nack_crc_silence_atomic_set_all_and_get_order(dut):
     kind, payload = await transact(dut, 0x55, b"")
     assert kind == ACK_NACK; ack(payload, 0, 0x55, 1)
 
+    # Oversized requests are bounded streaming discards, not resync points.
+    # The whole payload (including embedded A5 5A) and CRC must retire before
+    # one length/unsupported response is emitted; no ghost command is formed.
+    embedded = bytearray(34)
+    embedded[7:9] = b"\xA5\x5A"
+    before = int(dut.host_response_count_mon.value)
+    kind, payload = await transact(dut, SET_ALL, bytes(embedded))
+    assert kind == ACK_NACK; ack(payload, 0, SET_ALL, 2, 32)
+    assert int(dut.host_response_count_mon.value) == before + 1
+
+    oversized = bytearray((index * 17) & 0xFF for index in range(255))
+    oversized[120:122] = b"\xA5\x5A"
+    before = int(dut.host_response_count_mon.value)
+    kind, payload = await transact(dut, 0x55, bytes(oversized))
+    assert kind == ACK_NACK; ack(payload, 0, 0x55, 1)
+    assert int(dut.host_response_count_mon.value) == before + 1
+
     # First invalid index is reported and nothing enters Manual.
     bad = bytearray([0] * 24 + [20] * 8)
     bad[7] = 101

+ 0 - 248
tests/cocotb/test_6400_v1_identification_integration.py

@@ -1,248 +0,0 @@
-"""Identification-profile stimulus lifetime and safety integration."""
-
-from __future__ import annotations
-
-import cocotb
-from cocotb.triggers import ReadOnly, RisingEdge
-
-from thermal_6400_uart import (
-    SET_STIMULUS,
-    SET_STIMULUS_ACK,
-    HOST_CLKS_PER_BIT,
-    bring_auto,
-    encode_frame,
-    get_snapshot,
-    host_transaction,
-    pulse_tick_1s,
-    send_uart,
-    send_bmc_snapshot,
-    wait_for,
-)
-
-
-def array(snapshot: dict[str, object], name: str) -> list[int]:
-    value = snapshot[name]
-    assert isinstance(value, list)
-    return [int(item) for item in value]
-
-
-async def send_silent_invalid_stimulus(dut, port: str, payload: bytes) -> None:
-    responses_before = int(dut.host_response_count_mon.value)
-    active_bank_before = int(dut.u_dut.u_control.stimulus_bank_active.value)
-    await send_uart(
-        getattr(dut, f"host_{port}_rx"),
-        encode_frame(SET_STIMULUS, payload),
-        HOST_CLKS_PER_BIT,
-    )
-    await wait_for(
-        dut,
-        lambda: int(dut.host_locked_mon.value) == 0
-        and int(dut.u_dut.u_command.busy.value) == 0,
-        cycles=200,
-        label=f"invalid stimulus silent retirement on {port}",
-    )
-    assert int(dut.host_response_count_mon.value) == responses_before
-    assert int(dut.u_dut.u_control.stimulus_bank_active.value) == active_bank_before
-    assert int(dut.stimulus_active_mon.value) == 1
-    assert int(getattr(dut, f"host_{port}_tx").value) == 1
-
-
-@cocotb.test()
-async def test_identification_stimulus_expires_and_safety_preempts(dut):
-    await bring_auto(dut)
-
-    ptc = [20 + (index % 3) for index in range(24)]
-    front = [20, 30, 40, 50]
-    rear = [50, 40, 30, 20]
-    stimulus = bytes([2, *ptc, *front, *rear])
-    responses_before_repeated_stimulus = int(dut.host_response_count_mon.value)
-    for transaction_index in (1, 2):
-        kind, payload = await host_transaction(dut, "rs232", SET_STIMULUS, stimulus)
-        assert (kind, payload) == (SET_STIMULUS_ACK, b"")
-        assert int(dut.host_response_count_mon.value) == (
-            responses_before_repeated_stimulus + transaction_index
-        )
-        assert int(dut.stimulus_active_mon.value) == 1
-
-    old_control_epoch = int(dut.control_epoch_mon.value)
-    await send_bmc_snapshot(dut, [60] * 24)
-    await wait_for(
-        dut,
-        lambda: int(dut.control_epoch_mon.value) > old_control_epoch,
-        cycles=1000,
-        label="stimulus output commit",
-    )
-    active = await get_snapshot(dut, "ttl")
-    assert array(active, "ptc_requested") == ptc
-    assert array(active, "ptc_applied") == ptc
-    assert array(active, "front_requested") == front
-    assert array(active, "front_applied") == front
-    assert array(active, "rear_requested") == rear
-    assert array(active, "rear_applied") == rear
-
-    # Duration zero and one out-of-range duty both dirty only the inactive
-    # staging bank. They are silently rejected: no ACK, no active pointer
-    # flip, and the already-running A vector remains intact.
-    await send_silent_invalid_stimulus(
-        dut, "rs232", bytes([0, *([83] * 32)])
-    )
-    invalid_duty = [67] * 32
-    invalid_duty[15] = 101
-    await send_silent_invalid_stimulus(
-        dut, "ttl", bytes([2, *invalid_duty])
-    )
-    still_a = await get_snapshot(dut, "rs232")
-    assert array(still_a, "ptc_applied") == ptc
-    assert array(still_a, "front_applied") == front
-    assert array(still_a, "rear_applied") == rear
-
-    # Launch a different legal B vector, then admit a new BMC epoch while the
-    # command is still staging its bytes. The running control pass must lock
-    # A. The 0x83 ACK is fresh and the pointer flips mid-pass, but every read
-    # in that pass remains A; the following pass is wholly B.
-    ptc_b = [41 + (index % 5) for index in range(24)]
-    front_b = [61, 62, 63, 64]
-    rear_b = [71, 72, 73, 74]
-    stimulus_b = bytes([2, *ptc_b, *front_b, *rear_b])
-    responses_before_b = int(dut.host_response_count_mon.value)
-    old_active_bank = int(dut.u_dut.u_control.stimulus_bank_active.value)
-    old_control_epoch = int(dut.control_epoch_mon.value)
-    b_transaction = cocotb.start_soon(
-        host_transaction(dut, "rs232", SET_STIMULUS, stimulus_b)
-    )
-    await wait_for(
-        dut,
-        lambda: int(dut.u_dut.u_command.state.value) == 4
-        and 4 <= int(dut.u_dut.u_command.index.value) <= 12,
-        cycles=15000,
-        label="B stimulus staging window",
-    )
-    forced_epoch = (int(dut.bmc_epoch_mon.value) + 1) & 0xFFFF
-    dut.bmc_epoch_override_value.value = forced_epoch
-    dut.bmc_epoch_override_enable.value = 1
-    await wait_for(
-        dut,
-        lambda: int(dut.u_dut.u_control.work_state.value) == 2
-        and int(dut.u_dut.u_control.work_index.value) == 0,
-        cycles=200,
-        label="A-locked control pass",
-    )
-    assert int(dut.u_dut.u_control.stimulus_pass_bank.value) == old_active_bank
-    assert int(dut.u_dut.u_control.stimulus_pass_running.value) == 1
-
-    vector_a = [*ptc, *front, *rear]
-    saw_b_commit_mid_pass = False
-    for _ in range(500):
-        await RisingEdge(dut.sys_clk)
-        await ReadOnly()
-        if int(dut.control_epoch_mon.value) != old_control_epoch:
-            break
-        work_state = int(dut.u_dut.u_control.work_state.value)
-        work_index = int(dut.u_dut.u_control.work_index.value)
-        assert int(dut.u_dut.u_control.stimulus_pass_bank.value) == old_active_bank
-        assert int(dut.u_dut.u_control.stimulus_pass_running.value) == 1
-        if work_state in (1, 2, 3, 4, 5, 6, 8, 10):
-            assert int(dut.u_dut.u_control.stimulus_pass_data.value) == vector_a[work_index]
-        if int(dut.u_dut.u_control.stimulus_bank_active.value) != old_active_bank:
-            saw_b_commit_mid_pass = True
-            assert work_state != 0
-    else:
-        raise AssertionError("A-locked pass did not commit")
-    assert saw_b_commit_mid_pass
-
-    kind, payload = await b_transaction
-    assert (kind, payload) == (SET_STIMULUS_ACK, b"")
-    assert int(dut.host_response_count_mon.value) == responses_before_b + 1
-    first_after_b_commit = await get_snapshot(dut, "ttl")
-    assert array(first_after_b_commit, "ptc_applied") == ptc
-    assert array(first_after_b_commit, "front_applied") == front
-    assert array(first_after_b_commit, "rear_applied") == rear
-
-    old_control_epoch = int(dut.control_epoch_mon.value)
-    forced_epoch = (forced_epoch + 1) & 0xFFFF
-    dut.bmc_epoch_override_value.value = forced_epoch
-    await wait_for(
-        dut,
-        lambda: int(dut.control_epoch_mon.value) > old_control_epoch,
-        cycles=1000,
-        label="first wholly-B control pass",
-    )
-    active_b = await get_snapshot(dut, "rs232")
-    assert array(active_b, "ptc_requested") == ptc_b
-    assert array(active_b, "ptc_applied") == ptc_b
-    assert array(active_b, "front_applied") == front_b
-    assert array(active_b, "rear_applied") == rear_b
-    ptc, front, rear = ptc_b, front_b, rear_b
-    release_control_epoch = int(dut.control_epoch_mon.value)
-    dut.bmc_epoch_override_enable.value = 0
-    await wait_for(
-        dut,
-        lambda: int(dut.control_epoch_mon.value) > release_control_epoch,
-        cycles=1000,
-        label="epoch-hook release pass",
-    )
-
-    await pulse_tick_1s(dut)
-    assert int(dut.stimulus_active_mon.value) == 1
-    await pulse_tick_1s(dut)
-    assert int(dut.stimulus_active_mon.value) == 0
-    old_control_epoch = int(dut.control_epoch_mon.value)
-    await send_bmc_snapshot(dut, [60] * 24)
-    await wait_for(
-        dut,
-        lambda: int(dut.control_epoch_mon.value) > old_control_epoch,
-        cycles=1000,
-        label="autonomous resume after stimulus expiry",
-    )
-    resumed = await get_snapshot(dut, "rs232")
-    assert resumed["control_state"] == 4
-    assert array(resumed, "ptc_applied") != ptc
-
-    # A fresh stimulus is terminated immediately by the 77 C lane override.
-    stimulus = bytes([3, *([35] * 24), *([25] * 4), *([45] * 4)])
-    kind, payload = await host_transaction(dut, "ttl", SET_STIMULUS, stimulus)
-    assert (kind, payload) == (SET_STIMULUS_ACK, b"")
-    assert int(dut.stimulus_active_mon.value) == 1
-
-    # Per-channel thermal protection has priority over an active stimulus.
-    old_control_epoch = int(dut.control_epoch_mon.value)
-    await send_bmc_snapshot(dut, [74, *([60] * 23)])
-    await wait_for(
-        dut,
-        lambda: int(dut.control_epoch_mon.value) > old_control_epoch,
-        cycles=1000,
-        label="soft-limit stimulus preemption",
-    )
-    soft = await get_snapshot(dut, "rs232")
-    assert int(dut.stimulus_active_mon.value) == 1
-    assert array(soft, "ptc_applied")[0] < 35
-    assert array(soft, "ptc_applied")[1:6] == [35] * 5
-    assert array(soft, "front_applied")[0] == 80
-    assert array(soft, "rear_applied")[0] == 80
-
-    old_control_epoch = int(dut.control_epoch_mon.value)
-    await send_bmc_snapshot(dut, [76, *([60] * 23)])
-    await wait_for(
-        dut,
-        lambda: int(dut.control_epoch_mon.value) > old_control_epoch,
-        cycles=1000,
-        label="pretrip stimulus preemption",
-    )
-    pretrip = await get_snapshot(dut, "ttl")
-    assert int(dut.stimulus_active_mon.value) == 1
-    assert array(pretrip, "ptc_applied")[0] == 0
-    assert array(pretrip, "front_applied")[0] == 80
-    assert array(pretrip, "rear_applied")[0] == 80
-
-    await send_bmc_snapshot(dut, [77, *([60] * 23)])
-    await wait_for(
-        dut,
-        lambda: int(dut.stimulus_active_mon.value) == 0
-        and bool(int(dut.lane_fault_mask_mon.value) & 1),
-        cycles=1000,
-        label="hard-limit stimulus preemption",
-    )
-    hard = await get_snapshot(dut, "rs232")
-    assert array(hard, "ptc_applied")[:6] == [0] * 6
-    assert array(hard, "front_applied")[0] == 100
-    assert array(hard, "rear_applied")[0] == 100

+ 2 - 1
tests/cocotb/thermal_6400_uart.py

@@ -283,7 +283,8 @@ async def get_snapshot(dut, port: str = "ttl") -> dict[str, object]:
 
     async def receive_ack_then_data() -> bytes:
         ack_kind, ack_payload = await receive_frame(tx)
-        assert (ack_kind, ack_payload) == (GET_SNAPSHOT_ACK, b"")
+        assert ack_kind == ACK_NACK
+        assert ack_payload == bytes((1, GET_SNAPSHOT, 0, 0))
         data_kind, data_payload = await receive_frame(tx)
         assert data_kind == SNAPSHOT_DATA
         return data_payload

+ 21 - 13
tests/cocotb/thermal_control_core_cocotb_top.v

@@ -4,6 +4,10 @@ module thermal_control_core_cocotb_top (
     input  wire        tick_1s_test,
     input  wire        target_commit_test,
     input  wire [7:0]  target_celsius_test,
+    input  wire        manual_wr_en_test,
+    input  wire [4:0]  manual_wr_addr_test,
+    input  wire [7:0]  manual_wr_data_test,
+    input  wire        manual_commit_test,
     input  wire [15:0] bmc_epoch_test,
     input  wire        bmc_stale_test,
     input  wire [23:0] bmc_valid_mask_test,
@@ -29,6 +33,8 @@ module thermal_control_core_cocotb_top (
     output wire [3:0]  lane_fault_mask,
     output wire        global_fault,
     output wire        output_commit,
+    output wire        manual_commit_done,
+    output wire        manual_commit_ok,
     output reg  [15:0] commit_count_mon = 0
 );
     reg clk = 1'b0;
@@ -38,8 +44,6 @@ module thermal_control_core_cocotb_top (
     wire [15:0] bmc_rd_raw = bmc_mem[bmc_rd_index];
     wire bmc_rd_valid = bmc_valid_mask_test[bmc_rd_index];
     wire [7:0] pwm_rd_data;
-    wire host_target_seen;
-    wire stimulus_active;
     integer i;
 
     always #20 clk = ~clk;
@@ -61,17 +65,18 @@ module thermal_control_core_cocotb_top (
         end
     end
 
-    thermal_control_core u_dut (
+    thermal_control_core #(.WATCHDOG_TICKS_OVERRIDE(3)) u_dut (
         .clk(clk),
         .rst_n(rst_n_mon),
         .tick_1s(tick_1s_test),
-        .target_commit(target_commit_test),
-        .target_celsius(target_celsius_test),
-        .stimulus_wr_en(1'b0),
-        .stimulus_wr_addr(5'd0),
-        .stimulus_wr_data(8'd0),
-        .stimulus_commit(1'b0),
-        .stimulus_duration_seconds(8'd0),
+        .manual_wr_en(manual_wr_en_test),
+        .manual_wr_addr(manual_wr_addr_test),
+        .manual_wr_data(manual_wr_data_test),
+        .manual_commit(manual_commit_test),
+        .manual_commit_done(manual_commit_done),
+        .manual_commit_ok(manual_commit_ok),
+        .pid_target_commit(target_commit_test),
+        .pid_target_celsius(target_celsius_test),
         .bmc_epoch(bmc_epoch_test),
         .bmc_stale(bmc_stale_test),
         .bmc_valid_mask(bmc_valid_mask_test),
@@ -92,13 +97,16 @@ module thermal_control_core_cocotb_top (
         .active_output_bank(active_output_bank),
         .control_state(control_state),
         .current_target_celsius(current_target_celsius),
-        .host_target_seen(host_target_seen),
         .control_epoch(control_epoch),
         .safety_override_mask(safety_override_mask),
         .lane_fault_mask(lane_fault_mask),
         .global_fault(global_fault),
         .output_commit(output_commit),
-        .stimulus_active(stimulus_active),
+        .watchdog_active(),
+        .watchdog_remaining(),
+        .pid_running(),
+        .manual_mode(),
+        .hard_protect(),
         .pwm_phase_boundary(1'b1),
         .pwm_scan_idle(1'b1),
         .boot_init_complete()
@@ -109,5 +117,5 @@ module thermal_control_core_cocotb_top (
         u_dut.u_pi_state.memory[rd_index][31:16] : 16'd0;
     assign previous_output_data = (rd_index < 24) ?
         u_dut.u_pi_state.memory[rd_index][15:0] : 16'd0;
-    wire unused = &{1'b0, pwm_rd_data, host_target_seen, stimulus_active};
+    wire unused = &{1'b0, pwm_rd_data};
 endmodule

+ 29 - 35
tests/formal/6400-properties.json

@@ -1,42 +1,36 @@
 {
-  "schema": "prod2u-6400-formal-properties-v1",
+  "schema": "prod2u-6400-formal-properties-v2",
+  "product": "6400-front-rear",
+  "phase": "quick-smoke",
   "required_solvers": ["boolector", "z3"],
   "proof_targets": [
-    {"name": "core", "sby": "6400_core_properties.sby", "tasks": ["boolector", "z3"], "mode": "prove", "depth": 4},
-    {"name": "transport", "sby": "6400_transport_properties.sby", "tasks": ["boolector", "z3"], "mode": "prove", "depth": 8},
-    {"name": "transport_identification", "sby": "6400_transport_identification_properties.sby", "tasks": ["boolector", "z3"], "mode": "prove", "depth": 40},
-    {"name": "bmc_bank", "sby": "6400_bmc_bank_properties.sby", "tasks": ["boolector", "z3"], "mode": "prove", "depth": 8},
-    {"name": "snapshot", "sby": "6400_snapshot_properties.sby", "tasks": ["boolector", "z3"], "mode": "prove", "depth": 4},
-    {"name": "pwm", "sby": "6400_pwm_properties.sby", "tasks": ["boolector", "z3"], "mode": "prove", "depth": 8},
-    {"name": "boot_output", "sby": "6400_boot_output_properties.sby", "tasks": ["boolector", "z3"], "mode": "prove", "depth": 8}
-  ],
-  "cover_targets": [
-    {"name": "core_reachability", "sby": "6400_core_reachability.sby", "tasks": [], "mode": "cover", "depth": 220, "witnesses": ["P02", "P03", "P04", "P05", "P10", "P12", "P13", "P16"]},
-    {"name": "transport_reachability", "sby": "6400_transport_reachability.sby", "tasks": [], "mode": "cover", "depth": 128, "witnesses": ["P06", "P07", "P15"]},
-    {"name": "transport_identification_reachability", "sby": "6400_transport_identification_reachability.sby", "tasks": [], "mode": "cover", "depth": 100, "witnesses": ["P18"]},
-    {"name": "bmc_bank_reachability", "sby": "6400_bmc_bank_reachability.sby", "tasks": [], "mode": "cover", "depth": 128, "witnesses": ["P08", "P09"]},
-    {"name": "snapshot_reachability", "sby": "6400_snapshot_reachability.sby", "tasks": [], "mode": "cover", "depth": 8, "witnesses": ["P14"]},
-    {"name": "pwm_reachability", "sby": "6400_pwm_reachability.sby", "tasks": [], "mode": "cover", "depth": 505, "witnesses": ["P11"]},
-    {"name": "boot_output_reachability", "sby": "6400_boot_output_reachability.sby", "tasks": [], "mode": "cover", "depth": 12, "witnesses": ["P17"]}
+    {
+      "name": "board_adapter",
+      "sby": "6400_board_adapter_properties.sby",
+      "tasks": ["boolector", "z3"],
+      "mode": "prove",
+      "depth": 2
+    }
   ],
+  "cover_targets": [],
   "properties": [
-    {"id": "P01", "requirement": "Duty always remains in 0..100", "harness": "6400_core_properties.sby"},
-    {"id": "P02", "requirement": "Hard safety overrides ordinary requests", "harness": "6400_core_properties.sby"},
-    {"id": "P03", "requirement": "BMC stale forces all PTC off", "harness": "6400_core_properties.sby"},
-    {"id": "P04", "requirement": "Invalid channels cannot heat", "harness": "6400_core_properties.sby"},
-    {"id": "P05", "requirement": "77 C lane fault overrides all lane PTC", "harness": "6400_core_properties.sby"},
-    {"id": "P06", "requirement": "Bad CRC cannot change target", "harness": "6400_transport_properties.sby"},
-    {"id": "P07", "requirement": "SET_TARGET ACK occurs only after legal atomic target commit", "harness": "6400_transport_properties.sby"},
-    {"id": "P08", "requirement": "Inactive bank cannot affect active bank", "harness": "6400_bmc_bank_properties.sby"},
-    {"id": "P09", "requirement": "Bank swap is atomic", "harness": "6400_bmc_bank_properties.sby"},
-    {"id": "P10", "requirement": "Scheduler has no permanent starvation", "harness": "6400_core_properties.sby"},
-    {"id": "P11", "requirement": "PWM scan completes before deadline", "harness": "6400_pwm_properties.sby"},
-    {"id": "P12", "requirement": "Host disconnect does not stop autonomous mode", "harness": "6400_core_properties.sby"},
-    {"id": "P13", "requirement": "Identification stimulus necessarily expires", "harness": "6400_core_properties.sby"},
-    {"id": "P14", "requirement": "Snapshot never mixes epochs or banks", "harness": "6400_snapshot_properties.sby"},
-    {"id": "P15", "requirement": "Host port selection is stable for one lock", "harness": "6400_transport_properties.sby"},
-    {"id": "P16", "requirement": "STOPPED never heats after safe commit", "harness": "6400_core_properties.sby"},
-    {"id": "P17", "requirement": "Reset and boot keep fan pins at full-speed request until an initialized PWM-boundary release", "harness": "6400_boot_output_properties.sby"},
-    {"id": "P18", "requirement": "Identification stimulus stages 32 valid duties in an inactive bank, atomically flips once, and emits a fresh zero-length 0x83 ACK", "harness": "6400_transport_identification_properties.sby"}
+    {
+      "id": "QF01",
+      "requirement": "FAN_BOARD_INVERT_MASK is 0x0F: Front connector requests invert once at FPGA balls and Rear requests remain direct",
+      "harness": "6400_board_adapter_properties.sby"
+    }
+  ],
+  "deferred_long_targets": [
+    "owner_watchdog",
+    "set_all_timeout_priority",
+    "manual_without_bmc",
+    "pid_stale_hold",
+    "incremental_pi_epoch_gate",
+    "hard_fault_release",
+    "hard_fault_cancels_manual",
+    "oversized_request",
+    "get_ack_before_data",
+    "snapshot_lock_stop_bit",
+    "reset_safe_pwm"
   ]
 }

+ 20 - 0
tests/formal/6400_board_adapter_properties.sby

@@ -0,0 +1,20 @@
+[tasks]
+boolector
+z3
+
+[options]
+mode prove
+depth 2
+
+[engines]
+boolector: smtbmc boolector
+z3: smtbmc z3 -- --noincr
+
+[script]
+read_verilog -formal fan_board_output_adapter.v
+read_verilog -formal 6400_board_adapter_properties_formal.v
+prep -top thermal_6400_board_adapter_properties_formal
+
+[files]
+../../src/actuator/fan_board_output_adapter.v
+6400_board_adapter_properties_formal.v

+ 16 - 0
tests/formal/6400_board_adapter_properties_formal.v

@@ -0,0 +1,16 @@
+module thermal_6400_board_adapter_properties_formal;
+    (* anyconst *) reg [7:0] connector_request;
+    wire [3:0] front_ball;
+    wire [3:0] rear_ball;
+
+    fan_board_output_adapter #(.BOARD_INVERT_MASK(8'h0F)) dut (
+        .logical_fan_on(connector_request),
+        .front_fan_ball(front_ball),
+        .rear_fan_ball(rear_ball)
+    );
+
+    always @* begin
+        assert(front_ball == ~connector_request[3:0]);
+        assert(rear_ball == connector_request[7:4]);
+    end
+endmodule

+ 25 - 5
tests/sim/frame_rx_tb.v

@@ -101,12 +101,32 @@ module frame_rx_tb;
         if (frame_length !== 8'd11) $fatal(1, "mixed golden length");
         ack_frame();
 
-        // Legacy length 0x0E must be rejected under MAX_PAYLOAD=11.
-        push(8'hA5); push(8'h5A); push(8'h01); push(8'h0E);
-        for (i = 0; i < 14; i = i + 1) push(8'h00);
-        push(8'h00); push(8'h00);
+        // A complete oversized frame remains one trusted request.  Only the
+        // first MAX_PAYLOAD bytes enter RAM; embedded A5 5A cannot resync it.
+        // CRC covers TYPE=01, LENGTH=34 and the complete generated payload.
+        push(8'hA5); push(8'h5A); push(8'h01); push(8'h22);
+        for (i = 0; i < 34; i = i + 1) begin
+            if (i == 3) push(8'hA5);
+            else if (i == 4) push(8'h5A);
+            else push(i[7:0]);
+        end
+        push(8'hEC); push(8'h69);
+        repeat (4) @(posedge clk);
+        if (!frame_valid) $fatal(1, "trusted oversized frame metadata missing");
+        if (frame_type !== 8'h01 || frame_length !== 8'd34)
+            $fatal(1, "oversized metadata mismatch type=%h len=%0d", frame_type, frame_length);
+        ack_frame();
+
+        // The same complete oversized request with a bad CRC is silent.
+        push(8'hA5); push(8'h5A); push(8'h01); push(8'h22);
+        for (i = 0; i < 34; i = i + 1) begin
+            if (i == 3) push(8'hA5);
+            else if (i == 4) push(8'h5A);
+            else push(i[7:0]);
+        end
+        push(8'hED); push(8'h69);
         repeat (4) @(posedge clk);
-        if (frame_valid) $fatal(1, "legacy 14-byte SET_ALL published");
+        if (frame_valid) $fatal(1, "bad-CRC oversized frame published");
 
         accept_enable = 1'b0;
         push(8'hA5); push(8'h5A); push(8'h02); push(8'h00); push(8'h6D); push(8'h7B);

+ 5 - 6
tests/sim/thermal_control_core_tb.v

@@ -12,7 +12,7 @@ module thermal_control_core_tb;
     reg [15:0] bmc_raw [0:23];
     reg [4:0] pwm_addr = 0;
     wire [7:0] pwm_data;
-    wire manual_done, active_bank, output_commit;
+    wire manual_done, manual_ok, active_bank, output_commit;
     wire [2:0] mode;
     wire [7:0] current_target, watchdog_remaining;
     wire [15:0] control_epoch;
@@ -28,10 +28,9 @@ module thermal_control_core_tb;
         .clk(clk), .rst_n(rst_n), .tick_1s(tick),
         .manual_wr_en(manual_wr), .manual_wr_addr(manual_addr),
         .manual_wr_data(manual_data), .manual_commit(manual_commit),
-        .manual_commit_done(manual_done), .pid_target_commit(pid_commit),
-        .pid_target_celsius(pid_target), .stimulus_wr_en(1'b0),
-        .stimulus_wr_addr(0), .stimulus_wr_data(0), .stimulus_commit(1'b0),
-        .stimulus_duration_seconds(0), .bmc_epoch(bmc_epoch),
+        .manual_commit_done(manual_done), .manual_commit_ok(manual_ok),
+        .pid_target_commit(pid_commit), .pid_target_celsius(pid_target),
+        .bmc_epoch(bmc_epoch),
         .bmc_stale(bmc_stale), .bmc_valid_mask(bmc_mask),
         .bmc_rd_index(bmc_index), .bmc_rd_raw(bmc_raw[bmc_index]),
         .bmc_rd_valid(bmc_mask[bmc_index]), .ct_epoch(0), .ct_stale(1'b0),
@@ -43,7 +42,7 @@ module thermal_control_core_tb;
         .current_target_celsius(current_target), .control_epoch(control_epoch),
         .safety_override_mask(safety), .lane_fault_mask(lane_fault),
         .global_fault(global_fault), .output_commit(output_commit),
-        .stimulus_active(), .watchdog_active(watchdog_active),
+        .watchdog_active(watchdog_active),
         .watchdog_remaining(watchdog_remaining), .pid_running(pid_running),
         .manual_mode(manual_mode), .hard_protect(hard_protect),
         .pwm_phase_boundary(1'b1), .pwm_scan_idle(1'b1), .boot_init_complete()

+ 104 - 0
tests/sim/thermal_control_hard_race_tb.v

@@ -0,0 +1,104 @@
+`timescale 1ns/1ps
+
+module thermal_control_hard_race_tb;
+    reg clk = 0, rst_n = 0, tick = 0;
+    reg manual_wr = 0, manual_commit = 0;
+    reg [4:0] manual_addr = 0;
+    reg [7:0] manual_data = 0;
+    reg [15:0] bmc_epoch = 0;
+    reg bmc_stale = 1;
+    reg [23:0] bmc_mask = 24'hffffff;
+    reg [15:0] bmc_raw [0:23];
+    wire [4:0] bmc_index;
+    reg pwm_boundary = 1;
+    wire manual_done, manual_ok, active_bank, output_commit;
+    wire [2:0] owner;
+    wire [3:0] lane_fault;
+    wire [7:0] pwm_data;
+    reg [4:0] pwm_addr = 0;
+    integer i, timeout, commit_count = 0;
+
+    always #5 clk = ~clk;
+    always @(posedge clk) if (output_commit) commit_count <= commit_count + 1;
+
+    thermal_control_core #(.WATCHDOG_TICKS_OVERRIDE(4)) dut (
+        .clk(clk), .rst_n(rst_n), .tick_1s(tick),
+        .manual_wr_en(manual_wr), .manual_wr_addr(manual_addr),
+        .manual_wr_data(manual_data), .manual_commit(manual_commit),
+        .manual_commit_done(manual_done), .manual_commit_ok(manual_ok),
+        .pid_target_commit(1'b0), .pid_target_celsius(8'd70),
+        .bmc_epoch(bmc_epoch), .bmc_stale(bmc_stale), .bmc_valid_mask(bmc_mask),
+        .bmc_rd_index(bmc_index), .bmc_rd_raw(bmc_raw[bmc_index]),
+        .bmc_rd_valid(bmc_mask[bmc_index]), .ct_epoch(16'd0), .ct_stale(1'b1),
+        .ct_valid_mask(27'd0), .snapshot_lock(1'b0), .snapshot_lock_bank(1'b0),
+        .pwm_rd_addr(pwm_addr), .pwm_rd_data(pwm_data),
+        .snapshot_output_bank(active_bank), .snapshot_rd_addr(5'd0),
+        .snapshot_requested_data(), .snapshot_applied_data(),
+        .active_output_bank(active_bank), .control_state(owner),
+        .current_target_celsius(), .control_epoch(), .safety_override_mask(),
+        .lane_fault_mask(lane_fault), .global_fault(), .output_commit(output_commit),
+        .watchdog_active(), .watchdog_remaining(), .pid_running(), .manual_mode(),
+        .hard_protect(), .pwm_phase_boundary(pwm_boundary), .pwm_scan_idle(1'b1),
+        .boot_init_complete()
+    );
+
+    task check_duty;
+        input [4:0] address;
+        input [7:0] expected;
+        begin
+            pwm_addr = address;
+            repeat (2) @(negedge clk);
+            if (pwm_data !== expected)
+                $fatal(1, "duty[%0d]=%0d expected=%0d", address, pwm_data, expected);
+        end
+    endtask
+
+    initial begin
+        for (i = 0; i < 24; i = i + 1) bmc_raw[i] = {8'd60, 8'd0};
+        repeat (4) @(negedge clk); rst_n = 1;
+        repeat (40) @(negedge clk);
+
+        for (i = 0; i < 32; i = i + 1) begin
+            @(negedge clk); manual_wr = 1; manual_addr = i[4:0];
+            manual_data = (i < 24) ? 8'd80 : 8'd60;
+        end
+        @(negedge clk); manual_wr = 0;
+
+        // Hold the atomic output boundary after the complete Manual Bank has
+        // committed, then inject a new complete 77 C BMC epoch.
+        pwm_boundary = 0;
+        @(negedge clk); manual_commit = 1;
+        @(negedge clk); manual_commit = 0;
+        timeout = 0;
+        while (dut.work_state != 9 && timeout < 300) begin
+            @(negedge clk); timeout = timeout + 1;
+        end
+        if (timeout == 300) $fatal(1, "manual never reached output commit wait");
+        bmc_stale = 0;
+        bmc_raw[0] = {8'd77, 8'd0};
+        bmc_epoch = 1;
+
+        timeout = 0;
+        while (!manual_done && timeout < 500) begin
+            @(negedge clk); timeout = timeout + 1;
+        end
+        if (timeout == 500 || manual_ok)
+            $fatal(1, "in-flight manual was not cancelled by new hard lock");
+        if (owner == 1) $fatal(1, "cancelled manual gained ownership");
+        check_duty(0, 0);
+        check_duty(24, 20);
+
+        pwm_boundary = 1;
+        timeout = 0;
+        while ((!lane_fault[0] || commit_count == 0) && timeout < 500) begin
+            @(negedge clk); timeout = timeout + 1;
+        end
+        if (timeout == 500 || owner != 2) $fatal(1, "hard safe commit missing");
+        check_duty(0, 0);
+        check_duty(24, 100);
+        check_duty(28, 100);
+        check_duty(25, 20);
+        $display("PASS: new hard epoch cancels in-flight Manual before output Bank apply");
+        $finish;
+    end
+endmodule

+ 25 - 7
tests/sim/thermal_host_command_v2_tb.v

@@ -5,8 +5,8 @@ module thermal_host_command_v2_tb;
     reg [7:0] frame_type = 0, frame_length = 0;
     wire [7:0] payload_addr;
     reg [7:0] payload [0:32];
-    reg safety_locked = 0, manual_done = 0, snapshot_ready = 0;
-    wire manual_wr, manual_commit, pid_commit, stimulus_commit, snapshot_capture;
+    reg safety_locked = 0, manual_done = 0, manual_ok = 1, snapshot_ready = 0;
+    wire manual_wr, manual_commit, pid_commit, snapshot_capture;
     wire [4:0] manual_wr_addr;
     wire [7:0] manual_wr_data, pid_target;
     wire tx_start, transaction_done, busy;
@@ -18,16 +18,15 @@ module thermal_host_command_v2_tb;
     always #5 clk = ~clk;
     always @(posedge clk) if (manual_wr) writes <= writes + 1;
 
-    thermal_host_command #(.ENABLE_STIMULUS(0), .SNAPSHOT_LENGTH(201)) dut (
+    thermal_host_command #(.SNAPSHOT_LENGTH(201)) dut (
         .clk(clk), .rst_n(rst_n), .frame_valid(frame_valid), .frame_ready(),
         .frame_accept_enable(), .frame_type(frame_type), .frame_length(frame_length),
         .payload_read_addr(payload_addr), .payload_read_data(payload[payload_addr]),
         .manual_wr_en(manual_wr), .manual_wr_addr(manual_wr_addr),
         .manual_wr_data(manual_wr_data), .manual_commit(manual_commit),
-        .manual_commit_done(manual_done), .safety_locked(safety_locked),
+        .manual_commit_done(manual_done), .manual_commit_ok(manual_ok),
+        .safety_locked(safety_locked),
         .pid_target_commit(pid_commit), .pid_target_celsius(pid_target),
-        .stimulus_wr_en(), .stimulus_wr_addr(), .stimulus_wr_data(),
-        .stimulus_commit(stimulus_commit), .stimulus_duration_seconds(),
         .snapshot_capture(snapshot_capture), .snapshot_ready(snapshot_ready),
         .tx_start(tx_start), .tx_frame_type(tx_type), .tx_payload_length(tx_length),
         .tx_payload_addr(tx_payload_addr), .ack_payload_data(ack_data),
@@ -38,6 +37,7 @@ module thermal_host_command_v2_tb;
         input [7:0] kind;
         input [7:0] length;
         begin
+            while (busy) @(negedge clk);
             @(negedge clk); frame_type = kind; frame_length = length; frame_valid = 1;
             @(negedge clk); frame_valid = 0;
         end
@@ -51,7 +51,9 @@ module thermal_host_command_v2_tb;
         begin
             timeout = 0;
             while (!tx_start && timeout < 300) begin @(negedge clk); timeout = timeout + 1; end
-            if (timeout == 300 || tx_type != 8'h06 || tx_length != 4) $fatal(1, "ACK timeout/type");
+            if (timeout == 300 || tx_type != 8'h06 || tx_length != 4)
+                $fatal(1, "ACK timeout/type state=%0d req=%h len=%0d tx_start=%b tx_type=%h tx_len=%0d",
+                    dut.state, frame_type, frame_length, tx_start, tx_type, tx_length);
             tx_payload_addr = 0; #1; if (ack_data != ok) $fatal;
             tx_payload_addr = 1; #1; if (ack_data != request_kind) $fatal;
             tx_payload_addr = 2; #1; if (ack_data != status) $fatal;
@@ -73,6 +75,15 @@ module thermal_host_command_v2_tb;
         request(8'h01, 32); expect_ack(0, 8'h01, 3, 7);
         if (writes != 0 || manual_commit) $fatal(1, "bad SET_ALL partially wrote");
 
+        // A new lock after validation but before Manual Bank commit is
+        // fail-closed and never emits manual_commit or ACK OK.
+        for (i = 0; i < 32; i = i + 1) payload[i] = 20;
+        writes = 0; request(8'h01, 32);
+        wait(dut.state == 3); safety_locked = 1;
+        expect_ack(0, 8'h01, 4, 0);
+        if (manual_commit || writes != 32) $fatal(1, "validate race did not fail closed");
+        safety_locked = 0;
+
         for (i = 0; i < 32; i = i + 1) payload[i] = (i < 24) ? i : 20;
         writes = 0; request(8'h01, 32);
         wait(manual_commit); if (writes != 32) $fatal(1, "valid writes=%0d", writes);
@@ -80,6 +91,13 @@ module thermal_host_command_v2_tb;
         manual_done = 1; @(negedge clk); manual_done = 0;
         expect_ack(1, 8'h01, 0, 0);
 
+        // A hard lock discovered after the manual bank commit cancels ACK OK.
+        writes = 0; request(8'h01, 32);
+        wait(manual_commit); manual_ok = 0;
+        @(negedge clk); manual_done = 1;
+        @(negedge clk); manual_done = 0;
+        expect_ack(0, 8'h01, 4, 0); manual_ok = 1;
+
         safety_locked = 1; request(8'h01, 32); expect_ack(0, 8'h01, 4, 0); safety_locked = 0;
         payload[0] = 19; request(8'h04, 1); expect_ack(0, 8'h04, 3, 0);
         payload[0] = 70; request(8'h04, 1);

+ 15 - 0
tests/unit/test_6400_closure_separation.py

@@ -0,0 +1,15 @@
+from __future__ import annotations
+
+from tools.check_6400_closures import build_receipt
+
+
+def test_production_and_analysis_closures_are_complete_and_separate() -> None:
+    receipt = build_receipt()
+    production = receipt["production_source_closure"]["files"]
+    analysis = receipt["analysis_replay_closure"]["files"]
+    assert "src/top/prod2u_6400_rs232_only_top.v" in production
+    assert "tools/target_registry.py" in analysis
+    assert "tools/package_target.py" in analysis
+    assert "tools/target_registry.py" not in production
+    assert "tests/cocotb/test_6400_pi_differential.py" not in production
+    assert all(len(digest) == 64 for digest in [*production.values(), *analysis.values()])

+ 4 - 4
tests/unit/test_6400_contract.py

@@ -86,16 +86,16 @@ class Contract6400Tests(unittest.TestCase):
                 build_target_package("6400", "firmware", P(directory))
             with self.assertRaises(SystemExit):
                 build_target_package(
-                    "6400", "firmware", P(directory), profile_name="6400-control"
+                    "6400", "firmware", P(directory), profile_name="6400-front-rear"
                 )
             path = build_target_package(
-                "6400", "source", P(directory), profile_name="6400-control"
+                "6400", "source", P(directory), profile_name="6400-front-rear"
             )
             self.assertTrue(path.is_file())
             with zipfile.ZipFile(path) as archive:
                 manifest = json.loads(archive.read("manifest.json"))
-                self.assertEqual(manifest["profile"], "6400-control")
-                self.assertEqual(manifest["top"], "prod2u_6400_v1_top")
+                self.assertEqual(manifest["profile"], "6400-front-rear")
+                self.assertEqual(manifest["top"], "prod2u_6400_rs232_only_top")
                 self.assertNotIn(
                     "src/generated/6400/prod2u_6400_front_back.adc",
                     archive.namelist(),

+ 47 - 235
tests/unit/test_6400_formal_contract.py

@@ -1,260 +1,72 @@
 #!/usr/bin/env python3
-"""Contract checks for the 6400 P01-P17 formal acceptance suite."""
+"""Active Formal registry checks for the single 6400-front-rear product."""
 
 from __future__ import annotations
 
 import json
 from pathlib import Path
-import re
-import signal
-import subprocess
-
-import pytest
-
-import tools.run_6400_formal as formal_runner
-from tools.run_6400_formal import compiled_property_ids, formal_run_base, property_cell_ids
 
 
 ROOT = Path(__file__).resolve().parents[2]
 FORMAL = ROOT / "tests" / "formal"
 
 
-def _manifest() -> dict:
+def manifest() -> dict:
     return json.loads((FORMAL / "6400-properties.json").read_text(encoding="utf-8"))
 
 
-def test_exact_p01_p18_manifest() -> None:
-    manifest = _manifest()
-    assert [item["id"] for item in manifest["properties"]] == [
-        f"P{index:02d}" for index in range(1, 19)
-    ]
-    assert len({item["id"] for item in manifest["properties"]}) == 18
-
-
-def test_every_proof_runs_boolector_and_z3() -> None:
-    manifest = _manifest()
-    assert manifest["required_solvers"] == ["boolector", "z3"]
-    harnesses = {target["sby"] for target in manifest["proof_targets"]}
-    assert all(target["tasks"] == ["boolector", "z3"] for target in manifest["proof_targets"])
-    assert all(item["harness"] in harnesses for item in manifest["properties"])
-
-
-def test_sby_mode_and_depth_match_manifest() -> None:
-    manifest = _manifest()
-    for target in [*manifest["proof_targets"], *manifest["cover_targets"]]:
-        text = (FORMAL / target["sby"]).read_text(encoding="utf-8")
-        assert re.search(rf"(?m)^mode\s+{re.escape(target['mode'])}\s*$", text)
-        assert re.search(rf"(?m)^depth\s+{target['depth']}\s*$", text)
-
-
-def test_pwm_proof_and_reachability_compile_board_adapter() -> None:
-    for name in ("6400_pwm_properties.sby", "6400_pwm_reachability.sby"):
-        text = (FORMAL / name).read_text(encoding="utf-8")
-        assert "fan_board_output_adapter.v" in text
-
-
-def test_boot_output_proof_uses_production_controller_and_board_adapter() -> None:
-    for name in (
-        "6400_boot_output_properties.sby",
-        "6400_boot_output_reachability.sby",
-    ):
-        text = (FORMAL / name).read_text(encoding="utf-8")
-        assert "fan_boot_safety_controller.v" in text
-        assert "fan_board_output_adapter.v" in text
-    p17 = next(item for item in _manifest()["properties"] if item["id"] == "P17")
-    assert p17["harness"] == "6400_boot_output_properties.sby"
+def test_active_manifest_is_single_product_and_has_no_identification_target() -> None:
+    data = manifest()
+    assert data["product"] == "6400-front-rear"
+    serialized = json.dumps(data, sort_keys=True).lower()
+    assert "identification" not in serialized
+    assert "stimulus" not in serialized
+    assert "6400-control" not in serialized
 
 
-def test_identification_transport_proves_fresh_ack_without_claiming_uart_stop_bit() -> None:
-    manifest = _manifest()
-    target = next(
-        item for item in manifest["proof_targets"]
-        if item["name"] == "transport_identification"
-    )
-    reachability = next(
-        item for item in manifest["cover_targets"]
-        if item["name"] == "transport_identification_reachability"
-    )
-    assert target["sby"] == "6400_transport_identification_properties.sby"
-    assert reachability["sby"] == "6400_transport_identification_reachability.sby"
-    assert reachability["witnesses"] == ["P18"]
+def test_quick_smoke_is_bounded_and_cross_solver() -> None:
+    data = manifest()
+    assert data["phase"] == "quick-smoke"
+    assert data["required_solvers"] == ["boolector", "z3"]
+    assert len(data["proof_targets"]) == 1
+    target = data["proof_targets"][0]
+    assert target["name"] == "board_adapter"
+    assert target["tasks"] == ["boolector", "z3"]
+    assert target["depth"] <= 2
+    assert (FORMAL / target["sby"]).is_file()
 
-    proof = (FORMAL / target["sby"]).read_text(encoding="utf-8")
-    harness = (
-        FORMAL / "6400_transport_identification_properties_formal.v"
-    ).read_text(encoding="utf-8")
-    assert "thermal_host_command.v" in proof
-    assert "stimulus_atomic_bank.v" in proof
-    assert "uart_tx_byte.v" not in proof
-    assert "repeated_ack_seen" in harness
-    assert "writes_seen == 32'hFFFF_FFFF" in harness
-    assert "tx_frame_type == 8'h83 && tx_payload_length == 0" in harness
-    assert "invalid_duration_silent_seen" in harness
-    assert "invalid_duty_silent_seen" in harness
-    assert "Physical UART serialization" in harness
-    assert "u_command.state" not in harness
-    assert ".formal_state_o(formal_state)" in harness
-    assert "bank_commit_applied" in harness
-    assert "formal_active_stimulus_data == 8'd50" in harness
 
-    command = (ROOT / "src/transport/thermal_host_command.v").read_text(
+def test_board_adapter_property_is_current_contract() -> None:
+    harness = (FORMAL / "6400_board_adapter_properties_formal.v").read_text(
         encoding="utf-8"
     )
-    assert "`ifdef FORMAL\n    , output wire [3:0] formal_state_o" in command
-
-    p07 = next(item for item in manifest["properties"] if item["id"] == "P07")
-    assert p07["harness"] == "6400_transport_properties.sby"
-    assert p07["requirement"].startswith("SET_TARGET ACK")
-    p18 = next(item for item in manifest["properties"] if item["id"] == "P18")
-    assert p18["harness"] == "6400_transport_identification_properties.sby"
-    assert p18["requirement"].startswith("Identification stimulus stages 32")
-
-
-def test_stimulus_reload_commit_has_priority_over_same_cycle_expiry_tick() -> None:
-    core = (ROOT / "src/control/thermal_control_core.v").read_text(encoding="utf-8")
-    runner = (ROOT / "tools/run_6400_v1.py").read_text(encoding="utf-8")
-    directed_tb = (ROOT / "tests/sim/stimulus_reload_priority_tb.v").read_text(
+    adapter = (ROOT / "src/actuator/fan_board_output_adapter.v").read_text(
         encoding="utf-8"
     )
-    assert "end else if (tick_1s && stimulus_running) begin" in core
-    assert "$past(stimulus_commit_applied &&" in core
-    assert "stimulus_remaining ==\n                           $past(stimulus_duration_seconds)" in core
-    assert '"stimulus_reload_priority_tb"' in runner
-    assert "commit_vector(8'd7, 1'b1)" in directed_tb
-    assert "same-cycle reload was overwritten by expiry" in directed_tb
-
-
-def test_critical_safety_and_crc_properties_have_reachable_witnesses() -> None:
-    witnesses = {
-        property_id
-        for target in _manifest()["cover_targets"]
-        for property_id in target["witnesses"]
-    }
-    assert {"P03", "P04", "P05", "P06"} <= witnesses
-
-
-def test_core_composes_detection_fill_and_active_bank() -> None:
-    source = (ROOT / "src/control/thermal_control_core.v").read_text(encoding="utf-8")
-    assert "formal_stale_preempt" in source
-    assert "formal_inactive_applied" in source
-    assert "formal_active_applied" in source
-    assert "global_fault <= global_fault || bmc_stale" in source
-    assert "safe_fill_value" in source
-
-
-def test_bad_crc_is_composed_through_target_engine() -> None:
-    harness = (FORMAL / "6400_transport_properties_formal.v").read_text(encoding="utf-8")
-    frame = (ROOT / "src/common/frame_rx.v").read_text(encoding="utf-8")
-    command = (ROOT / "src/transport/thermal_host_command.v").read_text(encoding="utf-8")
-    assert "bad_crc_quarantine" in harness
-    assert "formal_bad_crc_event_o" in frame
-    assert "target_celsius != $past(target_celsius)" in command
-    assert "u_frame_rx.formal_" not in harness
-
-
-def test_runner_is_fail_closed_and_commit_bound() -> None:
-    runner = (ROOT / "tools/run_6400_formal.py").read_text(encoding="utf-8")
-    assert "formal acceptance requires a clean worktree" in runner
-    assert "PROD2U_CONTAINER_DIGEST" in runner
-    assert '"source_tree_sha256"' in runner
-    assert '"bitstream_sha256": None' in runner
+    assert "BOARD_INVERT_MASK = 8'h0F" in adapter
+    assert "front_ball == ~connector_request[3:0]" in harness
+    assert "rear_ball == connector_request[7:4]" in harness
+    assert "boot_release" not in harness
+    assert "force_full_speed" not in harness
+
+
+def test_long_acceptance_targets_are_explicitly_deferred() -> None:
+    deferred = set(manifest()["deferred_long_targets"])
+    assert {
+        "owner_watchdog",
+        "set_all_timeout_priority",
+        "manual_without_bmc",
+        "pid_stale_hold",
+        "hard_fault_cancels_manual",
+        "oversized_request",
+        "get_ack_before_data",
+        "snapshot_lock_stop_bit",
+        "reset_safe_pwm",
+    } <= deferred
+
+
+def test_formal_runner_uses_external_process_group_workdirs() -> None:
+    runner = (ROOT / "tools" / "run_6400_formal.py").read_text(encoding="utf-8")
+    assert "formal run base must be outside the Git worktree" in runner
     assert "start_new_session=True" in runner
     assert "os.killpg" in runner
-    assert "default=1" in runner
-    assert "solver_map" in runner
-
-
-def test_core_formal_does_not_assume_pwm_scan_is_always_idle() -> None:
-    harness = (FORMAL / "6400_core_properties_formal.v").read_text(encoding="utf-8")
-    core = (ROOT / "src/control/thermal_control_core.v").read_text(encoding="utf-8")
-    assert "(* anyseq *) reg pwm_scan_idle" in harness
-    assert ".pwm_scan_idle(pwm_scan_idle)" in harness
-    assert "active_output_bank != $past(active_output_bank)" in core
-    assert "$past(pwm_scan_idle)" in core
-
-
-def test_formal_run_base_is_external_and_rejects_git_worktree(
-    tmp_path: Path, monkeypatch: pytest.MonkeyPatch
-) -> None:
-    external = tmp_path / "formal-runs"
-    monkeypatch.setenv("PRODU2_FORMAL_RUN_BASE", str(external))
-    assert formal_run_base() == external.resolve()
-
-    monkeypatch.setenv("PRODU2_FORMAL_RUN_BASE", str(ROOT / "receipts"))
-    with pytest.raises(RuntimeError, match="outside the Git worktree"):
-        formal_run_base()
-
-
-def test_runner_timeout_kills_process_group_and_keeps_task_log_name(
-    tmp_path: Path, monkeypatch: pytest.MonkeyPatch
-) -> None:
-    if formal_runner.os.name != "posix":
-        pytest.skip("process-group timeout policy is Linux authoritative")
-
-    class StubbornProcess:
-        pid = 4242
-        returncode: int | None = None
-
-        def __init__(self) -> None:
-            self.communicate_calls = 0
-
-        def communicate(self, timeout: int | None = None) -> tuple[str, None]:
-            self.communicate_calls += 1
-            if self.communicate_calls == 1:
-                raise subprocess.TimeoutExpired("sby", timeout, output="partial\n")
-            if self.communicate_calls == 2:
-                raise subprocess.TimeoutExpired("sby", timeout, output="partial\nterm\n")
-            self.returncode = -signal.SIGKILL
-            return "partial\nterm\nkilled\n", None
-
-    process = StubbornProcess()
-    signals: list[tuple[int, signal.Signals]] = []
-    monkeypatch.setattr(formal_runner.subprocess, "Popen", lambda *args, **kwargs: process)
-    monkeypatch.setattr(
-        formal_runner.os,
-        "killpg",
-        lambda pid, sent_signal: signals.append((pid, sent_signal)),
-    )
-
-    result = formal_runner.run_job(
-        {
-            "target": {
-                "name": "core",
-                "sby": "6400_core_properties.sby",
-                "mode": "prove",
-                "depth": 4,
-            },
-            "task": "boolector",
-        },
-        tmp_path,
-        timeout=1,
-    )
-
-    assert signals == [(4242, signal.SIGTERM), (4242, signal.SIGKILL)]
-    process_log = tmp_path / "work" / "core" / "boolector.process.log"
-    assert process_log.read_text(encoding="utf-8") == "partial\nterm\nkilled\n"
-    assert result["process_log"]["path"] == process_log.as_posix()
-    assert result["timed_out"] is True
-    assert "timeout" in result["evidence_failures"]
-
-
-def test_runner_reads_yosys_jny_property_cell_sorts(tmp_path: Path) -> None:
-    model = tmp_path / "model"
-    model.mkdir()
-    (model / "design.json").write_text(json.dumps({
-        "modules": [{
-            "name": "formal_top",
-            "cell_sorts": [
-                {"type": "$assert", "cells": [{"name": "$assert$source.v:1$1"}]},
-                {"type": "$cover", "cells": [{"name": "$cover$source.v:2$2"}]},
-            ],
-        }],
-    }), encoding="utf-8")
-    assertions, covers, design_hash, failures = compiled_property_ids(tmp_path)
-    assert assertions == ["formal_top.$assert$source.v:1$1"]
-    assert covers == ["formal_top.$cover$source.v:2$2"]
-    assert len(design_hash) == 64
-    assert failures == []
-    assert property_cell_ids(["formal_top.dut.$cover$source.v:2$2"]) == {
-        "$cover$source.v:2$2"
-    }

+ 47 - 114
tests/unit/test_6400_profile_package.py

@@ -11,39 +11,36 @@ from tools import package_target
 
 
 ROOT = Path(__file__).resolve().parents[2]
+PROFILE = "6400-front-rear"
 TEST_COMMIT = "a" * 40
 TEST_SOURCE_COMMIT = "b" * 40
 
 
-def _receipt(
-    tmp_path: Path, profile_name: str, commit: str = TEST_SOURCE_COMMIT
-) -> Path:
-    profile = package_target.HARDWARE_PROFILES[profile_name]
-    inputs = package_target.td_input_manifest(profile_name)
+def _receipt(tmp_path: Path, commit: str = TEST_SOURCE_COMMIT) -> Path:
+    profile = package_target.HARDWARE_PROFILES[PROFILE]
+    inputs = package_target.td_input_manifest(PROFILE)
     bitstream = tmp_path / f"{profile['artifact_basename']}.bit"
     bitstream.write_bytes(b"TD-BIT-TEST")
     payload = {
         "schema": "prod2u-6400-td-receipt-v1",
         "status": "PASS",
-        "profile": profile_name,
+        "profile": PROFILE,
         "project": str(profile["project"]),
         "source_closure": str(profile["closure"]),
         "commit": commit,
-        "production": bool(profile["production"]),
-        "stimulus": bool(profile["stimulus"]),
+        "production": True,
+        "stimulus": False,
         "simulation_only": False,
         "artifact_basename": str(profile["artifact_basename"]),
         "timing_pass_25mhz": True,
         "project_sha256": package_target._sha256(ROOT / str(profile["project"])),
-        "source_closure_sha256": package_target._sha256(
-            ROOT / str(profile["closure"])
-        ),
+        "source_closure_sha256": package_target._sha256(ROOT / str(profile["closure"])),
         "source_manifest_sha256": hashlib.sha256(
             json.dumps(inputs, sort_keys=True, separators=(",", ":")).encode()
         ).hexdigest(),
         "inputs": inputs,
         "known_unbound_ports": [],
-        "deployment_status": package_target._expected_deployment_status(profile_name),
+        "deployment_status": package_target._expected_deployment_status(PROFILE),
         "warning_audit": {
             "status": "PASS",
             "expected_unbound_ports": [],
@@ -59,6 +56,13 @@ def _receipt(
     return path
 
 
+def test_only_front_rear_profile_is_active() -> None:
+    assert set(package_target.HARDWARE_PROFILES) == {PROFILE}
+    profile = package_target.HARDWARE_PROFILES[PROFILE]
+    assert profile["production"] is True
+    assert profile["stimulus"] is False
+
+
 def test_firmware_requires_explicit_profile_and_td_receipt(
     tmp_path: Path, monkeypatch: pytest.MonkeyPatch
 ) -> None:
@@ -67,164 +71,93 @@ def test_firmware_requires_explicit_profile_and_td_receipt(
         package_target.build_target_package("6400", "firmware", tmp_path)
     with pytest.raises(SystemExit, match="explicit --td-receipt is required"):
         package_target.build_target_package(
-            "6400", "firmware", tmp_path, profile_name="6400-control"
+            "6400", "firmware", tmp_path, profile_name=PROFILE
         )
-    with pytest.raises(SystemExit, match="Sim-Debug"):
+    with pytest.raises(SystemExit, match="explicitly select --profile"):
         package_target.build_target_package(
-            "6400", "firmware", tmp_path, profile_name="6400-sim-debug"
+            "6400", "firmware", tmp_path, profile_name="6400-identification"
         )
 
 
-@pytest.mark.parametrize("profile_name", ["6400-control", "6400-identification"])
-def test_td_receipt_is_profile_commit_closure_and_bit_bound(
-    tmp_path: Path, profile_name: str
-) -> None:
-    receipt_path = _receipt(tmp_path, profile_name)
-    commit = TEST_COMMIT
+def test_td_receipt_is_commit_closure_and_bit_bound(tmp_path: Path) -> None:
+    receipt_path = _receipt(tmp_path)
     bitstream, receipt = package_target._validated_td_bitstream(
-        profile_name, receipt_path, commit
+        PROFILE, receipt_path, TEST_COMMIT
     )
-    assert bitstream.name == f"{package_target.HARDWARE_PROFILES[profile_name]['artifact_basename']}.bit"
-    assert receipt["profile"] == profile_name
+    assert bitstream.name == "prod2u_6400_front_back.bit"
+    assert receipt["profile"] == PROFILE
     assert receipt["commit"] == TEST_SOURCE_COMMIT
-    assert receipt["commit"] != commit
-
     payload = json.loads(receipt_path.read_text(encoding="utf-8"))
     payload["source_closure_sha256"] = "0" * 64
     receipt_path.write_text(json.dumps(payload), encoding="utf-8")
     with pytest.raises(SystemExit, match="TD receipt mismatch"):
-        package_target._validated_td_bitstream(profile_name, receipt_path, commit)
+        package_target._validated_td_bitstream(PROFILE, receipt_path, TEST_COMMIT)
 
 
 @pytest.mark.parametrize(
     "tamper",
-    [
-        "input_digest",
-        "input_missing",
-        "ports_missing",
-        "ports_duplicate",
-        "deployment_status",
-        "warning_observed",
-    ],
+    ["input_digest", "input_missing", "ports_missing", "ports_duplicate", "warning_observed"],
 )
-def test_td_receipt_rejects_missing_duplicate_and_tampered_provenance(
-    tmp_path: Path, tamper: str
-) -> None:
-    receipt_path = _receipt(tmp_path, "6400-identification")
+def test_td_receipt_rejects_tampered_provenance(tmp_path: Path, tamper: str) -> None:
+    receipt_path = _receipt(tmp_path)
     payload = json.loads(receipt_path.read_text(encoding="utf-8"))
     if tamper == "input_digest":
-        first = next(iter(payload["inputs"]))
-        payload["inputs"][first] = "0" * 64
+        payload["inputs"][next(iter(payload["inputs"]))] = "0" * 64
     elif tamper == "input_missing":
         payload["inputs"].pop(next(iter(payload["inputs"])))
     elif tamper == "ports_missing":
         payload.pop("known_unbound_ports")
     elif tamper == "ports_duplicate":
-        payload["known_unbound_ports"].append("host_ttl_rx")
-    elif tamper == "deployment_status":
-        payload["deployment_status"] = package_target.CONTROL_DEPLOYMENT_STATUS
+        payload["known_unbound_ports"] = ["host_ttl_rx", "host_ttl_rx"]
     else:
         payload["warning_audit"]["observed_unbound_ports"].append("unexpected")
     receipt_path.write_text(json.dumps(payload), encoding="utf-8")
     with pytest.raises(SystemExit, match="TD receipt mismatch|warning audit mismatch"):
-        package_target._validated_td_bitstream(
-            "6400-identification", receipt_path, TEST_COMMIT
-        )
+        package_target._validated_td_bitstream(PROFILE, receipt_path, TEST_COMMIT)
 
 
-def test_control_source_package_contains_only_active_grouped_closure(tmp_path: Path) -> None:
+def test_source_package_contains_only_active_closure(tmp_path: Path) -> None:
     archive = package_target.build_target_package(
-        "6400", "source", tmp_path, profile_name="6400-control"
+        "6400", "source", tmp_path, profile_name=PROFILE
     )
     with zipfile.ZipFile(archive) as zipf:
         names = set(zipf.namelist())
         manifest = json.loads(zipf.read("manifest.json"))
         closure = json.loads(zipf.read("source-closure-expanded.json"))
         host_contract = json.loads(zipf.read("generated/6400/host-contract.json"))
-    assert manifest["profile"] == "6400-control"
+    assert manifest["profile"] == PROFILE
     assert manifest["top"] == "prod2u_6400_rs232_only_top"
     assert "src/actuator/fan_board_output_adapter.v" in closure["sources"]
     assert host_contract["wire"]["host_uart"]["baud"] == 921600
     assert host_contract["wire"]["responses"]["ACK_NACK"]["type"] == 0x06
-    assert host_contract["wire"]["responses"]["SNAPSHOT_DATA"]["type"] == 0x82
-    assert host_contract["canonical_profiles"]["6400-control"]["stimulus"] is False
-    assert not any(name.startswith("src/generated/6400/") for name in names)
-    assert not any("prod2u_6400_front_back_top" in name for name in names)
+    assert set(host_contract["canonical_profiles"]) == {PROFILE}
+    assert not any("identification" in name or "sim-debug" in name for name in names)
 
 
-@pytest.mark.parametrize(
-    ("profile_name", "expected_bit", "role", "production", "stimulus", "contract_text"),
-    [
-        (
-            "6400-control",
-            "prod2u_6400_front_back.bit",
-            "production",
-            True,
-            False,
-            "stimulus=false",
-        ),
-        (
-            "6400-identification",
-            "prod2u_6400_identification.bit",
-            "identification",
-            False,
-            True,
-            "不得作为 Production",
-        ),
-    ],
-)
-def test_firmware_package_is_fail_closed_and_profile_bound(
-    tmp_path: Path,
-    monkeypatch: pytest.MonkeyPatch,
-    profile_name: str,
-    expected_bit: str,
-    role: str,
-    production: bool,
-    stimulus: bool,
-    contract_text: str,
+def test_firmware_package_is_single_product_and_fail_closed(
+    tmp_path: Path, monkeypatch: pytest.MonkeyPatch
 ) -> None:
     monkeypatch.setattr(package_target, "_git", lambda *_args: TEST_COMMIT)
-    receipt = _receipt(tmp_path, profile_name)
+    receipt = _receipt(tmp_path)
     archive = package_target.build_target_package(
-        profile_name, "firmware", tmp_path / "out", td_receipt=receipt
+        PROFILE, "firmware", tmp_path / "out", td_receipt=receipt
     )
     with zipfile.ZipFile(archive) as zipf:
         names = set(zipf.namelist())
         manifest = json.loads(zipf.read("manifest.json"))
         instructions = zipf.read("FLASH-INSTRUCTIONS.zh-CN.txt").decode("utf-8")
-    assert manifest["profile"] == profile_name
-    assert manifest["firmware_role"] == role
-    assert manifest["production"] is production
-    assert manifest["stimulus"] is stimulus
+    assert manifest["profile"] == PROFILE
+    assert manifest["production"] is True and manifest["stimulus"] is False
     assert manifest["source_commit"] == TEST_SOURCE_COMMIT
-    assert manifest["package_commit"] == TEST_COMMIT
-    assert manifest["contract_sha256"] == package_target._contract_sha256()
-    assert manifest["source_closure_sha256"] == package_target._sha256(
-        ROOT / str(package_target.HARDWARE_PROFILES[profile_name]["closure"])
-    )
-    assert expected_bit in names
+    assert "prod2u_6400_front_back.bit" in names
     assert "source-manifest.json" in names
-    assert "921600 8N1" in instructions
-    assert "独立 ACK" in instructions
-    assert contract_text in instructions
-    expected_header = (
-        package_target.PRODUCTION_PROGRAM_LINE
-        if production
-        else package_target.IDENTIFICATION_PROGRAM_LINE
-    )
-    assert instructions.startswith(expected_header)
-    assert manifest["release_blocked"] is False
-    assert manifest["td_programmable"] is True
-    assert manifest["candidate_only"] is True
+    assert "921600 8N1" in instructions and "UNSUPPORTED NACK" in instructions
     assert manifest["hardware_validated"] is False
     assert manifest["deployable"] is False
-    assert manifest["production_deployable"] is False
-    assert manifest["identification_programmable"] is (not production)
     assert manifest["known_unbound_ports"] == []
-    assert "CANDIDATE-NOTICE.zh-CN.txt" not in names
 
 
-def test_blocked_firmware_selftest_rejects_programming_instructions(
+def test_firmware_selftest_rejects_unsafe_programming_instructions(
     tmp_path: Path, monkeypatch: pytest.MonkeyPatch
 ) -> None:
     monkeypatch.setattr(package_target, "_git", lambda *_args: TEST_COMMIT)
@@ -233,8 +166,8 @@ def test_blocked_firmware_selftest_rejects_programming_instructions(
         "PRODUCTION_PROGRAM_LINE",
         "RS-232-ONLY PRODUCTION TD PASS\n3. 先执行 Erase/Program",
     )
-    receipt = _receipt(tmp_path, "6400-control")
+    receipt = _receipt(tmp_path)
     with pytest.raises(SystemExit, match="Host UART/ACK contract missing"):
         package_target.build_target_package(
-            "6400-control", "firmware", tmp_path / "out", td_receipt=receipt
+            PROFILE, "firmware", tmp_path / "out", td_receipt=receipt
         )

+ 19 - 46
tests/unit/test_6400_td_parser.py

@@ -18,7 +18,7 @@ SPEC.loader.exec_module(run_6400_td)
 def test_td_synthesis_uses_source_root_for_generated_includes() -> None:
     script = (ROOT / "td/syn/prod2u_6400_front_back.tcl").read_text(encoding="utf-8")
     closure = json.loads(
-        (ROOT / "products/6400-control/source-closure.json").read_text(encoding="utf-8")
+        (ROOT / "products/6400-front-rear/source-closure.json").read_text(encoding="utf-8")
     )
     expected_verilog = [path for path in closure["sources"] if path.endswith(".v")]
 
@@ -31,7 +31,7 @@ def test_td_synthesis_uses_source_root_for_generated_includes() -> None:
 def test_td_source_closure_keeps_fan_adapter_before_production_top() -> None:
     script = (ROOT / "td/syn/prod2u_6400_front_back.tcl").read_text(encoding="utf-8")
     closure = json.loads(
-        (ROOT / "products/6400-control/source-closure.json").read_text(encoding="utf-8")
+        (ROOT / "products/6400-front-rear/source-closure.json").read_text(encoding="utf-8")
     )
     adapter = "src/actuator/fan_board_output_adapter.v"
     top = "src/top/prod2u_6400_v1_top.v"
@@ -44,57 +44,30 @@ def test_td_source_closure_keeps_fan_adapter_before_production_top() -> None:
     )
 
 
-def test_identification_td_uses_expanded_profile_closure_and_distinct_top() -> None:
-    script = (ROOT / "td/syn/prod2u_6400_identification.tcl").read_text(
-        encoding="utf-8"
-    )
-    expected_sources, closure_inputs = run_6400_td.source_closure(
-        "6400-identification"
-    )
-    expected_verilog = [path for path in expected_sources if path.endswith(".v")]
-
-    assert [f"analyze_src {{{path}}}" for path in expected_verilog] == [
-        line for line in script.splitlines() if line.startswith("analyze_src {")
-    ]
-    assert "elaborate -top {prod2u_6400_identification_top}" in script
-    assert closure_inputs == [
-        "products/6400-identification/source-closure.json",
-        "products/6400-control/source-closure.json",
-    ]
-
-
-def test_td_hardware_profiles_keep_roles_and_artifacts_unambiguous() -> None:
+def test_td_hardware_profile_is_single_front_rear_product() -> None:
     profiles = run_6400_td.HARDWARE_PROFILES
-    assert set(profiles) == {"6400-control", "6400-identification"}
-    assert "6400-sim-debug" not in profiles
-    assert profiles["6400-control"]["production"] is True
-    assert profiles["6400-control"]["stimulus"] is False
-    assert profiles["6400-identification"]["production"] is False
-    assert profiles["6400-identification"]["stimulus"] is True
-    assert profiles["6400-control"]["artifact_basename"] != profiles[
-        "6400-identification"
-    ]["artifact_basename"]
-
-    manifest = run_6400_td.input_manifest("6400-identification")
-    assert "src/top/prod2u_6400_identification_top.v" in manifest
-    assert "td/prod2u_6400_identification.prj" in manifest
-    assert "td/bitgen/prod2u_6400_identification.tcl" in manifest
-
-    receipt_fields = run_6400_td.profile_receipt_fields("6400-identification")
+    assert set(profiles) == {"6400-front-rear"}
+    profile = profiles["6400-front-rear"]
+    assert profile["production"] is True
+    assert profile["stimulus"] is False
+    manifest = run_6400_td.input_manifest("6400-front-rear")
+    assert "src/top/prod2u_6400_rs232_only_top.v" in manifest
+    assert "td/prod2u_6400_front_back.prj" in manifest
+    assert "td/bitgen/prod2u_6400_front_back.tcl" in manifest
+    receipt_fields = run_6400_td.profile_receipt_fields("6400-front-rear")
     assert receipt_fields == {
-        "profile": "6400-identification",
-        "firmware_role": "identification",
-        "production": False,
-        "stimulus": True,
+        "profile": "6400-front-rear",
+        "firmware_role": "production",
+        "production": True,
+        "stimulus": False,
         "simulation_only": False,
-        "artifact_basename": "prod2u_6400_identification",
+        "artifact_basename": "prod2u_6400_front_back",
         "hardware_host_interfaces": ["host_rs232"],
     }
-    bitgen = (ROOT / "td/bitgen/prod2u_6400_identification.tcl").read_text(
+    bitgen = (ROOT / "td/bitgen/prod2u_6400_front_back.tcl").read_text(
         encoding="utf-8"
     )
-    assert "bitgen -bit prod2u_6400_identification.bit" in bitgen
-    assert "prod2u_6400_front_back.bit" not in bitgen
+    assert "bitgen -bit prod2u_6400_front_back.bit" in bitgen
     assert "unconstr_io" not in bitgen
 
 

+ 16 - 28
tests/unit/test_6400_v1_contract.py

@@ -79,10 +79,7 @@ def test_fan_contract_drives_params_active_adc_and_both_td_profiles() -> None:
             )
             assert re.search(pattern, adc), (group, lane, row["fpga_ball"])
 
-    for script_name in (
-        "td/syn/prod2u_6400_front_back.tcl",
-        "td/syn/prod2u_6400_identification.tcl",
-    ):
+    for script_name in ("td/syn/prod2u_6400_front_back.tcl",):
         script = (ROOT / script_name).read_text(encoding="utf-8")
         assert "read_adc [src {constraints/prod2u_6400_front_back.adc}]" in script
         assert "src/generated/6400" not in script
@@ -95,32 +92,23 @@ def test_fan_contract_drives_params_active_adc_and_both_td_profiles() -> None:
     assert '`define FB_BOARD_ID "fcb_fpga_mcu_v1_1_20260625"' in params
 
 
-def test_hardware_profiles_bind_v11_constraints_and_rs232_only_tops() -> None:
-    control = yaml.safe_load(
-        (ROOT / "products/6400-control/project.json").read_text(encoding="utf-8")
+def test_single_hardware_product_binds_v11_constraints_and_rs232_top() -> None:
+    product = yaml.safe_load(
+        (ROOT / "products/6400-front-rear/project.json").read_text(encoding="utf-8")
     )
-    identification = yaml.safe_load(
-        (ROOT / "products/6400-identification/project.json").read_text(
-            encoding="utf-8"
-        )
+    assert product["board_id"] == "fcb_fpga_mcu_v1_1_20260625"
+    assert product["constraints"] == "constraints/prod2u_6400_front_back.adc"
+    assert product["timing_constraints"] == "constraints/prod2u_6400_front_back.sdc"
+    assert product["top"] == "prod2u_6400_rs232_only_top"
+    assert product["host_interfaces"] == ["host_rs232"]
+    source = (ROOT / "src/top/prod2u_6400_rs232_only_top.v").read_text(
+        encoding="utf-8"
     )
-    assert control["board_id"] == "fcb_fpga_mcu_v1_1_20260625"
-    assert control["constraints"] == "constraints/prod2u_6400_front_back.adc"
-    assert control["timing_constraints"] == "constraints/prod2u_6400_front_back.sdc"
-    assert control["top"] == "prod2u_6400_rs232_only_top"
-    assert control["host_interfaces"] == ["host_rs232"]
-    assert identification["host_interfaces"] == ["host_rs232"]
-
-    for path in (
-        ROOT / "src/top/prod2u_6400_rs232_only_top.v",
-        ROOT / "src/top/prod2u_6400_identification_top.v",
-    ):
-        source = path.read_text(encoding="utf-8")
-        module_ports = source.split(");", 1)[0]
-        assert "host_ttl_rx" not in module_ports
-        assert "host_ttl_tx" not in module_ports
-        assert ".host_ttl_rx(1'b1)" in source
-        assert "host_ttl_tx_unused" in source
+    module_ports = source.split(");", 1)[0]
+    assert "host_ttl_rx" not in module_ports
+    assert "host_ttl_tx" not in module_ports
+    assert ".host_ttl_rx(1'b1)" in source
+    assert "host_ttl_tx_unused" in source
 
 
 def test_generated_standby_duty_reaches_the_production_core() -> None:

+ 1 - 1
tests/unit/test_fw_multiproject.py

@@ -21,7 +21,7 @@ class MultiProjectRegistryTests(unittest.TestCase):
         aliases = list_aliases(ROOT)
         self.assertEqual(set(aliases), {"mrdimm", "6400"})
         self.assertEqual(resolve_target("mrdimm", ROOT)["project_id"], "prod2u-door-temp")
-        self.assertEqual(resolve_target("6400", ROOT)["project_id"], "6400-control")
+        self.assertEqual(resolve_target("6400", ROOT)["project_id"], "6400-front-rear")
         with self.assertRaises(ValueError):
             resolve_target("no-such-target", ROOT)
 

+ 5 - 4
tests/unit/test_multiproject_targets.py

@@ -27,7 +27,7 @@ class MultiProjectRegistryTests(unittest.TestCase):
         self.assertEqual(mrdimm.alias, "mrdimm")
         self.assertEqual(six.alias, "6400")
         self.assertEqual(mrdimm.project_id, "prod2u-door-temp")
-        self.assertEqual(six.project_id, "6400-control")
+        self.assertEqual(six.project_id, "6400-front-rear")
         self.assertNotEqual(mrdimm.generated_dir, six.generated_dir)
 
     def test_unknown_target_fails_fast(self):
@@ -59,9 +59,10 @@ class MultiProjectRegistryTests(unittest.TestCase):
             contract = ROOT / "generated" / "6400" / "host-contract.json"
             self.assertTrue(contract.is_file())
             payload = json.loads(contract.read_text(encoding="utf-8"))
-            self.assertEqual(payload["schema"], "prod2u-6400-host-contract-v2")
-            self.assertTrue(payload["canonical_profiles"]["6400-control"]["production"])
-            self.assertFalse(payload["canonical_profiles"]["6400-control"]["stimulus"])
+            self.assertEqual(payload["schema"], "prod2u-6400-host-contract-v3")
+            self.assertEqual(set(payload["canonical_profiles"]), {"6400-front-rear"})
+            self.assertTrue(payload["canonical_profiles"]["6400-front-rear"]["production"])
+            self.assertFalse(payload["canonical_profiles"]["6400-front-rear"]["stimulus"])
             _ = first, second, gen
 
     def test_source_closures_are_disjoint_for_motors(self):

+ 93 - 0
tools/check_6400_closures.py

@@ -0,0 +1,93 @@
+#!/usr/bin/env python3
+"""Check and hash production-TD and analysis-replay closures separately."""
+
+from __future__ import annotations
+
+import argparse
+import hashlib
+import json
+from pathlib import Path
+
+
+ROOT = Path(__file__).resolve().parents[1]
+PRODUCT = ROOT / "products/6400-front-rear"
+PRODUCTION = PRODUCT / "source-closure.json"
+ANALYSIS = PRODUCT / "analysis-replay-closure.json"
+TD_INPUTS = (
+    "constraints/prod2u_6400_front_back.adc",
+    "constraints/prod2u_6400_front_back.sdc",
+    "td/prod2u_6400_front_back.prj",
+    "td/syn/prod2u_6400_front_back.tcl",
+    "td/phy/prod2u_6400_front_back.tcl",
+    "td/bitgen/prod2u_6400_front_back.tcl",
+    "products/6400-front-rear/project.json",
+    "products/6400-front-rear/source-closure.json",
+)
+
+
+def sha256(path: Path) -> str:
+    digest = hashlib.sha256()
+    with path.open("rb") as stream:
+        for chunk in iter(lambda: stream.read(1024 * 1024), b""):
+            digest.update(chunk)
+    return digest.hexdigest()
+
+
+def safe_paths(values: object, label: str) -> list[str]:
+    if not isinstance(values, list) or not values:
+        raise ValueError(f"{label} closure must be a non-empty list")
+    result: list[str] = []
+    for value in values:
+        if not isinstance(value, str) or not value:
+            raise ValueError(f"{label} closure has invalid path")
+        path = Path(value)
+        if path.is_absolute() or ".." in path.parts or "\\" in value:
+            raise ValueError(f"{label} closure has unsafe path: {value}")
+        result.append(value)
+    if len(result) != len(set(result)):
+        raise ValueError(f"{label} closure has duplicate paths")
+    return result
+
+
+def build_receipt() -> dict[str, object]:
+    production_payload = json.loads(PRODUCTION.read_text(encoding="utf-8"))
+    analysis_payload = json.loads(ANALYSIS.read_text(encoding="utf-8"))
+    production_sources = safe_paths(production_payload.get("sources"), "production")
+    analysis_paths = safe_paths(analysis_payload.get("paths"), "analysis")
+    production_paths = list(dict.fromkeys([*production_sources, *TD_INPUTS]))
+    missing_production = [path for path in production_paths if not (ROOT / path).is_file()]
+    missing_analysis = [path for path in analysis_paths if not (ROOT / path).is_file()]
+    if missing_production or missing_analysis:
+        raise ValueError(
+            f"closure missing files: production={missing_production} analysis={missing_analysis}"
+        )
+    return {
+        "schema": "prod2u-6400-closure-check-v1",
+        "project_id": "6400-front-rear",
+        "production_source_closure": {
+            "path": str(PRODUCTION.relative_to(ROOT)),
+            "files": {path: sha256(ROOT / path) for path in production_paths},
+        },
+        "analysis_replay_closure": {
+            "path": str(ANALYSIS.relative_to(ROOT)),
+            "files": {path: sha256(ROOT / path) for path in analysis_paths},
+        },
+    }
+
+
+def main() -> int:
+    parser = argparse.ArgumentParser()
+    parser.add_argument("--output", type=Path)
+    args = parser.parse_args()
+    payload = build_receipt()
+    text = json.dumps(payload, indent=2, sort_keys=True) + "\n"
+    if args.output:
+        args.output.parent.mkdir(parents=True, exist_ok=True)
+        args.output.write_text(text, encoding="utf-8")
+    else:
+        print(text, end="")
+    return 0
+
+
+if __name__ == "__main__":
+    raise SystemExit(main())

+ 1 - 1
tools/generate_6400.py

@@ -441,7 +441,7 @@ def generate_6400(
         "schema": "prod2u-simple-source-manifest-template-v1",
         "lifecycle": "historical_only",
         "active_product": False,
-        "superseded_by": "products/6400-control/source-closure.json",
+        "superseded_by": "products/6400-front-rear/source-closure.json",
         "project_id": PROJECT_ID,
         "target_alias": target_alias,
         "top_module": "prod2u_6400_front_back_top",

+ 1 - 1
tools/generate_target.py

@@ -23,7 +23,7 @@ def generate_named_target(name: str, *, repo: Path | None = None) -> dict[str, A
             if not path.is_file() or path.read_bytes() != content:
                 path.write_bytes(content)
         return {
-            "project_id": "6400-control",
+            "project_id": "6400-front-rear",
             "project_config_sha256": hashlib.sha256(
                 target.project_config.read_bytes()
             ).hexdigest(),

+ 1 - 0
tools/requirements-verify.txt

@@ -1,4 +1,5 @@
 pytest>=8
+PyYAML>=6
 jsonschema>=4
 psutil>=5
 cocotb>=1.8

+ 3 - 3
tools/run_6400_formal.py

@@ -1,5 +1,5 @@
 #!/usr/bin/env python3
-"""Run and bind the complete 6400 P01-P18 formal acceptance suite."""
+"""Run and bind the active 6400-front-rear Formal target registry."""
 
 from __future__ import annotations
 
@@ -25,8 +25,8 @@ MANIFEST = FORMAL_DIR / "6400-properties.json"
 SOLVER_MAP = FORMAL_DIR / "solver-map.yaml"
 ENVIRONMENT_RECEIPT = ROOT / "receipts" / "environment" / "container-image.json"
 PROJECT_CONTRACT = ROOT / "projects" / "prod2u-6400-front-back" / "project.json"
-PROFILE_CONTRACT = ROOT / "products" / "6400-control" / "project.json"
-SOURCE_MANIFEST = ROOT / "products" / "6400-control" / "source-closure.json"
+PROFILE_CONTRACT = ROOT / "products" / "6400-front-rear" / "project.json"
+SOURCE_MANIFEST = ROOT / "products" / "6400-front-rear" / "source-closure.json"
 DESIGN_LOCK = ROOT / "docs" / "architecture" / "6400-v1-design-lock.md"
 RECEIPT_SCHEMA = "prod2u-6400-formal-receipt-v1"