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

merge 6400 front-rear v1.1 30s convergence

root 3 месяцев назад
Родитель
Сommit
62af23921f
100 измененных файлов с 4057 добавлено и 3677 удалено
  1. 74 0
      ACTIVE_FIX_LOCK.yaml
  2. 46 0
      ACTIVE_TASK_LOCK.md
  3. 77 0
      ACTIVE_TASK_LOCK.yaml
  4. 4 3
      AGENTS.md
  5. 9 0
      BLOCKERS.md
  6. 13 0
      DECISION_TRACE.md
  7. 38 0
      QUICK_PROGRESS.md
  8. 15 7
      contracts/6400-snapshot.yaml
  9. 29 20
      contracts/6400-wire.yaml
  10. 2 2
      contracts/controller-coefficients.yaml
  11. 9 6
      contracts/fan-control-parameters.yaml
  12. 42 75
      docs/architecture/6400-v1-design-lock.md
  13. 9 18
      docs/audits/01-requirements-product-boundary.md
  14. 9 25
      docs/audits/02-board-electrical-evidence.md
  15. 8 19
      docs/audits/03-rtl-reuse-resource-structure.md
  16. 10 20
      docs/audits/04-protocol-state-safety.md
  17. 9 20
      docs/audits/05-multirepo-environment-replay.md
  18. 1 1
      docs/generated/6400-channel-map.md
  19. 32 47
      docs/prod2u-6400-front-back-protocol.zh-CN.md
  20. 1 1
      generated/6400/channel-map.json
  21. 1 1
      generated/6400/contract-sha256.txt
  22. 5 9
      generated/6400/controller-coefficients.json
  23. 17 13
      generated/6400/fan-control-parameters.json
  24. 1 1
      generated/6400/fixed-point.json
  25. 13 8
      generated/6400/golden-vectors.json
  26. 189 139
      generated/6400/host-contract.json
  27. 51 32
      generated/6400/prod2u_6400_v1_params.vh
  28. 76 27
      generated/6400/snapshot-layout.json
  29. 3 1
      products/6400-control/project.json
  30. 2 2
      products/6400-control/source-closure.json
  31. 55 0
      products/6400-front-rear/analysis-replay-closure.json
  32. 24 0
      products/6400-front-rear/project.json
  33. 33 0
      products/6400-front-rear/source-closure.json
  34. 1 1
      products/6400-identification/source-closure.json
  35. 1 1
      products/6400-sim-debug/source-closure.json
  36. 8 8
      projects/registry.json
  37. 21 0
      protocol-compatibility.json
  38. 3 11
      src/actuator/fan_board_output_adapter.v
  39. 57 94
      src/actuator/pwm_bitmap_engine.v
  40. 1 1
      src/common/AGENTS.md
  41. 13 11
      src/common/frame_rx.v
  42. 12 3
      src/common/uart_rx_byte.v
  43. 40 0
      src/control/manual_set_all_bank.v
  44. 433 992
      src/control/thermal_control_core.v
  45. 2 2
      src/generated/6400/td-source-manifest.json
  46. 6 3
      src/rtl/prod2u_p4_i2c_stop_start_read.v
  47. 47 15
      src/telemetry/thermal_snapshot_mux.v
  48. 45 47
      src/top/prod2u_6400_v1_top.v
  49. 142 164
      src/transport/thermal_host_command.v
  50. 1 2
      td/syn/prod2u_6400_front_back.tcl
  51. 1 1
      td/syn/prod2u_6400_identification.tcl
  52. 1 5
      tests/cocotb/prod2u_6400_v1_cocotb_top.v
  53. 7 2
      tests/cocotb/run_6400_pi_differential.py
  54. 7 9
      tests/cocotb/run_6400_v1_integration.py
  55. 112 269
      tests/cocotb/test_6400_pi_differential.py
  56. 67 300
      tests/cocotb/test_6400_v1_control_integration.py
  57. 88 218
      tests/cocotb/test_6400_v1_host_protocol_integration.py
  58. 0 248
      tests/cocotb/test_6400_v1_identification_integration.py
  59. 68 47
      tests/cocotb/test_6400_v1_soak.py
  60. 6 6
      tests/cocotb/thermal_6400_uart.py
  61. 21 13
      tests/cocotb/thermal_control_core_cocotb_top.v
  62. 172 37
      tests/formal/6400-properties.json
  63. 20 0
      tests/formal/6400_board_adapter_properties.sby
  64. 16 0
      tests/formal/6400_board_adapter_properties_formal.v
  65. 24 0
      tests/formal/6400_core_owner_properties.sby
  66. 152 0
      tests/formal/6400_core_owner_properties_formal.v
  67. 22 0
      tests/formal/6400_core_transition_properties.sby
  68. 21 0
      tests/formal/6400_frame_rx_properties.sby
  69. 45 0
      tests/formal/6400_frame_rx_properties_formal.v
  70. 21 0
      tests/formal/6400_host_command_properties.sby
  71. 102 0
      tests/formal/6400_host_command_properties_formal.v
  72. 1 1
      tests/formal/6400_pwm_properties.sby
  73. 17 22
      tests/formal/6400_pwm_properties_formal.v
  74. 21 0
      tests/formal/6400_set_all_commit_properties.sby
  75. 57 0
      tests/formal/6400_set_all_commit_properties_formal.v
  76. 4 1
      tests/formal/6400_snapshot_properties_formal.v
  77. 23 0
      tests/formal/6400_snapshot_transport_properties.sby
  78. 106 0
      tests/formal/6400_snapshot_transport_properties_formal.v
  79. 49 15
      tests/formal/solver-map.yaml
  80. 25 5
      tests/sim/frame_rx_tb.v
  81. 30 13
      tests/sim/pwm_bitmap_engine_tb.v
  82. 111 135
      tests/sim/thermal_control_core_tb.v
  83. 119 0
      tests/sim/thermal_control_hard_race_tb.v
  84. 116 0
      tests/sim/thermal_host_command_v2_tb.v
  85. 80 0
      tests/unit/test_6400_canonical_packages.py
  86. 15 0
      tests/unit/test_6400_closure_separation.py
  87. 4 4
      tests/unit/test_6400_contract.py
  88. 52 239
      tests/unit/test_6400_formal_contract.py
  89. 35 0
      tests/unit/test_6400_hex_gui_v2.py
  90. 48 116
      tests/unit/test_6400_profile_package.py
  91. 19 46
      tests/unit/test_6400_td_parser.py
  92. 39 45
      tests/unit/test_6400_v1_contract.py
  93. 9 8
      tests/unit/test_6400_v1_source_closure.py
  94. 6 15
      tests/unit/test_encode_6400_hex.py
  95. 1 1
      tests/unit/test_fw_multiproject.py
  96. 5 4
      tests/unit/test_multiproject_targets.py
  97. 190 0
      tools/6400_hex_gui.py
  98. 69 0
      tools/build_6400_hex_gui.py
  99. 93 0
      tools/check_6400_closures.py
  100. 0 0
      tools/encode_6400_hex.py

+ 74 - 0
ACTIVE_FIX_LOCK.yaml

@@ -0,0 +1,74 @@
+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
+current_committed_head: ecd1493e98d15ae330f0f504ae9c8912979a6966
+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: PASS_base_current_delivery_fresh_extraction_tamper_rejection
+  host_ttl_physical_pins: BLOCKED_EVIDENCE
+execution:
+  phase: LONG_VALIDATION_IN_PROGRESS
+  long_tests_before_quick: forbidden
+  hardware: NOT_RUN
+  com: NOT_RUN
+  jtag: NOT_RUN
+  pre_configuration_output: NOT_VERIFIED
+last_test: FOCUSED_PASS_generator_closure_lint_unit21_icarus_cocotb_hard_race
+formal_latest: core_owner_k_induction_PASS94s_core_transitions_bmc90_PASS125s_frame_rx_PASS_snapshot_boolector_PASS
+next: commit_formal_split_then_full_formal_registry_and_affected_mrdimm_gate

+ 46 - 0
ACTIVE_TASK_LOCK.md

@@ -0,0 +1,46 @@
+# ACTIVE TASK LOCK — 6400-front-rear-v1 production migration
+
+- Owner: single Codex production writer; no sub-agents.
+- Branch: `codex/6400-front-rear-v1-prod`.
+- Worktree: `/data/prod2u/worktrees/6400-front-rear-v1-prod`.
+- Base: `127db8eef879a6c0cad0e97b485c28d59944afa9` (`dev`).
+- Authority: root `AGENTS.md` plus the delegated 2026-08-25 production contract.
+- Hardware: 6400 V1.1, EF2L45BG256B, 25 MHz, no PLL.
+- Protected: no COM/JTAG/programming/driver install/global PATH changes.
+- External run roots: `/data/prod2u/cpld-runs/`, `/data/prod2u/deliveries/`.
+- Evidence boundary: Hardware and PRE_CONFIGURATION_OUTPUT are NOT RUN / NOT VERIFIED.
+
+## Frozen decisions for this task
+
+- Host RS232/TTL 921600 8N1; BMC RS232 115200.
+- Output order is PTC0..23, Front0..3, Rear0..3.
+- Connector-side duty is canonical everywhere; `FAN_BOARD_INVERT_MASK=8'h0F` is the only fan polarity adapter.
+- Safe output is PTC 0 and all connector fans 20 for Reset, Boot, Standby, watchdog transition, PID wait, and ordinary non-overtemp global fault.
+- Only confirmed >=77 C lane hard protect may force lane PTC 0 / fans 100.
+- Modes: BOOT_WAIT, MANUAL_SET_ALL, PID_WAIT_SENSOR, PID_AUTO, HARD_PROTECT.
+- Watchdog: 10 s; default PID target: 70 C.
+- `0x03` remains SET_STIMULUS; Production returns UNSUPPORTED NACK; Identification/Sim Debug retain payload/behavior.
+- Host commands: 01 SET_ALL, 02 GET_SNAPSHOT, 03 SET_STIMULUS, 04 SET_PID_TARGET, 06 ACK_NACK, 82 SNAPSHOT_DATA.
+- Unified response payload: `[ok, request_type, status, detail]` with status 0..4.
+- Invalid header/CRC/partial/timeout/framing are silent; each complete CRC-valid request gets exactly one ACK/NACK, GET additionally gets DATA.
+- Only a legal atomically committed SET_ALL feeds the watchdog; commit wins over same-cycle expiry.
+- Snapshot and selected Host port stay locked through final DATA CRC stop bit.
+- GUI is HEX-only, generated from the same Host Contract and Golden Vector; no serial access.
+
+## Ordered gates
+
+1. Q0 contract/generator/RTL/golden/GUI and static invariants.
+2. Q1 deterministic generation, hashes, lint, focused unit/Icarus/cocotb.
+3. Q2 clean committed source, fresh TD synth/P&R/setup/hold/bitgen.
+4. Q3 same commit/profile packages under `/data/prod2u/deliveries/6400-v11-quick/<timestamp>-<commit8>/`.
+5. Q4 report QUICK CANDIDATE READY with WSL and Windows absolute paths; then continue automatically.
+6. L1-L6 bounded formal, full integration, fuzz/soak/mutation/race, legacy once after freeze, resource/timing capture, separate FINAL candidate.
+
+## Current state
+
+- Q0: COMPLETE — active registry 01/02/03/04 unique; responses 06/82; invert mask 0F; V1.1 PTC/FAN/ADC constraints unchanged.
+- Q1: COMPLETE — deterministic generator 10 files; Verilator+Yosys lint PASS; focused unit 21 PASS (related expanded set 43 PASS); Icarus Host/mode/PWM PASS; cocotb full-bit Host protocol 1 PASS.
+- Focused reset proof: three consecutive 50,000-clock periods each PTC high 0, connector FAN high 10,000, Front Ball low 10,000, Rear Ball high 10,000.
+- Q2-Q4: PENDING.
+- L1-L6: PENDING.
+- Hardware: NOT RUN.

+ 77 - 0
ACTIVE_TASK_LOCK.yaml

@@ -0,0 +1,77 @@
+schema: prod2u-active-task-lock-v1
+task: 6400-front-rear-v11-30s-single-product
+baseline_commit: 127db8eef879a6c0cad0e97b485c28d59944afa9
+implementation_commit: SELF_Q3_CLEAN_COMMIT
+branch: feature/6400-front-rear-v11-30s
+workspace: /data/prod2u/worktrees/6400-front-rear-v11-30s
+product: 6400-front-rear
+board: FCB_V1.1
+device: EF2L45BG256B
+clock_hz: 25000000
+pll: forbidden
+uart:
+  host_rs232: 921600_8N1
+  host_ttl: 921600_8N1_LOGICAL_ONLY_PINS_BLOCKED_EVIDENCE
+  bmc_rs232: 115200_8N1
+pins:
+  clock: J1
+  host_rs232: {tx: M10, rx: N11}
+  host_ttl: {tx: unknown, rx: unknown}
+  bmc_rs232: {tx: L10, rx: M9}
+  ct7428: {scl: M8, sda: N9}
+  front: [B1, C4, B5, A14]
+  rear: [P15, N15, M14, P5]
+  ptc: [R7, T6, R5, T4, G16, F16, R3, T2, R1, P1, N1, M1, P7, P8, N16, M16, R16, P16, T12, T13, R10, P10, P9, T9]
+polarity:
+  ptc_active_high: true
+  fan_duty_semantics: connector_high_percent
+  fan_board_invert_mask: 0x0F
+  inversion_location: board_adapter_only
+pwm:
+  ptc_hz: 500
+  fan_hz: 500
+  period_clocks: 50000
+  safe_fan_high_clocks_at_20_percent: 10000
+safe_output: {ptc_percent: 0, front_percent: 20, rear_percent: 20}
+control:
+  owners: [OWNER_SAFE, OWNER_MANUAL, OWNER_PID]
+  initial_owner: OWNER_SAFE
+  watchdog_seconds: 30
+  watchdog_500us_ticks: 60000
+  watchdog_test_override: WATCHDOG_TICKS_OVERRIDE
+  default_pid_target_c: 70
+  transitions:
+    - SAFE_timeout_to_PID_wait_new_valid_bmc_epoch
+    - SET_ALL_commit_to_MANUAL_reload_watchdog
+    - MANUAL_timeout_atomic_safe_then_PID_wait_new_valid_bmc_epoch
+    - SET_ALL_commit_wins_over_same_cycle_timeout
+    - SET_PID_TARGET_does_not_change_owner_or_feed_watchdog
+safety:
+  channel_clamp_c: 76
+  lane_hard_protect_c: 77
+  lane_release_c: 72
+  lane_release_new_epochs: 3
+commands:
+  SET_ALL: 0x01
+  GET_SNAPSHOT: 0x02
+  SET_STIMULUS_RESERVED_EXISTING: 0x03
+  SET_PID_TARGET: 0x04
+  ACK_NACK: 0x06
+  SNAPSHOT_DATA: 0x82
+ack_payload: [ok, request_type, status, detail]
+ack_status: {OK: 0, UNSUPPORTED: 1, BAD_LENGTH: 2, BAD_VALUE: 3, SAFETY_LOCKED: 4}
+profile_behavior_0x03: UNSUPPORTED_NACK
+q0_evidence:
+  adc: constraints/prod2u_6400_front_back.adc
+  registry: projects/registry.json
+  channel_map: contracts/channel-map.yaml
+  current_host_contract: generated/6400/host-contract.json
+  compatibility: protocol-compatibility.json
+blockers:
+  - HOST_TTL_PHYSICAL_PINS_BLOCKED_EVIDENCE
+pre_configuration_output: NOT_VERIFIED
+hardware: NOT_RUN
+com: NOT_RUN
+jtag: NOT_RUN
+recent_test: Q2_FOCUSED_TESTS_PASS_GENERATOR_LINT_UNIT_ICARUS_PWM_COCOTB
+next_step: Q3_clean_commit_fresh_td2026_synth_place_route_timing_bitgen

+ 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
 

+ 9 - 0
BLOCKERS.md

@@ -0,0 +1,9 @@
+# Blockers
+
+## HOST_TTL_PHYSICAL_PINS — BLOCKED_EVIDENCE
+
+The active V1.1 ADC, `constraints/prod2u_6400_front_back.adc`, identifies itself as the `CON78 RS-232-only physical top` and constrains only Host RS-232 TX/RX at M10/N11. It contains no authoritative Host TTL connector or FPGA-ball assignments.
+
+`projects/registry.json` records `hardware_host_interfaces` as `CON78_RS232_921600_8N1` and states `logical_host_ttl_status` is `implemented_but_disabled_in_hardware_profile_until_pins_are_confirmed`.
+
+No TTL pin is guessed or added. The 921600 8N1 logical Host TTL contract may remain represented, but physical TTL delivery is `BLOCKED_EVIDENCE` until authoritative board evidence supplies the connector and balls. This blocker does not alter the confirmed RS-232, BMC, CT7428, 24 PTC, four Front, or four Rear constraints.

+ 13 - 0
DECISION_TRACE.md

@@ -0,0 +1,13 @@
+# Decision trace
+
+## 2026-08-25 destructive Host/control migration
+
+Accepted by explicit delegated production contract:
+
+- Replace SET_TARGET/0x81, standalone 0x82 ACK, 0x42 DATA and silent semantic rejection with SET_ALL, SET_PID_TARGET, unified 0x06 ACK/NACK and 0x82 DATA.
+- Preserve command 0x03 as SET_STIMULUS; Production returns UNSUPPORTED, Identification/Sim Debug retain its payload.
+- Replace autonomous-on-Host-disconnect behavior with BOOT/MANUAL/PID_WAIT/PID_AUTO/HARD_PROTECT modes and a SET_ALL-only 10-second watchdog.
+- Replace boot/BMC-stale/global-fault full-speed fan overrides with connector FAN20; reserve lane FAN100 for confirmed >=77 C hard protection.
+- Separate control reset from the safe PWM carrier and retain `8'h0F` as the sole Front/Rear board polarity adaptation.
+
+Evidence remains layered: source/simulation/formal/TD/package/hardware. Hardware and pre-configuration output are not verified by this decision.

+ 38 - 0
QUICK_PROGRESS.md

@@ -0,0 +1,38 @@
+# 6400 V1.1 Bounded Fix Progress
+
+- Workspace: `/data/prod2u/worktrees/6400-front-rear-v11-30s`
+- Branch: `feature/6400-front-rear-v11-30s`
+- Baseline: `a00a5b673f6007ba4602221393aa4dce1e75e51e`; committed HEAD before current fix: `704b947d10d924325598ac15847febb0c4908f49`.
+- Initial Git status: clean.
+- Product: `6400-front-rear`; Board: `FCB V1.1`.
+- Phase: Quick/Q4 complete; long validation in progress.
+- 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.
+- Q3 PASS: Fresh TD commit `635fd540`, bit SHA `0bc41195...`, GUI SHA `908fdab2...`; Quick paths reported.
+- Q4: canonical Base/Current/Delivery implementation added; 19 focused package tests PASS.
+- Q4 PASS: Base ID `88af3f118e53`; Base/Current/Delivery deterministic rebuild, fresh overlay and tamper rejection PASS.
+- L1 PASS: Board Adapter Boolector+Z3; Core Owner Boolector depth90 (110s); Snapshot Lock and BMC Bank Boolector.
+- L1 evidence boundary: old boot/PWM/transport harnesses are stale and are not counted PASS; protocol/reset harness repair remains.
+- PASS: current-contract 96-round soak at `d6b604e4`, seed `1677779166`, including two reset/reconfiguration points.
+- PASS: mutation 6/6 and full 6400 integration; prior Final TD at `704b947` is superseded by the current RTL fix.
+- Fixed after Formal counterexample: Watchdog reload now occurs only on final safely applied Manual output commit; staging/cancelled SET_ALL cannot feed it.
+- PASS current focused replay: generator/closure, lint, 21 unit, Icarus sim, Host Cocotb, hard-fault cancellation race with Watchdog non-feed assertion.
+- Formal split: Core Owner invariant k-induction PASS 94s; added transaction/race properties BMC depth90 PASS 125s; Frame RX Z3/Boolector PASS; Snapshot transport Boolector depth48 PASS and Z3 probe TIMEOUT.
+- Next: commit Formal solver-map split, rerun exact-clean-commit registry, affected MRDIMM/Legacy gate, source-freeze soak/mutation, Fresh Final TD/GUI/packages.

+ 15 - 7
contracts/6400-snapshot.yaml

@@ -1,16 +1,24 @@
-schema: prod2u-6400-snapshot-v1
+schema: prod2u-6400-snapshot-v2
 byte_order: little
-max_payload_bytes: 200
+max_payload_bytes: 255
 fields:
-  - {name: control_state, type: u8}
+  - {name: mode, type: u8}
   - {name: fault_flags, type: u16}
-  - {name: current_target, type: u8, unit: degC}
-  - {name: host_target_seen, type: u8}
+  - {name: watchdog_active, type: u8}
+  - {name: watchdog_remaining, type: u8, unit: seconds}
+  - {name: pid_target, type: u8, unit: degC}
+  - {name: pid_running, type: u8}
+  - {name: manual_mode, type: u8}
+  - {name: bmc_valid, type: u8}
+  - {name: bmc_stale, type: u8}
+  - {name: ct_valid, type: u8}
+  - {name: ct_stale, type: u8}
+  - {name: hard_protect, type: u8}
   - {name: bmc_epoch, type: u16}
   - {name: ct_epoch, type: u16}
   - {name: control_epoch, type: u16}
-  - {name: bmc_age, type: u16, unit: control_ticks}
-  - {name: ct_age, type: u16, unit: control_ticks}
+  - {name: bmc_age, type: u16, unit: seconds}
+  - {name: ct_age, type: u16, unit: seconds}
   - {name: bmc_raw, type: u16, count: 24}
   - {name: bmc_valid_mask, type: bytes, count: 3}
   - {name: ct_raw, type: u16, count: 27}

+ 29 - 20
contracts/6400-wire.yaml

@@ -1,4 +1,4 @@
-schema: prod2u-6400-wire-v1
+schema: prod2u-6400-wire-v2
 clock_hz: 25000000
 device: EF2L45BG256B
 header: [0xA5, 0x5A]
@@ -17,33 +17,42 @@ bmc_uart:
   poll_ascii: "ipmitool raw 0x36 0x6c 0xdf 0xdd 0x00 0x03\n"
   response_data_bytes: 48
 commands:
-  SET_TARGET: {type: 0x01, payload_length: 1, response: SET_TARGET_ACK, valid: [0, 20-70]}
-  GET_SNAPSHOT: {type: 0x02, payload_length: 0, response: [GET_SNAPSHOT_ACK, SNAPSHOT_DATA]}
+  SET_ALL:
+    type: 0x01
+    payload_length: 32
+    response: ACK_NACK
+    payload_fields:
+      - {name: ptc_duty_percent, offset: 0, count: 24, minimum: 0, maximum: 100, unit: percent}
+      - {name: front_fan_duty_percent, offset: 24, count: 4, minimum: 0, maximum: 100, unit: percent}
+      - {name: rear_fan_duty_percent, offset: 28, count: 4, minimum: 0, maximum: 100, unit: percent}
+  GET_SNAPSHOT: {type: 0x02, payload_length: 0, response: [ACK_NACK, SNAPSHOT_DATA]}
   SET_STIMULUS:
     type: 0x03
     payload_length: 33
-    response: SET_STIMULUS_ACK
-    profiles: [6400-identification, 6400-sim-debug]
+    response: ACK_NACK
+    product_behavior: UNSUPPORTED
     payload_fields:
       - {name: duration_seconds, offset: 0, count: 1, minimum: 1, maximum: 255, unit: seconds}
       - {name: ptc_duty_percent, offset: 1, count: 24, minimum: 0, maximum: 100, unit: percent}
       - {name: front_fan_duty_percent, offset: 25, count: 4, minimum: 0, maximum: 100, unit: percent}
       - {name: rear_fan_duty_percent, offset: 29, count: 4, minimum: 0, maximum: 100, unit: percent}
+  SET_PID_TARGET: {type: 0x04, payload_length: 1, response: ACK_NACK, minimum: 20, maximum: 70, default: 70}
 responses:
-  SET_TARGET_ACK: {type: 0x81, payload_length: 0}
-  GET_SNAPSHOT_ACK: {type: 0x82, payload_length: 0}
-  SNAPSHOT_DATA: {type: 0x42, payload_contract: 6400-snapshot.yaml}
-  SET_STIMULUS_ACK: {type: 0x83, payload_length: 0, profiles: [6400-identification, 6400-sim-debug]}
-type_classes:
-  request: 0x01-0x3F
-  data: request_type_or_0x40
-  ack: request_type_or_0x80
-  reserved: 0xC0-0xFF
+  ACK_NACK:
+    type: 0x06
+    payload_length: 4
+    payload: [ok, request_type, status, detail]
+    status: {OK: 0, UNSUPPORTED: 1, BAD_LENGTH: 2, BAD_VALUE: 3, SAFETY_LOCKED: 4}
+  SNAPSHOT_DATA: {type: 0x82, payload_contract: 6400-snapshot.yaml}
 host_response_order:
-  SET_TARGET: [SET_TARGET_ACK]
-  GET_SNAPSHOT: [GET_SNAPSHOT_ACK, SNAPSHOT_DATA]
-  SET_STIMULUS: [SET_STIMULUS_ACK]
-ack_contract: {payload_length: 0, independent_frame: true, every_legal_command: true}
-invalid_behavior: silent_drop
+  SET_ALL: [ACK_NACK]
+  GET_SNAPSHOT: [ACK_NACK, SNAPSHOT_DATA]
+  SET_STIMULUS: [ACK_NACK]
+  SET_PID_TARGET: [ACK_NACK]
+invalid_behavior:
+  bad_header_crc_partial_timeout_framing: silent_drop
+  complete_crc_valid_request: exactly_one_ack_nack
 outstanding_transactions: 1
-forbidden_fields: [protocol_version, project_id, profile_id, capability, sequence, transaction_id, timestamp, tlv, nack]
+command_fifo: false
+snapshot_lock_release: final_data_crc_byte_stop_bit_complete
+watchdog_feed: legal_atomic_set_all_commit_only

+ 2 - 2
contracts/controller-coefficients.yaml

@@ -3,6 +3,6 @@ truth_label: SIMULATION_DEFAULT_NOT_HARDWARE_TUNED
 classes:
   EDGE: {lanes: [0, 3], kp_q4_12: 32, ki_q4_12: 4}
   CENTER: {lanes: [1, 2], kp_q4_12: 24, ki_q4_12: 3}
-limits_centi_degC: {soft: 7400, pretrip: 7600, hard: 7700, recovery_above_target: 200}
-targets_centi_degC: {default: 7000, preheat_offset: -500, ideal_band: 100, qualification_band: 700}
+limits_centi_degC: {channel_clamp: 7600, lane_hard: 7700, lane_release: 7200}
+targets_centi_degC: {default: 7000}
 recovery_epochs: 3

+ 9 - 6
contracts/fan-control-parameters.yaml

@@ -1,9 +1,11 @@
-schema: prod2u-6400-fan-control-v2
+schema: prod2u-6400-fan-control-v3
 truth_label: EXPERIMENTAL_UNVERIFIED
-duty: {reset: 10, stopped: 10, nominal: 30, warm: 50, protection: 80, hard: 100}
-temperature_centi_degC: {warm_delta_from_target: -300, protection: 7400, hard: 7700}
-invalid_lane_threshold: 2
-front_rear_independent: true
+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}
+manual_front_rear_independent: true
+pid_fan_policy: safe20_hard100
+connector_duty_semantics: high_level_percent
+board_invert_mask: 0x0F
 pwm:
   ptc_hz: 500
   fan_hz: 500
@@ -11,8 +13,9 @@ pwm:
   phases: 100
   ptc_phase_clks: 500
   fan_phase_clks: 500
-  carrier_backend: shared_equal_frequency_v1
+  carrier_backend: shared_equal_frequency_control_reset_independent_v2
   evidence: EXPERIMENTAL_CONFIGURATION_NOT_FAN_DATASHEET_VERIFIED
 pwm_high_level_status: PWM_HIGH_LEVEL_UNVERIFIED
+pre_configuration_output_status: NOT_VERIFIED
 actual_rpm_status: NOT_RUN
 actual_airflow_status: NOT_RUN

+ 42 - 75
docs/architecture/6400-v1-design-lock.md

@@ -1,92 +1,59 @@
-# 6400-front-rear-v1 design lock
+# 6400-front-rear production design lock
 
-Status: FROZEN for this task after the five audits in `docs/audits/`. Changes require an explicit decision-register entry and affected-audit rerun.
+Status: ACTIVE destructive protocol migration, 2026-08-25. This supersedes the previous SET_TARGET-first autonomous contract.
 
-## Product boundary
+## Hardware and duty boundary
 
-- Device: EF2L45BG256B; one 25 MHz clock domain; no PLL, generated clock, gated clock, or CDC.
-- Four 6-DIMM execution lanes: L0 CPU0 slots 0-5, L1 CPU0 slots 6-11, L2 CPU1 slots 0-5, L3 CPU1 slots 6-11.
-- Three physical thermal zones: Z0=L0, Z1=L1+L2, Z2=L3.
-- 24 independent PTC duties, 4 front-fan duties, 4 rear-fan duties; every output is exact 500 Hz.
-- All 24 DIMMs are acquired, controlled, protected, simulated, and telemetered. L0-L2 are the 18-channel primary modelling cohort; L3 is a 6-channel holdout only for model fitting.
-- No motor, limit, door percentage, startup motor calibration, solenoid, fan FG, PLL, MCU/SoC, online learning, or Host watchdog.
+- EF2L45BG256B, one 25 MHz clock, no PLL.
+- Host RS232/TTL 921600 8N1; production V1.1 physical top exports confirmed RS232 only. BMC RS232 is 115200.
+- Outputs are PTC0..23, Front0..3, Rear0..3. PTC is active high.
+- Every Host/GUI/Snapshot/Requested/Applied FAN value is connector-side high-level duty.
+- `FAN_BOARD_INVERT_MASK=8'h0F` is the only fan polarity adapter: Front balls B1/C4/B5/A14 invert; Rear balls P15/N15/M14/P5 are direct.
+- PTC connectors CON18/27/28/29 and all V1.1 ADC pins remain fixed.
+- PWM is 500 Hz: 100 phases x 500 clocks = 50,000 clocks.
+- The carrier is independent of control reset. While control reset is held, every period has PTC high 0 clocks, connector FAN high 10,000 clocks, Front ball low 10,000 clocks, Rear ball high 10,000 clocks.
+- PRE_CONFIGURATION_OUTPUT is NOT VERIFIED. RPM, airflow and physical thermal behavior are NOT RUN.
 
-## Physical interfaces
+## Safe and hard-protect outputs
 
-- BMC RS-232: UART1 / CON77, FPGA TX L10 and RX M9, 115200 8N1.
-- Host RS-232: UART2 / CON78, FPGA TX M10 and RX N11, 921600 8N1.
-- Host TTL: the shared logical core retains complete `host_ttl_rx`/`host_ttl_tx` 3.3 V support, but V1.1 evidence does not prove a connector or balls. Production and Identification hardware therefore use explicit RS-232-only physical tops: TTL RX is held at UART idle and TTL TX is not exported to a package port. TD auto-placement of TTL is forbidden.
-- In simulation/debug variants that expose both ports, Host RS-232 and TTL RX each have a two-flop synchronizer. The first detected start bit selects one port for the complete request/response transaction. Only the selected TX toggles; the other remains high. Simultaneous use is out of contract.
-- CT7428: one open-drain I2C master on M8/N9; three devices 0x49, 0x48, 0x4B; nine registers each; all 27 values are retained with raw, converted, valid, age, source index, and epoch.
-- BMC poll command is exactly `ipmitool raw 0x36 0x6c 0xdf 0xdd 0x00 0x03\n`. The streaming parser accepts case-insensitive hex separated by whitespace/CR/LF, rejects malformed or non-48-byte replies, and never commits a partial snapshot. Each two-byte `FF FF` value is invalid, never 0 C.
+- Reset, boot, standby, watchdog transition, PID waiting and ordinary non-overtemperature global fault atomically apply PTC0/FAN20.
+- BMC absence or stale data never integrates and never requests full speed.
+- A valid channel at or above 76 C clamps that channel PTC Applied duty to zero. A valid channel at or above 77 C latches its lane, applies lane PTC0/FAN100, and invalidates Manual ownership.
+- A latched lane releases only after three new complete valid BMC epochs in which every valid lane temperature is at or below 72 C; release commits PTC0/FAN20 and returns ownership to PID.
+- Requested and Applied banks are separate; a safety override cannot weaken the required protection.
 
-## Host wire protocol
+## Owner and watchdog
 
-Frame: `A5 5A | TYPE | LENGTH | PAYLOAD | CRC_LOW | CRC_HIGH`. CRC-16/CCITT-FALSE covers TYPE, LENGTH, and payload. Invalid header, length, CRC, type, target, or timeout is silently discarded. There is no NACK, version, project ID, capability, sequence, transaction ID, timestamp, TLV, command queue, or parallel outstanding transaction.
+- The only ownership values are SAFE, MANUAL and PID. Hard protection is an independent Applied-output override, not an owner.
+- Reset: SAFE, PID off, PTC0/FAN20, watchdog 30 seconds, PID target 70 C.
+- First 30-second watchdog expiry commits safe duty, clears PI and transfers ownership to PID.
+- A new complete valid BMC epoch permits PID calculation. No BMC means no integration and PTC0/FAN20.
+- Legal SET_ALL atomically enters MANUAL, freezes PID state, reloads 30 seconds and ACKs after the PWM-boundary commit. Identical SET_ALL also commits/feeds/ACKs.
+- Manual expiry commits safe duty, clears PI and transfers ownership to PID. A SET_ALL commit wins over the same-cycle final expiry tick.
+- Only legal atomically committed SET_ALL feeds watchdog. GET_SNAPSHOT, SET_PID_TARGET, SET_STIMULUS, NACK and invalid traffic do not.
 
-- `0x01 SET_TARGET`, payload length 1: `0` enters STOPPED; `20..70` atomically commits the global Celsius target; all other values are rejected. A legal commit returns `0x81 SET_TARGET_ACK`, zero payload. ACK means commit only.
-- `0x02 GET_SNAPSHOT`, zero payload: after the snapshot banks, epochs, and fixed fields are locked, returns an independent zero-payload `0x82 GET_SNAPSHOT_ACK`, then `0x42 SNAPSHOT_DATA` with the fixed 193-byte payload. The Host must process `WAIT_ACK` before `WAIT_DATA`; DATA never substitutes for ACK.
-- `0x03 SET_STIMULUS`, identification and sim-debug profiles only: duration 1..255 seconds, 24 PTC duties, 4 front duties, 4 rear duties, all 0..100; legal atomic commit returns zero-payload `0x83`. Production removes the decoder path at compile time.
-- The Host may retry idempotent SET_TARGET after an ACK timeout. HTH permits one outstanding transaction only.
+## Host protocol
 
-Every legal Host request receives its own ACK (`0x81`, `0x82`, or profile-gated `0x83`). SET ACK follows atomic commit. GET ACK follows snapshot locking and precedes DATA. The selected Host port and snapshot lock remain held until the final DATA CRC byte stop bit completes. Invalid requests remain silent drops; BMC framing is unchanged and has no ACK.
+Frame: `A5 5A | TYPE | LENGTH | PAYLOAD | CRC_LOW | CRC_HIGH`. CRC-16/CCITT-FALSE covers TYPE+LENGTH+PAYLOAD.
 
-The snapshot layout is generated from `contracts/6400-snapshot.yaml`, is fixed and under 200 bytes, and contains state/fault/target/source flags; BMC, CT, and control epochs and ages; 24 BMC raw pairs and valid bits; 27 CT raw values and valid bits; requested/applied PTC/front/rear duties; safety mask; lane faults; and global fault. TX locks bank IDs and streams offsets without copying the payload into flip-flops.
+- `0x01 SET_ALL`, length 32: PTC0..23, Front0..3, Rear0..3; all 0..100.
+- `0x02 GET_SNAPSHOT`, length 0.
+- `0x03 SET_STIMULUS`, existing name and 33-byte payload retained in the registry; the single product returns UNSUPPORTED.
+- `0x04 SET_PID_TARGET`, length 1, 20..70; updates only the next PID target and does not change Manual output or feed watchdog.
+- `0x06 ACK_NACK`, length 4: `[ok, request_type, status, detail]`.
+- `0x82 SNAPSHOT_DATA`, generated fixed layout.
+- Status: 0 OK, 1 UNSUPPORTED, 2 BAD_LENGTH, 3 BAD_VALUE, 4 SAFETY_LOCKED.
 
-## Control sequence
+Every complete CRC-correct Host request produces exactly one ACK/NACK. Bad header/CRC, partial, timeout and UART framing errors are silent. One outstanding request, no FIFO and one Frame TX/CRC/UART TX set are permitted.
 
-Reset values: target 70 C, PTC 0, front/rear fan banks 10, epochs/valid/integrators clear. Physical fans remain on the full-speed boot request through bank initialization and one complete PWM boundary before 10% standby is exposed.
+SET_ALL is validated completely before staging. The first value above 100 returns BAD_VALUE with its index; there is no partial write, bank switch, mode change or watchdog feed. A valid vector stages into the inactive bank and becomes visible only at a safe PWM boundary.
 
-1. `RESET_SAFE`: enforce safe outputs, then enter `WAIT_CT_VALID`.
-2. `WAIT_CT_VALID`: wait for a complete valid CT scan required by the channel map.
-3. `PREHEAT_CT`: per-channel conservative CT feedback targets `target-5 C`; BMC polling continues.
-4. `WAIT_BMC_STABLE`: require three distinct complete valid BMC epochs.
-5. `AUTO_BMC`: one shared incremental-PI datapath updates channels 0..23 exactly once per new BMC epoch.
-6. `SENSOR_DEGRADED`: invalid channel disables that PTC and freezes its state; lane-level invalidity disables the lane and raises both fans; global BMC stale disables all PTC and sets all fans to 100.
-7. `STOPPED`: all PTC off, fan stop-safe value, acquisition and GET remain active. A later legal nonzero target restarts through the CT/BMC qualification sequence.
+GET_SNAPSHOT locks BMC, CT, output banks, control epoch and fixed fields before its `0x06` ACK. It then sends `0x82` DATA. The selected Host port and all snapshot locks remain held through the final DATA CRC byte stop bit.
 
-Host connection state never changes the autonomous state machine. `host_target_seen` is telemetry only.
+Snapshot includes mode, watchdog active/remaining, PID target/running, Manual flag, BMC/CT valid/stale/epochs/ages, Requested/Applied PTC/Front/Rear connector duties, faults and hard-protect state.
 
-## PI and supervision
+## Product and GUI
 
-- Internal temperature unit: 0.01 C. Raw BMC bytes are always retained; until scaling evidence is complete, conversion is isolated behind the generated format contract.
-- One physical incremental PI datapath: `u[k]=u[k-1]+Kp*(e[k]-e[k-1])+Ki*e[k]`; Kd is zero in V1.
-- Coefficients have only EDGE (L0/L3) and CENTER (L1/L2) classes and are generated. Defaults are labelled `SIMULATION_DEFAULT_NOT_HARDWARE_TUNED`.
-- Required behavior: saturation, anti-windup, slew limiting, invalid/stale/safety freeze, epoch gating, CT-to-BMC and target-change bumpless transfer, and safe recovery.
-- One lane-statistics supervisor scans lanes sequentially and produces independent front/rear targets. It does not instantiate eight fan PIDs.
+- The only active product is `6400-front-rear`. Historical profile files are not active build or release inputs.
 
-## Safety
-
-Safety has final priority over autonomous and stimulus requests.
-
-- At 74 C: block positive integration, reduce the channel PTC, and increase lane airflow.
-- At 76 C: force the channel PTC off and raise both lane fans.
-- At or above 77 C: force all six lane PTCs off, set both lane fans to 100, and latch lane fault.
-- BMC stale: all 24 PTCs off and all 8 fan duties 100.
-- Invalid BMC channel: that PTC off and its controller frozen. Multiple invalid channels in a lane close the lane.
-- Recovery requires every relevant temperature at or below `target+2 C`, three distinct valid BMC epochs, and fresh sensors. Recovery starts from limited duty with reset/bumpless PI state.
-- Stimulus expires automatically and cannot bypass safety or maximum duty.
-
-This proves only deterministic electrical override after a sampled condition. Physical overshoot and the 77 C product objective remain NOT RUN.
-
-## PWM and storage
-
-- PTC and FAN frequency/phase-clock values are independent generated parameters. The V1 contract sets both to 500 Hz and selects the resource-minimal equal-frequency backend: one global 0..99 phase, one 0..499 subcounter, one channel index, one synchronous duty read, one comparator, one 32-bit `next_bitmap`, and one 32-bit `active_bitmap`. An unequal future contract must select a dual-carrier backend and cannot silently inherit the PTC frequency.
-- During each phase, scan all 32 requested/applied duties into `next_bitmap`. At the phase boundary atomically assign `active_bitmap <= next_bitmap`.
-- `duty=0` is always off; `100` always on; 1..99 are exact phase counts. Compile-time polarity masks drive physical pins.
-- BMC, CT, requested duties, snapshot view, and applicable parameters use inactive-bank writes plus a single bank-pointer flip. No large active-array copy is allowed.
-
-## Profiles
-
-- `6400-control`: production autonomous implementation; no stimulus/raw-manual path.
-- `6400-identification`: adds finite `SET_STIMULUS` under the same safety path.
-- `6400-sim-debug`: accelerated counters and observability; never a production source closure.
-- `legacy-door-percent`: retains the previous door product and its own nearest-scope contract; it cannot affect 6400 generation or closure.
-
-## Explicit unknowns
-
-- TTL Host physical balls/connector.
-- CT physical channel-to-DIMM mapping where current board evidence is insufficient.
-- BMC fractional byte scaling pending protocol evidence; raw bytes remain canonical.
-
-Unknowns are generated as explicit unbound/unknown fields and do not block logic simulation, Host software, lab replay, or the known-pin RS-232-only production closure. No hardware package may expose or auto-place a Host TTL port until those pins are resolved.
+The single `6400-front-rear` HEX GUI generates/parses HEX only, never opens a serial port, and embeds the same generated Host Contract/Golden Vector SHA as the firmware package.

+ 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: `9b2df5161fb37e4b84af8337c5e99a78e27b6058934a245068afd2d533468def`.
+Contract SHA-256: `35fe2e0602b5bc1ead064b7aaaf66571266fa6c809841fe68fb1c882cb13291b`.
 
 | DIMM | CPU slot | Lane | Zone | PTC | BMC | CT | Cohort |
 | ---: | --- | ---: | ---: | ---: | ---: | --- | --- |

+ 32 - 47
docs/prod2u-6400-front-back-protocol.zh-CN.md

@@ -1,63 +1,48 @@
-# 6400 前4进风/后4出风 Host 协议
+# 6400 V1.1 Host 协议(生产候选)
 
-本页只描述当前 `6400-control`、`6400-identification` 与 `6400-sim-debug` 合同。机器可读权威为 `generated/6400/host-contract.json`。
+本协议是破坏性迁移。旧 `SET_TARGET`、`0x81/0x82/0x83` 独立 ACK、`0x42` Snapshot Data、无 NACK,以及 Host 断开后立即 Autonomous 的实现均已停用。
 
-## 串口与帧
+## 固定接口
 
-- Host 线协议:921600 8N1。当前 V1.1 Production/Identification 刷机 Profile 只导出 Host RS-232(CON78);Host TTL 仅保留在逻辑核和 Sim-Debug,真实 connector/Ball 未确认前不得由 TD 自动分配。
-- BMC UART:115200 8N1;本次不修改 BMC Poll/Response,也不给 BMC 增加 ACK。
-- 帧:`A5 5A | TYPE | LENGTH | PAYLOAD | CRC_LOW | CRC_HIGH`。
-- CRC-16/CCITT-FALSE 覆盖 TYPE、LENGTH、PAYLOAD,CRC 低字节先发。
-- Request 为 `0x01..0x3F`,DATA 为 `request_type | 0x40`,ACK 为 `request_type | 0x80`,`0xC0..0xFF` 保留。
-- Header、Length、CRC、TYPE、参数错误或 Profile 不支持的命令静默丢弃;没有 NACK、Sequence、Version、Project ID 或命令队列。
+- Host:RS232/TTL 921600 8N1;V1.1 生产物理 Top 仅导出已确认的 RS232 CON78。
+- BMC:RS232 115200 8N1,CON77。
+- 帧:`A5 5A | TYPE | LENGTH | PAYLOAD | CRC低 | CRC高`。
+- CRC:CRC-16/CCITT-FALSE,poly `0x1021`,init `0xFFFF`,覆盖 TYPE+LENGTH+PAYLOAD。
+- 最多一个 outstanding,不设命令 FIFO,只用一套 Frame TX/CRC/UART TX。
 
-## 命令与独立 ACK
+## 命令
 
-所有合法 Host 命令每次都返回一帧独立 ACK,重复合法命令也不能省略。
-
-| 请求 | Payload | 回复顺序 | Profile |
+| Type | 名称 | Payload | 行为 |
 | --- | --- | --- | --- |
-| `0x01 SET_TARGET` | 1 字节:`0` 或 `20..70` °C | 原子提交后 `0x81/LEN0` | 全部 |
-| `0x02 GET_SNAPSHOT` | 空 | 锁存 Bank/Epoch/固定字段后 `0x82/LEN0`,再 `0x42/LEN193` | 全部 |
-| `0x03 SET_STIMULUS` | 33 字节 | 原子提交后 `0x83/LEN0` | 仅 Identification/Sim-Debug |
-
-旧 `0x82/LEN193 SNAPSHOT_DATA` 定义已废止。Host 必须按 `WAIT_ACK → WAIT_DATA` 处理 GET,DATA 不能替代 ACK。GET 的 port selector 与 snapshot bank lock 一直保持到 `0x42` 最后一字节 CRC 的 UART Stop Bit 完成。
+| `01` | SET_ALL | 32 字节 | PTC0..23、Front0..3、Rear0..3,均为连接器侧高电平占空比 0..100 |
+| `02` | GET_SNAPSHOT | 0 字节 | 先返回 `06`,再返回 `82` 数据 |
+| `03` | SET_STIMULUS | 33 字节 | 保留既有名称与 Payload;单一 6400-front-rear 对合法请求返回 UNSUPPORTED |
+| `04` | SET_PID_TARGET | 1 字节 | 20..70 C,默认 70;不启动 PID、不改变 Manual 输出、不喂狗 |
+| `06` | ACK_NACK | 4 字节 | `[ok, request_type, status, detail]` |
+| `82` | SNAPSHOT_DATA | 201 字节 | 按生成的 `snapshot-layout.json` 解析 |
 
-## SET_STIMULUS Payload
+Status:`0 OK`、`1 UNSUPPORTED`、`2 BAD_LENGTH`、`3 BAD_VALUE`、`4 SAFETY_LOCKED`。
 
-仅用于 `6400-identification` 和 `6400-sim-debug`;Production 完全移除其解码路径。
+所有 CRC 正确且完整的 Host 请求恰好返回一帧 ACK/NACK;GET 成功后另发一帧 DATA。坏 Header、CRC、半帧、超时和 UART framing error 静默丢弃。
 
-| Offset | 字段 | 数量 | 范围 |
-| ---: | --- | ---: | --- |
-| 0 | duration_seconds | 1 | 1..255 秒 |
-| 1 | PTC duty | 24 | 每项 0..100% |
-| 25 | Front fan duty | 4 | 每项 0..100% |
-| 29 | Rear fan duty | 4 | 每项 0..100% |
+SET_ALL 必须收全后先完整校验。首个大于 100 的值返回 BAD_VALUE,detail 为索引;不得部分写、切 Bank、改 Owner 或喂狗。合法值写入 inactive bank,在 PWM 安全边界原子切换,进入 MANUAL、冻结 PI、reload 30 秒,commit 后返回 OK。相同值也必须 commit/feed/ACK。
 
-顺序严格为 24 PTC、Front0..3、Rear0..3。Stimulus 有限期自动退出且永远不能越过 BMC stale、74/76/77 °C 或 lane/global fault 安全优先级。
+GET 在 ACK 前锁存 BMC、CT、Output Bank、control epoch 和固定字段;Host 端口与 Snapshot Bank 锁保持到 `82` 最后 CRC 字节 stop bit 完成。
 
-## 风扇物理顺序
-
-| 逻辑输出 | Connector | Net / Ball | 板级极性 |
-| --- | --- | --- | --- |
-| Front0..3 | CON25.7 / CON8.7 / CON24.7 / CON26.7 | FAN_PWM3/B1, FAN_PWM1/C4, FAN_PWM2/B5, FAN_PWM4/A14 | Q101/Q99/Q100/Q102 反相 |
-| Rear0..3 | CON64.4 / CON66.4 / CON62.4 / CON60.4 | FAN_GPIO44/P15, FAN_GPIO46/N15, FAN_GPIO42/M14, FAN_GPIO40/P5 | 0 R 直连,不反相 |
+## Owner 与安全输出
 
-生产向量固定为 Front0..3 后 Rear0..3,`FAN_BOARD_INVERT_MASK=0x0F`。500 Hz、10% Standby、PWM High Level 仍是 `EXPERIMENTAL_UNVERIFIED`;实际 RPM、风量和硬件验证均 `NOT RUN`。
+- Owner 只有 SAFE、MANUAL、PID;Hard Protect 是独立 Applied 安全覆盖,不是 Owner。
+- Reset/Boot/Standby/watchdog/PID 等待/普通非过温 global fault:PTC0、Front/Rear FAN20。
+- 有效通道达到 76 C 时仅 Clamp 该通道 PTC Applied=0;有效通道达到 77 C 时锁存对应 Lane,Lane PTC0、Front/Rear FAN100,并使当前 Manual Lease 失效。
+- Lane 只有在连续 3 个新完整有效 BMC Snapshot 中该 Lane 所有有效温度均不高于 72 C 才释放;释放后提交 PTC0/FAN20、Owner=PID,并等待下一新 Epoch。
+- BMC 无有效数据时 PID 不积分、不全速。第一次 Boot watchdog timeout 以及 Manual timeout 都原子提交安全值、清 PI、Owner=PID;新完整有效 BMC epoch 后才计算 PID。
+- 只有合法并完成原子提交的 SET_ALL 喂 30 秒 watchdog;SET_ALL commit 与最后 timeout tick 同周期时 SET_ALL 优先。
+- MANUAL 在无 BMC 时仍可工作;此时没有基于 BMC 的过温保护。
 
-## Golden Vector
+## 风扇极性
 
-- SET_TARGET 0 °C:`A55A0101009DC8`
-- SET_TARGET 20 °C:`A55A010114289A`
-- SET_TARGET 70 °C:`A55A0101469FE0`
-- GET_SNAPSHOT:`A55A02006D7B`
-- SET_TARGET_ACK:`A55A8100A635`
-- GET_SNAPSHOT_ACK:`A55A8200F560`
-- SET_STIMULUS_ACK:`A55A8300C453`
+合同、GUI、Snapshot、Requested 和 Applied 均使用连接器侧高电平 duty。唯一适配点为 `FAN_BOARD_INVERT_MASK=8'h0F`:Front Ball B1/C4/B5/A14 反相,Rear Ball P15/N15/M14/P5 直通。
 
-离线生成 HEX(不打开串口):
+连接器 20% 示例:每 50,000 个 25 MHz 时钟中,连接器 FAN 高电平 10,000;Front Ball 低 10,000;Rear Ball 高 10,000。PTC 高电平为 0。
 
-```bash
-python3 tools/encode_6400_hex.py --profile 6400-control set-target 50
-python3 tools/encode_6400_hex.py --profile 6400-control get-snapshot
-```
+`PRE_CONFIGURATION_OUTPUT=NOT VERIFIED`;Hardware、RPM、风量和实机热控均为 `NOT RUN`。

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

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

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

@@ -1 +1 @@
-9b2df5161fb37e4b84af8337c5e99a78e27b6058934a245068afd2d533468def
+35fe2e0602b5bc1ead064b7aaaf66571266fa6c809841fe68fb1c882cb13291b

+ 5 - 9
generated/6400/controller-coefficients.json

@@ -17,20 +17,16 @@
       ]
     }
   },
-  "contract_sha256": "9b2df5161fb37e4b84af8337c5e99a78e27b6058934a245068afd2d533468def",
+  "contract_sha256": "35fe2e0602b5bc1ead064b7aaaf66571266fa6c809841fe68fb1c882cb13291b",
   "limits_centi_degC": {
-    "hard": 7700,
-    "pretrip": 7600,
-    "recovery_above_target": 200,
-    "soft": 7400
+    "channel_clamp": 7600,
+    "lane_hard": 7700,
+    "lane_release": 7200
   },
   "recovery_epochs": 3,
   "schema": "prod2u-6400-controller-coefficients-v1",
   "targets_centi_degC": {
-    "default": 7000,
-    "ideal_band": 100,
-    "preheat_offset": -500,
-    "qualification_band": 700
+    "default": 7000
   },
   "truth_label": "SIMULATION_DEFAULT_NOT_HARDWARE_TUNED"
 }

+ 17 - 13
generated/6400/fan-control-parameters.json

@@ -1,19 +1,23 @@
 {
   "actual_airflow_status": "NOT_RUN",
   "actual_rpm_status": "NOT_RUN",
-  "contract_sha256": "9b2df5161fb37e4b84af8337c5e99a78e27b6058934a245068afd2d533468def",
+  "board_invert_mask": 15,
+  "connector_duty_semantics": "high_level_percent",
+  "contract_sha256": "35fe2e0602b5bc1ead064b7aaaf66571266fa6c809841fe68fb1c882cb13291b",
   "duty": {
+    "boot": 20,
     "hard": 100,
-    "nominal": 30,
-    "protection": 80,
-    "reset": 10,
-    "stopped": 10,
-    "warm": 50
+    "ordinary_fault": 20,
+    "pid_wait_sensor": 20,
+    "reset": 20,
+    "standby": 20,
+    "watchdog": 20
   },
-  "front_rear_independent": true,
-  "invalid_lane_threshold": 2,
+  "manual_front_rear_independent": true,
+  "pid_fan_policy": "safe20_hard100",
+  "pre_configuration_output_status": "NOT_VERIFIED",
   "pwm": {
-    "carrier_backend": "shared_equal_frequency_v1",
+    "carrier_backend": "shared_equal_frequency_control_reset_independent_v2",
     "clock_hz": 25000000,
     "evidence": "EXPERIMENTAL_CONFIGURATION_NOT_FAN_DATASHEET_VERIFIED",
     "fan_hz": 500,
@@ -23,11 +27,11 @@
     "ptc_phase_clks": 500
   },
   "pwm_high_level_status": "PWM_HIGH_LEVEL_UNVERIFIED",
-  "schema": "prod2u-6400-fan-control-v2",
+  "schema": "prod2u-6400-fan-control-v3",
   "temperature_centi_degC": {
-    "hard": 7700,
-    "protection": 7400,
-    "warm_delta_from_target": -300
+    "channel_clamp": 7600,
+    "lane_hard": 7700,
+    "lane_release": 7200
   },
   "truth_label": "EXPERIMENTAL_UNVERIFIED"
 }

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

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

+ 13 - 8
generated/6400/golden-vectors.json

@@ -1,14 +1,19 @@
 {
-  "contract_sha256": "9b2df5161fb37e4b84af8337c5e99a78e27b6058934a245068afd2d533468def",
+  "contract_sha256": "35fe2e0602b5bc1ead064b7aaaf66571266fa6c809841fe68fb1c882cb13291b",
   "frames": {
+    "bad_length_01_nack": "A55A060400010220C77F",
+    "bad_value_01_index_7_nack": "A55A0604000103077318",
     "get_snapshot": "A55A02006D7B",
-    "get_snapshot_ack": "A55A8200F560",
-    "set_target_20": "A55A010114289A",
-    "set_target_70": "A55A0101469FE0",
-    "set_target_ack": "A55A8100A635",
-    "set_target_stop": "A55A0101009DC8",
-    "stimulus_ack": "A55A8300C453",
-    "stimulus_all_zero_one_second": "A55A03210100000000000000000000000000000000000000000000000000000000000000009782"
+    "get_snapshot_ack": "A55A0604010200002312",
+    "safety_locked_01_nack": "A55A06040001040003F1",
+    "set_all_0_20_50_100": "A55A0120000102030405060708090A0B0C0D0E0F10111213141516170014326400143264D091",
+    "set_all_ack": "A55A060401010000734B",
+    "set_all_safe": "A55A01200000000000000000000000000000000000000000000000001414141414141414E70A",
+    "set_pid_target_70": "A55A0401466F0B",
+    "set_pid_target_ack": "A55A06040104000083A0",
+    "stimulus_ack": "A55A0604010300001325",
+    "stimulus_all_zero_one_second": "A55A03210100000000000000000000000000000000000000000000000000000000000000009782",
+    "unsupported_03_nack": "A55A0604000301009660"
   },
   "schema": "prod2u-6400-golden-vectors-v1"
 }

+ 189 - 139
generated/6400/host-contract.json

@@ -1,33 +1,14 @@
 {
   "canonical_profiles": {
-    "6400-control": {
+    "6400-front-rear": {
       "allowed_commands": [
-        "SET_TARGET",
-        "GET_SNAPSHOT"
+        "SET_ALL",
+        "GET_SNAPSHOT",
+        "SET_PID_TARGET"
       ],
       "production": true,
       "simulation_only": false,
       "stimulus": false
-    },
-    "6400-identification": {
-      "allowed_commands": [
-        "SET_TARGET",
-        "GET_SNAPSHOT",
-        "SET_STIMULUS"
-      ],
-      "production": false,
-      "simulation_only": false,
-      "stimulus": true
-    },
-    "6400-sim-debug": {
-      "allowed_commands": [
-        "SET_TARGET",
-        "GET_SNAPSHOT",
-        "SET_STIMULUS"
-      ],
-      "production": false,
-      "simulation_only": true,
-      "stimulus": true
     }
   },
   "channel_map": {
@@ -713,7 +694,7 @@
     "product": "6400-front-rear-v1",
     "schema": "prod2u-6400-channel-map-v1"
   },
-  "contract_sha256": "9b2df5161fb37e4b84af8337c5e99a78e27b6058934a245068afd2d533468def",
+  "contract_sha256": "35fe2e0602b5bc1ead064b7aaaf66571266fa6c809841fe68fb1c882cb13291b",
   "controller_coefficients": {
     "classes": {
       "CENTER": {
@@ -734,36 +715,36 @@
       }
     },
     "limits_centi_degC": {
-      "hard": 7700,
-      "pretrip": 7600,
-      "recovery_above_target": 200,
-      "soft": 7400
+      "channel_clamp": 7600,
+      "lane_hard": 7700,
+      "lane_release": 7200
     },
     "recovery_epochs": 3,
     "schema": "prod2u-6400-controller-coefficients-v1",
     "targets_centi_degC": {
-      "default": 7000,
-      "ideal_band": 100,
-      "preheat_offset": -500,
-      "qualification_band": 700
+      "default": 7000
     },
     "truth_label": "SIMULATION_DEFAULT_NOT_HARDWARE_TUNED"
   },
   "fan_control": {
     "actual_airflow_status": "NOT_RUN",
     "actual_rpm_status": "NOT_RUN",
+    "board_invert_mask": 15,
+    "connector_duty_semantics": "high_level_percent",
     "duty": {
+      "boot": 20,
       "hard": 100,
-      "nominal": 30,
-      "protection": 80,
-      "reset": 10,
-      "stopped": 10,
-      "warm": 50
+      "ordinary_fault": 20,
+      "pid_wait_sensor": 20,
+      "reset": 20,
+      "standby": 20,
+      "watchdog": 20
     },
-    "front_rear_independent": true,
-    "invalid_lane_threshold": 2,
+    "manual_front_rear_independent": true,
+    "pid_fan_policy": "safe20_hard100",
+    "pre_configuration_output_status": "NOT_VERIFIED",
     "pwm": {
-      "carrier_backend": "shared_equal_frequency_v1",
+      "carrier_backend": "shared_equal_frequency_control_reset_independent_v2",
       "clock_hz": 25000000,
       "evidence": "EXPERIMENTAL_CONFIGURATION_NOT_FAN_DATASHEET_VERIFIED",
       "fan_hz": 500,
@@ -773,11 +754,11 @@
       "ptc_phase_clks": 500
     },
     "pwm_high_level_status": "PWM_HIGH_LEVEL_UNVERIFIED",
-    "schema": "prod2u-6400-fan-control-v2",
+    "schema": "prod2u-6400-fan-control-v3",
     "temperature_centi_degC": {
-      "hard": 7700,
-      "protection": 7400,
-      "warm_delta_from_target": -300
+      "channel_clamp": 7600,
+      "lane_hard": 7700,
+      "lane_release": 7200
     },
     "truth_label": "EXPERIMENTAL_UNVERIFIED"
   },
@@ -816,26 +797,31 @@
     }
   },
   "golden_vectors": {
-    "contract_sha256": "9b2df5161fb37e4b84af8337c5e99a78e27b6058934a245068afd2d533468def",
+    "contract_sha256": "35fe2e0602b5bc1ead064b7aaaf66571266fa6c809841fe68fb1c882cb13291b",
     "frames": {
+      "bad_length_01_nack": "A55A060400010220C77F",
+      "bad_value_01_index_7_nack": "A55A0604000103077318",
       "get_snapshot": "A55A02006D7B",
-      "get_snapshot_ack": "A55A8200F560",
-      "set_target_20": "A55A010114289A",
-      "set_target_70": "A55A0101469FE0",
-      "set_target_ack": "A55A8100A635",
-      "set_target_stop": "A55A0101009DC8",
-      "stimulus_ack": "A55A8300C453",
-      "stimulus_all_zero_one_second": "A55A03210100000000000000000000000000000000000000000000000000000000000000009782"
+      "get_snapshot_ack": "A55A0604010200002312",
+      "safety_locked_01_nack": "A55A06040001040003F1",
+      "set_all_0_20_50_100": "A55A0120000102030405060708090A0B0C0D0E0F10111213141516170014326400143264D091",
+      "set_all_ack": "A55A060401010000734B",
+      "set_all_safe": "A55A01200000000000000000000000000000000000000000000000001414141414141414E70A",
+      "set_pid_target_70": "A55A0401466F0B",
+      "set_pid_target_ack": "A55A06040104000083A0",
+      "stimulus_ack": "A55A0604010300001325",
+      "stimulus_all_zero_one_second": "A55A03210100000000000000000000000000000000000000000000000000000000000000009782",
+      "unsupported_03_nack": "A55A0604000301009660"
     },
     "schema": "prod2u-6400-golden-vectors-v1"
   },
-  "schema": "prod2u-6400-host-contract-v2",
+  "schema": "prod2u-6400-host-contract-v3",
   "snapshot": {
     "byte_order": "little",
-    "contract_sha256": "9b2df5161fb37e4b84af8337c5e99a78e27b6058934a245068afd2d533468def",
+    "contract_sha256": "35fe2e0602b5bc1ead064b7aaaf66571266fa6c809841fe68fb1c882cb13291b",
     "fields": [
       {
-        "name": "control_state",
+        "name": "mode",
         "offset": 0,
         "size": 1,
         "type": "u8"
@@ -847,149 +833,193 @@
         "type": "u16"
       },
       {
-        "name": "current_target",
+        "name": "watchdog_active",
         "offset": 3,
         "size": 1,
+        "type": "u8"
+      },
+      {
+        "name": "watchdog_remaining",
+        "offset": 4,
+        "size": 1,
+        "type": "u8",
+        "unit": "seconds"
+      },
+      {
+        "name": "pid_target",
+        "offset": 5,
+        "size": 1,
         "type": "u8",
         "unit": "degC"
       },
       {
-        "name": "host_target_seen",
-        "offset": 4,
+        "name": "pid_running",
+        "offset": 6,
+        "size": 1,
+        "type": "u8"
+      },
+      {
+        "name": "manual_mode",
+        "offset": 7,
+        "size": 1,
+        "type": "u8"
+      },
+      {
+        "name": "bmc_valid",
+        "offset": 8,
+        "size": 1,
+        "type": "u8"
+      },
+      {
+        "name": "bmc_stale",
+        "offset": 9,
+        "size": 1,
+        "type": "u8"
+      },
+      {
+        "name": "ct_valid",
+        "offset": 10,
+        "size": 1,
+        "type": "u8"
+      },
+      {
+        "name": "ct_stale",
+        "offset": 11,
+        "size": 1,
+        "type": "u8"
+      },
+      {
+        "name": "hard_protect",
+        "offset": 12,
         "size": 1,
         "type": "u8"
       },
       {
         "name": "bmc_epoch",
-        "offset": 5,
+        "offset": 13,
         "size": 2,
         "type": "u16"
       },
       {
         "name": "ct_epoch",
-        "offset": 7,
+        "offset": 15,
         "size": 2,
         "type": "u16"
       },
       {
         "name": "control_epoch",
-        "offset": 9,
+        "offset": 17,
         "size": 2,
         "type": "u16"
       },
       {
         "name": "bmc_age",
-        "offset": 11,
+        "offset": 19,
         "size": 2,
         "type": "u16",
-        "unit": "control_ticks"
+        "unit": "seconds"
       },
       {
         "name": "ct_age",
-        "offset": 13,
+        "offset": 21,
         "size": 2,
         "type": "u16",
-        "unit": "control_ticks"
+        "unit": "seconds"
       },
       {
         "count": 24,
         "name": "bmc_raw",
-        "offset": 15,
+        "offset": 23,
         "size": 48,
         "type": "u16"
       },
       {
         "count": 3,
         "name": "bmc_valid_mask",
-        "offset": 63,
+        "offset": 71,
         "size": 3,
         "type": "bytes"
       },
       {
         "count": 27,
         "name": "ct_raw",
-        "offset": 66,
+        "offset": 74,
         "size": 54,
         "type": "u16"
       },
       {
         "count": 4,
         "name": "ct_valid_mask",
-        "offset": 120,
+        "offset": 128,
         "size": 4,
         "type": "bytes"
       },
       {
         "count": 24,
         "name": "ptc_requested",
-        "offset": 124,
+        "offset": 132,
         "size": 24,
         "type": "u8"
       },
       {
         "count": 24,
         "name": "ptc_applied",
-        "offset": 148,
+        "offset": 156,
         "size": 24,
         "type": "u8"
       },
       {
         "count": 4,
         "name": "front_requested",
-        "offset": 172,
+        "offset": 180,
         "size": 4,
         "type": "u8"
       },
       {
         "count": 4,
         "name": "front_applied",
-        "offset": 176,
+        "offset": 184,
         "size": 4,
         "type": "u8"
       },
       {
         "count": 4,
         "name": "rear_requested",
-        "offset": 180,
+        "offset": 188,
         "size": 4,
         "type": "u8"
       },
       {
         "count": 4,
         "name": "rear_applied",
-        "offset": 184,
+        "offset": 192,
         "size": 4,
         "type": "u8"
       },
       {
         "count": 3,
         "name": "safety_override_mask",
-        "offset": 188,
+        "offset": 196,
         "size": 3,
         "type": "bytes"
       },
       {
         "name": "lane_fault_mask",
-        "offset": 191,
+        "offset": 199,
         "size": 1,
         "type": "u8"
       },
       {
         "name": "global_fault",
-        "offset": 192,
+        "offset": 200,
         "size": 1,
         "type": "u8"
       }
     ],
-    "payload_length": 193,
-    "schema": "prod2u-6400-snapshot-v1"
+    "payload_length": 201,
+    "schema": "prod2u-6400-snapshot-v2"
   },
   "wire": {
-    "ack_contract": {
-      "every_legal_command": true,
-      "independent_frame": true,
-      "payload_length": 0
-    },
     "bmc_uart": {
       "baud": 115200,
       "clks_per_bit": 217,
@@ -1004,15 +1034,55 @@
       }
     },
     "clock_hz": 25000000,
+    "command_fifo": false,
     "commands": {
       "GET_SNAPSHOT": {
         "payload_length": 0,
         "response": [
-          "GET_SNAPSHOT_ACK",
+          "ACK_NACK",
           "SNAPSHOT_DATA"
         ],
         "type": 2
       },
+      "SET_ALL": {
+        "payload_fields": [
+          {
+            "count": 24,
+            "maximum": 100,
+            "minimum": 0,
+            "name": "ptc_duty_percent",
+            "offset": 0,
+            "unit": "percent"
+          },
+          {
+            "count": 4,
+            "maximum": 100,
+            "minimum": 0,
+            "name": "front_fan_duty_percent",
+            "offset": 24,
+            "unit": "percent"
+          },
+          {
+            "count": 4,
+            "maximum": 100,
+            "minimum": 0,
+            "name": "rear_fan_duty_percent",
+            "offset": 28,
+            "unit": "percent"
+          }
+        ],
+        "payload_length": 32,
+        "response": "ACK_NACK",
+        "type": 1
+      },
+      "SET_PID_TARGET": {
+        "default": 70,
+        "maximum": 70,
+        "minimum": 20,
+        "payload_length": 1,
+        "response": "ACK_NACK",
+        "type": 4
+      },
       "SET_STIMULUS": {
         "payload_fields": [
           {
@@ -1049,21 +1119,9 @@
           }
         ],
         "payload_length": 33,
-        "profiles": [
-          "6400-identification",
-          "6400-sim-debug"
-        ],
-        "response": "SET_STIMULUS_ACK",
+        "product_behavior": "UNSUPPORTED",
+        "response": "ACK_NACK",
         "type": 3
-      },
-      "SET_TARGET": {
-        "payload_length": 1,
-        "response": "SET_TARGET_ACK",
-        "type": 1,
-        "valid": [
-          0,
-          "20-70"
-        ]
       }
     },
     "crc": {
@@ -1077,31 +1135,23 @@
       "xor_output": 0
     },
     "device": "EF2L45BG256B",
-    "forbidden_fields": [
-      "protocol_version",
-      "project_id",
-      "profile_id",
-      "capability",
-      "sequence",
-      "transaction_id",
-      "timestamp",
-      "tlv",
-      "nack"
-    ],
     "header": [
       165,
       90
     ],
     "host_response_order": {
       "GET_SNAPSHOT": [
-        "GET_SNAPSHOT_ACK",
+        "ACK_NACK",
         "SNAPSHOT_DATA"
       ],
-      "SET_STIMULUS": [
-        "SET_STIMULUS_ACK"
+      "SET_ALL": [
+        "ACK_NACK"
+      ],
+      "SET_PID_TARGET": [
+        "ACK_NACK"
       ],
-      "SET_TARGET": [
-        "SET_TARGET_ACK"
+      "SET_STIMULUS": [
+        "ACK_NACK"
       ]
     },
     "host_uart": {
@@ -1122,36 +1172,36 @@
         "tx_ball": "unknown"
       }
     },
-    "invalid_behavior": "silent_drop",
+    "invalid_behavior": {
+      "bad_header_crc_partial_timeout_framing": "silent_drop",
+      "complete_crc_valid_request": "exactly_one_ack_nack"
+    },
     "outstanding_transactions": 1,
     "responses": {
-      "GET_SNAPSHOT_ACK": {
-        "payload_length": 0,
-        "type": 130
-      },
-      "SET_STIMULUS_ACK": {
-        "payload_length": 0,
-        "profiles": [
-          "6400-identification",
-          "6400-sim-debug"
+      "ACK_NACK": {
+        "payload": [
+          "ok",
+          "request_type",
+          "status",
+          "detail"
         ],
-        "type": 131
-      },
-      "SET_TARGET_ACK": {
-        "payload_length": 0,
-        "type": 129
+        "payload_length": 4,
+        "status": {
+          "BAD_LENGTH": 2,
+          "BAD_VALUE": 3,
+          "OK": 0,
+          "SAFETY_LOCKED": 4,
+          "UNSUPPORTED": 1
+        },
+        "type": 6
       },
       "SNAPSHOT_DATA": {
         "payload_contract": "6400-snapshot.yaml",
-        "type": 66
+        "type": 130
       }
     },
-    "schema": "prod2u-6400-wire-v1",
-    "type_classes": {
-      "ack": "request_type_or_0x80",
-      "data": "request_type_or_0x40",
-      "request": "0x01-0x3F",
-      "reserved": "0xC0-0xFF"
-    }
+    "schema": "prod2u-6400-wire-v2",
+    "snapshot_lock_release": "final_data_crc_byte_stop_bit_complete",
+    "watchdog_feed": "legal_atomic_set_all_commit_only"
   }
 }

+ 51 - 32
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: 9b2df5161fb37e4b84af8337c5e99a78e27b6058934a245068afd2d533468def
+// Generated contract SHA-256: 35fe2e0602b5bc1ead064b7aaaf66571266fa6c809841fe68fb1c882cb13291b
 `define FB_CLOCK_HZ 25000000
 `define FB_PTC_COUNT 24
 `define FB_FRONT_FAN_COUNT 4
@@ -28,45 +28,64 @@
 `define REAR_FAN_FPGA_BALL_MAP "P15,N15,M14,P5"
 `define FB_BOARD_ID "fcb_fpga_mcu_v1_1_20260625"
 `define FB_BOARD_EVIDENCE_SHA256 "db02938f7943b2ae532aa18208f61588364d32a70a0cc72f74b4a94aaab7e258"
-`define FB_CMD_SET_TARGET 8'h01
+`define FB_CMD_SET_ALL 8'h01
 `define FB_CMD_GET_SNAPSHOT 8'h02
 `define FB_CMD_SET_STIMULUS 8'h03
-`define FB_RSP_SET_TARGET_ACK 8'h81
-`define FB_RSP_GET_SNAPSHOT_ACK 8'h82
-`define FB_RSP_SNAPSHOT_DATA 8'h42
-`define FB_RSP_STIMULUS_ACK 8'h83
-`define FB_SNAPSHOT_LENGTH 193
-`define FB_TEMP_SOFT 7400
-`define FB_TEMP_PRETRIP 7600
-`define FB_TEMP_HARD 7700
+`define FB_CMD_SET_PID_TARGET 8'h04
+`define FB_RSP_ACK_NACK 8'h06
+`define FB_RSP_SNAPSHOT_DATA 8'h82
+`define FB_STATUS_OK 8'd0
+`define FB_STATUS_UNSUPPORTED 8'd1
+`define FB_STATUS_BAD_LENGTH 8'd2
+`define FB_STATUS_BAD_VALUE 8'd3
+`define FB_STATUS_SAFETY_LOCKED 8'd4
+`define FB_SNAPSHOT_LENGTH 201
+`define FB_TEMP_CHANNEL_CLAMP 7600
+`define FB_TEMP_LANE_HARD 7700
+`define FB_TEMP_LANE_RELEASE 7200
 `define FB_TEMP_DEFAULT_TARGET 7000
 `define FB_EDGE_KP_Q4_12 32
 `define FB_EDGE_KI_Q4_12 4
 `define FB_CENTER_KP_Q4_12 24
 `define FB_CENTER_KI_Q4_12 3
-`define FAN_STANDBY_DUTY 10
+`define FAN_SAFE_DUTY 20
+`define FAN_STANDBY_DUTY `FAN_SAFE_DUTY
 `define FB_FAN_RESET `FAN_STANDBY_DUTY
 `define FB_FAN_HARD 100
-`define FB_SNAPSHOT_CONTROL_STATE_OFFSET 0
+`define CONTROL_WATCHDOG_SECONDS 30
+`define SET_ALL_WATCHDOG_SECONDS `CONTROL_WATCHDOG_SECONDS
+`define DEFAULT_PID_TARGET_C 70
+`define FB_OWNER_SAFE 3'd0
+`define FB_OWNER_MANUAL 3'd1
+`define FB_OWNER_PID 3'd2
+`define FB_SNAPSHOT_MODE_OFFSET 0
 `define FB_SNAPSHOT_FAULT_FLAGS_OFFSET 1
-`define FB_SNAPSHOT_CURRENT_TARGET_OFFSET 3
-`define FB_SNAPSHOT_HOST_TARGET_SEEN_OFFSET 4
-`define FB_SNAPSHOT_BMC_EPOCH_OFFSET 5
-`define FB_SNAPSHOT_CT_EPOCH_OFFSET 7
-`define FB_SNAPSHOT_CONTROL_EPOCH_OFFSET 9
-`define FB_SNAPSHOT_BMC_AGE_OFFSET 11
-`define FB_SNAPSHOT_CT_AGE_OFFSET 13
-`define FB_SNAPSHOT_BMC_RAW_OFFSET 15
-`define FB_SNAPSHOT_BMC_VALID_MASK_OFFSET 63
-`define FB_SNAPSHOT_CT_RAW_OFFSET 66
-`define FB_SNAPSHOT_CT_VALID_MASK_OFFSET 120
-`define FB_SNAPSHOT_PTC_REQUESTED_OFFSET 124
-`define FB_SNAPSHOT_PTC_APPLIED_OFFSET 148
-`define FB_SNAPSHOT_FRONT_REQUESTED_OFFSET 172
-`define FB_SNAPSHOT_FRONT_APPLIED_OFFSET 176
-`define FB_SNAPSHOT_REAR_REQUESTED_OFFSET 180
-`define FB_SNAPSHOT_REAR_APPLIED_OFFSET 184
-`define FB_SNAPSHOT_SAFETY_OVERRIDE_MASK_OFFSET 188
-`define FB_SNAPSHOT_LANE_FAULT_MASK_OFFSET 191
-`define FB_SNAPSHOT_GLOBAL_FAULT_OFFSET 192
+`define FB_SNAPSHOT_WATCHDOG_ACTIVE_OFFSET 3
+`define FB_SNAPSHOT_WATCHDOG_REMAINING_OFFSET 4
+`define FB_SNAPSHOT_PID_TARGET_OFFSET 5
+`define FB_SNAPSHOT_PID_RUNNING_OFFSET 6
+`define FB_SNAPSHOT_MANUAL_MODE_OFFSET 7
+`define FB_SNAPSHOT_BMC_VALID_OFFSET 8
+`define FB_SNAPSHOT_BMC_STALE_OFFSET 9
+`define FB_SNAPSHOT_CT_VALID_OFFSET 10
+`define FB_SNAPSHOT_CT_STALE_OFFSET 11
+`define FB_SNAPSHOT_HARD_PROTECT_OFFSET 12
+`define FB_SNAPSHOT_BMC_EPOCH_OFFSET 13
+`define FB_SNAPSHOT_CT_EPOCH_OFFSET 15
+`define FB_SNAPSHOT_CONTROL_EPOCH_OFFSET 17
+`define FB_SNAPSHOT_BMC_AGE_OFFSET 19
+`define FB_SNAPSHOT_CT_AGE_OFFSET 21
+`define FB_SNAPSHOT_BMC_RAW_OFFSET 23
+`define FB_SNAPSHOT_BMC_VALID_MASK_OFFSET 71
+`define FB_SNAPSHOT_CT_RAW_OFFSET 74
+`define FB_SNAPSHOT_CT_VALID_MASK_OFFSET 128
+`define FB_SNAPSHOT_PTC_REQUESTED_OFFSET 132
+`define FB_SNAPSHOT_PTC_APPLIED_OFFSET 156
+`define FB_SNAPSHOT_FRONT_REQUESTED_OFFSET 180
+`define FB_SNAPSHOT_FRONT_APPLIED_OFFSET 184
+`define FB_SNAPSHOT_REAR_REQUESTED_OFFSET 188
+`define FB_SNAPSHOT_REAR_APPLIED_OFFSET 192
+`define FB_SNAPSHOT_SAFETY_OVERRIDE_MASK_OFFSET 196
+`define FB_SNAPSHOT_LANE_FAULT_MASK_OFFSET 199
+`define FB_SNAPSHOT_GLOBAL_FAULT_OFFSET 200
 `endif

+ 76 - 27
generated/6400/snapshot-layout.json

@@ -1,9 +1,9 @@
 {
   "byte_order": "little",
-  "contract_sha256": "9b2df5161fb37e4b84af8337c5e99a78e27b6058934a245068afd2d533468def",
+  "contract_sha256": "35fe2e0602b5bc1ead064b7aaaf66571266fa6c809841fe68fb1c882cb13291b",
   "fields": [
     {
-      "name": "control_state",
+      "name": "mode",
       "offset": 0,
       "size": 1,
       "type": "u8"
@@ -15,140 +15,189 @@
       "type": "u16"
     },
     {
-      "name": "current_target",
+      "name": "watchdog_active",
       "offset": 3,
       "size": 1,
+      "type": "u8"
+    },
+    {
+      "name": "watchdog_remaining",
+      "offset": 4,
+      "size": 1,
+      "type": "u8",
+      "unit": "seconds"
+    },
+    {
+      "name": "pid_target",
+      "offset": 5,
+      "size": 1,
       "type": "u8",
       "unit": "degC"
     },
     {
-      "name": "host_target_seen",
-      "offset": 4,
+      "name": "pid_running",
+      "offset": 6,
+      "size": 1,
+      "type": "u8"
+    },
+    {
+      "name": "manual_mode",
+      "offset": 7,
+      "size": 1,
+      "type": "u8"
+    },
+    {
+      "name": "bmc_valid",
+      "offset": 8,
+      "size": 1,
+      "type": "u8"
+    },
+    {
+      "name": "bmc_stale",
+      "offset": 9,
+      "size": 1,
+      "type": "u8"
+    },
+    {
+      "name": "ct_valid",
+      "offset": 10,
+      "size": 1,
+      "type": "u8"
+    },
+    {
+      "name": "ct_stale",
+      "offset": 11,
+      "size": 1,
+      "type": "u8"
+    },
+    {
+      "name": "hard_protect",
+      "offset": 12,
       "size": 1,
       "type": "u8"
     },
     {
       "name": "bmc_epoch",
-      "offset": 5,
+      "offset": 13,
       "size": 2,
       "type": "u16"
     },
     {
       "name": "ct_epoch",
-      "offset": 7,
+      "offset": 15,
       "size": 2,
       "type": "u16"
     },
     {
       "name": "control_epoch",
-      "offset": 9,
+      "offset": 17,
       "size": 2,
       "type": "u16"
     },
     {
       "name": "bmc_age",
-      "offset": 11,
+      "offset": 19,
       "size": 2,
       "type": "u16",
-      "unit": "control_ticks"
+      "unit": "seconds"
     },
     {
       "name": "ct_age",
-      "offset": 13,
+      "offset": 21,
       "size": 2,
       "type": "u16",
-      "unit": "control_ticks"
+      "unit": "seconds"
     },
     {
       "count": 24,
       "name": "bmc_raw",
-      "offset": 15,
+      "offset": 23,
       "size": 48,
       "type": "u16"
     },
     {
       "count": 3,
       "name": "bmc_valid_mask",
-      "offset": 63,
+      "offset": 71,
       "size": 3,
       "type": "bytes"
     },
     {
       "count": 27,
       "name": "ct_raw",
-      "offset": 66,
+      "offset": 74,
       "size": 54,
       "type": "u16"
     },
     {
       "count": 4,
       "name": "ct_valid_mask",
-      "offset": 120,
+      "offset": 128,
       "size": 4,
       "type": "bytes"
     },
     {
       "count": 24,
       "name": "ptc_requested",
-      "offset": 124,
+      "offset": 132,
       "size": 24,
       "type": "u8"
     },
     {
       "count": 24,
       "name": "ptc_applied",
-      "offset": 148,
+      "offset": 156,
       "size": 24,
       "type": "u8"
     },
     {
       "count": 4,
       "name": "front_requested",
-      "offset": 172,
+      "offset": 180,
       "size": 4,
       "type": "u8"
     },
     {
       "count": 4,
       "name": "front_applied",
-      "offset": 176,
+      "offset": 184,
       "size": 4,
       "type": "u8"
     },
     {
       "count": 4,
       "name": "rear_requested",
-      "offset": 180,
+      "offset": 188,
       "size": 4,
       "type": "u8"
     },
     {
       "count": 4,
       "name": "rear_applied",
-      "offset": 184,
+      "offset": 192,
       "size": 4,
       "type": "u8"
     },
     {
       "count": 3,
       "name": "safety_override_mask",
-      "offset": 188,
+      "offset": 196,
       "size": 3,
       "type": "bytes"
     },
     {
       "name": "lane_fault_mask",
-      "offset": 191,
+      "offset": 199,
       "size": 1,
       "type": "u8"
     },
     {
       "name": "global_fault",
-      "offset": 192,
+      "offset": 200,
       "size": 1,
       "type": "u8"
     }
   ],
-  "payload_length": 193,
-  "schema": "prod2u-6400-snapshot-v1"
+  "payload_length": 201,
+  "schema": "prod2u-6400-snapshot-v2"
 }

+ 3 - 1
products/6400-control/project.json

@@ -16,6 +16,8 @@
   "host_rs232_connector": "CON78",
   "ttl_pin_status": "disabled_in_rs232_only_hardware_profile_unbound",
   "ct_physical_map_status": "unknown",
-  "host_watchdog": false,
+  "host_watchdog_seconds": 10,
+  "default_pid_target_c": 70,
+  "fan_safe_connector_duty": 20,
   "pll": false
 }

+ 2 - 2
products/6400-control/source-closure.json

@@ -21,14 +21,14 @@
     "src/acquisition/bmc_ascii_snapshot.v",
     "src/acquisition/ct7428_snapshot.v",
     "src/control/thermal_output_banks.v",
+    "src/control/manual_set_all_bank.v",
     "src/control/stimulus_atomic_bank.v",
     "src/control/thermal_control_core.v",
     "src/actuator/pwm_bitmap_engine.v",
-    "src/actuator/fan_boot_safety_controller.v",
     "src/actuator/fan_board_output_adapter.v",
     "src/telemetry/thermal_snapshot_mux.v",
     "src/top/prod2u_6400_v1_top.v",
     "src/top/prod2u_6400_rs232_only_top.v"
   ],
-  "forbidden_substrings": ["door_", "motor", "limit_gate", "host_watchdog", "EF2_PHY_PLL", "SET_ALL"]
+  "forbidden_substrings": ["door_", "motor", "limit_gate", "EF2_PHY_PLL", "SET_TARGET", "8'h81", "8'h42"]
 }

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

@@ -0,0 +1,55 @@
+{
+  "schema": "prod2u-analysis-replay-closure-v1",
+  "project_id": "6400-front-rear",
+  "paths": [
+    "contracts/6400-fixed-point.yaml",
+    "contracts/6400-snapshot.yaml",
+    "contracts/6400-wire.yaml",
+    "contracts/channel-map.yaml",
+    "contracts/controller-coefficients.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_formal.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/formal/6400-properties.json",
+    "tests/formal/solver-map.yaml",
+    "tests/formal/6400_board_adapter_properties.sby",
+    "tests/formal/6400_board_adapter_properties_formal.v",
+    "tests/formal/6400_core_owner_properties.sby",
+    "tests/formal/6400_core_owner_properties_formal.v",
+    "tests/formal/6400_core_transition_properties.sby",
+    "tests/formal/6400_frame_rx_properties.sby",
+    "tests/formal/6400_frame_rx_properties_formal.v",
+    "tests/formal/6400_snapshot_transport_properties.sby",
+    "tests/formal/6400_snapshot_transport_properties_formal.v",
+    "tests/formal/6400_snapshot_properties.sby",
+    "tests/formal/6400_snapshot_properties_formal.v",
+    "tests/formal/6400_bmc_bank_properties.sby",
+    "tests/formal/6400_bmc_bank_properties_formal.v",
+    "tests/formal/6400_pwm_properties.sby",
+    "tests/formal/6400_pwm_properties_formal.v",
+    "tests/formal/6400_host_command_properties.sby",
+    "tests/formal/6400_host_command_properties_formal.v",
+    "tests/formal/6400_set_all_commit_properties.sby",
+    "tests/formal/6400_set_all_commit_properties_formal.v",
+    "tests/unit/test_6400_closure_separation.py"
+  ]
+}

+ 24 - 0
products/6400-front-rear/project.json

@@ -0,0 +1,24 @@
+{
+  "schema": "prod2u-6400-profile-v1",
+  "project_id": "6400-front-rear",
+  "product": "6400-front-rear",
+  "top": "prod2u_6400_rs232_only_top",
+  "device": "EF2L45BG256B",
+  "clock_hz": 25000000,
+  "source_closure": "products/6400-front-rear/source-closure.json",
+  "board_id": "fcb_fpga_mcu_v1_1_20260625",
+  "board_evidence": "external:FCB_FPGA+MCU_V1.1_20260625.brd",
+  "board_evidence_sha256": "db02938f7943b2ae532aa18208f61588364d32a70a0cc72f74b4a94aaab7e258",
+  "constraints": "constraints/prod2u_6400_front_back.adc",
+  "timing_constraints": "constraints/prod2u_6400_front_back.sdc",
+  "stimulus": false,
+  "host_interfaces": ["host_rs232"],
+  "host_rs232_connector": "CON78",
+  "ttl_pin_status": "disabled_in_rs232_only_hardware_profile_unbound",
+  "ct_physical_map_status": "unknown",
+  "control_watchdog_seconds": 30,
+  "default_pid_target_c": 70,
+  "fan_safe_connector_duty": 20,
+  "fan_board_invert_mask": "0x0F",
+  "pll": false
+}

+ 33 - 0
products/6400-front-rear/source-closure.json

@@ -0,0 +1,33 @@
+{
+  "schema": "prod2u-source-closure-v1",
+  "project_id": "6400-front-rear",
+  "top_module": "prod2u_6400_rs232_only_top",
+  "sources": [
+    "generated/6400/prod2u_6400_v1_params.vh",
+    "src/common/uart_rx_byte.v",
+    "src/common/uart_tx_byte.v",
+    "src/common/crc16_serial.v",
+    "src/common/ef2_bram_dp.v",
+    "src/common/frame_rx.v",
+    "src/common/frame_tx.v",
+    "src/common/payload_ram.v",
+    "src/modules/shared_500us_tick.v",
+    "src/modules/i2c_word_reader.v",
+    "src/rtl/prod2u_por.v",
+    "src/rtl/prod2u_p4_i2c_stop_start_read.v",
+    "src/transport/host_port_selector.v",
+    "src/transport/thermal_host_command.v",
+    "src/acquisition/bmc_poll_engine.v",
+    "src/acquisition/bmc_ascii_snapshot.v",
+    "src/acquisition/ct7428_snapshot.v",
+    "src/control/thermal_output_banks.v",
+    "src/control/manual_set_all_bank.v",
+    "src/control/thermal_control_core.v",
+    "src/actuator/pwm_bitmap_engine.v",
+    "src/actuator/fan_board_output_adapter.v",
+    "src/telemetry/thermal_snapshot_mux.v",
+    "src/top/prod2u_6400_v1_top.v",
+    "src/top/prod2u_6400_rs232_only_top.v"
+  ],
+  "forbidden_substrings": ["door_", "motor", "limit_gate", "EF2_PHY_PLL", "SET_TARGET", "8'h81", "8'h42", "stimulus_atomic_bank"]
+}

+ 1 - 1
products/6400-identification/source-closure.json

@@ -6,5 +6,5 @@
   "additional_sources": ["src/top/prod2u_6400_identification_top.v"],
   "stimulus": true,
   "production": false,
-  "forbidden_substrings": ["door_", "motor", "limit_gate", "host_watchdog", "EF2_PHY_PLL", "SET_ALL"]
+  "forbidden_substrings": ["door_", "motor", "limit_gate", "EF2_PHY_PLL", "SET_TARGET", "8'h81", "8'h42"]
 }

+ 1 - 1
products/6400-sim-debug/source-closure.json

@@ -7,5 +7,5 @@
   "stimulus": true,
   "simulation_only": true,
   "production": false,
-  "forbidden_substrings": ["door_", "motor", "limit_gate", "host_watchdog", "EF2_PHY_PLL", "SET_ALL"]
+  "forbidden_substrings": ["door_", "motor", "limit_gate", "EF2_PHY_PLL", "SET_TARGET", "8'h81", "8'h42"]
 }

+ 8 - 8
projects/registry.json

@@ -39,14 +39,14 @@
     "6400": {
       "alias": "6400",
       "aliases": ["prod2u-6400-front-back"],
-      "project_id": "6400-control",
-      "profile": "6400-control",
-      "validation_profile": "6400-control",
-      "project_profile": "6400-control",
-      "semantic_profile": "6400-front-rear-v1",
+      "project_id": "6400-front-rear",
+      "profile": "6400-front-rear",
+      "validation_profile": "6400-front-rear",
+      "project_profile": "6400-front-rear",
+      "semantic_profile": "6400-front-rear",
       "display_name": "6400 V1.1 front/rear production controller",
-      "project_config": "products/6400-control/project.json",
-      "project_json": "products/6400-control/project.json",
+      "project_config": "products/6400-front-rear/project.json",
+      "project_json": "products/6400-front-rear/project.json",
       "verification_targets": "config/prod2u_6400_verification_targets_v1.json",
       "features": {
         "motors": false,
@@ -55,7 +55,7 @@
         "get_motor_status": false
       },
       "requirements": "docs/prod2u-6400-front-back-protocol.zh-CN.md",
-      "source_closure": "products/6400-control/source-closure.json",
+      "source_closure": "products/6400-front-rear/source-closure.json",
       "generated_dir": "generated/6400",
       "top_module": "prod2u_6400_rs232_only_top",
       "top_file": "src/top/prod2u_6400_rs232_only_top.v",

+ 21 - 0
protocol-compatibility.json

@@ -0,0 +1,21 @@
+{
+  "schema": "prod2u-6400-protocol-compatibility-v1",
+  "product": "6400-front-rear",
+  "scan_baseline": "127db8eef879a6c0cad0e97b485c28d59944afa9",
+  "set_all_type": "0x01",
+  "get_type": "0x02",
+  "type_0x03_current_meaning": "SET_STIMULUS",
+  "type_0x03_product_behavior": "UNSUPPORTED_NACK",
+  "set_pid_target_type": "0x04",
+  "ack_nack_type": "0x06",
+  "ack_nack_source": "fallback_contract_format_no_active_mrdimm_unified_ack_found",
+  "ack_nack_payload": ["ok", "request_type", "status", "detail"],
+  "snapshot_data_type": "0x82",
+  "collisions": [],
+  "legacy_response_types_removed_from_active_6400": ["0x81", "0x83", "0x42"],
+  "evidence": [
+    "generated/6400/host-contract.json: current 0x03 SET_STIMULUS and legacy per-command responses",
+    "projects/registry.json: active 6400 physical interface and generated contract path",
+    "hth-platform internal protocol scan: no active unified ACK/NACK contract available"
+  ]
+}

+ 3 - 11
src/actuator/fan_board_output_adapter.v

@@ -7,14 +7,10 @@ module fan_board_output_adapter #(
     parameter [7:0] BOARD_INVERT_MASK = 8'h0F
 ) (
     input  wire [7:0] logical_fan_on,
-    input  wire       boot_release,
-    input  wire       force_full_speed,
     output wire [3:0] front_fan_ball,
     output wire [3:0] rear_fan_ball
 );
-    wire [7:0] requested_fan_on = (!boot_release || force_full_speed) ?
-        8'hFF : logical_fan_on;
-    wire [7:0] fan_pwm_sink_enable = requested_fan_on ^ BOARD_INVERT_MASK;
+    wire [7:0] fan_pwm_sink_enable = logical_fan_on ^ BOARD_INVERT_MASK;
 
     assign front_fan_ball = fan_pwm_sink_enable[3:0];
     assign rear_fan_ball = fan_pwm_sink_enable[7:4];
@@ -22,12 +18,8 @@ module fan_board_output_adapter #(
 `ifdef FORMAL
     always @* begin
         assert(BOARD_INVERT_MASK == 8'h0F);
-        if (!boot_release || force_full_speed) begin
-            assert(front_fan_ball == 4'h0);
-            assert(rear_fan_ball == 4'hF);
-        end
-        assert(front_fan_ball == ~requested_fan_on[3:0]);
-        assert(rear_fan_ball == requested_fan_on[7:4]);
+        assert(front_fan_ball == ~logical_fan_on[3:0]);
+        assert(rear_fan_ball == logical_fan_on[7:4]);
     end
 `endif
 endmodule

+ 57 - 94
src/actuator/pwm_bitmap_engine.v

@@ -1,14 +1,14 @@
 `timescale 1ns/1ps
 
-// One comparator builds the next 32-bit phase image. Physical outputs switch
-// together only at a phase boundary.
+// The carrier is FPGA/POR initialized and never held by control reset. While
+// rst_n is low it independently emits connector-safe PTC0/FAN20 PWM.
 module pwm_bitmap_engine #(
     parameter integer CHANNEL_COUNT = 32,
     parameter integer PHASE_COUNT = 100,
     parameter integer PTC_PHASE_CLKS = 500,
     parameter integer FAN_PHASE_CLKS = 500,
     parameter integer ADDR_WIDTH = 5,
-    parameter [31:0] RESET_LOGICAL_BITMAP = 32'hFF000000
+    parameter [7:0] RESET_FAN_DUTY = 8'd20
 ) (
     input  wire                     clk,
     input  wire                     rst_n,
@@ -21,18 +21,11 @@ module pwm_bitmap_engine #(
     output wire [6:0]               phase_value,
     output wire                     scan_idle
 );
-    localparam integer PHASE_BITS = (PHASE_COUNT <= 1) ? 1 : $clog2(PHASE_COUNT);
-    // V1 preserves one comparator and one scan because the independently
-    // generated PTC and FAN carrier parameters are equal in this closure.
-    // Unequal future contracts fail this backend explicitly and must select a
-    // dual-carrier scheduler; they cannot silently inherit the PTC frequency.
-    localparam integer SHARED_PHASE_CLKS = PTC_PHASE_CLKS;
-    localparam integer SLOT_BITS = (SHARED_PHASE_CLKS <= 1) ? 1 : $clog2(SHARED_PHASE_CLKS);
-    /* verilator lint_off WIDTH */
+    localparam integer PHASE_BITS = $clog2(PHASE_COUNT);
+    localparam integer SLOT_BITS = $clog2(PTC_PHASE_CLKS);
     localparam [PHASE_BITS-1:0] LAST_PHASE = PHASE_COUNT - 1;
-    localparam [SLOT_BITS-1:0] LAST_SLOT = SHARED_PHASE_CLKS - 1;
+    localparam [SLOT_BITS-1:0] LAST_SLOT = PTC_PHASE_CLKS - 1;
     localparam [ADDR_WIDTH-1:0] LAST_CHANNEL = CHANNEL_COUNT - 1;
-    /* verilator lint_on WIDTH */
 
     reg [PHASE_BITS-1:0] phase;
     reg [SLOT_BITS-1:0] phase_clk;
@@ -41,106 +34,76 @@ module pwm_bitmap_engine #(
     reg scanning;
     reg capture_valid;
     reg [CHANNEL_COUNT-1:0] next_bitmap;
+    wire [PHASE_BITS-1:0] build_phase = (phase == LAST_PHASE) ? 0 : phase + 1'b1;
+    wire [7:0] build_phase_8 = {{(8-PHASE_BITS){1'b0}}, build_phase};
+    wire [31:0] reset_safe_bitmap = (build_phase_8 < RESET_FAN_DUTY) ? 32'hFF000000 : 32'h00000000;
 
     initial begin
-        if (PTC_PHASE_CLKS != FAN_PHASE_CLKS)
-            $error("shared_equal_frequency_v1 requires equal independently generated PTC/FAN phase clocks");
+        phase = 0;
+        phase_clk = 0;
+        scan_addr = 0;
+        capture_addr = 0;
+        scanning = 0;
+        capture_valid = 0;
+        next_bitmap = 0;
+        logical_bitmap = 32'hFF000000;
+        phase_boundary = 0;
+        deadline_miss = 0;
     end
 
-    wire [PHASE_BITS-1:0] build_phase =
-        (phase == LAST_PHASE) ? {PHASE_BITS{1'b0}} : phase + 1'b1;
-    wire [7:0] build_phase_8 = {{(8-PHASE_BITS){1'b0}}, build_phase};
+    initial if (PTC_PHASE_CLKS != FAN_PHASE_CLKS)
+        $error("shared carrier requires equal PTC/FAN phase clocks");
 
     assign duty_rd_addr = scan_addr;
     assign phase_value = {{(7-PHASE_BITS){1'b0}}, phase};
     assign scan_idle = !scanning && !capture_valid;
     assign phase_boundary_advance = phase_clk == LAST_SLOT;
 
-    always @(posedge clk or negedge rst_n) begin
-        if (!rst_n) begin
-            phase <= {PHASE_BITS{1'b0}};
-            phase_clk <= {SLOT_BITS{1'b0}};
-            scan_addr <= {ADDR_WIDTH{1'b0}};
-            capture_addr <= {ADDR_WIDTH{1'b0}};
-            scanning <= 1'b1;
-            capture_valid <= 1'b0;
-            next_bitmap <= {CHANNEL_COUNT{1'b0}};
-            logical_bitmap <= RESET_LOGICAL_BITMAP[CHANNEL_COUNT-1:0];
-            phase_boundary <= 1'b0;
-            deadline_miss <= 1'b0;
-        end else begin
-            phase_boundary <= 1'b0;
-
-            if (capture_valid) begin
-                next_bitmap[capture_addr] <= (duty_rd_data > build_phase_8);
-            end
+    always @(posedge clk) begin
+        phase_boundary <= 0;
 
-            capture_valid <= scanning;
-            if (scanning) begin
-                capture_addr <= scan_addr;
-                if (scan_addr == LAST_CHANNEL) begin
-                    scanning <= 1'b0;
-                end else begin
-                    scan_addr <= scan_addr + 1'b1;
-                end
-            end
+        if (rst_n && capture_valid)
+            next_bitmap[capture_addr] <= duty_rd_data > build_phase_8;
+        capture_valid <= rst_n && scanning;
+        if (rst_n && scanning) begin
+            capture_addr <= scan_addr;
+            if (scan_addr == LAST_CHANNEL) scanning <= 0;
+            else scan_addr <= scan_addr + 1'b1;
+        end
 
-            if (phase_clk == LAST_SLOT) begin
-                phase_clk <= {SLOT_BITS{1'b0}};
-                phase <= (phase == LAST_PHASE) ? {PHASE_BITS{1'b0}} : phase + 1'b1;
-                phase_boundary <= 1'b1;
-                if (!scanning && !capture_valid) begin
-                    logical_bitmap <= next_bitmap;
-                end else begin
-                    deadline_miss <= 1'b1;
-                end
-                next_bitmap <= {CHANNEL_COUNT{1'b0}};
-                scan_addr <= {ADDR_WIDTH{1'b0}};
-                scanning <= 1'b1;
-                capture_valid <= 1'b0;
+        if (phase_clk == LAST_SLOT) begin
+            phase_clk <= 0;
+            phase <= build_phase;
+            phase_boundary <= 1;
+            if (!rst_n) begin
+                logical_bitmap <= reset_safe_bitmap[CHANNEL_COUNT-1:0];
+                deadline_miss <= 0;
+            end else if (!scanning && !capture_valid) begin
+                logical_bitmap <= next_bitmap;
             end else begin
-                phase_clk <= phase_clk + 1'b1;
+                deadline_miss <= 1;
+            end
+            next_bitmap <= 0;
+            scan_addr <= 0;
+            scanning <= rst_n;
+            capture_valid <= 0;
+        end else begin
+            phase_clk <= phase_clk + 1'b1;
+            if (!rst_n) begin
+                scanning <= 0;
+                capture_valid <= 0;
+                next_bitmap <= 0;
             end
         end
     end
 
 `ifdef FORMAL
-    reg formal_past_valid;
-    function [6:0] formal_scan_rank;
-        input [ADDR_WIDTH-1:0] address;
-        input scan_active;
-        input capture_pending;
-        begin
-            if (scan_active)
-                formal_scan_rank = CHANNEL_COUNT[6:0] - address + 1'b1;
-            else if (capture_pending)
-                formal_scan_rank = 7'd1;
-            else
-                formal_scan_rank = 7'd0;
-        end
-    endfunction
-    wire [6:0] formal_scan_remaining = formal_scan_rank(scan_addr, scanning, capture_valid);
-    initial formal_past_valid = 0;
     always @(posedge clk) begin
-        formal_past_valid <= 1;
-        if (rst_n) begin
-            // P11: the 32-channel scan always completes before the 500-clock deadline.
-            assert(!deadline_miss);
-            assert(phase <= LAST_PHASE);
-            assert(phase_clk <= LAST_SLOT);
-            assert(phase_boundary_advance == (phase_clk == LAST_SLOT));
-            if (phase_clk < CHANNEL_COUNT + 1)
-                assert(formal_scan_remaining == CHANNEL_COUNT + 1 - phase_clk);
-            else
-                assert(formal_scan_remaining == 0);
-            if (formal_past_valid && $past(rst_n) && logical_bitmap != $past(logical_bitmap))
-                assert(phase_boundary);
-            if (!scanning && !capture_valid)
-                assert(scan_idle);
-            if (formal_past_valid && $past(rst_n))
-                assert(phase_boundary == $past(phase_clk == LAST_SLOT));
-            cover(scan_idle);
-            cover(phase_boundary && !deadline_miss);
+        assert(phase < PHASE_COUNT);
+        assert(phase_clk < PTC_PHASE_CLKS);
+        if (!rst_n) begin
+            assert(logical_bitmap[23:0] == 0);
+            assert(logical_bitmap[31:24] == 8'h00 || logical_bitmap[31:24] == 8'hFF);
         end
     end
 `endif

+ 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;

+ 12 - 3
src/common/uart_rx_byte.v

@@ -21,15 +21,25 @@ module uart_rx_byte #(
     localparam [1:0] ST_DATA = 2'd2;
     localparam [1:0] ST_STOP = 2'd3;
 
-    (* async_reg = "true" *) reg [1:0] rx_sync_pipe;
+    reg [1:0] rx_sync_pipe;
     reg [1:0] state;
     reg [COUNTER_BITS-1:0] bit_counter;
     reg [2:0] bit_index;
     reg [7:0] data_reg;
 
+    // Keep the asynchronous input synchronizer on an ordinary, explicitly
+    // clocked two-flop path. TD maps async_reg plus async-reset metadata to an
+    // unclocked first-stage primitive on EF2; synchronous reset avoids that
+    // unsafe mapping while preserving two full settling clocks.
+    always @(posedge clk) begin
+        if (!rst_n)
+            rx_sync_pipe <= 2'b11;
+        else
+            rx_sync_pipe <= {rx_sync_pipe[0], rx_i};
+    end
+
     always @(posedge clk or negedge rst_n) begin
         if (!rst_n) begin
-            rx_sync_pipe <= 2'b11;
             state <= ST_IDLE;
             bit_counter <= {COUNTER_BITS{1'b0}};
             bit_index <= 3'd0;
@@ -38,7 +48,6 @@ module uart_rx_byte #(
             byte_data <= 8'd0;
             framing_error <= 1'b0;
         end else begin
-            rx_sync_pipe <= {rx_sync_pipe[0], rx_i};
             byte_valid <= 1'b0;
             framing_error <= 1'b0;
 

+ 40 - 0
src/control/manual_set_all_bank.v

@@ -0,0 +1,40 @@
+`timescale 1ns/1ps
+
+// Complete validated SET_ALL vectors stage here. The active pointer changes
+// only after all 32 addresses have been written; partial frames are invisible.
+module manual_set_all_bank (
+    input  wire       clk,
+    input  wire       rst_n,
+    input  wire       write_enable,
+    input  wire [4:0] write_address,
+    input  wire [7:0] write_data,
+    input  wire       commit,
+    output wire       commit_applied,
+    output reg        active_bank,
+    input  wire [4:0] read_address,
+    output wire [7:0] read_data
+);
+    reg [7:0] bank0 [0:31];
+    reg [7:0] bank1 [0:31];
+    reg [31:0] inactive_written;
+    wire accepted_write = write_enable && write_data <= 100;
+    assign commit_applied = commit && (&inactive_written);
+    assign read_data = active_bank ? bank1[read_address] : bank0[read_address];
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            active_bank <= 0;
+            inactive_written <= 0;
+        end else begin
+            if (accepted_write) begin
+                if (active_bank) bank0[write_address] <= write_data;
+                else bank1[write_address] <= write_data;
+                inactive_written[write_address] <= 1;
+            end
+            if (commit_applied) begin
+                active_bank <= ~active_bank;
+                inactive_written <= 0;
+            end
+        end
+    end
+endmodule

Разница между файлами не показана из-за своего большого размера
+ 433 - 992
src/control/thermal_control_core.v


+ 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": []

+ 6 - 3
src/rtl/prod2u_p4_i2c_stop_start_read.v

@@ -53,8 +53,8 @@ module prod2u_p4_i2c_stop_start_read #(
     localparam [4:0] ST_ABORT_SCL_HIGH = 5'd16;
     localparam [4:0] ST_ABORT_RELEASE = 5'd17;
 
-    (* async_reg = "true" *) reg [1:0] scl_sync;
-    (* async_reg = "true" *) reg [1:0] sda_sync;
+    reg [1:0] scl_sync;
+    reg [1:0] sda_sync;
     (* keep = "true", syn_encoding = "sequential", fsm_encoding = "none" *)
     reg [4:0] state;
     reg [31:0] phase_count;
@@ -86,7 +86,10 @@ module prod2u_p4_i2c_stop_start_read #(
         end
     endgenerate
 
-    always @(posedge clk or negedge rst_n) begin
+    // Synchronous-reset input synchronizers keep both EF2 stages on the
+    // declared sys_clk. See uart_rx_byte for the corresponding TD mapping
+    // constraint.
+    always @(posedge clk) begin
         if (!rst_n) begin
             scl_sync <= 2'b11;
             sda_sync <= 2'b11;

+ 47 - 15
src/telemetry/thermal_snapshot_mux.v

@@ -16,7 +16,13 @@ module thermal_snapshot_mux (
     input  wire [2:0]  control_state,
     input  wire [15:0] fault_flags,
     input  wire [7:0]  current_target,
-    input  wire        host_target_seen,
+    input  wire        watchdog_active,
+    input  wire [7:0]  watchdog_remaining,
+    input  wire        pid_running,
+    input  wire        manual_mode,
+    input  wire        hard_protect,
+    input  wire        bmc_stale,
+    input  wire        ct_stale,
     input  wire [15:0] bmc_epoch,
     input  wire [15:0] ct_epoch,
     input  wire [15:0] control_epoch,
@@ -41,7 +47,13 @@ module thermal_snapshot_mux (
     reg [2:0] state_latched;
     reg [15:0] faults_latched;
     reg [7:0] target_latched;
-    reg host_seen_latched;
+    reg watchdog_active_latched;
+    reg [7:0] watchdog_remaining_latched;
+    reg pid_running_latched;
+    reg manual_mode_latched;
+    reg hard_protect_latched;
+    reg bmc_stale_latched;
+    reg ct_stale_latched;
     reg [15:0] bmc_epoch_latched;
     reg [15:0] ct_epoch_latched;
     reg [15:0] control_epoch_latched;
@@ -67,7 +79,13 @@ module thermal_snapshot_mux (
             state_latched <= 0;
             faults_latched <= 0;
             target_latched <= 70;
-            host_seen_latched <= 0;
+            watchdog_active_latched <= 0;
+            watchdog_remaining_latched <= 0;
+            pid_running_latched <= 0;
+            manual_mode_latched <= 0;
+            hard_protect_latched <= 0;
+            bmc_stale_latched <= 1;
+            ct_stale_latched <= 1;
             bmc_epoch_latched <= 0;
             ct_epoch_latched <= 0;
             control_epoch_latched <= 0;
@@ -89,7 +107,13 @@ module thermal_snapshot_mux (
                 state_latched <= control_state;
                 faults_latched <= fault_flags;
                 target_latched <= current_target;
-                host_seen_latched <= host_target_seen;
+                watchdog_active_latched <= watchdog_active;
+                watchdog_remaining_latched <= watchdog_remaining;
+                pid_running_latched <= pid_running;
+                manual_mode_latched <= manual_mode;
+                hard_protect_latched <= hard_protect;
+                bmc_stale_latched <= bmc_stale;
+                ct_stale_latched <= ct_stale;
                 bmc_epoch_latched <= bmc_epoch;
                 ct_epoch_latched <= ct_epoch;
                 control_epoch_latched <= control_epoch;
@@ -109,30 +133,30 @@ module thermal_snapshot_mux (
         bmc_rd_index = 0;
         ct_rd_index = 0;
         output_rd_addr = 0;
-        bmc_relative = payload_addr[5:0] - 6'd15;
-        ct_relative = payload_addr[5:0] - 6'd2;
+        bmc_relative = payload_addr - `FB_SNAPSHOT_BMC_RAW_OFFSET;
+        ct_relative = payload_addr - `FB_SNAPSHOT_CT_RAW_OFFSET;
         output_relative = 0;
         if (payload_addr >= `FB_SNAPSHOT_BMC_RAW_OFFSET && payload_addr < `FB_SNAPSHOT_BMC_VALID_MASK_OFFSET)
             bmc_rd_index = bmc_relative[5:1];
         if (payload_addr >= `FB_SNAPSHOT_CT_RAW_OFFSET && payload_addr < `FB_SNAPSHOT_CT_VALID_MASK_OFFSET)
             ct_rd_index = ct_relative[5:1];
         if (payload_addr >= `FB_SNAPSHOT_PTC_REQUESTED_OFFSET && payload_addr < `FB_SNAPSHOT_PTC_APPLIED_OFFSET) begin
-            output_relative = payload_addr[4:0] - 5'd28;
+            output_relative = payload_addr - `FB_SNAPSHOT_PTC_REQUESTED_OFFSET;
             output_rd_addr = output_relative;
         end else if (payload_addr >= `FB_SNAPSHOT_PTC_APPLIED_OFFSET && payload_addr < `FB_SNAPSHOT_FRONT_REQUESTED_OFFSET) begin
-            output_relative = payload_addr[4:0] - 5'd20;
+            output_relative = payload_addr - `FB_SNAPSHOT_PTC_APPLIED_OFFSET;
             output_rd_addr = output_relative;
         end else if (payload_addr >= `FB_SNAPSHOT_FRONT_REQUESTED_OFFSET && payload_addr < `FB_SNAPSHOT_FRONT_APPLIED_OFFSET) begin
-            output_relative = payload_addr[4:0] - 5'd12;
+            output_relative = payload_addr - `FB_SNAPSHOT_FRONT_REQUESTED_OFFSET;
             output_rd_addr = 5'd24 + {3'd0, output_relative[1:0]};
         end else if (payload_addr >= `FB_SNAPSHOT_FRONT_APPLIED_OFFSET && payload_addr < `FB_SNAPSHOT_REAR_REQUESTED_OFFSET) begin
-            output_relative = payload_addr[4:0] - 5'd16;
+            output_relative = payload_addr - `FB_SNAPSHOT_FRONT_APPLIED_OFFSET;
             output_rd_addr = 5'd24 + {3'd0, output_relative[1:0]};
         end else if (payload_addr >= `FB_SNAPSHOT_REAR_REQUESTED_OFFSET && payload_addr < `FB_SNAPSHOT_REAR_APPLIED_OFFSET) begin
-            output_relative = payload_addr[4:0] - 5'd20;
+            output_relative = payload_addr - `FB_SNAPSHOT_REAR_REQUESTED_OFFSET;
             output_rd_addr = 5'd28 + {3'd0, output_relative[1:0]};
         end else if (payload_addr >= `FB_SNAPSHOT_REAR_APPLIED_OFFSET && payload_addr < `FB_SNAPSHOT_SAFETY_OVERRIDE_MASK_OFFSET) begin
-            output_relative = payload_addr[4:0] - 5'd24;
+            output_relative = payload_addr - `FB_SNAPSHOT_REAR_APPLIED_OFFSET;
             output_rd_addr = 5'd28 + {3'd0, output_relative[1:0]};
         end
     end
@@ -140,11 +164,19 @@ module thermal_snapshot_mux (
     always @* begin
         payload_data = 0;
         mask_relative = 0;
-        if (payload_addr == `FB_SNAPSHOT_CONTROL_STATE_OFFSET) payload_data = {5'd0, state_latched};
+        if (payload_addr == `FB_SNAPSHOT_MODE_OFFSET) payload_data = {5'd0, state_latched};
         else if (payload_addr == `FB_SNAPSHOT_FAULT_FLAGS_OFFSET) payload_data = faults_latched[7:0];
         else if (payload_addr == `FB_SNAPSHOT_FAULT_FLAGS_OFFSET + 1) payload_data = faults_latched[15:8];
-        else if (payload_addr == `FB_SNAPSHOT_CURRENT_TARGET_OFFSET) payload_data = target_latched;
-        else if (payload_addr == `FB_SNAPSHOT_HOST_TARGET_SEEN_OFFSET) payload_data = {7'd0, host_seen_latched};
+        else if (payload_addr == `FB_SNAPSHOT_WATCHDOG_ACTIVE_OFFSET) payload_data = {7'd0, watchdog_active_latched};
+        else if (payload_addr == `FB_SNAPSHOT_WATCHDOG_REMAINING_OFFSET) payload_data = watchdog_remaining_latched;
+        else if (payload_addr == `FB_SNAPSHOT_PID_TARGET_OFFSET) payload_data = target_latched;
+        else if (payload_addr == `FB_SNAPSHOT_PID_RUNNING_OFFSET) payload_data = {7'd0, pid_running_latched};
+        else if (payload_addr == `FB_SNAPSHOT_MANUAL_MODE_OFFSET) payload_data = {7'd0, manual_mode_latched};
+        else if (payload_addr == `FB_SNAPSHOT_BMC_VALID_OFFSET) payload_data = {7'd0, &bmc_valid_latched};
+        else if (payload_addr == `FB_SNAPSHOT_BMC_STALE_OFFSET) payload_data = {7'd0, bmc_stale_latched};
+        else if (payload_addr == `FB_SNAPSHOT_CT_VALID_OFFSET) payload_data = {7'd0, &ct_valid_latched};
+        else if (payload_addr == `FB_SNAPSHOT_CT_STALE_OFFSET) payload_data = {7'd0, ct_stale_latched};
+        else if (payload_addr == `FB_SNAPSHOT_HARD_PROTECT_OFFSET) payload_data = {7'd0, hard_protect_latched};
         else if (payload_addr == `FB_SNAPSHOT_BMC_EPOCH_OFFSET) payload_data = bmc_epoch_latched[7:0];
         else if (payload_addr == `FB_SNAPSHOT_BMC_EPOCH_OFFSET + 1) payload_data = bmc_epoch_latched[15:8];
         else if (payload_addr == `FB_SNAPSHOT_CT_EPOCH_OFFSET) payload_data = ct_epoch_latched[7:0];

+ 45 - 47
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,
@@ -45,13 +44,14 @@ module prod2u_6400_v1_top #(
     wire [7:0] payload_wr_data;
     wire [7:0] payload_rd_addr;
     wire [7:0] payload_rd_data;
-    wire target_commit;
-    wire [7:0] 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 manual_wr_en;
+    wire [4:0] manual_wr_addr;
+    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 snapshot_capture;
     wire snapshot_ready;
     wire snapshot_locked;
@@ -64,6 +64,8 @@ module prod2u_6400_v1_top #(
     wire [7:0] frame_tx_byte_data;
     wire [7:0] frame_tx_payload_addr;
     wire [7:0] frame_tx_payload_data;
+    wire [7:0] snapshot_payload_data;
+    wire [7:0] ack_payload_data;
     wire host_tx_busy;
     wire host_tx_done;
     wire host_response_done = host_tx_done && !frame_tx_busy;
@@ -146,16 +148,17 @@ module prod2u_6400_v1_top #(
     wire [7:0] snapshot_applied_data;
     wire [2:0] control_state;
     wire [7:0] current_target;
-    wire host_target_seen;
     wire [15:0] control_epoch;
     wire [23:0] safety_mask;
     wire [3:0] lane_fault_mask;
     wire global_fault;
     wire output_commit;
-    wire stimulus_active;
     wire boot_init_complete;
-    wire boot_fan_release;
-    wire fan_force_full_speed;
+    wire watchdog_active;
+    wire [7:0] watchdog_remaining;
+    wire pid_running;
+    wire manual_mode;
+    wire hard_protect;
     wire [15:0] fault_flags = {8'd0, pwm_deadline_miss, bmc_parser_error, ct_stale,
         bmc_stale, global_fault, |lane_fault_mask, host_rx_error, bmc_rx_error};
 
@@ -163,21 +166,8 @@ module prod2u_6400_v1_top #(
     assign temp_sda = ct_sda_drive_low ? 1'b0 : 1'bz;
     assign ptc_pwm_out = logical_bitmap[23:0];
 
-    // Boot release and fault state are sampled only at the common PWM
-    // boundary so the physical fan pins never acquire a narrow pulse.
-    fan_boot_safety_controller u_fan_boot_safety (
-        .clk(sys_clk), .rst_n(rst_n),
-        .pwm_boundary_advance(pwm_boundary_advance),
-        .boot_init_complete(boot_init_complete),
-        .bmc_stale(bmc_stale), .global_fault(global_fault),
-        .boot_release(boot_fan_release),
-        .force_full_speed(fan_force_full_speed)
-    );
-
     fan_board_output_adapter #(.BOARD_INVERT_MASK(`FAN_BOARD_INVERT_MASK)) u_fan_board_adapter (
         .logical_fan_on(logical_bitmap[31:24]),
-        .boot_release(boot_fan_release),
-        .force_full_speed(fan_force_full_speed),
         .front_fan_ball(front_fan_pwm_out),
         .rear_fan_ball(rear_fan_pwm_out)
     );
@@ -199,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),
@@ -211,22 +201,27 @@ 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),
-        .target_commit(target_commit), .target_celsius(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),
+        .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_ok(manual_commit_ok),
+        .safety_locked(hard_protect),
+        .pid_target_commit(pid_target_commit), .pid_target_celsius(pid_target_celsius),
+        .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_done(host_response_done),
+        .tx_payload_length(tx_payload_length), .tx_payload_addr(frame_tx_payload_addr),
+        .ack_payload_data(ack_payload_data), .tx_done(host_response_done),
         .transaction_done(host_transaction_done), .busy(host_command_busy)
     );
+    assign frame_tx_payload_data = (tx_frame_type == `FB_RSP_ACK_NACK) ?
+        ack_payload_data : snapshot_payload_data;
     frame_tx #(.PAYLOAD_IDX_BITS(8), .EXTERNAL_CRC(1), .PAYLOAD_READ_LATENCY(1)) u_frame_tx (
         .clk(sys_clk), .rst_n(rst_n), .start(tx_start), .frame_type(tx_frame_type),
         .payload_length(tx_payload_length), .busy(frame_tx_busy), .byte_valid(frame_tx_byte_valid),
@@ -295,14 +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_STANDBY_DUTY(FAN_STANDBY_DUTY)
-    ) u_control (
-        .clk(sys_clk), .rst_n(rst_n), .tick_1s(tick_1s), .target_commit(target_commit),
-        .target_celsius(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),
+    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_ok(manual_commit_ok),
+        .pid_target_commit(pid_target_commit), .pid_target_celsius(pid_target_celsius),
         .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),
@@ -312,9 +305,11 @@ module prod2u_6400_v1_top #(
         .snapshot_rd_addr(snapshot_output_addr), .snapshot_requested_data(snapshot_requested_data),
         .snapshot_applied_data(snapshot_applied_data), .active_output_bank(output_active_bank),
         .control_state(control_state), .current_target_celsius(current_target),
-        .host_target_seen(host_target_seen), .control_epoch(control_epoch),
+        .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),
         .boot_init_complete(boot_init_complete)
     );
@@ -334,12 +329,15 @@ module prod2u_6400_v1_top #(
         .output_active_bank(output_active_bank), .bmc_locked_bank(bmc_locked_bank),
         .ct_locked_bank(ct_locked_bank), .output_locked_bank(output_locked_bank),
         .control_state(control_state), .fault_flags(fault_flags), .current_target(current_target),
-        .host_target_seen(host_target_seen), .bmc_epoch(bmc_epoch), .ct_epoch(ct_epoch),
+        .watchdog_active(watchdog_active), .watchdog_remaining(watchdog_remaining),
+        .pid_running(pid_running), .manual_mode(manual_mode), .hard_protect(hard_protect),
+        .bmc_stale(bmc_stale), .ct_stale(ct_stale),
+        .bmc_epoch(bmc_epoch), .ct_epoch(ct_epoch),
         .control_epoch(control_epoch), .bmc_age(bmc_age), .ct_age(ct_age),
         .bmc_valid_mask(bmc_valid_mask), .ct_valid_mask(ct_valid_mask),
         .safety_override_mask(safety_mask), .lane_fault_mask(lane_fault_mask),
         .global_fault(global_fault), .unlock(host_transaction_done), .payload_addr(frame_tx_payload_addr),
-        .payload_data(frame_tx_payload_data), .bmc_rd_index(bmc_snapshot_index),
+        .payload_data(snapshot_payload_data), .bmc_rd_index(bmc_snapshot_index),
         .bmc_rd_raw(bmc_snapshot_raw), .ct_rd_index(ct_snapshot_index),
         .ct_rd_raw(ct_snapshot_raw), .output_rd_addr(snapshot_output_addr),
         .requested_data(snapshot_requested_data), .applied_data(snapshot_applied_data)
@@ -349,8 +347,8 @@ 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,
-        boot_init_complete, boot_fan_release, fan_force_full_speed};
+        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
     always @(posedge sys_clk) begin

+ 142 - 164
src/transport/thermal_host_command.v

@@ -1,8 +1,10 @@
 `timescale 1ns/1ps
+`include "generated/6400/prod2u_6400_v1_params.vh"
 
+// 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 = 193
+    parameter integer SNAPSHOT_LENGTH = `FB_SNAPSHOT_LENGTH
 ) (
     input  wire       clk,
     input  wire       rst_n,
@@ -13,154 +15,188 @@ module thermal_host_command #(
     input  wire [7:0] frame_length,
     output reg  [7:0] payload_read_addr,
     input  wire [7:0] payload_read_data,
-    output reg        target_commit,
-    output reg [7:0]  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        manual_wr_en,
+    output reg  [4:0] manual_wr_addr,
+    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        snapshot_capture,
     input  wire       snapshot_ready,
     output reg        tx_start,
-    output reg [7:0]  tx_frame_type,
-    output reg [7:0]  tx_payload_length,
+    output reg  [7:0] tx_frame_type,
+    output reg  [7:0] tx_payload_length,
+    input  wire [7:0] tx_payload_addr,
+    output reg  [7:0] ack_payload_data,
     input  wire       tx_done,
     output reg        transaction_done,
     output wire       busy
-`ifdef FORMAL
-    , output wire [3:0] formal_state_o
-    , output wire [5:0] formal_index_o
-    , output wire       formal_stimulus_bad_o
-`endif
 );
-    localparam [3:0] ST_IDLE = 4'd0;
-    localparam [3:0] ST_TARGET = 4'd1;
-    localparam [3:0] ST_SNAPSHOT_WAIT = 4'd2;
-    localparam [3:0] ST_STIM_DURATION = 4'd3;
-    localparam [3:0] ST_STIM_DATA = 4'd4;
-    localparam [3:0] ST_STIM_COMMIT = 4'd5;
-    localparam [3:0] ST_FINAL_TX = 4'd6;
-    localparam [3:0] ST_DROP = 4'd7;
-    localparam [3:0] ST_SNAPSHOT_ACK_TX = 4'd8;
-    localparam [3:0] ST_SNAPSHOT_DATA_TX = 4'd9;
-    reg [3:0] state;
+    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_SNAPSHOT_WAIT = 10, ST_ACK_TX = 11,
+        ST_SNAPSHOT_DATA_TX = 12, ST_DROP = 13;
+
+    reg [4:0] state;
     reg [5:0] index;
-    reg stimulus_bad;
+    reg [7:0] ack_ok;
+    reg [7:0] ack_request;
+    reg [7:0] ack_status;
+    reg [7:0] ack_detail;
 
     assign frame_ready = (state == ST_IDLE) || (state == ST_DROP);
     assign frame_accept_enable = (state == ST_IDLE);
     assign busy = state != ST_IDLE;
 
+    task start_ack;
+        input [7:0] ok;
+        input [7:0] request_type;
+        input [7:0] status;
+        input [7:0] detail;
+        begin
+            ack_ok <= ok;
+            ack_request <= request_type;
+            ack_status <= status;
+            ack_detail <= detail;
+            tx_frame_type <= `FB_RSP_ACK_NACK;
+            tx_payload_length <= 8'd4;
+            tx_start <= 1'b1;
+            state <= ST_ACK_TX;
+        end
+    endtask
+
+    always @* begin
+        case (tx_payload_addr[1:0])
+            2'd0: ack_payload_data = ack_ok;
+            2'd1: ack_payload_data = ack_request;
+            2'd2: ack_payload_data = ack_status;
+            default: ack_payload_data = ack_detail;
+        endcase
+    end
+
     always @(posedge clk or negedge rst_n) begin
         if (!rst_n) begin
             state <= ST_IDLE;
             index <= 0;
-            stimulus_bad <= 0;
             payload_read_addr <= 0;
-            target_commit <= 0;
-            target_celsius <= 70;
-            stimulus_wr_en <= 0;
-            stimulus_wr_addr <= 0;
-            stimulus_wr_data <= 0;
-            stimulus_commit <= 0;
-            stimulus_duration_seconds <= 0;
+            manual_wr_en <= 0;
+            manual_wr_addr <= 0;
+            manual_wr_data <= 0;
+            manual_commit <= 0;
+            pid_target_commit <= 0;
+            pid_target_celsius <= `DEFAULT_PID_TARGET_C;
             snapshot_capture <= 0;
             tx_start <= 0;
-            tx_frame_type <= 0;
+            tx_frame_type <= `FB_RSP_ACK_NACK;
             tx_payload_length <= 0;
+            ack_ok <= 0;
+            ack_request <= 0;
+            ack_status <= 0;
+            ack_detail <= 0;
             transaction_done <= 0;
         end else begin
-            target_commit <= 0;
-            stimulus_wr_en <= 0;
-            stimulus_commit <= 0;
+            manual_wr_en <= 0;
+            manual_commit <= 0;
+            pid_target_commit <= 0;
             snapshot_capture <= 0;
             tx_start <= 0;
             transaction_done <= 0;
             case (state)
                 ST_IDLE: if (frame_valid) begin
-                    if (frame_type == 8'h01 && frame_length == 1) begin
-                        payload_read_addr <= 0;
-                        state <= ST_TARGET;
-                    end else if (frame_type == 8'h02 && frame_length == 0) begin
-                        snapshot_capture <= 1;
-                        state <= ST_SNAPSHOT_WAIT;
-                    end else if ((ENABLE_STIMULUS != 0) && frame_type == 8'h03 && frame_length == 33) begin
-                        payload_read_addr <= 0;
-                        index <= 0;
-                        stimulus_bad <= 0;
-                        state <= ST_STIM_DURATION;
+                    if (frame_type == `FB_CMD_SET_ALL) begin
+                        if (frame_length != 8'd32)
+                            start_ack(0, frame_type, `FB_STATUS_BAD_LENGTH, 8'd32);
+                        else if (safety_locked)
+                            start_ack(0, frame_type, `FB_STATUS_SAFETY_LOCKED, 0);
+                        else begin
+                            index <= 0;
+                            payload_read_addr <= 0;
+                            state <= ST_SET_VALIDATE;
+                        end
+                    end else if (frame_type == `FB_CMD_GET_SNAPSHOT) begin
+                        if (frame_length != 0)
+                            start_ack(0, frame_type, `FB_STATUS_BAD_LENGTH, 0);
+                        else begin
+                            snapshot_capture <= 1;
+                            state <= ST_SNAPSHOT_WAIT;
+                        end
+                    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
+                            start_ack(0, frame_type, `FB_STATUS_UNSUPPORTED, 0);
+                    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);
+                        else begin
+                            payload_read_addr <= 0;
+                            state <= ST_PID_READ;
+                        end
                     end else begin
-                        transaction_done <= 1;
-                        state <= ST_DROP;
+                        start_ack(0, frame_type, `FB_STATUS_UNSUPPORTED, 0);
                     end
                 end
-                ST_TARGET: begin
-                    if (payload_read_data == 0 || (payload_read_data >= 20 && payload_read_data <= 70)) begin
-                        target_celsius <= payload_read_data;
-                        target_commit <= 1;
-                        tx_frame_type <= 8'h81;
-                        tx_payload_length <= 0;
-                        tx_start <= 1;
-                        state <= ST_FINAL_TX;
+                ST_SET_VALIDATE: begin
+                    if (payload_read_data > 100) begin
+                        start_ack(0, `FB_CMD_SET_ALL, `FB_STATUS_BAD_VALUE, {2'd0, index});
+                    end else if (index == 31) begin
+                        index <= 0;
+                        payload_read_addr <= 0;
+                        state <= ST_SET_WRITE;
                     end else begin
-                        transaction_done <= 1;
-                        state <= ST_DROP;
+                        index <= index + 1'b1;
+                        payload_read_addr <= index + 1'b1;
                     end
                 end
-                ST_SNAPSHOT_WAIT: if (snapshot_ready) begin
-                    tx_frame_type <= 8'h82;
-                    tx_payload_length <= 0;
-                    tx_start <= 1;
-                    state <= ST_SNAPSHOT_ACK_TX;
-                end
-                ST_STIM_DURATION: begin
-                    stimulus_duration_seconds <= payload_read_data;
-                    if (payload_read_data == 0) stimulus_bad <= 1;
-                    index <= 1;
-                    payload_read_addr <= 1;
-                    state <= ST_STIM_DATA;
+                ST_SET_WRITE: begin
+                    manual_wr_en <= 1;
+                    manual_wr_addr <= index[4:0];
+                    manual_wr_data <= payload_read_data;
+                    if (index == 31) state <= ST_SET_COMMIT;
+                    else begin
+                        index <= index + 1'b1;
+                        payload_read_addr <= index + 1'b1;
+                    end
                 end
-                ST_STIM_DATA: begin
-                    if (payload_read_data > 100) begin
-                        stimulus_bad <= 1;
-                    end else begin
-                        stimulus_wr_en <= 1;
-                        stimulus_wr_addr <= index[4:0] - 1'b1;
-                        stimulus_wr_data <= payload_read_data;
+                ST_SET_COMMIT: begin
+                    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
-                    if (index == 32) begin
-                        state <= ST_STIM_COMMIT;
-                    end else begin
-                        index <= index + 1'b1;
-                        payload_read_addr <= {2'b00, index} + 1'b1;
+                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_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);
+                    else begin
+                        pid_target_celsius <= payload_read_data;
+                        pid_target_commit <= 1;
+                        start_ack(1, `FB_CMD_SET_PID_TARGET, `FB_STATUS_OK, 0);
                     end
                 end
-                ST_STIM_COMMIT: begin
-                    if (!stimulus_bad) begin
-                        stimulus_commit <= 1;
-                        tx_frame_type <= 8'h83;
-                        tx_payload_length <= 0;
+                ST_SNAPSHOT_WAIT: if (snapshot_ready)
+                    start_ack(1, `FB_CMD_GET_SNAPSHOT, `FB_STATUS_OK, 0);
+                ST_ACK_TX: if (tx_done) begin
+                    if (ack_ok != 0 && ack_request == `FB_CMD_GET_SNAPSHOT) begin
+                        tx_frame_type <= `FB_RSP_SNAPSHOT_DATA;
+                        tx_payload_length <= SNAPSHOT_LENGTH[7:0];
                         tx_start <= 1;
-                        state <= ST_FINAL_TX;
+                        state <= ST_SNAPSHOT_DATA_TX;
                     end else begin
                         transaction_done <= 1;
                         state <= ST_DROP;
                     end
                 end
-                ST_FINAL_TX: if (tx_done) begin
-                    transaction_done <= 1;
-                    state <= ST_DROP;
-                end
-                ST_SNAPSHOT_ACK_TX: if (tx_done) begin
-                    // GET keeps the selected Host port and snapshot banks
-                    // locked across two independent frames. DATA never
-                    // substitutes for this ACK.
-                    tx_frame_type <= 8'h42;
-                    tx_payload_length <= SNAPSHOT_LENGTH[7:0];
-                    tx_start <= 1;
-                    state <= ST_SNAPSHOT_DATA_TX;
-                end
                 ST_SNAPSHOT_DATA_TX: if (tx_done) begin
                     transaction_done <= 1;
                     state <= ST_DROP;
@@ -170,62 +206,4 @@ module thermal_host_command #(
             endcase
         end
     end
-
-`ifdef FORMAL
-    assign formal_state_o = state;
-    assign formal_index_o = index;
-    assign formal_stimulus_bad_o = stimulus_bad;
-
-    reg formal_past_valid;
-    initial formal_past_valid = 0;
-    always @(posedge clk) begin
-        formal_past_valid <= 1;
-        if (rst_n) begin
-            assert(state <= ST_SNAPSHOT_DATA_TX);
-            // P07: ACK exists only on the same atomic legal target commit.
-            if (tx_start && tx_frame_type == 8'h81) begin
-                assert(target_commit);
-                assert(tx_payload_length == 0);
-            end
-            if (target_commit) begin
-                assert(target_celsius == 0 || (target_celsius >= 20 && target_celsius <= 70));
-                assert(tx_start && tx_frame_type == 8'h81 && tx_payload_length == 0);
-                if (formal_past_valid && $past(rst_n))
-                    assert($past(state) == ST_TARGET);
-            end
-            if (tx_start && tx_frame_type == 8'h82) begin
-                assert(tx_payload_length == 0);
-                assert(state == ST_SNAPSHOT_ACK_TX);
-            end
-            if (tx_start && tx_frame_type == 8'h42) begin
-                assert(tx_payload_length == SNAPSHOT_LENGTH[7:0]);
-                assert(state == ST_SNAPSHOT_DATA_TX);
-            end
-            if (formal_past_valid && $past(rst_n) &&
-                $past(state) == ST_SNAPSHOT_ACK_TX && $past(tx_done)) begin
-                assert(tx_start);
-                assert(tx_frame_type == 8'h42);
-                assert(tx_payload_length == SNAPSHOT_LENGTH[7:0]);
-                assert(!transaction_done);
-            end
-            if (formal_past_valid && $past(rst_n) &&
-                $past(state) == ST_SNAPSHOT_DATA_TX && $past(tx_done)) begin
-                assert(transaction_done);
-            end
-            if (state == ST_SNAPSHOT_ACK_TX || state == ST_SNAPSHOT_DATA_TX)
-                assert(busy && !transaction_done);
-            if (formal_past_valid && $past(rst_n) &&
-                target_celsius != $past(target_celsius))
-                assert(target_commit);
-            if (ENABLE_STIMULUS == 0) begin
-                assert(state != ST_STIM_DURATION);
-                assert(state != ST_STIM_DATA);
-                assert(state != ST_STIM_COMMIT);
-                assert(!stimulus_wr_en);
-                assert(!stimulus_commit);
-            end
-            cover(target_commit && tx_start && tx_frame_type == 8'h81);
-        end
-    end
-`endif
 endmodule

+ 1 - 2
td/syn/prod2u_6400_front_back.tcl

@@ -36,10 +36,9 @@ analyze_src {src/acquisition/bmc_poll_engine.v}
 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/stimulus_atomic_bank.v}
+analyze_src {src/control/manual_set_all_bank.v}
 analyze_src {src/control/thermal_control_core.v}
 analyze_src {src/actuator/pwm_bitmap_engine.v}
-analyze_src {src/actuator/fan_boot_safety_controller.v}
 analyze_src {src/actuator/fan_board_output_adapter.v}
 analyze_src {src/telemetry/thermal_snapshot_mux.v}
 analyze_src {src/top/prod2u_6400_v1_top.v}

+ 1 - 1
td/syn/prod2u_6400_identification.tcl

@@ -37,10 +37,10 @@ analyze_src {src/acquisition/bmc_poll_engine.v}
 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_boot_safety_controller.v}
 analyze_src {src/actuator/fan_board_output_adapter.v}
 analyze_src {src/telemetry/thermal_snapshot_mux.v}
 analyze_src {src/top/prod2u_6400_v1_top.v}

+ 1 - 5
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;
@@ -123,7 +119,7 @@ module prod2u_6400_v1_cocotb_top #(
             target_commit_count_mon <= 0;
             host_response_count_mon <= 0;
         end else begin
-            if (u_dut.target_commit)
+            if (u_dut.manual_commit_done)
                 target_commit_count_mon <= target_commit_count_mon + 1'b1;
             if (u_dut.tx_start)
                 host_response_count_mon <= host_response_count_mon + 1'b1;

+ 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,
         )

+ 7 - 9
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 ("control", "identification", "host_protocol")
-    stimulus = {"control": 0, "identification": 1, "host_protocol": 0}
+    profiles = args.profiles or ("host_protocol",)
     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

+ 88 - 218
tests/cocotb/test_6400_v1_host_protocol_integration.py

@@ -1,239 +1,109 @@
-"""Randomized full-UART Host framing and resynchronization coverage."""
+"""Focused full-UART test for the destructive 6400 Host protocol migration."""
 
 from __future__ import annotations
 
-from dataclasses import dataclass
-import warnings
-
 import cocotb
 from cocotb.triggers import RisingEdge, Timer, with_timeout
-from hypothesis import HealthCheck, given, settings, strategies as st
-from hypothesis.errors import HypothesisSideeffectWarning
 
 from thermal_6400_uart import (
-    CLOCK_NS,
-    HOST_CLKS_PER_BIT,
-    SET_TARGET,
-    SET_TARGET_ACK,
-    clock_cycles,
-    crc16,
-    encode_frame,
-    receive_frame,
-    send_uart,
-    wait_for,
+    ACK_NACK, CLOCK_NS, GET_SNAPSHOT, HOST_CLKS_PER_BIT, SET_ALL,
+    SET_PID_TARGET, SET_STIMULUS, SNAPSHOT_DATA, clock_cycles, encode_frame,
+    receive_frame, send_uart, wait_for,
 )
 
 
-@dataclass(frozen=True)
-class FrameCase:
-    frame_type: int
-    declared_length: int
-    payload: bytes
-    good_crc: bool
-
-    @property
-    def accepted_target(self) -> int | None:
-        if not self.good_crc or self.frame_type != SET_TARGET or self.declared_length != 1:
-            return None
-        target = self.payload[0]
-        return target if target == 0 or 20 <= target <= 70 else None
-
-    def encode(self) -> bytes:
-        body = bytes((self.frame_type, self.declared_length)) + self.payload
-        checksum = crc16(body)
-        if not self.good_crc:
-            checksum ^= 0x0001
-        return b"\xA5\x5A" + body + checksum.to_bytes(2, "little")
-
-
-@st.composite
-def frame_cases(draw) -> FrameCase:
-    frame_type = draw(st.sampled_from((0x00, 0x01, 0x04, 0x7F, 0x80, 0x81, 0xFF)))
-    declared_length = draw(st.integers(min_value=0, max_value=255))
-    if declared_length <= 33:
-        payload = draw(st.binary(min_size=declared_length, max_size=declared_length))
-    else:
-        # RTL rejects the oversized declaration before consuming payload.  A
-        # bounded tail exercises recovery without letting an embedded header
-        # become a separate, accidental test case.
-        tail = draw(st.binary(min_size=0, max_size=12))
-        payload = tail.replace(b"\xA5", b"\xA4")
-    return FrameCase(frame_type, declared_length, payload, draw(st.booleans()))
-
-
-def generated_cases() -> list[FrameCase]:
-    values: list[FrameCase] = []
-
-    @settings(
-        max_examples=96,
-        derandomize=True,
-        database=None,
-        deadline=None,
-        suppress_health_check=(HealthCheck.too_slow,),
-    )
-    @given(frame_cases())
-    def collect(value: FrameCase) -> None:
-        values.append(value)
-
-    # Cocotb imports tests through its pytest plugin, then invokes this
-    # collector deliberately from the running coroutine.  Hypothesis warns
-    # about any strategy evaluation in plugin-owned code even though this is
-    # the test body and the database/storage are both isolated.
-    with warnings.catch_warnings():
-        warnings.simplefilter("ignore", HypothesisSideeffectWarning)
-        collect()
-    return values
-
-
-async def send_uart_with_period(signal, data: bytes, clocks_per_bit: int) -> None:
-    for value in data:
-        signal.value = 0
-        await Timer(clocks_per_bit * CLOCK_NS, units="ns")
-        for bit in range(8):
-            signal.value = (value >> bit) & 1
-            await Timer(clocks_per_bit * CLOCK_NS, units="ns")
-        signal.value = 1
-        await Timer(clocks_per_bit * CLOCK_NS, units="ns")
-
-
-async def send_uart_jittered(signal, data: bytes) -> None:
-    periods = (27, 26, 28, 27, 28, 26, 27, 26, 28, 27)
-    for value in data:
-        bits = (0, *((value >> bit) & 1 for bit in range(8)), 1)
-        for level, clocks in zip(bits, periods, strict=True):
-            signal.value = level
-            await Timer(clocks * CLOCK_NS, units="ns")
-
-
-async def wait_unlocked(dut) -> None:
-    await wait_for(
-        dut,
-        lambda: int(dut.host_locked_mon.value) == 0,
-        cycles=1800,
-        label="Host selector unlock",
-    )
-
-
-async def target_transaction(dut, target: int, sender=send_uart) -> None:
+async def transact(dut, kind: int, payload: bytes) -> tuple[int, bytes]:
     response = cocotb.start_soon(receive_frame(dut.host_rs232_tx))
-    frame = encode_frame(SET_TARGET, bytes((target,)))
-    if sender is send_uart:
-        await sender(dut.host_rs232_rx, frame, HOST_CLKS_PER_BIT)
-    else:
-        await sender(dut.host_rs232_rx, frame)
-    kind, payload = await with_timeout(response, 20, "ms")
-    assert (kind, payload) == (SET_TARGET_ACK, b"")
+    await send_uart(dut.host_rs232_rx, encode_frame(kind, payload), HOST_CLKS_PER_BIT)
+    result = await with_timeout(response, 25, "ms")
     await Timer(HOST_CLKS_PER_BIT * CLOCK_NS * 2, units="ns")
-    await wait_unlocked(dut)
-    assert int(dut.current_target_mon.value) == target
+    await wait_for(dut, lambda: int(dut.host_locked_mon.value) == 0, cycles=1500, label="unlock")
+    return result
+
+
+def ack(payload: bytes, ok: int, request: int, status: int, detail: int = 0) -> None:
+    assert payload == bytes((ok, request, status, detail))
 
 
 @cocotb.test()
-async def test_host_random_frames_timeout_resync_and_port_lock(dut):
+async def test_host_ack_nack_crc_silence_atomic_set_all_and_get_order(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
     await with_timeout(RisingEdge(dut.rst_n_mon), 1, "ms")
-    await clock_cycles(dut, 8)
-
-    # Hypothesis supplies arbitrary declared lengths, payloads, CRC validity,
-    # legal targets, illegal targets, and unknown types.  Every invalid case
-    # is a silent drop and must leave both the target and response counters
-    # unchanged; valid target frames commit exactly once and ACK exactly once.
-    for case in generated_cases():
-        commits_before = int(dut.target_commit_count_mon.value)
-        responses_before = int(dut.host_response_count_mon.value)
-        target_before = int(dut.current_target_mon.value)
-        accepted = case.accepted_target
-        if accepted is not None:
-            response = cocotb.start_soon(receive_frame(dut.host_rs232_tx))
-            await send_uart(dut.host_rs232_rx, case.encode(), HOST_CLKS_PER_BIT)
-            assert await with_timeout(response, 20, "ms") == (SET_TARGET_ACK, b"")
-            await Timer(HOST_CLKS_PER_BIT * CLOCK_NS * 2, units="ns")
-        else:
-            await send_uart(dut.host_rs232_rx, case.encode(), HOST_CLKS_PER_BIT)
-        await wait_unlocked(dut)
-        if accepted is None:
-            assert int(dut.target_commit_count_mon.value) == commits_before
-            assert int(dut.host_response_count_mon.value) == responses_before
-            assert int(dut.current_target_mon.value) == target_before
-        else:
-            assert int(dut.target_commit_count_mon.value) == commits_before + 1
-            assert int(dut.host_response_count_mon.value) == responses_before + 1
-            assert int(dut.current_target_mon.value) == accepted
-        assert int(dut.host_rs232_tx.value) == 1
-        assert int(dut.host_ttl_tx.value) == 1
-
-    # Noise and overlapping A5 candidates must resynchronize to the next full
-    # header without resetting the UART or parser.
-    response = cocotb.start_soon(receive_frame(dut.host_rs232_tx))
-    noisy = b"\x00\xFF\xA5\xA5\x00\xA5" + encode_frame(SET_TARGET, b"\x3E")
-    await send_uart(dut.host_rs232_rx, noisy, HOST_CLKS_PER_BIT)
-    assert await with_timeout(response, 20, "ms") == (SET_TARGET_ACK, b"")
-    await Timer(HOST_CLKS_PER_BIT * CLOCK_NS * 2, units="ns")
-    await wait_unlocked(dut)
-    assert int(dut.current_target_mon.value) == 62
-
-    # A half-frame is discarded after the accelerated test timeout; the next
-    # valid frame must not inherit its type, length, payload, or CRC state.
-    commits_before = int(dut.target_commit_count_mon.value)
-    responses_before = int(dut.host_response_count_mon.value)
-    await send_uart(dut.host_rs232_rx, b"\xA5\x5A\x01\x01", HOST_CLKS_PER_BIT)
+    await clock_cycles(dut, 40)
+
+    # Complete CRC-correct requests always get one unified response.
+    kind, payload = await transact(dut, SET_ALL, bytes(31))
+    assert kind == ACK_NACK; ack(payload, 0, SET_ALL, 2, 32)
+    kind, payload = await transact(dut, SET_STIMULUS, bytes((1,)) + bytes(32))
+    assert kind == ACK_NACK; ack(payload, 0, SET_STIMULUS, 1)
+    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
+    commits = int(dut.target_commit_count_mon.value)
+    kind, payload = await transact(dut, SET_ALL, bytes(bad))
+    assert kind == ACK_NACK; ack(payload, 0, SET_ALL, 3, 7)
+    assert int(dut.target_commit_count_mon.value) == commits
+    assert int(dut.control_state_mon.value) == 0
+
+    # Legal and identical SET_ALL both atomically commit/feed and ACK.
+    vector = bytes([50] * 24 + [0, 20, 50, 100, 0, 20, 50, 100])
+    for repeat in range(2):
+        before = int(dut.target_commit_count_mon.value)
+        kind, payload = await transact(dut, SET_ALL, vector)
+        assert kind == ACK_NACK; ack(payload, 1, SET_ALL, 0)
+        assert int(dut.target_commit_count_mon.value) == before + 1
+        assert int(dut.control_state_mon.value) == 1
+
+    # PID target ACKs but does not exit Manual or feed via a SET_ALL commit.
+    before = int(dut.target_commit_count_mon.value)
+    kind, payload = await transact(dut, SET_PID_TARGET, b"\x46")
+    assert kind == ACK_NACK; ack(payload, 1, SET_PID_TARGET, 0)
+    assert int(dut.current_target_mon.value) == 70
+    assert int(dut.control_state_mon.value) == 1
+    assert int(dut.target_commit_count_mon.value) == before
+
+    # GET locks one snapshot and produces exactly 06 then 82.
+    ack_task = cocotb.start_soon(receive_frame(dut.host_rs232_tx))
+    await send_uart(dut.host_rs232_rx, encode_frame(GET_SNAPSHOT), HOST_CLKS_PER_BIT)
+    kind, payload = await with_timeout(ack_task, 25, "ms")
+    assert kind == ACK_NACK; ack(payload, 1, GET_SNAPSHOT, 0)
+    assert int(dut.host_locked_mon.value) == 1
+    data_kind, data = await with_timeout(receive_frame(dut.host_rs232_tx), 25, "ms")
+    assert data_kind == SNAPSHOT_DATA and len(data) == 201
+    await wait_for(dut, lambda: int(dut.host_locked_mon.value) == 0, cycles=1500, label="GET unlock")
+
+    # CRC damage and partial timeout are silent; the next legal request resyncs.
+    responses = int(dut.host_response_count_mon.value)
+    damaged = bytearray(encode_frame(SET_PID_TARGET, b"\x41")); damaged[-1] ^= 1
+    await send_uart(dut.host_rs232_rx, damaged, HOST_CLKS_PER_BIT)
     await clock_cycles(dut, 1200)
-    await wait_unlocked(dut)
-    assert int(dut.target_commit_count_mon.value) == commits_before
-    assert int(dut.host_response_count_mon.value) == responses_before
-    await target_transaction(dut, 61)
-
-    # There is no command queue: a second complete frame arriving while the
-    # first physical ACK is active is dropped, and a later retransmission is
-    # accepted after the response boundary retires.
-    commits_before = int(dut.target_commit_count_mon.value)
-    responses_before = int(dut.host_response_count_mon.value)
-    response = cocotb.start_soon(receive_frame(dut.host_rs232_tx))
-    await send_uart(dut.host_rs232_rx, encode_frame(SET_TARGET, b"\x14"), HOST_CLKS_PER_BIT)
-    await send_uart(dut.host_rs232_rx, encode_frame(SET_TARGET, b"\x46"), HOST_CLKS_PER_BIT)
-    assert await with_timeout(response, 20, "ms") == (SET_TARGET_ACK, b"")
-    await Timer(HOST_CLKS_PER_BIT * CLOCK_NS * 2, units="ns")
-    await wait_unlocked(dut)
-    assert int(dut.target_commit_count_mon.value) == commits_before + 1
-    assert int(dut.host_response_count_mon.value) == responses_before + 1
-    assert int(dut.current_target_mon.value) == 20
-    await target_transaction(dut, 70)
-
-    # Simultaneous start bits deterministically select RS-232 for the entire
-    # request/response lock.  TTL traffic cannot splice payload or steal TX.
-    commits_before = int(dut.target_commit_count_mon.value)
-    response = cocotb.start_soon(receive_frame(dut.host_rs232_tx))
-    rs232 = cocotb.start_soon(
-        send_uart(dut.host_rs232_rx, encode_frame(SET_TARGET, b"\x3C"), HOST_CLKS_PER_BIT)
-    )
-    ttl = cocotb.start_soon(
-        send_uart(dut.host_ttl_rx, encode_frame(SET_TARGET, b"\x46"), HOST_CLKS_PER_BIT)
-    )
-    await rs232
-    await ttl
-    assert await with_timeout(response, 20, "ms") == (SET_TARGET_ACK, b"")
-    assert int(dut.host_ttl_tx.value) == 1
-    await Timer(HOST_CLKS_PER_BIT * CLOCK_NS * 2, units="ns")
-    await wait_unlocked(dut)
-    assert int(dut.target_commit_count_mon.value) == commits_before + 1
-    assert int(dut.current_target_mon.value) == 60
-
-    # Integrate the raw UART tolerance proof with a legal frame: fixed -1/+1
-    # clock baud error and balanced per-bit jitter must preserve framing/CRC.
-    await target_transaction(dut, 64, lambda signal, data: send_uart_with_period(signal, data, 26))
-    await target_transaction(dut, 63, lambda signal, data: send_uart_with_period(signal, data, 28))
-    await target_transaction(dut, 65, send_uart_jittered)
-
-    # A declared 255-byte unknown frame plus a long zero tail is discarded
-    # without a response, state mutation, or loss of the next valid command.
-    commits_before = int(dut.target_commit_count_mon.value)
-    responses_before = int(dut.host_response_count_mon.value)
-    long_invalid = b"\xA5\x5A\x7F\xFF" + bytes(260)
-    await send_uart(dut.host_rs232_rx, long_invalid, HOST_CLKS_PER_BIT)
-    await wait_unlocked(dut)
-    assert int(dut.target_commit_count_mon.value) == commits_before
-    assert int(dut.host_response_count_mon.value) == responses_before
-    await target_transaction(dut, 66)
+    assert int(dut.host_response_count_mon.value) == responses
+    await send_uart(dut.host_rs232_rx, b"\xA5\x5A\x04\x01", HOST_CLKS_PER_BIT)
+    await clock_cycles(dut, 1200)
+    assert int(dut.host_response_count_mon.value) == responses
+    kind, payload = await transact(dut, SET_PID_TARGET, b"\x41")
+    assert kind == ACK_NACK; ack(payload, 1, SET_PID_TARGET, 0)
+    assert int(dut.current_target_mon.value) == 65

+ 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

+ 68 - 47
tests/cocotb/test_6400_v1_soak.py

@@ -8,23 +8,20 @@ from pathlib import Path
 import random
 
 import cocotb
-from cocotb.triggers import RisingEdge, Timer
+from cocotb.triggers import RisingEdge, Timer, with_timeout
 
 from thermal_6400_uart import (
     BMC_CLKS_PER_BIT,
     CLOCK_NS,
     GET_SNAPSHOT,
     HOST_CLKS_PER_BIT,
-    SET_STIMULUS,
-    SET_STIMULUS_ACK,
-    SET_TARGET,
-    SET_TARGET_ACK,
-    bring_auto,
+    ACK_NACK,
+    SET_ALL,
+    SET_PID_TARGET,
     clock_cycles,
     encode_frame,
     get_snapshot,
     host_transaction,
-    initialize,
     pulse_tick_1s,
     send_bmc_snapshot,
     send_uart,
@@ -60,12 +57,24 @@ async def wait_host_idle(dut) -> None:
     )
 
 
-async def set_target(dut, port: str, target: int) -> None:
+async def initialize_current(dut) -> None:
+    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.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
+
+
+async def set_pid_target(dut, port: str, target: int) -> None:
     try:
-        kind, payload = await host_transaction(dut, port, SET_TARGET, bytes([target]))
+        kind, payload = await host_transaction(dut, port, SET_PID_TARGET, bytes([target]))
     except BaseException:
         cocotb.log.error(
-            "SET_TARGET_TIMEOUT port=%s target=%d locked=%d selected=%d "
+            "SET_PID_TARGET_TIMEOUT port=%s target=%d locked=%d selected=%d "
             "rx_valid=%d rx_error=%d frame_valid=%d frame_ready=%d command_busy=%d "
             "target_commits=%d responses=%d",
             port,
@@ -81,7 +90,12 @@ async def set_target(dut, port: str, target: int) -> None:
             int(dut.host_response_count_mon.value),
         )
         raise
-    assert (kind, payload) == (SET_TARGET_ACK, b"")
+    assert (kind, payload) == (ACK_NACK, bytes((1, SET_PID_TARGET, 0, 0)))
+
+
+async def set_all(dut, port: str, vector: bytes) -> None:
+    kind, payload = await host_transaction(dut, port, SET_ALL, vector)
+    assert (kind, payload) == (ACK_NACK, bytes((1, SET_ALL, 0, 0)))
 
 
 async def send_noise(dut, rng: random.Random) -> None:
@@ -90,7 +104,7 @@ async def send_noise(dut, rng: random.Random) -> None:
     before_response = int(dut.host_response_count_mon.value)
     # A bad-CRC target-shaped frame plus arbitrary bytes must not commit or
     # produce a response. Let the bounded idle unlock recover the selected port.
-    corrupt = bytearray(encode_frame(SET_TARGET, bytes([rng.randint(55, 75)])))
+    corrupt = bytearray(encode_frame(SET_PID_TARGET, bytes([rng.randint(55, 70)])))
     corrupt[-1] ^= 0x80
     port = "rs232" if rng.randrange(2) == 0 else "ttl"
     await send_uart(getattr(dut, f"host_{port}_rx"), corrupt, HOST_CLKS_PER_BIT)
@@ -105,28 +119,35 @@ async def recover_safe(dut) -> None:
     for _ in range(4):
         previous = int(dut.control_epoch_mon.value)
         await send_bmc_snapshot(dut, [60] * 24)
-        if int(dut.control_state_mon.value) in (4, 5):
+        if int(dut.control_state_mon.value) == 2:
             await wait_control_epoch(dut, previous, "soak 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,
+        and int(dut.control_state_mon.value) == 2,
         cycles=1600,
-        label="soak recovery AUTO",
+        label="soak recovery PID",
     )
 
 
 async def validate_snapshot(dut, port: str, counters: dict[str, int]) -> dict[str, object]:
     await wait_host_idle(dut)
     snapshot = await get_snapshot(dut, port)
-    assert snapshot["control_state"] in range(7)
+    assert snapshot["mode"] in range(3)
     for name in ("ptc_requested", "ptc_applied", "front_requested", "front_applied", "rear_requested", "rear_applied"):
         assert all(0 <= value <= 100 for value in values(snapshot, name))
-    if snapshot["global_fault"]:
+    lane_faults = int(snapshot["lane_fault_mask"])
+    if lane_faults:
+        for lane in range(4):
+            if lane_faults & (1 << lane):
+                assert values(snapshot, "ptc_applied")[lane * 6 : lane * 6 + 6] == [0] * 6
+                assert values(snapshot, "front_applied")[lane] == 100
+                assert values(snapshot, "rear_applied")[lane] == 100
+    elif snapshot["global_fault"]:
         assert values(snapshot, "ptc_applied") == [0] * 24
-        assert values(snapshot, "front_applied") == [100] * 4
-        assert values(snapshot, "rear_applied") == [100] * 4
+        assert values(snapshot, "front_applied") == [20] * 4
+        assert values(snapshot, "rear_applied") == [20] * 4
     assert int(dut.pwm_deadline_miss_mon.value) == 0
     counters["get_snapshot"] += 1
     return snapshot
@@ -140,9 +161,9 @@ async def test_accelerated_randomized_system_soak(dut):
         "invalid": 0,
         "stale": 0,
         "get_snapshot": 0,
-        "set_target": 0,
+        "set_pid_target": 0,
         "repeated_set": 0,
-        "stimulus": 0,
+        "set_all": 0,
         "recovery": 0,
         "epoch_wrap": 0,
         "uart_noise": 0,
@@ -153,9 +174,14 @@ async def test_accelerated_randomized_system_soak(dut):
     }
     dut.reset_test.value = 0
     previous_state = 0
-    await bring_auto(dut)
+    await initialize_current(dut)
+    await pulse_tick_1s(dut, 30)
+    await wait_for(dut, lambda: int(dut.control_state_mon.value) == 2,
+                   cycles=2400, label="SAFE watchdog atomic handoff to PID")
+    for _ in range(4):
+        await send_bmc_snapshot(dut, [60] * 24)
 
-    # The soak-only wrapper starts at 0xfffa, so bring_auto's four real BMC
+    # The soak-only wrapper starts at 0xfffa, so the first four real BMC
     # frames leave the active epoch at 0xfffe. Two more frames cross the wrap.
     assert int(dut.bmc_epoch_mon.value) == 0xFFFE
     await send_bmc_snapshot(dut, [60] * 24)
@@ -185,14 +211,12 @@ async def test_accelerated_randomized_system_soak(dut):
             counters["bmc_random"] += 1
         elif action == 1:
             port = "rs232" if iteration & 1 else "ttl"
-            # SET_TARGET accepts only 0 or 20..70. Keep this positive path
-            # entirely legal; invalid-target silent drops are covered by L4.
             target = rng.choice((58, 63, 67, 70))
             await wait_host_idle(dut)
-            await set_target(dut, port, target)
+            await set_pid_target(dut, port, target)
             await wait_host_idle(dut)
-            await set_target(dut, port, target)
-            counters["set_target"] += 2
+            await set_pid_target(dut, port, target)
+            counters["set_pid_target"] += 2
             counters["repeated_set"] += 1
             await recover_safe(dut)
             counters["recovery"] += 1
@@ -209,21 +233,17 @@ async def test_accelerated_randomized_system_soak(dut):
             await validate_snapshot(dut, "ttl" if iteration & 1 else "rs232", counters)
         elif action == 4:
             ptc = [rng.randint(0, 45) for _ in range(24)]
-            front = [rng.randint(20, 70) for _ in range(4)]
-            rear = [rng.randint(20, 70) for _ in range(4)]
-            duration = rng.randint(1, 3)
+            front = [rng.randint(0, 100) for _ in range(4)]
+            rear = [rng.randint(0, 100) for _ in range(4)]
+            vector = bytes([*ptc, *front, *rear])
             await wait_host_idle(dut)
-            kind, payload = await host_transaction(
-                dut, "rs232", SET_STIMULUS, bytes([duration, *ptc, *front, *rear])
-            )
-            assert (kind, payload) == (SET_STIMULUS_ACK, b"")
-            previous = int(dut.control_epoch_mon.value)
-            await send_bmc_snapshot(dut, [60] * 24)
-            await wait_control_epoch(dut, previous, "stimulus commit")
-            await pulse_tick_1s(dut, duration)
-            counters["virtual_seconds"] += duration
-            assert int(dut.stimulus_active_mon.value) == 0
-            counters["stimulus"] += 1
+            await set_all(dut, "rs232", vector)
+            assert int(dut.control_state_mon.value) == 1
+            snap = await validate_snapshot(dut, "ttl", counters)
+            assert values(snap, "ptc_requested") == ptc
+            assert values(snap, "front_requested") == front
+            assert values(snap, "rear_requested") == rear
+            counters["set_all"] += 1
         elif action == 5:
             await send_noise(dut, rng)
             counters["uart_noise"] += 1
@@ -248,10 +268,11 @@ async def test_accelerated_randomized_system_soak(dut):
                 dut.reset_test.value = 1
                 await clock_cycles(dut, 4)
                 dut.reset_test.value = 0
-                await initialize(dut)
+                await initialize_current(dut)
+                await pulse_tick_1s(dut, 30)
                 for _ in range(4):
                     await send_bmc_snapshot(dut, [60] * 24)
-                await wait_for(dut, lambda: int(dut.control_state_mon.value) == 4, cycles=1200, label="AUTO after reset")
+                await wait_for(dut, lambda: int(dut.control_state_mon.value) == 2, cycles=2400, label="PID after reset")
                 counters["reset"] += 1
             else:
                 await validate_snapshot(dut, "rs232", counters)
@@ -260,14 +281,14 @@ async def test_accelerated_randomized_system_soak(dut):
         if state != previous_state:
             counters["state_transitions"] += 1
             previous_state = state
-        assert state in range(7)
+        assert state in range(3)
         assert int(dut.pwm_deadline_miss_mon.value) == 0
 
     final_snapshot = await validate_snapshot(dut, "ttl", counters)
     assert final_snapshot["control_epoch"] >= 1
     required_nonzero = (
-        "bmc_random", "invalid", "stale", "get_snapshot", "set_target",
-        "repeated_set", "stimulus", "recovery", "epoch_wrap", "uart_noise",
+        "bmc_random", "invalid", "stale", "get_snapshot", "set_pid_target",
+        "repeated_set", "set_all", "recovery", "epoch_wrap", "uart_noise",
         "reset", "hard_limit", "state_transitions", "virtual_seconds",
     )
     assert all(counters[name] > 0 for name in required_nonzero), counters

+ 6 - 6
tests/cocotb/thermal_6400_uart.py

@@ -14,13 +14,12 @@ ROOT = Path(__file__).resolve().parents[2]
 HOST_CLKS_PER_BIT = 27
 BMC_CLKS_PER_BIT = 217
 CLOCK_NS = 40
-SET_TARGET = 0x01
+SET_ALL = 0x01
 GET_SNAPSHOT = 0x02
 SET_STIMULUS = 0x03
-SET_TARGET_ACK = 0x81
-GET_SNAPSHOT_ACK = 0x82
-SNAPSHOT_DATA = 0x42
-SET_STIMULUS_ACK = 0x83
+SET_PID_TARGET = 0x04
+ACK_NACK = 0x06
+SNAPSHOT_DATA = 0x82
 
 _LAYOUT = json.loads(
     (ROOT / "generated/6400/snapshot-layout.json").read_text(encoding="utf-8")
@@ -284,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

+ 172 - 37
tests/formal/6400-properties.json

@@ -1,42 +1,177 @@
 {
-  "schema": "prod2u-6400-formal-properties-v1",
-  "required_solvers": ["boolector", "z3"],
+  "schema": "prod2u-6400-formal-properties-v2",
+  "product": "6400-front-rear",
+  "phase": "long-affected",
+  "required_solvers": ["per-target-solver-map"],
   "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
+    },
+    {
+      "name": "core_owner",
+      "sby": "6400_core_owner_properties.sby",
+      "tasks": ["boolector"],
+      "mode": "prove",
+      "depth": 90
+    },
+    {
+      "name": "core_transitions",
+      "sby": "6400_core_transition_properties.sby",
+      "tasks": ["boolector"],
+      "mode": "bmc",
+      "depth": 90
+    },
+    {
+      "name": "snapshot_lock",
+      "sby": "6400_snapshot_properties.sby",
+      "tasks": ["boolector"],
+      "mode": "prove",
+      "depth": 4
+    },
+    {
+      "name": "bmc_bank",
+      "sby": "6400_bmc_bank_properties.sby",
+      "tasks": ["boolector"],
+      "mode": "prove",
+      "depth": 8
+    },
+    {
+      "name": "reset_pwm",
+      "sby": "6400_pwm_properties.sby",
+      "tasks": ["boolector", "z3"],
+      "mode": "prove",
+      "depth": 12
+    },
+    {
+      "name": "host_command_short",
+      "sby": "6400_host_command_properties.sby",
+      "tasks": ["boolector", "z3"],
+      "mode": "bmc",
+      "depth": 16
+    },
+    {
+      "name": "set_all_commit",
+      "sby": "6400_set_all_commit_properties.sby",
+      "tasks": ["boolector", "z3"],
+      "mode": "bmc",
+      "depth": 76
+    },
+    {
+      "name": "frame_rx_crc",
+      "sby": "6400_frame_rx_properties.sby",
+      "tasks": ["boolector", "z3"],
+      "mode": "prove",
+      "depth": 24
+    },
+    {
+      "name": "snapshot_transport",
+      "sby": "6400_snapshot_transport_properties.sby",
+      "tasks": ["boolector"],
+      "mode": "bmc",
+      "depth": 48
+    }
   ],
+  "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"
+    },
+    {
+      "id": "LF01",
+      "requirement": "Owner is always SAFE, MANUAL, or PID and watchdog activity matches ownership",
+      "harness": "6400_core_owner_properties.sby"
+    },
+    {
+      "id": "LF02",
+      "requirement": "Successful manual commit ACK state is atomic with MANUAL owner, watchdog reload, and output bank commit",
+      "harness": "6400_core_owner_properties.sby"
+    },
+    {
+      "id": "LF03",
+      "requirement": "Every output commit flips exactly one bank and increments control epoch",
+      "harness": "6400_core_owner_properties.sby"
+    },
+    {
+      "id": "LF04",
+      "requirement": "Snapshot bank and epoch lock remain stable until explicit unlock",
+      "harness": "6400_snapshot_properties.sby"
+    },
+    {
+      "id": "LF05",
+      "requirement": "BMC snapshot publication is bank-atomic and epoch-bound",
+      "harness": "6400_bmc_bank_properties.sby"
+    },
+    {
+      "id": "LF06",
+      "requirement": "Control reset keeps PTC zero and connector fans at exactly 20 percent while the carrier advances",
+      "harness": "6400_pwm_properties.sby"
+    },
+    {
+      "id": "LF07",
+      "requirement": "Unknown and oversized complete requests produce unified UNSUPPORTED or BAD_LENGTH ACK_NACK",
+      "harness": "6400_host_command_properties.sby"
+    },
+    {
+      "id": "LF08",
+      "requirement": "GET emits ACK before SNAPSHOT_DATA and completes only after both transmissions",
+      "harness": "6400_host_command_properties.sby"
+    },
+    {
+      "id": "LF09",
+      "requirement": "Legal SET_ALL performs validation and writes before commit and starts OK ACK only after commit completion",
+      "harness": "6400_set_all_commit_properties.sby"
+    },
+    {
+      "id": "LF10",
+      "requirement": "SET_ALL acceptance dominates the simultaneous final watchdog tick",
+      "harness": "6400_core_transition_properties.sby"
+    },
+    {
+      "id": "LF11",
+      "requirement": "MANUAL remains available without BMC and persistent PID stale commits safe output once",
+      "harness": "6400_core_transition_properties.sby"
+    },
+    {
+      "id": "LF12",
+      "requirement": "PI state writes are epoch-gated and frozen outside init safe-clear or PID update",
+      "harness": "6400_core_transition_properties.sby"
+    },
+    {
+      "id": "LF13",
+      "requirement": "A new hard lock cancels an in-flight Manual commit before output apply",
+      "harness": "6400_core_transition_properties.sby"
+    },
+    {
+      "id": "LF14",
+      "requirement": "A hard lane releases only on a complete valid cool epoch after its release counter qualifies",
+      "harness": "6400_core_transition_properties.sby"
+    },
+    {
+      "id": "LF15",
+      "requirement": "Wrong CRC cannot produce a command-visible frame",
+      "harness": "6400_frame_rx_properties.sby"
+    },
+    {
+      "id": "LF16",
+      "requirement": "A complete oversized frame remains bounded by the streaming receive cursor",
+      "harness": "6400_frame_rx_properties.sby"
+    },
+    {
+      "id": "LF17",
+      "requirement": "GET keeps snapshot and selected Host port locked through ACK and DATA completion",
+      "harness": "6400_snapshot_transport_properties.sby"
+    },
+    {
+      "id": "LF18",
+      "requirement": "GET transaction_done occurs only after SNAPSHOT_DATA tx_done",
+      "harness": "6400_snapshot_transport_properties.sby"
+    }
+  ],
+  "deferred_long_targets": []
 }

+ 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

+ 24 - 0
tests/formal/6400_core_owner_properties.sby

@@ -0,0 +1,24 @@
+[tasks]
+boolector
+z3
+
+[options]
+mode prove
+depth 90
+
+[engines]
+boolector: smtbmc boolector
+z3: smtbmc z3 -- --noincr
+
+[script]
+read_verilog -formal -D FORMAL -I. ef2_bram_dp.v manual_set_all_bank.v thermal_output_banks.v thermal_control_core.v
+read_verilog -formal -I. 6400_core_owner_properties_formal.v
+prep -top thermal_6400_core_owner_properties_formal
+
+[files]
+../../src/common/ef2_bram_dp.v
+../../src/control/manual_set_all_bank.v
+../../src/control/thermal_output_banks.v
+../../src/control/thermal_control_core.v
+generated/6400/prod2u_6400_v1_params.vh ../../generated/6400/prod2u_6400_v1_params.vh
+6400_core_owner_properties_formal.v

+ 152 - 0
tests/formal/6400_core_owner_properties_formal.v

@@ -0,0 +1,152 @@
+`include "generated/6400/prod2u_6400_v1_params.vh"
+
+module thermal_6400_core_owner_properties_formal(input wire clk);
+    reg rst_n = 0;
+    reg [1:0] reset_count = 0;
+    reg formal_past_valid = 0;
+    (* anyseq *) reg tick_1s;
+    (* anyseq *) reg manual_wr_en;
+    (* anyseq *) reg [4:0] manual_wr_addr;
+    (* anyseq *) reg [7:0] manual_wr_data;
+    (* anyseq *) reg manual_commit;
+    (* anyseq *) reg pid_target_commit;
+    (* anyseq *) reg [7:0] pid_target_celsius;
+    (* anyseq *) reg [15:0] bmc_epoch;
+    (* anyseq *) reg bmc_stale;
+    (* anyseq *) reg [23:0] bmc_valid_mask;
+    (* anyseq *) reg [15:0] bmc_rd_raw;
+    (* anyseq *) reg bmc_rd_valid;
+    (* anyseq *) reg snapshot_lock;
+
+    wire manual_commit_done, manual_commit_ok;
+    wire [4:0] bmc_rd_index;
+    wire [7:0] pwm_rd_data, snapshot_requested_data, snapshot_applied_data;
+    wire active_output_bank;
+    wire [2:0] control_state;
+    wire [7:0] current_target_celsius;
+    wire [15:0] control_epoch;
+    wire [23:0] safety_override_mask;
+    wire [3:0] lane_fault_mask;
+    wire global_fault, output_commit, watchdog_active, pid_running;
+    wire manual_mode, hard_protect, boot_init_complete;
+    wire [7:0] watchdog_remaining;
+    wire [3:0] formal_work_state;
+    wire [1:0] formal_commit_kind;
+    wire formal_manual_commit_applied, formal_manual_pending, formal_safe_pending;
+    wire formal_stale_hold_committed, formal_pi_state_write;
+    wire formal_complete_valid_bmc;
+    wire [3:0] formal_epoch_above_release_mask;
+
+    thermal_control_core #(.WATCHDOG_TICKS_OVERRIDE(3)) dut (
+        .clk(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_ok(manual_commit_ok),
+        .pid_target_commit(pid_target_commit), .pid_target_celsius(pid_target_celsius),
+        .bmc_epoch(bmc_epoch), .bmc_stale(bmc_stale), .bmc_valid_mask(bmc_valid_mask),
+        .bmc_rd_index(bmc_rd_index), .bmc_rd_raw(bmc_rd_raw), .bmc_rd_valid(bmc_rd_valid),
+        .ct_epoch(16'd0), .ct_stale(1'b1), .ct_valid_mask(27'd0),
+        .snapshot_lock(snapshot_lock), .snapshot_lock_bank(1'b0),
+        .pwm_rd_addr(5'd0), .pwm_rd_data(pwm_rd_data),
+        .snapshot_output_bank(1'b0), .snapshot_rd_addr(5'd0),
+        .snapshot_requested_data(snapshot_requested_data),
+        .snapshot_applied_data(snapshot_applied_data),
+        .active_output_bank(active_output_bank), .control_state(control_state),
+        .current_target_celsius(current_target_celsius), .control_epoch(control_epoch),
+        .safety_override_mask(safety_override_mask), .lane_fault_mask(lane_fault_mask),
+        .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(1'b1), .pwm_scan_idle(1'b1),
+        .boot_init_complete(boot_init_complete),
+        .formal_work_state_o(formal_work_state),
+        .formal_commit_kind_o(formal_commit_kind),
+        .formal_manual_commit_applied_o(formal_manual_commit_applied),
+        .formal_manual_pending_o(formal_manual_pending),
+        .formal_safe_pending_o(formal_safe_pending),
+        .formal_stale_hold_committed_o(formal_stale_hold_committed),
+        .formal_pi_state_write_o(formal_pi_state_write),
+        .formal_complete_valid_bmc_o(formal_complete_valid_bmc),
+        .formal_epoch_above_release_mask_o(formal_epoch_above_release_mask)
+    );
+
+    always @(posedge clk) begin
+        formal_past_valid <= 1;
+        if (reset_count < 2) begin
+            rst_n <= 0;
+            reset_count <= reset_count + 1'b1;
+        end else rst_n <= 1;
+
+        assume(manual_wr_addr < 32);
+        assume(manual_wr_data <= 100);
+        if (pid_target_commit) assume(pid_target_celsius >= 20 && pid_target_celsius <= 70);
+        if (!boot_init_complete) begin
+            assume(!manual_commit);
+            assume(!tick_1s);
+        end
+
+        if (rst_n) begin
+            assert(control_state == `FB_OWNER_SAFE ||
+                   control_state == `FB_OWNER_MANUAL || control_state == `FB_OWNER_PID);
+            assert(watchdog_active == (control_state != `FB_OWNER_PID));
+            assert(manual_mode == (control_state == `FB_OWNER_MANUAL));
+            assert(hard_protect == (|lane_fault_mask));
+            assert(current_target_celsius >= 20 && current_target_celsius <= 70);
+            if (manual_commit_done && manual_commit_ok) begin
+                assert(output_commit);
+                assert(control_state == `FB_OWNER_MANUAL);
+                assert(watchdog_remaining == 3);
+                assert(!hard_protect);
+            end
+            if (manual_commit_done && !manual_commit_ok)
+                assert(!output_commit);
+            if (output_commit) begin
+                assert(active_output_bank != $past(active_output_bank));
+                assert(control_epoch == $past(control_epoch) + 1'b1);
+            end
+`ifdef FORMAL_LONG_TRANSITIONS
+            if (formal_past_valid && $past(rst_n)) begin
+                // SET_ALL staging suppresses a simultaneous final timeout, but
+                // does not feed the watchdog before the safe output commit.
+                if ($past(formal_manual_commit_applied && tick_1s &&
+                          watchdog_remaining == 1)) begin
+                    assert(watchdog_remaining == 1 ||
+                           (watchdog_remaining == 3 && manual_commit_done &&
+                            manual_commit_ok && output_commit));
+                end
+                // Persistent PID stale hold cannot churn the output bank/epoch.
+                if ($past(control_state == `FB_OWNER_PID && bmc_stale &&
+                          formal_stale_hold_committed && formal_work_state == 1)) begin
+                    assert(!output_commit);
+                    assert(control_epoch == $past(control_epoch));
+                    assert(active_output_bank == $past(active_output_bank));
+                end
+                // MANUAL is not displaced merely because BMC is stale.
+                if ($past(control_state == `FB_OWNER_MANUAL && bmc_stale &&
+                          !tick_1s && !formal_safe_pending && !formal_manual_pending &&
+                          formal_work_state == 1))
+                    assert(control_state == `FB_OWNER_MANUAL);
+                // PI BRAM writes occur only in init/safe-clear/PID-update states.
+                if (formal_pi_state_write)
+                    assert($past(formal_work_state) == 0 ||
+                           $past(formal_work_state) == 4 ||
+                           $past(formal_work_state) == 8);
+                // A hard lock at the final Manual boundary cancels the vector.
+                if ($past(formal_work_state == 9 && formal_commit_kind == 1 &&
+                          hard_protect)) begin
+                    assert(manual_commit_done);
+                    assert(!manual_commit_ok);
+                    assert(!output_commit);
+                    assert(control_state != `FB_OWNER_MANUAL);
+                end
+                // A lane latch may clear only after the third complete cool epoch.
+                if (($past(lane_fault_mask) & ~lane_fault_mask) != 0) begin
+                    assert($past(formal_complete_valid_bmc));
+                    assert(($past(formal_epoch_above_release_mask) &
+                            ($past(lane_fault_mask) & ~lane_fault_mask)) == 0);
+                end
+            end
+`endif
+        end
+    end
+endmodule

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

@@ -0,0 +1,22 @@
+[tasks]
+boolector
+
+[options]
+mode bmc
+depth 90
+
+[engines]
+boolector: smtbmc boolector
+
+[script]
+read_verilog -formal -D FORMAL -D FORMAL_LONG_TRANSITIONS -I. ef2_bram_dp.v manual_set_all_bank.v thermal_output_banks.v thermal_control_core.v
+read_verilog -formal -D FORMAL_LONG_TRANSITIONS -I. 6400_core_owner_properties_formal.v
+prep -top thermal_6400_core_owner_properties_formal
+
+[files]
+../../src/common/ef2_bram_dp.v
+../../src/control/manual_set_all_bank.v
+../../src/control/thermal_output_banks.v
+../../src/control/thermal_control_core.v
+generated/6400/prod2u_6400_v1_params.vh ../../generated/6400/prod2u_6400_v1_params.vh
+6400_core_owner_properties_formal.v

+ 21 - 0
tests/formal/6400_frame_rx_properties.sby

@@ -0,0 +1,21 @@
+[tasks]
+boolector
+z3
+
+[options]
+mode prove
+depth 24
+
+[engines]
+boolector: smtbmc boolector
+z3: smtbmc z3 -- --noincr
+
+[script]
+read_verilog -formal -D FORMAL crc16_serial.v frame_rx.v
+read_verilog -formal 6400_frame_rx_properties_formal.v
+prep -top thermal_6400_frame_rx_properties_formal
+
+[files]
+../../src/common/crc16_serial.v
+../../src/common/frame_rx.v
+6400_frame_rx_properties_formal.v

+ 45 - 0
tests/formal/6400_frame_rx_properties_formal.v

@@ -0,0 +1,45 @@
+module thermal_6400_frame_rx_properties_formal(input wire clk);
+    reg rst_n = 0;
+    reg [1:0] reset_count = 0;
+    (* anyseq *) reg byte_valid;
+    (* anyseq *) reg [7:0] byte_data;
+    (* anyseq *) reg accept_enable;
+    (* anyseq *) reg frame_ready;
+    (* anyseq *) reg crc_busy;
+    (* anyseq *) reg crc_data_done;
+    (* anyseq *) reg [15:0] crc_value;
+    wire frame_valid;
+    wire [7:0] frame_type, frame_length;
+    wire payload_wr_en;
+    wire [7:0] payload_wr_addr, payload_wr_data;
+    wire crc_start, crc_data_valid;
+    wire [7:0] crc_data;
+    wire crc_accepted, bad_crc_event;
+
+    frame_rx #(.MAX_PAYLOAD(32), .INTER_BYTE_TIMEOUT_CYCLES(4),
+               .EXTERNAL_CRC(1)) dut (
+        .clk(clk), .rst_n(rst_n), .byte_valid(byte_valid), .byte_data(byte_data),
+        .accept_enable(accept_enable), .frame_valid(frame_valid),
+        .frame_ready(frame_ready), .frame_type(frame_type),
+        .frame_length(frame_length), .payload_read_addr(8'd0),
+        .payload_read_data(8'd0), .payload_wr_en(payload_wr_en),
+        .payload_wr_addr(payload_wr_addr), .payload_wr_data(payload_wr_data),
+        .crc_start_o(crc_start), .crc_data_valid_o(crc_data_valid),
+        .crc_data_o(crc_data), .crc_busy_i(crc_busy),
+        .crc_data_done_i(crc_data_done), .crc_value_i(crc_value),
+        .formal_crc_accepted_o(crc_accepted),
+        .formal_bad_crc_event_o(bad_crc_event)
+    );
+
+    always @(posedge clk) begin
+        if (reset_count < 2) begin
+            rst_n <= 0;
+            reset_count <= reset_count + 1'b1;
+        end else rst_n <= 1;
+        if (rst_n) begin
+            assert(!frame_valid || crc_accepted);
+            if ($past(rst_n && bad_crc_event))
+                assert(!frame_valid);
+        end
+    end
+endmodule

+ 21 - 0
tests/formal/6400_host_command_properties.sby

@@ -0,0 +1,21 @@
+[tasks]
+boolector
+z3
+
+[options]
+mode bmc
+depth 16
+
+[engines]
+boolector: smtbmc boolector
+z3: smtbmc z3 -- --noincr
+
+[script]
+read_verilog -formal -I. thermal_host_command.v
+read_verilog -formal -I. 6400_host_command_properties_formal.v
+prep -top thermal_6400_host_command_properties_formal
+
+[files]
+../../src/transport/thermal_host_command.v
+generated/6400/prod2u_6400_v1_params.vh ../../generated/6400/prod2u_6400_v1_params.vh
+6400_host_command_properties_formal.v

+ 102 - 0
tests/formal/6400_host_command_properties_formal.v

@@ -0,0 +1,102 @@
+`include "generated/6400/prod2u_6400_v1_params.vh"
+
+module thermal_6400_host_command_properties_formal(input wire clk);
+    reg rst_n = 0;
+    reg [1:0] reset_count = 0;
+    (* anyseq *) reg frame_valid;
+    (* anyconst *) reg [7:0] request_type;
+    (* anyconst *) reg [7:0] request_length;
+    (* anyconst *) reg [7:0] payload_value;
+    (* anyseq *) reg safety_locked;
+    (* anyseq *) reg manual_commit_done;
+    (* anyseq *) reg manual_commit_ok;
+    (* anyseq *) reg snapshot_ready;
+    (* anyseq *) reg tx_done;
+
+    wire frame_ready, frame_accept_enable;
+    wire [7:0] payload_read_addr;
+    wire manual_wr_en, manual_commit, pid_target_commit, snapshot_capture;
+    wire [4:0] manual_wr_addr;
+    wire [7:0] manual_wr_data, pid_target_celsius;
+    wire tx_start;
+    wire [7:0] tx_frame_type, tx_payload_length, ack_status;
+    wire transaction_done, busy;
+
+    thermal_host_command dut (
+        .clk(clk), .rst_n(rst_n), .frame_valid(frame_valid),
+        .frame_ready(frame_ready), .frame_accept_enable(frame_accept_enable),
+        .frame_type(request_type), .frame_length(request_length),
+        .payload_read_addr(payload_read_addr), .payload_read_data(payload_value),
+        .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_ok(manual_commit_ok),
+        .safety_locked(safety_locked), .pid_target_commit(pid_target_commit),
+        .pid_target_celsius(pid_target_celsius), .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(8'd2), .ack_payload_data(ack_status), .tx_done(tx_done),
+        .transaction_done(transaction_done), .busy(busy)
+    );
+
+    reg sent = 0;
+    reg saw_manual_commit = 0;
+    reg saw_ack = 0;
+    reg saw_get_ack = 0;
+    reg saw_data = 0;
+
+    wire known = request_type == `FB_CMD_SET_ALL ||
+        request_type == `FB_CMD_GET_SNAPSHOT ||
+        request_type == `FB_CMD_SET_STIMULUS ||
+        request_type == `FB_CMD_SET_PID_TARGET;
+    wire bad_length =
+        (request_type == `FB_CMD_SET_ALL && request_length != 32) ||
+        (request_type == `FB_CMD_GET_SNAPSHOT && request_length != 0) ||
+        (request_type == `FB_CMD_SET_STIMULUS && request_length != 33) ||
+        (request_type == `FB_CMD_SET_PID_TARGET && request_length != 1);
+
+    always @(posedge clk) begin
+        if (reset_count < 2) begin
+            rst_n <= 0;
+            reset_count <= reset_count + 1'b1;
+        end else rst_n <= 1;
+
+        if (!rst_n) begin
+            assume(!frame_valid);
+            assume(!manual_commit_done);
+            assume(!tx_done);
+        end else begin
+            assume(!known || bad_length || request_type == `FB_CMD_SET_STIMULUS ||
+                   request_type == `FB_CMD_GET_SNAPSHOT);
+            if (sent) assume(!frame_valid);
+            if (frame_valid && frame_ready) sent <= 1;
+            if (!saw_manual_commit) assume(!manual_commit_done);
+            if (!manual_commit_done) assume(!manual_commit_ok);
+            if (manual_commit) saw_manual_commit <= 1;
+
+            if (tx_start) begin
+                assert(tx_frame_type == `FB_RSP_ACK_NACK ||
+                       tx_frame_type == `FB_RSP_SNAPSHOT_DATA);
+                if (tx_frame_type == `FB_RSP_ACK_NACK) begin
+                    assert(tx_payload_length == 4);
+                    saw_ack <= 1;
+                    if (!known) assert(ack_status == `FB_STATUS_UNSUPPORTED);
+                    else if (bad_length) assert(ack_status == `FB_STATUS_BAD_LENGTH);
+                    else if (request_type == `FB_CMD_SET_STIMULUS)
+                        assert(ack_status == `FB_STATUS_UNSUPPORTED);
+                    if (request_type == `FB_CMD_GET_SNAPSHOT && ack_status == `FB_STATUS_OK)
+                        saw_get_ack <= 1;
+                end else begin
+                    assert(saw_get_ack);
+                    assert(tx_payload_length == `FB_SNAPSHOT_LENGTH);
+                    saw_data <= 1;
+                end
+            end
+            assert(!manual_commit);
+            if (transaction_done) begin
+                assert(saw_ack);
+                if (request_type == `FB_CMD_GET_SNAPSHOT && request_length == 0)
+                    assert(saw_data);
+            end
+        end
+    end
+endmodule

+ 1 - 1
tests/formal/6400_pwm_properties.sby

@@ -4,7 +4,7 @@ z3
 
 [options]
 mode prove
-depth 8
+depth 12
 
 [engines]
 boolector: smtbmc boolector

+ 17 - 22
tests/formal/6400_pwm_properties_formal.v

@@ -1,35 +1,30 @@
-module thermal_6400_pwm_properties_formal (
-    input wire clk,
-    input wire rst_n
-);
-    (* anyseq *) reg [7:0] duty_data;
-    (* anyseq *) reg boot_release;
-    (* anyseq *) reg force_full_speed;
+module thermal_6400_pwm_properties_formal(input wire clk);
+    wire [4:0] duty_addr;
     wire [31:0] logical_bitmap;
     wire [3:0] front_fan_ball;
     wire [3:0] rear_fan_ball;
+    wire [6:0] phase_value;
 
-    pwm_bitmap_engine dut (
-        .clk(clk), .rst_n(rst_n), .duty_rd_addr(), .duty_rd_data(duty_data),
-        .logical_bitmap(logical_bitmap), .phase_boundary(), .phase_boundary_advance(), .deadline_miss(),
-        .phase_value(), .scan_idle()
+    // Five formal phase bins with one asserted bin is exactly the production
+    // reset ratio 20/100, while keeping the proof bounded and non-vacuous.
+    pwm_bitmap_engine #(
+        .PHASE_COUNT(5), .PTC_PHASE_CLKS(2), .FAN_PHASE_CLKS(2),
+        .RESET_FAN_DUTY(1)
+    ) dut (
+        .clk(clk), .rst_n(1'b0), .duty_rd_addr(duty_addr), .duty_rd_data(8'd100),
+        .logical_bitmap(logical_bitmap), .phase_boundary(),
+        .phase_boundary_advance(), .deadline_miss(), .phase_value(phase_value),
+        .scan_idle()
     );
     fan_board_output_adapter u_board (
         .logical_fan_on(logical_bitmap[31:24]),
-        .boot_release(boot_release), .force_full_speed(force_full_speed),
         .front_fan_ball(front_fan_ball), .rear_fan_ball(rear_fan_ball)
     );
 
-    reg [1:0] reset_cycles = 0;
     always @(posedge clk) begin
-        if (reset_cycles < 2) begin
-            assume(!rst_n);
-            reset_cycles <= reset_cycles + 1'b1;
-        end else assume(rst_n);
-        assume(duty_data <= 100);
-        assert(front_fan_ball == ~((!boot_release || force_full_speed) ?
-            4'hF : logical_bitmap[27:24]));
-        assert(rear_fan_ball == ((!boot_release || force_full_speed) ?
-            4'hF : logical_bitmap[31:28]));
+        assert(logical_bitmap[23:0] == 24'd0);
+        assert(logical_bitmap[31:24] == ((phase_value < 1) ? 8'hFF : 8'h00));
+        assert(front_fan_ball == ~logical_bitmap[27:24]);
+        assert(rear_fan_ball == logical_bitmap[31:28]);
     end
 endmodule

+ 21 - 0
tests/formal/6400_set_all_commit_properties.sby

@@ -0,0 +1,21 @@
+[tasks]
+boolector
+z3
+
+[options]
+mode bmc
+depth 76
+
+[engines]
+boolector: smtbmc boolector
+z3: smtbmc z3 -- --noincr
+
+[script]
+read_verilog -formal -I. thermal_host_command.v
+read_verilog -formal -I. 6400_set_all_commit_properties_formal.v
+prep -top thermal_6400_set_all_commit_properties_formal
+
+[files]
+../../src/transport/thermal_host_command.v
+generated/6400/prod2u_6400_v1_params.vh ../../generated/6400/prod2u_6400_v1_params.vh
+6400_set_all_commit_properties_formal.v

+ 57 - 0
tests/formal/6400_set_all_commit_properties_formal.v

@@ -0,0 +1,57 @@
+`include "generated/6400/prod2u_6400_v1_params.vh"
+
+module thermal_6400_set_all_commit_properties_formal(input wire clk);
+    reg rst_n = 0;
+    reg [1:0] reset_count = 0;
+    reg frame_valid = 0;
+    reg sent = 0;
+    reg manual_commit_done = 0;
+    reg manual_commit_ok = 0;
+    reg saw_commit = 0;
+    wire frame_ready;
+    wire manual_commit, tx_start, transaction_done;
+    wire [7:0] tx_frame_type, tx_payload_length, ack_status;
+
+    thermal_host_command dut (
+        .clk(clk), .rst_n(rst_n), .frame_valid(frame_valid),
+        .frame_ready(frame_ready), .frame_accept_enable(),
+        .frame_type(`FB_CMD_SET_ALL), .frame_length(8'd32),
+        .payload_read_addr(), .payload_read_data(8'd50),
+        .manual_wr_en(), .manual_wr_addr(), .manual_wr_data(),
+        .manual_commit(manual_commit), .manual_commit_done(manual_commit_done),
+        .manual_commit_ok(manual_commit_ok), .safety_locked(1'b0),
+        .pid_target_commit(), .pid_target_celsius(), .snapshot_capture(),
+        .snapshot_ready(1'b0), .tx_start(tx_start), .tx_frame_type(tx_frame_type),
+        .tx_payload_length(tx_payload_length), .tx_payload_addr(8'd2),
+        .ack_payload_data(ack_status), .tx_done(1'b1),
+        .transaction_done(transaction_done), .busy()
+    );
+
+    always @(posedge clk) begin
+        frame_valid <= 0;
+        manual_commit_done <= 0;
+        manual_commit_ok <= 0;
+        if (reset_count < 2) begin
+            rst_n <= 0;
+            reset_count <= reset_count + 1'b1;
+        end else begin
+            rst_n <= 1;
+            if (!sent && frame_ready) begin
+                frame_valid <= 1;
+                sent <= 1;
+            end
+            if (manual_commit) begin
+                saw_commit <= 1;
+                manual_commit_done <= 1;
+                manual_commit_ok <= 1;
+            end
+            if (tx_start) begin
+                assert(saw_commit);
+                assert(tx_frame_type == `FB_RSP_ACK_NACK);
+                assert(tx_payload_length == 4);
+                assert(ack_status == `FB_STATUS_OK);
+            end
+            if (transaction_done) assert(saw_commit);
+        end
+    end
+endmodule

+ 4 - 1
tests/formal/6400_snapshot_properties_formal.v

@@ -16,7 +16,10 @@ module thermal_6400_snapshot_properties_formal (
         .bmc_active_bank(bmc_active_bank), .ct_active_bank(ct_active_bank),
         .output_active_bank(output_active_bank), .bmc_locked_bank(),
         .ct_locked_bank(), .output_locked_bank(), .control_state(3'd0),
-        .fault_flags(16'd0), .current_target(8'd70), .host_target_seen(1'b0),
+        .fault_flags(16'd0), .current_target(8'd70),
+        .watchdog_active(1'b1), .watchdog_remaining(8'd30),
+        .pid_running(1'b0), .manual_mode(1'b0), .hard_protect(1'b0),
+        .bmc_stale(1'b1), .ct_stale(1'b1),
         .bmc_epoch(bmc_epoch), .ct_epoch(ct_epoch), .control_epoch(control_epoch),
         .bmc_age(16'd0), .ct_age(16'd0), .bmc_valid_mask(24'd0),
         .ct_valid_mask(27'd0), .safety_override_mask(24'd0),

+ 23 - 0
tests/formal/6400_snapshot_transport_properties.sby

@@ -0,0 +1,23 @@
+[tasks]
+boolector
+z3
+
+[options]
+mode bmc
+depth 48
+
+[engines]
+boolector: smtbmc boolector
+z3: smtbmc z3 -- --noincr
+
+[script]
+read_verilog -formal -D FORMAL -I. host_port_selector.v thermal_host_command.v thermal_snapshot_mux.v
+read_verilog -formal -I. 6400_snapshot_transport_properties_formal.v
+prep -top thermal_6400_snapshot_transport_properties_formal
+
+[files]
+../../src/transport/host_port_selector.v
+../../src/transport/thermal_host_command.v
+../../src/telemetry/thermal_snapshot_mux.v
+generated/6400/prod2u_6400_v1_params.vh ../../generated/6400/prod2u_6400_v1_params.vh
+6400_snapshot_transport_properties_formal.v

+ 106 - 0
tests/formal/6400_snapshot_transport_properties_formal.v

@@ -0,0 +1,106 @@
+`include "generated/6400/prod2u_6400_v1_params.vh"
+
+module thermal_6400_snapshot_transport_properties_formal(input wire clk);
+    reg rst_n = 0;
+    reg [1:0] reset_count = 0;
+    reg formal_past_valid = 0;
+    (* anyseq *) reg frame_valid;
+    (* anyseq *) reg snapshot_ready;
+    (* anyseq *) reg tx_done;
+    (* anyseq *) reg rs232_rx;
+    (* anyseq *) reg ttl_rx;
+    (* anyseq *) reg shared_tx;
+
+    wire frame_ready, frame_accept_enable;
+    wire snapshot_capture, tx_start, transaction_done, command_busy;
+    wire [7:0] tx_frame_type, tx_payload_length, ack_payload_data;
+    wire selected_rx, rs232_tx, ttl_tx, host_locked, port_sel;
+    wire snapshot_locked, snapshot_mux_ready;
+    reg get_active = 0;
+    reg [1:0] get_tx_done_count = 0;
+    reg capture_seen = 0;
+
+    host_port_selector #(.IDLE_UNLOCK_CLKS(255)) u_select (
+        .clk(clk), .rst_n(rst_n), .rs232_rx_async(rs232_rx),
+        .ttl_rx_async(ttl_rx), .shared_tx(shared_tx),
+        .transaction_done(transaction_done), .selected_rx(selected_rx),
+        .rs232_tx(rs232_tx), .ttl_tx(ttl_tx), .locked(host_locked),
+        .port_sel(port_sel), .rs232_rx_sync(), .ttl_rx_sync()
+    );
+
+    thermal_host_command #(.SNAPSHOT_LENGTH(`FB_SNAPSHOT_LENGTH)) u_command (
+        .clk(clk), .rst_n(rst_n), .frame_valid(frame_valid),
+        .frame_ready(frame_ready), .frame_accept_enable(frame_accept_enable),
+        .frame_type(`FB_CMD_GET_SNAPSHOT), .frame_length(8'd0),
+        .payload_read_addr(), .payload_read_data(8'd0), .manual_wr_en(),
+        .manual_wr_addr(), .manual_wr_data(), .manual_commit(),
+        .manual_commit_done(1'b0), .manual_commit_ok(1'b0),
+        .safety_locked(1'b0), .pid_target_commit(), .pid_target_celsius(),
+        .snapshot_capture(snapshot_capture), .snapshot_ready(snapshot_mux_ready),
+        .tx_start(tx_start), .tx_frame_type(tx_frame_type),
+        .tx_payload_length(tx_payload_length), .tx_payload_addr(8'd0),
+        .ack_payload_data(ack_payload_data), .tx_done(tx_done),
+        .transaction_done(transaction_done), .busy(command_busy)
+    );
+
+    thermal_snapshot_mux u_snapshot (
+        .clk(clk), .rst_n(rst_n), .capture(snapshot_capture),
+        .ready(snapshot_mux_ready), .locked(snapshot_locked),
+        .bmc_active_bank(1'b0), .ct_active_bank(1'b0),
+        .output_active_bank(1'b0), .bmc_locked_bank(), .ct_locked_bank(),
+        .output_locked_bank(), .control_state(3'd0), .fault_flags(16'd0),
+        .current_target(8'd70), .watchdog_active(1'b1),
+        .watchdog_remaining(8'd30), .pid_running(1'b0),
+        .manual_mode(1'b0), .hard_protect(1'b0), .bmc_stale(1'b1),
+        .ct_stale(1'b1), .bmc_epoch(16'd0), .ct_epoch(16'd0),
+        .control_epoch(16'd0), .bmc_age(16'd0), .ct_age(16'd0),
+        .bmc_valid_mask(24'd0), .ct_valid_mask(27'd0),
+        .safety_override_mask(24'd0), .lane_fault_mask(4'd0),
+        .global_fault(1'b0), .unlock(transaction_done), .payload_addr(8'd0),
+        .payload_data(), .bmc_rd_index(), .bmc_rd_raw(16'd0),
+        .ct_rd_index(), .ct_rd_raw(16'd0), .output_rd_addr(),
+        .requested_data(8'd0), .applied_data(8'd0)
+    );
+
+    always @(posedge clk) begin
+        formal_past_valid <= 1;
+        if (reset_count < 2) begin
+            rst_n <= 0;
+            reset_count <= reset_count + 1'b1;
+            get_active <= 0;
+            get_tx_done_count <= 0;
+            capture_seen <= 0;
+        end else begin
+            rst_n <= 1;
+            if (frame_valid && frame_ready) begin
+                assume(host_locked);
+                get_active <= 1;
+                get_tx_done_count <= 0;
+                capture_seen <= 0;
+            end else if (get_active && tx_done && get_tx_done_count != 3)
+                get_tx_done_count <= get_tx_done_count + 1'b1;
+            if (snapshot_capture)
+                capture_seen <= 1;
+            if (transaction_done) begin
+                get_active <= 0;
+                capture_seen <= 0;
+            end
+        end
+        if (rst_n && formal_past_valid && $past(rst_n)) begin
+            if (get_active && !transaction_done) begin
+                assert(host_locked);
+                if (capture_seen)
+                    assert(snapshot_locked);
+            end
+            if (transaction_done && get_active) begin
+                assert($past(tx_done));
+                assert(get_tx_done_count >= 2);
+                assert(capture_seen);
+                assert(snapshot_locked);
+                assert(host_locked);
+            end
+            if ($past(snapshot_locked && !transaction_done))
+                assert(snapshot_locked);
+        end
+    end
+endmodule

+ 49 - 15
tests/formal/solver-map.yaml

@@ -1,16 +1,50 @@
-schema: prod2u-6400-formal-solver-map-v1
-policy:
-  exploratory_timeout_seconds: 90
-  acceptance_timeout_seconds: 600
-  max_concurrent_heavy_tasks: 1
-  timeout_kills_process_group: true
+schema: prod2u-6400-solver-map-v1
+product: 6400-front-rear
 targets:
-  core: {selected: boolector, boolector_seconds: 8.219, z3_seconds: 55.260, dual_solver: true}
-  transport: {selected: boolector, boolector_seconds: 0.771, z3_seconds: 2.030, dual_solver: true}
-  bmc_bank: {selected: boolector, boolector_seconds: 0.743, z3_seconds: 1.878, dual_solver: true}
-  snapshot: {selected: boolector, boolector_seconds: 0.686, z3_seconds: 0.809, dual_solver: true}
-  pwm: {selected: boolector, boolector_seconds: 0.302, z3_seconds: 0.749, dual_solver: true}
-  boot_output: {selected: z3, boolector_seconds: 2.179, z3_seconds: 1.163, dual_solver: true}
-notes:
-  calibration_source: prior_commit_bound_receipt_plus_current_boot_output_exploration
-  physical_scope: formal_only_hardware_not_run
+  board_adapter:
+    selected: boolector
+    boolector_probe: PASS_0s
+    z3_probe: PASS_0s
+    safety_cross_check: PASS
+  core_owner:
+    selected: boolector
+    boolector_probe: TIMEOUT_90s_step89
+    z3_probe: TIMEOUT_90s_step15
+    selected_result: PASS_K_INDUCTION_94s_DEPTH90
+  core_transitions:
+    selected: boolector
+    boolector_probe: PASS_BMC_125s_DEPTH90
+  frame_rx:
+    selected: z3
+    boolector_probe: PASS
+    z3_probe: PASS_5s
+    safety_cross_check: PASS
+  snapshot_transport:
+    selected: boolector
+    boolector_probe: PASS_DEPTH48
+    z3_probe: TIMEOUT_90s_step36
+  snapshot_lock:
+    selected: boolector
+    boolector_probe: PASS_0s
+  bmc_bank:
+    selected: boolector
+    boolector_probe: PASS_0s
+  reset_pwm:
+    selected: boolector
+    boolector_probe: PASS_0s
+    z3_probe: PASS_1s
+    safety_cross_check: PASS
+  host_command_short:
+    selected: boolector
+    boolector_probe: PASS_1s
+    z3_probe: PASS_7s
+    safety_cross_check: PASS
+  set_all_commit:
+    selected: boolector
+    boolector_probe: PASS_1s
+    z3_probe: PASS_35s
+    safety_cross_check: PASS
+limits:
+  probe_seconds: 90
+  target_max_seconds: 600
+  simultaneous_solvers: 1

+ 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);

+ 30 - 13
tests/sim/pwm_bitmap_engine_tb.v

@@ -27,6 +27,7 @@ module pwm_bitmap_engine_tb;
     integer boundary_count;
     integer channel;
     integer sample;
+    integer period;
     reg previous_valid;
     reg idle_seen;
 
@@ -40,8 +41,7 @@ module pwm_bitmap_engine_tb;
         .phase_value(phase), .scan_idle(idle)
     );
     fan_board_output_adapter board_adapter (
-        .logical_fan_on(bitmap[31:24]), .boot_release(rst_n),
-        .force_full_speed(1'b0), .front_fan_ball(front_fan_balls),
+        .logical_fan_on(bitmap[31:24]), .front_fan_ball(front_fan_balls),
         .rear_fan_ball(rear_fan_balls)
     );
 
@@ -120,12 +120,12 @@ module pwm_bitmap_engine_tb;
                 endcase
             end else begin
                 case (channel)
-                    24: duty[channel] = 10;
+                    24: duty[channel] = 20;
                     25: duty[channel] = 50;
                     26: duty[channel] = 100;
                     27: duty[channel] = 0;
                     28: duty[channel] = 50;
-                    29: duty[channel] = 10;
+                    29: duty[channel] = 20;
                     30: duty[channel] = 0;
                     default: duty[channel] = 100;
                 endcase
@@ -136,15 +136,32 @@ module pwm_bitmap_engine_tb;
         for (channel = 0; channel < 8; channel = channel + 1)
             fan_active_count[channel] = 0;
 
-        repeat (4) @(negedge clk);
-        if (bitmap !== 32'hff000000 || ptc_pins !== 24'd0 || fan_balls !== 8'hf0 ||
-            fan_connector_pwm !== 8'hff)
-            $fatal(1, "reset polarity mismatch bitmap=%h ptc=%h balls=%h connector=%h",
-                bitmap, ptc_pins, fan_balls, fan_connector_pwm);
+        // Control reset is held for three complete carriers. The independent
+        // safe carrier must continue at connector FAN20 / PTC0.
+        repeat (2) @(negedge clk);
+        for (period = 0; period < 3; period = period + 1) begin
+            for (channel = 0; channel < 8; channel = channel + 1)
+                fan_active_count[channel] = 0;
+            for (sample = 0; sample < 50000; sample = sample + 1) begin
+                if (ptc_pins !== 0) $fatal(1, "PTC high during control reset");
+                for (channel = 0; channel < 8; channel = channel + 1)
+                    if (fan_connector_pwm[channel])
+                        fan_active_count[channel] = fan_active_count[channel] + 1;
+                @(negedge clk);
+            end
+            for (channel = 0; channel < 8; channel = channel + 1)
+                if (fan_active_count[channel] != 10000)
+                    $fatal(1, "reset period %0d fan %0d high=%0d", period, channel,
+                        fan_active_count[channel]);
+        end
         rst_n = 1;
 
         // Start at phase zero and count one exact 2 ms / 50,000-clock carrier.
         wait_for_phase_zero();
+        for (channel = 0; channel < 32; channel = channel + 1)
+            high_count[channel] = 0;
+        for (channel = 0; channel < 8; channel = channel + 1)
+            fan_active_count[channel] = 0;
         for (sample = 0; sample < 50000; sample = sample + 1) begin
             if (miss) $fatal(1, "unexpected scan deadline miss");
             for (channel = 0; channel < 32; channel = channel + 1)
@@ -182,17 +199,17 @@ module pwm_bitmap_engine_tb;
         // The already-built phase zero remains intact; the following phase
         // commits all 32 new values together with no mid-phase output change.
         for (channel = 0; channel < 24; channel = channel + 1) duty[channel] = 0;
-        for (channel = 24; channel < 32; channel = channel + 1) duty[channel] = 100;
+        for (channel = 24; channel < 32; channel = channel + 1) duty[channel] = 20;
         wait_for_boundary();
         wait_for_boundary();
-        if (bitmap !== 32'hff000000)
+        if (bitmap[23:0] !== 0)
             $fatal(1, "atomic safety bitmap mismatch: %h", bitmap);
-        if (ptc_pins !== 24'd0 || fan_balls !== 8'hf0 || fan_connector_pwm !== 8'hff)
+        if (ptc_pins !== 24'd0)
             $fatal(1, "safe physical polarity mismatch ptc=%h balls=%h connector=%h",
                 ptc_pins, fan_balls, fan_connector_pwm);
         if (miss) $fatal(1, "scan deadline miss after safety transition");
 
-        $display("PASS: L6 PWM 32ch 500Hz duties include 10/50/100 atomic 0x0F board polarity");
+        $display("PASS: PWM reset 3 periods FAN20 plus 0/20/50/100 connector polarity");
         $finish;
     end
 endmodule

+ 111 - 135
tests/sim/thermal_control_core_tb.v

@@ -1,187 +1,163 @@
 `timescale 1ns/1ps
 
 module thermal_control_core_tb;
-    reg clk = 0;
-    reg rst_n = 0;
-    reg tick = 0;
-    reg target_commit = 0;
-    reg [7:0] target = 70;
+    reg clk = 0, rst_n = 0, tick = 0;
+    reg manual_wr = 0, manual_commit = 0, pid_commit = 0;
+    reg [4:0] manual_addr = 0;
+    reg [7:0] manual_data = 0, pid_target = 70;
     reg [15:0] bmc_epoch = 0;
     reg bmc_stale = 1;
-    reg [23:0] bmc_valid_mask = 24'hffffff;
+    reg [23:0] bmc_mask = 24'hffffff;
     wire [4:0] bmc_index;
     reg [15:0] bmc_raw [0:23];
-    wire [15:0] bmc_data = bmc_raw[bmc_index];
-    wire bmc_valid = bmc_valid_mask[bmc_index];
-    reg [15:0] ct_epoch = 0;
-    reg ct_stale = 0;
-    reg [26:0] ct_valid_mask = 27'h7ffffff;
     reg [4:0] pwm_addr = 0;
     wire [7:0] pwm_data;
-    reg [4:0] snapshot_addr = 0;
-    wire [7:0] snapshot_req;
-    wire [7:0] snapshot_app;
-    wire active_bank;
-    wire [2:0] state;
-    wire [7:0] current_target;
-    wire host_seen;
+    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;
     wire [23:0] safety;
     wire [3:0] lane_fault;
-    wire global_fault;
-    wire output_commit;
-    wire stimulus_active;
-    integer i;
-    integer commits = 0;
+    wire global_fault, watchdog_active, pid_running, manual_mode, hard_protect;
+    integer i, commits = 0;
 
     always #5 clk = ~clk;
     always @(posedge clk) if (output_commit) commits <= commits + 1;
 
-    thermal_control_core dut (
-        .clk(clk), .rst_n(rst_n), .tick_1s(tick), .target_commit(target_commit),
-        .target_celsius(target), .stimulus_wr_en(1'b0), .stimulus_wr_addr(5'd0),
-        .stimulus_wr_data(8'd0), .stimulus_commit(1'b0), .stimulus_duration_seconds(8'd0),
-        .bmc_epoch(bmc_epoch), .bmc_stale(bmc_stale), .bmc_valid_mask(bmc_valid_mask),
-        .bmc_rd_index(bmc_index), .bmc_rd_raw(bmc_data), .bmc_rd_valid(bmc_valid),
-        .ct_epoch(ct_epoch), .ct_stale(ct_stale), .ct_valid_mask(ct_valid_mask),
-        .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(snapshot_addr), .snapshot_requested_data(snapshot_req),
-        .snapshot_applied_data(snapshot_app), .active_output_bank(active_bank),
-        .control_state(state), .current_target_celsius(current_target),
-        .host_target_seen(host_seen), .control_epoch(control_epoch),
+    thermal_control_core #(.WATCHDOG_TICKS_OVERRIDE(10)) 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(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),
+        .ct_valid_mask(27'h7ffffff), .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(0),
+        .snapshot_requested_data(), .snapshot_applied_data(),
+        .active_output_bank(active_bank), .control_state(mode),
+        .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(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(1'b1), .pwm_scan_idle(1'b1), .boot_init_complete()
     );
 
-    task next_bmc_epoch;
+    task one_tick;
+        begin @(negedge clk); tick = 1; @(negedge clk); tick = 0; end
+    endtask
+    task wait_commit;
+        input integer prior;
+        integer timeout;
         begin
-            @(negedge clk); bmc_epoch = bmc_epoch + 1'b1;
-            repeat (3) @(negedge clk);
+            timeout = 0;
+            while (commits == prior && timeout < 500) begin @(negedge clk); timeout = timeout + 1; end
+            if (timeout == 500) $fatal(1, "commit timeout mode=%0d work=%0d", mode, dut.work_state);
         end
     endtask
-
-    task wait_commit_after;
-        input integer old_count;
+    task wait_manual_commit;
         integer timeout;
         begin
             timeout = 0;
-            while (commits == old_count && timeout < 1000) begin @(negedge clk); timeout = timeout + 1; end
-            if (timeout >= 1000) begin
-                $display("commit timeout state=%0d work=%0d index=%0d last_bmc=%0d input_epoch=%0d", state, dut.work_state, dut.work_index, dut.last_bmc_epoch, bmc_epoch);
-                $fatal;
-            end
+            while (!manual_done && timeout < 500) begin @(negedge clk); timeout = timeout + 1; end
+            if (timeout == 500) $fatal(1, "manual commit timeout mode=%0d work=%0d", mode, dut.work_state);
+            @(negedge clk);
         end
     endtask
-
     task check_duty;
         input [4:0] address;
         input [7:0] expected;
         begin
             pwm_addr = address;
             repeat (2) @(negedge clk);
-            if (pwm_data !== expected) begin
-                $display("duty[%0d]=%0d expected=%0d", address, pwm_data, expected);
-                $fatal;
+            if (pwm_data !== expected) $fatal(1, "duty[%0d]=%0d expected=%0d", address, pwm_data, expected);
+        end
+    endtask
+    task stage_manual;
+        begin
+            for (i = 0; i < 32; i = i + 1) begin
+                @(negedge clk); manual_wr = 1; manual_addr = i[4:0];
+                manual_data = (i < 24) ? 8'd50 : ((i[1:0] == 0) ? 0 : (i[1:0] == 1) ? 20 : (i[1:0] == 2) ? 50 : 100);
             end
+            @(negedge clk); manual_wr = 0;
         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;
-        // The RAM-backed controller deterministically initializes both output
-        // banks and all PI-state words before leaving RESET_SAFE.
-        repeat (36) @(negedge clk);
-        if (state !== 1 || global_fault) $fatal;
-        ct_epoch = 1;
-        repeat (3) @(negedge clk);
-        if (state !== 2 || global_fault) $fatal;
-        bmc_stale = 0;
-        next_bmc_epoch();
-        if (state !== 3) $fatal;
-        next_bmc_epoch();
-        next_bmc_epoch();
-        next_bmc_epoch();
-        wait_commit_after(0);
-        if (state !== 4 || control_epoch == 0) $fatal;
-        check_duty(0, 5);
-        check_duty(24, 30);
+        repeat (4) @(negedge clk); rst_n = 1;
+        repeat (40) @(negedge clk);
+        if (mode != 0 || !watchdog_active || pid_running || manual_mode || current_target != 70) $fatal;
+        check_duty(0, 0); check_duty(24, 20); check_duty(31, 20);
 
-        // 74 C is a soft reduction, not a shutdown: retain a reduced PTC
-        // request and raise both fans for only the affected lane to 80%.
-        bmc_raw[0] = {8'd74, 8'd0};
+        // First boot timeout atomically commits safe and enters PID wait.
         i = commits;
-        next_bmc_epoch();
-        wait_commit_after(i);
-        if (!safety[0] || state !== 4) $fatal;
-        check_duty(0, 4);
-        check_duty(24, 80);
-        check_duty(28, 80);
-        check_duty(25, 30);
+        repeat (10) one_tick();
+        wait_commit(i);
+        if (mode != 2 || watchdog_remaining != 0 || pid_running) $fatal;
+        check_duty(0, 0); check_duty(24, 20);
 
-        // 76 C shuts down only the matching PTC while retaining 80% lane
-        // airflow; the 77 C lane latch below remains the 100% action.
-        bmc_raw[0] = {8'd76, 8'd0};
-        i = commits;
-        next_bmc_epoch();
-        wait_commit_after(i);
-        if (!safety[0] || lane_fault[0] || state !== 5) $fatal;
-        check_duty(0, 0);
-        check_duty(24, 80);
-        check_duty(28, 80);
-        bmc_raw[0] = {8'd77, 8'd0};
-        i = commits;
-        next_bmc_epoch();
-        wait_commit_after(i);
-        if (!lane_fault[0] || state !== 5) $fatal;
-        for (i = 0; i < 6; i = i + 1) check_duty(i[4:0], 0);
-        check_duty(24, 100);
-        check_duty(28, 100);
-        i = commits;
-        bmc_stale = 1;
-        wait_commit_after(i);
-        if (!global_fault) $fatal;
-        check_duty(12, 0);
-        check_duty(26, 100);
+        // A new complete valid BMC epoch starts PID; absence never integrates.
+        bmc_stale = 0; bmc_epoch = 1;
+        i = commits; wait_commit(i);
+        if (mode != 2 || !pid_running) $fatal;
 
-        // A legal target commit must not weaken an already-latched stale
-        // fault or its 100% airflow fallback.
-        i = commits;
-        @(negedge clk); target = 65; target_commit = 1;
-        @(negedge clk); target_commit = 0;
-        wait_commit_after(i);
-        if (!global_fault || state !== 5 || current_target !== 65) $fatal;
-        check_duty(0, 0);
-        check_duty(24, 100);
-        check_duty(28, 100);
+        // SET_PID_TARGET changes only the next PID target.
+        @(negedge clk); pid_target = 65; pid_commit = 1;
+        @(negedge clk); pid_commit = 0;
+        if (current_target != 65 || mode != 2) $fatal;
 
-        // Recovery holds the global/lane clamps for two complete fresh
-        // epochs and releases them only after the third safe epoch commits.
-        for (i = 0; i < 24; i = i + 1) bmc_raw[i] = {8'd60, 8'd0};
-        bmc_stale = 0;
+        // SET_ALL atomically enters Manual, freezes PI and reloads the test override.
+        stage_manual();
         i = commits;
-        next_bmc_epoch();
-        wait_commit_after(i);
-        if (!global_fault || !lane_fault[0] || state !== 5) $fatal;
+        @(negedge clk); manual_commit = 1;
+        @(negedge clk); manual_commit = 0;
+        wait_manual_commit();
+        if (mode != 1 || !manual_mode || watchdog_remaining != 10) $fatal;
+        check_duty(0, 50); check_duty(24, 0); check_duty(25, 20);
+        check_duty(26, 50); check_duty(27, 100);
+
+        // Same vector feeds again; SET_ALL wins over the final timeout tick.
+        repeat (9) one_tick();
+        if (watchdog_remaining != 1) $fatal;
+        stage_manual();
         i = commits;
-        next_bmc_epoch();
-        wait_commit_after(i);
-        if (!global_fault || !lane_fault[0] || state !== 5) $fatal;
+        @(negedge clk); manual_commit = 1; tick = 1;
+        @(negedge clk); manual_commit = 0; tick = 0;
+        wait_manual_commit();
+        if (mode != 1 || watchdog_remaining != 10) $fatal;
+
+        // Manual timeout returns atomically to safe PID_WAIT_SENSOR.
         i = commits;
-        next_bmc_epoch();
-        wait_commit_after(i);
-        if (global_fault || lane_fault != 0 || state !== 4) $fatal;
-        // The release commit is still zero-duty: PI state was cleared while
-        // clamped and may only ramp from the next fresh epoch.
-        check_duty(0, 0);
+        repeat (10) one_tick();
+        wait_commit(i);
+        if (mode != 2 || manual_mode) $fatal;
+        check_duty(0, 0); check_duty(24, 20);
+
+        // A valid 76 C channel is clamped without changing Manual ownership.
+        stage_manual();
         i = commits;
-        next_bmc_epoch();
-        wait_commit_after(i);
-        check_duty(0, 4);
-        $display("PASS: thermal_control_core_tb");
+        @(negedge clk); manual_commit = 1;
+        @(negedge clk); manual_commit = 0;
+        wait_manual_commit();
+        bmc_raw[0] = {8'd76, 8'd0}; bmc_epoch = 2;
+        i = commits; wait_commit(i);
+        if (mode != 1 || hard_protect || !safety[0]) $fatal;
+        check_duty(0, 0); check_duty(1, 50); check_duty(24, 0);
+
+        // Only confirmed 77 C hard protection may force lane fans to 100.
+        bmc_raw[0] = {8'd77, 8'd0}; bmc_epoch = 2;
+        bmc_epoch = 3;
+        i = commits; wait_commit(i);
+        if (mode != 2 || !hard_protect || !lane_fault[0]) $fatal;
+        check_duty(0, 0); check_duty(24, 100); check_duty(28, 100);
+        check_duty(25, 20);
+        $display("PASS: SAFE/MANUAL/PID watchdog, 76C clamp, 77C hard-protect");
         $finish;
     end
 endmodule

+ 119 - 0
tests/sim/thermal_control_hard_race_tb.v

@@ -0,0 +1,119 @@
+`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 [7:0] watchdog_remaining;
+    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(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);
+
+        // Put the lease on its final tick. Staging a SET_ALL must not feed it;
+        // only the later, safely-applied output commit may reload it.
+        repeat (3) begin
+            @(negedge clk); tick = 1;
+            @(negedge clk); tick = 0;
+        end
+        if (watchdog_remaining != 1)
+            $fatal(1, "watchdog setup failed: remaining=%0d", watchdog_remaining);
+
+        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;
+        repeat (4) @(negedge clk);
+        if (watchdog_remaining != 1)
+            $fatal(1, "staged/cancelable SET_ALL fed watchdog: remaining=%0d",
+                   watchdog_remaining);
+        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

+ 116 - 0
tests/sim/thermal_host_command_v2_tb.v

@@ -0,0 +1,116 @@
+`timescale 1ns/1ps
+
+module thermal_host_command_v2_tb;
+    reg clk = 0, rst_n = 0, frame_valid = 0, tx_done = 0;
+    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, 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;
+    wire [7:0] tx_type, tx_length;
+    reg [7:0] tx_payload_addr = 0;
+    wire [7:0] ack_data;
+    integer writes = 0, i;
+
+    always #5 clk = ~clk;
+    always @(posedge clk) if (manual_wr) writes <= writes + 1;
+
+    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), .manual_commit_ok(manual_ok),
+        .safety_locked(safety_locked),
+        .pid_target_commit(pid_commit), .pid_target_celsius(pid_target),
+        .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),
+        .tx_done(tx_done), .transaction_done(transaction_done), .busy(busy)
+    );
+
+    task request;
+        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
+    endtask
+    task expect_ack;
+        input [7:0] ok;
+        input [7:0] request_kind;
+        input [7:0] status;
+        input [7:0] detail;
+        integer timeout;
+        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 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;
+            tx_payload_addr = 3; #1; if (ack_data != detail) $fatal;
+            @(negedge clk); tx_done = 1;
+            @(negedge clk); tx_done = 0;
+        end
+    endtask
+
+    initial begin
+        for (i = 0; i < 33; i = i + 1) payload[i] = 0;
+        repeat (3) @(negedge clk); rst_n = 1;
+
+        request(8'h01, 31); expect_ack(0, 8'h01, 2, 32);
+        request(8'h03, 33); expect_ack(0, 8'h03, 1, 0);
+        request(8'h55, 0); expect_ack(0, 8'h55, 1, 0);
+
+        payload[7] = 101; writes = 0;
+        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);
+        repeat (3) @(negedge clk); if (tx_start) $fatal(1, "ACK before atomic commit boundary");
+        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);
+        wait(pid_commit); if (pid_target != 70) $fatal;
+        expect_ack(1, 8'h04, 0, 0);
+
+        request(8'h02, 0); wait(snapshot_capture);
+        snapshot_ready = 1; @(negedge clk); snapshot_ready = 0;
+        expect_ack(1, 8'h02, 0, 0);
+        wait(tx_start); if (tx_type != 8'h82 || tx_length != 201) $fatal(1, "GET DATA order");
+        @(negedge clk); tx_done = 1; @(negedge clk); tx_done = 0;
+        wait(transaction_done);
+        $display("PASS: unified ACK/NACK, atomic SET_ALL, PID and GET 06->82");
+        $finish;
+    end
+endmodule

+ 80 - 0
tests/unit/test_6400_canonical_packages.py

@@ -0,0 +1,80 @@
+from __future__ import annotations
+
+import json
+import subprocess
+import sys
+import zipfile
+from pathlib import Path
+
+import pytest
+
+from tools import package_6400_canonical as canonical
+
+
+def test_deterministic_sorted_posix_zip(tmp_path: Path) -> None:
+    files = {
+        "z/中文 long name.txt": b"z\n",
+        "a.txt": b"a\n",
+        "PACKAGE-MANIFEST.json": b"{}\n",
+        "SHA256SUMS": b"",
+        "PACKAGE-SELF-CHECK.py": b"print('PASS')\n",
+        "START-HERE.zh-CN.md": b"start\n",
+        "EXCLUSIONS.json": b"{}\n",
+    }
+    a = canonical.write_zip(tmp_path / "a.zip", files)
+    b = canonical.write_zip(tmp_path / "b.zip", files)
+    assert canonical.sha_file(a) == canonical.sha_file(b)
+    with zipfile.ZipFile(a) as archive:
+        assert archive.namelist() == sorted(archive.namelist())
+        assert not any("\\" in name for name in archive.namelist())
+
+
+@pytest.mark.parametrize("name", ["../escape", "/absolute", "bad\\member"])
+def test_unsafe_member_fails(name: str) -> None:
+    with pytest.raises(ValueError, match="unsafe ZIP member"):
+        canonical.safe_name(name)
+
+
+def test_base_id_is_path_sha_role_not_time() -> None:
+    files = {"src/common/a.v": b"a", "tools/x.py": b"x"}
+    assert canonical.fingerprint(files) == canonical.fingerprint(dict(reversed(list(files.items()))))
+    changed = dict(files)
+    changed["tools/x.py"] = b"y"
+    assert canonical.fingerprint(changed) != canonical.fingerprint(files)
+
+
+def test_common_profile_files_and_tamper_failure(tmp_path: Path) -> None:
+    payload = canonical.common_payload(
+        "base", "1" * 40, "2" * 40, {"src/common/a.v": b"module a; endmodule\n"}, {"base_id": "abc"}
+    )
+    archive = canonical.write_zip(tmp_path / "base.zip", payload)
+    canonical.tamper_must_fail(archive)
+    with zipfile.ZipFile(archive) as z:
+        assert set(canonical.COMMON).issubset(z.namelist())
+        manifest = json.loads(z.read("PACKAGE-MANIFEST.json"))
+        assert manifest["profile"] == "base"
+
+
+def test_current_selfcheck_explicit_base_required(tmp_path: Path) -> None:
+    payload = canonical.common_payload(
+        "current", "1" * 40, "2" * 40, {"BASE-REQUIRED.json": b"{}\n"}, {"base_id": "abc"}
+    )
+    archive = canonical.write_zip(tmp_path / "current.zip", payload)
+    root = tmp_path / "unpacked"
+    root.mkdir()
+    canonical.extract_safe(archive, root)
+    result = subprocess.run(
+        [sys.executable, str(root / "PACKAGE-SELF-CHECK.py")], cwd=root,
+        text=True, capture_output=True,
+    )
+    assert result.returncode == 3
+    assert "BASE_REQUIRED" in result.stdout
+
+
+def test_active_sets_exclude_old_profiles_and_scratch() -> None:
+    selected = canonical.base_paths() + canonical.current_paths()
+    assert not any("6400-control" in path or "6400-identification" in path or "6400-sim-debug" in path for path in selected)
+    assert "ACTIVE_FIX_LOCK.yaml" not in selected
+    assert "QUICK_PROGRESS.md" not in selected
+    assert "tools/target_registry.py" in canonical.base_paths()
+    assert "docs/generated/6400-channel-map.md" in canonical.current_paths()

+ 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(),

+ 52 - 239
tests/unit/test_6400_formal_contract.py

@@ -1,260 +1,73 @@
 #!/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_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"]
-
-    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_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_long_affected_registry_is_bounded_and_solver_mapped() -> None:
+    data = manifest()
+    assert data["phase"] == "long-affected"
+    assert data["required_solvers"] == ["per-target-solver-map"]
+    targets = {target["name"]: target for target in data["proof_targets"]}
+    assert {"board_adapter", "core_owner", "snapshot_lock", "bmc_bank",
+            "reset_pwm", "host_command_short", "set_all_commit"} <= set(targets)
+    assert targets["board_adapter"]["tasks"] == ["boolector", "z3"]
+    assert targets["reset_pwm"]["tasks"] == ["boolector", "z3"]
+    assert targets["host_command_short"]["mode"] == "bmc"
+    assert targets["set_all_commit"]["mode"] == "bmc"
+    assert all(target["depth"] <= 90 for target in targets.values())
+    assert all((FORMAL / target["sby"]).is_file() for target in targets.values())
+    assert (FORMAL / "solver-map.yaml").is_file()
+
+
+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_remaining_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",
+        "snapshot_lock_stop_bit",
+    } <= 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"
-    }

+ 35 - 0
tests/unit/test_6400_hex_gui_v2.py

@@ -0,0 +1,35 @@
+from importlib.util import module_from_spec, spec_from_file_location
+from pathlib import Path
+
+
+ROOT = Path(__file__).resolve().parents[2]
+SPEC = spec_from_file_location("hex_gui", ROOT / "tools/6400_hex_gui.py")
+assert SPEC and SPEC.loader
+GUI = module_from_spec(SPEC)
+SPEC.loader.exec_module(GUI)
+
+
+def test_gui_uses_generated_contract_and_golden_vectors() -> None:
+    assert GUI.CONTRACT["contract_sha256"] == GUI.GOLDEN["contract_sha256"]
+    assert GUI.frame_hex(GUI.set_all([0] * 24 + [20] * 8)).replace(" ", "") == GUI.GOLDEN["frames"]["set_all_safe"]
+    assert GUI.frame_hex(GUI.encode(2)).replace(" ", "") == GUI.GOLDEN["frames"]["get_snapshot"]
+    assert GUI.frame_hex(GUI.encode(4, bytes((70,)))).replace(" ", "") == GUI.GOLDEN["frames"]["set_pid_target_70"]
+
+
+def test_gui_parses_unified_ack_and_rejects_bad_crc() -> None:
+    ack = bytes.fromhex(GUI.GOLDEN["frames"]["set_all_ack"])
+    assert "status=OK" in GUI.describe(ack)
+    damaged = ack[:-1] + bytes((ack[-1] ^ 1,))
+    try:
+        GUI.decode(damaged)
+    except ValueError as exc:
+        assert "CRC mismatch" in str(exc)
+    else:
+        raise AssertionError("bad CRC accepted")
+
+
+def test_gui_has_no_serial_access_path() -> None:
+    source = (ROOT / "tools/6400_hex_gui.py").read_text(encoding="utf-8")
+    assert "import serial" not in source
+    assert "Serial(" not in source
+    assert "pyserial" not in source.lower()

+ 48 - 116
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,165 +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"]["SET_TARGET_ACK"]["type"] == 0x81
-    assert host_contract["wire"]["responses"]["GET_SNAPSHOT_ACK"]["type"] == 0x82
-    assert host_contract["wire"]["responses"]["SNAPSHOT_DATA"]["type"] == 0x42
-    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 host_contract["wire"]["responses"]["ACK_NACK"]["type"] == 0x06
+    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)
@@ -234,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
 
 

+ 39 - 45
tests/unit/test_6400_v1_contract.py

@@ -1,6 +1,7 @@
 from pathlib import Path
 import re
 import subprocess
+import sys
 
 import yaml
 
@@ -79,47 +80,36 @@ 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
 
     assert "front_fan_pwm_out[1] } { LOCATION = P15" not in adc
     assert "rear_fan_pwm_out[0] } { LOCATION = C4" not in adc
-    assert '`define FAN_STANDBY_DUTY 10' in params
+    assert '`define FAN_SAFE_DUTY 20' in params
+    assert '`define FAN_BOARD_INVERT_MASK 8\'h0F' in params
     assert '`define FB_FAN_RESET `FAN_STANDBY_DUTY' in params
     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:
@@ -128,36 +118,40 @@ def test_generated_standby_duty_reaches_the_production_core() -> None:
         encoding="utf-8"
     )
     assert "parameter [7:0] FAN_STANDBY_DUTY = `FAN_STANDBY_DUTY" in top
-    assert ".FAN_STANDBY_DUTY(FAN_STANDBY_DUTY)" in top
-    assert "parameter [7:0] FAN_STANDBY_DUTY = 8'd10" in core
-    assert "? 8'd0 : FAN_STANDBY_DUTY" in core
-    without_default = core.replace(
-        "parameter [7:0] FAN_STANDBY_DUTY = 8'd10", ""
-    )
-    assert re.search(r"8'd10(?!0)", without_default) is None
+    assert ".FAN_SAFE_DUTY(FAN_STANDBY_DUTY)" in top
+    assert "parameter [7:0] FAN_SAFE_DUTY = `FAN_SAFE_DUTY" in core
+    params = (ROOT / "generated/6400/prod2u_6400_v1_params.vh").read_text()
+    assert "CONTROL_WATCHDOG_SECONDS 30" in params
+    assert "FB_OWNER_SAFE 3'd0" in params
+    assert "FB_OWNER_MANUAL 3'd1" in params
+    assert "FB_OWNER_PID 3'd2" in params
+    assert "DEFAULT_PID_TARGET_C 70" in (ROOT / "generated/6400/prod2u_6400_v1_params.vh").read_text()
 
 
-def test_snapshot_layout_is_fixed_193_bytes() -> None:
+def test_snapshot_layout_contains_modes_watchdog_and_banks() -> None:
     rows, size = layout(load_yaml("6400-snapshot.yaml"))
-    assert size == 193
+    assert size == 201
     assert rows[0]["offset"] == 0
+    assert {"mode", "watchdog_active", "watchdog_remaining", "pid_target", "pid_running", "manual_mode", "hard_protect"} <= {row["name"] for row in rows}
     assert rows[-1]["name"] == "global_fault"
-    assert rows[-1]["offset"] == 192
+    assert rows[-1]["offset"] == 200
 
 
-def test_wire_has_no_forbidden_online_identity() -> None:
+def test_wire_has_unified_ack_registry_and_watchdog_rules() -> None:
     wire = load_yaml("6400-wire.yaml")
-    text = yaml.safe_dump(wire).lower()
-    for forbidden in ("protocol_version", "project_id", "sequence", "nack"):
-        assert forbidden in wire["forbidden_fields"]
-    assert "host_watchdog" not in text
     assert wire["host_uart"]["baud"] == 921600
     assert wire["bmc_uart"]["baud"] == 115200
+    assert {name: value["type"] for name, value in wire["commands"].items()} == {
+        "SET_ALL": 1, "GET_SNAPSHOT": 2, "SET_STIMULUS": 3, "SET_PID_TARGET": 4
+    }
+    assert wire["responses"]["ACK_NACK"]["type"] == 6
+    assert wire["responses"]["SNAPSHOT_DATA"]["type"] == 0x82
+    assert wire["watchdog_feed"] == "legal_atomic_set_all_commit_only"
 
 
 def test_generation_matches_tracked_outputs() -> None:
     subprocess.run(
-        ["python3", str(ROOT / "tools/generate_6400_v1.py"), "--check"],
+        [sys.executable, str(ROOT / "tools/generate_6400_v1.py"), "--check"],
         cwd=ROOT,
         check=True,
     )

+ 9 - 8
tests/unit/test_6400_v1_source_closure.py

@@ -8,22 +8,23 @@ ROOT = Path(__file__).resolve().parents[2]
 
 
 def test_production_closure_excludes_legacy_and_stimulus_wrapper() -> None:
-    closure = json.loads((ROOT / "products/6400-control/source-closure.json").read_text())
+    closure = json.loads((ROOT / "products/6400-front-rear/source-closure.json").read_text())
     sources = "\n".join(closure["sources"])
     assert "identification" not in sources
     for forbidden in ("door_", "motor", "host_watchdog", "EF2_PHY_PLL"):
         assert forbidden not in sources
     assert closure["top_module"] == "prod2u_6400_rs232_only_top"
     assert "src/top/prod2u_6400_rs232_only_top.v" in closure["sources"]
-    assert "src/actuator/fan_boot_safety_controller.v" in closure["sources"]
-    assert "src/control/stimulus_atomic_bank.v" in closure["sources"]
+    assert "src/actuator/fan_boot_safety_controller.v" not in closure["sources"]
+    assert "src/control/manual_set_all_bank.v" in closure["sources"]
+    assert "src/control/stimulus_atomic_bank.v" not in closure["sources"]
 
     runner = (ROOT / "tools/run_6400_v1.py").read_text(encoding="utf-8")
     assert "select -assert-none t:stimulus_atomic_bank" in runner
 
 
 def test_known_pins_are_unique_and_ttl_is_disabled_in_rs232_only_hardware() -> None:
-    project = json.loads((ROOT / "products/6400-control/project.json").read_text())
+    project = json.loads((ROOT / "products/6400-front-rear/project.json").read_text())
     assert project["ttl_pin_status"] == "disabled_in_rs232_only_hardware_profile_unbound"
     assert project["host_interfaces"] == ["host_rs232"]
     assert project["host_rs232_connector"] == "CON78"
@@ -34,14 +35,14 @@ def test_known_pins_are_unique_and_ttl_is_disabled_in_rs232_only_hardware() -> N
 
 
 def test_no_host_watchdog_or_pll_in_6400_sources() -> None:
-    closure = json.loads((ROOT / "products/6400-control/source-closure.json").read_text())
+    closure = json.loads((ROOT / "products/6400-front-rear/source-closure.json").read_text())
     text = "\n".join((ROOT / source).read_text(errors="ignore") for source in closure["sources"] if source.endswith(".v"))
     assert "host_watchdog" not in text
     assert "EF2_PHY_PLL" not in text
 
 
 def test_active_td_and_packaging_exclude_historical_interleaved_tree() -> None:
-    closure = json.loads((ROOT / "products/6400-control/source-closure.json").read_text())
+    closure = json.loads((ROOT / "products/6400-front-rear/source-closure.json").read_text())
     joined = "\n".join(closure["sources"])
     for forbidden in (
         "src/generated/6400",
@@ -52,8 +53,8 @@ def test_active_td_and_packaging_exclude_historical_interleaved_tree() -> None:
         assert forbidden not in joined
 
     target = resolve_target("6400")
-    assert target.project_config == ROOT / "products/6400-control/project.json"
-    assert target.source_closure == ROOT / "products/6400-control/source-closure.json"
+    assert target.project_config == ROOT / "products/6400-front-rear/project.json"
+    assert target.source_closure == ROOT / "products/6400-front-rear/source-closure.json"
     assert target.generated_dir == ROOT / "generated/6400"
     assert target.top_module == "prod2u_6400_rs232_only_top"
 

+ 6 - 15
tests/unit/test_encode_6400_hex.py

@@ -8,27 +8,18 @@ from tools.encode_6400_hex import Encoder
 ROOT = Path(__file__).resolve().parents[2]
 
 
-def test_target_and_get_match_generated_golden_vectors() -> None:
+def test_set_all_pid_and_get_match_generated_golden_vectors() -> None:
     encoder = Encoder()
     golden = encoder.contract["golden_vectors"]["frames"]
-    assert encoder.set_target("6400-control", 0).hex().upper() == golden["set_target_stop"]
-    assert encoder.set_target("6400-control", 20).hex().upper() == golden["set_target_20"]
-    assert encoder.set_target("6400-control", 70).hex().upper() == golden["set_target_70"]
-    assert encoder.get_snapshot("6400-control").hex().upper() == golden["get_snapshot"]
+    assert encoder.set_all("6400-front-rear", [0] * 24, [20] * 4, [20] * 4).hex().upper() == golden["set_all_safe"]
+    assert encoder.set_pid_target("6400-front-rear", 70).hex().upper() == golden["set_pid_target_70"]
+    assert encoder.get_snapshot("6400-front-rear").hex().upper() == golden["get_snapshot"]
 
 
-def test_profile_isolation_and_stimulus_layout() -> None:
+def test_single_product_rejects_reserved_stimulus() -> None:
     encoder = Encoder()
     with pytest.raises(ValueError, match="not supported"):
-        encoder.set_stimulus("6400-control", 1, [0] * 24, [0] * 4, [0] * 4)
-    result = encoder.set_stimulus(
-        "6400-identification", 3, list(range(24)), [10, 20, 30, 40], [50, 60, 70, 80]
-    )
-    assert result[2:4] == bytes((0x03, 33))
-    assert result[4] == 3
-    assert list(result[5:29]) == list(range(24))
-    assert list(result[29:33]) == [10, 20, 30, 40]
-    assert list(result[33:37]) == [50, 60, 70, 80]
+        encoder.set_stimulus("6400-front-rear", 1, [0] * 24, [0] * 4, [0] * 4)
 
 
 def test_only_canonical_profile_names_are_accepted() -> 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):

+ 190 - 0
tools/6400_hex_gui.py

@@ -0,0 +1,190 @@
+#!/usr/bin/env python3
+"""Contract-driven 6400 HEX generator/parser. It never opens a serial port."""
+
+from __future__ import annotations
+
+import json
+import re
+import sys
+from pathlib import Path
+from typing import Any, Iterable
+
+
+def asset(name: str) -> Path:
+    base = Path(getattr(sys, "_MEIPASS", Path(__file__).resolve().parents[1]))
+    direct = base / name
+    return direct if direct.exists() else base / "generated" / "6400" / name
+
+
+CONTRACT = json.loads(asset("host-contract.json").read_text(encoding="utf-8"))
+GOLDEN = json.loads(asset("golden-vectors.json").read_text(encoding="utf-8"))
+METADATA = json.loads(asset("gui-build-metadata.json").read_text(encoding="utf-8")) if asset("gui-build-metadata.json").exists() else {
+    "profile": "source", "commit": "WORKTREE", "bitstream_sha256": "NOT_BUILT"
+}
+WIRE = CONTRACT["wire"]
+COMMANDS = WIRE["commands"]
+RESPONSES = WIRE["responses"]
+STATUS = {int(value): name for name, value in RESPONSES["ACK_NACK"]["status"].items()}
+
+
+def crc16(data: Iterable[int]) -> int:
+    value = 0xFFFF
+    for byte in data:
+        value ^= int(byte) << 8
+        for _ in range(8):
+            value = ((value << 1) ^ 0x1021) & 0xFFFF if value & 0x8000 else (value << 1) & 0xFFFF
+    return value
+
+
+def encode(frame_type: int, payload: bytes = b"") -> bytes:
+    body = bytes((frame_type, len(payload))) + payload
+    check = crc16(body)
+    return b"\xA5\x5A" + body + check.to_bytes(2, "little")
+
+
+def parse_hex(text: str) -> bytes:
+    compact = re.sub(r"[\s:_-]+", "", text)
+    if not compact or len(compact) % 2 or not re.fullmatch(r"[0-9A-Fa-f]+", compact):
+        raise ValueError("HEX must contain an even number of hexadecimal digits")
+    return bytes.fromhex(compact)
+
+
+def decode(frame: bytes) -> tuple[int, bytes]:
+    if len(frame) < 6 or frame[:2] != b"\xA5\x5A":
+        raise ValueError("bad A5 5A header or short frame")
+    size = frame[3]
+    if len(frame) != size + 6:
+        raise ValueError(f"length mismatch: declared {size}, frame bytes {len(frame)}")
+    expected = int.from_bytes(frame[-2:], "little")
+    actual = crc16(frame[2:-2])
+    if expected != actual:
+        raise ValueError(f"CRC mismatch: wire {expected:04X}, calculated {actual:04X}")
+    return frame[2], frame[4:-2]
+
+
+def frame_hex(frame: bytes) -> str:
+    return " ".join(f"{byte:02X}" for byte in frame)
+
+
+def set_all(values: list[int]) -> bytes:
+    if len(values) != 32 or any(not 0 <= value <= 100 for value in values):
+        raise ValueError("SET_ALL requires 32 connector duties in 0..100")
+    return encode(int(COMMANDS["SET_ALL"]["type"]), bytes(values))
+
+
+def describe(frame: bytes) -> str:
+    kind, payload = decode(frame)
+    if kind == int(RESPONSES["ACK_NACK"]["type"]):
+        if len(payload) != 4:
+            raise ValueError("ACK/NACK payload must be 4 bytes")
+        ok, request, status, detail = payload
+        return f"ACK/NACK ok={ok} request=0x{request:02X} status={STATUS.get(status, 'UNKNOWN')} detail={detail}"
+    if kind == int(RESPONSES["SNAPSHOT_DATA"]["type"]):
+        layout = CONTRACT["snapshot"]
+        if len(payload) != int(layout["payload_length"]):
+            raise ValueError("SNAPSHOT_DATA payload length mismatch")
+        fields: list[str] = []
+        for field in layout["fields"][:13]:
+            chunk = payload[field["offset"]:field["offset"] + field["size"]]
+            fields.append(f"{field['name']}={int.from_bytes(chunk, 'little')}")
+        return "SNAPSHOT_DATA " + ", ".join(fields)
+    return f"type=0x{kind:02X} payload={payload.hex(' ').upper()}"
+
+
+def run_gui() -> int:
+    import tkinter as tk
+    from tkinter import messagebox, ttk
+
+    root = tk.Tk()
+    profile = METADATA["profile"]
+    root.title(f"6400 HEX GUI — {profile}")
+    root.geometry("1180x820")
+    notebook = ttk.Notebook(root)
+    notebook.pack(fill="both", expand=True, padx=8, pady=8)
+    output = tk.StringVar()
+
+    def page(title: str) -> ttk.Frame:
+        frame = ttk.Frame(notebook)
+        notebook.add(frame, text=title)
+        return frame
+
+    summary = page("Build / Contract")
+    facts = [
+        ("Product", "6400-front-rear"), ("Board", "FCB V1.1"),
+        ("Profile", profile), ("CPLD commit", METADATA["commit"]),
+        ("Contract SHA", CONTRACT["contract_sha256"]),
+        ("Bitstream SHA", METADATA["bitstream_sha256"]),
+        ("Host", "RS232/TTL 921600 8N1"), ("BMC", "RS232 115200 8N1"),
+        ("PTC PWM", f"{CONTRACT['fan_control']['pwm']['ptc_hz']} Hz"),
+        ("FAN PWM", f"{CONTRACT['fan_control']['pwm']['fan_hz']} Hz"),
+        ("SET_ALL watchdog", "30 s"), ("Default PID target", "70 C"),
+        ("FAN_BOARD_INVERT_MASK", "0x0F"),
+    ]
+    for row, (key, value) in enumerate(facts):
+        ttk.Label(summary, text=key + ":", width=24).grid(row=row, column=0, sticky="w", padx=8, pady=5)
+        ttk.Label(summary, text=str(value)).grid(row=row, column=1, sticky="w", padx=8, pady=5)
+
+    set_page = page("SET_ALL 32 channels")
+    variables = [tk.IntVar(value=0 if index < 24 else 20) for index in range(32)]
+    labels = [f"PTC{i}" for i in range(24)] + [f"Front{i}" for i in range(4)] + [f"Rear{i}" for i in range(4)]
+    for index, (label, variable) in enumerate(zip(labels, variables)):
+        row, column = divmod(index, 8)
+        cell = ttk.Frame(set_page)
+        cell.grid(row=row, column=column, padx=6, pady=7)
+        ttk.Label(cell, text=label).pack()
+        ttk.Spinbox(cell, from_=0, to=100, width=7, textvariable=variable).pack()
+
+    def make_set_all() -> None:
+        try:
+            output.set(frame_hex(set_all([value.get() for value in variables])))
+        except Exception as exc:
+            messagebox.showerror("SET_ALL", str(exc))
+
+    ttk.Button(set_page, text="Generate SET_ALL", command=make_set_all).grid(row=5, column=0, columnspan=2, pady=10)
+    ttk.Label(set_page, text="Order: PTC0..23, Front0..3, Rear0..3. Values are connector high-level duty.").grid(row=5, column=2, columnspan=6, sticky="w")
+    ttk.Label(set_page, text="MANUAL OPEN-LOOP — BMC TEMPERATURE MAY BE UNAVAILABLE", foreground="red").grid(row=6, column=0, columnspan=8, sticky="w", padx=8)
+    ttk.Label(set_page, text="MANUAL WITHOUT BMC HAS NO BMC-BASED OVERTEMPERATURE PROTECTION", foreground="red").grid(row=7, column=0, columnspan=8, sticky="w", padx=8)
+
+    get_page = page("GET reply 06 -> 82")
+    ttk.Button(get_page, text="Generate GET_SNAPSHOT", command=lambda: output.set(frame_hex(encode(2)))).pack(anchor="w", padx=10, pady=10)
+    ttk.Label(get_page, text="Device replies exactly: 0x06 ACK/NACK, then 0x82 SNAPSHOT_DATA. Banks and Host port remain locked through DATA stop bit.", wraplength=1050).pack(anchor="w", padx=10)
+
+    pid_page = page("SET_PID_TARGET")
+    pid = tk.IntVar(value=70)
+    ttk.Spinbox(pid_page, from_=20, to=70, textvariable=pid, width=8).pack(anchor="w", padx=10, pady=10)
+    ttk.Button(pid_page, text="Generate SET_PID_TARGET", command=lambda: output.set(frame_hex(encode(4, bytes((pid.get(),)))))).pack(anchor="w", padx=10)
+    ttk.Label(pid_page, text="Updates the next PID_AUTO target only; it does not start PID, change Manual output, or feed watchdog.").pack(anchor="w", padx=10, pady=10)
+
+    stimulus = page("0x03 profile behavior")
+    enabled = "Valid SET_STIMULUS preserves type/payload and receives UNSUPPORTED NACK"
+    ttk.Label(stimulus, text=enabled).pack(anchor="w", padx=10, pady=10)
+
+    parser = page("ACK/NACK + Snapshot parser")
+    parse_input = tk.Text(parser, height=8)
+    parse_input.pack(fill="x", padx=10, pady=10)
+    parsed = tk.StringVar()
+    def parse_action() -> None:
+        try:
+            parsed.set(describe(parse_hex(parse_input.get("1.0", "end"))))
+        except Exception as exc:
+            parsed.set("ERROR: " + str(exc))
+    ttk.Button(parser, text="Parse frame", command=parse_action).pack(anchor="w", padx=10)
+    ttk.Label(parser, textvariable=parsed, wraplength=1080).pack(anchor="w", padx=10, pady=10)
+
+    polarity = page("Fan polarity / 20% example")
+    ttk.Label(polarity, text="Contract, GUI, Snapshot, Requested and Applied FAN values are connector-side high-level duty.", wraplength=1050).pack(anchor="w", padx=10, pady=8)
+    ttk.Label(polarity, text="Single adapter mask 0x0F: Front balls are inverted, Rear balls are direct. At connector 20%: each 50,000-clock period has 10,000 connector-high clocks; Front ball low 10,000; Rear ball high 10,000.", wraplength=1050).pack(anchor="w", padx=10, pady=8)
+    for value in (0, 20, 50, 100):
+        ttk.Label(polarity, text=f"Connector {value:3d}% -> Front ball low {value:3d}% / Rear ball high {value:3d}%").pack(anchor="w", padx=10)
+
+    footer = ttk.Frame(root)
+    footer.pack(fill="x", padx=8, pady=(0, 8))
+    ttk.Entry(footer, textvariable=output, font=("Consolas", 9)).pack(side="left", fill="x", expand=True)
+    ttk.Button(footer, text="Copy HEX", command=lambda: (root.clipboard_clear(), root.clipboard_append(output.get()))).pack(side="left", padx=5)
+    make_set_all()
+    root.mainloop()
+    return 0
+
+
+if __name__ == "__main__":
+    raise SystemExit(run_gui())

+ 69 - 0
tools/build_6400_hex_gui.py

@@ -0,0 +1,69 @@
+#!/usr/bin/env python3
+"""Build one profile-specific Windows HEX-only GUI from generated contracts."""
+
+from __future__ import annotations
+
+import argparse
+import hashlib
+import json
+import shutil
+import subprocess
+import sys
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parents[1]
+
+
+def sha(path: Path) -> str:
+    return hashlib.sha256(path.read_bytes()).hexdigest()
+
+
+def main() -> int:
+    parser = argparse.ArgumentParser()
+    parser.add_argument("--profile", choices=("6400-front-rear",), default="6400-front-rear")
+    parser.add_argument("--output-dir", type=Path, required=True)
+    parser.add_argument("--bitstream-sha256", required=True)
+    parser.add_argument("--wsl-source-root")
+    args = parser.parse_args()
+    contract_path = ROOT / "generated/6400/host-contract.json"
+    golden_path = ROOT / "generated/6400/golden-vectors.json"
+    contract = json.loads(contract_path.read_text(encoding="utf-8"))
+    golden = json.loads(golden_path.read_text(encoding="utf-8"))
+    if contract["contract_sha256"] != golden["contract_sha256"]:
+        raise SystemExit("contract/golden SHA mismatch")
+    git_prefix = ["git"]
+    git_cwd = ROOT
+    if args.wsl_source_root:
+        if sys.platform != "win32":
+            raise SystemExit("--wsl-source-root is only valid for the Windows GUI build")
+        git_prefix = ["wsl.exe", "-d", "Debian13", "--cd", args.wsl_source_root, "git"]
+        git_cwd = None
+    commit = subprocess.check_output([*git_prefix, "rev-parse", "HEAD"], cwd=git_cwd, text=True).strip()
+    if subprocess.check_output([*git_prefix, "status", "--porcelain"], cwd=git_cwd, text=True).strip():
+        raise SystemExit("GUI packaging requires an exact clean commit")
+    output = args.output_dir.resolve()
+    output.mkdir(parents=True, exist_ok=True)
+    meta = {"profile": args.profile, "commit": commit, "contract_sha256": contract["contract_sha256"], "bitstream_sha256": args.bitstream_sha256}
+    meta_path = output / "gui-build-metadata.json"
+    meta_path.write_text(json.dumps(meta, indent=2) + "\n", encoding="utf-8")
+    name = f"6400-HEX-GUI-{args.profile}-{commit[:8]}-{contract['contract_sha256'][:8]}"
+    work = output / ("pyinstaller-" + args.profile)
+    sep = ";" if sys.platform == "win32" else ":"
+    command = [sys.executable, "-m", "PyInstaller", "--noconfirm", "--clean", "--onefile", "--windowed",
+        "--name", name, "--distpath", str(output), "--workpath", str(work), "--specpath", str(work),
+        "--add-data", f"{contract_path}{sep}generated/6400", "--add-data", f"{golden_path}{sep}generated/6400",
+        "--add-data", f"{meta_path}{sep}.", str(ROOT / "tools/6400_hex_gui.py")]
+    subprocess.run(command, cwd=ROOT, check=True)
+    exe = output / (name + (".exe" if sys.platform == "win32" else ""))
+    if sys.platform != "win32" or exe.read_bytes()[:2] != b"MZ":
+        raise SystemExit("Windows x64 Python/PyInstaller is required")
+    embedded = json.loads(meta_path.read_text(encoding="utf-8"))
+    if embedded["contract_sha256"] != contract["contract_sha256"]:
+        raise SystemExit("embedded GUI contract SHA mismatch")
+    print(json.dumps({"exe": str(exe), "sha256": sha(exe), **meta}, indent=2))
+    shutil.rmtree(work, ignore_errors=True)
+    return 0
+
+
+if __name__ == "__main__":
+    raise SystemExit(main())

+ 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())

+ 0 - 0
tools/encode_6400_hex.py


Некоторые файлы не были показаны из-за большого количества измененных файлов