Conversation
Signed-off-by: Abdulrasheed Abdulmajeed <miloboy188@gmail.com>
There was a problem hiding this comment.
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.
| 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_++; | ||
| } |
There was a problem hiding this comment.
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_++;
}
}
Summary
Adds the unchecked LEF/LIB area-consistency validation from #4872 to
check_ip.Changes
area.Validation
git diff --checkpasses.check_ip_liberty_pinspass/fail test.Part of #4872