Skip to content

odb: consolidate unique net name APIs into unified makeNewNetName - #9761

Merged
maliberty merged 12 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:secure-fix-net-name-collision
Mar 16, 2026
Merged

maliberty merged 12 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:secure-fix-net-name-collision

Conversation

@openroad-ci

Copy link
Copy Markdown
Member

Fixes #9760

Summary

  • Replace makeNewNetName(dbModInst*) and makeNewModNetName(dbModule*) with a single unified makeNewNetName(dbModule*) that handles both flat net and ModNet creation via a corresponding_flat_net parameter
    • This prevents the use of the old incomplete API, which caused the net name collision issue.
  • Delegate makeUniqueHierName (dbInsertBuffer) and makeUniqueName (dbEditHierarchy) to the unified API, eliminating duplicated local while-loop collision checks
  • Add new sanity checkers for net name collision in dbNet and `dbModNet1
  • Net reduction of 40 lines across 11 files

Test plan

  • All 38 TestInsertBuffer unit tests pass
  • dbSta.check_axioms regression passes
  • All 60 dbSta tests pass
  • Golden files updated for suffix numbering changes (local counter → shared persistent counter)

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>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/odb/src/db/dbInsertBuffer.cpp Outdated

return unique_name;
std::string full
= block_->makeNewNetName(const_cast<dbModule*>(module),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Fixed in 06a93f6 — changed both makeNewNetName and isInternalTo to accept const dbModule*, removing the const_cast.

@github-actions

Copy link
Copy Markdown
Contributor

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>
@github-actions

Copy link
Copy Markdown
Contributor

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>
@jhkim-pii

jhkim-pii commented Mar 14, 2026 •

Copy link
Copy Markdown
Contributor

All net name uniquification logic including port punching uses the same global index counter.
-> Rebased regressions.

@github-actions

Copy link
Copy Markdown
Contributor

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>
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

…-collision

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Comment thread src/odb/src/db/dbModNet.cpp Outdated
getHierarchicalName(),
module->getName(),
net->getConstName());
return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[gpt-5.4 xhigh] return; after logger->error() is unreachable — logger->error() throws internally. This is dead code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 7efcf70.

logger->error() throws internally, making the subsequent return
statement dead code.

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@jhkim-pii

Copy link
Copy Markdown
Contributor

PR-head fail is a CI glitch.

@jhkim-pii

jhkim-pii commented Mar 16, 2026 •

Copy link
Copy Markdown
Contributor

@jhkim-pii
jhkim-pii requested a review from maliberty March 16, 2026 04:12
@openroad-ci
openroad-ci force-pushed the secure-fix-net-name-collision branch from bff1ded to c54dc78 Compare March 16, 2026 07:20

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions


auto* orphan_modnet = dbModNet::create(collision.module, "tmp_modnet");
ASSERT_NE(orphan_modnet, nullptr);
orphan_modnet->rename("sig");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

@openroad-ci
openroad-ci force-pushed the secure-fix-net-name-collision branch from c54dc78 to 06d7d3a Compare March 16, 2026 07:28

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

orphan_modnet->rename("sig");
EXPECT_STREQ(orphan_modnet->getConstName(), "sig");

EXPECT_THROW(collision.flat_net->checkSanityNameCollision(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@openroad-ci
openroad-ci force-pushed the secure-fix-net-name-collision branch from 06d7d3a to 198b72e Compare March 16, 2026 08:17
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@openroad-ci
openroad-ci force-pushed the secure-fix-net-name-collision branch from 198b72e to e83ec10 Compare March 16, 2026 08:30
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@openroad-ci
openroad-ci force-pushed the secure-fix-net-name-collision branch from e83ec10 to 2edf92e Compare March 16, 2026 09:06
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>
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@openroad-ci
openroad-ci force-pushed the secure-fix-net-name-collision branch from 2edf92e to 0acbc69 Compare March 16, 2026 09:17
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@jhkim-pii

Copy link
Copy Markdown
Contributor

What This PR Does

Fixes 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 73f3aafdd6)

dbBlock::makeNewNetName() only checked flat net uniqueness via findNet(), missing ModNet and ModBTerm names in the target module scope.

Concrete failure path:

  1. SplitLoadMove calls insertBufferBeforeLoads with default net name "net" in a submodule
  2. Submodule already has a port (ModBTerm/ModNet) named "net"
  3. makeNewNetName() checks findNet("sub0/net") — no flat net collision
  4. New flat net "sub0/net" is created, colliding with existing ModNet "net"
  5. Emitted Verilog has duplicate wire declarations → CTS LEC failure

Fix: Add ModNet + ModBTerm checks to the exists lambda. Add checkSanityNameCollision() assertions in both dbNet::create() and dbModNet::create().

The Consolidation (commit 5c67f15198)

ODB had 4 functions doing essentially the same job with inconsistent collision logic:

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*)

@maliberty
maliberty merged commit 9b0caf1 into The-OpenROAD-Project:master Mar 16, 2026
12 checks passed
@maliberty
maliberty deleted the secure-fix-net-name-collision branch March 16, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

odb: net name collision in makeNewNetName causes Verilog LEC failure (sky130hd/microwatt)

3 participants