Skip to content

Commit 61a6567

Browse files
authored
Merge pull request #4789 from YosysHQ/emil/sklansky-adder
Add a Sklansky option for `$lcu` mapping
2 parents 889894a + fe64a71 commit 61a6567

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

techlibs/common/Makefile.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ $(eval $(call add_share_file,share,techlibs/common/cmp2lcu.v))
3737
$(eval $(call add_share_file,share,techlibs/common/cmp2softlogic.v))
3838
$(eval $(call add_share_file,share/choices,techlibs/common/choices/kogge-stone.v))
3939
$(eval $(call add_share_file,share/choices,techlibs/common/choices/han-carlson.v))
40+
$(eval $(call add_share_file,share/choices,techlibs/common/choices/sklansky.v))

techlibs/common/choices/sklansky.v

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
(* techmap_celltype = "$lcu" *)
2+
module _80_lcu_sklansky (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+
// iterate in reverse so we don't confuse a result from this stage and the previous
27+
for (j = WIDTH - 1; j >= 0; j = j - 1) begin
28+
if (j & 2**i) begin
29+
g[j] = g[j] | p[j] & g[(j & ~(2**i - 1)) - 1];
30+
p[j] = p[j] & p[(j & ~(2**i - 1)) - 1];
31+
end
32+
end
33+
end
34+
end
35+
36+
assign CO = g;
37+
endmodule

tests/techmap/sklansky.tcl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
yosys -import
2+
3+
read_verilog +/choices/sklansky.v
4+
read_verilog -icells lcu_refined.v
5+
design -save init
6+
7+
for {set i 1} {$i <= 16} {incr i} {
8+
design -load init
9+
chparam -set WIDTH $i
10+
yosys proc
11+
opt_clean
12+
equiv_make lcu _80_lcu_sklansky equiv
13+
equiv_simple equiv
14+
equiv_status -assert equiv
15+
}

0 commit comments

Comments
 (0)