Repository navigation
odb: consolidate unique net name APIs into unified makeNewNetName - #9761
Conversation
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 <jhkim@precisioninno.com>
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
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 <jhkim@precisioninno.com>
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
There was a problem hiding this comment.
Code Review
This pull request is a solid refactoring that consolidates the logic for creating unique net names into a single makeNewNetName API. This change effectively addresses the net name collision issue described in issue #9760 by ensuring that checks for ModNet and ModBTerm collisions are always performed. The delegation of uniqueness checks from dbInsertBuffer and dbEditHierarchy to this new unified API is a great simplification and reduces code duplication. The addition of new sanity checkers for net name collisions in dbNet and dbModNet is also a valuable improvement for future database integrity. The changes are well-implemented and the new test case provides good coverage for the fix.
|
|
||
| return unique_name; | ||
| std::string full | ||
| = block_->makeNewNetName(const_cast<dbModule*>(module), |
There was a problem hiding this comment.
The use of const_cast here suggests a potential improvement in the const-correctness of the called API. The makeUniqueHierName method is const, so its module parameter is a const dbModule*. The const_cast is necessary because makeNewNetName currently accepts a non-const dbModule*.
An analysis of makeNewNetName and its dependency dbNet::isInternalTo suggests they do not modify the dbModule object. To improve code quality and avoid const_cast, consider changing the signature of dbBlock::makeNewNetName (and dbNet::isInternalTo) to accept a const dbModule*. This would allow removing this const_cast and improve overall const-correctness.
There was a problem hiding this comment.
Good catch. Fixed in 06a93f6 — changed both makeNewNetName and isInternalTo to accept const dbModule*, removing the const_cast.
|
clang-tidy review says "All clean, LGTM! 👍" |
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 <jhkim@precisioninno.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
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 <jeonghyun@openroad.tools> Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
|
All net name uniquification logic including port punching uses the same global index counter. |
|
clang-tidy review says "All clean, LGTM! 👍" |
…ash_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 <jeonghyun@openroad.tools> Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
…-collision Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
| getHierarchicalName(), | ||
| module->getName(), | ||
| net->getConstName()); | ||
| return; |
There was a problem hiding this comment.
[gpt-5.4 xhigh] return; after logger->error() is unreachable — logger->error() throws internally. This is dead code.
logger->error() throws internally, making the subsequent return statement dead code. Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
|
PR-head fail is a CI glitch. |
|
QoR impact has been checked in this ORFS PR -> No QoR impact. |
bff1ded to
c54dc78
Compare
|
|
||
| auto* orphan_modnet = dbModNet::create(collision.module, "tmp_modnet"); | ||
| ASSERT_NE(orphan_modnet, nullptr); | ||
| orphan_modnet->rename("sig"); |
There was a problem hiding this comment.
warning: no header providing "std::runtime_error" is directly included [misc-include-cleaner]
src/odb/test/cpp/TestDbNet.cpp:1:
- #include <string>
+ #include <stdexcept>
+ #include <string>c54dc78 to
06d7d3a
Compare
| orphan_modnet->rename("sig"); | ||
| EXPECT_STREQ(orphan_modnet->getConstName(), "sig"); | ||
|
|
||
| EXPECT_THROW(collision.flat_net->checkSanityNameCollision(), |
There was a problem hiding this comment.
warning: no header providing "std::runtime_error" is directly included [misc-include-cleaner]
src/odb/test/cpp/TestDbNet.cpp:1:
- #include <string>
+ #include <stdexcept>
+ #include <string>|
clang-tidy review says "All clean, LGTM! 👍" |
06d7d3a to
198b72e
Compare
|
clang-tidy review says "All clean, LGTM! 👍" |
198b72e to
e83ec10
Compare
|
clang-tidy review says "All clean, LGTM! 👍" |
e83ec10 to
2edf92e
Compare
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 <jhkim@precisioninno.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
2edf92e to
0acbc69
Compare
|
clang-tidy review says "All clean, LGTM! 👍" |
What This PR DoesFixes a net name collision bug in hierarchical designs that caused Verilog LEC failure (sky130hd/microwatt), then consolidates 4 scattered net-naming functions into one unified API. The Bug (commit
|
| Function | Location | Problem |
|---|---|---|
makeNewNetName |
dbBlock.cpp | Missing ModNet/ModBTerm check (the bug) |
makeNewModNetName |
dbBlock.cpp | Correct, but separate API |
makeUniqueHierName |
dbInsertBuffer.cpp | Local while-loop, partial checks |
makeUniqueName |
dbEditHierarchy.cc | Local while-loop, ModBTerm only |
After: Single dbBlock::makeNewNetName(dbModule*, base_name, uniquify, corresponding_flat_net):
corresponding_flat_net = nullptr→ strict mode (for flat net creation)corresponding_flat_net = net→ lenient mode (for ModNet creation, excludes the corresponding flat net from collision check)
All 4 callers now delegate to this one function.
Files Changed (core logic)
| File | What changed |
|---|---|
db.h |
New unified makeNewNetName signature, remove old declarations |
dbBlock.cpp |
Single implementation replacing two, unified exists lambda |
dbNet.cpp |
Use new API + add checkSanityNameCollision() |
dbModNet.cpp |
Use new API + add checkSanityNameCollision() |
dbInsertBuffer.cpp |
Delegate makeUniqueHierName to unified API |
dbEditHierarchy.cc |
Delegate makeUniqueName to unified API |
dbNetwork.cc |
Update caller signature (dbModInst* → dbModule*) |
Fixes #9760
Summary
makeNewNetName(dbModInst*)andmakeNewModNetName(dbModule*)with a single unifiedmakeNewNetName(dbModule*)that handles both flat net and ModNet creation via acorresponding_flat_netparametermakeUniqueHierName(dbInsertBuffer) andmakeUniqueName(dbEditHierarchy) to the unified API, eliminating duplicated local while-loop collision checksdbNetand `dbModNet1Test plan
dbSta.check_axiomsregression passes