|
@@ -206,8 +206,8 @@ module motor_engine #(
|
|
|
wire [AXIS_INDEX_BITS-1:0] qc_axis = f_axis(stage_data);
|
|
wire [AXIS_INDEX_BITS-1:0] qc_axis = f_axis(stage_data);
|
|
|
|
|
|
|
|
// ---- execute fetch FSM ----
|
|
// ---- execute fetch FSM ----
|
|
|
- localparam [1:0] FX_IDLE = 2'd0, FX_RD = 2'd1, FX_LOAD = 2'd2, FX_WAIT = 2'd3;
|
|
|
|
|
- reg [1:0] fx_state;
|
|
|
|
|
|
|
+ localparam [2:0] FX_IDLE=0, FX_RD=1, FX_LOAD=2, FX_WAIT=3, FX_CONSUME=4;
|
|
|
|
|
+ reg [2:0] fx_state;
|
|
|
reg [AXIS_INDEX_BITS-1:0] fx_axis;
|
|
reg [AXIS_INDEX_BITS-1:0] fx_axis;
|
|
|
reg [AXIS_INDEX_BITS-1:0] fx_round;
|
|
reg [AXIS_INDEX_BITS-1:0] fx_round;
|
|
|
integer fx_k,fx_candidate;
|
|
integer fx_k,fx_candidate;
|
|
@@ -234,6 +234,7 @@ module motor_engine #(
|
|
|
reg [1:0] cs_axis;
|
|
reg [1:0] cs_axis;
|
|
|
reg cs_home;
|
|
reg cs_home;
|
|
|
reg [AXIS_COUNTER_BITS-1:0] su_axis; // includes terminal AXIS_COUNT
|
|
reg [AXIS_COUNTER_BITS-1:0] su_axis; // includes terminal AXIS_COUNT
|
|
|
|
|
+ reg su_wait;
|
|
|
|
|
|
|
|
// ---- axis cores ----
|
|
// ---- axis cores ----
|
|
|
wire [AXIS_COUNT-1:0] ax_active, ax_armed, ax_load_ready, ax_ref_seen, ax_done;
|
|
wire [AXIS_COUNT-1:0] ax_active, ax_armed, ax_load_ready, ax_ref_seen, ax_done;
|
|
@@ -254,11 +255,17 @@ module motor_engine #(
|
|
|
assign step_out = step_out_w;
|
|
assign step_out = step_out_w;
|
|
|
assign dir_out = dir_out_w;
|
|
assign dir_out = dir_out_w;
|
|
|
|
|
|
|
|
- reg [AXIS_COUNT-1:0] ax_seg_load, ax_seg_upper, ax_seg_armed;
|
|
|
|
|
- reg [2:0] ax_seg_mode [0:AXIS_COUNT-1];
|
|
|
|
|
- reg [31:0] ax_seg_count [0:AXIS_COUNT-1];
|
|
|
|
|
- reg [31:0] ax_seg_half [0:AXIS_COUNT-1];
|
|
|
|
|
- reg [15:0] ax_seg_tag [0:AXIS_COUNT-1];
|
|
|
|
|
|
|
+ reg [AXIS_COUNT-1:0] ax_seg_load;
|
|
|
|
|
+ wire [AXIS_COUNT-1:0] ax_seg_upper,ax_seg_armed,ax_seg_consumed;
|
|
|
|
|
+ wire [2:0] ax_seg_mode [0:AXIS_COUNT-1];
|
|
|
|
|
+ wire [31:0] ax_seg_count [0:AXIS_COUNT-1],ax_seg_half [0:AXIS_COUNT-1];
|
|
|
|
|
+ wire [15:0] ax_seg_tag [0:AXIS_COUNT-1];
|
|
|
|
|
+ // One descriptor register serves startup and queue execution. The
|
|
|
|
|
+ // consumer acknowledgment keeps it stable through any pending scan.
|
|
|
|
|
+ reg [2:0] load_mode;
|
|
|
|
|
+ reg load_upper,load_armed;
|
|
|
|
|
+ reg [31:0] load_count,load_half;
|
|
|
|
|
+ reg [15:0] load_tag;
|
|
|
reg [AXIS_COUNT-1:0] ax_start_armed, ax_abort, ax_preempt;
|
|
reg [AXIS_COUNT-1:0] ax_start_armed, ax_abort, ax_preempt;
|
|
|
reg [AXIS_COUNT-1:0] ax_pos_load, ax_ctr_clear, ax_pos_zero, ax_lat_clear;
|
|
reg [AXIS_COUNT-1:0] ax_pos_load, ax_ctr_clear, ax_pos_zero, ax_lat_clear;
|
|
|
|
|
|
|
@@ -294,6 +301,9 @@ 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 ax_seg_mode[g]=load_mode;
|
|
|
|
|
+ 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 bank_seg_mode[g*3 +:3]=ax_seg_mode[g];
|
|
assign bank_seg_mode[g*3 +:3]=ax_seg_mode[g];
|
|
|
assign bank_seg_count[g*32 +:32]=ax_seg_count[g];
|
|
assign bank_seg_count[g*32 +:32]=ax_seg_count[g];
|
|
|
assign bank_seg_half_us[g*32 +:32]=ax_seg_half[g];
|
|
assign bank_seg_half_us[g*32 +:32]=ax_seg_half[g];
|
|
@@ -337,6 +347,7 @@ module motor_engine #(
|
|
|
.limit_lower(ll_s2),
|
|
.limit_lower(ll_s2),
|
|
|
.limit_upper(ul_s2),
|
|
.limit_upper(ul_s2),
|
|
|
.seg_load(ax_seg_load),
|
|
.seg_load(ax_seg_load),
|
|
|
|
|
+ .seg_consumed(ax_seg_consumed),
|
|
|
.seg_dir_upper(ax_seg_upper),
|
|
.seg_dir_upper(ax_seg_upper),
|
|
|
.seg_armed(ax_seg_armed),
|
|
.seg_armed(ax_seg_armed),
|
|
|
.start_armed(ax_start_armed),
|
|
.start_armed(ax_start_armed),
|
|
@@ -501,7 +512,7 @@ module motor_engine #(
|
|
|
end
|
|
end
|
|
|
q_we <= 1'b0;q_re<=0;
|
|
q_we <= 1'b0;q_re<=0;
|
|
|
|
|
|
|
|
- cs_state <= 2'd0; su_axis <= AXIS_COUNT;
|
|
|
|
|
|
|
+ cs_state <= 2'd0; su_axis <= AXIS_COUNT;su_wait<=0;
|
|
|
end else begin
|
|
end else begin
|
|
|
// default single-cycle pulses
|
|
// default single-cycle pulses
|
|
|
ax_seg_load <= {AXIS_COUNT{1'b0}};
|
|
ax_seg_load <= {AXIS_COUNT{1'b0}};
|
|
@@ -619,7 +630,8 @@ 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) begin
|
|
|
|
|
|
|
+ (cs_state==0 || (cs_state==3 && cs_start_mask[fx_candidate])) && qc_state==QC_IDLE && !qw_submit &&
|
|
|
|
|
+ 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];
|
|
|
fx_from_urgent <= 1'b1;
|
|
fx_from_urgent <= 1'b1;
|
|
@@ -647,13 +659,13 @@ module motor_engine #(
|
|
|
end
|
|
end
|
|
|
FX_LOAD: begin
|
|
FX_LOAD: begin
|
|
|
ax_seg_load[fx_axis] <= 1'b1;
|
|
ax_seg_load[fx_axis] <= 1'b1;
|
|
|
- ax_seg_mode[fx_axis] <= f_mode(fx_seg);
|
|
|
|
|
- ax_seg_upper[fx_axis] <= f_upper(fx_seg);
|
|
|
|
|
- ax_seg_armed[fx_axis] <= cs_state==3 ? 1'b1 : (f_arm(fx_seg) && !start_credit[fx_axis]);
|
|
|
|
|
|
|
+ load_mode <= f_mode(fx_seg);
|
|
|
|
|
+ load_upper <= f_upper(fx_seg);
|
|
|
|
|
+ load_armed <= cs_state==3 ? 1'b1 : (f_arm(fx_seg) && !start_credit[fx_axis]);
|
|
|
start_credit[fx_axis] <= 0;
|
|
start_credit[fx_axis] <= 0;
|
|
|
- ax_seg_count[fx_axis] <= f_count(fx_seg);
|
|
|
|
|
- ax_seg_half[fx_axis] <= f_half(fx_seg);
|
|
|
|
|
- ax_seg_tag[fx_axis] <= f_tag(fx_seg);
|
|
|
|
|
|
|
+ load_count <= f_count(fx_seg);
|
|
|
|
|
+ load_half <= f_half(fx_seg);
|
|
|
|
|
+ load_tag <= f_tag(fx_seg);
|
|
|
if (fx_from_urgent) urgent_valid_r[fx_axis] <= 1'b0;
|
|
if (fx_from_urgent) urgent_valid_r[fx_axis] <= 1'b0;
|
|
|
else begin
|
|
else begin
|
|
|
// pop head
|
|
// pop head
|
|
@@ -662,9 +674,10 @@ module motor_engine #(
|
|
|
// Each head's ARM bit is loaded into the axis;
|
|
// Each head's ARM bit is loaded into the axis;
|
|
|
// the pause latch belongs to Abort/limit, not ARM.
|
|
// the pause latch belongs to Abort/limit, not ARM.
|
|
|
end
|
|
end
|
|
|
- fx_state <= FX_IDLE;
|
|
|
|
|
|
|
+ fx_state <= FX_CONSUME;
|
|
|
fx_round<=fx_axis==AXIS_COUNT-1 ? 0 : fx_axis+1'b1;
|
|
fx_round<=fx_axis==AXIS_COUNT-1 ? 0 : fx_axis+1'b1;
|
|
|
end
|
|
end
|
|
|
|
|
+ FX_CONSUME:if(ax_seg_consumed[fx_axis])fx_state<=FX_IDLE;
|
|
|
default: fx_state <= FX_IDLE;
|
|
default: fx_state <= FX_IDLE;
|
|
|
endcase
|
|
endcase
|
|
|
|
|
|
|
@@ -729,17 +742,21 @@ module motor_engine #(
|
|
|
|
|
|
|
|
// ---- startup: submit internal SEEK_LOWER per axis ----
|
|
// ---- startup: submit internal SEEK_LOWER per axis ----
|
|
|
if (startup_seek) begin
|
|
if (startup_seek) begin
|
|
|
- su_axis <= 2'd0;
|
|
|
|
|
- end else if (su_axis < AXIS_COUNT) begin
|
|
|
|
|
|
|
+ su_axis <= 2'd0;su_wait<=0;
|
|
|
|
|
+ end else if (su_axis < AXIS_COUNT && fx_state==FX_IDLE) begin
|
|
|
|
|
+ if(su_wait)begin
|
|
|
|
|
+ if(ax_seg_consumed[su_axis])begin su_wait<=0;su_axis<=su_axis+1'b1;end
|
|
|
|
|
+ end else begin
|
|
|
ax_seg_load[su_axis] <= 1'b1;
|
|
ax_seg_load[su_axis] <= 1'b1;
|
|
|
- ax_seg_mode[su_axis] <= M_SEEK_LOWER;
|
|
|
|
|
- ax_seg_upper[su_axis] <= 1'b0;
|
|
|
|
|
- ax_seg_armed[su_axis] <= 1'b0;
|
|
|
|
|
- ax_seg_count[su_axis] <= 32'd0; // unlimited until a limit
|
|
|
|
|
- ax_seg_half[su_axis] <= (su_axis == 2'd0) ? X_DEFAULT_HALF_US :
|
|
|
|
|
|
|
+ load_mode <= M_SEEK_LOWER;
|
|
|
|
|
+ load_upper <= 1'b0;
|
|
|
|
|
+ load_armed <= 1'b0;
|
|
|
|
|
+ load_count <= 32'd0; // unlimited until a limit
|
|
|
|
|
+ load_half <= (su_axis == 2'd0) ? X_DEFAULT_HALF_US :
|
|
|
(su_axis == 2'd1) ? Y_DEFAULT_HALF_US : Z_DEFAULT_HALF_US;
|
|
(su_axis == 2'd1) ? Y_DEFAULT_HALF_US : Z_DEFAULT_HALF_US;
|
|
|
- ax_seg_tag[su_axis] <= 16'd0;
|
|
|
|
|
- su_axis <= su_axis + 2'd1;
|
|
|
|
|
|
|
+ load_tag <= 16'd0;
|
|
|
|
|
+ su_wait<=1;
|
|
|
|
|
+ end
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|