1
0
mirror of https://github.com/aolofsson/oh.git synced 2025-01-17 20:02:53 +08:00
oh/common/hdl/oh_stretcher.v
Andreas Olofsson 19fa611bb9 Massive reorganization to impove reuse
- adding more chip code
- pushing memory stuff into common
- making common "oh_" naming class
-
2015-11-30 13:45:49 -05:00

41 lines
694 B
Verilog

/*
* This module stretches a pulse by DW+1 clock cycles
* Can be useful for synchronous clock transfers from fast to slow.
* The block has one cycle latency
*
* in
* clk
* out
*
*/
module oh_stretcher (/*AUTOARG*/
// Outputs
out,
// Inputs
clk, in, nrst
);
parameter CYCLES = 4;
input clk;
input in;
input nrst;
output out;
reg [CYCLES-1:0] valid;
always @ (posedge clk)
if(!nrst)
valid[CYCLES-1:0] <='b0;
else if(in)
valid[CYCLES-1:0] <={(CYCLES){1'b1}};
else
valid[CYCLES-1:0] <={valid[CYCLES-2:0],1'b0};
assign out = valid[CYCLES-1];
endmodule // oh_stretcher