Browse Source

Isolate single-port retained history from diagnostic parallel reads

codex 2 months ago
parent
commit
8c0b50728b
1 changed files with 23 additions and 4 deletions
  1. 23 4
      src/motor/motor_engine.v

+ 23 - 4
src/motor/motor_engine.v

@@ -292,8 +292,7 @@ module motor_engine #(
     wire [15:0] bank_telemetry_word;
     wire [15:0] queue_depth_word={2'd0,depth_r[telemetry_axis],8'd0};
     wire [15:0] queue_pause_word=queue_paused_r[telemetry_axis] ? (16'd1<<`MR_AXIS_FLAG_QUEUE_PAUSED_BIT) : 16'd0;
-    // Declare the memory before all addressed uses so the TD HDL front end
-    // sees an unpacked memory at the first read, rather than a forward net.
+    // Parallel copy is diagnostic only; production has one addressed bank.
     reg [159:0] limit_record [0:AXIS_COUNT-1];
     reg [AXIS_COUNT-1:0] limit_history_valid;
     integer ev_select,ev_scan,ev_i;
@@ -304,7 +303,11 @@ module motor_engine #(
     reg [AXIS_INDEX_BITS-1:0] history_scan_axis;
     wire limit_dispatch=!ev_wr_req && !reset_pending && ev_select>=0 && select_limit;
     wire [AXIS_INDEX_BITS-1:0] limit_read_axis=limit_dispatch ? ev_select[AXIS_INDEX_BITS-1:0] : history_scan_axis;
-    wire [159:0] limit_read_record=limit_record[limit_read_axis];
+    wire [159:0] limit_read_record;
+    motor_limit_history #(.AXIS_COUNT(AXIS_COUNT)) u_limit_history(
+        .clk(clk),.write_enable(rst_n && (|ax_limit_pulse)),
+        .write_axis(limit_write_axis[AXIS_INDEX_BITS-1:0]),.write_data({ax_limit_time_high,ax_limit_data}),
+        .read_axis(limit_read_axis),.read_data(limit_read_record));
     wire [159:0] status_limit_record=limit_history_valid[limit_read_axis] ? limit_read_record : 160'd0;
     reg [31:0] history_pair;
     wire history_selected=telemetry_word_addr>=`MR_AXIS_LAST_LIMIT_POSITION_OFFSET/2 &&
@@ -474,7 +477,7 @@ module motor_engine #(
     // One addressed write port per bank allows RAM inference. Reset clears
     // validity bits below; stale storage is never emitted after reset.
     always @(posedge clk)begin
-        if(rst_n && (|ax_limit_pulse))limit_record[limit_write_axis]<={ax_limit_time_high,ax_limit_data};
+        if(PARALLEL_TELEMETRY && rst_n && (|ax_limit_pulse))limit_record[limit_write_axis]<={ax_limit_time_high,ax_limit_data};
         if(rst_n && done_record_write)
             pending_record[done_write_axis]<={ax_done_word[127:48],
                 ((home_pending_r[done_write_axis] && ax_reason[done_write_axis]==SR_LOWER)?EV_HOME:event_for_stop(ax_reason[done_write_axis])),
@@ -813,6 +816,22 @@ module motor_engine #(
     end
 endmodule
 
+// Keep the production memory's single read/write ports explicit. Diagnostic
+// parallel views live outside this boundary and cannot change its inference.
+module motor_limit_history #(
+    parameter integer AXIS_COUNT=3,
+    parameter integer ADDRESS_WIDTH=(AXIS_COUNT<=1)?1:$clog2(AXIS_COUNT)
+)(
+    input wire clk,write_enable,
+    input wire [ADDRESS_WIDTH-1:0] write_axis,read_axis,
+    input wire [159:0] write_data,
+    output wire [159:0] read_data
+);
+    reg [159:0] records [0:AXIS_COUNT-1];
+    always @(posedge clk)if(write_enable)records[write_axis]<=write_data;
+    assign read_data=records[read_axis];
+endmodule
+
 // Validated queue descriptors need85 bits: mode3, direction1, arm1,
 // count32, half-period32 and tag16. Axis is implicit in the slot address;
 // preempt/clear/reserved fields have already been consumed by batch commit.