@@ -2621,8 +2621,8 @@ Net* dbNetwork::mergedInto(Net*)
26212621
26222622bool dbNetwork::isSpecial (Net* net)
26232623{
2624- dbNet* db_net = staToDb (net);
2625- return db_net->isSpecial ();
2624+ dbNet* db_net = getOrFindFlatDbNet (net);
2625+ return ( db_net && db_net ->isSpecial () );
26262626}
26272627
26282628// //////////////////////////////////////////////////////////////
@@ -3717,15 +3717,15 @@ void dbNetwork::hierarchicalConnect(dbITerm* source_pin,
37173717 for (auto module_to_clean_up : source_parent_tree) {
37183718 dbModInst* mi = module_to_clean_up->getModInst ();
37193719 if (mi) {
3720- mi->RemoveUnusedPortsAndPins ();
3720+ mi->removeUnusedPortsAndPins ();
37213721 cleaned_up.insert (mi);
37223722 }
37233723 }
37243724 for (auto module_to_clean_up : dest_parent_tree) {
37253725 dbModInst* mi = module_to_clean_up->getModInst ();
37263726 if (mi) {
37273727 if (cleaned_up.find (mi) == cleaned_up.end ()) {
3728- mi->RemoveUnusedPortsAndPins ();
3728+ mi->removeUnusedPortsAndPins ();
37293729 cleaned_up.insert (mi);
37303730 }
37313731 }
@@ -3736,7 +3736,7 @@ void dbNetwork::hierarchicalConnect(dbITerm* source_pin,
37363736void dbNetwork::removeUnusedPortsAndPinsOnModuleInstances ()
37373737{
37383738 for (auto mi : block ()->getModInsts ()) {
3739- mi->RemoveUnusedPortsAndPins ();
3739+ mi->removeUnusedPortsAndPins ();
37403740 }
37413741}
37423742
@@ -4228,19 +4228,60 @@ void dbNetwork::checkAxioms()
42284228 checkSanityNetNames ();
42294229}
42304230
4231- Net* dbNetwork::getFlatNet (Net* net) const
4231+ // Given a net that may be hierarchical, find the corresponding flat net.
4232+ // If the net is already a flat net, it is returned as is.
4233+ // If the net is a hierarchical net (dbModNet), find the associated dbNet and
4234+ // return it as Net*.
4235+ Net* dbNetwork::getOrFindFlatNet (const Net* net) const
4236+ {
4237+ return dbToSta (getOrFindFlatDbNet (net));
4238+ }
4239+
4240+ // Given a net that may be hierarchical, find the corresponding flat dbNet.
4241+ // If the net is already a flat net (dbNet), it is returned as is.
4242+ // If the net is a hierarchical net (dbModNet), find the associated dbNet.
4243+ dbNet* dbNetwork::getOrFindFlatDbNet (const Net* net) const
42324244{
42334245 if (!net) {
42344246 return nullptr ;
42354247 }
42364248 // Convert net to a flat net, if not already
4237- dbNet* db_net;
4238- dbModNet* db_mod_net;
4249+ dbNet* db_net = nullptr ;
4250+ dbModNet* db_mod_net = nullptr ;
42394251 staToDb (net, db_net, db_mod_net);
4252+
4253+ if (db_net) {
4254+ // If it's already a flat net, return it
4255+ return db_net;
4256+ }
4257+
42404258 if (db_mod_net) {
4259+ // If it's a hierarchical net, find the associated dbNet
4260+ // by traversing the hierarchy.
42414261 db_net = findRelatedDbNet (db_mod_net);
42424262 }
4243- return dbToSta (db_net);
4263+ return db_net;
4264+ }
4265+
4266+ // Find the flat net connected to the pin.
4267+ // This function handles both internal instance pins and top-level port pins.
4268+ Net* dbNetwork::getOrFindFlatNet (const Pin* pin) const
4269+ {
4270+ return dbToSta (getOrFindFlatDbNet (pin));
4271+ }
4272+
4273+ // Find the flat net (dbNet) connected to the pin in the OpenDB database.
4274+ // This function handles both internal instance pins and top-level port pins.
4275+ dbNet* dbNetwork::getOrFindFlatDbNet (const Pin* pin) const
4276+ {
4277+ dbNet* db_net = nullptr ;
4278+ if (isTopLevelPort (pin)) {
4279+ Net* net = this ->net (term (pin));
4280+ db_net = flatNet (net);
4281+ } else {
4282+ db_net = flatNet (pin);
4283+ }
4284+ return db_net;
42444285}
42454286
42464287dbModInst* dbNetwork::getModInst (Instance* inst) const
@@ -4255,6 +4296,24 @@ dbModInst* dbNetwork::getModInst(Instance* inst) const
42554296 return db_mod_inst;
42564297}
42574298
4299+ bool dbNetwork::hasPort (const Net* net) const
4300+ {
4301+ if (!net) {
4302+ return false ;
4303+ }
4304+
4305+ dbNet* db_net = nullptr ;
4306+ dbModNet* db_mod_net = nullptr ;
4307+ staToDb (net, db_net, db_mod_net);
4308+ if (db_net) {
4309+ return !db_net->getBTerms ().empty ();
4310+ }
4311+ if (db_mod_net) {
4312+ return !db_mod_net->getBTerms ().empty ();
4313+ }
4314+ return false ;
4315+ }
4316+
42584317void dbNetwork::checkSanityModBTerms ()
42594318{
42604319 if (block_ == nullptr ) {
0 commit comments