2019-01-09 13:58:20 +03:00
|
|
|
//------------------------------------------------------------------------------
|
2019-05-24 14:23:19 +03:00
|
|
|
// delay.sv
|
2019-01-09 13:58:20 +03:00
|
|
|
// Konstantin Pavlov, pavlovconst@gmail.com
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// INFO -------------------------------------------------------------------------
|
|
|
|
// Static Delay for arbitrary signal
|
|
|
|
// Another equivalent names for this module:
|
|
|
|
// conveyor.sv
|
|
|
|
// synchronizer.sv
|
|
|
|
//
|
2019-01-09 14:23:45 +03:00
|
|
|
// Tip for Xilinx-based implementations: Leave nrst=1'b1 and ena=1'b1 on
|
|
|
|
// purpose of inferring Xilinx`s SRL16E/SRL32E primitives
|
|
|
|
|
2019-01-09 13:58:20 +03:00
|
|
|
|
|
|
|
/* --- INSTANTIATION TEMPLATE BEGIN ---
|
|
|
|
|
2019-01-09 14:23:45 +03:00
|
|
|
delay #(
|
2019-01-09 14:59:39 +03:00
|
|
|
.LENGTH( 2 )
|
2019-01-09 14:23:45 +03:00
|
|
|
) S1 (
|
2019-01-09 13:58:20 +03:00
|
|
|
.clk( clk ),
|
|
|
|
.nrst( 1'b1 ),
|
2019-01-09 14:59:39 +03:00
|
|
|
.ena( 1'b1 ),
|
2019-01-09 13:58:20 +03:00
|
|
|
.in( ),
|
|
|
|
.out( )
|
|
|
|
);
|
|
|
|
|
|
|
|
--- INSTANTIATION TEMPLATE END ---*/
|
|
|
|
|
|
|
|
|
2019-02-23 00:20:06 +03:00
|
|
|
module delay #( parameter
|
2019-02-27 15:08:26 +03:00
|
|
|
LENGTH = 2 // delay/synchronizer chain length
|
|
|
|
// default length for synchronizer chain is 2
|
2019-01-09 13:58:20 +03:00
|
|
|
)(
|
|
|
|
input clk,
|
|
|
|
input nrst,
|
|
|
|
input ena,
|
|
|
|
input in,
|
2019-02-23 00:20:06 +03:00
|
|
|
output out
|
2019-01-09 13:58:20 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
|
2019-02-27 15:08:26 +03:00
|
|
|
logic [LENGTH-1:0] data = 0;
|
2019-01-09 13:58:20 +03:00
|
|
|
always_ff @(posedge clk) begin
|
|
|
|
if (~nrst) begin
|
2019-02-27 15:08:26 +03:00
|
|
|
data[LENGTH-1:0] <= 0;
|
2019-01-09 13:58:20 +03:00
|
|
|
end else if (ena) begin
|
2019-02-27 15:08:26 +03:00
|
|
|
data[LENGTH-1:0] <= {data[LENGTH-2:0],in};
|
2019-01-09 13:58:20 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
assign
|
2019-02-27 15:08:26 +03:00
|
|
|
out = data[LENGTH-1];
|
2019-01-09 13:58:20 +03:00
|
|
|
|
|
|
|
endmodule
|