Skip to content

dbSta: check LEF and Liberty area consistency - #11620

Open
mahjiid wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
mahjiid:fix/check-ip-lef-lib-area
Open

mahjiid wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
mahjiid:fix/check-ip-lef-lib-area

Conversation

@mahjiid

@mahjiid mahjiid commented Oct 3, 2026

Copy link
Copy Markdown

Summary

Adds the unchecked LEF/LIB area-consistency validation from #4872 to check_ip.

Changes

  • Compute each LEF macro's physical area from its database width/height and DBU scale.
  • Compare it with the matching Liberty cell area.
  • Allow a small 0.1% tolerance to avoid floating-point representation noise.
  • Report an IP-check warning when the values disagree.
  • Extend the existing LEF/Liberty regression fixture with an intentional 1.0 vs 2.0 area mismatch.

Validation

  • git diff --check passes.
  • Commit includes DCO sign-off.
  • Regression is integrated into the existing check_ip_liberty_pins pass/fail test.
  • A full local OpenROAD build was not run because the Windows host does not have the OpenROAD C++ build toolchain installed; CI should exercise the existing registered test.

Part of #4872

Signed-off-by: Abdulrasheed Abdulmajeed <miloboy188@gmail.com>
@mahjiid
mahjiid requested a review from a team as a code owner October 3, 2026 11:20
@mahjiid
mahjiid requested a review from maliberty October 3, 2026 11:20
@github-actions github-actions Bot added the size/S label Oct 3, 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 introduces a new check (LEF/LIB-CHK-013) to verify that cell areas match between LEF and Liberty files, implementing the comparison logic in IpChecker::checkLibertyPins and adding corresponding test cases. Feedback on the implementation highlights a potential division-by-zero vulnerability if dbu_per_micron is zero, suggesting a guard condition to make the code more robust.

Comment on lines +798 to +814
const double dbu_per_micron = tech->getDbUnitsPerMicron();
const double lef_area
= static_cast<double>(master->getWidth()) * master->getHeight()
/ (dbu_per_micron * dbu_per_micron);
const double liberty_area = liberty_cell->area();
const double area_tolerance = std::max(1e-6, lef_area * 1e-3);

if (std::abs(lef_area - liberty_area) > area_tolerance) {
logger_->warn(utl::CHK,
122,
"Master {} area mismatch between LEF ({:.6f}) and "
"Liberty ({:.6f})",
master_name,
lef_area,
liberty_area);
warning_count_++;
}

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

If dbu_per_micron is 0 (which can happen if the database units are not properly initialized or defined in the LEF), dividing by it will result in a division-by-zero error, producing inf or nan values. Adding a guard to ensure dbu_per_micron > 0 before performing the division is a safer and more robust approach.

    const double dbu_per_micron = tech->getDbUnitsPerMicron();
    if (dbu_per_micron > 0) {
      const double lef_area
          = static_cast<double>(master->getWidth()) * master->getHeight()
            / (dbu_per_micron * dbu_per_micron);
      const double liberty_area = liberty_cell->area();
      const double area_tolerance = std::max(1e-6, lef_area * 1e-3);

      if (std::abs(lef_area - liberty_area) > area_tolerance) {
        logger_->warn(utl::CHK,
                      122,
                      "Master {} area mismatch between LEF ({:.6f}) and "
                      "Liberty ({:.6f})",
                      master_name,
                      lef_area,
                      liberty_area);
        warning_count_++;
      }
    }

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.

1 participant