1
0
mirror of https://github.com/aolofsson/oh.git synced 2025-02-07 06:44:09 +08:00
oh/common/hdl/oh_delay.v
Andreas.Olofsson 6d1735d3b9 Fixing a bunch of synthesis issues
-Better to fix to avoid issues across different synthesis platform
(even if standard would allow if for verilog2005)
2020-08-17 16:11:42 -04:00

35 lines
1.0 KiB
Verilog

//#############################################################################
//# Function: Delays input signal by N clock cycles #
//#############################################################################
//# Author: Andreas Olofsson #
//# License: MIT (see LICENSE file in OH! repository) #
//#############################################################################
module oh_delay #(parameter DW = 1, // width of data
parameter N = 1 // clock cycle delay by
)
(
input [DW-1:0] in, // input
input clk,//clock input
output [DW-1:0] out // output
);
reg [DW-1:0] sync_pipe[N-1:0];
genvar i;
generate
always @ (posedge clk)
sync_pipe[0]<=in[DW-1:0];
for(i=1;i<N;i=i+1) begin: gen_pipe
always @ (posedge clk)
sync_pipe[i]<=sync_pipe[i-1];
end
endgenerate
assign out[DW-1:0] = sync_pipe[N-1];
endmodule // oh_delay