@@ -1132,6 +1132,12 @@ bool dbNetwork::isLeaf(const Instance* instance) const
11321132Instance* dbNetwork::findInstance (const char * path_name) const
11331133{
11341134 if (hierarchy_) { // are we in hierarchical mode ?
1135+ // find a hierarchical module instance first
1136+ dbModInst* mod_inst = block ()->findModInst (path_name);
1137+ if (mod_inst) {
1138+ return dbToSta (mod_inst);
1139+ }
1140+
11351141 std::string path_name_str = path_name;
11361142 // search for the last token in the string, which is the leaf instance name
11371143 size_t last_idx = path_name_str.find_last_of (' /' );
@@ -3745,13 +3751,6 @@ bool PinConnections::connected(const Pin* pin) const
37453751 return pins_.find (pin) != pins_.end ();
37463752}
37473753
3748- bool dbNetwork::connected (Pin* source_pin, Pin* dest_pin)
3749- {
3750- PinConnections visitor;
3751- network_->visitConnectedPins (source_pin, visitor);
3752- return visitor.connected (dest_pin);
3753- }
3754-
37553754void dbNetwork::removeUnusedPortsAndPinsOnModuleInstances ()
37563755{
37573756 for (dbModInst* mi : block ()->getModInsts ()) {
@@ -3777,6 +3776,45 @@ class DbNetConnectedToBTerm : public PinVisitor
37773776 dbBTerm* bterm_{nullptr };
37783777};
37793778
3779+ bool dbNetwork::isConnected (const Pin* source_pin, const Pin* dest_pin) const
3780+ {
3781+ PinConnections visitor;
3782+ network_->visitConnectedPins (source_pin, visitor);
3783+ return visitor.connected (dest_pin);
3784+ }
3785+
3786+ bool dbNetwork::isConnected (const Net* net, const Pin* pin) const
3787+ {
3788+ dbNet* dbnet;
3789+ dbModNet* modnet;
3790+ staToDb (net, dbnet, modnet);
3791+
3792+ dbNet* pin_dbnet = findFlatDbNet (pin);
3793+ if (dbnet != nullptr ) {
3794+ return dbnet->isConnected (pin_dbnet);
3795+ }
3796+ if (modnet != nullptr ) {
3797+ return modnet->isConnected (pin_dbnet);
3798+ }
3799+
3800+ return false ;
3801+ }
3802+
3803+ bool dbNetwork::isConnected (const Net* net1, const Net* net2) const
3804+ {
3805+ if (net1 == net2) {
3806+ return true ;
3807+ }
3808+
3809+ dbNet* flat_net1 = findFlatDbNet (net1);
3810+ dbNet* flat_net2 = findFlatDbNet (net2);
3811+ if (flat_net1 != nullptr && flat_net1 == flat_net2) {
3812+ return true ;
3813+ }
3814+
3815+ return false ;
3816+ }
3817+
37803818void DbNetConnectedToBTerm::operator ()(const Pin* pin)
37813819{
37823820 dbITerm* iterm;
@@ -4293,14 +4331,13 @@ Net* dbNetwork::findFlatNet(const Pin* pin) const
42934331// This function handles both internal instance pins and top-level port pins.
42944332dbNet* dbNetwork::findFlatDbNet (const Pin* pin) const
42954333{
4296- dbNet* db_net = nullptr ;
4334+ Net* sta_net = nullptr ;
42974335 if (isTopLevelPort (pin)) {
4298- Net* net = this ->net (term (pin));
4299- db_net = flatNet (net);
4336+ sta_net = net (term (pin));
43004337 } else {
4301- db_net = flatNet (pin);
4338+ sta_net = net (pin);
43024339 }
4303- return db_net ;
4340+ return findFlatDbNet (sta_net) ;
43044341}
43054342
43064343dbModInst* dbNetwork::getModInst (Instance* inst) const
0 commit comments