// pulse_stretch.sv module pulse_stretch #( parameter int N = 4 ) ( input logic clk, rst, in_pulse, output logic out ); localparam int CW = $clog2(N + 1); logic [CW-1:0] cnt; always_ff @(posedge clk) if (rst) cnt <= '0; else if (in_pulse) cnt <= CW'(N); // (re)start the window else if (cnt != '0) cnt <= cnt - 1'b1; assign out = (cnt != '0); endmodule