| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- `timescale 1ns/1ps
- // Production selected-limit hard gate: immediate truncate + hold until engine low.
- // Formal and sim must instantiate this module (not a hand-copied shell).
- module prod2u_runtime_step_limit_gate #(
- parameter integer AXIS_COUNT = 3
- ) (
- input wire clk,
- input wire rst_n,
- input wire [AXIS_COUNT-1:0] engine_step,
- input wire [AXIS_COUNT-1:0] engine_dir,
- input wire [AXIS_COUNT-1:0] close_limit,
- input wire [AXIS_COUNT-1:0] open_limit,
- output wire [AXIS_COUNT-1:0] selected_limit,
- output wire [AXIS_COUNT-1:0] gated_step
- );
- reg [AXIS_COUNT-1:0] gate_hold;
- genvar gi;
- generate
- for (gi = 0; gi < AXIS_COUNT; gi = gi + 1) begin : gen_gate
- assign selected_limit[gi] =
- engine_dir[gi] ? close_limit[gi] : open_limit[gi];
- assign gated_step[gi] =
- engine_step[gi] & ~selected_limit[gi] & ~gate_hold[gi];
- end
- endgenerate
- integer ai;
- always @(posedge clk or negedge rst_n) begin
- if (!rst_n) begin
- gate_hold <= {AXIS_COUNT{1'b0}};
- end else begin
- for (ai = 0; ai < AXIS_COUNT; ai = ai + 1) begin
- if (!engine_step[ai])
- gate_hold[ai] <= 1'b0;
- else if (selected_limit[ai])
- gate_hold[ai] <= 1'b1;
- end
- end
- end
- endmodule
|