Skip to content

Commit

Permalink
Simplification of RemoveUnusedPortsAndPins
Browse files Browse the repository at this point in the history
Signed-off-by: andyfox-rushc <[email protected]>
  • Loading branch information
andyfox-rushc committed Jan 21, 2025
1 parent b7be22d commit 246aa4a
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/odb/src/db/dbModInst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ void dbModInst::RemoveUnusedPortsAndPins()
dbModule* module = this->getMaster();
dbSet<dbModITerm> moditerms = getModITerms();
dbSet<dbModBTerm> modbterms = module->getModBTerms();
bool in_scope_of_bus = false;
int bus_ix = 0;

// traverse in modbterm order so we can skip over
Expand All @@ -379,20 +378,21 @@ void dbModInst::RemoveUnusedPortsAndPins()
dbModNet* mod_net = nullptr;

// Avoid removing unused ports from a bus
if (in_scope_of_bus) {
bus_ix = bus_ix - 1;
if (bus_ix == 0) {
in_scope_of_bus = false;
} else {
continue;
}
}
// when we hit a bus port, we count down from the size
// skipping the bus elements
// Layout:
// mod_bterm (head_element describing size)
// mod_bterm[size-1],...mod_bterm[0] -- bus elements
//
if (mod_bterm->isBusPort()) {
in_scope_of_bus = true;
dbBusPort* bus_port = mod_bterm->getBusPort();
bus_ix = bus_port->getSize(); // count down
continue;
}
if (bus_ix != 0) {
bus_ix = bus_ix - 1;
continue;
}

dbModITerm* mod_iterm = mod_bterm->getParentModITerm();
mod_net = mod_bterm->getModNet();
Expand All @@ -402,9 +402,7 @@ void dbModInst::RemoveUnusedPortsAndPins()
dbSet<dbITerm> dest_iterms = mod_net->getITerms();
if (dest_mod_iterms.size() == 0 && dest_bterms.size() == 0
&& dest_iterms.size() == 0) {
if (!in_scope_of_bus) {
kill_set.insert(mod_iterm);
}
kill_set.insert(mod_iterm);
}
}
}
Expand Down

0 comments on commit 246aa4a

Please sign in to comment.