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

feat-6400-production-host-safe-control

root 3 месяцев назад
Родитель
Сommit
f47f405079
47 измененных файлов с 1846 добавлено и 2053 удалено
  1. 46 0
      ACTIVE_TASK_LOCK.md
  2. 13 0
      DECISION_TRACE.md
  3. 15 7
      contracts/6400-snapshot.yaml
  4. 29 19
      contracts/6400-wire.yaml
  5. 6 3
      contracts/fan-control-parameters.yaml
  6. 42 74
      docs/architecture/6400-v1-design-lock.md
  7. 1 1
      docs/generated/6400-channel-map.md
  8. 30 47
      docs/prod2u-6400-front-back-protocol.zh-CN.md
  9. 1 1
      generated/6400/channel-map.json
  10. 1 1
      generated/6400/contract-sha256.txt
  11. 1 1
      generated/6400/controller-coefficients.json
  12. 13 6
      generated/6400/fan-control-parameters.json
  13. 1 1
      generated/6400/fixed-point.json
  14. 13 8
      generated/6400/golden-vectors.json
  15. 186 103
      generated/6400/host-contract.json
  16. 49 29
      generated/6400/prod2u_6400_v1_params.vh
  17. 76 27
      generated/6400/snapshot-layout.json
  18. 3 1
      products/6400-control/project.json
  19. 2 2
      products/6400-control/source-closure.json
  20. 1 1
      products/6400-identification/source-closure.json
  21. 1 1
      products/6400-sim-debug/source-closure.json
  22. 3 11
      src/actuator/fan_board_output_adapter.v
  23. 57 94
      src/actuator/pwm_bitmap_engine.v
  24. 40 0
      src/control/manual_set_all_bank.v
  25. 270 989
      src/control/thermal_control_core.v
  26. 47 15
      src/telemetry/thermal_snapshot_mux.v
  27. 38 27
      src/top/prod2u_6400_v1_top.v
  28. 172 148
      src/transport/thermal_host_command.v
  29. 1 1
      td/syn/prod2u_6400_front_back.tcl
  30. 1 1
      td/syn/prod2u_6400_identification.tcl
  31. 1 1
      tests/cocotb/prod2u_6400_v1_cocotb_top.v
  32. 1 1
      tests/cocotb/run_6400_v1_integration.py
  33. 71 218
      tests/cocotb/test_6400_v1_host_protocol_integration.py
  34. 4 5
      tests/cocotb/thermal_6400_uart.py
  35. 30 13
      tests/sim/pwm_bitmap_engine_tb.v
  36. 93 137
      tests/sim/thermal_control_core_tb.v
  37. 98 0
      tests/sim/thermal_host_command_v2_tb.v
  38. 35 0
      tests/unit/test_6400_hex_gui_v2.py
  39. 2 3
      tests/unit/test_6400_profile_package.py
  40. 17 16
      tests/unit/test_6400_v1_contract.py
  41. 2 1
      tests/unit/test_6400_v1_source_closure.py
  42. 3 4
      tests/unit/test_encode_6400_hex.py
  43. 189 0
      tools/6400_hex_gui.py
  44. 61 0
      tools/build_6400_hex_gui.py
  45. 24 7
      tools/encode_6400_hex.py
  46. 54 27
      tools/generate_6400_v1.py
  47. 2 1
      tools/run_6400_v1.py

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

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

+ 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 - 19
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,43 @@ 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
+    response: ACK_NACK
     profiles: [6400-identification, 6400-sim-debug]
+    production_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

+ 6 - 3
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}
+duty: {reset: 20, boot: 20, standby: 20, watchdog: 20, pid_wait_sensor: 20, ordinary_fault: 20, 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
+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 - 74
docs/architecture/6400-v1-design-lock.md

@@ -1,92 +1,60 @@
-# 6400-front-rear-v1 design lock
+# 6400-front-rear-v1 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_WAIT, standby, watchdog transition, PID_WAIT_SENSOR and ordinary non-overtemperature global fault atomically apply PTC0/FAN20.
+- BMC absence or stale data never integrates and never requests full speed.
+- Only a confirmed sampled lane temperature at or above 77 C may latch HARD_PROTECT and apply lane PTC0/FAN100.
+- Requested and Applied banks are separate; a safety override cannot weaken the required protection.
 
-## Host wire protocol
+## Modes 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.
+- Modes: BOOT_WAIT, MANUAL_SET_ALL, PID_WAIT_SENSOR, PID_AUTO, HARD_PROTECT.
+- Reset: BOOT_WAIT, PID off, PTC0/FAN20, watchdog elapsed zero, PID target 70 C.
+- First 10-second watchdog expiry commits safe duty, clears PI and enters PID_WAIT_SENSOR.
+- A new complete valid BMC epoch starts PID_AUTO. No BMC means no integration.
+- Legal SET_ALL atomically enters MANUAL_SET_ALL, stops/clears PID, reloads 10 seconds and ACKs after the PWM-boundary commit. Identical SET_ALL also commits/feeds/ACKs.
+- Manual expiry commits safe duty, clears PI and enters PID_WAIT_SENSOR. 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`, unchanged 33-byte payload. Identification/Sim Debug retain it; Production 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.
-
-## PI and supervision
-
-- 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.
-
-## 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.
+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.
 
 ## 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.
+- `6400-control`: production, `0x03` valid request returns UNSUPPORTED.
+- `6400-identification`: `0x03` enabled with unchanged payload and safety path.
+- `6400-sim-debug`: accelerated simulation, never production source closure.
 
-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.
+HEX GUIs are profile-specific, generate/parse HEX only, never open a serial port, and embed the same generated Host Contract/Golden Vector SHA as the firmware package.

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

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

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

@@ -1,63 +1,46 @@
-# 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 字节 | Identification/Sim Debug 保留;Production 对合法请求返回 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、改 Mode 或喂狗。合法值写入 inactive bank,在 PWM 安全边界原子切换,进入 MANUAL_SET_ALL,清 PI、reload 10 秒,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 直连,不反相 |
+## 模式与安全输出
 
-生产向量固定为 Front0..3 后 Rear0..3,`FAN_BOARD_INVERT_MASK=0x0F`。500 Hz、10% Standby、PWM High Level 仍是 `EXPERIMENTAL_UNVERIFIED`;实际 RPM、风量和硬件验证均 `NOT RUN`。
+- 模式:BOOT_WAIT、MANUAL_SET_ALL、PID_WAIT_SENSOR、PID_AUTO、HARD_PROTECT。
+- Reset/Boot/Standby/watchdog/PID 等待/普通非过温 global fault:PTC0、Front/Rear FAN20。
+- 只有确认采样达到 77 C 的 lane 可以进入 HARD_PROTECT:该 lane PTC0、Front/Rear FAN100。
+- BMC 无有效数据时不积分、不全速。第一次 Boot watchdog timeout 以及 Manual timeout 都原子提交安全值、清 PI、进入 PID_WAIT_SENSOR;新完整有效 BMC epoch 后进入 PID_AUTO。
+- 只有合法并完成原子提交的 SET_ALL 喂 10 秒 watchdog;SET_ALL commit 与最后 timeout tick 同周期时 SET_ALL 优先。
 
-## 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": "e8f8a5885411ae109b465fe88bf7327e8bbcee27583b8bd77948155fdc14d26a",
   "fan_output_vector_order": [
     "front0",
     "front1",

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

@@ -1 +1 @@
-9b2df5161fb37e4b84af8337c5e99a78e27b6058934a245068afd2d533468def
+e8f8a5885411ae109b465fe88bf7327e8bbcee27583b8bd77948155fdc14d26a

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

@@ -17,7 +17,7 @@
       ]
     }
   },
-  "contract_sha256": "9b2df5161fb37e4b84af8337c5e99a78e27b6058934a245068afd2d533468def",
+  "contract_sha256": "e8f8a5885411ae109b465fe88bf7327e8bbcee27583b8bd77948155fdc14d26a",
   "limits_centi_degC": {
     "hard": 7700,
     "pretrip": 7600,

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

@@ -1,19 +1,26 @@
 {
   "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": "e8f8a5885411ae109b465fe88bf7327e8bbcee27583b8bd77948155fdc14d26a",
   "duty": {
+    "boot": 20,
     "hard": 100,
     "nominal": 30,
+    "ordinary_fault": 20,
+    "pid_wait_sensor": 20,
     "protection": 80,
-    "reset": 10,
-    "stopped": 10,
-    "warm": 50
+    "reset": 20,
+    "standby": 20,
+    "warm": 50,
+    "watchdog": 20
   },
   "front_rear_independent": true,
   "invalid_lane_threshold": 2,
+  "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,7 +30,7 @@
     "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,

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

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

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

@@ -1,14 +1,19 @@
 {
-  "contract_sha256": "9b2df5161fb37e4b84af8337c5e99a78e27b6058934a245068afd2d533468def",
+  "contract_sha256": "e8f8a5885411ae109b465fe88bf7327e8bbcee27583b8bd77948155fdc14d26a",
   "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"
 }

+ 186 - 103
generated/6400/host-contract.json

@@ -2,8 +2,9 @@
   "canonical_profiles": {
     "6400-control": {
       "allowed_commands": [
-        "SET_TARGET",
-        "GET_SNAPSHOT"
+        "SET_ALL",
+        "GET_SNAPSHOT",
+        "SET_PID_TARGET"
       ],
       "production": true,
       "simulation_only": false,
@@ -11,9 +12,10 @@
     },
     "6400-identification": {
       "allowed_commands": [
-        "SET_TARGET",
+        "SET_ALL",
         "GET_SNAPSHOT",
-        "SET_STIMULUS"
+        "SET_STIMULUS",
+        "SET_PID_TARGET"
       ],
       "production": false,
       "simulation_only": false,
@@ -21,9 +23,10 @@
     },
     "6400-sim-debug": {
       "allowed_commands": [
-        "SET_TARGET",
+        "SET_ALL",
         "GET_SNAPSHOT",
-        "SET_STIMULUS"
+        "SET_STIMULUS",
+        "SET_PID_TARGET"
       ],
       "production": false,
       "simulation_only": true,
@@ -713,7 +716,7 @@
     "product": "6400-front-rear-v1",
     "schema": "prod2u-6400-channel-map-v1"
   },
-  "contract_sha256": "9b2df5161fb37e4b84af8337c5e99a78e27b6058934a245068afd2d533468def",
+  "contract_sha256": "e8f8a5885411ae109b465fe88bf7327e8bbcee27583b8bd77948155fdc14d26a",
   "controller_coefficients": {
     "classes": {
       "CENTER": {
@@ -752,18 +755,25 @@
   "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,
+      "ordinary_fault": 20,
+      "pid_wait_sensor": 20,
       "protection": 80,
-      "reset": 10,
-      "stopped": 10,
-      "warm": 50
+      "reset": 20,
+      "standby": 20,
+      "warm": 50,
+      "watchdog": 20
     },
     "front_rear_independent": true,
     "invalid_lane_threshold": 2,
+    "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,7 +783,7 @@
       "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,
@@ -816,26 +826,31 @@
     }
   },
   "golden_vectors": {
-    "contract_sha256": "9b2df5161fb37e4b84af8337c5e99a78e27b6058934a245068afd2d533468def",
+    "contract_sha256": "e8f8a5885411ae109b465fe88bf7327e8bbcee27583b8bd77948155fdc14d26a",
     "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": "e8f8a5885411ae109b465fe88bf7327e8bbcee27583b8bd77948155fdc14d26a",
     "fields": [
       {
-        "name": "control_state",
+        "name": "mode",
         "offset": 0,
         "size": 1,
         "type": "u8"
@@ -847,149 +862,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 +1063,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 +1148,13 @@
           }
         ],
         "payload_length": 33,
+        "production_behavior": "UNSUPPORTED",
         "profiles": [
           "6400-identification",
           "6400-sim-debug"
         ],
-        "response": "SET_STIMULUS_ACK",
+        "response": "ACK_NACK",
         "type": 3
-      },
-      "SET_TARGET": {
-        "payload_length": 1,
-        "response": "SET_TARGET_ACK",
-        "type": 1,
-        "valid": [
-          0,
-          "20-70"
-        ]
       }
     },
     "crc": {
@@ -1077,31 +1168,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 +1205,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"
   }
 }

+ 49 - 29
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: e8f8a5885411ae109b465fe88bf7327e8bbcee27583b8bd77948155fdc14d26a
 `define FB_CLOCK_HZ 25000000
 `define FB_PTC_COUNT 24
 `define FB_FRONT_FAN_COUNT 4
@@ -28,14 +28,18 @@
 `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_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_SOFT 7400
 `define FB_TEMP_PRETRIP 7600
 `define FB_TEMP_HARD 7700
@@ -44,29 +48,45 @@
 `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 SET_ALL_WATCHDOG_SECONDS 10
+`define DEFAULT_PID_TARGET_C 70
+`define FB_MODE_BOOT_WAIT 3'd0
+`define FB_MODE_MANUAL_SET_ALL 3'd1
+`define FB_MODE_PID_WAIT_SENSOR 3'd2
+`define FB_MODE_PID_AUTO 3'd3
+`define FB_MODE_HARD_PROTECT 3'd4
+`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": "e8f8a5885411ae109b465fe88bf7327e8bbcee27583b8bd77948155fdc14d26a",
   "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"]
 }

+ 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"]
 }

+ 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

+ 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

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


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

+ 38 - 27
src/top/prod2u_6400_v1_top.v

@@ -45,8 +45,13 @@ 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 manual_wr_en;
+    wire [4:0] manual_wr_addr;
+    wire [7:0] manual_wr_data;
+    wire manual_commit;
+    wire manual_commit_done;
+    wire pid_target_commit;
+    wire [7:0] pid_target_celsius;
     wire stimulus_wr_en;
     wire [4:0] stimulus_wr_addr;
     wire [7:0] stimulus_wr_data;
@@ -64,6 +69,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,7 +153,6 @@ 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;
@@ -154,8 +160,11 @@ module prod2u_6400_v1_top #(
     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 +172,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)
     );
@@ -219,14 +215,20 @@ module prod2u_6400_v1_top #(
         .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),
+        .manual_wr_en(manual_wr_en), .manual_wr_addr(manual_wr_addr),
+        .manual_wr_data(manual_wr_data), .manual_commit(manual_commit),
+        .manual_commit_done(manual_commit_done), .safety_locked(hard_protect),
+        .pid_target_commit(pid_target_commit), .pid_target_celsius(pid_target_celsius),
         .stimulus_wr_en(stimulus_wr_en), .stimulus_wr_addr(stimulus_wr_addr),
         .stimulus_wr_data(stimulus_wr_data), .stimulus_commit(stimulus_commit),
         .stimulus_duration_seconds(stimulus_duration), .snapshot_capture(snapshot_capture),
         .snapshot_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),
@@ -297,10 +299,14 @@ module prod2u_6400_v1_top #(
 
     thermal_control_core #(
         .ENABLE_STIMULUS(ENABLE_STIMULUS),
-        .FAN_STANDBY_DUTY(FAN_STANDBY_DUTY)
+        .FAN_SAFE_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),
+        .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),
+        .pid_target_commit(pid_target_commit), .pid_target_celsius(pid_target_celsius),
+        .stimulus_wr_en(stimulus_wr_en),
         .stimulus_wr_addr(stimulus_wr_addr), .stimulus_wr_data(stimulus_wr_data),
         .stimulus_commit(stimulus_commit), .stimulus_duration_seconds(stimulus_duration),
         .bmc_epoch(bmc_epoch), .bmc_stale(bmc_stale), .bmc_valid_mask(bmc_valid_mask),
@@ -312,9 +318,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),
+        .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 +342,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)
@@ -350,7 +361,7 @@ module prod2u_6400_v1_top #(
         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};
+        boot_init_complete, watchdog_active, watchdog_remaining, pid_running, manual_mode, hard_protect};
 
 `ifdef FORMAL
     always @(posedge sys_clk) begin

+ 172 - 148
src/transport/thermal_host_command.v

@@ -1,8 +1,11 @@
 `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,53 +16,84 @@ 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        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       safety_locked,
+    output reg        pid_target_commit,
+    output reg  [7:0] pid_target_celsius,
     output reg        stimulus_wr_en,
-    output reg [4:0]  stimulus_wr_addr,
-    output reg [7:0]  stimulus_wr_data,
+    output reg  [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  [7:0] stimulus_duration_seconds,
     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_STIM_DURATION = 6, ST_STIM_VALIDATE = 7, ST_STIM_WRITE = 8,
+        ST_STIM_COMMIT = 9, ST_SNAPSHOT_WAIT = 10, ST_ACK_TX = 11,
+        ST_SNAPSHOT_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;
+            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;
             stimulus_wr_en <= 0;
             stimulus_wr_addr <= 0;
             stimulus_wr_data <= 0;
@@ -67,11 +101,17 @@ module thermal_host_command #(
             stimulus_duration_seconds <= 0;
             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;
+            manual_wr_en <= 0;
+            manual_commit <= 0;
+            pid_target_commit <= 0;
             stimulus_wr_en <= 0;
             stimulus_commit <= 0;
             snapshot_capture <= 0;
@@ -79,88 +119,130 @@ module thermal_host_command #(
             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 if (ENABLE_STIMULUS == 0)
+                            start_ack(0, frame_type, `FB_STATUS_UNSUPPORTED, 0);
+                        else begin
+                            index <= 0;
+                            payload_read_addr <= 0;
+                            state <= ST_STIM_DURATION;
+                        end
+                    end else if (frame_type == `FB_CMD_SET_PID_TARGET) begin
+                        if (frame_length != 1)
+                            start_ack(0, frame_type, `FB_STATUS_BAD_LENGTH, 1);
+                        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_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_SNAPSHOT_WAIT: if (snapshot_ready) begin
-                    tx_frame_type <= 8'h82;
-                    tx_payload_length <= 0;
-                    tx_start <= 1;
-                    state <= ST_SNAPSHOT_ACK_TX;
+                ST_SET_COMMIT: begin
+                    manual_commit <= 1;
+                    state <= ST_SET_WAIT;
+                end
+                ST_SET_WAIT: if (manual_commit_done)
+                    start_ack(1, `FB_CMD_SET_ALL, `FB_STATUS_OK, 0);
+                ST_PID_READ: begin
+                    if (payload_read_data < 20 || payload_read_data > 70)
+                        start_ack(0, `FB_CMD_SET_PID_TARGET, `FB_STATUS_BAD_VALUE, 0);
+                    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_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;
+                    if (payload_read_data == 0)
+                        start_ack(0, `FB_CMD_SET_STIMULUS, `FB_STATUS_BAD_VALUE, 0);
+                    else begin
+                        index <= 1;
+                        payload_read_addr <= 1;
+                        state <= ST_STIM_VALIDATE;
+                    end
                 end
-                ST_STIM_DATA: begin
-                    if (payload_read_data > 100) begin
-                        stimulus_bad <= 1;
+                ST_STIM_VALIDATE: begin
+                    if (payload_read_data > 100)
+                        start_ack(0, `FB_CMD_SET_STIMULUS, `FB_STATUS_BAD_VALUE, {2'd0, index});
+                    else if (index == 32) begin
+                        index <= 1;
+                        payload_read_addr <= 1;
+                        state <= ST_STIM_WRITE;
                     end else begin
-                        stimulus_wr_en <= 1;
-                        stimulus_wr_addr <= index[4:0] - 1'b1;
-                        stimulus_wr_data <= payload_read_data;
+                        index <= index + 1'b1;
+                        payload_read_addr <= index + 1'b1;
                     end
-                    if (index == 32) begin
-                        state <= ST_STIM_COMMIT;
-                    end else begin
+                end
+                ST_STIM_WRITE: begin
+                    stimulus_wr_en <= 1;
+                    stimulus_wr_addr <= index[4:0] - 1'b1;
+                    stimulus_wr_data <= payload_read_data;
+                    if (index == 32) state <= ST_STIM_COMMIT;
+                    else begin
                         index <= index + 1'b1;
-                        payload_read_addr <= {2'b00, index} + 1'b1;
+                        payload_read_addr <= index + 1'b1;
                     end
                 end
                 ST_STIM_COMMIT: begin
-                    if (!stimulus_bad) begin
-                        stimulus_commit <= 1;
-                        tx_frame_type <= 8'h83;
-                        tx_payload_length <= 0;
+                    stimulus_commit <= 1;
+                    start_ack(1, `FB_CMD_SET_STIMULUS, `FB_STATUS_OK, 0);
+                end
+                ST_SNAPSHOT_WAIT: if (snapshot_ready)
+                    start_ack(1, `FB_CMD_GET_SNAPSHOT, `FB_STATUS_OK, 0);
+                ST_ACK_TX: if (tx_done) begin
+                    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 +252,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 - 1
td/syn/prod2u_6400_front_back.tcl

@@ -36,10 +36,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 - 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 - 1
tests/cocotb/prod2u_6400_v1_cocotb_top.v

@@ -123,7 +123,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;

+ 1 - 1
tests/cocotb/run_6400_v1_integration.py

@@ -70,7 +70,7 @@ def main(argv: list[str] | None = None) -> int:
     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")
+    profiles = args.profiles or ("host_protocol",)
     stimulus = {"control": 0, "identification": 1, "host_protocol": 0}
     with tempfile.TemporaryDirectory(prefix="prod2u-6400-cocotb-") as directory:
         root = Path(directory)

+ 71 - 218
tests/cocotb/test_6400_v1_host_protocol_integration.py

@@ -1,239 +1,92 @@
-"""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)
+
+    # 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

+ 4 - 5
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")

+ 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

+ 93 - 137
tests/sim/thermal_control_core_tb.v

@@ -1,187 +1,143 @@
 `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, 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),
+        .clk(clk), .rst_n(rst_n), .tick_1s(tick),
+        .manual_wr_en(manual_wr), .manual_wr_addr(manual_addr),
+        .manual_wr_data(manual_data), .manual_commit(manual_commit),
+        .manual_commit_done(manual_done), .pid_target_commit(pid_commit),
+        .pid_target_celsius(pid_target), .stimulus_wr_en(1'b0),
+        .stimulus_wr_addr(0), .stimulus_wr_data(0), .stimulus_commit(1'b0),
+        .stimulus_duration_seconds(0), .bmc_epoch(bmc_epoch),
+        .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),
+        .stimulus_active(), .watchdog_active(watchdog_active),
+        .watchdog_remaining(watchdog_remaining), .pid_running(pid_running),
+        .manual_mode(manual_mode), .hard_protect(hard_protect),
         .pwm_phase_boundary(1'b1), .pwm_scan_idle(1'b1), .boot_init_complete()
     );
 
-    task next_bmc_epoch;
-        begin
-            @(negedge clk); bmc_epoch = bmc_epoch + 1'b1;
-            repeat (3) @(negedge clk);
-        end
+    task one_tick;
+        begin @(negedge clk); tick = 1; @(negedge clk); tick = 0; end
     endtask
-
-    task wait_commit_after;
-        input integer old_count;
+    task wait_commit;
+        input integer prior;
         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 (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 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 != 3 || !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 != 3) $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;
-        i = commits;
-        next_bmc_epoch();
-        wait_commit_after(i);
-        if (!global_fault || !lane_fault[0] || state !== 5) $fatal;
+        // SET_ALL atomically enters Manual, resets PI and reloads 10 seconds.
+        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_commit(i);
+        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 !== 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);
+        @(negedge clk); manual_commit = 1; tick = 1;
+        @(negedge clk); manual_commit = 0; tick = 0;
+        wait_commit(i);
+        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);
-        check_duty(0, 4);
-        $display("PASS: thermal_control_core_tb");
+        repeat (10) one_tick();
+        wait_commit(i);
+        if (mode != 2 || manual_mode) $fatal;
+        check_duty(0, 0); check_duty(24, 20);
+
+        // Only confirmed 77 C hard protection may force lane fans to 100.
+        bmc_raw[0] = {8'd77, 8'd0}; bmc_epoch = 2;
+        i = commits; wait_commit(i);
+        if (mode != 4 || !hard_protect || !lane_fault[0]) $fatal;
+        check_duty(0, 0); check_duty(24, 100); check_duty(28, 100);
+        check_duty(25, 30);
+        $display("PASS: boot/manual/watchdog/PID wait/77C hard-protect modes");
         $finish;
     end
 endmodule

+ 98 - 0
tests/sim/thermal_host_command_v2_tb.v

@@ -0,0 +1,98 @@
+`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, snapshot_ready = 0;
+    wire manual_wr, manual_commit, pid_commit, stimulus_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 #(.ENABLE_STIMULUS(0), .SNAPSHOT_LENGTH(201)) dut (
+        .clk(clk), .rst_n(rst_n), .frame_valid(frame_valid), .frame_ready(),
+        .frame_accept_enable(), .frame_type(frame_type), .frame_length(frame_length),
+        .payload_read_addr(payload_addr), .payload_read_data(payload[payload_addr]),
+        .manual_wr_en(manual_wr), .manual_wr_addr(manual_wr_addr),
+        .manual_wr_data(manual_wr_data), .manual_commit(manual_commit),
+        .manual_commit_done(manual_done), .safety_locked(safety_locked),
+        .pid_target_commit(pid_commit), .pid_target_celsius(pid_target),
+        .stimulus_wr_en(), .stimulus_wr_addr(), .stimulus_wr_data(),
+        .stimulus_commit(stimulus_commit), .stimulus_duration_seconds(),
+        .snapshot_capture(snapshot_capture), .snapshot_ready(snapshot_ready),
+        .tx_start(tx_start), .tx_frame_type(tx_type), .tx_payload_length(tx_length),
+        .tx_payload_addr(tx_payload_addr), .ack_payload_data(ack_data),
+        .tx_done(tx_done), .transaction_done(transaction_done), .busy(busy)
+    );
+
+    task request;
+        input [7:0] kind;
+        input [7:0] length;
+        begin
+            @(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");
+            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");
+
+        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);
+
+        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

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

+ 2 - 3
tests/unit/test_6400_profile_package.py

@@ -145,9 +145,8 @@ def test_control_source_package_contains_only_active_grouped_closure(tmp_path: P
     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["wire"]["responses"]["ACK_NACK"]["type"] == 0x06
+    assert host_contract["wire"]["responses"]["SNAPSHOT_DATA"]["type"] == 0x82
     assert host_contract["canonical_profiles"]["6400-control"]["stimulus"] is False
     assert not any(name.startswith("src/generated/6400/") for name in names)
     assert not any("prod2u_6400_front_back_top" in name for name in names)

+ 17 - 16
tests/unit/test_6400_v1_contract.py

@@ -89,7 +89,8 @@ def test_fan_contract_drives_params_active_adc_and_both_td_profiles() -> None:
 
     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
 
@@ -128,31 +129,31 @@ 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
+    assert "SET_ALL_WATCHDOG_SECONDS 10" in (ROOT / "generated/6400/prod2u_6400_v1_params.vh").read_text()
+    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:

+ 2 - 1
tests/unit/test_6400_v1_source_closure.py

@@ -15,7 +15,8 @@ def test_production_closure_excludes_legacy_and_stimulus_wrapper() -> None:
         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/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" in closure["sources"]
 
     runner = (ROOT / "tools/run_6400_v1.py").read_text(encoding="utf-8")

+ 3 - 4
tests/unit/test_encode_6400_hex.py

@@ -8,12 +8,11 @@ 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.set_all("6400-control", [0] * 24, [20] * 4, [20] * 4).hex().upper() == golden["set_all_safe"]
+    assert encoder.set_pid_target("6400-control", 70).hex().upper() == golden["set_pid_target_70"]
     assert encoder.get_snapshot("6400-control").hex().upper() == golden["get_snapshot"]
 
 

+ 189 - 0
tools/6400_hex_gui.py

@@ -0,0 +1,189 @@
+#!/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 = [
+        ("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"),
+        ("PWM", f"{CONTRACT['fan_control']['pwm']['fan_hz']} Hz"),
+        ("SET_ALL watchdog", "10 s"), ("Default PID target", "70 C"),
+    ]
+    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")
+
+    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 = "SET_STIMULUS enabled with unchanged 33-byte payload" if profile != "6400-control" else "Production: valid SET_STIMULUS receives UNSUPPORTED NACK"
+    ttk.Label(stimulus, text=enabled).pack(anchor="w", padx=10, pady=10)
+    if profile != "6400-control":
+        duration = tk.IntVar(value=1)
+        ttk.Spinbox(stimulus, from_=1, to=255, textvariable=duration, width=8).pack(anchor="w", padx=10)
+        ttk.Button(stimulus, text="Generate SET_STIMULUS from current 32 duties", command=lambda: output.set(frame_hex(encode(3, bytes((duration.get(),)) + bytes(v.get() for v in variables))))).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())

+ 61 - 0
tools/build_6400_hex_gui.py

@@ -0,0 +1,61 @@
+#!/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-control", "6400-identification"), required=True)
+    parser.add_argument("--output-dir", type=Path, required=True)
+    parser.add_argument("--bitstream-sha256", required=True)
+    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")
+    commit = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=ROOT, text=True).strip()
+    if subprocess.check_output(["git", "status", "--porcelain"], cwd=ROOT, 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())

+ 24 - 7
tools/encode_6400_hex.py

@@ -45,10 +45,16 @@ class Encoder:
             raise ValueError(f"{command} is not supported by {profile}")
         return int(self.commands[command]["type"])
 
-    def set_target(self, profile: str, target_celsius: int) -> bytes:
-        if target_celsius != 0 and not 20 <= target_celsius <= 70:
-            raise ValueError("target must be 0 or 20..70 C")
-        return frame(self._type(profile, "SET_TARGET"), bytes((target_celsius,)))
+    def set_all(self, profile: str, ptc: Iterable[int], front: Iterable[int], rear: Iterable[int]) -> bytes:
+        values = [*ptc, *front, *rear]
+        if len(values) != 32 or any(not 0 <= value <= 100 for value in values):
+            raise ValueError("SET_ALL requires 24 PTC + 4 Front + 4 Rear values in 0..100")
+        return frame(self._type(profile, "SET_ALL"), bytes(values))
+
+    def set_pid_target(self, profile: str, target_celsius: int) -> bytes:
+        if not 20 <= target_celsius <= 70:
+            raise ValueError("PID target must be 20..70 C")
+        return frame(self._type(profile, "SET_PID_TARGET"), bytes((target_celsius,)))
 
     def get_snapshot(self, profile: str) -> bytes:
         return frame(self._type(profile, "GET_SNAPSHOT"))
@@ -92,8 +98,12 @@ def main(argv: list[str] | None = None) -> int:
     parser.add_argument("--contract", type=Path, default=DEFAULT_CONTRACT)
     parser.add_argument("--profile", required=True)
     subparsers = parser.add_subparsers(dest="command", required=True)
-    target_parser = subparsers.add_parser("set-target")
+    target_parser = subparsers.add_parser("set-pid-target")
     target_parser.add_argument("celsius", type=int)
+    set_all_parser = subparsers.add_parser("set-all")
+    set_all_parser.add_argument("--ptc", required=True)
+    set_all_parser.add_argument("--front", required=True)
+    set_all_parser.add_argument("--rear", required=True)
     subparsers.add_parser("get-snapshot")
     stimulus_parser = subparsers.add_parser("set-stimulus")
     stimulus_parser.add_argument("--duration", type=int, required=True)
@@ -103,8 +113,15 @@ def main(argv: list[str] | None = None) -> int:
     args = parser.parse_args(argv)
 
     encoder = Encoder(args.contract)
-    if args.command == "set-target":
-        result = encoder.set_target(args.profile, args.celsius)
+    if args.command == "set-pid-target":
+        result = encoder.set_pid_target(args.profile, args.celsius)
+    elif args.command == "set-all":
+        result = encoder.set_all(
+            args.profile,
+            percent_list(args.ptc, 24, "PTC"),
+            percent_list(args.front, 4, "Front"),
+            percent_list(args.rear, 4, "Rear"),
+        )
     elif args.command == "get-snapshot":
         result = encoder.get_snapshot(args.profile)
     else:

+ 54 - 27
tools/generate_6400_v1.py

@@ -104,8 +104,12 @@ def validate_wire(wire: dict[str, Any], snapshot_size: int) -> None:
         raise ValueError("device/clock drift")
     if wire["host_uart"]["baud"] != 921_600 or wire["bmc_uart"]["baud"] != 115_200:
         raise ValueError("UART baud drift")
-    if wire["commands"]["SET_TARGET"]["payload_length"] != 1:
-        raise ValueError("SET_TARGET length drift")
+    expected_ids = {"SET_ALL": 0x01, "GET_SNAPSHOT": 0x02, "SET_STIMULUS": 0x03, "SET_PID_TARGET": 0x04}
+    actual_ids = {name: int(value["type"]) for name, value in wire["commands"].items()}
+    if actual_ids != expected_ids or len(set(actual_ids.values())) != len(actual_ids):
+        raise ValueError("active command registry drift or duplicate command id")
+    if wire["commands"]["SET_ALL"]["payload_length"] != 32:
+        raise ValueError("SET_ALL length drift")
     stimulus_fields = wire["commands"]["SET_STIMULUS"].get("payload_fields", [])
     expected_stimulus_fields = [
         {"name": "duration_seconds", "offset": 0, "count": 1, "minimum": 1, "maximum": 255, "unit": "seconds"},
@@ -115,15 +119,18 @@ def validate_wire(wire: dict[str, Any], snapshot_size: int) -> None:
     ]
     if stimulus_fields != expected_stimulus_fields:
         raise ValueError("SET_STIMULUS payload layout drift")
-    if wire["responses"]["GET_SNAPSHOT_ACK"] != {"type": 0x82, "payload_length": 0}:
-        raise ValueError("GET_SNAPSHOT independent ACK drift")
-    if wire["responses"]["SNAPSHOT_DATA"].get("type") != 0x42:
-        raise ValueError("SNAPSHOT_DATA must be request type OR 0x40")
+    ack = wire["responses"]["ACK_NACK"]
+    if ack.get("type") != 0x06 or ack.get("payload_length") != 4:
+        raise ValueError("unified ACK/NACK drift")
+    if ack.get("payload") != ["ok", "request_type", "status", "detail"]:
+        raise ValueError("ACK/NACK payload drift")
+    if wire["responses"]["SNAPSHOT_DATA"].get("type") != 0x82:
+        raise ValueError("SNAPSHOT_DATA type drift")
     if wire["responses"]["SNAPSHOT_DATA"].get("payload_length", snapshot_size) != snapshot_size:
         raise ValueError("snapshot length drift")
-    forbidden = set(wire.get("forbidden_fields", []))
-    if not {"protocol_version", "project_id", "sequence", "nack"}.issubset(forbidden):
-        raise ValueError("forbidden field list incomplete")
+    pid = wire["commands"]["SET_PID_TARGET"]
+    if (pid.get("payload_length"), pid.get("minimum"), pid.get("maximum"), pid.get("default")) != (1, 20, 70, 70):
+        raise ValueError("PID target contract drift")
 
 
 def validate_fans(mapping: dict[str, Any], fan: dict[str, Any]) -> None:
@@ -173,10 +180,13 @@ def validate_fans(mapping: dict[str, Any], fan: dict[str, Any]) -> None:
         raise ValueError("current PTC/FAN PWM frequencies must independently equal 500 Hz")
     if pwm.get("ptc_phase_clks") != 500 or pwm.get("fan_phase_clks") != 500:
         raise ValueError("current PTC/FAN phase clocks must independently equal 500")
-    if pwm.get("carrier_backend") != "shared_equal_frequency_v1":
+    if pwm.get("carrier_backend") != "shared_equal_frequency_control_reset_independent_v2":
         raise ValueError("current equal-frequency carrier backend drift")
-    if fan["duty"].get("reset") != 10 or fan["duty"].get("stopped") != 10:
-        raise ValueError("reset and STOPPED fan standby duty must remain 10")
+    safe_states = ("reset", "boot", "standby", "watchdog", "pid_wait_sensor", "ordinary_fault")
+    if any(fan["duty"].get(name) != 20 for name in safe_states):
+        raise ValueError("all non-hard-protect safe fan duties must remain 20")
+    if fan.get("board_invert_mask") != 0x0F or fan.get("connector_duty_semantics") != "high_level_percent":
+        raise ValueError("connector fan duty / board invert contract drift")
 
 
 def crc16(data: bytes) -> int:
@@ -249,13 +259,17 @@ def verilog_header(layout_rows: list[dict[str, Any]], snapshot_size: int, wire:
         f"`define REAR_FAN_FPGA_BALL_MAP \"{ball_map(rear_rows)}\"",
         f"`define FB_BOARD_ID \"{mapping['board']['id']}\"",
         f"`define FB_BOARD_EVIDENCE_SHA256 \"{mapping['board']['evidence_sha256']}\"",
-        f"`define FB_CMD_SET_TARGET 8'h{int(command['SET_TARGET']['type']):02X}",
+        f"`define FB_CMD_SET_ALL 8'h{int(command['SET_ALL']['type']):02X}",
         f"`define FB_CMD_GET_SNAPSHOT 8'h{int(command['GET_SNAPSHOT']['type']):02X}",
         f"`define FB_CMD_SET_STIMULUS 8'h{int(command['SET_STIMULUS']['type']):02X}",
-        f"`define FB_RSP_SET_TARGET_ACK 8'h{int(response['SET_TARGET_ACK']['type']):02X}",
-        f"`define FB_RSP_GET_SNAPSHOT_ACK 8'h{int(response['GET_SNAPSHOT_ACK']['type']):02X}",
+        f"`define FB_CMD_SET_PID_TARGET 8'h{int(command['SET_PID_TARGET']['type']):02X}",
+        f"`define FB_RSP_ACK_NACK 8'h{int(response['ACK_NACK']['type']):02X}",
         f"`define FB_RSP_SNAPSHOT_DATA 8'h{int(response['SNAPSHOT_DATA']['type']):02X}",
-        f"`define FB_RSP_STIMULUS_ACK 8'h{int(response['SET_STIMULUS_ACK']['type']):02X}",
+        "`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",
         f"`define FB_SNAPSHOT_LENGTH {snapshot_size}",
         f"`define FB_TEMP_SOFT {int(limits['soft'])}",
         f"`define FB_TEMP_PRETRIP {int(limits['pretrip'])}",
@@ -265,9 +279,17 @@ def verilog_header(layout_rows: list[dict[str, Any]], snapshot_size: int, wire:
         f"`define FB_EDGE_KI_Q4_12 {int(classes['EDGE']['ki_q4_12'])}",
         f"`define FB_CENTER_KP_Q4_12 {int(classes['CENTER']['kp_q4_12'])}",
         f"`define FB_CENTER_KI_Q4_12 {int(classes['CENTER']['ki_q4_12'])}",
-        f"`define FAN_STANDBY_DUTY {int(fan['duty']['reset'])}",
+        f"`define FAN_SAFE_DUTY {int(fan['duty']['reset'])}",
+        "`define FAN_STANDBY_DUTY `FAN_SAFE_DUTY",
         "`define FB_FAN_RESET `FAN_STANDBY_DUTY",
         f"`define FB_FAN_HARD {int(fan['duty']['hard'])}",
+        "`define SET_ALL_WATCHDOG_SECONDS 10",
+        "`define DEFAULT_PID_TARGET_C 70",
+        "`define FB_MODE_BOOT_WAIT 3'd0",
+        "`define FB_MODE_MANUAL_SET_ALL 3'd1",
+        "`define FB_MODE_PID_WAIT_SENSOR 3'd2",
+        "`define FB_MODE_PID_AUTO 3'd3",
+        "`define FB_MODE_HARD_PROTECT 3'd4",
     ]
     for row in layout_rows:
         macro = row["name"].upper()
@@ -313,38 +335,43 @@ def generate(output: Path) -> dict[Path, bytes]:
         "schema": "prod2u-6400-golden-vectors-v1",
         "contract_sha256": contract_sha,
         "frames": {
-            "set_target_stop": frame(0x01, bytes((0,))),
-            "set_target_20": frame(0x01, bytes((20,))),
-            "set_target_70": frame(0x01, bytes((70,))),
+            "set_all_safe": frame(0x01, bytes(24) + bytes((20,)) * 8),
+            "set_all_0_20_50_100": frame(0x01, bytes(range(24)) + bytes((0, 20, 50, 100, 0, 20, 50, 100))),
             "get_snapshot": frame(0x02, b""),
-            "set_target_ack": frame(0x81, b""),
-            "get_snapshot_ack": frame(0x82, b""),
+            "set_pid_target_70": frame(0x04, bytes((70,))),
+            "set_all_ack": frame(0x06, bytes((1, 0x01, 0, 0))),
+            "get_snapshot_ack": frame(0x06, bytes((1, 0x02, 0, 0))),
+            "set_pid_target_ack": frame(0x06, bytes((1, 0x04, 0, 0))),
+            "unsupported_03_nack": frame(0x06, bytes((0, 0x03, 1, 0))),
+            "bad_length_01_nack": frame(0x06, bytes((0, 0x01, 2, 32))),
+            "bad_value_01_index_7_nack": frame(0x06, bytes((0, 0x01, 3, 7))),
+            "safety_locked_01_nack": frame(0x06, bytes((0, 0x01, 4, 0))),
             "stimulus_all_zero_one_second": frame(0x03, bytes((1,)) + bytes(32)),
-            "stimulus_ack": frame(0x83, b""),
+            "stimulus_ack": frame(0x06, bytes((1, 0x03, 0, 0))),
         },
     }
     canonical_profiles = {
         "6400-control": {
-            "allowed_commands": ["SET_TARGET", "GET_SNAPSHOT"],
+            "allowed_commands": ["SET_ALL", "GET_SNAPSHOT", "SET_PID_TARGET"],
             "production": True,
             "stimulus": False,
             "simulation_only": False,
         },
         "6400-identification": {
-            "allowed_commands": ["SET_TARGET", "GET_SNAPSHOT", "SET_STIMULUS"],
+            "allowed_commands": ["SET_ALL", "GET_SNAPSHOT", "SET_STIMULUS", "SET_PID_TARGET"],
             "production": False,
             "stimulus": True,
             "simulation_only": False,
         },
         "6400-sim-debug": {
-            "allowed_commands": ["SET_TARGET", "GET_SNAPSHOT", "SET_STIMULUS"],
+            "allowed_commands": ["SET_ALL", "GET_SNAPSHOT", "SET_STIMULUS", "SET_PID_TARGET"],
             "production": False,
             "stimulus": True,
             "simulation_only": True,
         },
     }
     host = {
-        "schema": "prod2u-6400-host-contract-v2",
+        "schema": "prod2u-6400-host-contract-v3",
         "contract_sha256": contract_sha,
         "canonical_profiles": canonical_profiles,
         "wire": wire,

+ 2 - 1
tools/run_6400_v1.py

@@ -18,8 +18,8 @@ TESTBENCHES = (
     "host_port_selector_tb",
     "bmc_ascii_snapshot_tb",
     "stimulus_atomic_bank_tb",
-    "stimulus_reload_priority_tb",
     "thermal_control_core_tb",
+    "thermal_host_command_v2_tb",
 )
 PWM_TESTBENCH = "pwm_bitmap_engine_tb"
 UART_CANDIDATE_SOURCES = (
@@ -115,6 +115,7 @@ def unit() -> None:
         "tests/unit/test_6400_v1_source_closure.py",
         "tests/unit/test_encode_6400_hex.py",
         "tests/unit/test_fw_6400_v1_entrypoint.py",
+        "tests/unit/test_6400_hex_gui_v2.py",
     ])