3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-07-17 04:35:44 +00:00
This commit is contained in:
Emil J. Tywoniak 2026-06-12 00:18:53 +02:00
parent afdae7b87e
commit c3ffbf6fae
229 changed files with 3902 additions and 3835 deletions

View file

@ -302,60 +302,60 @@ Aig::Aig(Cell *cell)
}
}
if (cell->type.in(ID($not), ID($_NOT_), ID($pos), ID($buf), ID($_BUF_)))
if (cell->type.in(TW($not), TW($_NOT_), TW($pos), TW($buf), TW($_BUF_)))
{
for (int i = 0; i < GetSize(cell->getPort(TW::Y)); i++) {
int A = mk.inport(TW::A, i);
int Y = cell->type.in(ID($not), ID($_NOT_)) ? mk.not_gate(A) : A;
int Y = cell->type.in(TW($not), TW($_NOT_)) ? mk.not_gate(A) : A;
mk.outport(Y, TW::Y, i);
}
goto optimize;
}
if (cell->type.in(ID($and), ID($_AND_), ID($_NAND_), ID($or), ID($_OR_), ID($_NOR_), ID($xor), ID($xnor), ID($_XOR_), ID($_XNOR_), ID($_ANDNOT_), ID($_ORNOT_)))
if (cell->type.in(TW($and), TW($_AND_), TW($_NAND_), TW($or), TW($_OR_), TW($_NOR_), TW($xor), TW($xnor), TW($_XOR_), TW($_XNOR_), TW($_ANDNOT_), TW($_ORNOT_)))
{
for (int i = 0; i < GetSize(cell->getPort(TW::Y)); i++) {
int A = mk.inport(TW::A, i);
int B = mk.inport(TW::B, i);
int Y = cell->type.in(ID($and), ID($_AND_)) ? mk.and_gate(A, B) :
cell->type.in(ID($_NAND_)) ? mk.nand_gate(A, B) :
cell->type.in(ID($or), ID($_OR_)) ? mk.or_gate(A, B) :
cell->type.in(ID($_NOR_)) ? mk.nor_gate(A, B) :
cell->type.in(ID($xor), ID($_XOR_)) ? mk.xor_gate(A, B) :
cell->type.in(ID($xnor), ID($_XNOR_)) ? mk.xnor_gate(A, B) :
cell->type.in(ID($_ANDNOT_)) ? mk.andnot_gate(A, B) :
cell->type.in(ID($_ORNOT_)) ? mk.ornot_gate(A, B) : -1;
int Y = cell->type.in(TW($and), TW($_AND_)) ? mk.and_gate(A, B) :
cell->type.in(TW($_NAND_)) ? mk.nand_gate(A, B) :
cell->type.in(TW($or), TW($_OR_)) ? mk.or_gate(A, B) :
cell->type.in(TW($_NOR_)) ? mk.nor_gate(A, B) :
cell->type.in(TW($xor), TW($_XOR_)) ? mk.xor_gate(A, B) :
cell->type.in(TW($xnor), TW($_XNOR_)) ? mk.xnor_gate(A, B) :
cell->type.in(TW($_ANDNOT_)) ? mk.andnot_gate(A, B) :
cell->type.in(TW($_ORNOT_)) ? mk.ornot_gate(A, B) : -1;
mk.outport(Y, TW::Y, i);
}
goto optimize;
}
if (cell->type.in(ID($mux), ID($_MUX_), ID($_NMUX_)))
if (cell->type.in(TW($mux), TW($_MUX_), TW($_NMUX_)))
{
int S = mk.inport(TW::S);
for (int i = 0; i < GetSize(cell->getPort(TW::Y)); i++) {
int A = mk.inport(TW::A, i);
int B = mk.inport(TW::B, i);
int Y = mk.mux_gate(A, B, S);
if (cell->type == ID($_NMUX_))
if (cell->type == TW($_NMUX_))
Y = mk.not_gate(Y);
mk.outport(Y, TW::Y, i);
}
goto optimize;
}
if (cell->type.in(ID($reduce_and), ID($reduce_or), ID($reduce_xor), ID($reduce_xnor), ID($reduce_bool)))
if (cell->type.in(TW($reduce_and), TW($reduce_or), TW($reduce_xor), TW($reduce_xnor), TW($reduce_bool)))
{
int Y = mk.inport(TW::A, 0);
for (int i = 1; i < GetSize(cell->getPort(TW::A)); i++) {
int A = mk.inport(TW::A, i);
if (cell->type == ID($reduce_and)) Y = mk.and_gate(A, Y);
if (cell->type == ID($reduce_or)) Y = mk.or_gate(A, Y);
if (cell->type == ID($reduce_bool)) Y = mk.or_gate(A, Y);
if (cell->type == ID($reduce_xor)) Y = mk.xor_gate(A, Y);
if (cell->type == ID($reduce_xnor)) Y = mk.xor_gate(A, Y);
if (cell->type == TW($reduce_and)) Y = mk.and_gate(A, Y);
if (cell->type == TW($reduce_or)) Y = mk.or_gate(A, Y);
if (cell->type == TW($reduce_bool)) Y = mk.or_gate(A, Y);
if (cell->type == TW($reduce_xor)) Y = mk.xor_gate(A, Y);
if (cell->type == TW($reduce_xnor)) Y = mk.xor_gate(A, Y);
}
if (cell->type == ID($reduce_xnor))
if (cell->type == TW($reduce_xnor))
Y = mk.not_gate(Y);
mk.outport(Y, TW::Y, 0);
for (int i = 1; i < GetSize(cell->getPort(TW::Y)); i++)
@ -363,31 +363,31 @@ Aig::Aig(Cell *cell)
goto optimize;
}
if (cell->type.in(ID($logic_not), ID($logic_and), ID($logic_or)))
if (cell->type.in(TW($logic_not), TW($logic_and), TW($logic_or)))
{
int A = mk.inport(TW::A, 0), Y = -1;
for (int i = 1; i < GetSize(cell->getPort(TW::A)); i++)
A = mk.or_gate(mk.inport(TW::A, i), A);
if (cell->type.in(ID($logic_and), ID($logic_or))) {
if (cell->type.in(TW($logic_and), TW($logic_or))) {
int B = mk.inport(TW::B, 0);
for (int i = 1; i < GetSize(cell->getPort(TW::B)); i++)
B = mk.or_gate(mk.inport(TW::B, i), B);
if (cell->type == ID($logic_and)) Y = mk.and_gate(A, B);
if (cell->type == ID($logic_or)) Y = mk.or_gate(A, B);
if (cell->type == TW($logic_and)) Y = mk.and_gate(A, B);
if (cell->type == TW($logic_or)) Y = mk.or_gate(A, B);
} else {
if (cell->type == ID($logic_not)) Y = mk.not_gate(A);
if (cell->type == TW($logic_not)) Y = mk.not_gate(A);
}
mk.outport_bool(Y, TW::Y);
goto optimize;
}
if (cell->type.in(ID($add), ID($sub)))
if (cell->type.in(TW($add), TW($sub)))
{
int width = GetSize(cell->getPort(TW::Y));
vector<int> A = mk.inport_vec(TW::A, width);
vector<int> B = mk.inport_vec(TW::B, width);
int carry = mk.bool_node(false);
if (cell->type == ID($sub)) {
if (cell->type == TW($sub)) {
for (auto &n : B)
n = mk.not_gate(n);
carry = mk.not_gate(carry);
@ -397,17 +397,17 @@ Aig::Aig(Cell *cell)
goto optimize;
}
if (cell->type.in(ID($lt), ID($gt), ID($le), ID($ge)))
if (cell->type.in(TW($lt), TW($gt), TW($le), TW($ge)))
{
int width = std::max(GetSize(cell->getPort(TW::A)),
GetSize(cell->getPort(TW::B))) + 1;
vector<int> A = mk.inport_vec(TW::A, width);
vector<int> B = mk.inport_vec(TW::B, width);
if (cell->type.in(ID($gt), ID($ge)))
if (cell->type.in(TW($gt), TW($ge)))
std::swap(A, B);
int carry = mk.bool_node(!cell->type.in(ID($le), ID($ge)));
int carry = mk.bool_node(!cell->type.in(TW($le), TW($ge)));
for (auto &n : B)
n = mk.not_gate(n);
vector<int> Y = mk.adder(A, B, carry);
@ -417,7 +417,7 @@ Aig::Aig(Cell *cell)
goto optimize;
}
if (cell->type == ID($alu))
if (cell->type == TW($alu))
{
int width = GetSize(cell->getPort(TW::Y));
vector<int> A = mk.inport_vec(TW::A, width);
@ -436,7 +436,7 @@ Aig::Aig(Cell *cell)
goto optimize;
}
if (cell->type.in(ID($eq), ID($ne)))
if (cell->type.in(TW($eq), TW($ne)))
{
int width = max(GetSize(cell->getPort(TW::A)), GetSize(cell->getPort(TW::B)));
vector<int> A = mk.inport_vec(TW::A, width);
@ -444,13 +444,13 @@ Aig::Aig(Cell *cell)
int Y = mk.bool_node(false);
for (int i = 0; i < width; i++)
Y = mk.or_gate(Y, mk.xor_gate(A[i], B[i]));
if (cell->type == ID($eq))
if (cell->type == TW($eq))
Y = mk.not_gate(Y);
mk.outport_bool(Y, TW::Y);
goto optimize;
}
if (cell->type == ID($_AOI3_))
if (cell->type == TW($_AOI3_))
{
int A = mk.inport(TW::A);
int B = mk.inport(TW::B);
@ -460,7 +460,7 @@ Aig::Aig(Cell *cell)
goto optimize;
}
if (cell->type == ID($_OAI3_))
if (cell->type == TW($_OAI3_))
{
int A = mk.inport(TW::A);
int B = mk.inport(TW::B);
@ -470,7 +470,7 @@ Aig::Aig(Cell *cell)
goto optimize;
}
if (cell->type == ID($_AOI4_))
if (cell->type == TW($_AOI4_))
{
int A = mk.inport(TW::A);
int B = mk.inport(TW::B);
@ -482,7 +482,7 @@ Aig::Aig(Cell *cell)
goto optimize;
}
if (cell->type == ID($_OAI4_))
if (cell->type == TW($_OAI4_))
{
int A = mk.inport(TW::A);
int B = mk.inport(TW::B);