Skip to content

dpl: fix power-rail detection in getMasterPwrs#10616

Open
gudeh wants to merge 16 commits into
The-OpenROAD-Project:masterfrom
gudeh:dpl-fix-getMasterPwrs
Open

dpl: fix power-rail detection in getMasterPwrs#10616
gudeh wants to merge 16 commits into
The-OpenROAD-Project:masterfrom
gudeh:dpl-fix-getMasterPwrs

Conversation

@gudeh

@gudeh gudeh commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Check rails with cell borders instead of using bbox centers. Previous code would incorrectly collapsed multi-box pins to the cell middle, instead of borders, mislabeling double-height cells.

Type of Change

  • Bug fix

Impact

Private designs do not fail anymore.

Verification

  • I have verified that the local build succeeds (./etc/Build.sh).
  • I have run the relevant tests and they pass.
  • My code follows the repository's formatting guidelines.
  • I have included tests to prevent regressions.
  • I have signed my commits (DCO).

Related Issues

This is one of multiple PRs splitting up PR #10226 to make Negotiation the default algorithm at DPL.

Check rails with cell borders instead of using bbox centers.
Previous code would incorrectly collapsed multi-box pins to the cell middle,
instead of borders, mislabeling double-height cells.

Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
@gudeh gudeh requested a review from a team as a code owner June 8, 2026 19:59
@gudeh gudeh requested a review from osamahammad21 June 8, 2026 19:59
@github-actions github-actions Bot added the size/S label Jun 8, 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 refactors the getMasterPwrs function in src/dpl/src/infrastructure/network.cxx to improve power and ground rail detection. Instead of using the bounding box center of the MPins, it now evaluates individual routing-layer geometries to determine if they touch the cell's top or bottom boundaries. Feedback on this PR includes cleaning up a leftover comment fragment and improving the robustness of the boundary checks by ensuring the pin geometry actually intersects the cell boundaries rather than just checking one-sided inequalities.

Comment thread src/dpl/src/infrastructure/network.cxx Outdated
Comment thread src/dpl/src/infrastructure/network.cxx Outdated
Comment on lines +295 to +300
if (rect.yMin() <= y_cell_bot) {
(is_pwr ? bot_has_pwr : bot_has_gnd) = true;
}
if (rect.yMax() >= y_cell_top) {
(is_pwr ? top_has_pwr : top_has_gnd) = true;
}

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

To prevent potential false positives from out-of-bounds geometries (e.g., geometries completely below y_cell_bot or completely above y_cell_top), it is safer and more robust to verify that the pin geometry actually intersects or touches the respective boundary. This can be achieved by checking that the boundary coordinate lies within the [yMin, yMax] interval of the geometry.

Suggested change
if (rect.yMin() <= y_cell_bot) {
(is_pwr ? bot_has_pwr : bot_has_gnd) = true;
}
if (rect.yMax() >= y_cell_top) {
(is_pwr ? top_has_pwr : top_has_gnd) = true;
}
if (rect.yMin() <= y_cell_bot && rect.yMax() >= y_cell_bot) {
(is_pwr ? bot_has_pwr : bot_has_gnd) = true;
}
if (rect.yMin() <= y_cell_top && rect.yMax() >= y_cell_top) {
(is_pwr ? top_has_pwr : top_has_gnd) = true;
}

gudeh added 5 commits June 10, 2026 13:39
Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
@gudeh

gudeh commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

@eder-matheus @maliberty I believe we can merge this. It's no-op for all our secure-CI designs. The incorrect rail setting only affected tap cells and one TSMC double-height cell, caused by the TSMC PDK encoding wells as power/ground pins.

@gudeh gudeh requested a review from eder-matheus June 12, 2026 14:23
@eder-matheus

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 2136357c15

ℹ️ 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".

@eder-matheus eder-matheus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@gudeh Is this PR resolving the issue you reported in the last F&P meeting? Where he PWR/GND pins were wrongly detected in the negotiation-based DPL when running in the private design?

Comment thread src/dpl/src/infrastructure/network.cxx Outdated
Comment on lines +316 to +317
// std::cout << master->getConstName() << ", height: " << master->getHeight()
// << ", return: top_pwr:" << top_pwr << " bot_pwr:" << bot_pwr << "\n";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remove dead code.

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.

I mean to keep this. This class does not have access to a logger object.

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.

Do you have any suggestion on how to proceed when we want to keep a debugPrint() but we don't have access to the logger?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you just add the Logger to this class? We shouldn't rely on std::cout or similar, just Logger. If you need it here, you should be able to just add it.

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.

I think it is useful to have access to it at Network class. I remember having to use std::cout in the past for other things too.

I included it on the latest commit.

@gudeh

gudeh commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

@gudeh Is this PR resolving the issue you reported in the last F&P meeting? Where he PWR/GND pins were wrongly detected in the negotiation-based DPL when running in the private design?

Yes! Although, this change is actually no-op. Even with internal incorrect values the function was returning the correct value for most cases. It was incorrect for tap cells (which should not matter for DPL, since they are fixed), and for one instance of a private design. I should present further info on the next meeting.

But since this is no-op we should be good to merge, and be able to cover corner cases.

This secure-CI run shows no-op

@gudeh gudeh requested a review from eder-matheus June 17, 2026 20:16

@eder-matheus eder-matheus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me. I'll leave the final approval and merge for @osamahammad21

@osamahammad21 osamahammad21 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@gudeh
Two concerns:

  1. The edge tests (yMin <= y_cell_bot / yMax >= y_cell_top) assume the rail reaches the placement boundary. If a lib draws the rail slightly inside the boundary, the rail is missed and the edge silently becomes Power_UNK. That's probably why the old code had more tolerance. I am not sure if this a real concern or a theoretical one, but at least it is worth a warning .
  2. Downstream, toRailType in NegotiationLegalizer falls back per-edge to a fixed default (UNK bottom→VSS, UNK top→VDD), ignoring the other edge. So if one rail is detected and the other is UNK, you can end up with both edges the same type (e.g. bottom=VDD + top UNK→VDD => power/power). Since rails alternate, the unknown edge should mirror the known one.

@gudeh

gudeh commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author
  1. The edge tests (yMin <= y_cell_bot / yMax >= y_cell_top) assume the rail reaches the placement boundary. If a lib draws the rail slightly inside the boundary, the rail is missed and the edge silently becomes Power_UNK.

From your concern number 1, do you think we should include a small acceptance range?

We should not worry about 2 because this code will be removed with the other PR #10645, where we remove the rail checking from negotiation legalizer and only use the native one from DPL.

@gudeh

gudeh commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

If we include a warning for Power_UNK it happens at least 19 times at dpl tests.

@osamahammad21

Copy link
Copy Markdown
Member
  1. The edge tests (yMin <= y_cell_bot / yMax >= y_cell_top) assume the rail reaches the placement boundary. If a lib draws the rail slightly inside the boundary, the rail is missed and the edge silently becomes Power_UNK.

From your concern number 1, do you think we should include a small acceptance range?

We should not worry about 2 because this code will be removed with the other PR #10645, where we remove the rail checking from negotiation legalizer and only use the native one from DPL.

@gudeh It depends on what the acceptance range would be. I think a reasonable value could be the layer width, but this needs to be verified against the current designs. Tho I am not sure if any of the libraries we have currently may hit that corner case.

It is also worth noting that if the hypothesis is wrong, the designs may still silently pass, since DPL does not currently check the power pins against the physical PDN grid. You may notice we infer the row bottom and top power types from the cells.

@github-actions github-actions Bot added size/M and removed size/S labels Jun 23, 2026
gudeh added 3 commits June 24, 2026 01:00
fix incorrect l values for min and max pwr and gnd by using geometries and properly calculate the pin locations,
avoid fallback to VSS for unknown power type,
include skipping non routing layers

Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
@gudeh

gudeh commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

I rolled back to the previous implementation version (we should not need to worry about item 1 from @osamahammad21) with a few modifications:

Now we skip non-routing layers, and we use geometry to properly calculate the internal pin positions. The previous version even had a comment asking about using geometry or box.

We were also setting as VSS some masters which have undefined power pin shapes. Now they are unk.

I do not observe any issue anymore with a private design which was being mislabeled.

Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
@gudeh gudeh requested a review from osamahammad21 June 24, 2026 21:34
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.

3 participants