Skip to content

dbSta: fix ObjectId collision between ConcreteCell and dbModule#9674

Open
openroad-ci wants to merge 3 commits intoThe-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:secure-fix-dbnetwork-id
Open

dbSta: fix ObjectId collision between ConcreteCell and dbModule#9674
openroad-ci wants to merge 3 commits intoThe-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:secure-fix-dbnetwork-id

Conversation

@openroad-ci
Copy link
Collaborator

Fixes #9661

Summary

  • Tag ConcreteCell/ConcretePort IDs with CONCRETE_OBJECT_ID (0xF) in dbNetwork::id() to prevent collisions with dbModule IDs (tag 0x8)
  • Guard against top_cell_ in id(Cell*) — it is a ConcreteCell but isConcreteCell() returns false for it, causing a crash when reinterpret_cast is called to dbObject
  • Add regression test TestWriteVerilog.RemoveCellsIdCollision (CMake + Bazel)

Problem

write_verilog -remove_cells silently drops hierarchical module instances due to an ObjectId collision.
CellSet uses CellIdLess (comparing by network_->id(cell)) for ordering.
Two different Cell* types produce overlapping IDs:

  • ConcreteCell (liberty/LEF): raw sequential counter ccell->id_ (0, 1, 2, ...)
  • dbModule (hierarchical): (db_id << 4) | 0x8 (24, 40, 56, ...)

When these IDs collide, CellSet::contains() treats a dbModule as equal to a ConcreteCell, causing writeChild() to silently drop hierarchical instances.

Solution

Introduce a new tag CONCRETE_OBJECT_ID for ConcreteCell and ConcretePort to avoid the ID collision.

Tag allocation

Tag Value Object Type
DBITERM_ID 0x0 dbITerm
DBBTERM_ID 0x1 dbBTerm
DBINST_ID 0x2 dbInst
DBNET_ID 0x3 dbNet
DBMODITERM_ID 0x4 dbModITerm
DBMODBTERM_ID 0x5 dbModBTerm
DBMODINST_ID 0x6 dbModInst
DBMODNET_ID 0x7 dbModNet
DBMODULE_ID 0x8 dbModule
CONCRETE_OBJECT_ID 0xF ConcreteCell, ConcretePort (NEW)

🤖 Generated with Claude Code

@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2026

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

Copy link
Contributor

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

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 aims to resolve an ObjectId collision between ConcreteCell and dbModule that causes hierarchical instances to be dropped during Verilog generation, by introducing unique tags for ConcreteCell and ConcretePort IDs. While the fix for dbNetwork::id(const Cell* cell) is correct, the corresponding fix for dbNetwork::id(const Port* port) is incomplete. It fails to apply the necessary tagging logic to ConcretePort objects when hierarchy is enabled, allowing ID collisions to persist for ports and potentially leading to similar integrity issues in the generated output. Consistent application of the tagging logic across all concrete objects is required to ensure the robustness of the fix.

@jhkim-pii
Copy link
Contributor

jhkim-pii commented Mar 6, 2026

Checking ORFS QoR impact w/ The-OpenROAD-Project/OpenROAD-flow-scripts#3957.

jhkim-pii and others added 3 commits March 7, 2026 09:49
Tag ConcreteCell/ConcretePort IDs with CONCRETE_OBJECT_ID (0xF) in
dbNetwork::id() to prevent collisions with dbModule IDs (tag 0x8).

Previously, ConcreteCell used raw sequential id_ (0,1,2,...) which
could collide with dbModule computed IDs ((db_id << 4) | 0x8),
causing CellSet::contains() to treat different Cell* types as equal.
This led to write_verilog -remove_cells silently dropping hierarchical
module instances.

Also guard against top_cell_ in id(Cell*), which is a ConcreteCell
but isConcreteCell() returns false for it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
@openroad-ci openroad-ci force-pushed the secure-fix-dbnetwork-id branch from 8ce762a to 758a57d Compare March 7, 2026 00:53
@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2026

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

@jhkim-pii jhkim-pii requested a review from maliberty March 7, 2026 04:21
@maliberty
Copy link
Member

I don't see an actual use of this bit? How is it checked?

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.

write_verilog -remove_cells [find_physical_only_masters] omitted some of ALU_* cell instances

3 participants