mirror of
https://github.com/aolofsson/oh.git
synced 2025-01-30 02:32:53 +08:00
35d86bcdc3
-simple but powerful for syncing from fast to slow clock domains
34 lines
590 B
Verilog
34 lines
590 B
Verilog
/*
|
|
* This module stretches a pulse by DW+1 clock cycles
|
|
* Can be useful for synchronous clock transfers from fast to slow.
|
|
*
|
|
*/
|
|
module pulse_stretcher (/*AUTOARG*/
|
|
// Outputs
|
|
out,
|
|
// Inputs
|
|
clk, reset, in
|
|
);
|
|
|
|
parameter DW = 1;
|
|
|
|
input clk;
|
|
input reset;
|
|
input in;
|
|
output out;
|
|
|
|
reg [DW-1:0] wide_pulse;
|
|
|
|
|
|
always @ (posedge clk or posedge reset)
|
|
if(reset)
|
|
wide_pulse[DW-1:0] <= 'b0;
|
|
else
|
|
wide_pulse[DW-1:0] <= {wide_pulse[DW-2:0],in};
|
|
|
|
assign out = (|{wide_pulse[DW-1:0],in});
|
|
|
|
endmodule // pulse_stretcher
|
|
|
|
|