Skip to content

Commit 45a1621

Browse files
committed
Restored simplified Verilog version of delay.sv
1 parent db681a4 commit 45a1621

File tree

2 files changed

+79
-9
lines changed

2 files changed

+79
-9
lines changed

delay.sv

+10-9
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@
2626
/* --- INSTANTIATION TEMPLATE BEGIN ---
2727
2828
delay #(
29-
.LENGTH( 2 ),
30-
.WIDTH( 1 ),
31-
.TYPE( "CELLS" ),
32-
.REGISTER_OUTPUTS( "FALSE" )
29+
.LENGTH( 2 ),
30+
.WIDTH( 1 ),
31+
.TYPE( "CELLS" ),
32+
.REGISTER_OUTPUTS( "FALSE" )
3333
) S1 (
34-
.clk( clk ),
35-
.nrst( 1'b1 ),
36-
.ena( 1'b1 ),
34+
.clk( clk ),
35+
.nrst( 1'b1 ),
36+
.ena( 1'b1 ),
3737
38-
.in( ),
39-
.out( )
38+
.in( ),
39+
.out( )
4040
);
4141
4242
--- INSTANTIATION TEMPLATE END ---*/
@@ -209,3 +209,4 @@ generate
209209
endgenerate
210210

211211
endmodule
212+

delay.v

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
//------------------------------------------------------------------------------
2+
// delay.v
3+
// published as part of https://github.com/pConst/basic_verilog
4+
// Konstantin Pavlov, [email protected]
5+
//------------------------------------------------------------------------------
6+
7+
// INFO -------------------------------------------------------------------------
8+
// Static Delay for arbitrary signal
9+
// (simplified Verilog version, see ./delay.sv for advanced features)
10+
//
11+
// Another equivalent names for this module:
12+
// conveyor.sv
13+
// synchronizer.sv
14+
//
15+
// Tip for Xilinx-based implementations: Leave nrst=1'b1 and ena=1'b1 on
16+
// purpose of inferring Xilinx`s SRL16E/SRL32E primitives
17+
//
18+
// CAUTION: delay module is widely used for synchronizing signals across clock
19+
// domains. When synchronizing, please exclude input data paths from timing
20+
// analysis manually by writing appropriate set_false_path SDC constraint
21+
//
22+
23+
/* --- INSTANTIATION TEMPLATE BEGIN ---
24+
25+
delay S1 #(
26+
.LENGTH( 2 ),
27+
.WIDTH( 1 )
28+
)(
29+
.clk( clk ),
30+
.nrst( 1'b1 ),
31+
.ena( 1'b1 ),
32+
33+
.in( ),
34+
.out( )
35+
);
36+
37+
--- INSTANTIATION TEMPLATE END ---*/
38+
39+
40+
module delay #( parameter
41+
LENGTH = 2, // delay/synchronizer chain length
42+
WIDTH = 1 // signal width
43+
)(
44+
input clk,
45+
input nrst,
46+
input ena,
47+
48+
input [WIDTH-1:0] in,
49+
output [WIDTH-1:0] out
50+
);
51+
52+
reg [LENGTH:1][WIDTH-1:0] data = 0;
53+
54+
always @(posedge clk) begin
55+
integer i;
56+
if( ~nrst ) begin
57+
data <= 0;
58+
end else if( ena ) begin
59+
for( i=LENGTH-1; i>0; i=i-1 ) begin
60+
data[i+1][WIDTH-1:0] <= data[i][WIDTH-1:0];
61+
end
62+
data[1][WIDTH-1:0] <= in[WIDTH-1:0];
63+
end
64+
end
65+
66+
assign out[WIDTH-1:0] = data[LENGTH][WIDTH-1:0];
67+
68+
endmodule
69+

0 commit comments

Comments
 (0)