|
|
@@ -83,6 +83,8 @@ module door_axis_controller #(
|
|
|
reg cal_started;
|
|
|
reg need_planner;
|
|
|
reg wd_stopped;
|
|
|
+ reg open_limit_armed;
|
|
|
+ reg close_limit_armed;
|
|
|
|
|
|
assign calibrated = calibrated_r;
|
|
|
assign faulted = (status_state == ST_FAULT);
|
|
|
@@ -100,19 +102,29 @@ module door_axis_controller #(
|
|
|
wire [CNT_W-1:0] guard_limit = travel_steps + ENDPOINT_GUARD_EXTRA[CNT_W-1:0];
|
|
|
wire in_calibration = (status_state == ST_CAL_SEEK_CLOSE) ||
|
|
|
(status_state == ST_CAL_MEASURE_OPEN);
|
|
|
- // Pre-NBA view: single-limit coordinate disagrees with endpoint snap target.
|
|
|
- // Used so same-cycle heartbeat/request still replans after §1b correction.
|
|
|
+ wire open_assert_event = open_limit && open_limit_armed;
|
|
|
+ wire close_assert_event = close_limit && close_limit_armed;
|
|
|
+ wire departing_close_source =
|
|
|
+ calibrated_r && !in_calibration &&
|
|
|
+ ((status_state == ST_MOVE_OPEN) || (moving && !dir_close));
|
|
|
+ wire departing_open_source =
|
|
|
+ calibrated_r && !in_calibration &&
|
|
|
+ ((status_state == ST_MOVE_CLOSE) || (moving && dir_close));
|
|
|
+ wire close_snap_accept =
|
|
|
+ calibrated_r && !in_calibration &&
|
|
|
+ close_assert_event && !departing_close_source;
|
|
|
+ wire open_snap_accept =
|
|
|
+ calibrated_r && !in_calibration &&
|
|
|
+ open_assert_event && !departing_open_source;
|
|
|
+ // Pre-NBA view: single-limit coordinate disagrees with accepted snap event.
|
|
|
wire limit_pos_mismatch =
|
|
|
- (calibrated_r && close_limit && !open_limit &&
|
|
|
- (current_position != travel_steps)) ||
|
|
|
- (calibrated_r && open_limit && !close_limit &&
|
|
|
- (current_position != {CNT_W{1'b0}}));
|
|
|
+ (close_snap_accept && (current_position != travel_steps)) ||
|
|
|
+ (open_snap_accept && (current_position != {CNT_W{1'b0}}));
|
|
|
|
|
|
// Combinational endpoint-effective coordinate for same-cycle planner decisions.
|
|
|
- // §1b NBA snap does not update current_position until the next delta cycle.
|
|
|
wire [CNT_W-1:0] effective_current_position =
|
|
|
- (calibrated_r && close_limit && !open_limit) ? travel_steps :
|
|
|
- (calibrated_r && open_limit && !close_limit) ? {CNT_W{1'b0}} :
|
|
|
+ close_snap_accept ? travel_steps :
|
|
|
+ open_snap_accept ? {CNT_W{1'b0}} :
|
|
|
current_position;
|
|
|
|
|
|
// Distinguish request bookkeeping from material replan preempt.
|
|
|
@@ -191,6 +203,8 @@ module door_axis_controller #(
|
|
|
step <= 1'b0;
|
|
|
dir_close <= 1'b1;
|
|
|
wd_stopped <= 1'b0;
|
|
|
+ open_limit_armed <= 1'b1;
|
|
|
+ close_limit_armed <= 1'b1;
|
|
|
end else if (both_limits) begin
|
|
|
status_state <= ST_FAULT;
|
|
|
fault_code <= FC_BOTH_LIMITS;
|
|
|
@@ -232,14 +246,22 @@ module door_axis_controller #(
|
|
|
end
|
|
|
|
|
|
// ----------------------------------------------------------
|
|
|
- // 1b) Single-limit position snap (before host replan / planner).
|
|
|
- // Same-cycle request+limit must use corrected coordinates; also
|
|
|
- // overrides any gated_step_rise delta from §1 this cycle.
|
|
|
+ // 1b) One-shot single-limit snap (consumes assertion interval).
|
|
|
+ // Departure from a consumed source limit must not overwrite §1.
|
|
|
// ----------------------------------------------------------
|
|
|
- if (calibrated_r && open_limit && !close_limit)
|
|
|
- current_position <= {CNT_W{1'b0}};
|
|
|
- else if (calibrated_r && close_limit && !open_limit)
|
|
|
+ if (!open_limit)
|
|
|
+ open_limit_armed <= 1'b1;
|
|
|
+ if (!close_limit)
|
|
|
+ close_limit_armed <= 1'b1;
|
|
|
+ if (open_assert_event)
|
|
|
+ open_limit_armed <= 1'b0;
|
|
|
+ if (close_assert_event)
|
|
|
+ close_limit_armed <= 1'b0;
|
|
|
+
|
|
|
+ if (close_snap_accept)
|
|
|
current_position <= travel_steps;
|
|
|
+ else if (open_snap_accept)
|
|
|
+ current_position <= {CNT_W{1'b0}};
|
|
|
|
|
|
// ----------------------------------------------------------
|
|
|
// 2a) Non-destructive request bookkeeping (idempotent OK).
|
|
|
@@ -669,9 +691,9 @@ module door_axis_controller #(
|
|
|
end else if (status_state == ST_IDLE) begin
|
|
|
step <= 1'b0;
|
|
|
moving <= 1'b0;
|
|
|
- if (calibrated_r && is_open_endpoint && open_limit)
|
|
|
+ if (open_snap_accept)
|
|
|
current_position <= {CNT_W{1'b0}};
|
|
|
- if (calibrated_r && is_close_endpoint && close_limit)
|
|
|
+ if (close_snap_accept)
|
|
|
current_position <= travel_steps;
|
|
|
if (replan_pending)
|
|
|
status_state <= ST_WAIT_REPLAN;
|