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

Rotate wide state with the axis scanner to remove address muxes

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

+ 11 - 6
src/motor/motor_axis_core.v

@@ -414,7 +414,7 @@ module motor_axis_state_bank #(
  reg [AXIS_COUNT-1:0] valid;
  wire [223:0] raw_data;
  motor_axis_words #(.AXIS_COUNT(AXIS_COUNT)) u_words(
-  .clk(clk),.rst_n(rst_n),.axis(axis),.write_data(write_data),.read_data(raw_data));
+  .clk(clk),.rst_n(rst_n),.write_data(write_data),.read_data(raw_data));
  assign read_data=raw_data;
  always @(posedge clk or negedge rst_n)begin
   if(!rst_n)valid<=0;else valid[axis]<=1;
@@ -431,15 +431,20 @@ module motor_axis_state_bank #(
  end endgenerate
 endmodule
 
-module motor_axis_words #(parameter integer AXIS_COUNT=3,
- parameter integer AW=(AXIS_COUNT<=1)?1:$clog2(AXIS_COUNT))
-(input wire clk,rst_n,input wire [AW-1:0] axis,
+// The head is the current scan axis. Both the core axis index and this bank
+// advance every active clock; the updated word returns at the tail. This
+// removes the wide dynamic read selector and per-axis write selection.
+module motor_axis_words #(parameter integer AXIS_COUNT=3)
+(input wire clk,rst_n,
  input wire [223:0] write_data,output wire [223:0] read_data);
  reg [223:0] words [0:AXIS_COUNT-1];
  integer i;
  always @(posedge clk or negedge rst_n)begin
   if(!rst_n)for(i=0;i<AXIS_COUNT;i=i+1)words[i]<=224'd1;
-  else words[axis]<=write_data;
+  else begin
+   for(i=0;i<AXIS_COUNT-1;i=i+1)words[i]<=words[i+1];
+   words[AXIS_COUNT-1]<=write_data;
+  end
  end
- assign read_data=words[axis];
+ assign read_data=words[0];
 endmodule

+ 2 - 1
tests/sim/motor_history_shared_tb.v

@@ -77,7 +77,8 @@ module motor_history_shared_tb #(parameter integer AXIS_COUNT=3);
   lower=1;repeat(60)@(negedge clk);
   if(!captured)$fatal(1,"physical lower edge missing");
   saved_history={8'd2,16'd0,expected_time,32'd0,32'h81234567};check_history;
-  if(g[0].dut.u_axes.u_state_bank.u_words.words[0][127:96]!=0)$fatal(1,"lower edge did not zero position after capture");
+  while(g[0].dut.u_axes.scan_axis!=0)@(negedge clk);
+  if(g[0].dut.u_axes.s_position!=0)$fatal(1,"lower edge did not zero position after capture");
   control(3,0);check_history; // counter clear does not erase the last limit
   @(negedge clk);clear=1;@(negedge clk);clear=0;repeat(60)@(negedge clk);
   if(event_count[0]!=0 || event_count[1]!=0)$fatal(1,"event clear failed");check_history;

+ 2 - 3
tests/sim/prod2u_mrdimm_i2c_e2e_tb.v

@@ -13,15 +13,14 @@ module prod2u_mrdimm_i2c_e2e_tb;
     integer x_rises=0;
     reg x_previous=0;
     // Observe the production counter bank; parallel diagnostic views are off.
-    wire [31:0] x_emitted_total=dut.u_motor.u_axes.u_state_bank.valid[0] ?
-        dut.u_motor.u_axes.u_state_bank.u_words.words[0][159:128] : 32'd0;
+    wire [31:0] selected_emitted_total=dut.u_motor.u_axes.s_total;
     always @(posedge clk)begin
         #1;
         if(!dut.rst_n)begin x_rises=0;x_previous=0;end
         else begin
             if(x_step && !x_previous)x_rises=x_rises+1;
             x_previous=x_step;
-            if(dut.motor_telemetry_ready && x_emitted_total!==x_rises)
+            if(dut.motor_telemetry_ready && dut.u_motor.u_axes.scan_axis==0 && selected_emitted_total!==x_rises)
                 $fatal(1,"snapshot/Host activity lost actual motor STEP counts");
         end
     end