Skip to content

Commit 12f1f41

Browse files
Add Kogge-Stone LCU module implementation
1 parent 6f19de3 commit 12f1f41

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
(* techmap_celltype = "$lcu" *)
2+
module _80_lcu_kogge_stone (P, G, CI, CO);
3+
parameter WIDTH = 2;
4+
5+
(* force_downto *)
6+
input [WIDTH-1:0] P, G;
7+
input CI;
8+
9+
(* force_downto *)
10+
output [WIDTH-1:0] CO;
11+
12+
integer i, j;
13+
(* force_downto *)
14+
reg [WIDTH-1:0] p, g;
15+
16+
wire [1023:0] _TECHMAP_DO_ = "proc; opt -fast";
17+
18+
always @* begin
19+
p = P;
20+
g = G;
21+
22+
// in almost all cases CI will be constant zero
23+
g[0] = g[0] | (p[0] & CI);
24+
25+
for (i = 0; i < $clog2(WIDTH); i = i + 1) begin
26+
for (j = WIDTH - 1; j >= 2**i; j = j - 1) begin
27+
g[j] = g[j] | p[j] & g[j - 2**i];
28+
p[j] = p[j] & p[j - 2**i];
29+
end
30+
end
31+
end
32+
33+
assign CO = g;
34+
endmodule

0 commit comments

Comments
 (0)