Преглед на файлове

fix(mrdimm): connect response bytes and wait for queue RAM reads

codex преди 2 месеца
родител
ревизия
71c2119d08
променени са 3 файла, в които са добавени 19 реда и са изтрити 10 реда
  1. 5 2
      src/motor/motor_engine.v
  2. 13 7
      src/transport/mrdimm_host_command.v
  3. 1 1
      tests/sim/prod2u_mrdimm_uart_e2e_tb.v

+ 5 - 2
src/motor/motor_engine.v

@@ -176,7 +176,7 @@ module motor_engine #(
     wire [1:0] qc_axis = f_axis(stage[qc_index]);
 
     // ---- execute fetch FSM ----
-    localparam [1:0] FX_IDLE = 2'd0, FX_RD = 2'd1, FX_LOAD = 2'd2;
+    localparam [1:0] FX_IDLE = 2'd0, FX_RD = 2'd1, FX_LOAD = 2'd2, FX_WAIT = 2'd3;
     reg [1:0] fx_state;
     reg [1:0] fx_axis;
     reg       fx_from_urgent;
@@ -356,7 +356,7 @@ module motor_engine #(
                 home_pending_r[i] <= 1'b0;
             end
             q_we <= 1'b0;
-            cs_state <= 2'd0; su_axis <= 2'd0;
+            cs_state <= 2'd0; su_axis <= AXIS_COUNT;
         end else begin
             // default single-cycle pulses
             ax_seg_load <= {AXIS_COUNT{1'b0}};
@@ -478,6 +478,9 @@ module motor_engine #(
                     end
                 end
                 FX_RD: begin
+                    fx_state <= FX_WAIT;
+                end
+                FX_WAIT: begin
                     fx_seg <= q_rd;
                     fx_state <= FX_LOAD;
                 end

+ 13 - 7
src/transport/mrdimm_host_command.v

@@ -67,6 +67,7 @@ module mrdimm_host_command #(
     input  wire [7:0] status_byte_in,
     input  wire [15:0] tx_payload_addr,
     output wire [7:0]  ack_payload_data,
+    output wire [7:0]  tx_payload_data,
     output reg        tx_start,
     output reg  [7:0]  tx_frame_type,
     output reg  [15:0] tx_payload_length,
@@ -101,6 +102,7 @@ module mrdimm_host_command #(
     reg [7:0]  ctl_flags_r;
     reg [31:0] ctl_value_r;
     reg [7:0]  ev_max_records;
+    reg ctl_sent;
 
     assign frame_ready = (state == ST_IDLE) || (state == ST_DROP);
     assign frame_accept_enable = (state == ST_IDLE);
@@ -128,7 +130,7 @@ module mrdimm_host_command #(
     reg [127:0] ack_word;
     reg status_valid;           // DATA phase carries ALL_STATUS
     reg event_valid;            // DATA phase carries EVENT_DATA
-    reg tx_payload_data_r;
+    reg [7:0] tx_payload_data_r;
     reg tx_start_or_running;
 
     // Ring view freeze: while the EVENT payload streams, the engine holds
@@ -142,7 +144,7 @@ module mrdimm_host_command #(
             (tx_payload_addr - 16'd1) >> 4 : 8'd0;
     end
 
-    wire [2:0] ev_byte_sel = tx_payload_addr[3:0];  // (addr-1) % 16 == addr[3:0]
+    wire [3:0] ev_byte_sel = tx_payload_addr[3:0] - 4'd1;
 
     always @(posedge clk or negedge rst_n) begin
         if (!rst_n) begin
@@ -155,19 +157,19 @@ module mrdimm_host_command #(
             if (tx_start && tx_frame_type == RSP_ACK)
                 ack_word <= {96'd0, ack_detail, ack_status, ack_request};
             if (tx_start_or_running) begin
-                if (event_valid)
+                if (tx_frame_type==RSP_EVENT)
                     // addr 0: count byte; addr>=1: record bytes, and
                     // (addr-1)%16 == addr[3:0] because records are 16B
                     tx_payload_data_r <= (tx_payload_addr == 16'd0) ?
                         ev_freeze_count : ev_rd_data[ev_byte_sel*8 +: 8];
-                else if (status_valid)
+                else if (tx_frame_type==RSP_STATUS)
                     tx_payload_data_r <= status_byte_in;
                 else
                     tx_payload_data_r <= ack_word[tx_payload_addr[3:0]*8 +: 8];
             end
         end
     end
-    wire [7:0] tx_payload_data = tx_payload_data_r;
+    assign tx_payload_data = tx_payload_data_r;
     // Bank fake-tx ACK capture walks this mux with tx_payload_addr 0..3.
     assign ack_payload_data = ack_word[tx_payload_addr[3:0]*8 +: 8];
 
@@ -189,6 +191,7 @@ module mrdimm_host_command #(
             tx_start <= 0; tx_frame_type <= RSP_ACK; tx_payload_length <= 0;
             transaction_done <= 0;
             status_valid <= 0; event_valid <= 0;
+            ctl_sent <= 0;
         end else begin
             thermal_wr_en <= 0; thermal_commit <= 0; keepalive_reload <= 0;
             snapshot_capture <= 0;
@@ -199,6 +202,7 @@ module mrdimm_host_command #(
             transaction_done <= 0;
             case (state)
                 ST_IDLE: if (frame_valid) begin
+                    ctl_sent <= 0;
                     case (frame_type)
                         T_SET_ALL: begin
                             if (frame_length != 16'd11) begin
@@ -390,8 +394,9 @@ module mrdimm_host_command #(
                         state <= ST_CTL_WAIT;
                     end else payload_read_addr <= payload_read_addr + 16'd1;
                 end
-                ST_CTL_WAIT: if (!ctl_valid) begin
+                ST_CTL_WAIT: if (!ctl_sent) begin
                     ctl_valid <= 1;
+                    ctl_sent <= 1;
                     ctl_op <= ctl_op_r; ctl_axis_mask <= ctl_mask_r;
                     ctl_flags <= ctl_flags_r; ctl_value <= ctl_value_r;
                 end else if (ctl_accept) begin
@@ -400,7 +405,8 @@ module mrdimm_host_command #(
 
                 // ---- EVENT_CLEAR ----
                 ST_EVCLEAR_SEND: begin
-                    if (payload_read_data == 8'd0) begin
+                    if (payload_read_data == 8'd0 ||
+                        (payload_read_data > 8'd64 && payload_read_data != 8'hFF)) begin
                         start_ack(1'b0, T_EVCLEAR, S_BADVAL, DET_NONE);
                     end else begin
                         ev_clear_n <= 1;

+ 1 - 1
tests/sim/prod2u_mrdimm_uart_e2e_tb.v

@@ -127,7 +127,7 @@ module prod2u_mrdimm_uart_e2e_tb;
         .ev_clear_n(ev_clear_n_w), .ev_clear_count(ev_clear_count_w),
         .status_byte_in(status_byte_in),
         .tx_payload_addr(u_frame_tx.payload_addr),
-        .ack_payload_data(tx_payload_data),
+        .ack_payload_data(), .tx_payload_data(tx_payload_data),
         .tx_start(tx_start), .tx_frame_type(tx_frame_type),
         .tx_payload_length(tx_payload_length), .tx_done(host_response_done_w),
         .transaction_done(), .busy(host_command_busy)