Skip to content

Commit 46fbed6

Browse files
authored
Merge pull request #5525 from YosysHQ/emil/fix-xaiger2-empty-cell-input
aiger2: fix empty cell input
2 parents 52b1245 + 36f0e03 commit 46fbed6

File tree

3 files changed

+97
-5
lines changed

3 files changed

+97
-5
lines changed

backends/aiger2/aiger.cc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include "kernel/register.h"
2626
#include "kernel/celltypes.h"
27+
#include "kernel/rtlil.h"
2728

2829
USING_YOSYS_NAMESPACE
2930
PRIVATE_NAMESPACE_BEGIN
@@ -845,11 +846,14 @@ struct XAigerAnalysis : Index<XAigerAnalysis, int, 0, 0> {
845846
return false;
846847

847848
int max = 1;
848-
for (auto wire : mod->wires())
849-
if (wire->port_input && !wire->port_output)
850-
for (int i = 0; i < wire->width; i++) {
851-
int ilevel = visit(cursor, driver->getPort(wire->name)[i]);
852-
max = std::max(max, ilevel + 1);
849+
for (auto wire : mod->wires()) {
850+
if (wire->port_input && !wire->port_output) {
851+
SigSpec port = driver->getPort(wire->name);
852+
for (int i = 0; i < std::min(wire->width, port.size()); i++) {
853+
int ilevel = visit(cursor, port[i]);
854+
max = std::max(max, ilevel + 1);
855+
}
856+
}
853857
}
854858
lits[idx] = max;
855859

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
&st
2+
&dch -r
3+
&nf
4+
&st
5+
&syn2
6+
&if -g -K 6
7+
&synch2 -r
8+
&nf
9+
&st
10+
&syn2
11+
&if -g -K 6
12+
&synch2 -r
13+
&nf
14+
&st
15+
&syn2
16+
&if -g -K 6
17+
&synch2 -r
18+
&nf
19+
&st
20+
&syn2
21+
&if -g -K 6
22+
&synch2 -r
23+
&nf
24+
&st
25+
&syn2
26+
&if -g -K 6
27+
&synch2 -r
28+
&nf

tests/techmap/xaiger2-5169.ys

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
read_rtlil <<EOF
2+
3+
# Generated by Yosys 0.53+98 (git sha1 780b12271, g++ 15.1.1 -fPIC -O3)
4+
autoidx 30
5+
attribute \top 1
6+
attribute \src "top.v:1.1-21.10"
7+
module \top
8+
attribute \src "top.v:7.15-7.18"
9+
wire output 1 \led
10+
attribute \src "top.v:9.8-9.9"
11+
wire \w
12+
attribute \src "top.v:20.16-20.18"
13+
cell $not $not$top.v:20$1
14+
parameter \A_SIGNED 0
15+
parameter \A_WIDTH 1
16+
parameter \Y_WIDTH 1
17+
connect \A \w
18+
connect \Y \led
19+
end
20+
attribute \module_not_derived 1
21+
attribute \src "top.v:10.10-18.4"
22+
cell \CC_MX4 \mux
23+
connect \D0 1'x
24+
connect \D1 1'x
25+
connect \D2 1'x
26+
connect \D3 { }
27+
connect \S0 1'x
28+
connect \S1 1'x
29+
connect \Y \w
30+
end
31+
end
32+
33+
EOF
34+
35+
read_verilog -lib -specify <<EOF
36+
37+
(* abc9_box, lib_whitebox *)
38+
module CC_MX4 (
39+
input D0, D1, D2, D3,
40+
input S0, S1,
41+
output Y
42+
);
43+
specify
44+
(D0 => Y) = 453;
45+
(D1 => Y) = 449;
46+
(D2 => Y) = 488;
47+
(D3 => Y) = 484;
48+
(S0 => Y) = 422;
49+
(S1 => Y) = 385;
50+
endspecify
51+
52+
assign Y = S1 ? (S0 ? D3 : D2) :
53+
(S0 ? D1 : D0);
54+
55+
endmodule
56+
57+
EOF
58+
59+
logger -expect error "Malformed design" 1
60+
abc_new -script abc_speed_gia_only.script -liberty ../../tests/liberty/normal.lib -liberty ../../tests/liberty/dff.lib

0 commit comments

Comments
 (0)