| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652 |
- `timescale 1ns/1ps
- // Per-axis door percent FSM: cal seek-close → measure-open, then runtime
- // mid/endpoint motion with latest-wins replan. Position only on gated_step_rise.
- module door_axis_controller #(
- parameter integer AXIS_ID = 0,
- parameter integer MAX_CAL_STEPS = 5000,
- parameter integer MIN_TRAVEL = 2,
- parameter integer ENDPOINT_GUARD_EXTRA = 500,
- parameter integer DIR_SETUP_TICKS = 2,
- parameter integer PERCENT_MAX = 100
- ) (
- input wire clk,
- input wire rst_n,
- input wire open_limit,
- input wire close_limit,
- input wire limit_sync_valid,
- input wire gated_step,
- input wire gated_step_rise,
- input wire tick_500us,
- input wire request_valid,
- input wire [7:0] requested_percent_in,
- input wire watchdog_stop,
- output reg planner_req,
- output wire [7:0] planner_percent,
- output wire [12:0] planner_travel,
- input wire planner_done,
- input wire [1:0] planner_done_axis,
- input wire [7:0] planner_done_percent,
- input wire [12:0] planner_result,
- output reg step,
- output reg dir_close,
- output reg [2:0] status_state,
- output reg [7:0] status_flags,
- output reg [7:0] status_requested_percent,
- output reg [12:0] status_current,
- output reg [12:0] status_target,
- output reg [12:0] status_travel,
- output reg [7:0] status_fault_code,
- output wire calibrated,
- output wire faulted,
- output wire terminal
- );
- localparam [2:0] ST_CAL_SEEK_CLOSE = 3'd0;
- localparam [2:0] ST_CAL_MEASURE_OPEN = 3'd1;
- localparam [2:0] ST_IDLE = 3'd2;
- localparam [2:0] ST_MOVE_OPEN = 3'd3;
- localparam [2:0] ST_MOVE_CLOSE = 3'd4;
- localparam [2:0] ST_WAIT_REPLAN = 3'd5;
- localparam [2:0] ST_FAULT = 3'd6;
- localparam [2:0] FC_NONE = 3'd0;
- localparam [2:0] FC_BOTH_LIMITS = 3'd1;
- localparam [2:0] FC_CAL_CLOSE_TIMEOUT = 3'd2;
- localparam [2:0] FC_CAL_OPEN_TIMEOUT = 3'd3;
- localparam [2:0] FC_TINY_TRAVEL = 3'd4;
- localparam [2:0] FC_ENDPOINT_TIMEOUT = 3'd5;
- localparam [2:0] PH_NONE = 3'd0;
- localparam [2:0] PH_DIR_SETUP = 3'd1;
- localparam [2:0] PH_RUN = 3'd2;
- localparam [2:0] PH_DRAIN_HIGH = 3'd3;
- localparam integer CNT_W = 13;
- localparam [CNT_W-1:0] MAX_STEPS_W = MAX_CAL_STEPS[CNT_W-1:0];
- localparam [CNT_W-1:0] MIN_TRAVEL_W = MIN_TRAVEL[CNT_W-1:0];
- reg calibrated_r;
- reg [2:0] fault_code;
- reg [CNT_W-1:0] travel_steps;
- reg [CNT_W-1:0] current_position;
- reg [CNT_W-1:0] target_position;
- reg [7:0] requested_percent;
- reg replan_pending;
- reg endpoint_mode;
- reg target_valid;
- reg moving;
- reg [2:0] phase;
- reg [3:0] setup_count;
- reg [CNT_W-1:0] motion_count;
- reg allow_rise;
- reg stop_after_budget;
- reg cal_started;
- reg need_planner;
- reg wd_stopped;
- assign calibrated = calibrated_r;
- assign faulted = (status_state == ST_FAULT);
- assign terminal = ((status_state == ST_IDLE) && calibrated_r) || (status_state == ST_FAULT);
- assign planner_percent = requested_percent;
- assign planner_travel = travel_steps;
- wire both_limits = open_limit && close_limit;
- wire mid_request = (requested_percent > 8'd0) && (requested_percent < PERCENT_MAX[7:0]);
- wire is_open_endpoint = (requested_percent == 8'd0);
- wire is_close_endpoint = (requested_percent == PERCENT_MAX[7:0]);
- wire planner_accept = planner_done && (planner_done_axis == AXIS_ID[1:0]) &&
- (planner_done_percent == requested_percent) && calibrated_r &&
- (status_state != ST_FAULT) && mid_request && need_planner;
- 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);
- always @* begin
- status_requested_percent = requested_percent;
- status_current = current_position;
- status_target = target_position;
- status_travel = travel_steps;
- status_fault_code = {5'd0, fault_code};
- status_flags = {
- 1'b0,
- replan_pending,
- target_valid,
- endpoint_mode,
- moving,
- calibrated_r,
- close_limit,
- open_limit
- };
- end
- // Shared STEP half-period helper: returns next step level
- function automatic step_toggle;
- input cur_step;
- input do_allow_rise;
- begin
- if (cur_step)
- step_toggle = 1'b0;
- else if (do_allow_rise)
- step_toggle = 1'b1;
- else
- step_toggle = 1'b0;
- end
- endfunction
- always @(posedge clk or negedge rst_n) begin
- if (!rst_n) begin
- status_state <= ST_CAL_SEEK_CLOSE;
- calibrated_r <= 1'b0;
- fault_code <= FC_NONE;
- travel_steps <= {CNT_W{1'b0}};
- current_position <= {CNT_W{1'b0}};
- target_position <= {CNT_W{1'b0}};
- requested_percent <= 8'd0;
- replan_pending <= 1'b0;
- endpoint_mode <= 1'b0;
- target_valid <= 1'b0;
- moving <= 1'b0;
- phase <= PH_NONE;
- setup_count <= 4'd0;
- motion_count <= {CNT_W{1'b0}};
- allow_rise <= 1'b0;
- stop_after_budget <= 1'b0;
- cal_started <= 1'b0;
- need_planner <= 1'b0;
- planner_req <= 1'b0;
- step <= 1'b0;
- dir_close <= 1'b1;
- wd_stopped <= 1'b0;
- end else if (both_limits) begin
- status_state <= ST_FAULT;
- fault_code <= FC_BOTH_LIMITS;
- step <= 1'b0;
- phase <= PH_NONE;
- moving <= 1'b0;
- allow_rise <= 1'b0;
- stop_after_budget <= 1'b0;
- planner_req <= 1'b0;
- need_planner <= 1'b0;
- replan_pending <= 1'b0;
- if (request_valid)
- requested_percent <= requested_percent_in;
- end else if (status_state == ST_FAULT) begin
- step <= 1'b0;
- moving <= 1'b0;
- planner_req <= 1'b0;
- if (request_valid)
- requested_percent <= requested_percent_in;
- end else begin
- // ----------------------------------------------------------
- // 1) Position / cal / guard counts on gated rise (always)
- // ----------------------------------------------------------
- if (gated_step_rise) begin
- if (status_state == ST_CAL_SEEK_CLOSE ||
- status_state == ST_CAL_MEASURE_OPEN) begin
- motion_count <= motion_count + 1'b1;
- end else if (calibrated_r) begin
- if (endpoint_mode)
- motion_count <= motion_count + 1'b1;
- if (dir_close) begin
- if (current_position < travel_steps)
- current_position <= current_position + 1'b1;
- end else begin
- if (current_position != {CNT_W{1'b0}})
- current_position <= current_position - 1'b1;
- end
- end
- end
- // ----------------------------------------------------------
- // 2) Host request (latest-wins). Preempts tick progression.
- // ----------------------------------------------------------
- if (request_valid && calibrated_r) begin
- // Resume only if new percent, after watchdog, or idle-not-satisfied.
- if ((requested_percent_in != requested_percent) ||
- wd_stopped ||
- ((status_state == ST_IDLE) && (
- ((requested_percent_in == 8'd0) && !open_limit) ||
- ((requested_percent_in == PERCENT_MAX[7:0]) && !close_limit) ||
- ((requested_percent_in > 8'd0) &&
- (requested_percent_in < PERCENT_MAX[7:0]) &&
- (current_position != target_position))
- ))) begin
- requested_percent <= requested_percent_in;
- wd_stopped <= 1'b0;
- replan_pending <= 1'b1;
- planner_req <= 1'b0;
- need_planner <= 1'b0;
- allow_rise <= 1'b0;
- // Same endpoint already in motion: do not reset guard/phase
- if ((requested_percent_in == requested_percent) &&
- endpoint_mode && moving &&
- ((status_state == ST_MOVE_OPEN) || (status_state == ST_MOVE_CLOSE)) &&
- !wd_stopped) begin
- // Idempotent heartbeat while correctly moving: keep going
- replan_pending <= 1'b0;
- end else begin
- // Materially new percent or forced replan: old target invalid
- target_valid <= 1'b0;
- if (gated_step || step) begin
- phase <= PH_DRAIN_HIGH;
- status_state <= ST_WAIT_REPLAN;
- end else begin
- step <= 1'b0;
- phase <= PH_NONE;
- moving <= 1'b0;
- status_state <= ST_WAIT_REPLAN;
- end
- end
- end else begin
- // Same target while already moving/planning/satisfied: no-op
- requested_percent <= requested_percent_in;
- wd_stopped <= 1'b0;
- end
- // ----------------------------------------------------------
- // 3) Watchdog graceful stop (request same cycle already handled)
- // Latch drain once; while PH_DRAIN_HIGH, fall through to §8 so
- // tick_500us can pull STEP low even if watchdog_stop stays high.
- // ----------------------------------------------------------
- end else if (watchdog_stop && calibrated_r && !in_calibration &&
- !wd_stopped &&
- !(status_state == ST_WAIT_REPLAN && phase == PH_DRAIN_HIGH)) begin
- allow_rise <= 1'b0;
- planner_req <= 1'b0;
- need_planner <= 1'b0;
- if (gated_step || step) begin
- phase <= PH_DRAIN_HIGH;
- status_state <= ST_WAIT_REPLAN;
- replan_pending <= 1'b0;
- end else begin
- step <= 1'b0;
- phase <= PH_NONE;
- moving <= 1'b0;
- status_state <= ST_IDLE;
- wd_stopped <= 1'b1;
- replan_pending <= 1'b0;
- end
- // ----------------------------------------------------------
- // 4) Planner result
- // ----------------------------------------------------------
- end else if (planner_accept) begin
- planner_req <= 1'b0;
- need_planner <= 1'b0;
- replan_pending <= 1'b0;
- target_position <= planner_result;
- target_valid <= 1'b1;
- endpoint_mode <= 1'b0;
- motion_count <= {CNT_W{1'b0}};
- step <= 1'b0;
- setup_count <= 4'd0;
- allow_rise <= 1'b0;
- stop_after_budget <= 1'b0;
- if (planner_result == current_position) begin
- status_state <= ST_IDLE;
- moving <= 1'b0;
- phase <= PH_NONE;
- end else if (planner_result > current_position) begin
- dir_close <= 1'b1;
- phase <= PH_DIR_SETUP;
- moving <= 1'b1;
- status_state <= ST_MOVE_CLOSE;
- end else begin
- dir_close <= 1'b0;
- phase <= PH_DIR_SETUP;
- moving <= 1'b1;
- status_state <= ST_MOVE_OPEN;
- end
- // ----------------------------------------------------------
- // 5) Calibration start
- // ----------------------------------------------------------
- end else if (!cal_started) begin
- if (limit_sync_valid) begin
- cal_started <= 1'b1;
- motion_count <= {CNT_W{1'b0}};
- setup_count <= 4'd0;
- allow_rise <= 1'b0;
- stop_after_budget <= 1'b0;
- step <= 1'b0;
- phase <= PH_DIR_SETUP;
- moving <= 1'b1;
- if (close_limit) begin
- dir_close <= 1'b0;
- status_state <= ST_CAL_MEASURE_OPEN;
- end else begin
- dir_close <= 1'b1;
- status_state <= ST_CAL_SEEK_CLOSE;
- end
- end
- // ----------------------------------------------------------
- // 6) CAL_SEEK_CLOSE
- // ----------------------------------------------------------
- end else if (status_state == ST_CAL_SEEK_CLOSE) begin
- if (close_limit) begin
- step <= 1'b0;
- allow_rise <= 1'b0;
- stop_after_budget <= 1'b0;
- motion_count <= {CNT_W{1'b0}};
- setup_count <= 4'd0;
- dir_close <= 1'b0;
- phase <= PH_DIR_SETUP;
- moving <= 1'b1;
- status_state <= ST_CAL_MEASURE_OPEN;
- end else if (stop_after_budget && !gated_step && !step) begin
- status_state <= ST_FAULT;
- fault_code <= FC_CAL_CLOSE_TIMEOUT;
- moving <= 1'b0;
- phase <= PH_NONE;
- end else begin
- // Use post-rise count: if count already at max, stop new rises
- if ((motion_count >= MAX_STEPS_W) ||
- (gated_step_rise && (motion_count + 1'b1 >= MAX_STEPS_W))) begin
- allow_rise <= 1'b0;
- stop_after_budget <= 1'b1;
- end
- if (phase == PH_DIR_SETUP) begin
- step <= 1'b0;
- if (tick_500us) begin
- if (setup_count + 1'b1 >= DIR_SETUP_TICKS[3:0]) begin
- phase <= PH_RUN;
- setup_count <= 4'd0;
- allow_rise <= !stop_after_budget && (motion_count < MAX_STEPS_W);
- end else begin
- setup_count <= setup_count + 1'b1;
- end
- end
- end else if (tick_500us) begin
- step <= step_toggle(step, allow_rise && !stop_after_budget &&
- (motion_count < MAX_STEPS_W));
- end
- end
- // ----------------------------------------------------------
- // 7) CAL_MEASURE_OPEN
- // ----------------------------------------------------------
- end else if (status_state == ST_CAL_MEASURE_OPEN) begin
- if (open_limit) begin
- // motion_count already includes this cycle's rise (NBA: see old+1)
- // Use effective count: if rise this cycle, +1 on current
- if (gated_step_rise) begin
- // effective = motion_count+1 (scheduled); compare with that
- if (((motion_count + 1'b1) >= MIN_TRAVEL_W) &&
- ((motion_count + 1'b1) <= MAX_STEPS_W)) begin
- travel_steps <= motion_count + 1'b1;
- current_position <= {CNT_W{1'b0}};
- target_position <= {CNT_W{1'b0}};
- requested_percent <= 8'd0;
- calibrated_r <= 1'b1;
- fault_code <= FC_NONE;
- target_valid <= 1'b1;
- endpoint_mode <= 1'b1;
- step <= 1'b0;
- phase <= PH_NONE;
- moving <= 1'b0;
- allow_rise <= 1'b0;
- stop_after_budget <= 1'b0;
- status_state <= ST_IDLE;
- end else begin
- status_state <= ST_FAULT;
- fault_code <= FC_TINY_TRAVEL;
- step <= 1'b0;
- moving <= 1'b0;
- phase <= PH_NONE;
- end
- end else begin
- if ((motion_count >= MIN_TRAVEL_W) &&
- (motion_count <= MAX_STEPS_W)) begin
- travel_steps <= motion_count;
- current_position <= {CNT_W{1'b0}};
- target_position <= {CNT_W{1'b0}};
- requested_percent <= 8'd0;
- calibrated_r <= 1'b1;
- fault_code <= FC_NONE;
- target_valid <= 1'b1;
- endpoint_mode <= 1'b1;
- step <= 1'b0;
- phase <= PH_NONE;
- moving <= 1'b0;
- allow_rise <= 1'b0;
- stop_after_budget <= 1'b0;
- status_state <= ST_IDLE;
- end else begin
- status_state <= ST_FAULT;
- fault_code <= FC_TINY_TRAVEL;
- step <= 1'b0;
- moving <= 1'b0;
- phase <= PH_NONE;
- end
- end
- end else if (stop_after_budget && !gated_step && !step) begin
- status_state <= ST_FAULT;
- fault_code <= FC_CAL_OPEN_TIMEOUT;
- moving <= 1'b0;
- phase <= PH_NONE;
- end else begin
- if ((motion_count >= MAX_STEPS_W) ||
- (gated_step_rise && (motion_count + 1'b1 >= MAX_STEPS_W))) begin
- allow_rise <= 1'b0;
- stop_after_budget <= 1'b1;
- end
- if (phase == PH_DIR_SETUP) begin
- step <= 1'b0;
- if (tick_500us) begin
- if (setup_count + 1'b1 >= DIR_SETUP_TICKS[3:0]) begin
- phase <= PH_RUN;
- allow_rise <= !stop_after_budget && (motion_count < MAX_STEPS_W);
- end else begin
- setup_count <= setup_count + 1'b1;
- end
- end
- end else if (tick_500us) begin
- step <= step_toggle(step, allow_rise && !stop_after_budget &&
- (motion_count < MAX_STEPS_W));
- end
- end
- // ----------------------------------------------------------
- // 8) WAIT_REPLAN / drain / decide
- // ----------------------------------------------------------
- end else if (status_state == ST_WAIT_REPLAN) begin
- if (phase == PH_DRAIN_HIGH) begin
- if (tick_500us)
- step <= 1'b0;
- if (!gated_step && (!step || tick_500us)) begin
- step <= 1'b0;
- phase <= PH_NONE;
- moving <= 1'b0;
- if (watchdog_stop) begin
- status_state <= ST_IDLE;
- wd_stopped <= 1'b1;
- replan_pending <= 1'b0;
- end else begin
- replan_pending <= 1'b1;
- end
- end
- end else if (replan_pending) begin
- replan_pending <= 1'b0;
- if (is_open_endpoint) begin
- endpoint_mode <= 1'b1;
- target_position <= {CNT_W{1'b0}};
- target_valid <= 1'b1;
- need_planner <= 1'b0;
- planner_req <= 1'b0;
- if (open_limit) begin
- current_position <= {CNT_W{1'b0}};
- status_state <= ST_IDLE;
- moving <= 1'b0;
- step <= 1'b0;
- phase <= PH_NONE;
- end else begin
- motion_count <= {CNT_W{1'b0}};
- dir_close <= 1'b0;
- step <= 1'b0;
- setup_count <= 4'd0;
- allow_rise <= 1'b0;
- stop_after_budget <= 1'b0;
- phase <= PH_DIR_SETUP;
- moving <= 1'b1;
- status_state <= ST_MOVE_OPEN;
- end
- end else if (is_close_endpoint) begin
- endpoint_mode <= 1'b1;
- target_position <= travel_steps;
- target_valid <= 1'b1;
- need_planner <= 1'b0;
- planner_req <= 1'b0;
- if (close_limit) begin
- current_position <= travel_steps;
- status_state <= ST_IDLE;
- moving <= 1'b0;
- step <= 1'b0;
- phase <= PH_NONE;
- end else begin
- motion_count <= {CNT_W{1'b0}};
- dir_close <= 1'b1;
- step <= 1'b0;
- setup_count <= 4'd0;
- allow_rise <= 1'b0;
- stop_after_budget <= 1'b0;
- phase <= PH_DIR_SETUP;
- moving <= 1'b1;
- status_state <= ST_MOVE_CLOSE;
- end
- end else begin
- endpoint_mode <= 1'b0;
- need_planner <= 1'b1;
- planner_req <= 1'b1;
- moving <= 1'b0;
- step <= 1'b0;
- phase <= PH_NONE;
- end
- end
- // ----------------------------------------------------------
- // 9) MOVE_OPEN / MOVE_CLOSE
- // ----------------------------------------------------------
- end else if ((status_state == ST_MOVE_OPEN) ||
- (status_state == ST_MOVE_CLOSE)) begin
- if (endpoint_mode) begin
- if ((dir_close && close_limit) || (!dir_close && open_limit)) begin
- step <= 1'b0;
- allow_rise <= 1'b0;
- stop_after_budget <= 1'b0;
- phase <= PH_NONE;
- moving <= 1'b0;
- if (dir_close) begin
- current_position <= travel_steps;
- target_position <= travel_steps;
- end else begin
- current_position <= {CNT_W{1'b0}};
- target_position <= {CNT_W{1'b0}};
- end
- status_state <= ST_IDLE;
- end else if (stop_after_budget && !gated_step && !step) begin
- status_state <= ST_FAULT;
- fault_code <= FC_ENDPOINT_TIMEOUT;
- moving <= 1'b0;
- phase <= PH_NONE;
- step <= 1'b0;
- end else begin
- if ((motion_count >= guard_limit) ||
- (gated_step_rise && (motion_count + 1'b1 >= guard_limit))) begin
- allow_rise <= 1'b0;
- stop_after_budget <= 1'b1;
- end
- if (phase == PH_DIR_SETUP) begin
- step <= 1'b0;
- if (tick_500us) begin
- if (setup_count + 1'b1 >= DIR_SETUP_TICKS[3:0]) begin
- phase <= PH_RUN;
- allow_rise <= 1'b1;
- end else begin
- setup_count <= setup_count + 1'b1;
- end
- end
- end else if (phase == PH_DRAIN_HIGH) begin
- if (tick_500us)
- step <= 1'b0;
- end else if (tick_500us) begin
- step <= step_toggle(step, allow_rise && !stop_after_budget &&
- (motion_count < guard_limit));
- end
- end
- end else begin
- // Mid-percent motion
- if ((dir_close && close_limit) || (!dir_close && open_limit)) begin
- step <= 1'b0;
- allow_rise <= 1'b0;
- if (dir_close)
- current_position <= travel_steps;
- else
- current_position <= {CNT_W{1'b0}};
- replan_pending <= 1'b1;
- need_planner <= 1'b0;
- planner_req <= 1'b0;
- phase <= PH_NONE;
- moving <= 1'b0;
- status_state <= ST_WAIT_REPLAN;
- end else begin
- // Effective current after this cycle's rise
- // Completion: compare using updated position intent
- if ((current_position == target_position) ||
- (gated_step_rise && dir_close &&
- (current_position + 1'b1 == target_position)) ||
- (gated_step_rise && !dir_close &&
- (current_position - 1'b1 == target_position))) begin
- allow_rise <= 1'b0;
- if (step || gated_step) begin
- phase <= PH_DRAIN_HIGH;
- if (tick_500us)
- step <= 1'b0;
- end else begin
- step <= 1'b0;
- phase <= PH_NONE;
- moving <= 1'b0;
- status_state <= ST_IDLE;
- end
- end else if (phase == PH_DIR_SETUP) begin
- step <= 1'b0;
- if (tick_500us) begin
- if (setup_count + 1'b1 >= DIR_SETUP_TICKS[3:0]) begin
- phase <= PH_RUN;
- allow_rise <= 1'b1;
- end else begin
- setup_count <= setup_count + 1'b1;
- end
- end
- end else if (phase == PH_DRAIN_HIGH) begin
- if (tick_500us)
- step <= 1'b0;
- if (!step && !gated_step) begin
- moving <= 1'b0;
- status_state <= ST_IDLE;
- phase <= PH_NONE;
- end else if (tick_500us && step) begin
- // falling this tick; next cycle check idle
- end
- end else if (tick_500us) begin
- step <= step_toggle(step, allow_rise);
- end
- end
- end
- // ----------------------------------------------------------
- // 10) IDLE
- // ----------------------------------------------------------
- end else if (status_state == ST_IDLE) begin
- step <= 1'b0;
- moving <= 1'b0;
- if (calibrated_r && is_open_endpoint && open_limit)
- current_position <= {CNT_W{1'b0}};
- if (calibrated_r && is_close_endpoint && close_limit)
- current_position <= travel_steps;
- if (replan_pending)
- status_state <= ST_WAIT_REPLAN;
- end
- end
- end
- endmodule
|