Skip to content

odb: Avoid Verilog namespace collisions - #11038

Open
jhkim-pii wants to merge 8 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:secure-replace-bracket
Open

odb: Avoid Verilog namespace collisions#11038
jhkim-pii wants to merge 8 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:secure-replace-bracket

Conversation

@jhkim-pii

Copy link
Copy Markdown
Contributor

Summary

  • Add more bracket replacement codes in missing places to avoid bracket escaping.
  • Prevent Verilog namespace collisions between nets, ports, and instances.

Changes

  1. Move replaceBracketsWithUnderscores to the shared ODB utility API and reuse it from dbSta and buffer insertion.
  2. Make hierarchy base name extraction escape-aware and preserve escaped local delimiters through generated-name validation and creation.
  3. Apply scoped uniqueness checks to generated net, port, and instance names, including parsed leaf instances and concrete top-level BTerms.
  4. Separate exact BTerm association from corresponding flat-net handling so unrelated same-base name nets remain collisions.

Related

Share bracket sanitization between hierarchical connection and buffer insertion so generated scalar names remain valid Verilog identifiers.

Make generated net and instance names mutually unique against ports, nets, and instances within their module scope. Add dbSta, ODB, and resizer regressions for bracketed names and namespace collisions.

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
Check concrete top-level BTerms when generating instance names so a scalar instance cannot reuse an existing port name. Add a focused regression where the BTerm name differs from its backing net, preserving the existing scoped uniqueness behavior for hierarchical modules.

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
Preserve local identifiers containing the hierarchy delimiter when checking generated net and instance names. Derive the local-name offset from the exact parent hierarchy prefix instead of splitting at the final delimiter, and add regressions for escaped instance and ModNet collisions.

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
Use the exact parent module-instance prefix to recover local names after generated-name validation. This preserves escaped hierarchy delimiters and makes scoped instance collision checks cover both leaf and module instances. Extend the ODB, dbSta, and resizer regressions to lock the escaped-name behavior and emitted Verilog.

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
Make basename extraction distinguish hierarchy separators from escaped local delimiters and retain exact block-level leaf-instance checks. Handle top-port collisions according to strict or associated-net naming, preserve BTerm-derived net names, and make bracket sanitization backslash-parity aware. Add regressions for full-path hierarchy connections, parsed instances, escaped delimiters, top ports, and backslash pairs.

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
Require a corresponding flat net to either own the top BTerm or already carry its candidate name before reusing that port identifier. This preserves port-net migration while rejecting unrelated lenient naming calls, with a regression for the unrelated-net case.

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
Distinguish the corresponding flat net used for ModNet creation from the exact BTerm reused during port migration. Name-based association could accept an unrelated net with the same local basename and weaken flat-net collision checks. Pass the moving BTerm explicitly, keep flat-net creation strict, and use escape-aware basename lookup for ModBTerms.

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
Bring secure-replace-bracket up to the current private master before further development. Preserve the existing namespace-collision fixes while incorporating upstream changes through a non-rewriting merge.

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
@jhkim-pii jhkim-pii self-assigned this Jul 31, 2026

@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 enhances hierarchical net and instance naming in ODB to prevent name collisions in Verilog module scopes and correctly handle escaped brackets and delimiters. Key changes include moving and improving the bracket-to-underscore sanitization utility, updating dbBlock::getBaseName to respect escaped delimiters, and adding robust collision checks in makeNewNetName and makeNewInstName. Comprehensive unit tests have also been added to verify these behaviors. The reviewer feedback suggests adding a defensive null check for full_name in dbBlock::getBaseName to prevent potential null pointer dereferences, which is a valid improvement.

Comment thread src/odb/src/db/dbBlock.cpp
@jhkim-pii
jhkim-pii marked this pull request as ready for review July 31, 2026 00:42
@jhkim-pii
jhkim-pii requested review from a team as code owners July 31, 2026 00:42
@oharboe

oharboe commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants