Skip to content

Commit 5020e0b

Browse files
committed
Add combinational repeater module
1 parent 39c1b4c commit 5020e0b

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

comb_repeater.sv

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//------------------------------------------------------------------------------
2+
// comb_repeater.sv
3+
// Konstantin Pavlov, [email protected]
4+
//------------------------------------------------------------------------------
5+
6+
// INFO ------------------------------------------------------------------------
7+
// Combinational signal repeater
8+
//
9+
// Every stage consists of two sequential inverters
10+
// Configurable number of stages
11+
//
12+
// Adapted for AMD/Xilinx devices
13+
//
14+
15+
16+
/* --- INSTANTIATION TEMPLATE BEGIN ---
17+
18+
comb_repeater #(
19+
.LENGTH( 2 ),
20+
.WIDTH( 1 )
21+
) R1 (
22+
.in( ),
23+
.out( )
24+
);
25+
26+
--- INSTANTIATION TEMPLATE END ---*/
27+
28+
29+
module comb_repeater #( parameter
30+
LENGTH = 1, // repeater chain length
31+
WIDTH = 1 // repeater bus width
32+
)(
33+
input [WIDTH-1:0] in,
34+
output logic [WIDTH-1:0] out
35+
);
36+
37+
38+
(* DONT_TOUCH = "TRUE" *) logic [LENGTH-1:0][WIDTH-1:0] s1; // first inverter outputs
39+
(* DONT_TOUCH = "TRUE" *) logic [LENGTH-1:0][WIDTH-1:0] s2; // second inverter outputs
40+
41+
genvar i;
42+
generate
43+
for( i=0; i<LENGTH; i=i+1 ) begin
44+
45+
always_comb begin
46+
47+
if( i==(LENGTH-1) ) begin
48+
s1[i][WIDTH-1:0] <= ~in[WIDTH-1:0];
49+
end else begin
50+
s1[i][WIDTH-1:0] <= ~s2[i+1][WIDTH-1:0];
51+
end
52+
53+
if( i==0 ) begin
54+
out[WIDTH-1:0] <= ~s1[i][WIDTH-1:0];
55+
end else begin
56+
s2[i][WIDTH-1:0] <= ~s1[i][WIDTH-1:0];
57+
end
58+
end
59+
60+
end // for
61+
endgenerate
62+
63+
endmodule
64+

0 commit comments

Comments
 (0)