Skip to content

Commit 478703b

Browse files
committed
Optimized with a new dbNet::isInternalTo() API
Signed-off-by: Jaehyun Kim <[email protected]>
1 parent 796d725 commit 478703b

File tree

3 files changed

+36
-15
lines changed

3 files changed

+36
-15
lines changed

src/odb/include/odb/db.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2504,6 +2504,13 @@ class dbNet : public dbObject
25042504
///
25052505
void renameWithModNetInHighestHier();
25062506

2507+
///
2508+
/// Check if this net is internal to the given module.
2509+
/// A net is internal if all its iterms belong to instances within the module
2510+
/// and it has no bterms.
2511+
///
2512+
bool isInternalTo(dbModule* module) const;
2513+
25072514
///
25082515
/// Check issues such as multiple drivers, no driver, or dangling net
25092516
///

src/odb/src/db/dbModule.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -878,23 +878,20 @@ void _dbModule::copyModuleInsts(dbModule* old_module,
878878
// net_name = u0/_001_ <-- External net crossing module
879879
// boundary.
880880
std::string old_net_name = old_net->getName();
881-
if (old_module->getModInst() != nullptr) {
882-
std::string modinst_name = old_module->getHierarchicalName();
883-
if (old_net_name.compare(0, modinst_name.length(), modinst_name) != 0) {
884-
// Skip external net crossing module boundary.
885-
// It will be connected later.
886-
debugPrint(logger,
887-
utl::ODB,
888-
"replace_design",
889-
3,
890-
"Skip: dbNet '{}'. Hierarchy_prefix='{}'\n",
891-
old_net_name,
892-
modinst_name);
893-
continue;
894-
}
881+
if (old_net->isInternalTo(old_module) == false) {
882+
// Skip external net crossing module boundary.
883+
// It will be connected later.
884+
debugPrint(logger,
885+
utl::ODB,
886+
"replace_design",
887+
3,
888+
" Skip: non-internal dbNet '{}' of old_module '{}'.\n",
889+
old_net_name,
890+
old_module->getHierarchicalName());
891+
continue;
895892
}
896-
new_net_name += block->getBaseName(old_net_name.c_str());
897893

894+
new_net_name += block->getBaseName(old_net_name.c_str());
898895
auto it = new_net_name_map.find(new_net_name);
899896
if (it != new_net_name_map.end()) {
900897
// Connect to an existing local net

src/odb/src/db/dbNet.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2599,4 +2599,21 @@ void dbNet::renameWithModNetInHighestHier()
25992599
}
26002600
}
26012601

2602+
bool dbNet::isInternalTo(dbModule* module) const
2603+
{
2604+
// If it's connected to any top-level ports (BTerms), it's not internal.
2605+
if (!getBTerms().empty()) {
2606+
return false;
2607+
}
2608+
2609+
// Check all instance terminals (ITerms) it's connected to.
2610+
for (dbITerm* iterm : getITerms()) {
2611+
if (iterm->getInst()->getModule() != module) {
2612+
return false;
2613+
}
2614+
}
2615+
2616+
return true;
2617+
}
2618+
26022619
} // namespace odb

0 commit comments

Comments
 (0)