Skip to content

Fix/balance pad to core connections#10295

Open
alokkumardalei-wq wants to merge 4 commits intoThe-OpenROAD-Project:masterfrom
alokkumardalei-wq:fix/balance-pad-to-core-connections
Open

Fix/balance pad to core connections#10295
alokkumardalei-wq wants to merge 4 commits intoThe-OpenROAD-Project:masterfrom
alokkumardalei-wq:fix/balance-pad-to-core-connections

Conversation

@alokkumardalei-wq
Copy link
Copy Markdown
Contributor

@alokkumardalei-wq alokkumardalei-wq commented Apr 29, 2026

Fixes #9994.

Problem

-connect_to_pads on add_pdn_ring produces imbalanced pad-to-core ring
connections — e.g. mole99's report of 1 VSS vs 5 VDD per side. Root cause
identified by @gadfort: CoreGrid::setupDirectConnect adds all VDD straps
to the grid component list before any VSS strap. Grid::makeShapes
iterates components in append order and accumulates obstructions, so VSS
straps face a more obstructed environment than VDD and get dropped
disproportionately by core PDN straps.

Fix

In CoreGrid::setupDirectConnect:

  1. Sort iterms within each net by pad lower-left corner (deterministic
    spatial order, identical comparator across nets so position i of
    each net refers to a pad in the same region of the die).
  2. Round-robin across nets when adding straps to the grid. VDD and VSS
    straps now interleave in the grid component list, giving fair
    geometric competition during shape generation.

This is static interleave balance, not deficit-tracking
(success/fail feedback) balance. Chose static interleave because:

  • Localizes the change to one method (no Grid::makeShapes changes)
  • Matches @gadfort's "only impact tests that rely on connectOverPads"
    scope guidance
  • Should be sufficient for mole99's reported 1/5 imbalance

@gadfort: if you'd prefer feedback-driven deficit tracking, happy to
escalate to that as a follow-up PR.

Test results (verified locally)

Built openroad on macOS arm64 with --linkopt=-fuse-ld=lld (Apple ld64
segfaults on link, LLVM's lld works) and ran every affected test:

Test Before After
pads_black_parrot golden mismatch PASS, +2 stripes (metal8 + metal9)
pads_black_parrot_flipchip golden mismatch PASS, +2 stripes (metal8 + metal9)
pads_black_parrot_flipchip_connect_bumps golden mismatch PASS, +2 stripes (metal8 + metal7)
pads_black_parrot_flipchip_connect_overpads golden mismatch PASS, +2 stripes (metal10 vert+horiz)
pads_black_parrot_grid_define golden mismatch PASS, +2 stripes (metal8 + metal9)
pads_black_parrot_limit_connect golden mismatch PASS, +2 stripes (metal7 only)
pads_black_parrot_max_width golden mismatch PASS, +2 stripes (metal7)
pads_black_parrot_no_connect unchanged ✓ unchanged ✓ (control — no -connect_to_pads)
pads_black_parrot_offset golden mismatch PASS, +2 stripes (metal8 + metal9)
pads_black_parrot_straps golden mismatch PASS, +2 stripes (metal8 + metal9)
pads_connect_from_non_pref_edge golden mismatch PASS, +2 stripes (Metal2)

Every change is purely additive — every affected test gains exactly
2 new pad-to-core ring stripes, zero stripes removed, zero geometric
regressions. The pads_black_parrot_no_connect test (the only pads_*
test that doesn't use -connect_to_pads) is unchanged, confirming the
change is correctly scoped.

Why 10 golden file updates and not 1?

@gadfort, you wrote "only impact the tests that rely on the
connectOverPads code". Strictly, my change touches every test using
add_pdn_ring -connect_to_pads or define_pdn_grid -connect_to_pads,
not only the test named connect_overpads. Hence 10 goldens updated,
not 1. Large line counts in the .defok diffs are SWIRES re-shuffling
in the DEF output (the strap order changed, so the SWIRES section is
re-emitted in different order) , not real geometric changes. Each
test's semantic diff against its old golden is just +2 stripes as
shown above; the line shuffle is an artifact of DEF emission order.

If this scope is broader than you intended, happy to discuss narrowing
the change.

Signed-off-by: alokkumardalei-wq <alokkumardalei2@gmail.com>
Signed-off-by: alokkumardalei-wq <alokkumardalei2@gmail.com>
Copy link
Copy Markdown
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 updates the PDN grid setup to improve pad connection distribution by implementing a round-robin approach for VDD and VSS pads, which helps prevent uneven connection density. The code changes also include significant updates to the test files to reflect these routing adjustments. I have reviewed the logic and suggest that the nested loop structure in grid.cpp could be further simplified to improve readability and reduce indentation.

Comment thread src/pdn/src/grid.cpp Outdated
Comment on lines 1366 to 1374
for (size_t i = 0; i < max_count; ++i) {
for (const auto& iterms : per_net_iterms) {
if (i >= iterms.size()) {
continue;
}
auto* iterm = iterms[i];
auto pad_connect = std::make_unique<PadDirectConnectionStraps>(
this, iterm, connect_pad_layers);
if (pad_connect->canConnect()) {
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 nested loop structure for round-robin iteration is clear, but it could be simplified by using a single loop over the maximum size and checking bounds. This would reduce the indentation level and improve readability.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 20ecd0a, split the round-robin into phase 1 (build ordered_iterms interleaved) and phase 2 (create straps from that flat list). Strap-creation loop is now single-level.

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

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

Comment thread src/pdn/src/grid.cpp Outdated
// Spatial sort: same comparator across nets so position i in each net
// refers to a pad in roughly the same region of the die.
std::sort(
iterms.begin(), iterms.end(), [](odb::dbITerm* lhs, odb::dbITerm* rhs) {
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: use a ranges version of this algorithm [modernize-use-ranges]

Suggested change
iterms.begin(), iterms.end(), [](odb::dbITerm* lhs, odb::dbITerm* rhs) {
std::ranges::sort(
iterms,, [](odb::dbITerm* lhs, odb::dbITerm* rhs) {

Comment thread src/pdn/src/grid.cpp
per_net_iterms.push_back(std::move(iterms));
}

size_t max_count = 0;
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 "size_t" is directly included [misc-include-cleaner]

src/pdn/src/grid.cpp:7:

- #include <cstdint>
+ #include <cstddef>
+ #include <cstdint>

Signed-off-by: alokkumardalei-wq <alokkumardalei2@gmail.com>
Signed-off-by: alokkumardalei-wq <alokkumardalei2@gmail.com>
@alokkumardalei-wq alokkumardalei-wq force-pushed the fix/balance-pad-to-core-connections branch from 20ecd0a to ad10f41 Compare April 29, 2026 14:40
@github-actions
Copy link
Copy Markdown
Contributor

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

@maliberty
Copy link
Copy Markdown
Member

@codex review

@maliberty maliberty requested a review from gadfort April 30, 2026 16:35
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

-connect_to_pads only adds sporadic connections

2 participants