Преглед изворни кода

Factor one-bit queue arbitration from the shared descriptor datapath

codex пре 2 месеци
родитељ
комит
d4e2595ff2
1 измењених фајлова са 23 додато и 6 уклоњено
  1. 23 6
      src/motor/motor_engine.v

+ 23 - 6
src/motor/motor_engine.v

@@ -211,7 +211,10 @@ module motor_engine #(
     reg [2:0] fx_state;
     reg [AXIS_INDEX_BITS-1:0] fx_axis;
     reg [AXIS_INDEX_BITS-1:0] fx_round;
-    integer fx_k,fx_candidate;
+    integer fx_k,fx_probe;
+    reg [AXIS_COUNT-1:0] fx_eligible;
+    reg [7:0] fx_candidate;
+    reg fx_candidate_valid;
     reg       fx_from_urgent;
     reg [127:0] fx_seg;
 
@@ -501,6 +504,21 @@ module motor_engine #(
             endcase
         end
     endfunction
+    // Factor one-bit eligibility/priority from the wide descriptor datapath.
+    // This preserves the original round-robin winner and one-clock arbitration.
+    always @* begin
+        for(fx_k=0;fx_k<AXIS_COUNT;fx_k=fx_k+1)
+            fx_eligible[fx_k]=ax_load_ready[fx_k] && !ax_seg_load[fx_k] && !queue_paused_r[fx_k] &&
+                (cs_state==0 || (cs_state==3 && cs_start_mask[fx_k]) || (seek_context && cs_mask[fx_k])) &&
+                (urgent_valid_r[fx_k] || depth_r[fx_k]!=0);
+        fx_candidate=0;fx_candidate_valid=0;fx_probe=0;
+        for(fx_k=AXIS_COUNT-1;fx_k>=0;fx_k=fx_k-1)begin
+            fx_probe=fx_round+fx_k;
+            if(fx_probe>=AXIS_COUNT)fx_probe=fx_probe-AXIS_COUNT;
+            if(fx_eligible[fx_probe])begin fx_candidate=fx_probe[7:0];fx_candidate_valid=1;end
+        end
+    end
+
     always @* begin
         ev_select=-1;select_limit=0;pending_losses=0;
         for(ev_scan=AXIS_COUNT-1;ev_scan>=0;ev_scan=ev_scan-1)
@@ -687,11 +705,10 @@ module motor_engine #(
             // ---- execution fetch: idle axis takes urgent, else head ----
             case (fx_state)
                 FX_IDLE: begin
-                    for (fx_k = AXIS_COUNT - 1; fx_k >= 0; fx_k = fx_k - 1) begin
-                        fx_candidate=fx_round+fx_k;
-                        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 &&
-                            (cs_state==0 || (cs_state==3 && cs_start_mask[fx_candidate]) || (seek_context && cs_mask[fx_candidate])) && qc_state==QC_IDLE && !qw_submit &&
+                    // Arbitration selects only an axis. One datapath below
+                    // owns address and descriptor construction for that winner.
+                    begin
+                        if (fx_candidate_valid && !ctl_valid && qc_state==QC_IDLE && !qw_submit &&
                             su_axis>=AXIS_COUNT && !startup_seek) begin
                             if (urgent_valid_r[fx_candidate]) begin
                                 fx_axis <= fx_candidate[AXIS_INDEX_BITS-1:0];