|
@@ -1,13 +1,19 @@
|
|
|
`timescale 1ns/1ps
|
|
`timescale 1ns/1ps
|
|
|
|
|
|
|
|
-// Three-axis door motion: shared percent planner, startup_complete, status snapshot.
|
|
|
|
|
|
|
+// Three-axis door motion: Scheme A full-feature
|
|
|
|
|
+// - per-axis safety kernels
|
|
|
|
|
+// - serial X→Y→Z calibration
|
|
|
|
|
+// - shared 25 us DDA (A1) + shared profile threshold builder
|
|
|
module door_motion_controller #(
|
|
module door_motion_controller #(
|
|
|
parameter integer MAX_CAL_STEPS = 5000,
|
|
parameter integer MAX_CAL_STEPS = 5000,
|
|
|
parameter integer MIN_TRAVEL = 2,
|
|
parameter integer MIN_TRAVEL = 2,
|
|
|
parameter integer ENDPOINT_GUARD_EXTRA = 500,
|
|
parameter integer ENDPOINT_GUARD_EXTRA = 500,
|
|
|
parameter integer DIR_SETUP_TICKS = 2,
|
|
parameter integer DIR_SETUP_TICKS = 2,
|
|
|
parameter integer PERCENT_MAX = 100,
|
|
parameter integer PERCENT_MAX = 100,
|
|
|
- parameter integer STATUS_PAYLOAD_LENGTH = 31
|
|
|
|
|
|
|
+ parameter integer STATUS_PAYLOAD_LENGTH = 31,
|
|
|
|
|
+ parameter integer MOTION_SERVICE_CLKS = 625,
|
|
|
|
|
+ parameter integer PHASE_FACTOR = 5120,
|
|
|
|
|
+ parameter integer CAL_RAMP_UNIT = 8
|
|
|
) (
|
|
) (
|
|
|
input wire clk,
|
|
input wire clk,
|
|
|
input wire rst_n,
|
|
input wire rst_n,
|
|
@@ -28,8 +34,6 @@ module door_motion_controller #(
|
|
|
output reg startup_complete,
|
|
output reg startup_complete,
|
|
|
output wire [2:0] calibrated_mask,
|
|
output wire [2:0] calibrated_mask,
|
|
|
output wire [2:0] fault_mask,
|
|
output wire [2:0] fault_mask,
|
|
|
- // Snapshot capture / read (31-byte MOTOR_STATUS_DATA)
|
|
|
|
|
- // Combinational read matches frame_tx payload_data contract (0-cycle latency).
|
|
|
|
|
input wire status_capture,
|
|
input wire status_capture,
|
|
|
input wire [7:0] status_rd_addr,
|
|
input wire [7:0] status_rd_addr,
|
|
|
output wire [7:0] status_rd_data
|
|
output wire [7:0] status_rd_data
|
|
@@ -58,6 +62,60 @@ module door_motion_controller #(
|
|
|
wire cal_x, cal_y, cal_z;
|
|
wire cal_x, cal_y, cal_z;
|
|
|
wire fault_x, fault_y, fault_z;
|
|
wire fault_x, fault_y, fault_z;
|
|
|
wire term_x, term_y, term_z;
|
|
wire term_x, term_y, term_z;
|
|
|
|
|
+ wire mov_x, mov_y, mov_z;
|
|
|
|
|
+ wire allow_x, allow_y, allow_z;
|
|
|
|
|
+ wire in_cal_x, in_cal_y, in_cal_z;
|
|
|
|
|
+ wire crawl_x, crawl_y, crawl_z;
|
|
|
|
|
+ wire dda_run_x, dda_run_y, dda_run_z;
|
|
|
|
|
+ wire [3:0] lvl_x, lvl_y, lvl_z;
|
|
|
|
|
+ wire [20:0] rq_x, rq_y, rq_z;
|
|
|
|
|
+
|
|
|
|
|
+ wire [2:0] cal_enable;
|
|
|
|
|
+ wire profile_start;
|
|
|
|
|
+ wire profile_ready;
|
|
|
|
|
+ wire profile_busy;
|
|
|
|
|
+ wire profile_done;
|
|
|
|
|
+ wire [12:0] max_travel;
|
|
|
|
|
+ wire [24:0] phase_threshold;
|
|
|
|
|
+ wire service_ce;
|
|
|
|
|
+ wire [2:0] toggle_pulse;
|
|
|
|
|
+ wire dda_busy;
|
|
|
|
|
+ wire dda_overrun;
|
|
|
|
|
+
|
|
|
|
|
+ // Shared rate refresh: travel * profile_scale[level] (or scale alone in cal).
|
|
|
|
|
+ reg rate_busy;
|
|
|
|
|
+ reg rate_valid;
|
|
|
|
|
+ reg [1:0] rate_axis;
|
|
|
|
|
+ reg [20:0] rate_result;
|
|
|
|
|
+ reg [12:0] mul_travel;
|
|
|
|
|
+ reg [8:0] mul_scale;
|
|
|
|
|
+ reg [20:0] mul_acc;
|
|
|
|
|
+ reg [3:0] mul_bit;
|
|
|
|
|
+ reg [3:0] mul_level;
|
|
|
|
|
+
|
|
|
|
|
+ function automatic [8:0] f_profile_scale;
|
|
|
|
|
+ input [3:0] level;
|
|
|
|
|
+ begin
|
|
|
|
|
+ case (level)
|
|
|
|
|
+ 4'd0: f_profile_scale = 9'd64;
|
|
|
|
|
+ 4'd1: f_profile_scale = 9'd66;
|
|
|
|
|
+ 4'd2: f_profile_scale = 9'd73;
|
|
|
|
|
+ 4'd3: f_profile_scale = 9'd84;
|
|
|
|
|
+ 4'd4: f_profile_scale = 9'd98;
|
|
|
|
|
+ 4'd5: f_profile_scale = 9'd114;
|
|
|
|
|
+ 4'd6: f_profile_scale = 9'd132;
|
|
|
|
|
+ 4'd7: f_profile_scale = 9'd150;
|
|
|
|
|
+ 4'd8: f_profile_scale = 9'd170;
|
|
|
|
|
+ 4'd9: f_profile_scale = 9'd188;
|
|
|
|
|
+ 4'd10: f_profile_scale = 9'd206;
|
|
|
|
|
+ 4'd11: f_profile_scale = 9'd222;
|
|
|
|
|
+ 4'd12: f_profile_scale = 9'd236;
|
|
|
|
|
+ 4'd13: f_profile_scale = 9'd247;
|
|
|
|
|
+ 4'd14: f_profile_scale = 9'd254;
|
|
|
|
|
+ default: f_profile_scale = 9'd256;
|
|
|
|
|
+ endcase
|
|
|
|
|
+ end
|
|
|
|
|
+ endfunction
|
|
|
|
|
|
|
|
assign calibrated_mask = {cal_z, cal_y, cal_x};
|
|
assign calibrated_mask = {cal_z, cal_y, cal_x};
|
|
|
assign fault_mask = {fault_z, fault_y, fault_x};
|
|
assign fault_mask = {fault_z, fault_y, fault_x};
|
|
@@ -75,8 +133,6 @@ module door_motion_controller #(
|
|
|
.done_percent(planner_done_percent)
|
|
.done_percent(planner_done_percent)
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- // X→Y→Z arbiter: one-shot grant per request. Hold until axis drops req
|
|
|
|
|
- // so planner done+busy=0 cannot re-grant the same level request.
|
|
|
|
|
reg grant_start;
|
|
reg grant_start;
|
|
|
reg [1:0] grant_axis;
|
|
reg [1:0] grant_axis;
|
|
|
reg [7:0] grant_percent;
|
|
reg [7:0] grant_percent;
|
|
@@ -97,12 +153,9 @@ module door_motion_controller #(
|
|
|
grant_hold <= 3'b000;
|
|
grant_hold <= 3'b000;
|
|
|
end else begin
|
|
end else begin
|
|
|
grant_start <= 1'b0;
|
|
grant_start <= 1'b0;
|
|
|
- if (!req_x)
|
|
|
|
|
- grant_hold[0] <= 1'b0;
|
|
|
|
|
- if (!req_y)
|
|
|
|
|
- grant_hold[1] <= 1'b0;
|
|
|
|
|
- if (!req_z)
|
|
|
|
|
- grant_hold[2] <= 1'b0;
|
|
|
|
|
|
|
+ if (!req_x) grant_hold[0] <= 1'b0;
|
|
|
|
|
+ if (!req_y) grant_hold[1] <= 1'b0;
|
|
|
|
|
+ if (!req_z) grant_hold[2] <= 1'b0;
|
|
|
if (!planner_busy && !grant_start) begin
|
|
if (!planner_busy && !grant_start) begin
|
|
|
if (req_x && !grant_hold[0]) begin
|
|
if (req_x && !grant_hold[0]) begin
|
|
|
grant_start <= 1'b1;
|
|
grant_start <= 1'b1;
|
|
@@ -127,22 +180,132 @@ module door_motion_controller #(
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
+ door_motion_service_tick #(.SERVICE_CLKS(MOTION_SERVICE_CLKS)) u_svc (
|
|
|
|
|
+ .clk(clk), .rst_n(rst_n), .service_ce(service_ce)
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ door_calibration_sequencer u_cal_seq (
|
|
|
|
|
+ .clk(clk), .rst_n(rst_n),
|
|
|
|
|
+ .limit_sync_valid(limit_sync_valid),
|
|
|
|
|
+ .term_x(term_x), .term_y(term_y), .term_z(term_z),
|
|
|
|
|
+ .cal_ok_x(cal_x), .cal_ok_y(cal_y), .cal_ok_z(cal_z),
|
|
|
|
|
+ .profile_busy(profile_busy),
|
|
|
|
|
+ .profile_done(profile_done),
|
|
|
|
|
+ .cal_enable(cal_enable),
|
|
|
|
|
+ .profile_start(profile_start),
|
|
|
|
|
+ .profile_ready(profile_ready),
|
|
|
|
|
+ .all_axes_terminal()
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ door_profile_quantum_builder #(
|
|
|
|
|
+ .PHASE_FACTOR(PHASE_FACTOR)
|
|
|
|
|
+ ) u_profile (
|
|
|
|
|
+ .clk(clk), .rst_n(rst_n),
|
|
|
|
|
+ .start(profile_start),
|
|
|
|
|
+ .travel_x(st_trav_x), .travel_y(st_trav_y), .travel_z(st_trav_z),
|
|
|
|
|
+ .cal_ok_x(cal_x), .cal_ok_y(cal_y), .cal_ok_z(cal_z),
|
|
|
|
|
+ .busy(profile_busy), .done(profile_done),
|
|
|
|
|
+ .max_travel(max_travel),
|
|
|
|
|
+ .phase_threshold(phase_threshold)
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ wire [2:0] dda_active = {dda_run_z, dda_run_y, dda_run_x};
|
|
|
|
|
+ wire [2:0] dda_allow = {allow_z, allow_y, allow_x};
|
|
|
|
|
+ wire [2:0] dda_cal = {in_cal_z, in_cal_y, in_cal_x};
|
|
|
|
|
+
|
|
|
|
|
+ door_shared_dda_scheduler #(
|
|
|
|
|
+ .CAL_PHASE_THRESHOLD(PHASE_FACTOR)
|
|
|
|
|
+ ) u_dda (
|
|
|
|
|
+ .clk(clk), .rst_n(rst_n),
|
|
|
|
|
+ .service_ce(service_ce),
|
|
|
|
|
+ .active(dda_active),
|
|
|
|
|
+ .allow_toggle(dda_allow),
|
|
|
|
|
+ .cal_mode(dda_cal),
|
|
|
|
|
+ .rate0(rq_x), .rate1(rq_y), .rate2(rq_z),
|
|
|
|
|
+ .phase_threshold(phase_threshold),
|
|
|
|
|
+ .toggle_pulse(toggle_pulse),
|
|
|
|
|
+ .busy(dda_busy),
|
|
|
|
|
+ .service_overrun(dda_overrun)
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ // Round-robin shared rate builder
|
|
|
|
|
+ reg [1:0] rate_axis_busy;
|
|
|
|
|
+ always @(posedge clk or negedge rst_n) begin
|
|
|
|
|
+ if (!rst_n) begin
|
|
|
|
|
+ rate_busy <= 1'b0;
|
|
|
|
|
+ rate_valid <= 1'b0;
|
|
|
|
|
+ rate_axis <= 2'd0;
|
|
|
|
|
+ rate_axis_busy <= 2'd0;
|
|
|
|
|
+ rate_result <= 21'd0;
|
|
|
|
|
+ mul_travel <= 13'd0;
|
|
|
|
|
+ mul_scale <= 9'd0;
|
|
|
|
|
+ mul_acc <= 21'd0;
|
|
|
|
|
+ mul_bit <= 4'd0;
|
|
|
|
|
+ mul_level <= 4'd0;
|
|
|
|
|
+ end else begin
|
|
|
|
|
+ rate_valid <= 1'b0;
|
|
|
|
|
+ if (!rate_busy) begin
|
|
|
|
|
+ rate_axis_busy <= rate_axis;
|
|
|
|
|
+ rate_busy <= 1'b1;
|
|
|
|
|
+ mul_bit <= 4'd0;
|
|
|
|
|
+ mul_acc <= 21'd0;
|
|
|
|
|
+ case (rate_axis)
|
|
|
|
|
+ 2'd0: begin
|
|
|
|
|
+ mul_level <= crawl_x ? 4'd0 : lvl_x;
|
|
|
|
|
+ mul_travel <= in_cal_x ? 13'd1 : ((st_trav_x == 0) ? 13'd1 : st_trav_x);
|
|
|
|
|
+ mul_scale <= f_profile_scale(crawl_x ? 4'd0 : lvl_x);
|
|
|
|
|
+ end
|
|
|
|
|
+ 2'd1: begin
|
|
|
|
|
+ mul_level <= crawl_y ? 4'd0 : lvl_y;
|
|
|
|
|
+ mul_travel <= in_cal_y ? 13'd1 : ((st_trav_y == 0) ? 13'd1 : st_trav_y);
|
|
|
|
|
+ mul_scale <= f_profile_scale(crawl_y ? 4'd0 : lvl_y);
|
|
|
|
|
+ end
|
|
|
|
|
+ default: begin
|
|
|
|
|
+ mul_level <= crawl_z ? 4'd0 : lvl_z;
|
|
|
|
|
+ mul_travel <= in_cal_z ? 13'd1 : ((st_trav_z == 0) ? 13'd1 : st_trav_z);
|
|
|
|
|
+ mul_scale <= f_profile_scale(crawl_z ? 4'd0 : lvl_z);
|
|
|
|
|
+ end
|
|
|
|
|
+ endcase
|
|
|
|
|
+ rate_axis <= (rate_axis == 2'd2) ? 2'd0 : (rate_axis + 1'b1);
|
|
|
|
|
+ end else if (mul_bit == 4'd9) begin
|
|
|
|
|
+ rate_result <= mul_acc;
|
|
|
|
|
+ rate_valid <= 1'b1;
|
|
|
|
|
+ rate_busy <= 1'b0;
|
|
|
|
|
+ end else begin
|
|
|
|
|
+ if (mul_scale[0])
|
|
|
|
|
+ mul_acc <= mul_acc + {8'd0, mul_travel};
|
|
|
|
|
+ mul_scale <= {1'b0, mul_scale[8:1]};
|
|
|
|
|
+ mul_travel <= {mul_travel[11:0], 1'b0};
|
|
|
|
|
+ mul_bit <= mul_bit + 1'b1;
|
|
|
|
|
+ end
|
|
|
|
|
+ end
|
|
|
|
|
+ end
|
|
|
|
|
+
|
|
|
|
|
+ wire rate_valid_x = rate_valid && (rate_axis_busy == 2'd0);
|
|
|
|
|
+ wire rate_valid_y = rate_valid && (rate_axis_busy == 2'd1);
|
|
|
|
|
+ wire rate_valid_z = rate_valid && (rate_axis_busy == 2'd2);
|
|
|
|
|
+
|
|
|
door_axis_controller #(
|
|
door_axis_controller #(
|
|
|
.AXIS_ID(0),
|
|
.AXIS_ID(0),
|
|
|
.MAX_CAL_STEPS(MAX_CAL_STEPS),
|
|
.MAX_CAL_STEPS(MAX_CAL_STEPS),
|
|
|
.MIN_TRAVEL(MIN_TRAVEL),
|
|
.MIN_TRAVEL(MIN_TRAVEL),
|
|
|
.ENDPOINT_GUARD_EXTRA(ENDPOINT_GUARD_EXTRA),
|
|
.ENDPOINT_GUARD_EXTRA(ENDPOINT_GUARD_EXTRA),
|
|
|
.DIR_SETUP_TICKS(DIR_SETUP_TICKS),
|
|
.DIR_SETUP_TICKS(DIR_SETUP_TICKS),
|
|
|
- .PERCENT_MAX(PERCENT_MAX)
|
|
|
|
|
|
|
+ .PERCENT_MAX(PERCENT_MAX),
|
|
|
|
|
+ .CAL_RAMP_UNIT(CAL_RAMP_UNIT)
|
|
|
) u_axis_x (
|
|
) u_axis_x (
|
|
|
.clk(clk), .rst_n(rst_n),
|
|
.clk(clk), .rst_n(rst_n),
|
|
|
.open_limit(open_limit[0]), .close_limit(close_limit[0]),
|
|
.open_limit(open_limit[0]), .close_limit(close_limit[0]),
|
|
|
.limit_sync_valid(limit_sync_valid),
|
|
.limit_sync_valid(limit_sync_valid),
|
|
|
|
|
+ .cal_enable(cal_enable[0]),
|
|
|
.gated_step(gated_step[0]), .gated_step_rise(gated_step_rise[0]),
|
|
.gated_step(gated_step[0]), .gated_step_rise(gated_step_rise[0]),
|
|
|
.tick_500us(tick_500us),
|
|
.tick_500us(tick_500us),
|
|
|
|
|
+ .step_toggle_pulse(toggle_pulse[0]),
|
|
|
.request_valid(motor_request_valid),
|
|
.request_valid(motor_request_valid),
|
|
|
.requested_percent_in(percent_x),
|
|
.requested_percent_in(percent_x),
|
|
|
.watchdog_stop(watchdog_stop),
|
|
.watchdog_stop(watchdog_stop),
|
|
|
|
|
+ .rate_quantum_in(rate_result),
|
|
|
|
|
+ .rate_quantum_valid(rate_valid_x),
|
|
|
.planner_req(req_x),
|
|
.planner_req(req_x),
|
|
|
.planner_percent(pct_req_x),
|
|
.planner_percent(pct_req_x),
|
|
|
.planner_travel(trav_req_x),
|
|
.planner_travel(trav_req_x),
|
|
@@ -155,7 +318,13 @@ module door_motion_controller #(
|
|
|
.status_requested_percent(st_pct_x),
|
|
.status_requested_percent(st_pct_x),
|
|
|
.status_current(st_cur_x), .status_target(st_tgt_x),
|
|
.status_current(st_cur_x), .status_target(st_tgt_x),
|
|
|
.status_travel(st_trav_x), .status_fault_code(st_fault_x),
|
|
.status_travel(st_trav_x), .status_fault_code(st_fault_x),
|
|
|
- .calibrated(cal_x), .faulted(fault_x), .terminal(term_x)
|
|
|
|
|
|
|
+ .calibrated(cal_x), .faulted(fault_x), .terminal(term_x),
|
|
|
|
|
+ .axis_moving(mov_x), .axis_allow_rise(allow_x),
|
|
|
|
|
+ .axis_in_calibration(in_cal_x), .axis_endpoint_crawl(crawl_x),
|
|
|
|
|
+ .axis_dda_run(dda_run_x),
|
|
|
|
|
+ .profile_level(lvl_x),
|
|
|
|
|
+ .profile_distance(), .profile_done_steps(), .profile_ramp_unit(),
|
|
|
|
|
+ .rate_quantum(rq_x)
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
door_axis_controller #(
|
|
door_axis_controller #(
|
|
@@ -164,16 +333,21 @@ module door_motion_controller #(
|
|
|
.MIN_TRAVEL(MIN_TRAVEL),
|
|
.MIN_TRAVEL(MIN_TRAVEL),
|
|
|
.ENDPOINT_GUARD_EXTRA(ENDPOINT_GUARD_EXTRA),
|
|
.ENDPOINT_GUARD_EXTRA(ENDPOINT_GUARD_EXTRA),
|
|
|
.DIR_SETUP_TICKS(DIR_SETUP_TICKS),
|
|
.DIR_SETUP_TICKS(DIR_SETUP_TICKS),
|
|
|
- .PERCENT_MAX(PERCENT_MAX)
|
|
|
|
|
|
|
+ .PERCENT_MAX(PERCENT_MAX),
|
|
|
|
|
+ .CAL_RAMP_UNIT(CAL_RAMP_UNIT)
|
|
|
) u_axis_y (
|
|
) u_axis_y (
|
|
|
.clk(clk), .rst_n(rst_n),
|
|
.clk(clk), .rst_n(rst_n),
|
|
|
.open_limit(open_limit[1]), .close_limit(close_limit[1]),
|
|
.open_limit(open_limit[1]), .close_limit(close_limit[1]),
|
|
|
.limit_sync_valid(limit_sync_valid),
|
|
.limit_sync_valid(limit_sync_valid),
|
|
|
|
|
+ .cal_enable(cal_enable[1]),
|
|
|
.gated_step(gated_step[1]), .gated_step_rise(gated_step_rise[1]),
|
|
.gated_step(gated_step[1]), .gated_step_rise(gated_step_rise[1]),
|
|
|
.tick_500us(tick_500us),
|
|
.tick_500us(tick_500us),
|
|
|
|
|
+ .step_toggle_pulse(toggle_pulse[1]),
|
|
|
.request_valid(motor_request_valid),
|
|
.request_valid(motor_request_valid),
|
|
|
.requested_percent_in(percent_y),
|
|
.requested_percent_in(percent_y),
|
|
|
.watchdog_stop(watchdog_stop),
|
|
.watchdog_stop(watchdog_stop),
|
|
|
|
|
+ .rate_quantum_in(rate_result),
|
|
|
|
|
+ .rate_quantum_valid(rate_valid_y),
|
|
|
.planner_req(req_y),
|
|
.planner_req(req_y),
|
|
|
.planner_percent(pct_req_y),
|
|
.planner_percent(pct_req_y),
|
|
|
.planner_travel(trav_req_y),
|
|
.planner_travel(trav_req_y),
|
|
@@ -186,7 +360,13 @@ module door_motion_controller #(
|
|
|
.status_requested_percent(st_pct_y),
|
|
.status_requested_percent(st_pct_y),
|
|
|
.status_current(st_cur_y), .status_target(st_tgt_y),
|
|
.status_current(st_cur_y), .status_target(st_tgt_y),
|
|
|
.status_travel(st_trav_y), .status_fault_code(st_fault_y),
|
|
.status_travel(st_trav_y), .status_fault_code(st_fault_y),
|
|
|
- .calibrated(cal_y), .faulted(fault_y), .terminal(term_y)
|
|
|
|
|
|
|
+ .calibrated(cal_y), .faulted(fault_y), .terminal(term_y),
|
|
|
|
|
+ .axis_moving(mov_y), .axis_allow_rise(allow_y),
|
|
|
|
|
+ .axis_in_calibration(in_cal_y), .axis_endpoint_crawl(crawl_y),
|
|
|
|
|
+ .axis_dda_run(dda_run_y),
|
|
|
|
|
+ .profile_level(lvl_y),
|
|
|
|
|
+ .profile_distance(), .profile_done_steps(), .profile_ramp_unit(),
|
|
|
|
|
+ .rate_quantum(rq_y)
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
door_axis_controller #(
|
|
door_axis_controller #(
|
|
@@ -195,16 +375,21 @@ module door_motion_controller #(
|
|
|
.MIN_TRAVEL(MIN_TRAVEL),
|
|
.MIN_TRAVEL(MIN_TRAVEL),
|
|
|
.ENDPOINT_GUARD_EXTRA(ENDPOINT_GUARD_EXTRA),
|
|
.ENDPOINT_GUARD_EXTRA(ENDPOINT_GUARD_EXTRA),
|
|
|
.DIR_SETUP_TICKS(DIR_SETUP_TICKS),
|
|
.DIR_SETUP_TICKS(DIR_SETUP_TICKS),
|
|
|
- .PERCENT_MAX(PERCENT_MAX)
|
|
|
|
|
|
|
+ .PERCENT_MAX(PERCENT_MAX),
|
|
|
|
|
+ .CAL_RAMP_UNIT(CAL_RAMP_UNIT)
|
|
|
) u_axis_z (
|
|
) u_axis_z (
|
|
|
.clk(clk), .rst_n(rst_n),
|
|
.clk(clk), .rst_n(rst_n),
|
|
|
.open_limit(open_limit[2]), .close_limit(close_limit[2]),
|
|
.open_limit(open_limit[2]), .close_limit(close_limit[2]),
|
|
|
.limit_sync_valid(limit_sync_valid),
|
|
.limit_sync_valid(limit_sync_valid),
|
|
|
|
|
+ .cal_enable(cal_enable[2]),
|
|
|
.gated_step(gated_step[2]), .gated_step_rise(gated_step_rise[2]),
|
|
.gated_step(gated_step[2]), .gated_step_rise(gated_step_rise[2]),
|
|
|
.tick_500us(tick_500us),
|
|
.tick_500us(tick_500us),
|
|
|
|
|
+ .step_toggle_pulse(toggle_pulse[2]),
|
|
|
.request_valid(motor_request_valid),
|
|
.request_valid(motor_request_valid),
|
|
|
.requested_percent_in(percent_z),
|
|
.requested_percent_in(percent_z),
|
|
|
.watchdog_stop(watchdog_stop),
|
|
.watchdog_stop(watchdog_stop),
|
|
|
|
|
+ .rate_quantum_in(rate_result),
|
|
|
|
|
+ .rate_quantum_valid(rate_valid_z),
|
|
|
.planner_req(req_z),
|
|
.planner_req(req_z),
|
|
|
.planner_percent(pct_req_z),
|
|
.planner_percent(pct_req_z),
|
|
|
.planner_travel(trav_req_z),
|
|
.planner_travel(trav_req_z),
|
|
@@ -217,22 +402,25 @@ module door_motion_controller #(
|
|
|
.status_requested_percent(st_pct_z),
|
|
.status_requested_percent(st_pct_z),
|
|
|
.status_current(st_cur_z), .status_target(st_tgt_z),
|
|
.status_current(st_cur_z), .status_target(st_tgt_z),
|
|
|
.status_travel(st_trav_z), .status_fault_code(st_fault_z),
|
|
.status_travel(st_trav_z), .status_fault_code(st_fault_z),
|
|
|
- .calibrated(cal_z), .faulted(fault_z), .terminal(term_z)
|
|
|
|
|
|
|
+ .calibrated(cal_z), .faulted(fault_z), .terminal(term_z),
|
|
|
|
|
+ .axis_moving(mov_z), .axis_allow_rise(allow_z),
|
|
|
|
|
+ .axis_in_calibration(in_cal_z), .axis_endpoint_crawl(crawl_z),
|
|
|
|
|
+ .axis_dda_run(dda_run_z),
|
|
|
|
|
+ .profile_level(lvl_z),
|
|
|
|
|
+ .profile_distance(), .profile_done_steps(), .profile_ramp_unit(),
|
|
|
|
|
+ .rate_quantum(rq_z)
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- // Sticky startup_complete when all axes terminal
|
|
|
|
|
|
|
+ // startup_complete only after serial cal terminal + profile ready
|
|
|
always @(posedge clk or negedge rst_n) begin
|
|
always @(posedge clk or negedge rst_n) begin
|
|
|
if (!rst_n)
|
|
if (!rst_n)
|
|
|
startup_complete <= 1'b0;
|
|
startup_complete <= 1'b0;
|
|
|
- else if (!startup_complete && term_x && term_y && term_z)
|
|
|
|
|
|
|
+ else if (!startup_complete && profile_ready && term_x && term_y && term_z)
|
|
|
startup_complete <= 1'b1;
|
|
startup_complete <= 1'b1;
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
- // -------- 31-byte atomic snapshot --------
|
|
|
|
|
reg [7:0] snap [0:30];
|
|
reg [7:0] snap [0:30];
|
|
|
integer si;
|
|
integer si;
|
|
|
-
|
|
|
|
|
- // Combinational mux: same 0-cycle latency as temperature RAM → frame_tx.
|
|
|
|
|
assign status_rd_data = (status_rd_addr < STATUS_PAYLOAD_LENGTH[7:0]) ?
|
|
assign status_rd_data = (status_rd_addr < STATUS_PAYLOAD_LENGTH[7:0]) ?
|
|
|
snap[status_rd_addr] : 8'd0;
|
|
snap[status_rd_addr] : 8'd0;
|
|
|
|
|
|
|
@@ -241,9 +429,7 @@ module door_motion_controller #(
|
|
|
for (si = 0; si < STATUS_PAYLOAD_LENGTH; si = si + 1)
|
|
for (si = 0; si < STATUS_PAYLOAD_LENGTH; si = si + 1)
|
|
|
snap[si] <= 8'd0;
|
|
snap[si] <= 8'd0;
|
|
|
end else if (status_capture) begin
|
|
end else if (status_capture) begin
|
|
|
- // byte0: cal[2:0], fault[2:0], startup, watchdog
|
|
|
|
|
snap[0] <= {watchdog_tripped, startup_complete, fault_mask, calibrated_mask};
|
|
snap[0] <= {watchdog_tripped, startup_complete, fault_mask, calibrated_mask};
|
|
|
- // X @1, Y @11, Z @21
|
|
|
|
|
snap[1] <= {5'd0, st_state_x};
|
|
snap[1] <= {5'd0, st_state_x};
|
|
|
snap[2] <= st_flags_x;
|
|
snap[2] <= st_flags_x;
|
|
|
snap[3] <= st_pct_x;
|
|
snap[3] <= st_pct_x;
|