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