|
|
@@ -1,921 +0,0 @@
|
|
|
-`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,
|
|
|
- parameter integer CAL_RAMP_UNIT = 8
|
|
|
-) (
|
|
|
- input wire clk,
|
|
|
- input wire rst_n,
|
|
|
- input wire open_limit,
|
|
|
- input wire close_limit,
|
|
|
- input wire limit_sync_valid,
|
|
|
- input wire cal_enable,
|
|
|
- input wire gated_step,
|
|
|
- input wire gated_step_rise,
|
|
|
- input wire tick_500us,
|
|
|
- input wire step_toggle_pulse,
|
|
|
- input wire request_valid,
|
|
|
- input wire [7:0] requested_percent_in,
|
|
|
- input wire watchdog_stop,
|
|
|
- input wire [20:0] rate_quantum_in,
|
|
|
- input wire rate_quantum_valid,
|
|
|
- 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,
|
|
|
- output wire axis_moving,
|
|
|
- output wire axis_allow_rise,
|
|
|
- output wire axis_in_calibration,
|
|
|
- output wire axis_endpoint_crawl,
|
|
|
- output wire axis_dda_run,
|
|
|
- output reg [3:0] profile_level,
|
|
|
- output reg [12:0] profile_distance,
|
|
|
- output reg [12:0] profile_done_steps,
|
|
|
- output reg [12:0] profile_ramp_unit,
|
|
|
- output reg [20:0] rate_quantum
|
|
|
-);
|
|
|
- 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; // target is 0%/100% (estimated endpoint)
|
|
|
- reg endpoint_crawl_active; // past estimate; level-0 search for real limit
|
|
|
- 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;
|
|
|
- reg open_limit_armed;
|
|
|
- reg close_limit_armed;
|
|
|
- // Cached L*unit for O(1) S-curve climb/drop (avoids 15-iter combo unroll).
|
|
|
- reg [CNT_W-1:0] profile_level_thresh;
|
|
|
-
|
|
|
- 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);
|
|
|
- assign axis_moving = moving;
|
|
|
- assign axis_allow_rise = allow_rise && !stop_after_budget;
|
|
|
- assign axis_in_calibration = in_calibration;
|
|
|
- assign axis_endpoint_crawl = endpoint_crawl_active && moving && calibrated_r;
|
|
|
- // DDA only while producing/consuming half-cycles; DIR_SETUP clears phase via !active.
|
|
|
- assign axis_dda_run = (phase == PH_RUN) || (phase == PH_DRAIN_HIGH);
|
|
|
-
|
|
|
- // Incremental level matching min(15, floor(done/u), floor((rem-1)/u)).
|
|
|
- // One add/compare per rise (no 15-iter combinational scan).
|
|
|
-
|
|
|
- function automatic [CNT_W-1:0] f_ramp_unit;
|
|
|
- input [CNT_W-1:0] distance_i;
|
|
|
- reg [CNT_W-1:0] u;
|
|
|
- begin
|
|
|
- if (distance_i == {CNT_W{1'b0}})
|
|
|
- f_ramp_unit = {{(CNT_W-1){1'b0}}, 1'b1};
|
|
|
- else begin
|
|
|
- u = (distance_i + 7'd63) >> 6;
|
|
|
- f_ramp_unit = (u == {CNT_W{1'b0}}) ? {{(CNT_W-1){1'b0}}, 1'b1} : u;
|
|
|
- end
|
|
|
- end
|
|
|
- endfunction
|
|
|
-
|
|
|
- function automatic [CNT_W-1:0] f_abs_delta;
|
|
|
- input [CNT_W-1:0] a;
|
|
|
- input [CNT_W-1:0] b;
|
|
|
- begin
|
|
|
- f_abs_delta = (a > b) ? (a - b) : (b - a);
|
|
|
- end
|
|
|
- endfunction
|
|
|
- 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 =
|
|
|
- (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.
|
|
|
- // Use held source limit (not only one-shot snap): departure may consume arm
|
|
|
- // without snapping, so a later mid accept while close_limit stays high must
|
|
|
- // still treat the axis as at travel (never MOVE_CLOSE into the close limit).
|
|
|
- wire close_source_hold =
|
|
|
- calibrated_r && !in_calibration && close_limit && !departing_close_source;
|
|
|
- wire open_source_hold =
|
|
|
- calibrated_r && !in_calibration && open_limit && !departing_open_source;
|
|
|
- wire [CNT_W-1:0] effective_current_position =
|
|
|
- close_source_hold ? travel_steps :
|
|
|
- open_source_hold ? {CNT_W{1'b0}} :
|
|
|
- current_position;
|
|
|
-
|
|
|
- // Distinguish request bookkeeping from material replan preempt.
|
|
|
- // Idempotent same-percent heartbeat must not occupy the exclusive FSM branch.
|
|
|
- wire request_seen = request_valid && calibrated_r;
|
|
|
- wire idle_not_satisfied =
|
|
|
- (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))
|
|
|
- );
|
|
|
- wire request_requires_replan = request_seen && (
|
|
|
- (requested_percent_in != requested_percent) ||
|
|
|
- wd_stopped ||
|
|
|
- // Limit snap forces resume only when this cycle cannot accept a matching
|
|
|
- // planner result (which uses effective_current_position for DIR).
|
|
|
- (limit_pos_mismatch && !planner_accept) ||
|
|
|
- idle_not_satisfied
|
|
|
- );
|
|
|
-
|
|
|
- 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;
|
|
|
- endpoint_crawl_active <= 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;
|
|
|
- open_limit_armed <= 1'b1;
|
|
|
- close_limit_armed <= 1'b1;
|
|
|
- profile_level <= 4'd0;
|
|
|
- profile_level_thresh <= {CNT_W{1'b0}};
|
|
|
- profile_distance <= {CNT_W{1'b0}};
|
|
|
- profile_done_steps <= {CNT_W{1'b0}};
|
|
|
- profile_ramp_unit <= {{(CNT_W-1){1'b0}}, 1'b1};
|
|
|
- rate_quantum <= 21'd64; // level-0 scale until shared builder refreshes
|
|
|
- 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;
|
|
|
- // Calibration soft-start: every CAL_RAMP_UNIT rises bump level.
|
|
|
- if (profile_level < 4'd15) begin
|
|
|
- if (profile_done_steps + 1'b1 >= CAL_RAMP_UNIT[CNT_W-1:0]) begin
|
|
|
- profile_done_steps <= {CNT_W{1'b0}};
|
|
|
- profile_level <= profile_level + 1'b1;
|
|
|
- end else begin
|
|
|
- profile_done_steps <= profile_done_steps + 1'b1;
|
|
|
- end
|
|
|
- end
|
|
|
- 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
|
|
|
- // Runtime S-curve on gated rises (mid + endpoint estimate phase).
|
|
|
- // Endpoint crawl holds level 0 after estimate is reached.
|
|
|
- if (moving && !endpoint_crawl_active) begin
|
|
|
- begin : sc_rise
|
|
|
- reg [CNT_W-1:0] done_n;
|
|
|
- reg [CNT_W-1:0] rem_n;
|
|
|
- reg [CNT_W-1:0] rem_term;
|
|
|
- reg [CNT_W-1:0] next_thr;
|
|
|
- done_n = profile_done_steps + 1'b1;
|
|
|
- rem_n = (profile_distance > done_n) ?
|
|
|
- (profile_distance - done_n) : {CNT_W{1'b0}};
|
|
|
- rem_term = (rem_n < {{(CNT_W-1){1'b0}}, 1'b1}) ?
|
|
|
- {CNT_W{1'b0}} : (rem_n - {{(CNT_W-1){1'b0}}, 1'b1});
|
|
|
- profile_done_steps <= done_n;
|
|
|
- if (profile_ramp_unit == {CNT_W{1'b0}}) begin
|
|
|
- profile_level <= 4'd0;
|
|
|
- profile_level_thresh <= {CNT_W{1'b0}};
|
|
|
- end else if ((profile_level != 4'd0) &&
|
|
|
- (rem_term < profile_level_thresh)) begin
|
|
|
- profile_level <= profile_level - 4'd1;
|
|
|
- profile_level_thresh <=
|
|
|
- profile_level_thresh - profile_ramp_unit;
|
|
|
- end else if (profile_level < 4'd15) begin
|
|
|
- next_thr = profile_level_thresh + profile_ramp_unit;
|
|
|
- if ((done_n >= next_thr) && (rem_term >= next_thr)) begin
|
|
|
- profile_level <= profile_level + 4'd1;
|
|
|
- profile_level_thresh <= next_thr;
|
|
|
- end
|
|
|
- end
|
|
|
- end
|
|
|
- end else if (moving && endpoint_crawl_active) begin
|
|
|
- profile_level <= 4'd0;
|
|
|
- profile_level_thresh <= {CNT_W{1'b0}};
|
|
|
- end
|
|
|
- end
|
|
|
- end
|
|
|
- if (rate_quantum_valid)
|
|
|
- rate_quantum <= rate_quantum_in;
|
|
|
-
|
|
|
- // ----------------------------------------------------------
|
|
|
- // 1b) One-shot single-limit snap (consumes assertion interval).
|
|
|
- // Departure from a consumed source limit must not overwrite §1.
|
|
|
- // ----------------------------------------------------------
|
|
|
- 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).
|
|
|
- // Does not occupy the exclusive FSM branch — heartbeat may
|
|
|
- // coexist with planner_accept / tick_500us / limit progression.
|
|
|
- // ----------------------------------------------------------
|
|
|
- if (request_seen) begin
|
|
|
- requested_percent <= requested_percent_in;
|
|
|
- wd_stopped <= 1'b0;
|
|
|
- end
|
|
|
-
|
|
|
- // ----------------------------------------------------------
|
|
|
- // 2b) Material host replan only (latest-wins). Preempts tick.
|
|
|
- // Same-percent heartbeat does NOT enter this branch.
|
|
|
- // ----------------------------------------------------------
|
|
|
- if (request_requires_replan) begin
|
|
|
- replan_pending <= 1'b1;
|
|
|
- planner_req <= 1'b0;
|
|
|
- need_planner <= 1'b0;
|
|
|
- allow_rise <= 1'b0;
|
|
|
- // 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
|
|
|
-
|
|
|
- // ----------------------------------------------------------
|
|
|
- // 3) Watchdog graceful stop (suppressed by same-cycle SET_ALL)
|
|
|
- // 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 && !request_seen &&
|
|
|
- !(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 (uses effective_current_position for DIR)
|
|
|
- // ----------------------------------------------------------
|
|
|
- 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;
|
|
|
- endpoint_crawl_active <= 1'b0;
|
|
|
- motion_count <= {CNT_W{1'b0}};
|
|
|
- step <= 1'b0;
|
|
|
- setup_count <= 4'd0;
|
|
|
- allow_rise <= 1'b0;
|
|
|
- stop_after_budget <= 1'b0;
|
|
|
- begin : sc_init_plan
|
|
|
- reg [CNT_W-1:0] dist_n;
|
|
|
- reg [CNT_W-1:0] unit_n;
|
|
|
- dist_n = f_abs_delta(planner_result, effective_current_position);
|
|
|
- unit_n = f_ramp_unit(dist_n);
|
|
|
- profile_distance <= dist_n;
|
|
|
- profile_ramp_unit <= unit_n;
|
|
|
- profile_done_steps <= {CNT_W{1'b0}};
|
|
|
- // done==0 ⇒ level 0 (same as prior full scan).
|
|
|
- profile_level <= 4'd0;
|
|
|
- profile_level_thresh <= {CNT_W{1'b0}};
|
|
|
- end
|
|
|
- if (planner_result == effective_current_position) begin
|
|
|
- status_state <= ST_IDLE;
|
|
|
- moving <= 1'b0;
|
|
|
- phase <= PH_NONE;
|
|
|
- end else if (planner_result > effective_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 && cal_enable) 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;
|
|
|
- profile_level <= 4'd0;
|
|
|
- profile_level_thresh <= {CNT_W{1'b0}};
|
|
|
- profile_done_steps <= {CNT_W{1'b0}};
|
|
|
- profile_distance <= {CNT_W{1'b0}};
|
|
|
- profile_ramp_unit <= CAL_RAMP_UNIT[CNT_W-1:0];
|
|
|
- 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;
|
|
|
- // Rebuild soft-start for measure-open (no S decelerate claimed).
|
|
|
- profile_level <= 4'd0;
|
|
|
- profile_level_thresh <= {CNT_W{1'b0}};
|
|
|
- profile_done_steps <= {CNT_W{1'b0}};
|
|
|
- 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 (step_toggle_pulse) 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;
|
|
|
- endpoint_crawl_active <= 1'b0;
|
|
|
- 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;
|
|
|
- endpoint_crawl_active <= 1'b0;
|
|
|
- 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 (step_toggle_pulse) 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 (step_toggle_pulse)
|
|
|
- step <= step_toggle(step, 1'b0);
|
|
|
- if (!gated_step && !step) 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}};
|
|
|
- endpoint_crawl_active <= 1'b0;
|
|
|
- profile_level <= 4'd0;
|
|
|
- profile_level_thresh <= {CNT_W{1'b0}};
|
|
|
- profile_done_steps <= {CNT_W{1'b0}};
|
|
|
- profile_distance <= {CNT_W{1'b0}};
|
|
|
- status_state <= ST_IDLE;
|
|
|
- moving <= 1'b0;
|
|
|
- step <= 1'b0;
|
|
|
- phase <= PH_NONE;
|
|
|
- end else begin
|
|
|
- begin : sc_init_open_ep
|
|
|
- reg [CNT_W-1:0] dist_n;
|
|
|
- reg [CNT_W-1:0] unit_n;
|
|
|
- dist_n = f_abs_delta(effective_current_position, {CNT_W{1'b0}});
|
|
|
- unit_n = f_ramp_unit(dist_n);
|
|
|
- profile_distance <= dist_n;
|
|
|
- profile_ramp_unit <= unit_n;
|
|
|
- profile_done_steps <= {CNT_W{1'b0}};
|
|
|
- profile_level <= 4'd0;
|
|
|
- profile_level_thresh <= {CNT_W{1'b0}};
|
|
|
- // Already at estimate with no limit → crawl immediately.
|
|
|
- endpoint_crawl_active <= (dist_n == {CNT_W{1'b0}});
|
|
|
- end
|
|
|
- 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;
|
|
|
- endpoint_crawl_active <= 1'b0;
|
|
|
- profile_level <= 4'd0;
|
|
|
- profile_level_thresh <= {CNT_W{1'b0}};
|
|
|
- profile_done_steps <= {CNT_W{1'b0}};
|
|
|
- profile_distance <= {CNT_W{1'b0}};
|
|
|
- status_state <= ST_IDLE;
|
|
|
- moving <= 1'b0;
|
|
|
- step <= 1'b0;
|
|
|
- phase <= PH_NONE;
|
|
|
- end else begin
|
|
|
- begin : sc_init_close_ep
|
|
|
- reg [CNT_W-1:0] dist_n;
|
|
|
- reg [CNT_W-1:0] unit_n;
|
|
|
- dist_n = f_abs_delta(effective_current_position, travel_steps);
|
|
|
- unit_n = f_ramp_unit(dist_n);
|
|
|
- profile_distance <= dist_n;
|
|
|
- profile_ramp_unit <= unit_n;
|
|
|
- profile_done_steps <= {CNT_W{1'b0}};
|
|
|
- profile_level <= 4'd0;
|
|
|
- profile_level_thresh <= {CNT_W{1'b0}};
|
|
|
- endpoint_crawl_active <= (dist_n == {CNT_W{1'b0}});
|
|
|
- end
|
|
|
- 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;
|
|
|
- endpoint_crawl_active <= 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;
|
|
|
- endpoint_crawl_active <= 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;
|
|
|
- endpoint_crawl_active <= 1'b0;
|
|
|
- moving <= 1'b0;
|
|
|
- phase <= PH_NONE;
|
|
|
- step <= 1'b0;
|
|
|
- end else if (!endpoint_crawl_active) begin
|
|
|
- // Phase A: normal S-curve to estimated 0/travel.
|
|
|
- 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
|
|
|
- // Estimate reached; target limit still missing → crawl.
|
|
|
- endpoint_crawl_active <= 1'b1;
|
|
|
- profile_level <= 4'd0;
|
|
|
- profile_level_thresh <= {CNT_W{1'b0}};
|
|
|
- allow_rise <= !stop_after_budget && (motion_count < guard_limit);
|
|
|
- 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 (step_toggle_pulse) begin
|
|
|
- step <= step_toggle(step, allow_rise && !stop_after_budget &&
|
|
|
- (motion_count < guard_limit));
|
|
|
- end
|
|
|
- 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 (step_toggle_pulse)
|
|
|
- step <= step_toggle(step, 1'b0);
|
|
|
- end else if (step_toggle_pulse) begin
|
|
|
- step <= step_toggle(step, allow_rise && !stop_after_budget &&
|
|
|
- (motion_count < guard_limit));
|
|
|
- end
|
|
|
- end
|
|
|
- end else begin
|
|
|
- // Phase B: level-0 crawl until real limit or travel+500.
|
|
|
- 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 (step_toggle_pulse)
|
|
|
- step <= step_toggle(step, 1'b0);
|
|
|
- end else if (step_toggle_pulse) 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 (step_toggle_pulse)
|
|
|
- step <= step_toggle(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 (step_toggle_pulse)
|
|
|
- step <= step_toggle(step, 1'b0);
|
|
|
- if (!step && !gated_step) begin
|
|
|
- moving <= 1'b0;
|
|
|
- status_state <= ST_IDLE;
|
|
|
- phase <= PH_NONE;
|
|
|
- end
|
|
|
- end else if (step_toggle_pulse) 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 (open_snap_accept)
|
|
|
- current_position <= {CNT_W{1'b0}};
|
|
|
- if (close_snap_accept)
|
|
|
- current_position <= travel_steps;
|
|
|
- if (replan_pending)
|
|
|
- status_state <= ST_WAIT_REPLAN;
|
|
|
- end
|
|
|
- end
|
|
|
- end
|
|
|
-endmodule
|