mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-06 06:03:23 +00:00
Use ID() macro in all of passes/opt/
This was obtained by running the following SED command in passes/opt/ and then using "meld foo.cc foo.cc.orig" to manually fix all resulting compiler errors. sed -i.orig -r 's/"\\\\([a-zA-Z0-9_]+)"/ID(\1)/g; s/"(\$[a-zA-Z0-9_]+)"/ID(\1)/g;' *.cc Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
parent
b5534b66c8
commit
6995914f3f
12 changed files with 991 additions and 991 deletions
|
@ -47,8 +47,8 @@ struct OptMergeWorker
|
|||
|
||||
static void sort_pmux_conn(dict<RTLIL::IdString, RTLIL::SigSpec> &conn)
|
||||
{
|
||||
SigSpec sig_s = conn.at("\\S");
|
||||
SigSpec sig_b = conn.at("\\B");
|
||||
SigSpec sig_s = conn.at(ID(S));
|
||||
SigSpec sig_b = conn.at(ID(B));
|
||||
|
||||
int s_width = GetSize(sig_s);
|
||||
int width = GetSize(sig_b) / s_width;
|
||||
|
@ -59,12 +59,12 @@ struct OptMergeWorker
|
|||
|
||||
std::sort(sb_pairs.begin(), sb_pairs.end());
|
||||
|
||||
conn["\\S"] = SigSpec();
|
||||
conn["\\B"] = SigSpec();
|
||||
conn[ID(S)] = SigSpec();
|
||||
conn[ID(B)] = SigSpec();
|
||||
|
||||
for (auto &it : sb_pairs) {
|
||||
conn["\\S"].append(it.first);
|
||||
conn["\\B"].append(it.second);
|
||||
conn[ID(S)].append(it.first);
|
||||
conn[ID(B)].append(it.second);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,32 +94,32 @@ struct OptMergeWorker
|
|||
const dict<RTLIL::IdString, RTLIL::SigSpec> *conn = &cell->connections();
|
||||
dict<RTLIL::IdString, RTLIL::SigSpec> alt_conn;
|
||||
|
||||
if (cell->type.in("$and", "$or", "$xor", "$xnor", "$add", "$mul",
|
||||
"$logic_and", "$logic_or", "$_AND_", "$_OR_", "$_XOR_")) {
|
||||
if (cell->type.in(ID($and), ID($or), ID($xor), ID($xnor), ID($add), ID($mul),
|
||||
ID($logic_and), ID($logic_or), ID($_AND_), ID($_OR_), ID($_XOR_))) {
|
||||
alt_conn = *conn;
|
||||
if (assign_map(alt_conn.at("\\A")) < assign_map(alt_conn.at("\\B"))) {
|
||||
alt_conn["\\A"] = conn->at("\\B");
|
||||
alt_conn["\\B"] = conn->at("\\A");
|
||||
if (assign_map(alt_conn.at(ID(A))) < assign_map(alt_conn.at(ID(B)))) {
|
||||
alt_conn[ID(A)] = conn->at(ID(B));
|
||||
alt_conn[ID(B)] = conn->at(ID(A));
|
||||
}
|
||||
conn = &alt_conn;
|
||||
} else
|
||||
if (cell->type.in("$reduce_xor", "$reduce_xnor")) {
|
||||
if (cell->type.in(ID($reduce_xor), ID($reduce_xnor))) {
|
||||
alt_conn = *conn;
|
||||
assign_map.apply(alt_conn.at("\\A"));
|
||||
alt_conn.at("\\A").sort();
|
||||
assign_map.apply(alt_conn.at(ID(A)));
|
||||
alt_conn.at(ID(A)).sort();
|
||||
conn = &alt_conn;
|
||||
} else
|
||||
if (cell->type.in("$reduce_and", "$reduce_or", "$reduce_bool")) {
|
||||
if (cell->type.in(ID($reduce_and), ID($reduce_or), ID($reduce_bool))) {
|
||||
alt_conn = *conn;
|
||||
assign_map.apply(alt_conn.at("\\A"));
|
||||
alt_conn.at("\\A").sort_and_unify();
|
||||
assign_map.apply(alt_conn.at(ID(A)));
|
||||
alt_conn.at(ID(A)).sort_and_unify();
|
||||
conn = &alt_conn;
|
||||
} else
|
||||
if (cell->type == "$pmux") {
|
||||
if (cell->type == ID($pmux)) {
|
||||
alt_conn = *conn;
|
||||
assign_map.apply(alt_conn.at("\\A"));
|
||||
assign_map.apply(alt_conn.at("\\B"));
|
||||
assign_map.apply(alt_conn.at("\\S"));
|
||||
assign_map.apply(alt_conn.at(ID(A)));
|
||||
assign_map.apply(alt_conn.at(ID(B)));
|
||||
assign_map.apply(alt_conn.at(ID(S)));
|
||||
sort_pmux_conn(alt_conn);
|
||||
conn = &alt_conn;
|
||||
}
|
||||
|
@ -189,28 +189,28 @@ struct OptMergeWorker
|
|||
assign_map.apply(it.second);
|
||||
}
|
||||
|
||||
if (cell1->type == "$and" || cell1->type == "$or" || cell1->type == "$xor" || cell1->type == "$xnor" || cell1->type == "$add" || cell1->type == "$mul" ||
|
||||
cell1->type == "$logic_and" || cell1->type == "$logic_or" || cell1->type == "$_AND_" || cell1->type == "$_OR_" || cell1->type == "$_XOR_") {
|
||||
if (conn1.at("\\A") < conn1.at("\\B")) {
|
||||
RTLIL::SigSpec tmp = conn1["\\A"];
|
||||
conn1["\\A"] = conn1["\\B"];
|
||||
conn1["\\B"] = tmp;
|
||||
if (cell1->type == ID($and) || cell1->type == ID($or) || cell1->type == ID($xor) || cell1->type == ID($xnor) || cell1->type == ID($add) || cell1->type == ID($mul) ||
|
||||
cell1->type == ID($logic_and) || cell1->type == ID($logic_or) || cell1->type == ID($_AND_) || cell1->type == ID($_OR_) || cell1->type == ID($_XOR_)) {
|
||||
if (conn1.at(ID(A)) < conn1.at(ID(B))) {
|
||||
RTLIL::SigSpec tmp = conn1[ID(A)];
|
||||
conn1[ID(A)] = conn1[ID(B)];
|
||||
conn1[ID(B)] = tmp;
|
||||
}
|
||||
if (conn2.at("\\A") < conn2.at("\\B")) {
|
||||
RTLIL::SigSpec tmp = conn2["\\A"];
|
||||
conn2["\\A"] = conn2["\\B"];
|
||||
conn2["\\B"] = tmp;
|
||||
if (conn2.at(ID(A)) < conn2.at(ID(B))) {
|
||||
RTLIL::SigSpec tmp = conn2[ID(A)];
|
||||
conn2[ID(A)] = conn2[ID(B)];
|
||||
conn2[ID(B)] = tmp;
|
||||
}
|
||||
} else
|
||||
if (cell1->type == "$reduce_xor" || cell1->type == "$reduce_xnor") {
|
||||
conn1["\\A"].sort();
|
||||
conn2["\\A"].sort();
|
||||
if (cell1->type == ID($reduce_xor) || cell1->type == ID($reduce_xnor)) {
|
||||
conn1[ID(A)].sort();
|
||||
conn2[ID(A)].sort();
|
||||
} else
|
||||
if (cell1->type == "$reduce_and" || cell1->type == "$reduce_or" || cell1->type == "$reduce_bool") {
|
||||
conn1["\\A"].sort_and_unify();
|
||||
conn2["\\A"].sort_and_unify();
|
||||
if (cell1->type == ID($reduce_and) || cell1->type == ID($reduce_or) || cell1->type == ID($reduce_bool)) {
|
||||
conn1[ID(A)].sort_and_unify();
|
||||
conn2[ID(A)].sort_and_unify();
|
||||
} else
|
||||
if (cell1->type == "$pmux") {
|
||||
if (cell1->type == ID($pmux)) {
|
||||
sort_pmux_conn(conn1);
|
||||
sort_pmux_conn(conn2);
|
||||
}
|
||||
|
@ -222,9 +222,9 @@ struct OptMergeWorker
|
|||
return true;
|
||||
}
|
||||
|
||||
if (cell1->type.begins_with("$") && conn1.count("\\Q") != 0) {
|
||||
std::vector<RTLIL::SigBit> q1 = dff_init_map(cell1->getPort("\\Q")).to_sigbit_vector();
|
||||
std::vector<RTLIL::SigBit> q2 = dff_init_map(cell2->getPort("\\Q")).to_sigbit_vector();
|
||||
if (cell1->type.begins_with("$") && conn1.count(ID(Q)) != 0) {
|
||||
std::vector<RTLIL::SigBit> q1 = dff_init_map(cell1->getPort(ID(Q))).to_sigbit_vector();
|
||||
std::vector<RTLIL::SigBit> q2 = dff_init_map(cell2->getPort(ID(Q))).to_sigbit_vector();
|
||||
for (size_t i = 0; i < q1.size(); i++)
|
||||
if ((q1.at(i).wire == NULL || q2.at(i).wire == NULL) && q1.at(i) != q2.at(i)) {
|
||||
lt = q1.at(i) < q2.at(i);
|
||||
|
@ -271,24 +271,24 @@ struct OptMergeWorker
|
|||
ct.setup_stdcells_mem();
|
||||
|
||||
if (mode_nomux) {
|
||||
ct.cell_types.erase("$mux");
|
||||
ct.cell_types.erase("$pmux");
|
||||
ct.cell_types.erase(ID($mux));
|
||||
ct.cell_types.erase(ID($pmux));
|
||||
}
|
||||
|
||||
ct.cell_types.erase("$tribuf");
|
||||
ct.cell_types.erase("$_TBUF_");
|
||||
ct.cell_types.erase("$anyseq");
|
||||
ct.cell_types.erase("$anyconst");
|
||||
ct.cell_types.erase("$allseq");
|
||||
ct.cell_types.erase("$allconst");
|
||||
ct.cell_types.erase(ID($tribuf));
|
||||
ct.cell_types.erase(ID($_TBUF_));
|
||||
ct.cell_types.erase(ID($anyseq));
|
||||
ct.cell_types.erase(ID($anyconst));
|
||||
ct.cell_types.erase(ID($allseq));
|
||||
ct.cell_types.erase(ID($allconst));
|
||||
|
||||
log("Finding identical cells in module `%s'.\n", module->name.c_str());
|
||||
assign_map.set(module);
|
||||
|
||||
dff_init_map.set(module);
|
||||
for (auto &it : module->wires_)
|
||||
if (it.second->attributes.count("\\init") != 0) {
|
||||
Const initval = it.second->attributes.at("\\init");
|
||||
if (it.second->attributes.count(ID(init)) != 0) {
|
||||
Const initval = it.second->attributes.at(ID(init));
|
||||
for (int i = 0; i < GetSize(initval) && i < GetSize(it.second); i++)
|
||||
if (initval[i] == State::S0 || initval[i] == State::S1)
|
||||
dff_init_map.add(SigBit(it.second, i), initval[i]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue