فهرست منبع

Build internal seek descriptors from the held control context

codex 3 ماه پیش
والد
کامیت
59ca3e7d3c
1فایلهای تغییر یافته به همراه12 افزوده شده و 9 حذف شده
  1. 12 9
      src/motor/motor_engine.v

+ 12 - 9
src/motor/motor_engine.v

@@ -132,7 +132,6 @@ module motor_engine #(
     reg [5:0] head_r    [0:AXIS_COUNT-1];  // oldest waiting slot
     reg [5:0] head_r    [0:AXIS_COUNT-1];  // oldest waiting slot
     reg       queue_paused_r [0:AXIS_COUNT-1];
     reg       queue_paused_r [0:AXIS_COUNT-1];
     reg       urgent_valid_r [0:AXIS_COUNT-1];
     reg       urgent_valid_r [0:AXIS_COUNT-1];
-    reg [127:0] urgent_r [0:AXIS_COUNT-1];
     reg       urgent_from_queue [0:AXIS_COUNT-1];
     reg       urgent_from_queue [0:AXIS_COUNT-1];
     reg       home_pending_r [0:AXIS_COUNT-1];
     reg       home_pending_r [0:AXIS_COUNT-1];
 
 
@@ -234,6 +233,8 @@ module motor_engine #(
     wire [31:0] cs_value=ctl_value;
     wire [31:0] cs_value=ctl_value;
     wire [7:0] cs_flags=ctl_flags;
     wire [7:0] cs_flags=ctl_flags;
     reg [1:0]  cs_state;      // 0 idle, 1 exec, 2 done-pulse
     reg [1:0]  cs_state;      // 0 idle, 1 exec, 2 done-pulse
+    wire seek_context=cs_state==2 && (cs_op==OP_HOME_LOWER || cs_op==OP_SEEK_UPPER);
+    wire [AXIS_COUNT-1:0] internal_urgent_pending;
     reg [AXIS_COUNT-1:0] cs_start_mask;
     reg [AXIS_COUNT-1:0] cs_start_mask;
     reg [1:0]  cs_axis;
     reg [1:0]  cs_axis;
     reg        cs_home;
     reg        cs_home;
@@ -345,6 +346,7 @@ module motor_engine #(
         else if(status_changing)motor_status_epoch<=motor_status_epoch+1'b1;
         else if(status_changing)motor_status_epoch<=motor_status_epoch+1'b1;
     end
     end
     generate for(g=0;g<AXIS_COUNT;g=g+1)begin:g_bank_ports
     generate for(g=0;g<AXIS_COUNT;g=g+1)begin:g_bank_ports
+        assign internal_urgent_pending[g]=urgent_valid_r[g] && !urgent_from_queue[g];
         assign ax_seg_mode[g]=load_mode;
         assign ax_seg_mode[g]=load_mode;
         assign ax_seg_upper[g]=load_upper;assign ax_seg_armed[g]=load_armed;
         assign ax_seg_upper[g]=load_upper;assign ax_seg_armed[g]=load_armed;
         assign ax_seg_count[g]=load_count;assign ax_seg_half[g]=load_half;assign ax_seg_tag[g]=load_tag;
         assign ax_seg_count[g]=load_count;assign ax_seg_half[g]=load_half;assign ax_seg_tag[g]=load_tag;
@@ -689,7 +691,7 @@ module motor_engine #(
                         fx_candidate=fx_round+fx_k;
                         fx_candidate=fx_round+fx_k;
                         if(fx_candidate>=AXIS_COUNT)fx_candidate=fx_candidate-AXIS_COUNT;
                         if(fx_candidate>=AXIS_COUNT)fx_candidate=fx_candidate-AXIS_COUNT;
                         if (ax_load_ready[fx_candidate] && !ax_seg_load[fx_candidate] && !queue_paused_r[fx_candidate] && !ctl_valid &&
                         if (ax_load_ready[fx_candidate] && !ax_seg_load[fx_candidate] && !queue_paused_r[fx_candidate] && !ctl_valid &&
-                            (cs_state==0 || (cs_state==3 && cs_start_mask[fx_candidate])) && qc_state==QC_IDLE && !qw_submit &&
+                            (cs_state==0 || (cs_state==3 && cs_start_mask[fx_candidate]) || (seek_context && cs_mask[fx_candidate])) && qc_state==QC_IDLE && !qw_submit &&
                             su_axis>=AXIS_COUNT && !startup_seek) begin
                             su_axis>=AXIS_COUNT && !startup_seek) begin
                             if (urgent_valid_r[fx_candidate]) begin
                             if (urgent_valid_r[fx_candidate]) begin
                                 fx_axis <= fx_candidate[AXIS_INDEX_BITS-1:0];
                                 fx_axis <= fx_candidate[AXIS_INDEX_BITS-1:0];
@@ -697,7 +699,12 @@ module motor_engine #(
                                 if(urgent_from_queue[fx_candidate])begin
                                 if(urgent_from_queue[fx_candidate])begin
                                     fx_state<=FX_RD;q_rd_addr<=AXIS_COUNT*32+fx_candidate;q_re<=1;
                                     fx_state<=FX_RD;q_rd_addr<=AXIS_COUNT*32+fx_candidate;q_re<=1;
                                 end else begin
                                 end else begin
-                                    fx_state<=FX_LOAD;fx_seg<=urgent_r[fx_candidate];
+                                    // The accepted seek context is held until all
+                                    // selected internal descriptors are consumed.
+                                    fx_state<=FX_LOAD;
+                                    fx_seg<={32'd0,(cs_value!=0 ? cs_value :
+                                        (fx_candidate==0 ? X_DEFAULT_HALF_US : (fx_candidate==1 ? Y_DEFAULT_HALF_US : Z_DEFAULT_HALF_US))),
+                                        32'd0,8'd0,8'd0,(cs_op==OP_HOME_LOWER ? 8'd1 : 8'd2),fx_candidate[7:0]};
                                 end
                                 end
                             end else if (depth_r[fx_candidate] != 0) begin
                             end else if (depth_r[fx_candidate] != 0) begin
                                 fx_state <= FX_RD;
                                 fx_state <= FX_RD;
@@ -774,11 +781,6 @@ module motor_engine #(
                             OP_HOME_LOWER,OP_SEEK_UPPER: begin
                             OP_HOME_LOWER,OP_SEEK_UPPER: begin
                                 ax_preempt[i]<=1;depth_r[i]<=0;queue_paused_r[i]<=0;
                                 ax_preempt[i]<=1;depth_r[i]<=0;queue_paused_r[i]<=0;
                                 urgent_valid_r[i]<=1;urgent_from_queue[i]<=0;
                                 urgent_valid_r[i]<=1;urgent_from_queue[i]<=0;
-                                urgent_r[i]<={16'd0,16'd0,
-                                    (cs_value!=0 ? cs_value :
-                                        (i==0 ? X_DEFAULT_HALF_US : (i==1 ? Y_DEFAULT_HALF_US : Z_DEFAULT_HALF_US))),
-                                    32'd0,8'd0,8'd0,
-                                    (cs_op==OP_HOME_LOWER ? 8'd1 : 8'd2),i[7:0]};
                                 home_pending_r[i]<=(cs_op==OP_HOME_LOWER);
                                 home_pending_r[i]<=(cs_op==OP_HOME_LOWER);
                             end
                             end
                         endcase
                         endcase
@@ -790,7 +792,8 @@ module motor_engine #(
                 cs_state<=2;
                 cs_state<=2;
             // Keep the shared value stable until the scanner consumed all
             // Keep the shared value stable until the scanner consumed all
             // control pulses. ACK then releases the one command context.
             // control pulses. ACK then releases the one command context.
-            end else if(cs_state==2 && !bank_telemetry_changing) begin
+            end else if(cs_state==2 && !bank_telemetry_changing &&
+                (!seek_context || (internal_urgent_pending==0 && fx_state==FX_IDLE && ax_seg_load==0))) begin
                 ctl_accept<=1;ctl_status<=ST_OK;cs_state<=0;
                 ctl_accept<=1;ctl_status<=ST_OK;cs_state<=0;
             end
             end