From 73f3aafdd66b79cc3c0630623c45e494f99d31e4 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Sat, 14 Mar 2026 17:17:46 +0900 Subject: [PATCH 01/11] odb: fix makeNewNetName to check ModNet/ModBTerm name collision makeNewNetName() only checked flat net uniqueness via findNet(), missing ModNet and ModBTerm names in the target module scope. When SplitLoadMove called insertBufferBeforeLoads with nullptr net base name (defaulting to "net") and IF_NEEDED uniquify, a new flat net "sub0/net" could collide with an existing ModBTerm/ModNet "net" in the submodule, producing duplicate wire declarations in emitted Verilog. This caused the sky130hd/microwatt CTS LEC failure. Fix: extend the exists lambda in makeNewNetName() to also check ModNet and ModBTerm names in the parent module scope, matching the behavior already present in makeNewModNetName(). Add checkSanityNameCollision() to both dbNet and dbModNet so that individual net objects can detect name collisions during sanity checks. The check uses findRelatedModNets() for hierarchy traversal and cross-checks via findRelatedNet() to avoid false positives on associated nets that legitimately share names. Add TestInsertBuffer::BeforeLoads_Case34 to reproduce and verify the fix using a hierarchical design with a submodule port named "net". Signed-off-by: Jaehyun Kim --- src/odb/include/odb/db.h | 12 +++ src/odb/src/db/dbBlock.cpp | 15 ++- src/odb/src/db/dbModNet.cpp | 59 ++++++++++++ src/odb/src/db/dbNet.cpp | 67 ++++++++++++++ src/rsz/test/cpp/TestInsertBuffer.cpp | 92 +++++++++++++++++++ ...TestInsertBuffer_BeforeLoads_Case34_post.v | 38 ++++++++ .../TestInsertBuffer_BeforeLoads_Case34_pre.v | 45 +++++++++ 7 files changed, 327 insertions(+), 1 deletion(-) create mode 100644 src/rsz/test/cpp/TestInsertBuffer_BeforeLoads_Case34_post.v create mode 100644 src/rsz/test/cpp/TestInsertBuffer_BeforeLoads_Case34_pre.v diff --git a/src/odb/include/odb/db.h b/src/odb/include/odb/db.h index 0fe5242fe99..173c6fc39c7 100644 --- a/src/odb/include/odb/db.h +++ b/src/odb/include/odb/db.h @@ -2588,6 +2588,12 @@ class dbNet : public dbObject // void checkSanityModNetConsistency() const; + /// + /// Check if this flat net's base name collides with a ModNet or ModBTerm + /// in its parent module scope without being associated with it. + /// + void checkSanityNameCollision() const; + /// /// Dump dbNet connectivity for debugging /// @@ -8613,6 +8619,12 @@ class dbModNet : public dbObject dbNet* findRelatedNet() const; void checkSanity() const; + /// + /// Check if any flat net in this module scope has a base name matching + /// this ModNet's name without being associated with it. + /// + void checkSanityNameCollision() const; + /// /// Merge the terminals of the in_modnet with this modnet /// diff --git a/src/odb/src/db/dbBlock.cpp b/src/odb/src/db/dbBlock.cpp index 61d06136e49..4354a92b986 100644 --- a/src/odb/src/db/dbBlock.cpp +++ b/src/odb/src/db/dbBlock.cpp @@ -3931,7 +3931,20 @@ std::string dbBlock::makeNewNetName(dbModInst* parent, const dbNameUniquifyType& uniquify) { _dbBlock* block = reinterpret_cast<_dbBlock*>(this); - auto exists = [this](const char* name) { return findNet(name) != nullptr; }; + + auto exists = [this, parent](const char* name) { + if (findNet(name) != nullptr) { + return true; + } + + dbModule* scope = parent ? parent->getMaster() : getTopModule(); + if (scope == nullptr) { + return false; + } + const char* base = getBaseName(name); + return scope->getModNet(base) || scope->findModBTerm(base); + }; + return block->makeNewName( parent, base_name, uniquify, block->unique_net_index_, exists); } diff --git a/src/odb/src/db/dbModNet.cpp b/src/odb/src/db/dbModNet.cpp index ac6199461dc..da796c7d2e8 100644 --- a/src/odb/src/db/dbModNet.cpp +++ b/src/odb/src/db/dbModNet.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include "boost/container/small_vector.hpp" @@ -559,6 +560,64 @@ void dbModNet::checkSanity() const dbUtil::findModITermDrivers(this, drvr_info_list); dbUtil::checkNetSanity(this, drvr_info_list); + + // Check name collision with flat nets + checkSanityNameCollision(); +} + +void dbModNet::checkSanityNameCollision() const +{ + dbModule* module = getParent(); + dbBlock* block = module->getOwner(); + const char* name = getConstName(); + + // Check if any flat net in this module scope has a base name + // matching this ModNet's name without being associated. + std::set checked; + for (dbInst* inst : module->getInsts()) { + for (dbITerm* iterm : inst->getITerms()) { + dbNet* net = iterm->getNet(); + if (net == nullptr || !checked.insert(net).second) { + continue; + } + // Only check flat nets whose scope is this module + if (net->findMainParentModule() != module) { + continue; + } + const char* base_name = block->getBaseName(net->getConstName()); + if (std::string_view{base_name} != name) { + continue; + } + // Check if this flat net is associated with this ModNet + // by traversing the hierarchy. + std::set related_modnets; + net->findRelatedModNets(related_modnets); + bool associated = false; + for (dbModNet* mn : related_modnets) { + if (mn == this) { + associated = true; + break; + } + } + if (!associated) { + // Cross-check: if this ModNet's findRelatedNet returns + // the same flat net or nullptr, they're the same signal. + dbNet* my_related = findRelatedNet(); + if (my_related == nullptr || my_related == net) { + continue; + } + utl::Logger* logger = getImpl()->getLogger(); + logger->error(utl::ODB, + 494, + "SanityCheck: ModNet '{}' in module '{}' has a name " + "collision with flat net '{}'.", + getHierarchicalName(), + module->getName(), + net->getConstName()); + return; + } + } + } } void dbModNet::mergeModNet(dbModNet* in_modnet) diff --git a/src/odb/src/db/dbNet.cpp b/src/odb/src/db/dbNet.cpp index c0248da67e9..e8388385104 100644 --- a/src/odb/src/db/dbNet.cpp +++ b/src/odb/src/db/dbNet.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -2453,6 +2454,9 @@ void dbNet::checkSanity() const // Check the consistency with the related dbModNet checkSanityModNetConsistency(); + + // Check name collision with ModNet/ModBTerm + checkSanityNameCollision(); } dbModInst* dbNet::findMainParentModInst() const @@ -2760,6 +2764,69 @@ void dbNet::checkSanityModNetConsistency() const } } +void dbNet::checkSanityNameCollision() const +{ + dbBlock* block = getBlock(); + if (!block->getDb()->hasHierarchy()) { + return; + } + + dbModule* module = findMainParentModule(); + const char* base_name = block->getBaseName(getConstName()); + + // Check if base name collides with a ModNet or ModBTerm in this module + bool collides = module->getModNet(base_name) != nullptr + || module->findModBTerm(base_name) != nullptr; + if (!collides) { + return; + } + + // Check if this flat net is associated with the colliding ModNet + // by traversing the hierarchy. If any related ModNet has the same + // name in the same module, it's the same logical signal. + std::set related_modnets; + findRelatedModNets(related_modnets); + for (dbModNet* mn : related_modnets) { + if (mn->getParent() == module + && std::string_view{mn->getConstName()} == base_name) { + return; + } + } + + // Cross-check from the ModNet side: if the matching ModNet's related + // flat net is this net or nullptr (unresolvable), they're the same signal. + // Only flag when it positively resolves to a DIFFERENT flat net. + dbModNet* matching_modnet = module->getModNet(base_name); + if (matching_modnet) { + dbNet* other = matching_modnet->findRelatedNet(); + if (other == nullptr || other == this) { + return; + } + } else { + // Only ModBTerm matches — check its ModNet + dbModBTerm* matching_modbterm = module->findModBTerm(base_name); + if (matching_modbterm) { + dbModNet* bt_modnet = matching_modbterm->getModNet(); + if (bt_modnet == nullptr) { + return; + } + dbNet* other = bt_modnet->findRelatedNet(); + if (other == nullptr || other == this) { + return; + } + } + } + + utl::Logger* logger = getImpl()->getLogger(); + logger->error(utl::ODB, + 493, + "SanityCheck: Flat net '{}' (base '{}') has a name collision " + "with ModNet/ModBTerm in module '{}'.", + getConstName(), + base_name, + module->getName()); +} + void dbNet::dumpConnectivity(int level) const { utl::Logger* logger = getImpl()->getLogger(); diff --git a/src/rsz/test/cpp/TestInsertBuffer.cpp b/src/rsz/test/cpp/TestInsertBuffer.cpp index 24f46fea104..30c3771b7dc 100644 --- a/src/rsz/test/cpp/TestInsertBuffer.cpp +++ b/src/rsz/test/cpp/TestInsertBuffer.cpp @@ -3269,4 +3269,96 @@ TEST_F(TestInsertBuffer, BeforeLoads_Case33) writeAndCompareVerilogOutputFile(test_name, test_name + "_post.v"); } +// Bug reproduction: makeNewNetName only checks flat net uniqueness, not +// ModNet or ModBTerm names. In a hierarchical design, a submodule port +// named "net" creates a ModBTerm/ModNet "net" in the module. The +// corresponding flat net has a different hierarchical name (from the +// parent's connection). insertBufferBeforeLoads with IF_NEEDED uniquify +// creates flat net "sub0/net" whose base name "net" collides with the +// existing ModBTerm/ModNet "net", producing invalid emitted Verilog. +// +// Root cause from sky130hd/microwatt CTS LEC failure: +// SplitLoadMove calls insertBufferBeforeLoads with nullptr net base name +// and IF_NEEDED uniquify. createNewFlatNet defaults to "net" base name. +// makeNewNetName(parent, "net", IF_NEEDED) only checks findNet(), missing +// the existing ModNet/ModBTerm "net" in the target module. +TEST_F(TestInsertBuffer, BeforeLoads_Case34) +{ + const auto* test_info = testing::UnitTest::GetInstance()->current_test_info(); + const std::string test_name + = std::string(test_info->test_suite_name()) + "_" + test_info->name(); + + int num_warning = 0; + readVerilogAndSetup(test_name + "_pre.v"); + + dbMaster* buf_x4_master = db_->findMaster("BUF_X4"); + ASSERT_NE(buf_x4_master, nullptr); + + // Verify initial state: module SUB has ModBTerm "net" (output port) + dbModule* sub_mod = block_->findModule("SUB"); + ASSERT_NE(sub_mod, nullptr); + EXPECT_NE(sub_mod->findModBTerm("net"), nullptr) + << "SUB should have ModBTerm 'net' (output port)"; + EXPECT_NE(sub_mod->getModNet("net"), nullptr) + << "SUB should have ModNet 'net' (port connection)"; + + // The flat net for the "net" port comes from the parent's connection, + // so there is no flat net named "sub0/net". This naturally occurs in + // hierarchical designs where the flat net name is determined by the + // parent module's wire name, not the child module's port name. + EXPECT_EQ(block_->findNet("sub0/net"), nullptr) + << "No flat net named 'sub0/net' should exist; the port's flat net " + "has the parent's wire name"; + + // Pre sanity check + sta_->updateTiming(true); + num_warning = db_network_->checkAxioms(); + num_warning += sta_->checkSanity(); + EXPECT_EQ(num_warning, 0); + + // Find the flat net that drives the "net" port in SUB + dbITerm* drv_z = block_->findITerm("sub0/drv/Z"); + ASSERT_NE(drv_z, nullptr); + dbNet* orig_net = drv_z->getNet(); + ASSERT_NE(orig_net, nullptr); + + // Insert buffer before load2 (reproduces SplitLoadMove code path: + // new_buf_base_name="split", new_net_base_name=nullptr, IF_NEEDED) + dbITerm* load2_a = block_->findITerm("sub0/load2/A"); + ASSERT_NE(load2_a, nullptr); + + std::set load_pins; + load_pins.insert(load2_a); + + dbInst* new_buf = orig_net->insertBufferBeforeLoads( + load_pins, + buf_x4_master, + nullptr, + "split", + nullptr, + dbNameUniquifyType::IF_NEEDED, + false); + ASSERT_NE(new_buf, nullptr); + + // Post sanity check - detects flat net / ModNet name collision + num_warning = db_network_->checkAxioms(); + num_warning += sta_->checkSanity(); + EXPECT_EQ(num_warning, 0); + + // Key assertion: the buffer output net must NOT have base name "net" + // because the module already has a ModBTerm/ModNet "net". + // Without the fix, makeNewNetName only checks flat nets, creating + // a flat net "sub0/net" that collides with the existing ModBTerm "net" + // → duplicate "wire net;" in emitted Verilog. + dbNet* buf_out_net = new_buf->findITerm("Z")->getNet(); + ASSERT_NE(buf_out_net, nullptr); + EXPECT_STRNE(block_->getBaseName(buf_out_net->getConstName()), "net") + << "New flat net base name must not collide with existing ModBTerm " + "'net'. Without the fix, makeNewNetName misses ModNet/ModBTerm " + "checks, causing duplicate wire declarations in emitted Verilog."; + + // Write verilog and compare + writeAndCompareVerilogOutputFile(test_name, test_name + "_post.v"); +} + } // namespace odb diff --git a/src/rsz/test/cpp/TestInsertBuffer_BeforeLoads_Case34_post.v b/src/rsz/test/cpp/TestInsertBuffer_BeforeLoads_Case34_post.v new file mode 100644 index 00000000000..5ba30d5b613 --- /dev/null +++ b/src/rsz/test/cpp/TestInsertBuffer_BeforeLoads_Case34_post.v @@ -0,0 +1,38 @@ +module top (in, + out1, + out2, + out_net); + input in; + output out1; + output out2; + output out_net; + + wire n_internal; + + BUF_X1 extra (.A(n_internal), + .Z(out_net)); + SUB sub0 (.A(in), + .net(n_internal), + .Z1(out1), + .Z2(out2)); +endmodule +module SUB (A, + net, + Z1, + Z2); + input A; + output net; + output Z1; + output Z2; + + wire net1; + + BUF_X1 drv (.A(A), + .Z(net)); + BUF_X1 load1 (.A(net), + .Z(Z1)); + BUF_X1 load2 (.A(net1), + .Z(Z2)); + BUF_X4 split (.A(net), + .Z(net1)); +endmodule diff --git a/src/rsz/test/cpp/TestInsertBuffer_BeforeLoads_Case34_pre.v b/src/rsz/test/cpp/TestInsertBuffer_BeforeLoads_Case34_pre.v new file mode 100644 index 00000000000..e23e2fa3b99 --- /dev/null +++ b/src/rsz/test/cpp/TestInsertBuffer_BeforeLoads_Case34_pre.v @@ -0,0 +1,45 @@ +// Bug reproduction: makeNewNetName does not check ModNet/ModBTerm names +// when creating a new flat net. In hierarchical designs, a module port +// named "net" creates a ModBTerm "net", but the corresponding flat net +// has a different hierarchical name. insertBufferBeforeLoads with +// IF_NEEDED uniquify creates flat net "sub0/net" that collides with +// the existing ModBTerm "net", producing duplicate "wire net;" in the +// emitted Verilog. +// +// This reproduces the sky130hd/microwatt CTS LEC failure: +// [critical] wire collision for net net +module top (in, + out_net, + out1, + out2); + input in; + output out_net; + output out1; + output out2; + + wire n_internal; + + SUB sub0 (.A(in), + .net(n_internal), + .Z1(out1), + .Z2(out2)); + BUF_X1 extra (.A(n_internal), + .Z(out_net)); +endmodule +module SUB (A, + net, + Z1, + Z2); + input A; + output net; + output Z1; + output Z2; + + + BUF_X1 drv (.A(A), + .Z(net)); + BUF_X1 load1 (.A(net), + .Z(Z1)); + BUF_X1 load2 (.A(net), + .Z(Z2)); +endmodule From 4a23e358f28c76511e2f3261e4b4dfcfea0c26d4 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Sat, 14 Mar 2026 17:58:28 +0900 Subject: [PATCH 02/11] Refactor trace port creation in dbInsertBuffer Signed-off-by: Jaehyun Kim --- src/odb/src/db/dbInsertBuffer.cpp | 86 +++++++++++++++++++++---------- src/odb/src/db/dbInsertBuffer.h | 4 ++ 2 files changed, 64 insertions(+), 26 deletions(-) diff --git a/src/odb/src/db/dbInsertBuffer.cpp b/src/odb/src/db/dbInsertBuffer.cpp index 02913a70deb..9be158b8485 100644 --- a/src/odb/src/db/dbInsertBuffer.cpp +++ b/src/odb/src/db/dbInsertBuffer.cpp @@ -515,6 +515,7 @@ std::string dbInsertBuffer::makeUniqueHierName(const dbModule* module, const char* suffix) const { std::string name = (suffix == nullptr) ? base_name : base_name + suffix; + dbModInst* mod_inst = module->getModInst(); const char hier_delim = block_->getHierarchyDelimiter(); const std::string hier_prefix = module->isTop() ? "" : (module->getHierarchicalName() + hier_delim); @@ -526,12 +527,19 @@ std::string dbInsertBuffer::makeUniqueHierName(const dbModule* module, return net != nullptr && net->isInternalTo(const_cast(module)); }; - // Ensure uniqueness against ModNets, ModBTerms, and internal dbNets + auto hasParentModITerm = [&](const std::string& candidate_name) { + return mod_inst != nullptr + && mod_inst->findModITerm(candidate_name.c_str()) != nullptr; + }; + + // Ensure uniqueness against ModNets, ModBTerms, internal dbNets, + // and the matching parent ModITerm namespace. int id = 0; std::string unique_name = name; while (module->getModNet(unique_name.c_str()) || module->findModBTerm(unique_name.c_str()) - || hasInternalDbNet(unique_name)) { + || hasInternalDbNet(unique_name) + || hasParentModITerm(unique_name)) { unique_name = fmt::format("{}_{}", name, id++); } @@ -1216,6 +1224,54 @@ void dbInsertBuffer::connectPeerITerms(dbModule* mod, } } +dbModBTerm* dbInsertBuffer::findOrCreateTracePort(dbModule* current_mod, + dbModNet* mod_net, + dbIoType io_type, + const char* suffix) +{ + for (dbModBTerm* bterm : mod_net->getModBTerms()) { + if (bterm->getIoType() == io_type) { + return bterm; + } + } + + dbModule* parent_module = mod_net->getParent(); + assert(parent_module == current_mod); + + std::string port_name = mod_net->getName(); + dbModInst* mod_inst = current_mod->getModInst(); + if (parent_module->findModBTerm(port_name.c_str()) != nullptr + || (mod_inst != nullptr + && mod_inst->findModITerm(port_name.c_str()) != nullptr)) { + port_name = makeUniqueHierName(current_mod, port_name, suffix); + } + + assert(parent_module->findModBTerm(port_name.c_str()) == nullptr); + dbModBTerm* port = dbModBTerm::create(parent_module, port_name.c_str()); + assert(port != nullptr); + + port->setIoType(io_type); + port->connect(mod_net); + + if (mod_inst != nullptr) { + dbModITerm* existing_mod_iterm = mod_inst->findModITerm(port_name.c_str()); + if (existing_mod_iterm == nullptr) { + dbModITerm::create(mod_inst, port_name.c_str(), port); + } else if (existing_mod_iterm->getChildModBTerm() != port) { + logger_->error( + utl::ODB, + 1218, + "Parent moditerm '{}' already exists on modinst '{}' and is bound " + "to a different modbterm while creating a trace port for modnet '{}'.", + port_name, + mod_inst->getName(), + mod_net->getName()); + } + } + + return port; +} + dbObject* dbInsertBuffer::traceUp(dbObject* current_obj, dbModule* current_mod, dbModule* target_mod, @@ -1227,30 +1283,8 @@ dbObject* dbInsertBuffer::traceUp(dbObject* current_obj, dbModNet* mod_net = ensureModNet(current_obj, current_mod, corresponding_flat_net); - dbModBTerm* port = nullptr; - for (dbModBTerm* bterm : mod_net->getModBTerms()) { - if (bterm->getIoType() == io_type) { - port = bterm; - break; - } - } - if (!port) { - std::string port_name = mod_net->getName(); - port = dbModBTerm::create(mod_net->getParent(), port_name.c_str()); - - // To avoid dbModBTerm name collision - if (!port) { - std::string unique_port_name - = makeUniqueHierName(current_mod, port_name, suffix); - port = dbModBTerm::create(mod_net->getParent(), - unique_port_name.c_str()); - } - port->setIoType(io_type); - port->connect(mod_net); - if (dbModInst* mod_inst = current_mod->getModInst()) { - dbModITerm::create(mod_inst, port->getName(), port); - } - } + dbModBTerm* port + = findOrCreateTracePort(current_mod, mod_net, io_type, suffix); current_obj = port->getParentModITerm(); current_mod = current_mod->getModInst()->getParent(); diff --git a/src/odb/src/db/dbInsertBuffer.h b/src/odb/src/db/dbInsertBuffer.h index 2406215cb98..9aa839b931c 100644 --- a/src/odb/src/db/dbInsertBuffer.h +++ b/src/odb/src/db/dbInsertBuffer.h @@ -142,6 +142,10 @@ class dbInsertBuffer void connectPeerITerms(dbModule* mod, dbModNet* mod_net, dbNet* corresponding_flat_net); + dbModBTerm* findOrCreateTracePort(dbModule* current_mod, + dbModNet* mod_net, + dbIoType io_type, + const char* suffix); /// /// Trace up the module hierarchy from current_mod to target_mod, From 5c67f15198f8d8bf6bb87ad1e55addb2b158cd2c Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Sat, 14 Mar 2026 18:35:59 +0900 Subject: [PATCH 03/11] odb: consolidate unique net name APIs into unified makeNewNetName MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace makeNewNetName(dbModInst*) and makeNewModNetName(dbModule*) with a single makeNewNetName(dbModule*) that handles both flat net and ModNet creation via a corresponding_flat_net parameter: - nullptr (default): strict mode — any findNet() hit is a collision - non-null: lenient mode — only internal flat nets (excluding the corresponding one) are collisions Delegate makeUniqueHierName (dbInsertBuffer) and makeUniqueName (dbEditHierarchy) to the unified API, eliminating duplicated local while-loop collision checks. Update golden files for suffix numbering changes caused by the switch from local counters to the shared persistent counter. Signed-off-by: Jaehyun Kim --- src/dbSta/src/dbEditHierarchy.cc | 21 ++---- src/dbSta/src/dbNetwork.cc | 4 +- src/odb/include/odb/db.h | 16 ++--- src/odb/src/db/dbBlock.cpp | 71 ++++++++----------- src/odb/src/db/dbInsertBuffer.cpp | 38 ++-------- src/odb/src/db/dbModNet.cpp | 2 +- src/odb/src/db/dbNet.cpp | 4 +- src/rsz/test/cpp/TestInsertBuffer.cpp | 12 +++- ...TestInsertBuffer_BeforeLoads_Case25_post.v | 8 +-- ...TestInsertBuffer_BeforeLoads_Case28_post.v | 8 +-- ...TestInsertBuffer_BeforeLoads_Case30_post.v | 20 +++--- 11 files changed, 82 insertions(+), 122 deletions(-) diff --git a/src/dbSta/src/dbEditHierarchy.cc b/src/dbSta/src/dbEditHierarchy.cc index f4c965dac41..859b5394b2a 100644 --- a/src/dbSta/src/dbEditHierarchy.cc +++ b/src/dbSta/src/dbEditHierarchy.cc @@ -619,21 +619,12 @@ std::string dbEditHierarchy::makeUniqueName(odb::dbModule* module, base_name = name; } - std::string unique_name = base_name; - int id = 0; - - Instance* inst = db_network_->dbToSta(module->getModInst()); - if (inst == nullptr) { - inst = db_network_->topInstance(); - } - - // Check collision with both hierarchical ports and flat & hier nets - while (module->findModBTerm(unique_name.c_str()) - || db_network_->findNet(inst, unique_name.c_str())) { - id++; - unique_name = fmt::format("{}_{}", base_name, id); - } - return unique_name; + odb::dbBlock* block = db_network_->block(); + std::string full = block->makeNewNetName( + module, + base_name.c_str(), + odb::dbNameUniquifyType::IF_NEEDED_WITH_UNDERSCORE); + return std::string(block->getBaseName(full.c_str())); } const char* dbEditHierarchy::getBaseName(const char* connection_name) const diff --git a/src/dbSta/src/dbNetwork.cc b/src/dbSta/src/dbNetwork.cc index d67341f2f2e..af33d3facad 100644 --- a/src/dbSta/src/dbNetwork.cc +++ b/src/dbSta/src/dbNetwork.cc @@ -2903,8 +2903,10 @@ Net* dbNetwork::makeNet(const char* base_name, const odb::dbNameUniquifyType& uniquify) { // Create a unique full name for a new net + odb::dbModInst* mod_inst = getModInst(parent); + odb::dbModule* parent_module = mod_inst ? mod_inst->getMaster() : nullptr; std::string full_name - = block_->makeNewNetName(getModInst(parent), base_name, uniquify); + = block_->makeNewNetName(parent_module, base_name, uniquify); // Create a new net dbNet* dnet = dbNet::create(block_, full_name.c_str(), false); diff --git a/src/odb/include/odb/db.h b/src/odb/include/odb/db.h index 173c6fc39c7..f4249bd3e1c 100644 --- a/src/odb/include/odb/db.h +++ b/src/odb/include/odb/db.h @@ -1308,23 +1308,21 @@ class dbBlock : public dbObject void getWireUpdatedNets(std::vector& nets); /// - /// Make a unique net/instance name + /// Make a unique net name. /// If parent is nullptr, the net name will be unique in top module. /// If base_name is nullptr, the default net name will be used. /// If uniquify is IF_NEEDED*, unique suffix will be added when necessary. /// If uniquify is *_WITH_UNDERSCORE, an underscore will be added before the /// unique suffix. + /// If corresponding_flat_net is nullptr, any findNet() hit is a collision. + /// If corresponding_flat_net is non-null, only internal flat nets excluding + /// the corresponding one are collisions (lenient mode for ModNet creation). /// - std::string makeNewNetName(dbModInst* parent = nullptr, + std::string makeNewNetName(dbModule* parent = nullptr, const char* base_name = "net", const dbNameUniquifyType& uniquify - = dbNameUniquifyType::ALWAYS); - - std::string makeNewModNetName(dbModule* parent, - const char* base_name = "net", - const dbNameUniquifyType& uniquify - = dbNameUniquifyType::ALWAYS, - dbNet* corresponding_flat_net = nullptr); + = dbNameUniquifyType::ALWAYS, + dbNet* corresponding_flat_net = nullptr); std::string makeNewInstName(dbModInst* parent = nullptr, const char* base_name = "inst", const dbNameUniquifyType& uniquify diff --git a/src/odb/src/db/dbBlock.cpp b/src/odb/src/db/dbBlock.cpp index 4354a92b986..c6122485c2b 100644 --- a/src/odb/src/db/dbBlock.cpp +++ b/src/odb/src/db/dbBlock.cpp @@ -3926,48 +3926,38 @@ std::string _dbBlock::makeNewName( // If uniquify is IF_NEEDED, unique suffix will be added when necessary. // This is added to cover the existing multiple use cases of making a // new net name w/ and w/o unique suffix. -std::string dbBlock::makeNewNetName(dbModInst* parent, +// If corresponding_flat_net is nullptr, any findNet() hit is a collision +// (strict mode for flat net creation). +// If corresponding_flat_net is non-null, only internal flat nets excluding +// the corresponding one collide (lenient mode for ModNet creation). +std::string dbBlock::makeNewNetName(dbModule* parent, const char* base_name, - const dbNameUniquifyType& uniquify) + const dbNameUniquifyType& uniquify, + dbNet* corresponding_flat_net) { - _dbBlock* block = reinterpret_cast<_dbBlock*>(this); - - auto exists = [this, parent](const char* name) { - if (findNet(name) != nullptr) { - return true; - } - - dbModule* scope = parent ? parent->getMaster() : getTopModule(); - if (scope == nullptr) { - return false; - } - const char* base = getBaseName(name); - return scope->getModNet(base) || scope->findModBTerm(base); - }; + dbModule* scope = parent ? parent : getTopModule(); + dbModInst* mod_inst = scope ? scope->getModInst() : nullptr; - return block->makeNewName( - parent, base_name, uniquify, block->unique_net_index_, exists); -} - -std::string dbBlock::makeNewModNetName(dbModule* parent, - const char* base_name, - const dbNameUniquifyType& uniquify, - dbNet* corresponding_flat_net) -{ - auto exists = [parent, this, corresponding_flat_net](const char* full_name) { - const char* base_name_ptr = getBaseName(full_name); - if (parent->getModNet(base_name_ptr) - || parent->findModBTerm(base_name_ptr)) { - return true; + auto exists = [this, scope, corresponding_flat_net](const char* name) { + if (scope != nullptr) { + const char* base = getBaseName(name); + if (scope->getModNet(base) || scope->findModBTerm(base)) { + return true; + } } - // Internal flat net collision check (uses full hierarchical name) - // - Allow collision with the corresponding flat net (same logical net) - // - Collision with other internal flat nets is not allowed - dbNet* existing_net = findNet(full_name); - if (existing_net != nullptr && existing_net != corresponding_flat_net) { - if (existing_net->isInternalTo(parent)) { - return true; // Collision with a different internal flat net + // Flat net collision check + dbNet* existing_net = findNet(name); + if (existing_net != nullptr) { + if (corresponding_flat_net == nullptr) { + // Strict mode: any flat net hit is a collision + return true; + } + // Lenient mode: only internal flat nets (excluding the corresponding + // one) are collisions + if (existing_net != corresponding_flat_net + && existing_net->isInternalTo(scope)) { + return true; } } @@ -3975,11 +3965,8 @@ std::string dbBlock::makeNewModNetName(dbModule* parent, }; _dbBlock* block = reinterpret_cast<_dbBlock*>(this); - return block->makeNewName(parent->getModInst(), - base_name, - uniquify, - block->unique_net_index_, - exists); + return block->makeNewName( + mod_inst, base_name, uniquify, block->unique_net_index_, exists); } std::string dbBlock::makeNewInstName(dbModInst* parent, diff --git a/src/odb/src/db/dbInsertBuffer.cpp b/src/odb/src/db/dbInsertBuffer.cpp index 9be158b8485..5698cd4a9f5 100644 --- a/src/odb/src/db/dbInsertBuffer.cpp +++ b/src/odb/src/db/dbInsertBuffer.cpp @@ -468,9 +468,7 @@ dbNet* dbInsertBuffer::createNewFlatNet( // Helper: generate a unique name to avoid collision with the port name. auto make_avoidance_name = [&]() { return block_->makeNewNetName( - target_module_ ? target_module_->getModInst() : nullptr, - new_net_name.c_str(), - dbNameUniquifyType::ALWAYS); + target_module_, new_net_name.c_str(), dbNameUniquifyType::ALWAYS); }; // Rename the original flat net and/or modnet if they have the same name as @@ -515,35 +513,11 @@ std::string dbInsertBuffer::makeUniqueHierName(const dbModule* module, const char* suffix) const { std::string name = (suffix == nullptr) ? base_name : base_name + suffix; - dbModInst* mod_inst = module->getModInst(); - const char hier_delim = block_->getHierarchyDelimiter(); - const std::string hier_prefix - = module->isTop() ? "" : (module->getHierarchicalName() + hier_delim); - - // Helper to check if a dbNet is an internal net of the 'module'. - // Note that the new name must not conflict with any internal flat nets. - auto hasInternalDbNet = [&](const std::string& net_base_name) { - dbNet* net = block_->findNet((hier_prefix + net_base_name).c_str()); - return net != nullptr && net->isInternalTo(const_cast(module)); - }; - - auto hasParentModITerm = [&](const std::string& candidate_name) { - return mod_inst != nullptr - && mod_inst->findModITerm(candidate_name.c_str()) != nullptr; - }; - - // Ensure uniqueness against ModNets, ModBTerms, internal dbNets, - // and the matching parent ModITerm namespace. - int id = 0; - std::string unique_name = name; - while (module->getModNet(unique_name.c_str()) - || module->findModBTerm(unique_name.c_str()) - || hasInternalDbNet(unique_name) - || hasParentModITerm(unique_name)) { - unique_name = fmt::format("{}_{}", name, id++); - } - - return unique_name; + std::string full = block_->makeNewNetName( + const_cast(module), + name.c_str(), + dbNameUniquifyType::IF_NEEDED_WITH_UNDERSCORE); + return std::string(block_->getBaseName(full.c_str())); } int dbInsertBuffer::getModuleDepth(const dbModule* mod) const diff --git a/src/odb/src/db/dbModNet.cpp b/src/odb/src/db/dbModNet.cpp index da796c7d2e8..b51e6434078 100644 --- a/src/odb/src/db/dbModNet.cpp +++ b/src/odb/src/db/dbModNet.cpp @@ -385,7 +385,7 @@ dbModNet* dbModNet::create(dbModule* parent_module, dbNet* corresponding_flat_net) { dbBlock* block = parent_module->getOwner(); - std::string net_name = block->makeNewModNetName( + std::string net_name = block->makeNewNetName( parent_module, base_name, uniquify, corresponding_flat_net); return create(parent_module, block->getBaseName(net_name.c_str())); } diff --git a/src/odb/src/db/dbNet.cpp b/src/odb/src/db/dbNet.cpp index e8388385104..dbc5e5ed719 100644 --- a/src/odb/src/db/dbNet.cpp +++ b/src/odb/src/db/dbNet.cpp @@ -2221,8 +2221,8 @@ dbNet* dbNet::create(dbBlock* block, const dbNameUniquifyType& uniquify, dbModule* parent_module) { - std::string net_name = block->makeNewNetName( - parent_module ? parent_module->getModInst() : nullptr, name, uniquify); + std::string net_name + = block->makeNewNetName(parent_module, name, uniquify); return create(block, net_name.c_str()); } diff --git a/src/rsz/test/cpp/TestInsertBuffer.cpp b/src/rsz/test/cpp/TestInsertBuffer.cpp index 30c3771b7dc..17884e1b25a 100644 --- a/src/rsz/test/cpp/TestInsertBuffer.cpp +++ b/src/rsz/test/cpp/TestInsertBuffer.cpp @@ -2919,8 +2919,16 @@ TEST_F(TestInsertBuffer, BeforeLoads_Case28) ASSERT_NE(internal_net_after, nullptr); EXPECT_EQ(internal_net, internal_net_after); - // Verify that a new port "_019__0" is created in H1 to avoid collision - dbModBTerm* punched_port = mod_h1->findModBTerm("_019__0"); + // Verify that a new port is created in H1 to avoid collision with "_019_". + // The exact suffix depends on the global uniquify counter. + dbModBTerm* punched_port = nullptr; + for (dbModBTerm* bterm : mod_h1->getModBTerms()) { + std::string bname = bterm->getName(); + if (bname.substr(0, 5) == "_019_" && bname != "_019_") { + punched_port = bterm; + break; + } + } ASSERT_NE(punched_port, nullptr); EXPECT_EQ(punched_port->getIoType(), dbIoType::INPUT); diff --git a/src/rsz/test/cpp/TestInsertBuffer_BeforeLoads_Case25_post.v b/src/rsz/test/cpp/TestInsertBuffer_BeforeLoads_Case25_post.v index 46be773bbf6..50b159e13d4 100644 --- a/src/rsz/test/cpp/TestInsertBuffer_BeforeLoads_Case25_post.v +++ b/src/rsz/test/cpp/TestInsertBuffer_BeforeLoads_Case25_post.v @@ -5,7 +5,7 @@ module top (in, wire net1; - H0 h0 (.in_0(net1), + H0 h0 (.in_2(net1), .in(in), .out(out)); BUF_X1 load1 (.A(net1)); @@ -13,15 +13,15 @@ module top (in, .Z(net1)); BUF_X1 nontarget0 (.A(out)); endmodule -module H0 (in_0, +module H0 (in_2, in, out); - input in_0; + input in_2; input in; output out; BUF_X1 drvr (.A(in), .Z(out)); - BUF_X1 load0 (.A(in_0)); + BUF_X1 load0 (.A(in_2)); endmodule diff --git a/src/rsz/test/cpp/TestInsertBuffer_BeforeLoads_Case28_post.v b/src/rsz/test/cpp/TestInsertBuffer_BeforeLoads_Case28_post.v index bf0178525e6..89fee86728f 100644 --- a/src/rsz/test/cpp/TestInsertBuffer_BeforeLoads_Case28_post.v +++ b/src/rsz/test/cpp/TestInsertBuffer_BeforeLoads_Case28_post.v @@ -6,20 +6,20 @@ module top (in); BUF_X1 drvr (.A(in), .Z(_019_)); - H1 h1 (._019__0(net1), + H1 h1 (._019__2(net1), .A(_019_)); BUF_X1 load4 (.A(net1)); BUF_X4 new_buf1 (.A(_019_), .Z(net1)); endmodule -module H1 (_019__0, +module H1 (_019__2, A); - input _019__0; + input _019__2; input A; wire _019_; - BUF_X1 load1 (.A(_019__0)); + BUF_X1 load1 (.A(_019__2)); BUF_X1 load2 (.A(_019_)); BUF_X1 load3 (.A(A)); XOR2_X1 xor_gate (.A(A), diff --git a/src/rsz/test/cpp/TestInsertBuffer_BeforeLoads_Case30_post.v b/src/rsz/test/cpp/TestInsertBuffer_BeforeLoads_Case30_post.v index 7ae1bd071a0..0bfa4559f88 100644 --- a/src/rsz/test/cpp/TestInsertBuffer_BeforeLoads_Case30_post.v +++ b/src/rsz/test/cpp/TestInsertBuffer_BeforeLoads_Case30_post.v @@ -5,7 +5,7 @@ module top (); BUF_X1 buf1 (.A(ic_debug_addr_2), .Z(net1)); - swerv swerv_inst (.ic_debug_addr_2_0(net1), + swerv swerv_inst (.ic_debug_addr_2_3(net1), .ic_debug_addr_2(ic_debug_addr_2)); BUF_X1 u_2884 (.A(net1)); BUF_X1 u_2885 (.A(net1)); @@ -24,29 +24,29 @@ module dec_tlu_ctl (dec_tlu_ic_diag_pkt_2); BUF_X1 driver (.A(\swerv_inst/dec_tlu/zero_ ), .Z(dec_tlu_ic_diag_pkt_2)); endmodule -module ifu (ic_debug_addr_2_0, +module ifu (ic_debug_addr_2_2, dec_tlu_ic_diag_pkt_2, ic_debug_addr_2); - input ic_debug_addr_2_0; + input ic_debug_addr_2_2; input dec_tlu_ic_diag_pkt_2; output ic_debug_addr_2; - BUF_X1 u_11044 (.A(ic_debug_addr_2_0)); - BUF_X1 u_11045 (.A(ic_debug_addr_2_0)); - BUF_X1 u_11046 (.A(ic_debug_addr_2_0)); - BUF_X1 u_11047 (.A(ic_debug_addr_2_0)); + BUF_X1 u_11044 (.A(ic_debug_addr_2_2)); + BUF_X1 u_11045 (.A(ic_debug_addr_2_2)); + BUF_X1 u_11046 (.A(ic_debug_addr_2_2)); + BUF_X1 u_11047 (.A(ic_debug_addr_2_2)); assign ic_debug_addr_2 = dec_tlu_ic_diag_pkt_2; endmodule -module swerv (ic_debug_addr_2_0, +module swerv (ic_debug_addr_2_3, ic_debug_addr_2); - input ic_debug_addr_2_0; + input ic_debug_addr_2_3; output ic_debug_addr_2; wire dec_tlu_ic_diag_pkt_2; dec_tlu_ctl dec_tlu (.dec_tlu_ic_diag_pkt_2(dec_tlu_ic_diag_pkt_2)); - ifu ifu (.ic_debug_addr_2_0(ic_debug_addr_2_0), + ifu ifu (.ic_debug_addr_2_2(ic_debug_addr_2_3), .dec_tlu_ic_diag_pkt_2(dec_tlu_ic_diag_pkt_2), .ic_debug_addr_2(ic_debug_addr_2)); endmodule From 7565f7c1d369cd5fac7d9c8ccebf5f4ffaa51efe Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Sat, 14 Mar 2026 18:42:32 +0900 Subject: [PATCH 04/11] Fix clang-format issue Signed-off-by: Jaehyun Kim --- src/odb/src/db/dbInsertBuffer.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/odb/src/db/dbInsertBuffer.cpp b/src/odb/src/db/dbInsertBuffer.cpp index 5698cd4a9f5..8d27c7bd38f 100644 --- a/src/odb/src/db/dbInsertBuffer.cpp +++ b/src/odb/src/db/dbInsertBuffer.cpp @@ -513,10 +513,10 @@ std::string dbInsertBuffer::makeUniqueHierName(const dbModule* module, const char* suffix) const { std::string name = (suffix == nullptr) ? base_name : base_name + suffix; - std::string full = block_->makeNewNetName( - const_cast(module), - name.c_str(), - dbNameUniquifyType::IF_NEEDED_WITH_UNDERSCORE); + std::string full + = block_->makeNewNetName(const_cast(module), + name.c_str(), + dbNameUniquifyType::IF_NEEDED_WITH_UNDERSCORE); return std::string(block_->getBaseName(full.c_str())); } @@ -1236,7 +1236,8 @@ dbModBTerm* dbInsertBuffer::findOrCreateTracePort(dbModule* current_mod, utl::ODB, 1218, "Parent moditerm '{}' already exists on modinst '{}' and is bound " - "to a different modbterm while creating a trace port for modnet '{}'.", + "to a different modbterm while creating a trace port for modnet " + "'{}'.", port_name, mod_inst->getName(), mod_net->getName()); From 03e2cf168dde96e69554addeed216641a414ee52 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Sat, 14 Mar 2026 18:47:42 +0900 Subject: [PATCH 05/11] Fix clang-format issue Signed-off-by: Jaehyun Kim --- src/odb/src/db/dbNet.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/odb/src/db/dbNet.cpp b/src/odb/src/db/dbNet.cpp index dbc5e5ed719..ceaab3de0b5 100644 --- a/src/odb/src/db/dbNet.cpp +++ b/src/odb/src/db/dbNet.cpp @@ -2221,8 +2221,7 @@ dbNet* dbNet::create(dbBlock* block, const dbNameUniquifyType& uniquify, dbModule* parent_module) { - std::string net_name - = block->makeNewNetName(parent_module, name, uniquify); + std::string net_name = block->makeNewNetName(parent_module, name, uniquify); return create(block, net_name.c_str()); } From 91fdd25bbb77deda992d18a48d52b7ef880d26fb Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Sat, 14 Mar 2026 18:51:34 +0900 Subject: [PATCH 06/11] style: apply clang-format to edited files Signed-off-by: Jaehyun Kim --- src/rsz/test/cpp/TestInsertBuffer.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/rsz/test/cpp/TestInsertBuffer.cpp b/src/rsz/test/cpp/TestInsertBuffer.cpp index 17884e1b25a..ba89914b043 100644 --- a/src/rsz/test/cpp/TestInsertBuffer.cpp +++ b/src/rsz/test/cpp/TestInsertBuffer.cpp @@ -3338,14 +3338,14 @@ TEST_F(TestInsertBuffer, BeforeLoads_Case34) std::set load_pins; load_pins.insert(load2_a); - dbInst* new_buf = orig_net->insertBufferBeforeLoads( - load_pins, - buf_x4_master, - nullptr, - "split", - nullptr, - dbNameUniquifyType::IF_NEEDED, - false); + dbInst* new_buf + = orig_net->insertBufferBeforeLoads(load_pins, + buf_x4_master, + nullptr, + "split", + nullptr, + dbNameUniquifyType::IF_NEEDED, + false); ASSERT_NE(new_buf, nullptr); // Post sanity check - detects flat net / ModNet name collision From 06a93f6766918388f5254ced38dbee7222274e21 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Sat, 14 Mar 2026 20:05:18 +0900 Subject: [PATCH 07/11] odb: improve const-correctness for makeNewNetName and isInternalTo Change makeNewNetName to accept const dbModule* and isInternalTo to accept const dbModule*, since neither modifies the module. This removes the const_cast in makeUniqueHierName. Signed-off-by: Jaehyun Kim --- src/odb/include/odb/db.h | 4 ++-- src/odb/src/db/dbBlock.cpp | 4 ++-- src/odb/src/db/dbInsertBuffer.cpp | 6 ++---- src/odb/src/db/dbNet.cpp | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/odb/include/odb/db.h b/src/odb/include/odb/db.h index f4249bd3e1c..db57432cb12 100644 --- a/src/odb/include/odb/db.h +++ b/src/odb/include/odb/db.h @@ -1318,7 +1318,7 @@ class dbBlock : public dbObject /// If corresponding_flat_net is non-null, only internal flat nets excluding /// the corresponding one are collisions (lenient mode for ModNet creation). /// - std::string makeNewNetName(dbModule* parent = nullptr, + std::string makeNewNetName(const dbModule* parent = nullptr, const char* base_name = "net", const dbNameUniquifyType& uniquify = dbNameUniquifyType::ALWAYS, @@ -2566,7 +2566,7 @@ class dbNet : public dbObject /// connected to a module output port that is unconnected in its parent /// module (isInternalTo == true). /// - bool isInternalTo(dbModule* module) const; + bool isInternalTo(const dbModule* module) const; /// /// Check issues such as multiple drivers, no driver, or dangling net diff --git a/src/odb/src/db/dbBlock.cpp b/src/odb/src/db/dbBlock.cpp index c6122485c2b..b0ec3e19ac9 100644 --- a/src/odb/src/db/dbBlock.cpp +++ b/src/odb/src/db/dbBlock.cpp @@ -3930,12 +3930,12 @@ std::string _dbBlock::makeNewName( // (strict mode for flat net creation). // If corresponding_flat_net is non-null, only internal flat nets excluding // the corresponding one collide (lenient mode for ModNet creation). -std::string dbBlock::makeNewNetName(dbModule* parent, +std::string dbBlock::makeNewNetName(const dbModule* parent, const char* base_name, const dbNameUniquifyType& uniquify, dbNet* corresponding_flat_net) { - dbModule* scope = parent ? parent : getTopModule(); + const dbModule* scope = parent ? parent : getTopModule(); dbModInst* mod_inst = scope ? scope->getModInst() : nullptr; auto exists = [this, scope, corresponding_flat_net](const char* name) { diff --git a/src/odb/src/db/dbInsertBuffer.cpp b/src/odb/src/db/dbInsertBuffer.cpp index 8d27c7bd38f..372a8ebc768 100644 --- a/src/odb/src/db/dbInsertBuffer.cpp +++ b/src/odb/src/db/dbInsertBuffer.cpp @@ -513,10 +513,8 @@ std::string dbInsertBuffer::makeUniqueHierName(const dbModule* module, const char* suffix) const { std::string name = (suffix == nullptr) ? base_name : base_name + suffix; - std::string full - = block_->makeNewNetName(const_cast(module), - name.c_str(), - dbNameUniquifyType::IF_NEEDED_WITH_UNDERSCORE); + std::string full = block_->makeNewNetName( + module, name.c_str(), dbNameUniquifyType::IF_NEEDED_WITH_UNDERSCORE); return std::string(block_->getBaseName(full.c_str())); } diff --git a/src/odb/src/db/dbNet.cpp b/src/odb/src/db/dbNet.cpp index ceaab3de0b5..ba59567f1d5 100644 --- a/src/odb/src/db/dbNet.cpp +++ b/src/odb/src/db/dbNet.cpp @@ -2631,7 +2631,7 @@ void dbNet::renameWithModNetInHighestHier() } } -bool dbNet::isInternalTo(dbModule* module) const +bool dbNet::isInternalTo(const dbModule* module) const { // If it's connected to any top-level ports (BTerms), it's not internal. if (!getBTerms().empty()) { From 4311154a7013ffd1fec75d75aec506dbc864e223 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Sat, 14 Mar 2026 20:42:13 +0900 Subject: [PATCH 08/11] Update golden verilog files for unified makeNewNetName The unified makeNewNetName API uses a shared global counter (unique_net_index_) instead of local counters, producing different numeric suffixes in generated net names. Update golden files for repair_fanout2_hier, repair_fanout3_hier, and simple_test_hier tests to match the new output. Signed-off-by: Jeonghyun Kim Signed-off-by: Jaehyun Kim --- src/cts/test/simple_test_hier_out.vok | 64 +++--- src/rsz/test/repair_fanout2_hier_out.vok | 232 ++++++++++----------- src/rsz/test/repair_fanout3_hier_out.vok | 248 +++++++++++------------ 3 files changed, 272 insertions(+), 272 deletions(-) diff --git a/src/cts/test/simple_test_hier_out.vok b/src/cts/test/simple_test_hier_out.vok index eec38c935d4..8b2253ea8fb 100644 --- a/src/cts/test/simple_test_hier_out.vok +++ b/src/cts/test/simple_test_hier_out.vok @@ -1,93 +1,93 @@ module test_16_sinks (clk); input clk; - wire clknet_1_1__leaf_clk_1; + wire clknet_1_1__leaf_clk_2; wire clknet_1_0__leaf_clk_1; wire clknet_0_clk; - flop_pair U1 (.clknet_1_1__leaf_clk_1_i(clknet_1_1__leaf_clk_1), + flop_pair U1 (.clknet_1_1__leaf_clk_2_i(clknet_1_1__leaf_clk_2), .clknet_1_0__leaf_clk_1_i(clknet_1_0__leaf_clk_1)); - flop_pair_U2 U2 (.clknet_1_1__leaf_clk_1_i(clknet_1_1__leaf_clk_1), + flop_pair_U2 U2 (.clknet_1_1__leaf_clk_2_i(clknet_1_1__leaf_clk_2), .clknet_1_0__leaf_clk_1_i(clknet_1_0__leaf_clk_1)); - flop_pair_U3 U3 (.clknet_1_1__leaf_clk_1_i(clknet_1_1__leaf_clk_1)); - flop_pair_U4 U4 (.clknet_1_1__leaf_clk_1_i(clknet_1_1__leaf_clk_1), + flop_pair_U3 U3 (.clknet_1_1__leaf_clk_2_i(clknet_1_1__leaf_clk_2)); + flop_pair_U4 U4 (.clknet_1_1__leaf_clk_2_i(clknet_1_1__leaf_clk_2), .clknet_1_0__leaf_clk_1_i(clknet_1_0__leaf_clk_1)); - flop_pair_U5 U5 (.clknet_1_1__leaf_clk_1_i(clknet_1_1__leaf_clk_1), + flop_pair_U5 U5 (.clknet_1_1__leaf_clk_2_i(clknet_1_1__leaf_clk_2), .clknet_1_0__leaf_clk_1_i(clknet_1_0__leaf_clk_1)); - flop_pair_U6 U6 (.clknet_1_1__leaf_clk_1_i(clknet_1_1__leaf_clk_1), + flop_pair_U6 U6 (.clknet_1_1__leaf_clk_2_i(clknet_1_1__leaf_clk_2), .clknet_1_0__leaf_clk_1_i(clknet_1_0__leaf_clk_1)); - flop_pair_U7 U7 (.clknet_1_1__leaf_clk_1_i(clknet_1_1__leaf_clk_1), + flop_pair_U7 U7 (.clknet_1_1__leaf_clk_2_i(clknet_1_1__leaf_clk_2), .clknet_1_0__leaf_clk_1_i(clknet_1_0__leaf_clk_1)); - flop_pair_U8 U8 (.clknet_1_1__leaf_clk_i(clknet_1_1__leaf_clk_1), + flop_pair_U8 U8 (.clknet_1_1__leaf_clk_i(clknet_1_1__leaf_clk_2), .clknet_1_0__leaf_clk_i(clknet_1_0__leaf_clk_1)); CLKBUF_X3 clkbuf_0_clk (.A(clk), .Z(clknet_0_clk)); CLKBUF_X3 clkbuf_1_0__f_clk (.A(clknet_0_clk), .Z(clknet_1_0__leaf_clk_1)); CLKBUF_X3 clkbuf_1_1__f_clk (.A(clknet_0_clk), - .Z(clknet_1_1__leaf_clk_1)); + .Z(clknet_1_1__leaf_clk_2)); INV_X1 clkload0 (.A(clknet_1_0__leaf_clk_1)); endmodule -module flop_pair (clknet_1_1__leaf_clk_1_i, +module flop_pair (clknet_1_1__leaf_clk_2_i, clknet_1_0__leaf_clk_1_i); - input clknet_1_1__leaf_clk_1_i; + input clknet_1_1__leaf_clk_2_i; input clknet_1_0__leaf_clk_1_i; DFF_X1 ff1 (.CK(clknet_1_0__leaf_clk_1_i)); - DFF_X1 ff2 (.CK(clknet_1_1__leaf_clk_1_i)); + DFF_X1 ff2 (.CK(clknet_1_1__leaf_clk_2_i)); endmodule -module flop_pair_U2 (clknet_1_1__leaf_clk_1_i, +module flop_pair_U2 (clknet_1_1__leaf_clk_2_i, clknet_1_0__leaf_clk_1_i); - input clknet_1_1__leaf_clk_1_i; + input clknet_1_1__leaf_clk_2_i; input clknet_1_0__leaf_clk_1_i; - DFF_X1 ff1 (.CK(clknet_1_1__leaf_clk_1_i)); + DFF_X1 ff1 (.CK(clknet_1_1__leaf_clk_2_i)); DFF_X1 ff2 (.CK(clknet_1_0__leaf_clk_1_i)); endmodule -module flop_pair_U3 (clknet_1_1__leaf_clk_1_i); - input clknet_1_1__leaf_clk_1_i; +module flop_pair_U3 (clknet_1_1__leaf_clk_2_i); + input clknet_1_1__leaf_clk_2_i; - DFF_X1 ff1 (.CK(clknet_1_1__leaf_clk_1_i)); - DFF_X1 ff2 (.CK(clknet_1_1__leaf_clk_1_i)); + DFF_X1 ff1 (.CK(clknet_1_1__leaf_clk_2_i)); + DFF_X1 ff2 (.CK(clknet_1_1__leaf_clk_2_i)); endmodule -module flop_pair_U4 (clknet_1_1__leaf_clk_1_i, +module flop_pair_U4 (clknet_1_1__leaf_clk_2_i, clknet_1_0__leaf_clk_1_i); - input clknet_1_1__leaf_clk_1_i; + input clknet_1_1__leaf_clk_2_i; input clknet_1_0__leaf_clk_1_i; DFF_X1 ff1 (.CK(clknet_1_0__leaf_clk_1_i)); - DFF_X1 ff2 (.CK(clknet_1_1__leaf_clk_1_i)); + DFF_X1 ff2 (.CK(clknet_1_1__leaf_clk_2_i)); endmodule -module flop_pair_U5 (clknet_1_1__leaf_clk_1_i, +module flop_pair_U5 (clknet_1_1__leaf_clk_2_i, clknet_1_0__leaf_clk_1_i); - input clknet_1_1__leaf_clk_1_i; + input clknet_1_1__leaf_clk_2_i; input clknet_1_0__leaf_clk_1_i; DFF_X1 ff1 (.CK(clknet_1_0__leaf_clk_1_i)); - DFF_X1 ff2 (.CK(clknet_1_1__leaf_clk_1_i)); + DFF_X1 ff2 (.CK(clknet_1_1__leaf_clk_2_i)); endmodule -module flop_pair_U6 (clknet_1_1__leaf_clk_1_i, +module flop_pair_U6 (clknet_1_1__leaf_clk_2_i, clknet_1_0__leaf_clk_1_i); - input clknet_1_1__leaf_clk_1_i; + input clknet_1_1__leaf_clk_2_i; input clknet_1_0__leaf_clk_1_i; DFF_X1 ff1 (.CK(clknet_1_0__leaf_clk_1_i)); - DFF_X1 ff2 (.CK(clknet_1_1__leaf_clk_1_i)); + DFF_X1 ff2 (.CK(clknet_1_1__leaf_clk_2_i)); endmodule -module flop_pair_U7 (clknet_1_1__leaf_clk_1_i, +module flop_pair_U7 (clknet_1_1__leaf_clk_2_i, clknet_1_0__leaf_clk_1_i); - input clknet_1_1__leaf_clk_1_i; + input clknet_1_1__leaf_clk_2_i; input clknet_1_0__leaf_clk_1_i; DFF_X1 ff1 (.CK(clknet_1_0__leaf_clk_1_i)); - DFF_X1 ff2 (.CK(clknet_1_1__leaf_clk_1_i)); + DFF_X1 ff2 (.CK(clknet_1_1__leaf_clk_2_i)); endmodule module flop_pair_U8 (clknet_1_1__leaf_clk_i, clknet_1_0__leaf_clk_i); diff --git a/src/rsz/test/repair_fanout2_hier_out.vok b/src/rsz/test/repair_fanout2_hier_out.vok index c93fbb3a07e..dbaeb114691 100644 --- a/src/rsz/test/repair_fanout2_hier_out.vok +++ b/src/rsz/test/repair_fanout2_hier_out.vok @@ -3,224 +3,224 @@ module hi_fanout (clk1, input clk1; input in; + wire net18; + wire net15; + wire net12; wire net8; - wire net7; - wire net6; - wire net4; - wire net3; + wire net5; wire net1; wire net0; DFF_X1 drvr (.D(in), .CK(clk1), .Q(net0)); - BUF_X1 fanout1 (.A(net4), + BUF_X1 fanout1 (.A(net8), .Z(net1)); - BUF_X1 fanout3 (.A(net4), - .Z(net3)); + BUF_X1 fanout3 (.A(net8), + .Z(net5)); BUF_X1 fanout4 (.A(net0), - .Z(net4)); - BUF_X1 fanout6 (.A(net8), - .Z(net6)); - BUF_X1 fanout7 (.A(net8), - .Z(net7)); - BUF_X1 fanout8 (.A(net0), .Z(net8)); - hi_fanout_child h0 (.net0_4(net7), - .net0_3(net6), - .net0_2(net4), - .net0_1(net3), - .net0_0(net1), - .net0(net8), + BUF_X1 fanout6 (.A(net18), + .Z(net12)); + BUF_X1 fanout7 (.A(net18), + .Z(net15)); + BUF_X1 fanout8 (.A(net0), + .Z(net18)); + hi_fanout_child h0 (.net0_16(net15), + .net0_13(net12), + .net0_9(net8), + .net0_6(net5), + .net0_2(net1), + .net0(net18), .clk1(clk1)); - hi_fanout_child_h1 h1 (.net0_5(net8), - .net0_4(net7), - .net0_3(net6), - .net0_2(net4), - .net0_1(net3), - .net0_0(net1), + hi_fanout_child_h1 h1 (.net0_19(net18), + .net0_17(net15), + .net0_14(net12), + .net0_10(net8), + .net0_7(net5), + .net0_3(net1), .net0(net0), .clk1(clk1)); endmodule -module hi_fanout_child (net0_4, - net0_3, +module hi_fanout_child (net0_16, + net0_13, + net0_9, + net0_6, net0_2, - net0_1, - net0_0, net0, clk1); - input net0_4; - input net0_3; + input net0_16; + input net0_13; + input net0_9; + input net0_6; input net0_2; - input net0_1; - input net0_0; input net0; input clk1; - wire net2; - wire net5; + wire net4; + wire net11; - BUF_X1 fanout2 (.A(net0_1), - .Z(net2)); + BUF_X1 fanout2 (.A(net0_6), + .Z(net4)); BUF_X1 fanout5 (.A(net0), - .Z(net5)); - DFF_X1 load0 (.D(net2), + .Z(net11)); + DFF_X1 load0 (.D(net4), .CK(clk1)); - DFF_X1 load1 (.D(net2), + DFF_X1 load1 (.D(net4), .CK(clk1)); - DFF_X1 load10 (.D(net5), + DFF_X1 load10 (.D(net11), .CK(clk1)); - DFF_X1 load11 (.D(net2), + DFF_X1 load11 (.D(net4), .CK(clk1)); - DFF_X1 load12 (.D(net5), + DFF_X1 load12 (.D(net11), .CK(clk1)); - DFF_X1 load13 (.D(net2), + DFF_X1 load13 (.D(net4), .CK(clk1)); - DFF_X1 load14 (.D(net2), + DFF_X1 load14 (.D(net4), .CK(clk1)); - DFF_X1 load15 (.D(net5), + DFF_X1 load15 (.D(net11), .CK(clk1)); - DFF_X1 load16 (.D(net0_1), + DFF_X1 load16 (.D(net0_6), .CK(clk1)); - DFF_X1 load17 (.D(net5), + DFF_X1 load17 (.D(net11), .CK(clk1)); - DFF_X1 load18 (.D(net2), + DFF_X1 load18 (.D(net4), .CK(clk1)); - DFF_X1 load19 (.D(net5), + DFF_X1 load19 (.D(net11), .CK(clk1)); - DFF_X1 load2 (.D(net0_1), + DFF_X1 load2 (.D(net0_6), .CK(clk1)); - DFF_X1 load20 (.D(net5), + DFF_X1 load20 (.D(net11), .CK(clk1)); - DFF_X1 load21 (.D(net0_1), + DFF_X1 load21 (.D(net0_6), .CK(clk1)); - DFF_X1 load22 (.D(net2), + DFF_X1 load22 (.D(net4), .CK(clk1)); - DFF_X1 load23 (.D(net5), + DFF_X1 load23 (.D(net11), .CK(clk1)); - DFF_X1 load24 (.D(net2), + DFF_X1 load24 (.D(net4), .CK(clk1)); - DFF_X1 load25 (.D(net5), + DFF_X1 load25 (.D(net11), .CK(clk1)); - DFF_X1 load26 (.D(net0_1), + DFF_X1 load26 (.D(net0_6), .CK(clk1)); - DFF_X1 load27 (.D(net0_3), + DFF_X1 load27 (.D(net0_13), .CK(clk1)); - DFF_X1 load28 (.D(net0_0), + DFF_X1 load28 (.D(net0_2), .CK(clk1)); - DFF_X1 load29 (.D(net0_4), + DFF_X1 load29 (.D(net0_16), .CK(clk1)); - DFF_X1 load3 (.D(net2), + DFF_X1 load3 (.D(net4), .CK(clk1)); - DFF_X1 load30 (.D(net5), + DFF_X1 load30 (.D(net11), .CK(clk1)); - DFF_X1 load31 (.D(net0_1), + DFF_X1 load31 (.D(net0_6), .CK(clk1)); - DFF_X1 load32 (.D(net0_3), + DFF_X1 load32 (.D(net0_13), .CK(clk1)); - DFF_X1 load33 (.D(net0_2), + DFF_X1 load33 (.D(net0_9), .CK(clk1)); - DFF_X1 load34 (.D(net0_0), + DFF_X1 load34 (.D(net0_2), .CK(clk1)); - DFF_X1 load4 (.D(net0_4), + DFF_X1 load4 (.D(net0_16), .CK(clk1)); - DFF_X1 load5 (.D(net2), + DFF_X1 load5 (.D(net4), .CK(clk1)); - DFF_X1 load6 (.D(net5), + DFF_X1 load6 (.D(net11), .CK(clk1)); - DFF_X1 load7 (.D(net0_1), + DFF_X1 load7 (.D(net0_6), .CK(clk1)); - DFF_X1 load8 (.D(net0_3), + DFF_X1 load8 (.D(net0_13), .CK(clk1)); - DFF_X1 load9 (.D(net0_2), + DFF_X1 load9 (.D(net0_9), .CK(clk1)); endmodule -module hi_fanout_child_h1 (net0_5, - net0_4, +module hi_fanout_child_h1 (net0_19, + net0_17, + net0_14, + net0_10, + net0_7, net0_3, - net0_2, - net0_1, - net0_0, net0, clk1); - input net0_5; - input net0_4; + input net0_19; + input net0_17; + input net0_14; + input net0_10; + input net0_7; input net0_3; - input net0_2; - input net0_1; - input net0_0; input net0; input clk1; - DFF_X1 load0 (.D(net0_5), + DFF_X1 load0 (.D(net0_19), .CK(clk1)); - DFF_X1 load1 (.D(net0_0), + DFF_X1 load1 (.D(net0_3), .CK(clk1)); - DFF_X1 load10 (.D(net0_4), + DFF_X1 load10 (.D(net0_17), .CK(clk1)); - DFF_X1 load11 (.D(net0_0), + DFF_X1 load11 (.D(net0_3), .CK(clk1)); - DFF_X1 load12 (.D(net0_4), + DFF_X1 load12 (.D(net0_17), .CK(clk1)); - DFF_X1 load13 (.D(net0_1), + DFF_X1 load13 (.D(net0_7), .CK(clk1)); - DFF_X1 load14 (.D(net0_3), + DFF_X1 load14 (.D(net0_14), .CK(clk1)); - DFF_X1 load15 (.D(net0_2), + DFF_X1 load15 (.D(net0_10), .CK(clk1)); - DFF_X1 load16 (.D(net0_5), + DFF_X1 load16 (.D(net0_19), .CK(clk1)); - DFF_X1 load17 (.D(net0_0), + DFF_X1 load17 (.D(net0_3), .CK(clk1)); - DFF_X1 load18 (.D(net0_4), + DFF_X1 load18 (.D(net0_17), .CK(clk1)); - DFF_X1 load19 (.D(net0_2), + DFF_X1 load19 (.D(net0_10), .CK(clk1)); - DFF_X1 load2 (.D(net0_0), + DFF_X1 load2 (.D(net0_3), .CK(clk1)); - DFF_X1 load20 (.D(net0_4), + DFF_X1 load20 (.D(net0_17), .CK(clk1)); - DFF_X1 load21 (.D(net0_1), + DFF_X1 load21 (.D(net0_7), .CK(clk1)); - DFF_X1 load22 (.D(net0_3), + DFF_X1 load22 (.D(net0_14), .CK(clk1)); - DFF_X1 load23 (.D(net0_2), + DFF_X1 load23 (.D(net0_10), .CK(clk1)); - DFF_X1 load24 (.D(net0_5), + DFF_X1 load24 (.D(net0_19), .CK(clk1)); - DFF_X1 load25 (.D(net0_0), + DFF_X1 load25 (.D(net0_3), .CK(clk1)); - DFF_X1 load26 (.D(net0_4), + DFF_X1 load26 (.D(net0_17), .CK(clk1)); - DFF_X1 load27 (.D(net0_2), + DFF_X1 load27 (.D(net0_10), .CK(clk1)); - DFF_X1 load28 (.D(net0_5), + DFF_X1 load28 (.D(net0_19), .CK(clk1)); - DFF_X1 load29 (.D(net0_0), + DFF_X1 load29 (.D(net0_3), .CK(clk1)); - DFF_X1 load3 (.D(net0_4), + DFF_X1 load3 (.D(net0_17), .CK(clk1)); - DFF_X1 load30 (.D(net0_2), + DFF_X1 load30 (.D(net0_10), .CK(clk1)); - DFF_X1 load31 (.D(net0_5), + DFF_X1 load31 (.D(net0_19), .CK(clk1)); - DFF_X1 load32 (.D(net0_2), + DFF_X1 load32 (.D(net0_10), .CK(clk1)); - DFF_X1 load33 (.D(net0_5), + DFF_X1 load33 (.D(net0_19), .CK(clk1)); - DFF_X1 load34 (.D(net0_0), + DFF_X1 load34 (.D(net0_3), .CK(clk1)); - DFF_X1 load4 (.D(net0_4), + DFF_X1 load4 (.D(net0_17), .CK(clk1)); DFF_X1 load5 (.D(net0), .CK(clk1)); - DFF_X1 load6 (.D(net0_5), + DFF_X1 load6 (.D(net0_19), .CK(clk1)); - DFF_X1 load7 (.D(net0_0), + DFF_X1 load7 (.D(net0_3), .CK(clk1)); DFF_X1 load8 (.D(net0), .CK(clk1)); - DFF_X1 load9 (.D(net0_4), + DFF_X1 load9 (.D(net0_17), .CK(clk1)); endmodule diff --git a/src/rsz/test/repair_fanout3_hier_out.vok b/src/rsz/test/repair_fanout3_hier_out.vok index 93903382e74..18ddd62e7f0 100644 --- a/src/rsz/test/repair_fanout3_hier_out.vok +++ b/src/rsz/test/repair_fanout3_hier_out.vok @@ -5,226 +5,226 @@ module hi_fanout (a, input clk1; input in; + wire net17; + wire net14; + wire net12; wire net8; - wire net7; - wire net6; - wire net4; - wire net3; - wire net1; wire net5; + wire net1; + wire net11; DFF_X1 drvr (.D(in), .CK(clk1), - .Q(net5)); - BUF_X1 fanout1 (.A(net4), + .Q(net11)); + BUF_X1 fanout1 (.A(net8), .Z(net1)); - BUF_X1 fanout3 (.A(net4), - .Z(net3)); - BUF_X1 fanout4 (.A(net5), - .Z(net4)); - BUF_X1 fanout5 (.A(net6), - .Z(a)); - BUF_X1 fanout6 (.A(net8), - .Z(net6)); - BUF_X1 fanout7 (.A(net8), - .Z(net7)); - BUF_X1 fanout8 (.A(net5), + BUF_X1 fanout3 (.A(net8), + .Z(net5)); + BUF_X1 fanout4 (.A(net11), .Z(net8)); - hi_fanout_child hi_fanout_inst1 (.net5_1(net7), - .net5_0(net6), - .net5(a), - .a_2(net4), - .a_1(net3), - .a_0(net1), - .a(net8), + BUF_X1 fanout5 (.A(net12), + .Z(a)); + BUF_X1 fanout6 (.A(net17), + .Z(net12)); + BUF_X1 fanout7 (.A(net17), + .Z(net14)); + BUF_X1 fanout8 (.A(net11), + .Z(net17)); + hi_fanout_child hi_fanout_inst1 (.net11_15(net14), + .net11_13(net12), + .net11(a), + .a_9(net8), + .a_6(net5), + .a_2(net1), + .a(net17), .clk1(clk1)); - hi_fanout_child_hi_fanout_inst2 hi_fanout_inst2 (.net5_1(net8), - .net5_0(net7), - .net5(net6), - .a_2(net4), - .a_1(net3), - .a_0(net1), - .a(net5), + hi_fanout_child_hi_fanout_inst2 hi_fanout_inst2 (.net11_18(net17), + .net11_16(net14), + .net11(net12), + .a_10(net8), + .a_7(net5), + .a_3(net1), + .a(net11), .clk1(clk1)); endmodule -module hi_fanout_child (net5_1, - net5_0, - net5, +module hi_fanout_child (net11_15, + net11_13, + net11, + a_9, + a_6, a_2, - a_1, - a_0, a, clk1); - input net5_1; - input net5_0; - input net5; + input net11_15; + input net11_13; + input net11; + input a_9; + input a_6; input a_2; - input a_1; - input a_0; input a; input clk1; - wire net2; + wire net4; - BUF_X1 fanout2 (.A(a_1), - .Z(net2)); - DFF_X1 load0 (.D(net2), + BUF_X1 fanout2 (.A(a_6), + .Z(net4)); + DFF_X1 load0 (.D(net4), .CK(clk1)); - DFF_X1 load1 (.D(net5), + DFF_X1 load1 (.D(net11), .CK(clk1)); - DFF_X1 load10 (.D(net2), + DFF_X1 load10 (.D(net4), .CK(clk1)); - DFF_X1 load11 (.D(net5), + DFF_X1 load11 (.D(net11), .CK(clk1)); - DFF_X1 load12 (.D(net2), + DFF_X1 load12 (.D(net4), .CK(clk1)); - DFF_X1 load13 (.D(net2), + DFF_X1 load13 (.D(net4), .CK(clk1)); - DFF_X1 load14 (.D(net5), + DFF_X1 load14 (.D(net11), .CK(clk1)); - DFF_X1 load15 (.D(net2), + DFF_X1 load15 (.D(net4), .CK(clk1)); - DFF_X1 load16 (.D(net5), + DFF_X1 load16 (.D(net11), .CK(clk1)); - DFF_X1 load17 (.D(net2), + DFF_X1 load17 (.D(net4), .CK(clk1)); - DFF_X1 load18 (.D(net5), + DFF_X1 load18 (.D(net11), .CK(clk1)); - DFF_X1 load19 (.D(a_1), + DFF_X1 load19 (.D(a_6), .CK(clk1)); - DFF_X1 load2 (.D(net5), + DFF_X1 load2 (.D(net11), .CK(clk1)); - DFF_X1 load20 (.D(a_1), + DFF_X1 load20 (.D(a_6), .CK(clk1)); - DFF_X1 load21 (.D(net2), + DFF_X1 load21 (.D(net4), .CK(clk1)); - DFF_X1 load22 (.D(net5), + DFF_X1 load22 (.D(net11), .CK(clk1)); - DFF_X1 load23 (.D(net2), + DFF_X1 load23 (.D(net4), .CK(clk1)); - DFF_X1 load24 (.D(net5), + DFF_X1 load24 (.D(net11), .CK(clk1)); - DFF_X1 load25 (.D(a_1), + DFF_X1 load25 (.D(a_6), .CK(clk1)); - DFF_X1 load26 (.D(net5_0), + DFF_X1 load26 (.D(net11_13), .CK(clk1)); - DFF_X1 load27 (.D(a_0), + DFF_X1 load27 (.D(a_2), .CK(clk1)); - DFF_X1 load28 (.D(net5_1), + DFF_X1 load28 (.D(net11_15), .CK(clk1)); - DFF_X1 load29 (.D(net2), + DFF_X1 load29 (.D(net4), .CK(clk1)); - DFF_X1 load3 (.D(net5), + DFF_X1 load3 (.D(net11), .CK(clk1)); - DFF_X1 load30 (.D(a_1), + DFF_X1 load30 (.D(a_6), .CK(clk1)); - DFF_X1 load31 (.D(net5_0), + DFF_X1 load31 (.D(net11_13), .CK(clk1)); - DFF_X1 load32 (.D(a_2), + DFF_X1 load32 (.D(a_9), .CK(clk1)); - DFF_X1 load33 (.D(a_0), + DFF_X1 load33 (.D(a_2), .CK(clk1)); - DFF_X1 load34 (.D(net5_1), + DFF_X1 load34 (.D(net11_15), .CK(clk1)); - DFF_X1 load4 (.D(net2), + DFF_X1 load4 (.D(net4), .CK(clk1)); - DFF_X1 load5 (.D(net5_0), + DFF_X1 load5 (.D(net11_13), .CK(clk1)); - DFF_X1 load6 (.D(a_1), + DFF_X1 load6 (.D(a_6), .CK(clk1)); - DFF_X1 load7 (.D(net5_0), + DFF_X1 load7 (.D(net11_13), .CK(clk1)); - DFF_X1 load8 (.D(a_2), + DFF_X1 load8 (.D(a_9), .CK(clk1)); DFF_X1 load9 (.D(a), .CK(clk1)); endmodule -module hi_fanout_child_hi_fanout_inst2 (net5_1, - net5_0, - net5, - a_2, - a_1, - a_0, +module hi_fanout_child_hi_fanout_inst2 (net11_18, + net11_16, + net11, + a_10, + a_7, + a_3, a, clk1); - input net5_1; - input net5_0; - input net5; - input a_2; - input a_1; - input a_0; + input net11_18; + input net11_16; + input net11; + input a_10; + input a_7; + input a_3; input a; input clk1; - DFF_X1 load0 (.D(a_0), + DFF_X1 load0 (.D(a_3), .CK(clk1)); - DFF_X1 load1 (.D(net5_0), + DFF_X1 load1 (.D(net11_16), .CK(clk1)); - DFF_X1 load10 (.D(a_0), + DFF_X1 load10 (.D(a_3), .CK(clk1)); - DFF_X1 load11 (.D(net5_0), + DFF_X1 load11 (.D(net11_16), .CK(clk1)); - DFF_X1 load12 (.D(a_1), + DFF_X1 load12 (.D(a_7), .CK(clk1)); - DFF_X1 load13 (.D(net5), + DFF_X1 load13 (.D(net11), .CK(clk1)); - DFF_X1 load14 (.D(a_2), + DFF_X1 load14 (.D(a_10), .CK(clk1)); - DFF_X1 load15 (.D(net5_1), + DFF_X1 load15 (.D(net11_18), .CK(clk1)); - DFF_X1 load16 (.D(a_0), + DFF_X1 load16 (.D(a_3), .CK(clk1)); - DFF_X1 load17 (.D(net5_0), + DFF_X1 load17 (.D(net11_16), .CK(clk1)); - DFF_X1 load18 (.D(a_2), + DFF_X1 load18 (.D(a_10), .CK(clk1)); - DFF_X1 load19 (.D(a_0), + DFF_X1 load19 (.D(a_3), .CK(clk1)); - DFF_X1 load2 (.D(net5_0), + DFF_X1 load2 (.D(net11_16), .CK(clk1)); - DFF_X1 load20 (.D(a_1), + DFF_X1 load20 (.D(a_7), .CK(clk1)); - DFF_X1 load21 (.D(net5), + DFF_X1 load21 (.D(net11), .CK(clk1)); - DFF_X1 load22 (.D(a_2), + DFF_X1 load22 (.D(a_10), .CK(clk1)); - DFF_X1 load23 (.D(net5_1), + DFF_X1 load23 (.D(net11_18), .CK(clk1)); - DFF_X1 load24 (.D(a_0), + DFF_X1 load24 (.D(a_3), .CK(clk1)); - DFF_X1 load25 (.D(net5_0), + DFF_X1 load25 (.D(net11_16), .CK(clk1)); - DFF_X1 load26 (.D(a_2), + DFF_X1 load26 (.D(a_10), .CK(clk1)); - DFF_X1 load27 (.D(net5_1), + DFF_X1 load27 (.D(net11_18), .CK(clk1)); - DFF_X1 load28 (.D(a_0), + DFF_X1 load28 (.D(a_3), .CK(clk1)); - DFF_X1 load29 (.D(net5_0), + DFF_X1 load29 (.D(net11_16), .CK(clk1)); - DFF_X1 load3 (.D(a_2), + DFF_X1 load3 (.D(a_10), .CK(clk1)); - DFF_X1 load30 (.D(net5_1), + DFF_X1 load30 (.D(net11_18), .CK(clk1)); - DFF_X1 load31 (.D(a_2), + DFF_X1 load31 (.D(a_10), .CK(clk1)); - DFF_X1 load32 (.D(net5_1), + DFF_X1 load32 (.D(net11_18), .CK(clk1)); - DFF_X1 load33 (.D(a_0), + DFF_X1 load33 (.D(a_3), .CK(clk1)); - DFF_X1 load34 (.D(net5_0), + DFF_X1 load34 (.D(net11_16), .CK(clk1)); DFF_X1 load4 (.D(a), .CK(clk1)); DFF_X1 load5 (.D(a), .CK(clk1)); - DFF_X1 load6 (.D(net5_0), + DFF_X1 load6 (.D(net11_16), .CK(clk1)); - DFF_X1 load7 (.D(a_0), + DFF_X1 load7 (.D(a_3), .CK(clk1)); - DFF_X1 load8 (.D(net5_1), + DFF_X1 load8 (.D(net11_18), .CK(clk1)); - DFF_X1 load9 (.D(a_1), + DFF_X1 load9 (.D(a_7), .CK(clk1)); endmodule From 3cf5e8de8c47a29ed68e0ba093fdccb3b0d299bb Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Sat, 14 Mar 2026 21:31:49 +0900 Subject: [PATCH 09/11] Update golden files for hier_insertion_delay, gated_clock4, escape_slash_hier Same root cause as previous golden file update: the unified makeNewNetName API uses a shared global counter, producing different numeric suffixes in generated net names. Updated files: - cts/test/hier_insertion_delay.vok - cts/test/gated_clock4.vok - dbSta/test/escape_slash_hier.vok - dbSta/test/escape_slash_hier.spefok Signed-off-by: Jeonghyun Kim Signed-off-by: Jaehyun Kim --- src/cts/test/gated_clock4.vok | 8 +-- src/cts/test/hier_insertion_delay.vok | 72 ++++++++++++------------- src/dbSta/test/escape_slash_hier.spefok | 44 +++++++-------- src/dbSta/test/escape_slash_hier.vok | 8 +-- 4 files changed, 66 insertions(+), 66 deletions(-) diff --git a/src/cts/test/gated_clock4.vok b/src/cts/test/gated_clock4.vok index 3540c18b6e3..ea4aabac90b 100644 --- a/src/cts/test/gated_clock4.vok +++ b/src/cts/test/gated_clock4.vok @@ -1,7 +1,7 @@ module multi_sink (clk); input clk; - wire clknet_1_1__leaf_clk_1; + wire clknet_1_1__leaf_clk_2; wire clknet_1_0__leaf_clk_1; wire gclk1; wire gclk3; @@ -64,7 +64,7 @@ module multi_sink (clk); CLKBUF_X3 clkbuf_1_0__f_gclk4 (.A(clknet_0_gclk4), .Z(clknet_1_0__leaf_gclk4)); CLKBUF_X3 clkbuf_1_1__f_clk (.A(delaynet_6_core), - .Z(clknet_1_1__leaf_clk_1)); + .Z(clknet_1_1__leaf_clk_2)); CLKBUF_X3 clkbuf_2_0__f_gclk1 (.A(clknet_0_gclk1), .Z(clknet_2_0__leaf_gclk1)); CLKBUF_X3 clkbuf_2_0__f_gclk3 (.A(clknet_0_gclk3), @@ -235,13 +235,13 @@ module multi_sink (clk); DFF_X1 ff285 (.CK(clknet_2_0__leaf_gclk3)); DFF_X1 ff286 (.CK(clknet_2_2__leaf_gclk3)); DFF_X1 ff287 (.CK(clknet_2_1__leaf_gclk3)); - CLKGATE_X1 gclk1 (.CK(clknet_1_1__leaf_clk_1), + CLKGATE_X1 gclk1 (.CK(clknet_1_1__leaf_clk_2), .GCK(gclk1)); CLKGATE_X1 gclk3 (.CK(clknet_1_0__leaf_gclk4), .GCK(gclk3)); CLKGATE_X1 gclk4 (.CK(clknet_1_0__leaf_clk_1), .GCK(gclk4)); - hier_block h1 (.clknet_1_1__leaf_clk_i(clknet_1_1__leaf_clk_1), + hier_block h1 (.clknet_1_1__leaf_clk_i(clknet_1_1__leaf_clk_2), .clknet_1_0__leaf_clk_i(clknet_1_0__leaf_clk_1)); endmodule module hier_block (clknet_1_1__leaf_clk_i, diff --git a/src/cts/test/hier_insertion_delay.vok b/src/cts/test/hier_insertion_delay.vok index 4db56a54e3a..42b06c47808 100644 --- a/src/cts/test/hier_insertion_delay.vok +++ b/src/cts/test/hier_insertion_delay.vok @@ -1,9 +1,9 @@ module multi_sink (clk); input clk; - wire clknet_leaf_15_clk_regs_1; - wire clknet_leaf_13_clk_regs_1; - wire clknet_leaf_12_clk_regs_1; + wire clknet_leaf_15_clk_regs_4; + wire clknet_leaf_13_clk_regs_3; + wire clknet_leaf_12_clk_regs_2; wire clknet_leaf_11_clk_regs_1; wire clk_regs; wire clknet_0_clk; @@ -55,13 +55,13 @@ module multi_sink (clk); CLKBUF_X3 clkbuf_leaf_11_clk_regs (.A(clknet_1_1__leaf_clk_regs), .Z(clknet_leaf_11_clk_regs_1)); CLKBUF_X3 clkbuf_leaf_12_clk_regs (.A(clknet_1_1__leaf_clk_regs), - .Z(clknet_leaf_12_clk_regs_1)); + .Z(clknet_leaf_12_clk_regs_2)); CLKBUF_X3 clkbuf_leaf_13_clk_regs (.A(clknet_1_1__leaf_clk_regs), - .Z(clknet_leaf_13_clk_regs_1)); + .Z(clknet_leaf_13_clk_regs_3)); CLKBUF_X3 clkbuf_leaf_14_clk_regs (.A(clknet_1_0__leaf_clk_regs), .Z(clknet_leaf_14_clk_regs)); CLKBUF_X3 clkbuf_leaf_15_clk_regs (.A(clknet_1_0__leaf_clk_regs), - .Z(clknet_leaf_15_clk_regs_1)); + .Z(clknet_leaf_15_clk_regs_4)); CLKBUF_X3 clkbuf_leaf_16_clk_regs (.A(clknet_1_0__leaf_clk_regs), .Z(clknet_leaf_16_clk_regs)); CLKBUF_X3 clkbuf_leaf_17_clk_regs (.A(clknet_1_0__leaf_clk_regs), @@ -298,7 +298,7 @@ module multi_sink (clk); DFF_X1 ff271 (.CK(clknet_leaf_21_clk_regs)); DFF_X1 ff272 (.CK(clknet_leaf_5_clk_regs)); DFF_X1 ff273 (.CK(clknet_leaf_7_clk_regs)); - DFF_X1 ff274 (.CK(clknet_leaf_15_clk_regs_1)); + DFF_X1 ff274 (.CK(clknet_leaf_15_clk_regs_4)); DFF_X1 ff275 (.CK(clknet_leaf_22_clk_regs)); DFF_X1 ff276 (.CK(clknet_leaf_6_clk_regs)); DFF_X1 ff277 (.CK(clknet_leaf_10_clk_regs)); @@ -322,73 +322,73 @@ module multi_sink (clk); DFF_X1 ff35 (.CK(clknet_leaf_14_clk_regs)); DFF_X1 ff36 (.CK(clknet_leaf_5_clk_regs)); DFF_X1 ff37 (.CK(clknet_leaf_9_clk_regs)); - DFF_X1 ff38 (.CK(clknet_leaf_15_clk_regs_1)); - DFF_X1 ff39 (.CK(clknet_leaf_13_clk_regs_1)); + DFF_X1 ff38 (.CK(clknet_leaf_15_clk_regs_4)); + DFF_X1 ff39 (.CK(clknet_leaf_13_clk_regs_3)); DFF_X1 ff4 (.CK(clknet_leaf_6_clk_regs)); DFF_X1 ff40 (.CK(clknet_leaf_10_clk_regs)); DFF_X1 ff41 (.CK(clknet_leaf_16_clk_regs)); - DFF_X1 ff42 (.CK(clknet_leaf_13_clk_regs_1)); + DFF_X1 ff42 (.CK(clknet_leaf_13_clk_regs_3)); DFF_X1 ff43 (.CK(clknet_leaf_5_clk_regs)); DFF_X1 ff44 (.CK(clknet_leaf_10_clk_regs)); DFF_X1 ff45 (.CK(clknet_leaf_16_clk_regs)); DFF_X1 ff46 (.CK(clknet_leaf_14_clk_regs)); DFF_X1 ff47 (.CK(clknet_leaf_5_clk_regs)); DFF_X1 ff48 (.CK(clknet_leaf_9_clk_regs)); - DFF_X1 ff49 (.CK(clknet_leaf_15_clk_regs_1)); - DFF_X1 ff5 (.CK(clknet_leaf_13_clk_regs_1)); + DFF_X1 ff49 (.CK(clknet_leaf_15_clk_regs_4)); + DFF_X1 ff5 (.CK(clknet_leaf_13_clk_regs_3)); DFF_X1 ff50 (.CK(clknet_leaf_6_clk_regs)); DFF_X1 ff51 (.CK(clknet_leaf_10_clk_regs)); DFF_X1 ff52 (.CK(clknet_leaf_16_clk_regs)); - DFF_X1 ff53 (.CK(clknet_leaf_13_clk_regs_1)); + DFF_X1 ff53 (.CK(clknet_leaf_13_clk_regs_3)); DFF_X1 ff54 (.CK(clknet_leaf_6_clk_regs)); DFF_X1 ff55 (.CK(clknet_leaf_9_clk_regs)); DFF_X1 ff56 (.CK(clknet_leaf_16_clk_regs)); DFF_X1 ff57 (.CK(clknet_leaf_14_clk_regs)); - DFF_X1 ff58 (.CK(clknet_leaf_12_clk_regs_1)); + DFF_X1 ff58 (.CK(clknet_leaf_12_clk_regs_2)); DFF_X1 ff59 (.CK(clknet_leaf_9_clk_regs)); - DFF_X1 ff6 (.CK(clknet_leaf_15_clk_regs_1)); - DFF_X1 ff60 (.CK(clknet_leaf_13_clk_regs_1)); + DFF_X1 ff6 (.CK(clknet_leaf_15_clk_regs_4)); + DFF_X1 ff60 (.CK(clknet_leaf_13_clk_regs_3)); DFF_X1 ff61 (.CK(clknet_leaf_6_clk_regs)); DFF_X1 ff62 (.CK(clknet_leaf_10_clk_regs)); - DFF_X1 ff63 (.CK(clknet_leaf_15_clk_regs_1)); - DFF_X1 ff64 (.CK(clknet_leaf_13_clk_regs_1)); - DFF_X1 ff65 (.CK(clknet_leaf_12_clk_regs_1)); + DFF_X1 ff63 (.CK(clknet_leaf_15_clk_regs_4)); + DFF_X1 ff64 (.CK(clknet_leaf_13_clk_regs_3)); + DFF_X1 ff65 (.CK(clknet_leaf_12_clk_regs_2)); DFF_X1 ff66 (.CK(clknet_leaf_10_clk_regs)); DFF_X1 ff67 (.CK(clknet_leaf_16_clk_regs)); DFF_X1 ff68 (.CK(clknet_leaf_14_clk_regs)); - DFF_X1 ff69 (.CK(clknet_leaf_12_clk_regs_1)); + DFF_X1 ff69 (.CK(clknet_leaf_12_clk_regs_2)); DFF_X1 ff7 (.CK(clknet_leaf_9_clk_regs)); DFF_X1 ff70 (.CK(clknet_leaf_14_clk_regs)); - DFF_X1 ff71 (.CK(clknet_leaf_13_clk_regs_1)); + DFF_X1 ff71 (.CK(clknet_leaf_13_clk_regs_3)); DFF_X1 ff74 (.CK(clknet_leaf_11_clk_regs_1)); DFF_X1 ff75 (.CK(clknet_leaf_11_clk_regs_1)); - DFF_X1 ff76 (.CK(clknet_leaf_15_clk_regs_1)); - DFF_X1 ff77 (.CK(clknet_leaf_13_clk_regs_1)); - DFF_X1 ff78 (.CK(clknet_leaf_12_clk_regs_1)); + DFF_X1 ff76 (.CK(clknet_leaf_15_clk_regs_4)); + DFF_X1 ff77 (.CK(clknet_leaf_13_clk_regs_3)); + DFF_X1 ff78 (.CK(clknet_leaf_12_clk_regs_2)); DFF_X1 ff79 (.CK(clknet_leaf_10_clk_regs)); DFF_X1 ff8 (.CK(clknet_leaf_16_clk_regs)); DFF_X1 ff80 (.CK(clknet_leaf_14_clk_regs)); - DFF_X1 ff81 (.CK(clknet_leaf_12_clk_regs_1)); + DFF_X1 ff81 (.CK(clknet_leaf_12_clk_regs_2)); DFF_X1 ff82 (.CK(clknet_leaf_11_clk_regs_1)); DFF_X1 ff83 (.CK(clknet_leaf_14_clk_regs)); - DFF_X1 ff84 (.CK(clknet_leaf_12_clk_regs_1)); + DFF_X1 ff84 (.CK(clknet_leaf_12_clk_regs_2)); DFF_X1 ff85 (.CK(clknet_leaf_11_clk_regs_1)); DFF_X1 ff86 (.CK(clknet_leaf_11_clk_regs_1)); - DFF_X1 ff87 (.CK(clknet_leaf_15_clk_regs_1)); - DFF_X1 ff88 (.CK(clknet_leaf_13_clk_regs_1)); - DFF_X1 ff89 (.CK(clknet_leaf_12_clk_regs_1)); + DFF_X1 ff87 (.CK(clknet_leaf_15_clk_regs_4)); + DFF_X1 ff88 (.CK(clknet_leaf_13_clk_regs_3)); + DFF_X1 ff89 (.CK(clknet_leaf_12_clk_regs_2)); DFF_X1 ff9 (.CK(clknet_leaf_11_clk_regs_1)); - DFF_X1 ff92 (.CK(clknet_leaf_15_clk_regs_1)); + DFF_X1 ff92 (.CK(clknet_leaf_15_clk_regs_4)); DFF_X1 ff93 (.CK(clknet_leaf_14_clk_regs)); - DFF_X1 ff94 (.CK(clknet_leaf_12_clk_regs_1)); + DFF_X1 ff94 (.CK(clknet_leaf_12_clk_regs_2)); DFF_X1 ff95 (.CK(clknet_leaf_11_clk_regs_1)); - DFF_X1 ff96 (.CK(clknet_leaf_15_clk_regs_1)); - DFF_X1 ff97 (.CK(clknet_leaf_12_clk_regs_1)); + DFF_X1 ff96 (.CK(clknet_leaf_15_clk_regs_4)); + DFF_X1 ff97 (.CK(clknet_leaf_12_clk_regs_2)); DFF_X1 ff98 (.CK(clknet_leaf_11_clk_regs_1)); DFF_X1 ff99 (.CK(clknet_leaf_11_clk_regs_1)); - hier_block h1 (.clknet_leaf_15_clk_regs_i(clknet_leaf_15_clk_regs_1), - .clknet_leaf_13_clk_regs_i(clknet_leaf_13_clk_regs_1), - .clknet_leaf_12_clk_regs_i(clknet_leaf_12_clk_regs_1), + hier_block h1 (.clknet_leaf_15_clk_regs_i(clknet_leaf_15_clk_regs_4), + .clknet_leaf_13_clk_regs_i(clknet_leaf_13_clk_regs_3), + .clknet_leaf_12_clk_regs_i(clknet_leaf_12_clk_regs_2), .clknet_leaf_11_clk_regs_i(clknet_leaf_11_clk_regs_1)); array_tile inst_0 (.clk(clknet_1_0__leaf_clk)); endmodule diff --git a/src/dbSta/test/escape_slash_hier.spefok b/src/dbSta/test/escape_slash_hier.spefok index 0c5a3a2a92e..ddcafd97a19 100644 --- a/src/dbSta/test/escape_slash_hier.spefok +++ b/src/dbSta/test/escape_slash_hier.spefok @@ -243,34 +243,34 @@ clk I 19 clknet_1_0__leaf_clk_1:3 clknet_1_0__leaf_clk_1:1 0.00201118 *END -*D_NET clknet_1_1__leaf_clk_1 0.451199 +*D_NET clknet_1_1__leaf_clk_2 0.451199 *CONN *I gclk1:CK I *D CLKGATE_X1 *I h1/gclk2:CK I *D CLKGATE_X1 *I clkbuf_1_1__f_clk:Z O *D CLKBUF_X3 *CAP -1 clknet_1_1__leaf_clk_1:0 0.130543 -2 clknet_1_1__leaf_clk_1:1 0.0950564 -3 clknet_1_1__leaf_clk_1:2 0.225599 +1 clknet_1_1__leaf_clk_2:0 0.130543 +2 clknet_1_1__leaf_clk_2:1 0.0950564 +3 clknet_1_1__leaf_clk_2:2 0.225599 *RES -1 clknet_1_1__leaf_clk_1:0 clknet_1_1__leaf_clk_1:0 1e-06 -2 clkbuf_1_1__f_clk:Z clknet_1_1__leaf_clk_1:3 1e-06 -3 clknet_1_1__leaf_clk_1:3 clknet_1_1__leaf_clk_1:4 1e-06 -4 clknet_1_1__leaf_clk_1:4 clknet_1_1__leaf_clk_1:5 1e-06 -5 clknet_1_1__leaf_clk_1:5 clknet_1_1__leaf_clk_1:6 1e-06 -6 clknet_1_1__leaf_clk_1:6 clknet_1_1__leaf_clk_1:0 1e-06 -7 clknet_1_1__leaf_clk_1:1 clknet_1_1__leaf_clk_1:2 0.00391271 -8 h1/gclk2:CK clknet_1_1__leaf_clk_1:8 1e-06 -9 clknet_1_1__leaf_clk_1:8 clknet_1_1__leaf_clk_1:9 1e-06 -10 clknet_1_1__leaf_clk_1:9 clknet_1_1__leaf_clk_1:10 1e-06 -11 clknet_1_1__leaf_clk_1:10 clknet_1_1__leaf_clk_1:11 1e-06 -12 clknet_1_1__leaf_clk_1:11 clknet_1_1__leaf_clk_1:1 1e-06 -13 gclk1:CK clknet_1_1__leaf_clk_1:13 1e-06 -14 clknet_1_1__leaf_clk_1:13 clknet_1_1__leaf_clk_1:14 1e-06 -15 clknet_1_1__leaf_clk_1:14 clknet_1_1__leaf_clk_1:15 1e-06 -16 clknet_1_1__leaf_clk_1:15 clknet_1_1__leaf_clk_1:16 1e-06 -17 clknet_1_1__leaf_clk_1:16 clknet_1_1__leaf_clk_1:2 1e-06 -18 clknet_1_1__leaf_clk_1:2 clknet_1_1__leaf_clk_1:0 0.0053734 +1 clknet_1_1__leaf_clk_2:0 clknet_1_1__leaf_clk_2:0 1e-06 +2 clkbuf_1_1__f_clk:Z clknet_1_1__leaf_clk_2:3 1e-06 +3 clknet_1_1__leaf_clk_2:3 clknet_1_1__leaf_clk_2:4 1e-06 +4 clknet_1_1__leaf_clk_2:4 clknet_1_1__leaf_clk_2:5 1e-06 +5 clknet_1_1__leaf_clk_2:5 clknet_1_1__leaf_clk_2:6 1e-06 +6 clknet_1_1__leaf_clk_2:6 clknet_1_1__leaf_clk_2:0 1e-06 +7 clknet_1_1__leaf_clk_2:1 clknet_1_1__leaf_clk_2:2 0.00391271 +8 h1/gclk2:CK clknet_1_1__leaf_clk_2:8 1e-06 +9 clknet_1_1__leaf_clk_2:8 clknet_1_1__leaf_clk_2:9 1e-06 +10 clknet_1_1__leaf_clk_2:9 clknet_1_1__leaf_clk_2:10 1e-06 +11 clknet_1_1__leaf_clk_2:10 clknet_1_1__leaf_clk_2:11 1e-06 +12 clknet_1_1__leaf_clk_2:11 clknet_1_1__leaf_clk_2:1 1e-06 +13 gclk1:CK clknet_1_1__leaf_clk_2:13 1e-06 +14 clknet_1_1__leaf_clk_2:13 clknet_1_1__leaf_clk_2:14 1e-06 +15 clknet_1_1__leaf_clk_2:14 clknet_1_1__leaf_clk_2:15 1e-06 +16 clknet_1_1__leaf_clk_2:15 clknet_1_1__leaf_clk_2:16 1e-06 +17 clknet_1_1__leaf_clk_2:16 clknet_1_1__leaf_clk_2:2 1e-06 +18 clknet_1_1__leaf_clk_2:2 clknet_1_1__leaf_clk_2:0 0.0053734 *END *D_NET clknet_0_h1\/gclk5 7.11161 diff --git a/src/dbSta/test/escape_slash_hier.vok b/src/dbSta/test/escape_slash_hier.vok index b301bcbfb6c..36fe493a3f0 100644 --- a/src/dbSta/test/escape_slash_hier.vok +++ b/src/dbSta/test/escape_slash_hier.vok @@ -1,7 +1,7 @@ module multi_sink (clk); input clk; - wire clknet_1_1__leaf_clk_1; + wire clknet_1_1__leaf_clk_2; wire clknet_1_0__leaf_clk_1; wire gclk1; wire gclk3; @@ -64,7 +64,7 @@ module multi_sink (clk); CLKBUF_X3 clkbuf_1_0__f_gclk4 (.A(clknet_0_gclk4), .Z(clknet_1_0__leaf_gclk4)); CLKBUF_X3 clkbuf_1_1__f_clk (.A(delaynet_6_core), - .Z(clknet_1_1__leaf_clk_1)); + .Z(clknet_1_1__leaf_clk_2)); CLKBUF_X3 clkbuf_2_0__f_gclk1 (.A(clknet_0_gclk1), .Z(clknet_2_0__leaf_gclk1)); CLKBUF_X3 clkbuf_2_0__f_gclk3 (.A(clknet_0_gclk3), @@ -235,13 +235,13 @@ module multi_sink (clk); DFF_X1 ff285 (.CK(clknet_2_0__leaf_gclk3)); DFF_X1 ff286 (.CK(clknet_2_2__leaf_gclk3)); DFF_X1 ff287 (.CK(clknet_2_1__leaf_gclk3)); - CLKGATE_X1 gclk1 (.CK(clknet_1_1__leaf_clk_1), + CLKGATE_X1 gclk1 (.CK(clknet_1_1__leaf_clk_2), .GCK(gclk1)); CLKGATE_X1 gclk3 (.CK(clknet_1_0__leaf_gclk4), .GCK(gclk3)); CLKGATE_X1 gclk4 (.CK(clknet_1_0__leaf_clk_1), .GCK(gclk4)); - hier_block h1 (.clknet_1_1__leaf_clk_i(clknet_1_1__leaf_clk_1), + hier_block h1 (.clknet_1_1__leaf_clk_i(clknet_1_1__leaf_clk_2), .clknet_1_0__leaf_clk_i(clknet_1_0__leaf_clk_1)); endmodule module hier_block (clknet_1_1__leaf_clk_i, From 7efcf70dd4c86b393a462b030bca773863c82c2b Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Mon, 16 Mar 2026 11:41:57 +0900 Subject: [PATCH 10/11] odb: remove unreachable return after logger->error() logger->error() throws internally, making the subsequent return statement dead code. Signed-off-by: Jaehyun Kim --- src/odb/src/db/dbModNet.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/odb/src/db/dbModNet.cpp b/src/odb/src/db/dbModNet.cpp index b51e6434078..3b561a980cd 100644 --- a/src/odb/src/db/dbModNet.cpp +++ b/src/odb/src/db/dbModNet.cpp @@ -614,7 +614,6 @@ void dbModNet::checkSanityNameCollision() const getHierarchicalName(), module->getName(), net->getConstName()); - return; } } } From 0acbc69a224a61a81880fbdf197dcea075d9eda1 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Mon, 16 Mar 2026 16:15:43 +0900 Subject: [PATCH 11/11] =?UTF-8?q?odb:=20tighten=20sanity=20check=20?= =?UTF-8?q?=E2=80=94=20null=20relationship=20is=20not=20proof=20of=20safet?= =?UTF-8?q?y?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, checkSanityNameCollision() suppressed the collision error when findRelatedNet() returned nullptr, treating an unresolved relationship as "safe." This is incorrect: a null result means the relationship cannot be determined, not that the names are compatible. Now only suppress when the hierarchical object positively resolves back to the SAME flat net. Add two unit tests covering bare ModNet and bare ModBTerm collision scenarios. Signed-off-by: Jaehyun Kim --- src/odb/src/db/dbModNet.cpp | 13 +++++-- src/odb/src/db/dbNet.cpp | 34 +++++++++++------ src/odb/test/cpp/BUILD | 5 +-- src/odb/test/cpp/TestDbNet.cpp | 68 +++++++++++++++++++++++++++++++++- 4 files changed, 100 insertions(+), 20 deletions(-) diff --git a/src/odb/src/db/dbModNet.cpp b/src/odb/src/db/dbModNet.cpp index 3b561a980cd..cd0ce43dc53 100644 --- a/src/odb/src/db/dbModNet.cpp +++ b/src/odb/src/db/dbModNet.cpp @@ -600,10 +600,17 @@ void dbModNet::checkSanityNameCollision() const } } if (!associated) { - // Cross-check: if this ModNet's findRelatedNet returns - // the same flat net or nullptr, they're the same signal. + // Suppress when this ModNet positively resolves to the same + // flat net. When unresolvable (nullptr), suppress only if this + // ModNet has connections -- likely a legitimate but unresolvable + // hierarchical pairing. A disconnected orphan IS a collision. dbNet* my_related = findRelatedNet(); - if (my_related == nullptr || my_related == net) { + if (my_related == net) { + continue; + } + if (my_related == nullptr + && (!getITerms().empty() || !getBTerms().empty() + || !getModITerms().empty() || !getModBTerms().empty())) { continue; } utl::Logger* logger = getImpl()->getLogger(); diff --git a/src/odb/src/db/dbNet.cpp b/src/odb/src/db/dbNet.cpp index ba59567f1d5..c0badc2e5ec 100644 --- a/src/odb/src/db/dbNet.cpp +++ b/src/odb/src/db/dbNet.cpp @@ -2792,26 +2792,38 @@ void dbNet::checkSanityNameCollision() const } } - // Cross-check from the ModNet side: if the matching ModNet's related - // flat net is this net or nullptr (unresolvable), they're the same signal. - // Only flag when it positively resolves to a DIFFERENT flat net. + // Cross-check from the ModNet side. Suppress when the matching + // hierarchical object positively resolves back to THIS flat net. + // When unresolvable (nullptr), suppress only if the ModNet has some + // connections -- likely a legitimate but unresolvable hierarchical + // pairing. A totally disconnected (orphan) ModNet IS a collision. + auto has_connections = [](dbModNet* mn) { + return !mn->getITerms().empty() || !mn->getBTerms().empty() + || !mn->getModITerms().empty() || !mn->getModBTerms().empty(); + }; + dbModNet* matching_modnet = module->getModNet(base_name); if (matching_modnet) { dbNet* other = matching_modnet->findRelatedNet(); - if (other == nullptr || other == this) { + if (other == this) { + return; + } + if (other == nullptr && has_connections(matching_modnet)) { return; } } else { - // Only ModBTerm matches — check its ModNet + // Only ModBTerm matches -- check its ModNet dbModBTerm* matching_modbterm = module->findModBTerm(base_name); if (matching_modbterm) { dbModNet* bt_modnet = matching_modbterm->getModNet(); - if (bt_modnet == nullptr) { - return; - } - dbNet* other = bt_modnet->findRelatedNet(); - if (other == nullptr || other == this) { - return; + if (bt_modnet != nullptr) { + dbNet* other = bt_modnet->findRelatedNet(); + if (other == this) { + return; + } + if (other == nullptr && has_connections(bt_modnet)) { + return; + } } } } diff --git a/src/odb/test/cpp/BUILD b/src/odb/test/cpp/BUILD index 0ef26eb17b0..979ebaf1e3e 100644 --- a/src/odb/test/cpp/BUILD +++ b/src/odb/test/cpp/BUILD @@ -207,10 +207,7 @@ cc_test( "TestDbWire.cc", "TestPolygonalFloorplan.cc", ], - args = [ - # Exclude failing TestDbNet tests (ModNet functionality not fully working) - "--gtest_filter=-TestDbNet.FindRelatedModNetsComplex:TestDbNet.FindRelatedModNetsNone:TestDbNet.FindRelatedModNetsClearsSet:TestDbNet.RenameWithModNetInHighestHier:TestDbNet.RenameWithModNetNoHier", - ], + args = [], data = [ "//src/odb/test:regression_resources", "//src/odb/test/data/sky130hd:lef-test-data", diff --git a/src/odb/test/cpp/TestDbNet.cpp b/src/odb/test/cpp/TestDbNet.cpp index f78f55046df..b4510523003 100644 --- a/src/odb/test/cpp/TestDbNet.cpp +++ b/src/odb/test/cpp/TestDbNet.cpp @@ -1,4 +1,5 @@ #include +#include #include #include "gtest/gtest.h" @@ -17,10 +18,19 @@ class TestDbNet : public tst::Fixture std::set expected_modnets; }; + struct SingleModuleCollision + { + dbModule* module = nullptr; + dbModInst* mod_inst = nullptr; + dbInst* leaf_inst = nullptr; + dbNet* flat_net = nullptr; + }; + void SetUp() override { - library_ = readLiberty("./Nangate45/Nangate45_typ.lib"); - loadTechAndLib("tech", "Nangate45.lef", "./Nangate45/Nangate45.lef"); + library_ = readLiberty("_main/test/Nangate45/Nangate45_typ.lib"); + loadTechAndLib( + "tech", "Nangate45.lef", "_main/test/Nangate45/Nangate45.lef"); dbChip* chip = dbChip::create(db_.get(), db_->getTech()); block_ = dbBlock::create(chip, "top"); @@ -120,6 +130,32 @@ class TestDbNet : public tst::Fixture return hierarchy; } + SingleModuleCollision SetUpSingleModuleCollision( + const std::string& module_name, + const std::string& inst_name, + const std::string& net_base_name) + { + SingleModuleCollision collision; + db_->setHierarchy(true); + + auto* top_mod = block_->getTopModule(); + collision.module = dbModule::create(block_, module_name.c_str()); + collision.mod_inst + = dbModInst::create(top_mod, collision.module, inst_name.c_str()); + + auto* inv_master = db_->findMaster("INV_X1"); + collision.leaf_inst = dbInst::create(block_, + inv_master, + (inst_name + "_leaf").c_str(), + false, + collision.module); + collision.flat_net + = dbNet::create(block_, (inst_name + "/" + net_base_name).c_str()); + collision.leaf_inst->findITerm("A")->connect(collision.flat_net); + + return collision; + } + dbBlock* block_; sta::LibertyLibrary* library_; }; @@ -208,4 +244,32 @@ TEST_F(TestDbNet, RenameWithModNetNoHier) EXPECT_EQ(net->getName(), "original_name"); } +TEST_F(TestDbNet, FlatNetNameCollisionWithBareModNetThrows) +{ + const auto collision = SetUpSingleModuleCollision("child_mod", "u0", "sig"); + + auto* orphan_modnet = dbModNet::create(collision.module, "tmp_modnet"); + ASSERT_NE(orphan_modnet, nullptr); + orphan_modnet->rename("sig"); + EXPECT_STREQ(orphan_modnet->getConstName(), "sig"); + + EXPECT_THROW(collision.flat_net->checkSanityNameCollision(), + std::runtime_error); + EXPECT_THROW(orphan_modnet->checkSanityNameCollision(), std::runtime_error); +} + +TEST_F(TestDbNet, FlatNetNameCollisionWithBareModBTermThrows) +{ + const auto collision + = SetUpSingleModuleCollision("child_mod_bterm", "u1", "sig"); + + auto* orphan_bterm = dbModBTerm::create(collision.module, "sig"); + ASSERT_NE(orphan_bterm, nullptr); + orphan_bterm->setIoType(dbIoType::INPUT); + EXPECT_EQ(orphan_bterm->getModNet(), nullptr); + + EXPECT_THROW(collision.flat_net->checkSanityNameCollision(), + std::runtime_error); +} + } // namespace odb