3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-05-24 19:06:22 +00:00

cellaigs: add $priority

This commit is contained in:
Emil J. Tywoniak 2026-01-21 20:55:32 +01:00
parent 3a5c492e32
commit 5a613fc457
10 changed files with 130 additions and 64 deletions

View file

@ -501,6 +501,27 @@ Aig::Aig(Cell *cell)
goto optimize; goto optimize;
} }
if (cell->type == ID($priority))
{
int width = GetSize(cell->getPort(ID::Y));
RTLIL::Const polarity = cell->getParam(ID::POLARITY);
vector<int> A = mk.inport_vec(ID::A, width);
vector<int> Y;
int any_previous_active;
if (width) {
any_previous_active = polarity[0] ? A[0] : mk.not_gate(A[0]);
Y.push_back(A[0]);
}
for (int i = 1; i < width; i++) {
int inactive_val = mk.bool_node(!polarity[i]);
Y.push_back(mk.mux_gate(A[i], inactive_val, any_previous_active));
int is_active = mk.xnor_gate(inactive_val, A[i]);
any_previous_active = mk.or_gate(any_previous_active, is_active);
}
mk.outport_vec(Y, ID::Y);
goto optimize;
}
name.clear(); name.clear();
return; return;

View file

@ -0,0 +1,5 @@
aag 1 1 0 1 0
2
2
c
Generated by Yosys

View file

@ -1,7 +1,12 @@
aag 1 1 0 3 0 aag 5 3 0 4 2
2
2 2
4
6
10
0 0
0 0
0
8 4 2
10 8 6
c c
Generated by Yosys Generated by Yosys

View file

@ -1,13 +1,9 @@
aag 7 4 0 3 3 aag 5 3 0 1 2
2 2
4 4
6 6
8 11
15 8 5 3
0 10 8 7
0
10 5 3
12 10 7
14 12 9
c c
Generated by Yosys Generated by Yosys

View file

@ -1,7 +1,10 @@
aag 3 2 0 1 1 aag 1 1 0 6 0
2 2
4 2
7 0
6 5 3 0
0
0
0
c c
Generated by Yosys Generated by Yosys

View file

@ -1,30 +1,10 @@
aag 25 6 0 2 19 aag 5 2 0 2 3
2 2
4 4
6 11
8
10
12
51
0 0
14 4 2 6 4 2
16 5 3 8 5 3
18 17 15 10 9 7
20 18 6
22 17 15
24 23 7
26 25 21
28 26 8
30 25 21
32 31 9
34 33 29
36 34 10
38 33 29
40 39 11
42 41 37
44 42 12
46 41 37
48 47 13
50 49 45
c c
Generated by Yosys Generated by Yosys

View file

@ -1,9 +1,7 @@
aag 5 2 0 1 3 aag 1 1 0 3 0
2 2
4 2
10 0
6 4 2 0
8 5 3
10 9 7
c c
Generated by Yosys Generated by Yosys

View file

@ -1,20 +1,35 @@
aag 16 13 0 1 3 aag 29 6 0 3 23
2 2
4 4
6 6
8 8
10 10
12 12
14 19
16 38
18 58
20 14 7 2
22 16 6 3
24 18 17 15
26 20 6 3
33 22 20 15
28 17 2 24 9 4
30 16 3 26 8 5
32 31 29 28 27 25
30 28 23
32 27 25
34 20 15
36 34 33
38 37 31
40 27 23
42 41 25
44 11 4
46 10 5
48 47 45
50 48 43
52 47 45
54 41 25
56 54 53
58 57 51
c c
Generated by Yosys Generated by Yosys

View file

@ -1,12 +1,16 @@
aag 10 4 0 4 6 aag 10 4 0 8 6
2 2
4 4
6 6
8 8
15 15
21 21
21 1
21 1
1
1
1
1
10 6 2 10 6 2
12 7 3 12 7 3
14 13 11 14 13 11

View file

@ -1,12 +1,51 @@
aag 8 5 0 1 3 aag 40 16 0 8 24
2 2
4 4
6 6
8 8
10 10
12
14
16 16
12 8 2 18
14 9 3 20
16 15 13 22
24
26
28
30
32
38
44
50
56
62
68
74
80
34 18 2
36 19 3
38 37 35
40 20 4
42 21 5
44 43 41
46 22 6
48 23 7
50 49 47
52 24 8
54 25 9
56 55 53
58 26 10
60 27 11
62 61 59
64 28 12
66 29 13
68 67 65
70 30 14
72 31 15
74 73 71
76 32 16
78 33 17
80 79 77
c c
Generated by Yosys Generated by Yosys