1
0
mirror of https://github.com/pConst/basic_verilog.git synced 2025-01-14 06:42:54 +08:00
basic_verilog/delay.sv
2019-02-23 00:20:06 +03:00

56 lines
1.2 KiB
Systemverilog

//------------------------------------------------------------------------------
// delay.v
// Konstantin Pavlov, pavlovconst@gmail.com
//------------------------------------------------------------------------------
// INFO -------------------------------------------------------------------------
// Static Delay for arbitrary signal
// Another equivalent names for this module:
// conveyor.sv
// synchronizer.sv
//
// Tip for Xilinx-based implementations: Leave nrst=1'b1 and ena=1'b1 on
// purpose of inferring Xilinx`s SRL16E/SRL32E primitives
/* --- INSTANTIATION TEMPLATE BEGIN ---
delay #(
.LENGTH( 2 )
) S1 (
.clk( clk ),
.nrst( 1'b1 ),
.ena( 1'b1 ),
.in( ),
.out( )
);
--- INSTANTIATION TEMPLATE END ---*/
module delay #( parameter
LENGTH = 2 // delay/synchronizer chain length
// default length for synchronizer chain is 2
)(
input clk,
input nrst,
input ena,
input in,
output out
);
(* ASYNC_REG = "TRUE" *) logic [LENGTH:0] data = 0;
always_ff @(posedge clk) begin
if (~nrst) begin
data[LENGTH:0] <= 0;
end else if (ena) begin
data[LENGTH:0] <= {data[LENGTH-1:0],in};
end
end
assign
out = data[LENGTH];
endmodule