3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-08-22 19:17:55 +00:00

Refactor call to sorted_pmux_in to avoid copying the connection dictionary

This commit is contained in:
Robert O'Callahan 2025-08-19 05:41:08 +00:00
parent 025d7a5641
commit 7d0ea0d64f

View file

@ -44,11 +44,8 @@ struct OptMergeWorker
CellTypes ct; CellTypes ct;
int total_count; int total_count;
static vector<pair<SigBit, SigSpec>> sorted_pmux_in(const dict<RTLIL::IdString, RTLIL::SigSpec> &conn) static vector<pair<SigBit, SigSpec>> sorted_pmux_in(const SigSpec& sig_s, const SigSpec& sig_b)
{ {
SigSpec sig_s = conn.at(ID::S);
SigSpec sig_b = conn.at(ID::B);
int s_width = GetSize(sig_s); int s_width = GetSize(sig_s);
int width = GetSize(sig_b) / s_width; int width = GetSize(sig_b) / s_width;
@ -104,11 +101,9 @@ struct OptMergeWorker
a.sort_and_unify(); a.sort_and_unify();
h = a.hash_into(h); h = a.hash_into(h);
} else if (cell->type == ID($pmux)) { } else if (cell->type == ID($pmux)) {
dict<RTLIL::IdString, RTLIL::SigSpec> conn = cell->connections(); SigSpec sig_s = assign_map(cell->getPort(ID::S));
assign_map.apply(conn.at(ID::A)); SigSpec sig_b = assign_map(cell->getPort(ID::B));
assign_map.apply(conn.at(ID::B)); for (const auto& [s_bit, b_chunk] : sorted_pmux_in(sig_s, sig_b)) {
assign_map.apply(conn.at(ID::S));
for (const auto& [s_bit, b_chunk] : sorted_pmux_in(conn)) {
h = s_bit.hash_into(h); h = s_bit.hash_into(h);
h = b_chunk.hash_into(h); h = b_chunk.hash_into(h);
} }