|
@@ -186,14 +186,13 @@ module motor_engine #(
|
|
|
reg [3:0] qc_count;
|
|
reg [3:0] qc_count;
|
|
|
reg [7:0] qc_is_urgent;
|
|
reg [7:0] qc_is_urgent;
|
|
|
wire [5:0] qc_base_depth [0:AXIS_COUNT-1];
|
|
wire [5:0] qc_base_depth [0:AXIS_COUNT-1];
|
|
|
- reg [3:0] qc_new_count [0:AXIS_COUNT-1]; // one batch has at most8 descriptors
|
|
|
|
|
- reg [4:0] qc_new_head [0:AXIS_COUNT-1];
|
|
|
|
|
|
|
+ reg [3:0] qc_new_count [0:AXIS_COUNT-1]; // validated count, then write offset; maximum8
|
|
|
|
|
+ reg [4:0] qc_insert_base [0:AXIS_COUNT-1];
|
|
|
reg [AXIS_COUNT-1:0] qc_resume, start_credit;
|
|
reg [AXIS_COUNT-1:0] qc_resume, start_credit;
|
|
|
reg [AXIS_INDEX_BITS-1:0] qc_space_axis;
|
|
reg [AXIS_INDEX_BITS-1:0] qc_space_axis;
|
|
|
wire [6:0] qc_space_total={1'b0,qc_base_depth[qc_space_axis]}+{3'd0,qc_new_count[qc_space_axis]};
|
|
wire [6:0] qc_space_total={1'b0,qc_base_depth[qc_space_axis]}+{3'd0,qc_new_count[qc_space_axis]};
|
|
|
wire qc_space_bad=qc_space_total>7'd32;
|
|
wire qc_space_bad=qc_space_total>7'd32;
|
|
|
reg [5:0] qc_proj_depth [0:AXIS_COUNT-1]; // projected waiting depth
|
|
reg [5:0] qc_proj_depth [0:AXIS_COUNT-1]; // projected waiting depth
|
|
|
- reg [5:0] qc_append_pos [0:AXIS_COUNT-1]; // next free slot per axis
|
|
|
|
|
reg [AXIS_COUNT-1:0] qc_first_of_axis;
|
|
reg [AXIS_COUNT-1:0] qc_first_of_axis;
|
|
|
reg [AXIS_COUNT-1:0] qc_want_preempt; // first-seg preempt request per axis
|
|
reg [AXIS_COUNT-1:0] qc_want_preempt; // first-seg preempt request per axis
|
|
|
reg [AXIS_COUNT-1:0] qc_want_clear;
|
|
reg [AXIS_COUNT-1:0] qc_want_clear;
|
|
@@ -208,6 +207,7 @@ module motor_engine #(
|
|
|
wire [31:0] stage_min_half = (f_axis(stage_data) == 2'd0) ? X_MIN_HALF_US :
|
|
wire [31:0] stage_min_half = (f_axis(stage_data) == 2'd0) ? X_MIN_HALF_US :
|
|
|
(f_axis(stage_data) == 2'd1) ? Y_MIN_HALF_US : Z_MIN_HALF_US;
|
|
(f_axis(stage_data) == 2'd1) ? Y_MIN_HALF_US : Z_MIN_HALF_US;
|
|
|
wire [AXIS_INDEX_BITS-1:0] qc_axis = f_axis(stage_data);
|
|
wire [AXIS_INDEX_BITS-1:0] qc_axis = f_axis(stage_data);
|
|
|
|
|
+ wire [4:0] qc_write_slot=qc_insert_base[qc_axis]+{1'b0,qc_new_count[qc_axis]};
|
|
|
|
|
|
|
|
// ---- execute fetch FSM ----
|
|
// ---- execute fetch FSM ----
|
|
|
localparam [2:0] FX_IDLE=0, FX_RD=1, FX_LOAD=2, FX_WAIT=3, FX_CONSUME=4;
|
|
localparam [2:0] FX_IDLE=0, FX_RD=1, FX_LOAD=2, FX_WAIT=3, FX_CONSUME=4;
|
|
@@ -665,12 +665,13 @@ module motor_engine #(
|
|
|
// row per clock. No live queue state or RAM is published
|
|
// row per clock. No live queue state or RAM is published
|
|
|
// until every row and every descriptor has passed.
|
|
// until every row and every descriptor has passed.
|
|
|
qc_proj_depth[qc_space_axis]<=qc_space_total[5:0];
|
|
qc_proj_depth[qc_space_axis]<=qc_space_total[5:0];
|
|
|
- qc_new_head[qc_space_axis]<=qc_want_preempt[qc_space_axis] && !qc_want_clear[qc_space_axis] ?
|
|
|
|
|
- (head_r[qc_space_axis][4:0]-{1'b0,qc_new_count[qc_space_axis]}) : head_r[qc_space_axis][4:0];
|
|
|
|
|
- qc_append_pos[qc_space_axis]<=qc_want_preempt[qc_space_axis] ?
|
|
|
|
|
|
|
+ qc_insert_base[qc_space_axis]<=qc_want_preempt[qc_space_axis] ?
|
|
|
(qc_want_clear[qc_space_axis] ? head_r[qc_space_axis][4:0] :
|
|
(qc_want_clear[qc_space_axis] ? head_r[qc_space_axis][4:0] :
|
|
|
- ((head_r[qc_space_axis][4:0]-{1'b0,qc_new_count[qc_space_axis]}) & 5'h1F)) :
|
|
|
|
|
- ((head_r[qc_space_axis][4:0]+qc_base_depth[qc_space_axis][4:0]) & 5'h1F);
|
|
|
|
|
|
|
+ (head_r[qc_space_axis][4:0]-{1'b0,qc_new_count[qc_space_axis]})) :
|
|
|
|
|
+ (head_r[qc_space_axis][4:0]+qc_base_depth[qc_space_axis][4:0]);
|
|
|
|
|
+ // Capacity and insertion base now own the validated count.
|
|
|
|
|
+ // Reuse its register as this axis's write offset.
|
|
|
|
|
+ qc_new_count[qc_space_axis]<=0;
|
|
|
if(qc_space_axis==AXIS_COUNT-1)begin
|
|
if(qc_space_axis==AXIS_COUNT-1)begin
|
|
|
qc_index<=0;stage_byte_index<=0;stage_for_write<=1;qc_state<=QC_STAGE_WAIT;
|
|
qc_index<=0;stage_byte_index<=0;stage_for_write<=1;qc_state<=QC_STAGE_WAIT;
|
|
|
end else qc_space_axis<=qc_space_axis+1'b1;
|
|
end else qc_space_axis<=qc_space_axis+1'b1;
|
|
@@ -683,8 +684,8 @@ module motor_engine #(
|
|
|
// Write after full validation, publish valid atomically.
|
|
// Write after full validation, publish valid atomically.
|
|
|
q_wr_addr<=AXIS_COUNT*32+qc_axis;
|
|
q_wr_addr<=AXIS_COUNT*32+qc_axis;
|
|
|
end else begin
|
|
end else begin
|
|
|
- q_wr_addr<=qc_axis*32+qc_append_pos[qc_axis][4:0];
|
|
|
|
|
- qc_append_pos[qc_axis]<=(qc_append_pos[qc_axis]+1'b1)&6'd31;
|
|
|
|
|
|
|
+ q_wr_addr<=qc_axis*32+qc_write_slot;
|
|
|
|
|
+ qc_new_count[qc_axis]<=qc_new_count[qc_axis]+1'b1;
|
|
|
end
|
|
end
|
|
|
q_wr_data<=stage_data;q_we<=1;
|
|
q_wr_data<=stage_data;q_we<=1;
|
|
|
qc_index<=qc_index+1'b1;stage_byte_index<=0;
|
|
qc_index<=qc_index+1'b1;stage_byte_index<=0;
|
|
@@ -696,7 +697,8 @@ module motor_engine #(
|
|
|
for(i=0;i<AXIS_COUNT;i=i+1) begin
|
|
for(i=0;i<AXIS_COUNT;i=i+1) begin
|
|
|
if(!qc_first_of_axis[i]) begin
|
|
if(!qc_first_of_axis[i]) begin
|
|
|
home_pending_r[i]<=0;
|
|
home_pending_r[i]<=0;
|
|
|
- depth_r[i]<=qc_proj_depth[i];head_r[i]<=qc_new_head[i];
|
|
|
|
|
|
|
+ depth_r[i]<=qc_proj_depth[i];
|
|
|
|
|
+ if(qc_want_preempt[i])head_r[i]<=qc_insert_base[i];
|
|
|
if(qc_want_clear[i]) urgent_valid_r[i]<=0;
|
|
if(qc_want_clear[i]) urgent_valid_r[i]<=0;
|
|
|
if(qc_want_preempt[i]) begin
|
|
if(qc_want_preempt[i]) begin
|
|
|
urgent_valid_r[i]<=1;urgent_from_queue[i]<=1;ax_preempt[i]<=1;
|
|
urgent_valid_r[i]<=1;urgent_from_queue[i]<=1;ax_preempt[i]<=1;
|