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

feat(rtl): implement autonomous 6400 control pipeline

root 3 месяцев назад
Родитель
Сommit
6bb3b043ea

+ 40 - 0
boards/fcb-fpga-mcu-v1_2/prod2u_6400_v1.adc

@@ -0,0 +1,40 @@
+# 6400-front-rear-v1 confirmed pins. TTL Host remains deliberately unbound.
+set_pin_assignment { sys_clk } { LOCATION = J1; IOSTANDARD = LVCMOS33; PULLTYPE = NONE; }
+set_pin_assignment { bmc_rs232_tx } { LOCATION = L10; IOSTANDARD = LVCMOS33; PULLTYPE = NONE; }
+set_pin_assignment { bmc_rs232_rx } { LOCATION = M9; IOSTANDARD = LVCMOS33; PULLTYPE = NONE; }
+set_pin_assignment { host_rs232_tx } { LOCATION = M10; IOSTANDARD = LVCMOS33; PULLTYPE = NONE; }
+set_pin_assignment { host_rs232_rx } { LOCATION = N11; IOSTANDARD = LVCMOS33; PULLTYPE = NONE; }
+set_pin_assignment { temp_scl } { LOCATION = M8; IOSTANDARD = LVCMOS33; PULLTYPE = NONE; }
+set_pin_assignment { temp_sda } { LOCATION = N9; IOSTANDARD = LVCMOS33; PULLTYPE = NONE; }
+set_pin_assignment { ptc_pwm_out[0] } { LOCATION = R7; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[1] } { LOCATION = T6; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[2] } { LOCATION = R5; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[3] } { LOCATION = T4; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[4] } { LOCATION = G16; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[5] } { LOCATION = F16; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[6] } { LOCATION = R3; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[7] } { LOCATION = T2; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[8] } { LOCATION = R1; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[9] } { LOCATION = P1; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[10] } { LOCATION = N1; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[11] } { LOCATION = M1; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[12] } { LOCATION = P7; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[13] } { LOCATION = P8; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[14] } { LOCATION = N16; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[15] } { LOCATION = M16; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[16] } { LOCATION = R16; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[17] } { LOCATION = P16; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[18] } { LOCATION = T12; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[19] } { LOCATION = T13; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[20] } { LOCATION = R10; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[21] } { LOCATION = P10; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[22] } { LOCATION = P9; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { ptc_pwm_out[23] } { LOCATION = T9; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { front_fan_pwm_out[0] } { LOCATION = B1; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { front_fan_pwm_out[1] } { LOCATION = C4; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { front_fan_pwm_out[2] } { LOCATION = B5; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { front_fan_pwm_out[3] } { LOCATION = A14; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { rear_fan_pwm_out[0] } { LOCATION = P15; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { rear_fan_pwm_out[1] } { LOCATION = N15; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { rear_fan_pwm_out[2] } { LOCATION = M14; IOSTANDARD = LVCMOS33; }
+set_pin_assignment { rear_fan_pwm_out[3] } { LOCATION = P5; IOSTANDARD = LVCMOS33; }

+ 1 - 0
boards/fcb-fpga-mcu-v1_2/prod2u_6400_v1.sdc

@@ -0,0 +1 @@
+create_clock -name sys_clk -period 40.000 [get_ports {sys_clk}]

+ 16 - 0
products/6400-control/project.json

@@ -0,0 +1,16 @@
+{
+  "schema": "prod2u-6400-profile-v1",
+  "project_id": "6400-control",
+  "product": "6400-front-rear-v1",
+  "top": "prod2u_6400_v1_top",
+  "device": "EF2L45BG256B",
+  "clock_hz": 25000000,
+  "source_closure": "products/6400-control/source-closure.json",
+  "constraints": "boards/fcb-fpga-mcu-v1_2/prod2u_6400_v1.adc",
+  "timing_constraints": "boards/fcb-fpga-mcu-v1_2/prod2u_6400_v1.sdc",
+  "stimulus": false,
+  "ttl_pin_status": "unbound",
+  "ct_physical_map_status": "unknown",
+  "host_watchdog": false,
+  "pll": false
+}

+ 28 - 0
products/6400-control/source-closure.json

@@ -0,0 +1,28 @@
+{
+  "schema": "prod2u-source-closure-v1",
+  "project_id": "6400-control",
+  "top_module": "prod2u_6400_v1_top",
+  "sources": [
+    "generated/6400/prod2u_6400_v1_params.vh",
+    "src/common/uart_rx_byte.v",
+    "src/common/uart_tx_byte.v",
+    "src/common/crc16_serial.v",
+    "src/common/frame_rx.v",
+    "src/common/frame_tx.v",
+    "src/common/payload_ram.v",
+    "src/modules/shared_500us_tick.v",
+    "src/modules/i2c_word_reader.v",
+    "src/rtl/prod2u_por.v",
+    "src/rtl/prod2u_p4_i2c_stop_start_read.v",
+    "src/transport/host_port_selector.v",
+    "src/transport/thermal_host_command.v",
+    "src/acquisition/bmc_poll_engine.v",
+    "src/acquisition/bmc_ascii_snapshot.v",
+    "src/acquisition/ct7428_snapshot.v",
+    "src/control/thermal_control_core.v",
+    "src/actuator/pwm_bitmap_engine.v",
+    "src/telemetry/thermal_snapshot_mux.v",
+    "src/top/prod2u_6400_v1_top.v"
+  ],
+  "forbidden_substrings": ["door_", "motor", "limit_gate", "host_watchdog", "EF2_PHY_PLL", "SET_ALL"]
+}

+ 9 - 0
products/6400-identification/project.json

@@ -0,0 +1,9 @@
+{
+  "schema": "prod2u-6400-profile-v1",
+  "project_id": "6400-identification",
+  "product": "6400-front-rear-v1",
+  "top": "prod2u_6400_identification_top",
+  "inherits": "products/6400-control/project.json",
+  "stimulus": true,
+  "production": false
+}

+ 10 - 0
products/6400-sim-debug/project.json

@@ -0,0 +1,10 @@
+{
+  "schema": "prod2u-6400-profile-v1",
+  "project_id": "6400-sim-debug",
+  "product": "6400-front-rear-v1",
+  "top": "prod2u_6400_v1_top",
+  "inherits": "products/6400-control/project.json",
+  "stimulus": true,
+  "simulation_only": true,
+  "production": false
+}

+ 10 - 0
products/legacy-door-percent/project.json

@@ -0,0 +1,10 @@
+{
+  "schema": "prod2u-legacy-profile-pointer-v1",
+  "project_id": "legacy-door-percent",
+  "legacy_project": "projects/prod2u-door-temp/project.json",
+  "legacy_requirements": "projects/prod2u-door-temp/requirements.zh-CN.md",
+  "legacy_protocol": "docs/prod2u-door-temp-protocol.zh-CN.md",
+  "legacy_top": "prod2u_p4_normal_v3_top",
+  "buildable": true,
+  "isolated_from_6400": true
+}

+ 205 - 0
src/acquisition/bmc_ascii_snapshot.v

@@ -0,0 +1,205 @@
+`timescale 1ns/1ps
+
+// Streaming ASCII-hex decoder for one 24 x two-byte BMC line. Writes always
+// target the inactive bank; only an exact, valid 48-byte line flips active.
+module bmc_ascii_snapshot #(
+    parameter integer STALE_SECONDS = 3
+) (
+    input  wire        clk,
+    input  wire        rst_n,
+    input  wire        tick_1s,
+    input  wire        rx_valid,
+    input  wire [7:0]  rx_data,
+    input  wire        rx_framing_error,
+    input  wire        snapshot_lock,
+    input  wire        snapshot_lock_bank,
+    output reg         snapshot_commit,
+    output reg         parser_error,
+    output reg [15:0]  epoch,
+    output reg [15:0]  age_seconds,
+    output wire        stale,
+    output reg         active_bank,
+    output wire [23:0] active_valid_mask,
+    input  wire        control_bank,
+    input  wire [4:0]  control_index,
+    output reg [15:0]  control_raw,
+    output reg         control_valid,
+    input  wire        snapshot_bank,
+    input  wire [4:0]  snapshot_index,
+    output reg [15:0]  snapshot_raw,
+    output reg         snapshot_valid
+);
+    reg [7:0] bank0 [0:47];
+    reg [7:0] bank1 [0:47];
+    reg [23:0] valid0;
+    reg [23:0] valid1;
+    reg [5:0] byte_count;
+    reg [3:0] high_nibble;
+    reg have_high;
+    reg line_active;
+    reg line_bad;
+    reg [7:0] integer_byte;
+    reg echo_match;
+    integer i;
+    wire inactive_bank = ~active_bank;
+    wire write_blocked = snapshot_lock && (inactive_bank == snapshot_lock_bank);
+
+    function is_hex;
+        input [7:0] value;
+        begin
+            is_hex = ((value >= "0") && (value <= "9")) ||
+                     ((value >= "a") && (value <= "f")) ||
+                     ((value >= "A") && (value <= "F"));
+        end
+    endfunction
+
+    function [3:0] hex_value;
+        input [7:0] value;
+        begin
+            if (value >= "0" && value <= "9")
+                hex_value = value[3:0];
+            else if (value >= "a" && value <= "f")
+                hex_value = value[3:0] + 4'd9;
+            else
+                hex_value = value[3:0] + 4'd9;
+        end
+    endfunction
+
+    function [7:0] echo_byte;
+        input [2:0] index;
+        begin
+            case (index)
+                3'd0: echo_byte = 8'h36;
+                3'd1: echo_byte = 8'h6c;
+                3'd2: echo_byte = 8'hdf;
+                3'd3: echo_byte = 8'hdd;
+                3'd4: echo_byte = 8'h00;
+                default: echo_byte = 8'h03;
+            endcase
+        end
+    endfunction
+
+    assign stale = (age_seconds >= STALE_SECONDS[15:0]);
+    assign active_valid_mask = active_bank ? valid1 : valid0;
+
+    always @* begin
+        if (control_bank) begin
+            control_raw = {bank1[{control_index, 1'b0}], bank1[{control_index, 1'b0} + 1'b1]};
+            control_valid = valid1[control_index];
+        end else begin
+            control_raw = {bank0[{control_index, 1'b0}], bank0[{control_index, 1'b0} + 1'b1]};
+            control_valid = valid0[control_index];
+        end
+        if (snapshot_bank) begin
+            snapshot_raw = {bank1[{snapshot_index, 1'b0}], bank1[{snapshot_index, 1'b0} + 1'b1]};
+            snapshot_valid = valid1[snapshot_index];
+        end else begin
+            snapshot_raw = {bank0[{snapshot_index, 1'b0}], bank0[{snapshot_index, 1'b0} + 1'b1]};
+            snapshot_valid = valid0[snapshot_index];
+        end
+    end
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            snapshot_commit <= 1'b0;
+            parser_error <= 1'b0;
+            epoch <= 16'd0;
+            age_seconds <= 16'hffff;
+            active_bank <= 1'b0;
+            valid0 <= 24'd0;
+            valid1 <= 24'd0;
+            byte_count <= 6'd0;
+            high_nibble <= 4'd0;
+            have_high <= 1'b0;
+            line_active <= 1'b0;
+            line_bad <= 1'b0;
+            integer_byte <= 8'd0;
+            echo_match <= 1'b1;
+            for (i = 0; i < 48; i = i + 1) begin
+                bank0[i] <= 8'd0;
+                bank1[i] <= 8'd0;
+            end
+        end else begin
+            snapshot_commit <= 1'b0;
+            parser_error <= 1'b0;
+            if (tick_1s && age_seconds != 16'hffff)
+                age_seconds <= age_seconds + 1'b1;
+            if (rx_framing_error) begin
+                line_bad <= 1'b1;
+                line_active <= 1'b1;
+            end
+            if (rx_valid) begin
+                if (is_hex(rx_data)) begin
+                    if (!line_active && !have_high) begin
+                        if (write_blocked)
+                            line_bad <= 1'b1;
+                        else if (active_bank)
+                            valid0 <= 24'd0;
+                        else
+                            valid1 <= 24'd0;
+                    end
+                    line_active <= 1'b1;
+                    if (!have_high) begin
+                        high_nibble <= hex_value(rx_data);
+                        have_high <= 1'b1;
+                    end else begin
+                        have_high <= 1'b0;
+                        if (byte_count < 6'd48) begin
+                            if (!write_blocked) begin
+                                if (active_bank)
+                                    bank0[byte_count] <= {high_nibble, hex_value(rx_data)};
+                                else
+                                    bank1[byte_count] <= {high_nibble, hex_value(rx_data)};
+                            end
+                            if (byte_count < 6)
+                                echo_match <= echo_match && ({high_nibble, hex_value(rx_data)} == echo_byte(byte_count[2:0]));
+                            if (byte_count[0] == 1'b0) begin
+                                integer_byte <= {high_nibble, hex_value(rx_data)};
+                            end else if ((integer_byte == 8'hff) && ({high_nibble, hex_value(rx_data)} == 8'hff)) begin
+                                if (active_bank)
+                                    valid0[byte_count[5:1]] <= 1'b0;
+                                else
+                                    valid1[byte_count[5:1]] <= 1'b0;
+                            end else if ((integer_byte == 8'hff) || ({high_nibble, hex_value(rx_data)} >= 8'd100)) begin
+                                line_bad <= 1'b1;
+                            end else begin
+                                if (active_bank)
+                                    valid0[byte_count[5:1]] <= 1'b1;
+                                else
+                                    valid1[byte_count[5:1]] <= 1'b1;
+                            end
+                            byte_count <= byte_count + 1'b1;
+                        end else begin
+                            line_bad <= 1'b1;
+                        end
+                    end
+                end else if ((rx_data == " ") || (rx_data == 8'h09)) begin
+                    if (have_high) line_bad <= 1'b1;
+                    have_high <= 1'b0;
+                end else if ((rx_data == 8'h0d) || (rx_data == 8'h0a)) begin
+                    if (line_active) begin
+                        if ((byte_count == 6) && echo_match && !have_high && !line_bad) begin
+                            // Optional six-byte command echo is a separate line.
+                        end else if ((byte_count == 48) && !have_high && !line_bad) begin
+                            active_bank <= ~active_bank;
+                            epoch <= epoch + 1'b1;
+                            age_seconds <= 16'd0;
+                            snapshot_commit <= 1'b1;
+                        end else begin
+                            parser_error <= 1'b1;
+                        end
+                    end
+                    byte_count <= 6'd0;
+                    have_high <= 1'b0;
+                    line_active <= 1'b0;
+                    line_bad <= 1'b0;
+                    echo_match <= 1'b1;
+                end else begin
+                    line_active <= 1'b1;
+                    line_bad <= 1'b1;
+                    have_high <= 1'b0;
+                end
+            end
+        end
+    end
+endmodule

+ 85 - 0
src/acquisition/bmc_poll_engine.v

@@ -0,0 +1,85 @@
+`timescale 1ns/1ps
+
+module bmc_poll_engine #(
+    parameter integer CLOCK_HZ = 25000000,
+    parameter integer POLL_SECONDS = 1,
+    parameter integer STARTUP_WAKE_COUNT = 3,
+    parameter integer STARTUP_GAP_CLKS = 5000000,
+    parameter integer STARTUP_DELAY_CLKS = 12500000
+) (
+    input  wire       clk,
+    input  wire       rst_n,
+    input  wire       tx_ready,
+    output reg        tx_valid,
+    output reg [7:0]  tx_data,
+    output reg [15:0] poll_count
+);
+    localparam [2:0] ST_WAKE = 3'd0;
+    localparam [2:0] ST_WAKE_GAP = 3'd1;
+    localparam [2:0] ST_START_DELAY = 3'd2;
+    localparam [2:0] ST_SEND = 3'd3;
+    localparam [2:0] ST_WAIT = 3'd4;
+    localparam [5:0] LAST_COMMAND_INDEX = 6'd42;
+    localparam integer POLL_CLKS = CLOCK_HZ * POLL_SECONDS;
+
+    reg [2:0] state;
+    reg [31:0] counter;
+    reg [5:0] command_index;
+    reg [2:0] wake_count;
+
+    function [7:0] command_char;
+        input [5:0] index;
+        begin
+            case (index)
+                0: command_char="i"; 1: command_char="p"; 2: command_char="m"; 3: command_char="i";
+                4: command_char="t"; 5: command_char="o"; 6: command_char="o"; 7: command_char="l";
+                8: command_char=" "; 9: command_char="r"; 10: command_char="a"; 11: command_char="w";
+                12: command_char=" "; 13: command_char="0"; 14: command_char="x"; 15: command_char="3";
+                16: command_char="6"; 17: command_char=" "; 18: command_char="0"; 19: command_char="x";
+                20: command_char="6"; 21: command_char="c"; 22: command_char=" "; 23: command_char="0";
+                24: command_char="x"; 25: command_char="d"; 26: command_char="f"; 27: command_char=" ";
+                28: command_char="0"; 29: command_char="x"; 30: command_char="d"; 31: command_char="d";
+                32: command_char=" "; 33: command_char="0"; 34: command_char="x"; 35: command_char="0";
+                36: command_char="0"; 37: command_char=" "; 38: command_char="0"; 39: command_char="x";
+                40: command_char="0"; 41: command_char="3"; default: command_char=8'h0a;
+            endcase
+        end
+    endfunction
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            state <= ST_WAKE;
+            counter <= 0;
+            command_index <= 0;
+            wake_count <= 0;
+            tx_valid <= 0;
+            tx_data <= 0;
+            poll_count <= 0;
+        end else begin
+            tx_valid <= 0;
+            case (state)
+                ST_WAKE: if (tx_ready) begin
+                    tx_valid <= 1;
+                    tx_data <= 8'h0d;
+                    wake_count <= wake_count + 1'b1;
+                    counter <= 0;
+                    state <= (wake_count + 1'b1 >= STARTUP_WAKE_COUNT[2:0]) ? ST_START_DELAY : ST_WAKE_GAP;
+                end
+                ST_WAKE_GAP: if (counter + 1 >= STARTUP_GAP_CLKS) begin counter <= 0; state <= ST_WAKE; end else counter <= counter + 1'b1;
+                ST_START_DELAY: if (counter + 1 >= STARTUP_DELAY_CLKS) begin counter <= 0; command_index <= 0; state <= ST_SEND; end else counter <= counter + 1'b1;
+                ST_SEND: if (tx_ready) begin
+                    tx_valid <= 1;
+                    tx_data <= command_char(command_index);
+                    if (command_index == LAST_COMMAND_INDEX) begin
+                        command_index <= 0;
+                        counter <= 0;
+                        poll_count <= poll_count + 1'b1;
+                        state <= ST_WAIT;
+                    end else command_index <= command_index + 1'b1;
+                end
+                ST_WAIT: if (counter + 1 >= POLL_CLKS) begin counter <= 0; state <= ST_SEND; end else counter <= counter + 1'b1;
+                default: state <= ST_WAKE;
+            endcase
+        end
+    end
+endmodule

+ 152 - 0
src/acquisition/ct7428_snapshot.v

@@ -0,0 +1,152 @@
+`timescale 1ns/1ps
+
+module ct7428_snapshot #(
+    parameter integer SCAN_PERIOD_CLKS = 2500000,
+    parameter integer STALE_SECONDS = 2
+) (
+    input  wire        clk,
+    input  wire        rst_n,
+    input  wire        tick_1s,
+    input  wire        snapshot_lock,
+    input  wire        snapshot_lock_bank,
+    output reg         request_valid,
+    input  wire        request_ready,
+    output reg [6:0]   device_addr,
+    output reg [7:0]   register_addr,
+    input  wire        response_valid,
+    output wire        response_ready,
+    input  wire [15:0] response_data,
+    input  wire [3:0]  response_error,
+    output reg         snapshot_commit,
+    output reg [15:0]  epoch,
+    output reg [15:0]  age_seconds,
+    output wire        stale,
+    output reg         active_bank,
+    output wire [26:0] active_valid_mask,
+    input  wire        control_bank,
+    input  wire [4:0]  control_index,
+    output reg [15:0]  control_raw,
+    output reg         control_valid,
+    input  wire        snapshot_bank,
+    input  wire [4:0]  snapshot_index,
+    output reg [15:0]  snapshot_raw,
+    output reg         snapshot_valid
+);
+    localparam ST_START = 2'd0;
+    localparam ST_REQUEST = 2'd1;
+    localparam ST_RESPONSE = 2'd2;
+    localparam ST_WAIT = 2'd3;
+    reg [1:0] state;
+    reg [4:0] index;
+    reg [31:0] wait_counter;
+    reg [15:0] bank0 [0:26];
+    reg [15:0] bank1 [0:26];
+    reg [26:0] valid0;
+    reg [26:0] valid1;
+    integer i;
+    wire inactive_bank = ~active_bank;
+    wire write_blocked = snapshot_lock && (inactive_bank == snapshot_lock_bank);
+
+    assign response_ready = (state == ST_RESPONSE);
+    assign stale = age_seconds >= STALE_SECONDS[15:0];
+    assign active_valid_mask = active_bank ? valid1 : valid0;
+
+    function [6:0] device_for;
+        input [4:0] value;
+        begin
+            if (value < 9) device_for = 7'h49;
+            else if (value < 18) device_for = 7'h48;
+            else device_for = 7'h4b;
+        end
+    endfunction
+
+    function [7:0] register_for;
+        input [4:0] value;
+        begin
+            if (value < 9) register_for = {3'd0, value};
+            else if (value < 18) register_for = {3'd0, value} - 8'd9;
+            else register_for = {3'd0, value} - 8'd18;
+        end
+    endfunction
+
+    always @* begin
+        if (control_bank) begin
+            control_raw = bank1[control_index];
+            control_valid = valid1[control_index];
+        end else begin
+            control_raw = bank0[control_index];
+            control_valid = valid0[control_index];
+        end
+        if (snapshot_bank) begin
+            snapshot_raw = bank1[snapshot_index];
+            snapshot_valid = valid1[snapshot_index];
+        end else begin
+            snapshot_raw = bank0[snapshot_index];
+            snapshot_valid = valid0[snapshot_index];
+        end
+    end
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            state <= ST_START;
+            index <= 0;
+            wait_counter <= 0;
+            request_valid <= 0;
+            device_addr <= 7'h49;
+            register_addr <= 0;
+            snapshot_commit <= 0;
+            epoch <= 0;
+            age_seconds <= 16'hffff;
+            active_bank <= 0;
+            valid0 <= 0;
+            valid1 <= 0;
+            for (i = 0; i < 27; i = i + 1) begin bank0[i] <= 0; bank1[i] <= 0; end
+        end else begin
+            snapshot_commit <= 0;
+            if (tick_1s && age_seconds != 16'hffff) age_seconds <= age_seconds + 1'b1;
+            case (state)
+                ST_START: begin
+                    index <= 0;
+                    if (!write_blocked) begin
+                        if (active_bank) valid0 <= 0; else valid1 <= 0;
+                        state <= ST_REQUEST;
+                    end
+                end
+                ST_REQUEST: begin
+                    request_valid <= 1;
+                    device_addr <= device_for(index);
+                    register_addr <= register_for(index);
+                    if (request_ready) begin
+                        request_valid <= 0;
+                        state <= ST_RESPONSE;
+                    end
+                end
+                ST_RESPONSE: if (response_valid) begin
+                    if (active_bank) begin
+                        bank0[index] <= response_data;
+                        valid0[index] <= (response_error == 0);
+                    end else begin
+                        bank1[index] <= response_data;
+                        valid1[index] <= (response_error == 0);
+                    end
+                    if (index == 26) begin
+                        active_bank <= ~active_bank;
+                        epoch <= epoch + 1'b1;
+                        age_seconds <= 0;
+                        snapshot_commit <= 1;
+                        wait_counter <= 0;
+                        state <= ST_WAIT;
+                    end else begin
+                        index <= index + 1'b1;
+                        state <= ST_REQUEST;
+                    end
+                end
+                ST_WAIT: if (wait_counter + 1 >= SCAN_PERIOD_CLKS) begin
+                    wait_counter <= 0;
+                    state <= ST_START;
+                end else wait_counter <= wait_counter + 1'b1;
+                default: state <= ST_START;
+            endcase
+        end
+    end
+endmodule

+ 93 - 0
src/actuator/pwm_bitmap_engine.v

@@ -0,0 +1,93 @@
+`timescale 1ns/1ps
+
+// One comparator builds the next 32-bit phase image. Physical outputs switch
+// together only at a phase boundary.
+module pwm_bitmap_engine #(
+    parameter integer CHANNEL_COUNT = 32,
+    parameter integer PHASE_COUNT = 100,
+    parameter integer PHASE_CLKS = 500,
+    parameter integer ADDR_WIDTH = 5,
+    parameter [31:0] RESET_LOGICAL_BITMAP = 32'hFF000000
+) (
+    input  wire                     clk,
+    input  wire                     rst_n,
+    output wire [ADDR_WIDTH-1:0]    duty_rd_addr,
+    input  wire [7:0]               duty_rd_data,
+    output reg  [CHANNEL_COUNT-1:0] logical_bitmap,
+    output reg                      phase_boundary,
+    output reg                      deadline_miss,
+    output wire [6:0]               phase_value,
+    output wire                     scan_idle
+);
+    localparam integer PHASE_BITS = (PHASE_COUNT <= 1) ? 1 : $clog2(PHASE_COUNT);
+    localparam integer SLOT_BITS = (PHASE_CLKS <= 1) ? 1 : $clog2(PHASE_CLKS);
+    /* verilator lint_off WIDTH */
+    localparam [PHASE_BITS-1:0] LAST_PHASE = PHASE_COUNT - 1;
+    localparam [SLOT_BITS-1:0] LAST_SLOT = 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;
+    reg [ADDR_WIDTH-1:0] scan_addr;
+    reg [ADDR_WIDTH-1:0] capture_addr;
+    reg scanning;
+    reg capture_valid;
+    reg [CHANNEL_COUNT-1:0] next_bitmap;
+
+    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};
+
+    assign duty_rd_addr = scan_addr;
+    assign phase_value = {{(7-PHASE_BITS){1'b0}}, phase};
+    assign scan_idle = !scanning && !capture_valid;
+
+    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
+
+            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 (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;
+            end else begin
+                phase_clk <= phase_clk + 1'b1;
+            end
+        end
+    end
+endmodule

+ 10 - 4
src/common/frame_rx.v

@@ -13,8 +13,10 @@ module frame_rx #(
     input  wire       frame_ready,
     input  wire       frame_ready,
     output reg [7:0]  frame_type,
     output reg [7:0]  frame_type,
     output reg [7:0]  frame_length,
     output reg [7:0]  frame_length,
+    /* verilator lint_off UNUSEDSIGNAL */
     input  wire [7:0] payload_read_addr,
     input  wire [7:0] payload_read_addr,
     input  wire [7:0] payload_read_data,
     input  wire [7:0] payload_read_data,
+    /* verilator lint_on UNUSEDSIGNAL */
     output reg        payload_wr_en,
     output reg        payload_wr_en,
     output reg [7:0]  payload_wr_addr,
     output reg [7:0]  payload_wr_addr,
     output reg [7:0]  payload_wr_data
     output reg [7:0]  payload_wr_data
@@ -37,6 +39,10 @@ module frame_rx #(
     reg [PAYLOAD_IDX_BITS-1:0] payload_index;
     reg [PAYLOAD_IDX_BITS-1:0] payload_index;
     reg [7:0] received_crc_low;
     reg [7:0] received_crc_low;
     reg [GAP_BITS-1:0] gap_counter;
     reg [GAP_BITS-1:0] gap_counter;
+    /* verilator lint_off WIDTH */
+    wire gap_expired = gap_counter >= INTER_BYTE_TIMEOUT_CYCLES - 1;
+    wire length_oversize = frame_length > MAX_PAYLOAD;
+    /* verilator lint_on WIDTH */
 
 
     wire crc_busy;
     wire crc_busy;
     wire crc_data_done;
     wire crc_data_done;
@@ -79,7 +85,7 @@ module frame_rx #(
         end else begin
         end else begin
             payload_wr_en <= 1'b0;
             payload_wr_en <= 1'b0;
             if (state != ST_WAIT_A5 && state != ST_WAIT_5A && !byte_valid) begin
             if (state != ST_WAIT_A5 && state != ST_WAIT_5A && !byte_valid) begin
-                if (INTER_BYTE_TIMEOUT_CYCLES <= 1 || gap_counter >= INTER_BYTE_TIMEOUT_CYCLES - 1) begin
+                if (INTER_BYTE_TIMEOUT_CYCLES <= 1 || gap_expired) begin
                     state <= ST_WAIT_A5;
                     state <= ST_WAIT_A5;
                     gap_counter <= {GAP_BITS{1'b0}};
                     gap_counter <= {GAP_BITS{1'b0}};
                 end else begin
                 end else begin
@@ -112,7 +118,7 @@ module frame_rx #(
                     ST_PAYLOAD: begin
                     ST_PAYLOAD: begin
                         if (!crc_busy) begin
                         if (!crc_busy) begin
                             payload_wr_en <= 1'b1;
                             payload_wr_en <= 1'b1;
-                            payload_wr_addr <= payload_index;
+                            payload_wr_addr <= {{(8-PAYLOAD_IDX_BITS){1'b0}}, payload_index};
                             payload_wr_data <= byte_data;
                             payload_wr_data <= byte_data;
                             state <= ST_PAYLOAD_CRC_WAIT;
                             state <= ST_PAYLOAD_CRC_WAIT;
                         end
                         end
@@ -138,7 +144,7 @@ module frame_rx #(
                 case (state)
                 case (state)
                     ST_TYPE_CRC_WAIT: state <= ST_LENGTH;
                     ST_TYPE_CRC_WAIT: state <= ST_LENGTH;
                     ST_LENGTH_CRC_WAIT: begin
                     ST_LENGTH_CRC_WAIT: begin
-                        if (frame_length > MAX_PAYLOAD) state <= ST_WAIT_A5;
+                        if (length_oversize) state <= ST_WAIT_A5;
                         else if (frame_length == 0) state <= ST_CRC_LOW;
                         else if (frame_length == 0) state <= ST_CRC_LOW;
                         else begin
                         else begin
                             payload_index <= {PAYLOAD_IDX_BITS{1'b0}};
                             payload_index <= {PAYLOAD_IDX_BITS{1'b0}};
@@ -146,7 +152,7 @@ module frame_rx #(
                         end
                         end
                     end
                     end
                     ST_PAYLOAD_CRC_WAIT: begin
                     ST_PAYLOAD_CRC_WAIT: begin
-                        if (payload_index + 1 >= frame_length) state <= ST_CRC_LOW;
+                        if ({{(8-PAYLOAD_IDX_BITS){1'b0}}, payload_index} + 1'b1 >= frame_length) state <= ST_CRC_LOW;
                         else begin
                         else begin
                             payload_index <= payload_index + 1'b1;
                             payload_index <= payload_index + 1'b1;
                             state <= ST_PAYLOAD;
                             state <= ST_PAYLOAD;

+ 7 - 2
src/common/payload_ram.v

@@ -13,10 +13,15 @@ module payload_ram #(
     output wire [7:0]            rd_data
     output wire [7:0]            rd_data
 );
 );
     reg [7:0] memory [0:DEPTH-1];
     reg [7:0] memory [0:DEPTH-1];
+    localparam integer INDEX_BITS = (DEPTH <= 1) ? 1 : $clog2(DEPTH);
+    /* verilator lint_off WIDTH */
+    wire wr_in_range = wr_addr < DEPTH;
+    wire rd_in_range = rd_addr < DEPTH;
+    /* verilator lint_on WIDTH */
 
 
     always @(posedge clk) begin
     always @(posedge clk) begin
-        if (wr_en && (wr_addr < DEPTH)) memory[wr_addr] <= wr_data;
+        if (wr_en && wr_in_range) memory[wr_addr[INDEX_BITS-1:0]] <= wr_data;
     end
     end
 
 
-    assign rd_data = (rd_addr < DEPTH) ? memory[rd_addr] : 8'hFF;
+    assign rd_data = rd_in_range ? memory[rd_addr[INDEX_BITS-1:0]] : 8'hFF;
 endmodule
 endmodule

+ 455 - 0
src/control/thermal_control_core.v

@@ -0,0 +1,455 @@
+`timescale 1ns/1ps
+
+// One shared incremental-PI datapath updates 24 logical loops once per new BMC
+// epoch. Requested/applied duties commit by bank flip after the sequential pass.
+module thermal_control_core #(
+    parameter integer ENABLE_STIMULUS = 0,
+    parameter signed [15:0] SOFT_LIMIT = 16'sd7400,
+    parameter signed [15:0] PRETRIP_LIMIT = 16'sd7600,
+    parameter signed [15:0] HARD_LIMIT = 16'sd7700,
+    parameter signed [15:0] DEFAULT_TARGET = 16'sd7000,
+    parameter signed [15:0] RECOVERY_MARGIN = 16'sd200,
+    parameter [1:0] RECOVERY_EPOCHS = 2'd3,
+    parameter signed [15:0] EDGE_KP = 16'sd32,
+    parameter signed [15:0] EDGE_KI = 16'sd4,
+    parameter signed [15:0] CENTER_KP = 16'sd24,
+    parameter signed [15:0] CENTER_KI = 16'sd3,
+    parameter integer SLEW_Q8_8 = 1280
+) (
+    input  wire         clk,
+    input  wire         rst_n,
+    input  wire         tick_1s,
+    input  wire         target_commit,
+    input  wire [7:0]   target_celsius,
+    input  wire         stimulus_wr_en,
+    input  wire [4:0]   stimulus_wr_addr,
+    input  wire [7:0]   stimulus_wr_data,
+    input  wire         stimulus_commit,
+    input  wire [7:0]   stimulus_duration_seconds,
+    input  wire [15:0]  bmc_epoch,
+    input  wire         bmc_stale,
+    input  wire [23:0]  bmc_valid_mask,
+    output reg  [4:0]   bmc_rd_index,
+    input  wire [15:0]  bmc_rd_raw,
+    input  wire         bmc_rd_valid,
+    input  wire [15:0]  ct_epoch,
+    input  wire         ct_stale,
+    input  wire [26:0]  ct_valid_mask,
+    input  wire         snapshot_lock,
+    input  wire         snapshot_lock_bank,
+    input  wire [4:0]   pwm_rd_addr,
+    output reg  [7:0]   pwm_rd_data,
+    input  wire         snapshot_output_bank,
+    input  wire [4:0]   snapshot_rd_addr,
+    output reg  [7:0]   snapshot_requested_data,
+    output reg  [7:0]   snapshot_applied_data,
+    output reg          active_output_bank,
+    output reg [2:0]    control_state,
+    output reg [7:0]    current_target_celsius,
+    output reg          host_target_seen,
+    output reg [15:0]   control_epoch,
+    output reg [23:0]   safety_override_mask,
+    output reg [3:0]    lane_fault_mask,
+    output reg          global_fault,
+    output reg          output_commit,
+    output wire         stimulus_active
+);
+    localparam [2:0] RESET_SAFE = 3'd0;
+    localparam [2:0] WAIT_CT_VALID = 3'd1;
+    localparam [2:0] PREHEAT_CT = 3'd2;
+    localparam [2:0] WAIT_BMC_STABLE = 3'd3;
+    localparam [2:0] AUTO_BMC = 3'd4;
+    localparam [2:0] SENSOR_DEGRADED = 3'd5;
+    localparam [2:0] STOPPED = 3'd6;
+
+    localparam [3:0] W_IDLE = 4'd0;
+    localparam [3:0] W_PREP = 4'd1;
+    localparam [3:0] W_KP = 4'd2;
+    localparam [3:0] W_KI = 4'd3;
+    localparam [3:0] W_UPDATE = 4'd4;
+    localparam [3:0] W_FANS = 4'd5;
+    localparam [3:0] W_APPLY = 4'd6;
+    localparam [3:0] W_SAFE_FILL = 4'd7;
+
+    reg [3:0] work_state;
+    reg [4:0] work_index;
+    reg [15:0] last_bmc_epoch;
+    reg [15:0] last_ct_epoch;
+    reg [1:0] stable_epochs;
+    reg epoch_safe;
+    reg [2:0] invalid_count0;
+    reg [2:0] invalid_count1;
+    reg [2:0] invalid_count2;
+    reg [2:0] invalid_count3;
+    reg [15:0] target_centi;
+    reg [7:0] req0 [0:31];
+    reg [7:0] req1 [0:31];
+    reg [7:0] app0 [0:31];
+    reg [7:0] app1 [0:31];
+    reg signed [15:0] previous_error [0:23];
+    reg signed [15:0] previous_output [0:23];
+    reg [7:0] stimulus_mem [0:31];
+    reg stimulus_running;
+    reg [7:0] stimulus_remaining;
+    reg [7:0] safe_fan_target;
+    reg sample_valid;
+    reg signed [15:0] sample_error;
+    reg signed [15:0] sample_temperature;
+    reg signed [31:0] kp_product;
+    reg signed [31:0] ki_product;
+    integer i;
+
+    wire [15:0] bmc_integer_scaled = ({8'd0, bmc_rd_raw[15:8]} << 6) +
+        ({8'd0, bmc_rd_raw[15:8]} << 5) + ({8'd0, bmc_rd_raw[15:8]} << 2);
+    wire signed [15:0] bmc_temperature = $signed(bmc_integer_scaled + {8'd0, bmc_rd_raw[7:0]});
+    wire signed [15:0] live_error = $signed(target_centi) - bmc_temperature;
+    wire edge_channel = (work_index < 6) || (work_index >= 18);
+    wire signed [15:0] selected_kp = edge_channel ? EDGE_KP : CENTER_KP;
+    wire signed [15:0] selected_ki = edge_channel ? EDGE_KI : CENTER_KI;
+    reg signed [15:0] mult_a;
+    reg signed [15:0] mult_b;
+    wire signed [31:0] mult_result = mult_a * mult_b;
+    wire signed [31:0] pi_sum = kp_product + ki_product;
+    wire signed [31:0] pi_delta = (pi_sum >= 0) ? ((pi_sum + 8) >>> 4) : -(((-pi_sum) + 8) >>> 4);
+    wire signed [31:0] previous_output_ext = {{16{previous_output[work_index][15]}}, previous_output[work_index]};
+    wire signed [31:0] pi_candidate = previous_output_ext + pi_delta;
+    wire signed [31:0] slew_low = previous_output_ext - SLEW_Q8_8;
+    wire signed [31:0] slew_high = previous_output_ext + SLEW_Q8_8;
+    wire signed [31:0] slew_candidate = (pi_candidate < slew_low) ? slew_low : ((pi_candidate > slew_high) ? slew_high : pi_candidate);
+    wire signed [15:0] clamped_output = (slew_candidate < 0) ? 16'sd0 : ((slew_candidate > 25600) ? 16'sd25600 : slew_candidate[15:0]);
+    wire signed [15:0] reduced_output = previous_output[work_index] - 16'sd256;
+    wire [7:0] clamped_duty = (clamped_output >= 16'sd25600) ? 8'd100 : q8_8_to_duty(clamped_output);
+    wire [7:0] reduced_duty = (previous_output[work_index] > 16'sd256) ? q8_8_to_duty(reduced_output) : 8'd0;
+    wire [7:0] inactive_request = active_output_bank ? req0[work_index] : req1[work_index];
+    wire signed [15:0] recovery_threshold = $signed(target_centi) + RECOVERY_MARGIN;
+
+    assign stimulus_active = stimulus_running;
+
+    function [1:0] lane_for_channel;
+        input [4:0] channel;
+        begin
+            if (channel < 6) lane_for_channel = 0;
+            else if (channel < 12) lane_for_channel = 1;
+            else if (channel < 18) lane_for_channel = 2;
+            else lane_for_channel = 3;
+        end
+    endfunction
+
+    function [7:0] q8_8_to_duty;
+        input signed [15:0] value;
+        /* verilator lint_off UNUSEDSIGNAL */
+        reg signed [15:0] rounded;
+        /* verilator lint_on UNUSEDSIGNAL */
+        begin
+            rounded = (value + 16'sd128) >>> 8;
+            q8_8_to_duty = rounded[7:0];
+        end
+    endfunction
+
+    function lane_fault_for_output;
+        input [4:0] address;
+        reg [1:0] lane;
+        begin
+            if (address < 24) lane = lane_for_channel(address);
+            else lane = address[1:0];
+            lane_fault_for_output = lane_fault_mask[lane];
+        end
+    endfunction
+
+    function [1:0] lane_for_output;
+        input [4:0] address;
+        begin
+            if (address < 24)
+                lane_for_output = lane_for_channel(address);
+            else
+                lane_for_output = address[1:0];
+        end
+    endfunction
+
+    function lane_invalid;
+        input [1:0] lane;
+        begin
+            case (lane)
+                0: lane_invalid = invalid_count0 >= 2;
+                1: lane_invalid = invalid_count1 >= 2;
+                2: lane_invalid = invalid_count2 >= 2;
+                default: lane_invalid = invalid_count3 >= 2;
+            endcase
+        end
+    endfunction
+
+    always @* begin
+        mult_a = 0;
+        mult_b = 0;
+        if (work_state == W_KP) begin
+            mult_a = live_error - previous_error[work_index[4:0]];
+            mult_b = selected_kp;
+        end else if (work_state == W_KI) begin
+            mult_a = sample_error;
+            mult_b = selected_ki;
+        end
+        if (snapshot_output_bank) begin
+            snapshot_requested_data = req1[snapshot_rd_addr];
+            snapshot_applied_data = app1[snapshot_rd_addr];
+        end else begin
+            snapshot_requested_data = req0[snapshot_rd_addr];
+            snapshot_applied_data = app0[snapshot_rd_addr];
+        end
+    end
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            active_output_bank <= 0;
+            control_state <= RESET_SAFE;
+            current_target_celsius <= 70;
+            target_centi <= DEFAULT_TARGET;
+            host_target_seen <= 0;
+            control_epoch <= 0;
+            safety_override_mask <= 0;
+            lane_fault_mask <= 0;
+            global_fault <= 0;
+            output_commit <= 0;
+            pwm_rd_data <= 0;
+            work_state <= W_IDLE;
+            work_index <= 0;
+            bmc_rd_index <= 0;
+            last_bmc_epoch <= 0;
+            last_ct_epoch <= 0;
+            stable_epochs <= 0;
+            epoch_safe <= 0;
+            invalid_count0 <= 0;
+            invalid_count1 <= 0;
+            invalid_count2 <= 0;
+            invalid_count3 <= 0;
+            stimulus_running <= 0;
+            stimulus_remaining <= 0;
+            safe_fan_target <= 10;
+            sample_valid <= 0;
+            sample_error <= 0;
+            sample_temperature <= 0;
+            kp_product <= 0;
+            ki_product <= 0;
+            for (i = 0; i < 32; i = i + 1) begin
+                req0[i] <= (i < 24) ? 0 : 10;
+                req1[i] <= (i < 24) ? 0 : 10;
+                app0[i] <= (i < 24) ? 0 : 10;
+                app1[i] <= (i < 24) ? 0 : 10;
+                stimulus_mem[i] <= 0;
+            end
+            for (i = 0; i < 24; i = i + 1) begin
+                previous_error[i] <= 0;
+                previous_output[i] <= 0;
+            end
+        end else begin
+            output_commit <= 0;
+            if (active_output_bank)
+                pwm_rd_data <= app1[pwm_rd_addr];
+            else
+                pwm_rd_data <= app0[pwm_rd_addr];
+            if (stimulus_wr_en && (ENABLE_STIMULUS != 0))
+                stimulus_mem[stimulus_wr_addr] <= stimulus_wr_data;
+            if (stimulus_commit && (ENABLE_STIMULUS != 0) && stimulus_duration_seconds != 0) begin
+                stimulus_running <= 1;
+                stimulus_remaining <= stimulus_duration_seconds;
+            end
+            if (tick_1s && stimulus_running) begin
+                if (stimulus_remaining <= 1) begin
+                    stimulus_running <= 0;
+                    stimulus_remaining <= 0;
+                end else stimulus_remaining <= stimulus_remaining - 1'b1;
+            end
+
+            if (target_commit) begin
+                current_target_celsius <= target_celsius;
+                target_centi <= ({8'd0, target_celsius} << 6) +
+                    ({8'd0, target_celsius} << 5) + ({8'd0, target_celsius} << 2);
+                host_target_seen <= 1;
+                stable_epochs <= 0;
+                stimulus_running <= 0;
+                work_index <= 0;
+                work_state <= W_SAFE_FILL;
+                safe_fan_target <= (target_celsius == 0) ? 8'd30 : 8'd10;
+                if (target_celsius == 0)
+                    control_state <= STOPPED;
+                else
+                    control_state <= WAIT_CT_VALID;
+                for (i = 0; i < 24; i = i + 1) begin
+                    previous_error[i] <= 0;
+                    previous_output[i] <= 0;
+                end
+            end else if (bmc_stale && !global_fault && control_state != STOPPED && control_state != RESET_SAFE) begin
+                global_fault <= 1;
+                control_state <= SENSOR_DEGRADED;
+                work_index <= 0;
+                work_state <= W_SAFE_FILL;
+                safe_fan_target <= 100;
+                stimulus_running <= 0;
+            end else begin
+                case (work_state)
+                    W_IDLE: begin
+                        if (control_state == RESET_SAFE) begin
+                            control_state <= WAIT_CT_VALID;
+                        end else if (control_state == WAIT_CT_VALID) begin
+                            if (!ct_stale && (&ct_valid_mask) && ct_epoch != last_ct_epoch) begin
+                                last_ct_epoch <= ct_epoch;
+                                control_state <= PREHEAT_CT;
+                            end
+                        end else if (control_state == PREHEAT_CT) begin
+                            if (bmc_epoch != last_bmc_epoch) begin
+                                last_bmc_epoch <= bmc_epoch;
+                                stable_epochs <= 0;
+                                control_state <= WAIT_BMC_STABLE;
+                            end
+                        end else if (control_state == WAIT_BMC_STABLE) begin
+                            if (bmc_epoch != last_bmc_epoch) begin
+                                last_bmc_epoch <= bmc_epoch;
+                                if (&bmc_valid_mask) begin
+                                    if (stable_epochs == 2) begin
+                                        stable_epochs <= 0;
+                                        control_state <= AUTO_BMC;
+                                        work_index <= 0;
+                                        work_state <= W_PREP;
+                                    end else stable_epochs <= stable_epochs + 1'b1;
+                                end else stable_epochs <= 0;
+                            end
+                        end else if ((control_state == AUTO_BMC || control_state == SENSOR_DEGRADED) &&
+                                     !bmc_stale && bmc_epoch != last_bmc_epoch &&
+                                     !(snapshot_lock && ((~active_output_bank) == snapshot_lock_bank))) begin
+                            last_bmc_epoch <= bmc_epoch;
+                            global_fault <= 0;
+                            work_index <= 0;
+                            work_state <= W_PREP;
+                        end
+                    end
+                    W_PREP: begin
+                        bmc_rd_index <= work_index;
+                        if (work_index == 0) begin
+                            epoch_safe <= 1;
+                            invalid_count0 <= 0;
+                            invalid_count1 <= 0;
+                            invalid_count2 <= 0;
+                            invalid_count3 <= 0;
+                        end
+                        work_state <= W_KP;
+                    end
+                    W_KP: begin
+                        sample_valid <= bmc_rd_valid;
+                        sample_temperature <= bmc_temperature;
+                        sample_error <= live_error;
+                        kp_product <= mult_result;
+                        work_state <= W_KI;
+                    end
+                    W_KI: begin
+                        ki_product <= mult_result;
+                        work_state <= W_UPDATE;
+                    end
+                    W_UPDATE: begin
+                        if (!sample_valid) begin
+                            if (active_output_bank) begin req0[work_index] <= 0; end else begin req1[work_index] <= 0; end
+                            safety_override_mask[work_index] <= 1;
+                            epoch_safe <= 0;
+                            control_state <= SENSOR_DEGRADED;
+                            case (lane_for_channel(work_index))
+                                0: invalid_count0 <= invalid_count0 + 1'b1;
+                                1: invalid_count1 <= invalid_count1 + 1'b1;
+                                2: invalid_count2 <= invalid_count2 + 1'b1;
+                                3: invalid_count3 <= invalid_count3 + 1'b1;
+                            endcase
+                        end else if (sample_temperature >= HARD_LIMIT) begin
+                            if (active_output_bank) req0[work_index] <= 0; else req1[work_index] <= 0;
+                            safety_override_mask[work_index] <= 1;
+                            lane_fault_mask[lane_for_channel(work_index)] <= 1;
+                            epoch_safe <= 0;
+                            control_state <= SENSOR_DEGRADED;
+                            stimulus_running <= 0;
+                        end else if (sample_temperature >= PRETRIP_LIMIT) begin
+                            if (active_output_bank) req0[work_index] <= 0; else req1[work_index] <= 0;
+                            safety_override_mask[work_index] <= 1;
+                            epoch_safe <= 0;
+                            control_state <= SENSOR_DEGRADED;
+                        end else begin
+                            if (stimulus_running) begin
+                                if (active_output_bank) req0[work_index] <= stimulus_mem[work_index]; else req1[work_index] <= stimulus_mem[work_index];
+                            end else if (sample_temperature >= SOFT_LIMIT) begin
+                                if (active_output_bank)
+                                    req0[work_index] <= reduced_duty;
+                                else
+                                    req1[work_index] <= reduced_duty;
+                                if (previous_output[work_index] > 16'sd256) previous_output[work_index] <= previous_output[work_index] - 16'sd256; else previous_output[work_index] <= 0;
+                                previous_error[work_index] <= sample_error;
+                                safety_override_mask[work_index] <= 1;
+                            end else begin
+                                if (active_output_bank) req0[work_index] <= clamped_duty; else req1[work_index] <= clamped_duty;
+                                previous_output[work_index] <= clamped_output;
+                                previous_error[work_index] <= sample_error;
+                                safety_override_mask[work_index] <= 0;
+                            end
+                            if (sample_temperature > recovery_threshold) epoch_safe <= 0;
+                        end
+                        if (work_index == 23) begin
+                            work_index <= 24;
+                            work_state <= W_FANS;
+                            if (control_state == SENSOR_DEGRADED) begin
+                                if (epoch_safe && sample_valid && sample_temperature <= recovery_threshold) begin
+                                    if (stable_epochs == RECOVERY_EPOCHS - 1'b1) begin
+                                        stable_epochs <= 0;
+                                        lane_fault_mask <= 0;
+                                        control_state <= AUTO_BMC;
+                                    end else stable_epochs <= stable_epochs + 1'b1;
+                                end else stable_epochs <= 0;
+                            end
+                        end else begin
+                            work_index <= work_index + 1'b1;
+                            work_state <= W_PREP;
+                        end
+                    end
+                    W_FANS: begin
+                        if (active_output_bank)
+                            req0[work_index] <= stimulus_running ? stimulus_mem[work_index] : 8'd30;
+                        else
+                            req1[work_index] <= stimulus_running ? stimulus_mem[work_index] : 8'd30;
+                        if (work_index == 31) begin work_index <= 0; work_state <= W_APPLY; end
+                        else work_index <= work_index + 1'b1;
+                    end
+                    W_APPLY: begin
+                        if (active_output_bank) begin
+                            if (work_index < 24)
+                                app0[work_index] <= (global_fault || lane_fault_for_output(work_index) || lane_invalid(lane_for_channel(work_index)) || safety_override_mask[work_index]) ? 8'd0 : inactive_request;
+                            else
+                                app0[work_index] <= (global_fault || lane_fault_for_output(work_index) || lane_invalid(lane_for_output(work_index))) ? 8'd100 : inactive_request;
+                        end else begin
+                            if (work_index < 24)
+                                app1[work_index] <= (global_fault || lane_fault_for_output(work_index) || lane_invalid(lane_for_channel(work_index)) || safety_override_mask[work_index]) ? 8'd0 : inactive_request;
+                            else
+                                app1[work_index] <= (global_fault || lane_fault_for_output(work_index) || lane_invalid(lane_for_output(work_index))) ? 8'd100 : inactive_request;
+                        end
+                        if (work_index == 31) begin
+                            active_output_bank <= ~active_output_bank;
+                            control_epoch <= control_epoch + 1'b1;
+                            output_commit <= 1;
+                            work_index <= 0;
+                            work_state <= W_IDLE;
+                        end else work_index <= work_index + 1'b1;
+                    end
+                    W_SAFE_FILL: begin
+                        if (active_output_bank) begin
+                            req0[work_index] <= (work_index < 24) ? 8'd0 : safe_fan_target;
+                            app0[work_index] <= (work_index < 24) ? 8'd0 : safe_fan_target;
+                        end else begin
+                            req1[work_index] <= (work_index < 24) ? 8'd0 : safe_fan_target;
+                            app1[work_index] <= (work_index < 24) ? 8'd0 : safe_fan_target;
+                        end
+                        if (work_index == 31) begin
+                            active_output_bank <= ~active_output_bank;
+                            control_epoch <= control_epoch + 1'b1;
+                            output_commit <= 1;
+                            work_index <= 0;
+                            work_state <= W_IDLE;
+                        end else work_index <= work_index + 1'b1;
+                    end
+                    default: work_state <= W_IDLE;
+                endcase
+            end
+        end
+    end
+endmodule

+ 4 - 1
src/modules/shared_500us_tick.v

@@ -14,13 +14,16 @@ module shared_500us_tick #(
         (CLOCK_HZ / 1_000_000) * TICK_US +
         (CLOCK_HZ / 1_000_000) * TICK_US +
         ((CLOCK_HZ % 1_000_000) * TICK_US) / 1_000_000;
         ((CLOCK_HZ % 1_000_000) * TICK_US) / 1_000_000;
     localparam integer COUNTER_BITS = (TICK_CLKS <= 1) ? 1 : $clog2(TICK_CLKS);
     localparam integer COUNTER_BITS = (TICK_CLKS <= 1) ? 1 : $clog2(TICK_CLKS);
+    /* verilator lint_off WIDTH */
+    localparam [COUNTER_BITS-1:0] LAST_TICK = TICK_CLKS - 1;
+    /* verilator lint_on WIDTH */
     reg [COUNTER_BITS-1:0] counter;
     reg [COUNTER_BITS-1:0] counter;
 
 
     always @(posedge clk or negedge rst_n) begin
     always @(posedge clk or negedge rst_n) begin
         if (!rst_n) begin
         if (!rst_n) begin
             counter <= {COUNTER_BITS{1'b0}};
             counter <= {COUNTER_BITS{1'b0}};
             tick <= 1'b0;
             tick <= 1'b0;
-        end else if (counter == TICK_CLKS - 1) begin
+        end else if (counter == LAST_TICK) begin
             counter <= {COUNTER_BITS{1'b0}};
             counter <= {COUNTER_BITS{1'b0}};
             tick <= 1'b1;
             tick <= 1'b1;
         end else begin
         end else begin

+ 192 - 0
src/telemetry/thermal_snapshot_mux.v

@@ -0,0 +1,192 @@
+`timescale 1ns/1ps
+`include "generated/6400/prod2u_6400_v1_params.vh"
+
+module thermal_snapshot_mux (
+    input  wire        clk,
+    input  wire        rst_n,
+    input  wire        capture,
+    output reg         ready,
+    output reg         locked,
+    input  wire        bmc_active_bank,
+    input  wire        ct_active_bank,
+    input  wire        output_active_bank,
+    output reg         bmc_locked_bank,
+    output reg         ct_locked_bank,
+    output reg         output_locked_bank,
+    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 [15:0] bmc_epoch,
+    input  wire [15:0] ct_epoch,
+    input  wire [15:0] control_epoch,
+    input  wire [15:0] bmc_age,
+    input  wire [15:0] ct_age,
+    input  wire [23:0] bmc_valid_mask,
+    input  wire [26:0] ct_valid_mask,
+    input  wire [23:0] safety_override_mask,
+    input  wire [3:0]  lane_fault_mask,
+    input  wire        global_fault,
+    input  wire        unlock,
+    input  wire [7:0]  payload_addr,
+    output reg  [7:0]  payload_data,
+    output reg  [4:0]  bmc_rd_index,
+    input  wire [15:0] bmc_rd_raw,
+    output reg  [4:0]  ct_rd_index,
+    input  wire [15:0] ct_rd_raw,
+    output reg  [4:0]  output_rd_addr,
+    input  wire [7:0]  requested_data,
+    input  wire [7:0]  applied_data
+);
+    reg [2:0] state_latched;
+    reg [15:0] faults_latched;
+    reg [7:0] target_latched;
+    reg host_seen_latched;
+    reg [15:0] bmc_epoch_latched;
+    reg [15:0] ct_epoch_latched;
+    reg [15:0] control_epoch_latched;
+    reg [15:0] bmc_age_latched;
+    reg [15:0] ct_age_latched;
+    reg [23:0] bmc_valid_latched;
+    reg [26:0] ct_valid_latched;
+    reg [23:0] safety_latched;
+    reg [3:0] lane_fault_latched;
+    reg global_fault_latched;
+    reg [5:0] bmc_relative;
+    reg [5:0] ct_relative;
+    reg [4:0] output_relative;
+    reg [1:0] mask_relative;
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            ready <= 0;
+            locked <= 0;
+            bmc_locked_bank <= 0;
+            ct_locked_bank <= 0;
+            output_locked_bank <= 0;
+            state_latched <= 0;
+            faults_latched <= 0;
+            target_latched <= 70;
+            host_seen_latched <= 0;
+            bmc_epoch_latched <= 0;
+            ct_epoch_latched <= 0;
+            control_epoch_latched <= 0;
+            bmc_age_latched <= 0;
+            ct_age_latched <= 0;
+            bmc_valid_latched <= 0;
+            ct_valid_latched <= 0;
+            safety_latched <= 0;
+            lane_fault_latched <= 0;
+            global_fault_latched <= 0;
+        end else begin
+            ready <= 0;
+            if (capture && !locked) begin
+                locked <= 1;
+                ready <= 1;
+                bmc_locked_bank <= bmc_active_bank;
+                ct_locked_bank <= ct_active_bank;
+                output_locked_bank <= output_active_bank;
+                state_latched <= control_state;
+                faults_latched <= fault_flags;
+                target_latched <= current_target;
+                host_seen_latched <= host_target_seen;
+                bmc_epoch_latched <= bmc_epoch;
+                ct_epoch_latched <= ct_epoch;
+                control_epoch_latched <= control_epoch;
+                bmc_age_latched <= bmc_age;
+                ct_age_latched <= ct_age;
+                bmc_valid_latched <= bmc_valid_mask;
+                ct_valid_latched <= ct_valid_mask;
+                safety_latched <= safety_override_mask;
+                lane_fault_latched <= lane_fault_mask;
+                global_fault_latched <= global_fault;
+            end
+            if (unlock) locked <= 0;
+        end
+    end
+
+    always @* begin
+        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;
+        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_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_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_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_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_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_rd_addr = 5'd28 + {3'd0, output_relative[1:0]};
+        end
+    end
+
+    always @* begin
+        payload_data = 0;
+        mask_relative = 0;
+        if (payload_addr == `FB_SNAPSHOT_CONTROL_STATE_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_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];
+        else if (payload_addr == `FB_SNAPSHOT_CT_EPOCH_OFFSET + 1) payload_data = ct_epoch_latched[15:8];
+        else if (payload_addr == `FB_SNAPSHOT_CONTROL_EPOCH_OFFSET) payload_data = control_epoch_latched[7:0];
+        else if (payload_addr == `FB_SNAPSHOT_CONTROL_EPOCH_OFFSET + 1) payload_data = control_epoch_latched[15:8];
+        else if (payload_addr == `FB_SNAPSHOT_BMC_AGE_OFFSET) payload_data = bmc_age_latched[7:0];
+        else if (payload_addr == `FB_SNAPSHOT_BMC_AGE_OFFSET + 1) payload_data = bmc_age_latched[15:8];
+        else if (payload_addr == `FB_SNAPSHOT_CT_AGE_OFFSET) payload_data = ct_age_latched[7:0];
+        else if (payload_addr == `FB_SNAPSHOT_CT_AGE_OFFSET + 1) payload_data = ct_age_latched[15:8];
+        else if (payload_addr >= `FB_SNAPSHOT_BMC_RAW_OFFSET && payload_addr < `FB_SNAPSHOT_BMC_VALID_MASK_OFFSET) begin
+            payload_data = bmc_relative[0] ? bmc_rd_raw[15:8] : bmc_rd_raw[7:0];
+        end else if (payload_addr >= `FB_SNAPSHOT_BMC_VALID_MASK_OFFSET && payload_addr < `FB_SNAPSHOT_CT_RAW_OFFSET) begin
+            mask_relative = payload_addr[1:0] - 2'd3;
+            case (mask_relative[1:0])
+                0: payload_data = bmc_valid_latched[7:0];
+                1: payload_data = bmc_valid_latched[15:8];
+                default: payload_data = bmc_valid_latched[23:16];
+            endcase
+        end else if (payload_addr >= `FB_SNAPSHOT_CT_RAW_OFFSET && payload_addr < `FB_SNAPSHOT_CT_VALID_MASK_OFFSET) begin
+            payload_data = ct_relative[0] ? ct_rd_raw[15:8] : ct_rd_raw[7:0];
+        end else if (payload_addr >= `FB_SNAPSHOT_CT_VALID_MASK_OFFSET && payload_addr < `FB_SNAPSHOT_PTC_REQUESTED_OFFSET) begin
+            mask_relative = payload_addr[1:0];
+            case (mask_relative[1:0])
+                0: payload_data = ct_valid_latched[7:0];
+                1: payload_data = ct_valid_latched[15:8];
+                2: payload_data = ct_valid_latched[23:16];
+                default: payload_data = {5'd0, ct_valid_latched[26:24]};
+            endcase
+        end else if (payload_addr >= `FB_SNAPSHOT_PTC_REQUESTED_OFFSET && payload_addr < `FB_SNAPSHOT_FRONT_REQUESTED_OFFSET) begin
+            payload_data = (payload_addr < `FB_SNAPSHOT_PTC_APPLIED_OFFSET) ? requested_data : applied_data;
+        end else if (payload_addr >= `FB_SNAPSHOT_FRONT_REQUESTED_OFFSET && payload_addr < `FB_SNAPSHOT_SAFETY_OVERRIDE_MASK_OFFSET) begin
+            payload_data = ((payload_addr >= `FB_SNAPSHOT_FRONT_APPLIED_OFFSET && payload_addr < `FB_SNAPSHOT_REAR_REQUESTED_OFFSET) ||
+                            (payload_addr >= `FB_SNAPSHOT_REAR_APPLIED_OFFSET)) ? applied_data : requested_data;
+        end else if (payload_addr >= `FB_SNAPSHOT_SAFETY_OVERRIDE_MASK_OFFSET && payload_addr < `FB_SNAPSHOT_LANE_FAULT_MASK_OFFSET) begin
+            mask_relative = payload_addr[1:0];
+            case (mask_relative[1:0])
+                0: payload_data = safety_latched[7:0];
+                1: payload_data = safety_latched[15:8];
+                default: payload_data = safety_latched[23:16];
+            endcase
+        end else if (payload_addr == `FB_SNAPSHOT_LANE_FAULT_MASK_OFFSET) payload_data = {4'd0, lane_fault_latched};
+        else if (payload_addr == `FB_SNAPSHOT_GLOBAL_FAULT_OFFSET) payload_data = {7'd0, global_fault_latched};
+    end
+endmodule

+ 24 - 0
src/top/prod2u_6400_identification_top.v

@@ -0,0 +1,24 @@
+`timescale 1ns/1ps
+
+module prod2u_6400_identification_top (
+    input wire sys_clk,
+    input wire host_rs232_rx,
+    output wire host_rs232_tx,
+    input wire host_ttl_rx,
+    output wire host_ttl_tx,
+    input wire bmc_rs232_rx,
+    output wire bmc_rs232_tx,
+    output wire [23:0] ptc_pwm_out,
+    output wire [3:0] front_fan_pwm_out,
+    output wire [3:0] rear_fan_pwm_out,
+    inout wire temp_scl,
+    inout wire temp_sda
+);
+    prod2u_6400_v1_top #(.ENABLE_STIMULUS(1)) core (
+        .sys_clk(sys_clk), .host_rs232_rx(host_rs232_rx), .host_rs232_tx(host_rs232_tx),
+        .host_ttl_rx(host_ttl_rx), .host_ttl_tx(host_ttl_tx),
+        .bmc_rs232_rx(bmc_rs232_rx), .bmc_rs232_tx(bmc_rs232_tx),
+        .ptc_pwm_out(ptc_pwm_out), .front_fan_pwm_out(front_fan_pwm_out),
+        .rear_fan_pwm_out(rear_fan_pwm_out), .temp_scl(temp_scl), .temp_sda(temp_sda)
+    );
+endmodule

+ 289 - 0
src/top/prod2u_6400_v1_top.v

@@ -0,0 +1,289 @@
+`timescale 1ns/1ps
+`include "generated/6400/prod2u_6400_v1_params.vh"
+
+module prod2u_6400_v1_top #(
+    parameter integer ENABLE_STIMULUS = 0
+) (
+    input  wire        sys_clk,
+    input  wire        host_rs232_rx,
+    output wire        host_rs232_tx,
+    input  wire        host_ttl_rx,
+    output wire        host_ttl_tx,
+    input  wire        bmc_rs232_rx,
+    output wire        bmc_rs232_tx,
+    output wire [23:0] ptc_pwm_out,
+    output wire [3:0]  front_fan_pwm_out,
+    output wire [3:0]  rear_fan_pwm_out,
+    inout  wire        temp_scl,
+    inout  wire        temp_sda
+);
+    wire rst_n;
+    wire tick_1s;
+    wire selected_host_rx;
+    wire shared_host_tx;
+    wire host_locked;
+    wire host_port_sel;
+    wire host_rs232_rx_sync;
+    wire host_ttl_rx_sync;
+    wire host_command_busy;
+    wire host_transaction_done;
+    wire host_rx_valid;
+    wire [7:0] host_rx_data;
+    wire host_rx_error;
+    wire frame_valid;
+    wire frame_ready;
+    wire frame_accept_enable;
+    wire [7:0] frame_type;
+    wire [7:0] frame_length;
+    wire payload_wr_en;
+    wire [7:0] payload_wr_addr;
+    wire [7:0] payload_wr_data;
+    wire [7:0] payload_rd_addr;
+    wire [7:0] payload_rd_data;
+    wire target_commit;
+    wire [7:0] target_celsius;
+    wire stimulus_wr_en;
+    wire [4:0] stimulus_wr_addr;
+    wire [7:0] stimulus_wr_data;
+    wire stimulus_commit;
+    wire [7:0] stimulus_duration;
+    wire snapshot_capture;
+    wire snapshot_ready;
+    wire snapshot_locked;
+    wire tx_start;
+    wire [7:0] tx_frame_type;
+    wire [7:0] tx_payload_length;
+    wire tx_done;
+    wire frame_tx_busy;
+    wire frame_tx_byte_valid;
+    wire [7:0] frame_tx_byte_data;
+    wire [7:0] frame_tx_payload_addr;
+    wire [7:0] frame_tx_payload_data;
+    wire host_tx_busy;
+    wire host_tx_done;
+
+    wire bmc_rx_valid;
+    wire [7:0] bmc_rx_data;
+    wire bmc_rx_error;
+    wire bmc_tx_valid;
+    wire [7:0] bmc_tx_data;
+    wire bmc_tx_busy;
+    wire bmc_tx_done;
+    wire [15:0] bmc_poll_count;
+    wire bmc_snapshot_commit;
+    wire bmc_parser_error;
+    wire [15:0] bmc_epoch;
+    wire [15:0] bmc_age;
+    wire bmc_stale;
+    wire bmc_active_bank;
+    wire [23:0] bmc_valid_mask;
+    wire [4:0] bmc_control_index;
+    wire [15:0] bmc_control_raw;
+    wire bmc_control_valid;
+    wire [4:0] bmc_snapshot_index;
+    wire [15:0] bmc_snapshot_raw;
+    wire bmc_snapshot_valid;
+    wire bmc_locked_bank;
+
+    wire ct_request_valid;
+    wire ct_request_ready;
+    wire [6:0] ct_device_addr;
+    wire [7:0] ct_register_addr;
+    wire ct_response_valid;
+    wire ct_response_ready;
+    wire [15:0] ct_response_data;
+    wire [3:0] ct_response_error;
+    wire ct_i2c_busy;
+    wire ct_scl_drive_low;
+    wire ct_sda_drive_low;
+    wire ct_snapshot_commit;
+    wire [15:0] ct_epoch;
+    wire [15:0] ct_age;
+    wire ct_stale;
+    wire ct_active_bank;
+    wire [26:0] ct_valid_mask;
+    wire [4:0] ct_control_index = 5'd0;
+    wire [15:0] ct_control_raw;
+    wire ct_control_valid;
+    wire [4:0] ct_snapshot_index;
+    wire [15:0] ct_snapshot_raw;
+    wire ct_snapshot_valid;
+    wire ct_locked_bank;
+
+    wire [4:0] pwm_duty_addr;
+    wire [7:0] pwm_duty_data;
+    wire [31:0] logical_bitmap;
+    wire pwm_boundary;
+    wire pwm_deadline_miss;
+    wire [6:0] pwm_phase;
+    wire pwm_scan_idle;
+    wire output_active_bank;
+    wire output_locked_bank;
+    wire [4:0] snapshot_output_addr;
+    wire [7:0] snapshot_requested_data;
+    wire [7:0] snapshot_applied_data;
+    wire [2:0] control_state;
+    wire [7:0] current_target;
+    wire host_target_seen;
+    wire [15:0] control_epoch;
+    wire [23:0] safety_mask;
+    wire [3:0] lane_fault_mask;
+    wire global_fault;
+    wire output_commit;
+    wire stimulus_active;
+    wire [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};
+
+    assign temp_scl = ct_scl_drive_low ? 1'b0 : 1'bz;
+    assign temp_sda = ct_sda_drive_low ? 1'b0 : 1'bz;
+    assign ptc_pwm_out = logical_bitmap[23:0];
+    assign front_fan_pwm_out = ~logical_bitmap[27:24];
+    assign rear_fan_pwm_out = ~logical_bitmap[31:28];
+
+    prod2u_por #(.POR_CYCLES(1024)) u_por (.sys_clk(sys_clk), .sys_rst_n(rst_n));
+    shared_500us_tick #(.CLOCK_HZ(`FB_CLOCK_HZ), .TICK_US(1000000)) u_tick_1s (
+        .clk(sys_clk), .rst_n(rst_n), .tick(tick_1s)
+    );
+
+    host_port_selector u_host_select (
+        .clk(sys_clk), .rst_n(rst_n), .rs232_rx_async(host_rs232_rx),
+        .ttl_rx_async(host_ttl_rx), .shared_tx(shared_host_tx),
+        .transaction_done(host_transaction_done), .selected_rx(selected_host_rx),
+        .rs232_tx(host_rs232_tx), .ttl_tx(host_ttl_tx), .locked(host_locked),
+        .port_sel(host_port_sel), .rs232_rx_sync(host_rs232_rx_sync),
+        .ttl_rx_sync(host_ttl_rx_sync)
+    );
+    uart_rx_byte #(.CLKS_PER_BIT(`FB_HOST_FIXED_CLKS_PER_BIT)) u_host_rx (
+        .clk(sys_clk), .rst_n(rst_n), .rx_i(selected_host_rx), .byte_valid(host_rx_valid),
+        .byte_data(host_rx_data), .framing_error(host_rx_error)
+    );
+    frame_rx #(.MAX_PAYLOAD(33), .INTER_BYTE_TIMEOUT_CYCLES(250000)) u_frame_rx (
+        .clk(sys_clk), .rst_n(rst_n), .byte_valid(host_rx_valid), .byte_data(host_rx_data),
+        .accept_enable(frame_accept_enable), .frame_valid(frame_valid), .frame_ready(frame_ready),
+        .frame_type(frame_type), .frame_length(frame_length), .payload_read_addr(payload_rd_addr),
+        .payload_read_data(payload_rd_data), .payload_wr_en(payload_wr_en),
+        .payload_wr_addr(payload_wr_addr), .payload_wr_data(payload_wr_data)
+    );
+    payload_ram #(.DEPTH(33), .ADDR_WIDTH(8)) u_payload (
+        .clk(sys_clk), .wr_en(payload_wr_en), .wr_addr(payload_wr_addr), .wr_data(payload_wr_data),
+        .rd_addr(payload_rd_addr), .rd_data(payload_rd_data)
+    );
+    thermal_host_command #(.ENABLE_STIMULUS(ENABLE_STIMULUS), .SNAPSHOT_LENGTH(`FB_SNAPSHOT_LENGTH)) u_command (
+        .clk(sys_clk), .rst_n(rst_n), .frame_valid(frame_valid), .frame_ready(frame_ready),
+        .frame_accept_enable(frame_accept_enable), .frame_type(frame_type), .frame_length(frame_length),
+        .payload_read_addr(payload_rd_addr), .payload_read_data(payload_rd_data),
+        .target_commit(target_commit), .target_celsius(target_celsius),
+        .stimulus_wr_en(stimulus_wr_en), .stimulus_wr_addr(stimulus_wr_addr),
+        .stimulus_wr_data(stimulus_wr_data), .stimulus_commit(stimulus_commit),
+        .stimulus_duration_seconds(stimulus_duration), .snapshot_capture(snapshot_capture),
+        .snapshot_ready(snapshot_ready), .tx_start(tx_start), .tx_frame_type(tx_frame_type),
+        .tx_payload_length(tx_payload_length), .tx_done(tx_done),
+        .transaction_done(host_transaction_done), .busy(host_command_busy)
+    );
+    frame_tx #(.PAYLOAD_IDX_BITS(8)) 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),
+        .byte_data(frame_tx_byte_data), .byte_ready(!host_tx_busy),
+        .payload_addr(frame_tx_payload_addr), .payload_data(frame_tx_payload_data), .done(tx_done)
+    );
+    uart_tx_byte #(.CLKS_PER_BIT(`FB_HOST_FIXED_CLKS_PER_BIT)) u_host_tx (
+        .clk(sys_clk), .rst_n(rst_n), .byte_valid(frame_tx_byte_valid && !host_tx_busy),
+        .byte_data(frame_tx_byte_data), .tx_o(shared_host_tx), .busy(host_tx_busy), .byte_done(host_tx_done)
+    );
+
+    uart_rx_byte #(.CLKS_PER_BIT(`FB_BMC_CLKS_PER_BIT)) u_bmc_rx (
+        .clk(sys_clk), .rst_n(rst_n), .rx_i(bmc_rs232_rx), .byte_valid(bmc_rx_valid),
+        .byte_data(bmc_rx_data), .framing_error(bmc_rx_error)
+    );
+    bmc_poll_engine u_bmc_poll (
+        .clk(sys_clk), .rst_n(rst_n), .tx_ready(!bmc_tx_busy), .tx_valid(bmc_tx_valid),
+        .tx_data(bmc_tx_data), .poll_count(bmc_poll_count)
+    );
+    uart_tx_byte #(.CLKS_PER_BIT(`FB_BMC_CLKS_PER_BIT)) u_bmc_tx (
+        .clk(sys_clk), .rst_n(rst_n), .byte_valid(bmc_tx_valid && !bmc_tx_busy),
+        .byte_data(bmc_tx_data), .tx_o(bmc_rs232_tx), .busy(bmc_tx_busy),
+        .byte_done(bmc_tx_done)
+    );
+    bmc_ascii_snapshot u_bmc_snapshot (
+        .clk(sys_clk), .rst_n(rst_n), .tick_1s(tick_1s), .rx_valid(bmc_rx_valid),
+        .rx_data(bmc_rx_data), .rx_framing_error(bmc_rx_error),
+        .snapshot_lock(snapshot_locked), .snapshot_lock_bank(bmc_locked_bank),
+        .snapshot_commit(bmc_snapshot_commit), .parser_error(bmc_parser_error),
+        .epoch(bmc_epoch), .age_seconds(bmc_age), .stale(bmc_stale),
+        .active_bank(bmc_active_bank), .active_valid_mask(bmc_valid_mask),
+        .control_bank(bmc_active_bank), .control_index(bmc_control_index),
+        .control_raw(bmc_control_raw), .control_valid(bmc_control_valid),
+        .snapshot_bank(bmc_locked_bank), .snapshot_index(bmc_snapshot_index),
+        .snapshot_raw(bmc_snapshot_raw), .snapshot_valid(bmc_snapshot_valid)
+    );
+
+    ct7428_snapshot u_ct_snapshot (
+        .clk(sys_clk), .rst_n(rst_n), .tick_1s(tick_1s),
+        .snapshot_lock(snapshot_locked), .snapshot_lock_bank(ct_locked_bank),
+        .request_valid(ct_request_valid), .request_ready(ct_request_ready),
+        .device_addr(ct_device_addr), .register_addr(ct_register_addr),
+        .response_valid(ct_response_valid), .response_ready(ct_response_ready),
+        .response_data(ct_response_data), .response_error(ct_response_error),
+        .snapshot_commit(ct_snapshot_commit), .epoch(ct_epoch), .age_seconds(ct_age),
+        .stale(ct_stale), .active_bank(ct_active_bank), .active_valid_mask(ct_valid_mask),
+        .control_bank(ct_active_bank), .control_index(ct_control_index),
+        .control_raw(ct_control_raw), .control_valid(ct_control_valid),
+        .snapshot_bank(ct_locked_bank), .snapshot_index(ct_snapshot_index),
+        .snapshot_raw(ct_snapshot_raw), .snapshot_valid(ct_snapshot_valid)
+    );
+    i2c_word_reader #(.HALF_PERIOD_CLKS(125), .TIMEOUT_CLKS(25000)) u_ct_i2c (
+        .clk(sys_clk), .rst_n(rst_n), .request_valid(ct_request_valid),
+        .request_ready(ct_request_ready), .request_device_addr(ct_device_addr),
+        .request_register(ct_register_addr), .response_valid(ct_response_valid),
+        .response_ready(ct_response_ready), .response_data(ct_response_data),
+        .response_error(ct_response_error), .busy(ct_i2c_busy), .scl_i(temp_scl),
+        .sda_i(temp_sda), .scl_drive_low(ct_scl_drive_low), .sda_drive_low(ct_sda_drive_low)
+    );
+
+    thermal_control_core #(.ENABLE_STIMULUS(ENABLE_STIMULUS)) u_control (
+        .clk(sys_clk), .rst_n(rst_n), .tick_1s(tick_1s), .target_commit(target_commit),
+        .target_celsius(target_celsius), .stimulus_wr_en(stimulus_wr_en),
+        .stimulus_wr_addr(stimulus_wr_addr), .stimulus_wr_data(stimulus_wr_data),
+        .stimulus_commit(stimulus_commit), .stimulus_duration_seconds(stimulus_duration),
+        .bmc_epoch(bmc_epoch), .bmc_stale(bmc_stale), .bmc_valid_mask(bmc_valid_mask),
+        .bmc_rd_index(bmc_control_index), .bmc_rd_raw(bmc_control_raw),
+        .bmc_rd_valid(bmc_control_valid), .ct_epoch(ct_epoch), .ct_stale(ct_stale),
+        .ct_valid_mask(ct_valid_mask), .snapshot_lock(snapshot_locked),
+        .snapshot_lock_bank(output_locked_bank), .pwm_rd_addr(pwm_duty_addr),
+        .pwm_rd_data(pwm_duty_data), .snapshot_output_bank(output_locked_bank),
+        .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),
+        .safety_override_mask(safety_mask), .lane_fault_mask(lane_fault_mask),
+        .global_fault(global_fault), .output_commit(output_commit), .stimulus_active(stimulus_active)
+    );
+    pwm_bitmap_engine u_pwm (
+        .clk(sys_clk), .rst_n(rst_n), .duty_rd_addr(pwm_duty_addr),
+        .duty_rd_data(pwm_duty_data), .logical_bitmap(logical_bitmap),
+        .phase_boundary(pwm_boundary), .deadline_miss(pwm_deadline_miss),
+        .phase_value(pwm_phase), .scan_idle(pwm_scan_idle)
+    );
+    thermal_snapshot_mux u_snapshot_mux (
+        .clk(sys_clk), .rst_n(rst_n), .capture(snapshot_capture), .ready(snapshot_ready),
+        .locked(snapshot_locked), .bmc_active_bank(bmc_active_bank), .ct_active_bank(ct_active_bank),
+        .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),
+        .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(tx_done), .payload_addr(frame_tx_payload_addr),
+        .payload_data(frame_tx_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)
+    );
+
+    wire unused = &{1'b0, host_locked, host_port_sel, frame_tx_busy, host_tx_done,
+        host_rs232_rx_sync, host_ttl_rx_sync, host_command_busy, bmc_tx_done,
+        bmc_poll_count, bmc_snapshot_commit, ct_snapshot_commit, ct_i2c_busy, ct_control_raw,
+        ct_control_valid, bmc_snapshot_valid, ct_snapshot_valid, output_commit,
+        stimulus_active, pwm_boundary, pwm_phase, pwm_scan_idle};
+endmodule

+ 77 - 0
src/transport/host_port_selector.v

@@ -0,0 +1,77 @@
+`timescale 1ns/1ps
+
+// The first synchronized start bit owns one complete Host request/response.
+// Simultaneous starts deterministically select RS-232; simultaneous use is
+// outside the external contract.
+module host_port_selector #(
+    parameter integer IDLE_UNLOCK_CLKS = 1250000
+) (
+    input  wire clk,
+    input  wire rst_n,
+    input  wire rs232_rx_async,
+    input  wire ttl_rx_async,
+    input  wire shared_tx,
+    input  wire transaction_done,
+    output wire selected_rx,
+    output wire rs232_tx,
+    output wire ttl_tx,
+    output reg  locked,
+    output reg  port_sel,
+    output wire rs232_rx_sync,
+    output wire ttl_rx_sync
+);
+    reg rs232_meta;
+    reg rs232_sync;
+    reg ttl_meta;
+    reg ttl_sync;
+    localparam integer IDLE_BITS = (IDLE_UNLOCK_CLKS <= 1) ? 1 : $clog2(IDLE_UNLOCK_CLKS + 1);
+    /* verilator lint_off WIDTH */
+    localparam [IDLE_BITS-1:0] LAST_IDLE = IDLE_UNLOCK_CLKS - 1;
+    /* verilator lint_on WIDTH */
+    reg [IDLE_BITS-1:0] idle_count;
+
+    assign rs232_rx_sync = rs232_sync;
+    assign ttl_rx_sync = ttl_sync;
+    assign selected_rx = locked ? (port_sel ? ttl_sync : rs232_sync) : 1'b1;
+    assign rs232_tx = (locked && !port_sel) ? shared_tx : 1'b1;
+    assign ttl_tx = (locked && port_sel) ? shared_tx : 1'b1;
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            rs232_meta <= 1'b1;
+            rs232_sync <= 1'b1;
+            ttl_meta <= 1'b1;
+            ttl_sync <= 1'b1;
+            locked <= 1'b0;
+            port_sel <= 1'b0;
+            idle_count <= {IDLE_BITS{1'b0}};
+        end else begin
+            rs232_meta <= rs232_rx_async;
+            rs232_sync <= rs232_meta;
+            ttl_meta <= ttl_rx_async;
+            ttl_sync <= ttl_meta;
+
+            if (!locked) begin
+                if (!rs232_sync) begin
+                    locked <= 1'b1;
+                    port_sel <= 1'b0;
+                    idle_count <= {IDLE_BITS{1'b0}};
+                end else if (!ttl_sync) begin
+                    locked <= 1'b1;
+                    port_sel <= 1'b1;
+                    idle_count <= {IDLE_BITS{1'b0}};
+                end
+            end else if (transaction_done && rs232_sync && ttl_sync) begin
+                locked <= 1'b0;
+                idle_count <= {IDLE_BITS{1'b0}};
+            end else if (!selected_rx || !shared_tx) begin
+                idle_count <= {IDLE_BITS{1'b0}};
+            end else if (IDLE_UNLOCK_CLKS <= 1 || idle_count >= LAST_IDLE) begin
+                locked <= 1'b0;
+                idle_count <= {IDLE_BITS{1'b0}};
+            end else begin
+                idle_count <= idle_count + 1'b1;
+            end
+        end
+    end
+endmodule

+ 153 - 0
src/transport/thermal_host_command.v

@@ -0,0 +1,153 @@
+`timescale 1ns/1ps
+
+module thermal_host_command #(
+    parameter integer ENABLE_STIMULUS = 0,
+    parameter integer SNAPSHOT_LENGTH = 193
+) (
+    input  wire       clk,
+    input  wire       rst_n,
+    input  wire       frame_valid,
+    output wire       frame_ready,
+    output wire       frame_accept_enable,
+    input  wire [7:0] frame_type,
+    input  wire [7:0] frame_length,
+    output reg  [7:0] payload_read_addr,
+    input  wire [7:0] payload_read_data,
+    output reg        target_commit,
+    output reg [7:0]  target_celsius,
+    output reg        stimulus_wr_en,
+    output reg [4:0]  stimulus_wr_addr,
+    output reg [7:0]  stimulus_wr_data,
+    output reg        stimulus_commit,
+    output reg [7:0]  stimulus_duration_seconds,
+    output reg        snapshot_capture,
+    input  wire       snapshot_ready,
+    output reg        tx_start,
+    output reg [7:0]  tx_frame_type,
+    output reg [7:0]  tx_payload_length,
+    input  wire       tx_done,
+    output reg        transaction_done,
+    output wire       busy
+);
+    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_TX = 4'd6;
+    localparam [3:0] ST_DROP = 4'd7;
+    reg [3:0] state;
+    reg [5:0] index;
+    reg stimulus_bad;
+
+    assign frame_ready = (state == ST_IDLE) || (state == ST_DROP);
+    assign frame_accept_enable = (state == ST_IDLE);
+    assign busy = state != ST_IDLE;
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            state <= ST_IDLE;
+            index <= 0;
+            stimulus_bad <= 0;
+            payload_read_addr <= 0;
+            target_commit <= 0;
+            target_celsius <= 70;
+            stimulus_wr_en <= 0;
+            stimulus_wr_addr <= 0;
+            stimulus_wr_data <= 0;
+            stimulus_commit <= 0;
+            stimulus_duration_seconds <= 0;
+            snapshot_capture <= 0;
+            tx_start <= 0;
+            tx_frame_type <= 0;
+            tx_payload_length <= 0;
+            transaction_done <= 0;
+        end else begin
+            target_commit <= 0;
+            stimulus_wr_en <= 0;
+            stimulus_commit <= 0;
+            snapshot_capture <= 0;
+            tx_start <= 0;
+            transaction_done <= 0;
+            case (state)
+                ST_IDLE: if (frame_valid) begin
+                    if (frame_type == 8'h01 && frame_length == 1) begin
+                        payload_read_addr <= 0;
+                        state <= ST_TARGET;
+                    end else if (frame_type == 8'h02 && frame_length == 0) begin
+                        snapshot_capture <= 1;
+                        state <= ST_SNAPSHOT_WAIT;
+                    end else if ((ENABLE_STIMULUS != 0) && frame_type == 8'h03 && frame_length == 33) begin
+                        payload_read_addr <= 0;
+                        index <= 0;
+                        stimulus_bad <= 0;
+                        state <= ST_STIM_DURATION;
+                    end else begin
+                        transaction_done <= 1;
+                        state <= ST_DROP;
+                    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_TX;
+                    end else begin
+                        transaction_done <= 1;
+                        state <= ST_DROP;
+                    end
+                end
+                ST_SNAPSHOT_WAIT: if (snapshot_ready) begin
+                    tx_frame_type <= 8'h82;
+                    tx_payload_length <= SNAPSHOT_LENGTH[7:0];
+                    tx_start <= 1;
+                    state <= ST_TX;
+                end
+                ST_STIM_DURATION: begin
+                    stimulus_duration_seconds <= payload_read_data;
+                    if (payload_read_data == 0) stimulus_bad <= 1;
+                    index <= 1;
+                    payload_read_addr <= 1;
+                    state <= ST_STIM_DATA;
+                end
+                ST_STIM_DATA: begin
+                    if (payload_read_data > 100) begin
+                        stimulus_bad <= 1;
+                    end else begin
+                        stimulus_wr_en <= 1;
+                        stimulus_wr_addr <= index[4:0] - 1'b1;
+                        stimulus_wr_data <= payload_read_data;
+                    end
+                    if (index == 32) begin
+                        state <= ST_STIM_COMMIT;
+                    end else begin
+                        index <= index + 1'b1;
+                        payload_read_addr <= {2'b00, index} + 1'b1;
+                    end
+                end
+                ST_STIM_COMMIT: begin
+                    if (!stimulus_bad) begin
+                        stimulus_commit <= 1;
+                        tx_frame_type <= 8'h83;
+                        tx_payload_length <= 0;
+                        tx_start <= 1;
+                        state <= ST_TX;
+                    end else begin
+                        transaction_done <= 1;
+                        state <= ST_DROP;
+                    end
+                end
+                ST_TX: if (tx_done) begin
+                    transaction_done <= 1;
+                    state <= ST_DROP;
+                end
+                ST_DROP: state <= ST_IDLE;
+                default: state <= ST_DROP;
+            endcase
+        end
+    end
+endmodule

+ 111 - 0
tests/sim/bmc_ascii_snapshot_tb.v

@@ -0,0 +1,111 @@
+`timescale 1ns/1ps
+
+module bmc_ascii_snapshot_tb;
+    reg clk = 0;
+    reg rst_n = 0;
+    reg tick = 0;
+    reg rx_valid = 0;
+    reg [7:0] rx_data = 0;
+    reg framing = 0;
+    wire commit;
+    wire error;
+    wire [15:0] epoch;
+    wire [15:0] age;
+    wire stale;
+    wire active_bank;
+    wire [23:0] valid_mask;
+    reg control_bank;
+    reg [4:0] control_index;
+    wire [15:0] control_raw;
+    wire control_valid;
+    reg snapshot_bank;
+    reg [4:0] snapshot_index;
+    wire [15:0] snapshot_raw;
+    wire snapshot_valid;
+    reg saw_commit = 0;
+    reg saw_error = 0;
+    integer i;
+
+    always #5 clk = ~clk;
+    always @(posedge clk) begin
+        if (commit) saw_commit <= 1;
+        if (error) saw_error <= 1;
+    end
+    bmc_ascii_snapshot #(.STALE_SECONDS(2)) dut (
+        .clk(clk), .rst_n(rst_n), .tick_1s(tick), .rx_valid(rx_valid),
+        .rx_data(rx_data), .rx_framing_error(framing), .snapshot_lock(1'b0),
+        .snapshot_lock_bank(1'b0), .snapshot_commit(commit),
+        .parser_error(error), .epoch(epoch), .age_seconds(age), .stale(stale),
+        .active_bank(active_bank), .active_valid_mask(valid_mask),
+        .control_bank(control_bank), .control_index(control_index), .control_raw(control_raw),
+        .control_valid(control_valid), .snapshot_bank(snapshot_bank),
+        .snapshot_index(snapshot_index), .snapshot_raw(snapshot_raw), .snapshot_valid(snapshot_valid)
+    );
+
+    task send_char;
+        input [7:0] value;
+        begin
+            @(negedge clk); rx_data = value; rx_valid = 1;
+            @(negedge clk); rx_valid = 0;
+        end
+    endtask
+
+    function [7:0] hex_char;
+        input [3:0] value;
+        input lower;
+        begin
+            if (value < 10) hex_char = "0" + value;
+            else if (lower) hex_char = "a" + value - 10;
+            else hex_char = "A" + value - 10;
+        end
+    endfunction
+
+    task send_byte;
+        input [7:0] value;
+        input lower;
+        begin
+            send_char(hex_char(value[7:4], lower));
+            send_char(hex_char(value[3:0], lower));
+            send_char(" ");
+        end
+    endtask
+
+    initial begin
+        control_bank = 0;
+        control_index = 0;
+        snapshot_bank = 0;
+        snapshot_index = 0;
+        repeat (3) @(negedge clk);
+        rst_n = 1;
+        for (i = 0; i < 23; i = i + 1) begin
+            send_byte(8'd25 + i, i[0]);
+            send_byte(8'd50, !i[0]);
+        end
+        send_byte(8'hff, 1);
+        send_byte(8'hff, 0);
+        send_char(8'h0d);
+        repeat (2) @(negedge clk);
+        if (epoch !== 1 || !saw_commit || valid_mask !== 24'h7fffff) begin
+            $display("commit mismatch epoch=%0d valid=%h", epoch, valid_mask);
+            $fatal;
+        end
+        control_bank = active_bank;
+        control_index = 0;
+        #1;
+        if (!control_valid || control_raw !== 16'h1932) $fatal;
+        control_index = 23;
+        #1;
+        if (control_valid || control_raw !== 16'hffff) $fatal;
+        send_byte(8'd30, 0);
+        send_byte(8'd100, 0);
+        for (i = 1; i < 24; i = i + 1) begin send_byte(8'd30, 0); send_byte(8'd0, 0); end
+        send_char(8'h0a);
+        repeat (2) @(negedge clk);
+        if (epoch !== 1 || !saw_error) $fatal;
+        tick = 1; @(negedge clk); tick = 0;
+        tick = 1; @(negedge clk); tick = 0;
+        if (!stale) $fatal;
+        $display("PASS: bmc_ascii_snapshot_tb");
+        $finish;
+    end
+endmodule

+ 48 - 0
tests/sim/host_port_selector_tb.v

@@ -0,0 +1,48 @@
+`timescale 1ns/1ps
+
+module host_port_selector_tb;
+    reg clk = 0;
+    reg rst_n = 0;
+    reg rs_rx = 1;
+    reg ttl_rx = 1;
+    reg tx = 1;
+    reg done = 0;
+    wire selected_rx;
+    wire rs_tx;
+    wire ttl_tx;
+    wire locked;
+    wire select;
+    wire rs_sync;
+    wire ttl_sync;
+
+    always #5 clk = ~clk;
+    host_port_selector dut (
+        .clk(clk), .rst_n(rst_n), .rs232_rx_async(rs_rx), .ttl_rx_async(ttl_rx),
+        .shared_tx(tx), .transaction_done(done), .selected_rx(selected_rx),
+        .rs232_tx(rs_tx), .ttl_tx(ttl_tx), .locked(locked), .port_sel(select),
+        .rs232_rx_sync(rs_sync), .ttl_rx_sync(ttl_sync)
+    );
+
+    initial begin
+        repeat (3) @(negedge clk);
+        rst_n = 1;
+        rs_rx = 0;
+        repeat (4) @(negedge clk);
+        if (!locked || select) $fatal;
+        tx = 0;
+        @(negedge clk);
+        if (rs_tx !== 0 || ttl_tx !== 1) $fatal;
+        rs_rx = 1;
+        done = 1;
+        repeat (4) @(negedge clk);
+        done = 0;
+        if (locked) $fatal;
+        ttl_rx = 0;
+        repeat (4) @(negedge clk);
+        if (!locked || !select) $fatal;
+        tx = 0;
+        if (rs_tx !== 1 || ttl_tx !== 0) $fatal;
+        $display("PASS: host_port_selector_tb");
+        $finish;
+    end
+endmodule

+ 62 - 0
tests/sim/pwm_bitmap_engine_tb.v

@@ -0,0 +1,62 @@
+`timescale 1ns/1ps
+
+module pwm_bitmap_engine_tb;
+    reg clk = 0;
+    reg rst_n = 0;
+    wire [4:0] addr;
+    reg [7:0] duty_data;
+    wire [31:0] bitmap;
+    wire boundary;
+    wire miss;
+    wire [6:0] phase;
+    wire idle;
+    reg [7:0] duty [0:31];
+    reg [31:0] previous;
+    integer i;
+    integer boundaries;
+
+    always #5 clk = ~clk;
+    always @(posedge clk) duty_data <= duty[addr];
+
+    pwm_bitmap_engine #(.PHASE_CLKS(40)) dut (
+        .clk(clk), .rst_n(rst_n), .duty_rd_addr(addr), .duty_rd_data(duty_data),
+        .logical_bitmap(bitmap), .phase_boundary(boundary), .deadline_miss(miss),
+        .phase_value(phase), .scan_idle(idle)
+    );
+
+    always @(posedge clk) begin
+        if (rst_n && !boundary && bitmap !== previous) begin
+            $display("bitmap changed away from boundary");
+            $fatal;
+        end
+        previous <= bitmap;
+        if (boundary) boundaries <= boundaries + 1;
+    end
+
+    initial begin
+        duty_data = 0;
+        previous = 32'hFF000000;
+        boundaries = 0;
+        for (i = 0; i < 32; i = i + 1) duty[i] = 0;
+        duty[0] = 1;
+        duty[1] = 2;
+        duty[2] = 50;
+        duty[3] = 99;
+        duty[4] = 100;
+        duty[24] = 100;
+        repeat (4) @(negedge clk);
+        rst_n = 1;
+        while (boundaries < 3) @(negedge clk);
+        if (miss) begin
+            $display("unexpected scan deadline miss");
+            $fatal;
+        end
+        if (bitmap[0] !== 1'b0 || bitmap[1] !== 1'b0 || bitmap[2] !== 1'b1 ||
+            bitmap[3] !== 1'b1 || bitmap[4] !== 1'b1 || bitmap[24] !== 1'b1) begin
+            $display("duty comparison mismatch phase=%0d bitmap=%h", phase, bitmap);
+            $fatal;
+        end
+        $display("PASS: pwm_bitmap_engine_tb");
+        $finish;
+    end
+endmodule

+ 125 - 0
tests/sim/thermal_control_core_tb.v

@@ -0,0 +1,125 @@
+`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 [15:0] bmc_epoch = 0;
+    reg bmc_stale = 0;
+    reg [23:0] bmc_valid_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 [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;
+
+    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),
+        .safety_override_mask(safety), .lane_fault_mask(lane_fault),
+        .global_fault(global_fault), .output_commit(output_commit), .stimulus_active(stimulus_active)
+    );
+
+    task next_bmc_epoch;
+        begin
+            @(negedge clk); bmc_epoch = bmc_epoch + 1'b1;
+            repeat (3) @(negedge clk);
+        end
+    endtask
+
+    task wait_commit_after;
+        input integer old_count;
+        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
+        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;
+            end
+        end
+    endtask
+
+    initial begin
+        for (i = 0; i < 24; i = i + 1) bmc_raw[i] = {8'd60, 8'd0};
+        repeat (4) @(negedge clk);
+        rst_n = 1;
+        repeat (3) @(negedge clk);
+        if (state !== 1) $fatal;
+        ct_epoch = 1;
+        repeat (3) @(negedge clk);
+        if (state !== 2) $fatal;
+        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);
+        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);
+        $display("PASS: thermal_control_core_tb");
+        $finish;
+    end
+endmodule

+ 30 - 0
tests/unit/test_6400_v1_source_closure.py

@@ -0,0 +1,30 @@
+import json
+from pathlib import Path
+
+
+ROOT = Path(__file__).resolve().parents[2]
+
+
+def test_production_closure_excludes_legacy_and_stimulus_wrapper() -> None:
+    closure = json.loads((ROOT / "products/6400-control/source-closure.json").read_text())
+    sources = "\n".join(closure["sources"])
+    assert "identification" not in sources
+    for forbidden in ("door_", "motor", "host_watchdog", "EF2_PHY_PLL"):
+        assert forbidden not in sources
+    assert closure["top_module"] == "prod2u_6400_v1_top"
+
+
+def test_known_pins_are_unique_and_ttl_is_explicitly_unbound() -> None:
+    project = json.loads((ROOT / "products/6400-control/project.json").read_text())
+    assert project["ttl_pin_status"] == "unbound"
+    adc = (ROOT / project["constraints"]).read_text()
+    assert "host_ttl" not in adc
+    locations = [line.split("LOCATION = ", 1)[1].split(";", 1)[0] for line in adc.splitlines() if "LOCATION = " in line]
+    assert len(locations) == len(set(locations))
+
+
+def test_no_host_watchdog_or_pll_in_6400_sources() -> None:
+    closure = json.loads((ROOT / "products/6400-control/source-closure.json").read_text())
+    text = "\n".join((ROOT / source).read_text(errors="ignore") for source in closure["sources"] if source.endswith(".v"))
+    assert "host_watchdog" not in text
+    assert "EF2_PHY_PLL" not in text

+ 3 - 0
tools/run-6400-v1.sh

@@ -0,0 +1,3 @@
+#!/bin/sh
+set -eu
+exec python3 "$(dirname "$0")/run_6400_v1.py" "$@"

+ 93 - 0
tools/run_6400_v1.py

@@ -0,0 +1,93 @@
+#!/usr/bin/env python3
+"""Current-run software verification entrypoint for 6400-front-rear-v1."""
+
+from __future__ import annotations
+
+import argparse
+import json
+from pathlib import Path
+import subprocess
+import sys
+import tempfile
+
+
+ROOT = Path(__file__).resolve().parents[1]
+CLOSURE = ROOT / "products/6400-control/source-closure.json"
+TESTBENCHES = (
+    "pwm_bitmap_engine_tb",
+    "host_port_selector_tb",
+    "bmc_ascii_snapshot_tb",
+    "thermal_control_core_tb",
+)
+
+
+def sources() -> list[str]:
+    value = json.loads(CLOSURE.read_text(encoding="utf-8"))
+    return [item for item in value["sources"] if item.endswith(".v")]
+
+
+def run(argv: list[str]) -> None:
+    print("+ " + " ".join(argv), flush=True)
+    subprocess.run(argv, cwd=ROOT, check=True)
+
+
+def generate(check: bool = True) -> None:
+    argv = ["python3", "tools/generate_6400_v1.py"]
+    if check:
+        argv.append("--check")
+    run(argv)
+
+
+def lint() -> None:
+    run([
+        "verilator", "--lint-only", "--Wall", "-Wno-fatal", "-Wno-MULTITOP",
+        "-I.", "--top-module", "prod2u_6400_v1_top", *sources(),
+    ])
+    script = "read_verilog -I. " + " ".join(sources()) + "; hierarchy -check -top prod2u_6400_v1_top; proc; check"
+    run(["yosys", "-q", "-p", script])
+
+
+def simulation() -> None:
+    with tempfile.TemporaryDirectory(prefix="prod2u-6400-sim-") as directory:
+        temp = Path(directory)
+        for name in TESTBENCHES:
+            output = temp / f"{name}.vvp"
+            run([
+                "iverilog", "-g2012", "-Wall", "-I.", "-s", name,
+                "-o", str(output), *sources(), f"tests/sim/{name}.v",
+            ])
+            run(["vvp", str(output)])
+        run([
+            "iverilog", "-g2012", "-Wall", "-I.", "-s", "prod2u_6400_v1_top",
+            "-o", str(temp / "top.vvp"), *sources(),
+        ])
+
+
+def unit() -> None:
+    run([
+        "pytest", "-q",
+        "tests/unit/test_6400_v1_contract.py",
+        "tests/unit/test_6400_v1_source_closure.py",
+    ])
+
+
+def main() -> int:
+    parser = argparse.ArgumentParser()
+    parser.add_argument("action", choices=("generate", "lint", "sim", "unit", "all"))
+    args = parser.parse_args()
+    if args.action in ("generate", "all"):
+        generate()
+    if args.action in ("lint", "all"):
+        lint()
+    if args.action in ("sim", "all"):
+        simulation()
+    if args.action in ("unit", "all"):
+        unit()
+    return 0
+
+
+if __name__ == "__main__":
+    try:
+        sys.exit(main())
+    except subprocess.CalledProcessError as exc:
+        sys.exit(exc.returncode)