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

feat(telemetry): expose complete motor and sensor state through stable 352-byte snapshots

codex 2 месяцев назад
Родитель
Сommit
ad970296fd

+ 4 - 0
src/control/mrdimm_output_core.v

@@ -42,6 +42,8 @@ module mrdimm_output_core #(
     // applied duties (percent, connector side)
     output reg [7:0]  applied_fan  [0:3],
     output reg [7:0]  applied_ptc  [0:3],
+    output reg [7:0] requested_fan [0:3],
+    output reg [7:0] requested_ptc [0:3],
     output wire [3:0] manual_active,       // per group: bit0 fan, bit1 ptc
     output wire       lease_active,
     output reg [7:0]  watchdog_remaining,
@@ -67,6 +69,7 @@ module mrdimm_output_core #(
             applied_fan[2] <= BOOT_FAN_PERCENT; applied_fan[3] <= BOOT_FAN_PERCENT;
             applied_ptc[0] <= BOOT_PTC_PERCENT; applied_ptc[1] <= BOOT_PTC_PERCENT;
             applied_ptc[2] <= BOOT_PTC_PERCENT; applied_ptc[3] <= BOOT_PTC_PERCENT;
+            for(i=0;i<4;i=i+1) begin requested_fan[i]<=BOOT_FAN_PERCENT;requested_ptc[i]<=BOOT_PTC_PERCENT;end
             lease_armed <= 1'b0;
             watchdog_remaining <= 8'd0;
             commit_done <= 1'b0;
@@ -83,6 +86,7 @@ module mrdimm_output_core #(
                 for (i = 0; i < 4; i = i + 1) begin
                     applied_fan[i] <= staging[i];
                     applied_ptc[i] <= staging[i + 4];
+                    requested_fan[i]<=staging[i];requested_ptc[i]<=staging[i+4];
                 end
                 lease_armed <= 1'b1;
                 watchdog_remaining <= LEASE_SECONDS;

+ 44 - 2
src/motor/motor_axis_core.v

@@ -1,4 +1,5 @@
 `timescale 1ns/1ps
+`include "generated/mrdimm/prod2u_mrdimm_params.vh"
 
 // Per-axis motor execution core (2026 MRDIMM contract, section 10).
 //
@@ -51,14 +52,16 @@ module motor_axis_core #(
     output reg  [15:0] done_tag,
     output reg  [31:0] done_executed,
     input wire [31:0] event_clock_us,
+    input wire [31:0] event_clock_high,
     output reg [31:0] done_position,done_total,done_time,
+    output wire [`MR_AXIS_RECORD_BYTES*8-1:0] telemetry_record,
     // telemetry
     output reg  [31:0] position,
     output reg  [31:0] total_steps,
     output reg  [31:0] last_executed,
     output wire        position_reference_seen,
-    output reg  [15:0] lower_hit_count,
-    output reg  [15:0] upper_hit_count,
+    output reg  [31:0] lower_hit_count,
+    output reg  [31:0] upper_hit_count,
     output reg         lower_latched,
     output reg         upper_latched,
     output reg         both_latched,
@@ -80,6 +83,9 @@ module motor_axis_core #(
     reg [31:0] r_remaining, r_half_us, r_half_cnt, r_executed, r_setup_cnt;
     reg [15:0] r_tag;
     reg limit_lower_q,limit_upper_q;
+    reg [31:0] last_limit_position,last_limit_total,last_limit_time_low,last_limit_time_high,counter_wrap_flags;
+    reg [15:0] last_limit_tag;
+    reg [7:0] last_limit_event;
     wire lower_rise=limit_lower && !limit_lower_q;
     wire upper_rise=limit_upper && !limit_upper_q;
     wire next_upper=(seg_mode==M_SEEK_UPPER) ||
@@ -98,6 +104,28 @@ module motor_axis_core #(
     assign armed=(state==S_ARMED);
     assign load_ready=(state==S_IDLE);
     assign position_reference_seen=r_ref_seen;
+    assign telemetry_record[`MR_AXIS_FLAGS_OFFSET*8 +:16]={5'd0,both_latched,both_live,upper_latched,lower_latched,
+        limit_upper,limit_lower,r_ref_seen,step_out,r_dir_upper,armed,active};
+    assign telemetry_record[`MR_AXIS_MODE_OFFSET*8 +:8]={5'd0,r_mode};
+    assign telemetry_record[`MR_AXIS_QUEUE_DEPTH_OFFSET*8 +:8]=0;
+    assign telemetry_record[`MR_AXIS_CURRENT_TAG_OFFSET*8 +:16]=r_tag;
+    assign telemetry_record[`MR_AXIS_LAST_TAG_OFFSET*8 +:16]=done_tag;
+    assign telemetry_record[`MR_AXIS_POSITION_OFFSET*8 +:32]=position;
+    assign telemetry_record[`MR_AXIS_TOTAL_STEPS_OFFSET*8 +:32]=total_steps;
+    assign telemetry_record[`MR_AXIS_CURRENT_EXECUTED_OFFSET*8 +:32]=r_executed;
+    assign telemetry_record[`MR_AXIS_LAST_EXECUTED_OFFSET*8 +:32]=last_executed;
+    assign telemetry_record[`MR_AXIS_REMAINING_OFFSET*8 +:32]=r_remaining;
+    assign telemetry_record[`MR_AXIS_LOWER_HITS_OFFSET*8 +:32]=lower_hit_count;
+    assign telemetry_record[`MR_AXIS_UPPER_HITS_OFFSET*8 +:32]=upper_hit_count;
+    assign telemetry_record[`MR_AXIS_LAST_LIMIT_POSITION_OFFSET*8 +:32]=last_limit_position;
+    assign telemetry_record[`MR_AXIS_LAST_LIMIT_TOTAL_OFFSET*8 +:32]=last_limit_total;
+    assign telemetry_record[`MR_AXIS_LAST_LIMIT_TAG_OFFSET*8 +:16]=last_limit_tag;
+    assign telemetry_record[`MR_AXIS_LAST_STOP_REASON_OFFSET*8 +:8]={4'd0,last_stop_reason};
+    assign telemetry_record[`MR_AXIS_LAST_LIMIT_EVENT_OFFSET*8 +:8]=last_limit_event;
+    assign telemetry_record[`MR_AXIS_LAST_LIMIT_TIME_LOW_OFFSET*8 +:32]=last_limit_time_low;
+    assign telemetry_record[`MR_AXIS_LAST_LIMIT_TIME_HIGH_OFFSET*8 +:32]=last_limit_time_high;
+    assign telemetry_record[`MR_AXIS_COUNTER_WRAP_FLAGS_OFFSET*8 +:32]=counter_wrap_flags;
+    assign telemetry_record[`MR_AXIS_HALF_PERIOD_US_OFFSET*8 +:32]=r_half_us;
 
     always @(posedge clk or negedge rst_n) begin
         if(!rst_n) begin
@@ -109,6 +137,8 @@ module motor_axis_core #(
             position<=0;total_steps<=0;r_ref_seen<=0;
             limit_lower_q<=0;limit_upper_q<=0;lower_hit_count<=0;upper_hit_count<=0;
             lower_latched<=0;upper_latched<=0;both_latched<=0;
+            last_limit_position<=0;last_limit_total<=0;last_limit_time_low<=0;last_limit_time_high<=0;
+            last_limit_tag<=0;last_limit_event<=0;counter_wrap_flags<=0;
         end else begin
             done_pulse<=0;
             limit_lower_q<=limit_lower;limit_upper_q<=limit_upper;
@@ -116,6 +146,13 @@ module motor_axis_core #(
             if(lower_rise) begin lower_latched<=1;lower_hit_count<=lower_hit_count+1'b1;end
             if(upper_rise) begin upper_latched<=1;upper_hit_count<=upper_hit_count+1'b1;end
             if(both_live && !(limit_lower_q && limit_upper_q)) both_latched<=1;
+            if(lower_rise || upper_rise) begin
+                last_limit_position<=position;last_limit_total<=total_steps;last_limit_tag<=r_tag;
+                last_limit_time_low<=event_clock_us;last_limit_time_high<=event_clock_high;
+                last_limit_event<=both_live ? 8'd7 : (lower_rise ? 8'd2 : 8'd3);
+            end
+            if(lower_rise && lower_hit_count==32'hFFFFFFFF) counter_wrap_flags[2]<=1;
+            if(upper_rise && upper_hit_count==32'hFFFFFFFF) counter_wrap_flags[3]<=1;
 
             // A single priority chain owns STEP and completion. Commands are
             // sampled on every system clock, including SETUP and ARMED states.
@@ -156,6 +193,10 @@ module motor_axis_core #(
                         // The only STEP rise and count update point. Both are
                         // gated by tick_us and the every-clock clamp above.
                         step_out<=1;r_executed<=r_executed+1'b1;total_steps<=total_steps+1'b1;
+                        if(total_steps==32'hFFFFFFFF) counter_wrap_flags[0]<=1;
+                        if(r_executed==32'hFFFFFFFF) counter_wrap_flags[1]<=1;
+                        if((r_dir_upper && position==32'h7FFFFFFF) || (!r_dir_upper && position==32'h80000000))
+                            counter_wrap_flags[4]<=1;
                         position<=r_dir_upper ? position+1'b1 : position-1'b1;
                         if(!r_unlimited) r_remaining<=r_remaining-1'b1;
                     end else begin
@@ -177,6 +218,7 @@ module motor_axis_core #(
             if(position_load) position<=position_value;
             if(counters_clear) begin
                 total_steps<=0;last_executed<=0;lower_hit_count<=0;upper_hit_count<=0;
+                counter_wrap_flags<=0;
                 if(pos_zero_with_counters) position<=0;
             end
             if(lower_rise) begin position<=0;r_ref_seen<=1;end

+ 23 - 21
src/motor/motor_engine.v

@@ -1,4 +1,5 @@
 `timescale 1ns/1ps
+`include "generated/mrdimm/prod2u_mrdimm_params.vh"
 
 // MRDIMM shared motor engine (2026 contract, section 10).
 //
@@ -60,10 +61,11 @@ module motor_engine #(
     output wire [7:0] ev_view_count,
     output reg [31:0] event_pending_overflow,
     output wire [31:0] ev_time_us,
+    output wire [31:0] ev_time_high,event_ring_overflow,
+    output wire any_limit_live,
     input  wire        ev_clear_n,
     input  wire [7:0]  ev_clear_count,
-    // per-axis telemetry, 96 bits packed (see layout below)
-    output wire [AXIS_COUNT*96-1:0] axis_telemetry,
+    output wire [AXIS_COUNT*`MR_AXIS_RECORD_BYTES*8-1:0] axis_telemetry,
     output wire [AXIS_COUNT-1:0] step_out,
     output wire [AXIS_COUNT-1:0] dir_out
 );
@@ -84,15 +86,17 @@ module motor_engine #(
     localparam integer AXIS_COUNTER_BITS=$clog2(AXIS_COUNT+1);
 
     // ---- time base ----
-    reg [31:0] time_us;
+    reg [63:0] time_us;
     always @(posedge clk or negedge rst_n) begin
-        if (!rst_n) time_us <= 32'd0;
-        else if (tick_us) time_us <= time_us + 32'd1;
+        if (!rst_n) time_us <= 64'd0;
+        else if (tick_us) time_us <= time_us + 64'd1;
     end
-    assign ev_time_us = time_us;
+    assign ev_time_us = time_us[31:0];
+    assign ev_time_high = time_us[63:32];
 
     // ---- limit 2FF synchronization ----
     reg [AXIS_COUNT-1:0] ll_s1, ll_s2, ul_s1, ul_s2;
+    assign any_limit_live=(|ll_s2) || (|ul_s2);
     always @(posedge clk or negedge rst_n) begin
         if (!rst_n) begin
             ll_s1 <= {AXIS_COUNT{1'b0}}; ll_s2 <= {AXIS_COUNT{1'b0}};
@@ -225,8 +229,9 @@ module motor_engine #(
     wire [31:0] ax_dpos [0:AXIS_COUNT-1],ax_dtotal [0:AXIS_COUNT-1],ax_dtime [0:AXIS_COUNT-1];
     wire [31:0] ax_pos [0:AXIS_COUNT-1];
     wire [31:0] ax_total [0:AXIS_COUNT-1];
-    wire [15:0] ax_lhits [0:AXIS_COUNT-1];
-    wire [15:0] ax_uhits [0:AXIS_COUNT-1];
+    wire [31:0] ax_lhits [0:AXIS_COUNT-1];
+    wire [31:0] ax_uhits [0:AXIS_COUNT-1];
+    wire [`MR_AXIS_RECORD_BYTES*8-1:0] ax_record [0:AXIS_COUNT-1];
     wire [AXIS_COUNT-1:0] ax_llat, ax_ulat, ax_both;
     wire [3:0]  ax_last_reason [0:AXIS_COUNT-1];
     wire [AXIS_COUNT-1:0] step_out_w, dir_out_w;
@@ -262,7 +267,8 @@ module motor_engine #(
                 .load_ready(ax_load_ready[g]),
                 .done_pulse(ax_done[g]), .done_reason(ax_reason[g]),
                 .done_tag(ax_dtag[g]), .done_executed(ax_dexec[g]),
-                .event_clock_us(time_us),.done_position(ax_dpos[g]),.done_total(ax_dtotal[g]),.done_time(ax_dtime[g]),
+                .event_clock_us(time_us[31:0]),.event_clock_high(time_us[63:32]),.telemetry_record(ax_record[g]),
+                .done_position(ax_dpos[g]),.done_total(ax_dtotal[g]),.done_time(ax_dtime[g]),
                 .position(ax_pos[g]), .total_steps(ax_total[g]),
                 .last_executed(), .position_reference_seen(ax_ref_seen[g]),
                 .lower_hit_count(ax_lhits[g]), .upper_hit_count(ax_uhits[g]),
@@ -275,18 +281,14 @@ module motor_engine #(
         end
     endgenerate
 
-    // telemetry layout per axis (96 bits):
-    // [95:64] total_steps [63:32] position [47:32] upper_hits [31:16] lower_hits
-    // [15:12] last_stop_reason [11] both [10] upper_latched [9] lower_latched
-    // [8:7] upper/lower live [6] ref_seen [5] armed [4] active [3:0] 0
+    // Generated field offsets; add queue-owned values without overlapping core fields.
     generate
-        for (g = 0; g < AXIS_COUNT; g = g + 1) begin : g_tel
-            assign axis_telemetry[g*96 +: 96] = {
-                ax_total[g], ax_pos[g], ax_uhits[g], ax_lhits[g],
-                ax_last_reason[g], ax_both[g], ax_ulat[g], ax_llat[g],
-                ul_s2[g], ll_s2[g], ax_ref_seen[g], ax_armed[g],
-                ax_active[g], 4'd0
-            };
+        for(g=0;g<AXIS_COUNT;g=g+1) begin:g_tel
+            wire [`MR_AXIS_RECORD_BYTES*8-1:0] queue_field={{(`MR_AXIS_RECORD_BYTES*8-6){1'b0}},depth_r[g]};
+            wire [`MR_AXIS_RECORD_BYTES*8-1:0] pause_field={{(`MR_AXIS_RECORD_BYTES*8-1){1'b0}},queue_paused_r[g]};
+            assign axis_telemetry[g*`MR_AXIS_RECORD_BYTES*8 +: `MR_AXIS_RECORD_BYTES*8]=ax_record[g] |
+                (queue_field << (`MR_AXIS_QUEUE_DEPTH_OFFSET*8)) |
+                (pause_field << (`MR_AXIS_FLAGS_OFFSET*8+`MR_AXIS_FLAG_QUEUE_PAUSED_BIT));
         end
     endgenerate
 
@@ -297,7 +299,7 @@ module motor_engine #(
         .wr_tag(ev_tag), .wr_position(ev_pos), .wr_total(ev_total), .time_us(ev_timestamp),
         .rd_index(ev_rd_index), .rd_hold(ev_hold), .rd_data(ev_rd_data), .record_count(ev_count),
         .overflow_lsb(ev_overflow),
-        .view_ready(ev_view_ready), .view_count(ev_view_count), .overflow_count(),
+        .view_ready(ev_view_ready), .view_count(ev_view_count), .overflow_count(event_ring_overflow),
         .clear_n(ev_clear_n), .clear_count(ev_clear_count)
     );
 

+ 76 - 81
src/telemetry/mrdimm_snapshot_mux.v

@@ -1,91 +1,86 @@
 `timescale 1ns/1ps
 `include "generated/mrdimm/prod2u_mrdimm_params.vh"
-
-// ALL_STATUS_DATA snapshot for the mrdimm-chamber product.
-//
-// On capture, latches a consistent view of the thermal duties, the three
-// axis telemetry words, the engine time base and the event ring head
-// info into a dedicated stable window; ready pulses one cycle later and
-// the window stays fixed until the next capture.  Layout (50 bytes):
-//   [0..7]   fan0..3 / ptc0..3 applied percent
-//   [8..19]  [20..31] [32..43] axis X/Y/Z 96-bit packed telemetry (LE)
-//   [44..47] time_us low 32
-//   [48]     event record count   [49] event overflow lsb
+// Capture scalar/axis state once, lock sensor banks for a bounded copy, then
+// serve every transport from independent stable RAM without holding sources.
 module mrdimm_snapshot_mux #(
-    parameter integer SNAPSHOT_LENGTH = `MR_SNAPSHOT_LENGTH
+    parameter integer AXIS_COUNT=`MR_AXIS_COUNT,
+    parameter integer SNAPSHOT_LENGTH=`MR_SNAPSHOT_AXIS_OFFSET+AXIS_COUNT*`MR_AXIS_RECORD_BYTES
 ) (
-    input  wire       clk,
-    input  wire       rst_n,
-    input  wire       capture,
-    output reg        ready,
-    // sources
-    input  wire [7:0] fan_applied [0:3],
-    input  wire [7:0] ptc_applied [0:3],
-    output reg [2:0] axis_sel,           // one axis read at a time (self-paced)
-    input  wire [95:0] axis_data,
-    input  wire [31:0] time_us,
-    input  wire [7:0] ev_count,
-    input  wire [7:0] ev_overflow,
-    // stable byte window (combinational read of latched registers)
-    input  wire [7:0] read_addr,
-    output reg  [7:0] read_data
+    input wire clk,rst_n,capture,
+    output reg ready,locked,bmc_locked_bank,ct_locked_bank,
+    input wire [31:0] fan_applied,ptc_applied,fan_requested,ptc_requested,
+    input wire watchdog_active,
+    input wire [7:0] watchdog_remaining,
+    input wire bmc_active_bank,ct_active_bank,bmc_stale,ct_stale,
+    input wire [15:0] bmc_epoch,ct_epoch,bmc_age,ct_age,
+    input wire [23:0] bmc_valid_mask,
+    input wire [26:0] ct_valid_mask,
+    output wire [4:0] bmc_rd_index,ct_rd_index,
+    input wire [15:0] bmc_rd_raw,ct_rd_raw,
+    input wire [AXIS_COUNT*`MR_AXIS_RECORD_BYTES*8-1:0] axis_data,
+    input wire [31:0] time_us,time_high,event_overflow,event_pending_overflow,global_flags,
+    input wire [7:0] ev_count,
+    input wire [9:0] read_addr,
+    output reg [7:0] read_data
 );
-    reg [7:0] window [0:SNAPSHOT_LENGTH-1];
-    reg [1:0] cap_state;
-    reg [1:0] cap_axis;
-    integer i;
-
+    reg [`MR_SNAPSHOT_AXIS_OFFSET*8-1:0] header_shadow;
+    reg [AXIS_COUNT*`MR_AXIS_RECORD_BYTES*8-1:0] axis_shadow;
+    reg [7:0] memory [0:SNAPSHOT_LENGTH-1];
+    reg [9:0] index;
+    reg [1:0] phase;
+    wire in_bmc=index>=`MR_SNAPSHOT_BMC_RAW_OFFSET && index<`MR_SNAPSHOT_BMC_RAW_OFFSET+`MR_SNAPSHOT_BMC_RAW_SIZE;
+    wire in_ct=index>=`MR_SNAPSHOT_CT_RAW_OFFSET && index<`MR_SNAPSHOT_CT_RAW_OFFSET+`MR_SNAPSHOT_CT_RAW_SIZE;
+    wire [9:0] bmc_relative=index-`MR_SNAPSHOT_BMC_RAW_OFFSET;
+    wire [9:0] ct_relative=index-`MR_SNAPSHOT_CT_RAW_OFFSET;
+    wire [9:0] axis_relative=index-`MR_SNAPSHOT_AXIS_OFFSET;
+    assign bmc_rd_index=in_bmc ? bmc_relative[5:1] : 5'd0;
+    assign ct_rd_index=in_ct ? ct_relative[5:1] : 5'd0;
+    wire [7:0] copy_data=in_bmc ? (bmc_relative[0] ? bmc_rd_raw[15:8] : bmc_rd_raw[7:0]) :
+        in_ct ? (ct_relative[0] ? ct_rd_raw[15:8] : ct_rd_raw[7:0]) :
+        index>=`MR_SNAPSHOT_AXIS_OFFSET ? axis_shadow[axis_relative*8 +:8] : header_shadow[index*8 +:8];
+    always @(posedge clk) begin
+        if(locked && phase==2) memory[index]<=copy_data;
+        read_data<=read_addr<SNAPSHOT_LENGTH ? memory[read_addr] : 8'hFF;
+    end
     always @(posedge clk or negedge rst_n) begin
-        if (!rst_n) begin
-            cap_state <= 2'd0;
-            cap_axis <= 2'd0;
-            axis_sel <= 2'd0;
-            ready <= 1'b0;
+        if(!rst_n) begin
+            ready<=0;locked<=0;bmc_locked_bank<=0;ct_locked_bank<=0;index<=0;phase<=0;
+            header_shadow<=0;axis_shadow<=0;
         end else begin
-            ready <= 1'b0;
-            case (cap_state)
-                2'd0: if (capture) begin
-                    for (i = 0; i < 4; i = i + 1) begin
-                        window[i] <= fan_applied[i];
-                        window[i + 4] <= ptc_applied[i];
-                    end
-                    cap_axis <= 2'd0;
-                    axis_sel <= 2'd0;
-                    cap_state <= 2'd1;
-                end
-                2'd1: begin
-                    // one cycle per axis with the registered read latency
-                    case (cap_axis)
-                        2'd0: for (i = 0; i < 12; i = i + 1)
-                            window[8 + i] <= axis_data[i*8 +: 8];
-                        2'd1: for (i = 0; i < 12; i = i + 1)
-                            window[20 + i] <= axis_data[i*8 +: 8];
-                        2'd2: for (i = 0; i < 12; i = i + 1)
-                            window[32 + i] <= axis_data[i*8 +: 8];
-                        default: ;
-                    endcase
-                    if (cap_axis == 2'd2) begin
-                        cap_state <= 2'd2;
-                    end else begin
-                        cap_axis <= cap_axis + 2'd1;
-                        axis_sel <= axis_sel + 2'd1;
-                    end
-                end
-                2'd2: begin
-                    window[44] <= time_us[7:0];   window[45] <= time_us[15:8];
-                    window[46] <= time_us[23:16]; window[47] <= time_us[31:24];
-                    window[48] <= ev_count;
-                    window[49] <= ev_overflow;
-                    ready <= 1'b1;
-                    cap_state <= 2'd0;
-                end
-                default: cap_state <= 2'd0;
-            endcase
+            ready<=0;
+            if(capture && !locked) begin
+                locked<=1;index<=0;phase<=0;bmc_locked_bank<=bmc_active_bank;ct_locked_bank<=ct_active_bank;
+                axis_shadow<=axis_data;
+                header_shadow<=0;
+                header_shadow[`MR_SNAPSHOT_FAN_APPLIED_OFFSET*8 +:32]<=fan_applied;
+                header_shadow[`MR_SNAPSHOT_PTC_APPLIED_OFFSET*8 +:32]<=ptc_applied;
+                header_shadow[`MR_SNAPSHOT_FAN_REQUESTED_OFFSET*8 +:32]<=fan_requested;
+                header_shadow[`MR_SNAPSHOT_PTC_REQUESTED_OFFSET*8 +:32]<=ptc_requested;
+                header_shadow[`MR_SNAPSHOT_WATCHDOG_ACTIVE_OFFSET*8 +:8]<={7'd0,watchdog_active};
+                header_shadow[`MR_SNAPSHOT_WATCHDOG_REMAINING_OFFSET*8 +:8]<=watchdog_remaining;
+                header_shadow[`MR_SNAPSHOT_BMC_VALID_OFFSET*8 +:8]<={7'd0,|bmc_valid_mask};
+                header_shadow[`MR_SNAPSHOT_BMC_STALE_OFFSET*8 +:8]<={7'd0,bmc_stale};
+                header_shadow[`MR_SNAPSHOT_CT_VALID_OFFSET*8 +:8]<={7'd0,|ct_valid_mask};
+                header_shadow[`MR_SNAPSHOT_CT_STALE_OFFSET*8 +:8]<={7'd0,ct_stale};
+                header_shadow[`MR_SNAPSHOT_BMC_EPOCH_OFFSET*8 +:16]<=bmc_epoch;
+                header_shadow[`MR_SNAPSHOT_CT_EPOCH_OFFSET*8 +:16]<=ct_epoch;
+                header_shadow[`MR_SNAPSHOT_BMC_AGE_OFFSET*8 +:16]<=bmc_age;
+                header_shadow[`MR_SNAPSHOT_CT_AGE_OFFSET*8 +:16]<=ct_age;
+                header_shadow[`MR_SNAPSHOT_BMC_VALID_MASK_OFFSET*8 +:24]<=bmc_valid_mask;
+                header_shadow[`MR_SNAPSHOT_CT_VALID_MASK_OFFSET*8 +:32]<={5'd0,ct_valid_mask};
+                header_shadow[`MR_SNAPSHOT_TIME_US_LOW_OFFSET*8 +:32]<=time_us;
+                header_shadow[`MR_SNAPSHOT_TIME_US_HIGH_OFFSET*8 +:32]<=time_high;
+                header_shadow[`MR_SNAPSHOT_EVENT_COUNT_OFFSET*8 +:8]<=ev_count;
+                header_shadow[`MR_SNAPSHOT_EVENT_OVERFLOW_OFFSET*8 +:32]<=event_overflow;
+                header_shadow[`MR_SNAPSHOT_EVENT_PENDING_OVERFLOW_OFFSET*8 +:32]<=event_pending_overflow;
+                header_shadow[`MR_SNAPSHOT_GLOBAL_FLAGS_OFFSET*8 +:32]<=global_flags;
+            end else if(locked) begin
+                if(phase==2) begin
+                    phase<=0;
+                    if(index==SNAPSHOT_LENGTH-1) begin locked<=0;ready<=1;end
+                    else index<=index+1'b1;
+                end else phase<=phase+1'b1;
+            end
         end
     end
-
-    always @* begin
-        read_data = 8'hFF;
-        if (read_addr < SNAPSHOT_LENGTH[7:0]) read_data = window[read_addr];
-    end
 endmodule

+ 34 - 26
src/top/prod2u_mrdimm_top.v

@@ -195,6 +195,7 @@ module prod2u_mrdimm_top (
         .commit(thermal_commit), .commit_done(thermal_commit_done),
         .commit_ok(thermal_commit_ok), .keepalive_reload(keepalive_reload),
         .applied_fan(applied_fan_w), .applied_ptc(applied_ptc_w),
+        .requested_fan(requested_fan_w),.requested_ptc(requested_ptc_w),
         .manual_active(), .lease_active(lease_active),
         .watchdog_remaining(watchdog_remaining),
         .fan_pwm_on(fan_on), .ptc_pwm_on(ptc_on)
@@ -202,6 +203,7 @@ module prod2u_mrdimm_top (
     wire [7:0] applied_fan_w [0:3];
     wire [7:0] applied_ptc_w [0:3];
     wire [7:0] watchdog_remaining;
+    wire [7:0] requested_fan_w [0:3],requested_ptc_w [0:3];
 
     // ---- motor engine ----
     motor_engine #(
@@ -224,40 +226,48 @@ module prod2u_mrdimm_top (
         .ev_rd_index(ev_rd_index), .ev_hold(ev_hold),
         .ev_rd_data(ev_rd_data), .ev_count(ev_count), .ev_overflow(ev_overflow),
         .ev_view_ready(ev_view_ready), .ev_view_count(ev_view_count),
-        .ev_time_us(ev_time_us),
+        .ev_time_us(ev_time_us),.ev_time_high(ev_time_high),.event_ring_overflow(event_ring_overflow),
+        .event_pending_overflow(event_pending_overflow),.any_limit_live(motor_any_limit),
         .ev_clear_n(ev_clear_n), .ev_clear_count(ev_clear_count),
         .axis_telemetry(axis_telemetry),
         .step_out({z_step, y_step, x_step}), .dir_out({z_dir, y_dir, x_dir})
     );
     wire [31:0] ev_time_us;
-    wire [287:0] axis_telemetry;
+    wire [`MR_AXIS_COUNT*`MR_AXIS_RECORD_BYTES*8-1:0] axis_telemetry;
+    wire [31:0] ev_time_high,event_ring_overflow,event_pending_overflow;
+    wire motor_any_limit;
     reg boot_seek;
     always @(posedge sys_clk or negedge rst_n) begin
         if (!rst_n) boot_seek <= 1'b1;      // power-on SEEK_LOWER x3
         else boot_seek <= 1'b0;
     end
 
-    // ---- ALL_STATUS snapshot ----
-    mrdimm_snapshot_mux #(.SNAPSHOT_LENGTH(`MR_SNAPSHOT_LENGTH)) u_snapshot (
-        .clk(sys_clk), .rst_n(rst_n), .capture(snapshot_capture), .ready(snapshot_ready),
-        .fan_applied(applied_fan_w), .ptc_applied(applied_ptc_w),
-        .axis_sel(axis_sel_w), .axis_data(axis_data_r),
-        .time_us(ev_time_us), .ev_count(ev_count), .ev_overflow(ev_overflow),
-        .read_addr(status_addr_r), .read_data(status_byte_in)
+    // ---- Complete schema-derived status and bounded sensor-bank copy ----
+    wire snapshot_locked,bmc_locked_bank,bmc_active_bank;
+    wire [4:0] bmc_snapshot_index;
+    wire [15:0] bmc_snapshot_raw,bmc_epoch,bmc_age;
+    mrdimm_snapshot_mux u_snapshot (
+        .clk(sys_clk),.rst_n(rst_n),.capture(snapshot_capture),.ready(snapshot_ready),.locked(snapshot_locked),
+        .bmc_locked_bank(bmc_locked_bank),.ct_locked_bank(ct_locked_bank),
+        .fan_applied({applied_fan_w[3],applied_fan_w[2],applied_fan_w[1],applied_fan_w[0]}),
+        .ptc_applied({applied_ptc_w[3],applied_ptc_w[2],applied_ptc_w[1],applied_ptc_w[0]}),
+        .fan_requested({requested_fan_w[3],requested_fan_w[2],requested_fan_w[1],requested_fan_w[0]}),
+        .ptc_requested({requested_ptc_w[3],requested_ptc_w[2],requested_ptc_w[1],requested_ptc_w[0]}),
+        .watchdog_active(lease_active),.watchdog_remaining(watchdog_remaining),
+        .bmc_active_bank(bmc_active_bank),.ct_active_bank(ct_active_bank),.bmc_stale(bmc_stale),.ct_stale(ct_stale),
+        .bmc_epoch(bmc_epoch),.ct_epoch(ct_epoch),.bmc_age(bmc_age),.ct_age(ct_age),
+        .bmc_valid_mask(bmc_valid_mask),.ct_valid_mask(ct_valid_mask),
+        .bmc_rd_index(bmc_snapshot_index),.ct_rd_index(ct_snapshot_index),
+        .bmc_rd_raw(bmc_snapshot_raw),.ct_rd_raw(ct_snapshot_raw),.axis_data(axis_telemetry),
+        .time_us(ev_time_us),.time_high(ev_time_high),.event_overflow(event_ring_overflow),
+        .event_pending_overflow(event_pending_overflow),.ev_count(ev_count),
+        .global_flags({28'd0,|event_pending_overflow,|event_ring_overflow,motor_any_limit,lease_active}),
+        .read_addr(frame_tx_payload_addr[9:0]),.read_data(status_byte_in)
     );
-    wire [2:0] axis_sel_w;
-    reg [95:0] axis_data_r;
-    reg [7:0] status_addr_r;
-    always @* begin
-        axis_data_r = (axis_sel_w == 2'd0) ? axis_telemetry[95:0] :
-                      (axis_sel_w == 2'd1) ? axis_telemetry[191:96] :
-                                             axis_telemetry[287:192];
-        status_addr_r = frame_tx_payload_addr[7:0];
-    end
 
     // ---- frame_tx + uart ----
     wire frame_tx_done, host_tx_busy, host_tx_done;
-    frame_tx #(.PAYLOAD_IDX_BITS(8), .EXTERNAL_CRC(1), .PAYLOAD_READ_LATENCY(1)) u_frame_tx (
+    frame_tx #(.PAYLOAD_IDX_BITS(10), .EXTERNAL_CRC(1), .PAYLOAD_READ_LATENCY(1)) u_frame_tx (
         .clk(sys_clk), .rst_n(rst_n), .start(tx_start), .frame_type(tx_frame_type),
         .payload_length(tx_payload_length), .busy(frame_tx_busy),
         .byte_valid(frame_tx_byte_valid), .byte_data(frame_tx_byte_data),
@@ -300,10 +310,10 @@ module prod2u_mrdimm_top (
 
     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(1'b0),.snapshot_lock_bank(1'b0),
-        .snapshot_commit(),.parser_error(),.epoch(),.age_seconds(),.stale(bmc_stale),
-        .active_bank(),.active_valid_mask(bmc_valid_mask),.control_bank(1'b0),.control_index(5'd0),
-        .control_raw(),.control_valid(),.snapshot_bank(1'b0),.snapshot_index(5'd0),.snapshot_raw(),.snapshot_valid()
+        .rx_framing_error(bmc_rx_error),.snapshot_lock(snapshot_locked),.snapshot_lock_bank(bmc_locked_bank),
+        .snapshot_commit(),.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(1'b0),.control_index(5'd0),
+        .control_raw(),.control_valid(),.snapshot_bank(bmc_locked_bank),.snapshot_index(bmc_snapshot_index),.snapshot_raw(bmc_snapshot_raw),.snapshot_valid()
     );
 
     // ---- CT7428 acquisition (independent I2C master) ----
@@ -319,11 +329,9 @@ module prod2u_mrdimm_top (
     wire [4:0] ct_snapshot_index;
     wire [15:0] ct_snapshot_raw;
     wire ct_snapshot_valid;
-    assign ct_locked_bank=ct_active_bank;
-    assign ct_snapshot_index=5'd0;
     ct7428_snapshot #(.SCAN_PERIOD_CLKS(2500000)) u_ct_snapshot (
         .clk(sys_clk), .rst_n(rst_n), .tick_1s(tick_1s),
-        .snapshot_lock(1'b0), .snapshot_lock_bank(ct_locked_bank),
+        .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),

+ 56 - 0
tests/sim/mrdimm_snapshot_contract_tb.v

@@ -0,0 +1,56 @@
+`timescale 1ns/1ps
+// Independent full-status Sentinel; literal offsets are deliberately not
+// imported from the production generator.
+module mrdimm_snapshot_contract_tb;
+    reg clk=0;always #20 clk=~clk;
+    reg rst_n=0,capture=0,generation=0;
+    wire ready,locked,bb,cb;
+    wire [4:0] bi,ci;
+    reg [15:0] braw,craw;
+    reg [1535:0] axes;
+    reg [9:0] address=0;
+    wire [7:0] data;
+    always @(posedge clk) begin
+        braw<=(generation ? 16'hEE00 : 16'hA000)+{7'd0,bb,8'd0}+bi;
+        craw<=(generation ? 16'hFF00 : 16'hB000)+{7'd0,cb,8'd0}+3*ci;
+    end
+    mrdimm_snapshot_mux dut(.clk(clk),.rst_n(rst_n),.capture(capture),.ready(ready),.locked(locked),
+        .bmc_locked_bank(bb),.ct_locked_bank(cb),.fan_applied(32'h18171615),.ptc_applied(32'h36353433),
+        .fan_requested(32'h2221201F),.ptc_requested(32'h403F3E3D),.watchdog_active(1'b1),.watchdog_remaining(8'd17),
+        .bmc_active_bank(1'b1),.ct_active_bank(1'b0),.bmc_stale(1'b0),.ct_stale(1'b1),
+        .bmc_epoch(16'h1234),.ct_epoch(16'h5678),.bmc_age(16'h9ABC),.ct_age(16'hDEF0),
+        .bmc_valid_mask(24'hABCDEF),.ct_valid_mask(27'h56789AB),.bmc_rd_index(bi),.ct_rd_index(ci),
+        .bmc_rd_raw(braw),.ct_rd_raw(craw),.axis_data(axes),.time_us(32'h76543210),.time_high(32'h12345678),
+        .event_overflow(32'h01020304),.event_pending_overflow(32'h5A6B7C8D),.ev_count(8'd63),
+        .global_flags(32'hA5A55A5A),.read_addr(address),.read_data(data));
+    reg [7:0] expected [0:351];
+    integer i,n,cycles;
+    task put(input integer offset,input integer count,input [31:0] v);
+        integer k;begin for(k=0;k<count;k=k+1)expected[offset+k]=(v>>(8*k))&255;end
+    endtask
+    initial begin
+        for(i=0;i<352;i=i+1)expected[i]=0;
+        put(0,4,32'h18171615);put(4,4,32'h36353433);put(8,4,32'h2221201F);put(12,4,32'h403F3E3D);
+        expected[16]=1;expected[17]=17;expected[18]=1;expected[19]=0;expected[20]=1;expected[21]=1;
+        put(22,2,16'h1234);put(24,2,16'h5678);put(26,2,16'h9ABC);put(28,2,16'hDEF0);
+        for(i=0;i<24;i=i+1)put(30+2*i,2,16'hA100+i);
+        put(78,3,24'hABCDEF);
+        for(i=0;i<27;i=i+1)put(81+2*i,2,16'hB000+3*i);
+        put(135,4,27'h56789AB);put(139,4,32'h76543210);put(143,4,32'h12345678);
+        expected[147]=63;put(148,4,32'h01020304);put(152,4,32'h5A6B7C8D);put(156,4,32'hA5A55A5A);
+        for(i=0;i<192;i=i+1)begin
+            expected[160+i]=((i*37+11)^(i>>4))&255;axes[i*8 +:8]=expected[160+i];
+        end
+        repeat(4) @(negedge clk);rst_n=1;repeat(4) @(negedge clk);capture=1;
+        @(negedge clk);capture=0;cycles=0;
+        while(!ready && cycles<2000)begin @(negedge clk);cycles=cycles+1;end
+        if(!ready || locked) $fatal(1,"snapshot copy did not release sources");
+        generation=1;axes=0;repeat(50) @(negedge clk);
+        for(n=0;n<352;n=n+1)begin
+            address=n;repeat(3) @(negedge clk);
+            if(data!==expected[n]) $fatal(1,"MR snapshot byte %0d got %02x expected %02x",n,data,expected[n]);
+        end
+        $display("mrdimm_snapshot_contract_tb PASS");$finish;
+    end
+    initial begin #1000000;$fatal(1,"MR snapshot bounded deadline");end
+endmodule

+ 3 - 3
tests/sim/prod2u_mrdimm_i2c_e2e_tb.v

@@ -112,7 +112,7 @@ module prod2u_mrdimm_i2c_e2e_tb;
         empty_command(5);require_response();
         reg_read(7,value);if(value!=30) $fatal(1,"I2C keepalive failed to reload active lease");
         empty_command(2);require_response();
-        reg_read(5,value);if(value!=50) $fatal(1,"MRDIMM GET length incorrectly used 6400 length: %0d",value);
+        reg_read(5,value);if(value!=96) $fatal(1,"MRDIMM GET length incorrectly used 6400 length: %0d",value);
         pointer(16'h0200);start_bus();send(8'h55,1);
         for(i=0;i<8;i=i+1) begin
             receive(value,i<7);
@@ -132,8 +132,8 @@ module prod2u_mrdimm_i2c_e2e_tb;
             host_frame(1,11);wait(serial_count>=11);#2160;check_serial_frame(0,8'h80,4);
             if(serial_response[5]!=1 || serial_response[6]!=0) $fatal(1,"UART SET_ALL rejected");
             if(dut.applied_fan_w[0]!=45+transport) $fatal(1,"UART source failed to commit");
-            host_frame(2,0);wait(serial_count>=68);#2160;
-            check_serial_frame(0,8'h80,4);check_serial_frame(11,8'h81,50);
+            host_frame(2,0);wait(serial_count>=370);#2160;
+            check_serial_frame(0,8'h80,4);check_serial_frame(11,8'h81,352);
             if(serial_response[16]!=45+transport) $fatal(1,"UART snapshot source mismatch");
         end
         wait(bmc_done);#10000;

+ 20 - 15
tests/sim/prod2u_mrdimm_uart_e2e_tb.v

@@ -107,7 +107,7 @@ module prod2u_mrdimm_uart_e2e_tb;
         .data_done(crc_done_w), .crc(crc_val_w)
     );
 
-    mrdimm_host_command #(.SNAPSHOT_LENGTH(50)) dut (
+    mrdimm_host_command #(.SNAPSHOT_LENGTH(352)) dut (
         .clk(clk), .rst_n(rst_n),
         .frame_valid(frame_valid), .frame_ready(frame_ready),
         .frame_accept_enable(frame_accept_enable), .frame_type(frame_type),
@@ -153,7 +153,7 @@ module prod2u_mrdimm_uart_e2e_tb;
         .fan_pwm_on(fan_on), .ptc_pwm_on(ptc_on)
     );
 
-    wire [287:0] axis_telemetry;
+    wire [1535:0] axis_telemetry;
     wire [31:0] unused_time;
     motor_engine #(
         .AXIS_COUNT(3),
@@ -179,23 +179,28 @@ module prod2u_mrdimm_uart_e2e_tb;
         .step_out(step_bus), .dir_out(dir_bus)
     );
 
-    // ALL_STATUS byte window: engine telemetry is checked through the
-    // snapshot capture; here a stub window is enough for the length check.
-    assign status_byte_in = 8'h00;
-    mrdimm_snapshot_mux #(.SNAPSHOT_LENGTH(50)) u_snapshot (
-        .clk(clk), .rst_n(rst_n), .capture(snapshot_capture), .ready(snapshot_ready),
-        .fan_applied(applied_fan), .ptc_applied(applied_ptc),
-        .axis_sel(), .axis_data(axis_telemetry[95:0]),
-        .time_us(unused_time), .ev_count(ev_count), .ev_overflow(ev_overflow),
-        .read_addr(8'd0), .read_data(status_byte_in_unused)
+    mrdimm_snapshot_mux u_snapshot (
+        .clk(clk),.rst_n(rst_n),.capture(snapshot_capture),.ready(snapshot_ready),.locked(),
+        .bmc_locked_bank(),.ct_locked_bank(),
+        .fan_applied({applied_fan[3],applied_fan[2],applied_fan[1],applied_fan[0]}),
+        .ptc_applied({applied_ptc[3],applied_ptc[2],applied_ptc[1],applied_ptc[0]}),
+        .fan_requested({applied_fan[3],applied_fan[2],applied_fan[1],applied_fan[0]}),
+        .ptc_requested({applied_ptc[3],applied_ptc[2],applied_ptc[1],applied_ptc[0]}),
+        .watchdog_active(lease_active_w),.watchdog_remaining(watchdog_remaining_w),
+        .bmc_active_bank(1'b0),.ct_active_bank(1'b0),.bmc_stale(1'b1),.ct_stale(1'b1),
+        .bmc_epoch(16'd0),.ct_epoch(16'd0),.bmc_age(16'd0),.ct_age(16'd0),
+        .bmc_valid_mask(24'd0),.ct_valid_mask(27'd0),.bmc_rd_index(),.ct_rd_index(),
+        .bmc_rd_raw(16'd0),.ct_rd_raw(16'd0),.axis_data(axis_telemetry),
+        .time_us(unused_time),.time_high(32'd0),.event_overflow(32'd0),
+        .event_pending_overflow(32'd0),.ev_count(ev_count),.global_flags(32'd0),
+        .read_addr(frame_tx_payload_addr_w[9:0]),.read_data(status_byte_in)
     );
-    wire [7:0] status_byte_in_unused;
 
     // frame_tx consumes the command core payload for ACK/DATA lengths.
     wire frame_tx_done_w, frame_tx_busy_w, frame_tx_byte_valid_w;
     wire [7:0] frame_tx_byte_data_w;
     wire [15:0] frame_tx_payload_addr_w;
-    frame_tx #(.PAYLOAD_IDX_BITS(8), .EXTERNAL_CRC(0), .PAYLOAD_READ_LATENCY(1)) u_frame_tx (
+    frame_tx #(.PAYLOAD_IDX_BITS(10), .EXTERNAL_CRC(0), .PAYLOAD_READ_LATENCY(1)) u_frame_tx (
         .clk(clk), .rst_n(rst_n), .start(tx_start), .frame_type(tx_frame_type),
         .payload_length(tx_payload_length), .busy(frame_tx_busy_w),
         .byte_valid(frame_tx_byte_valid_w), .byte_data(frame_tx_byte_data_w),
@@ -294,8 +299,8 @@ module prod2u_mrdimm_uart_e2e_tb;
         send_byte(8'hA5); send_byte(8'h5A); send_byte(8'h02);
         send_byte(8'h00); send_byte(8'h00);
         send_byte(8'hFC); send_byte(8'hA2);
-        repeat (2000) @(posedge clk);
-        if (data_len_seen !== 16'd50) $fatal(1, "ALL_STATUS length %0d", data_len_seen);
+        wait(response_checks==6);@(negedge clk);
+        if (data_len_seen !== 16'd352) $fatal(1, "ALL_STATUS length %0d", data_len_seen);
         if (response_checks!==6) $fatal(1,"incomplete serialized responses: %0d",response_checks);
         // Abort the running X seek, then read its stable event through 80/83.
         send_byte(8'hA5);send_byte(8'h5A);send_byte(8'h04);send_byte(8'h08);send_byte(0);

+ 1 - 1
tools/fw_cli.py

@@ -241,7 +241,7 @@ def cmd_diagnose(args: argparse.Namespace) -> int:
     products = ("6400-front-rear", "mrdimm-chamber") if args.target == "all" else (args.target,)
     tests = {
         "6400-front-rear": ("frame_rx_tb", "prod2u_6400_uart_e2e_tb", "thermal_snapshot_contract_tb", "host_i2c_slave_contract_tb", "prod2u_6400_host_e2e_tb"),
-        "mrdimm-chamber": ("motor_axis_contract_tb", "motor_engine_tb", "motor_event_ring_tb", "prod2u_mrdimm_uart_e2e_tb", "prod2u_mrdimm_i2c_e2e_tb"),
+        "mrdimm-chamber": ("motor_axis_contract_tb", "motor_engine_tb", "motor_event_ring_tb", "mrdimm_snapshot_contract_tb", "prod2u_mrdimm_uart_e2e_tb", "prod2u_mrdimm_i2c_e2e_tb"),
     }
     receipt = {"scope": "migration-diagnostic-only", "run_id": out.name,
                "hardware": "NOT_RUN", "results": [], "inputs": {}, "status": "RUNNING", "complete": False,