From 794f7ffde03a43effd82a63b44201d8ace21d7e9 Mon Sep 17 00:00:00 2001 From: Abdulrasheed Abdulmajeed Date: Sat, 3 Oct 2026 12:20:35 +0100 Subject: [PATCH] dbSta: check LEF and Liberty area consistency Signed-off-by: Abdulrasheed Abdulmajeed --- src/dbSta/include/db_sta/IpChecker.hh | 3 ++- src/dbSta/src/IpChecker.cc | 22 ++++++++++++++++++++++ src/dbSta/test/check_ip_liberty_pins.lef | 23 +++++++++++++++++++++++ src/dbSta/test/check_ip_liberty_pins.lib | 12 ++++++++++++ src/dbSta/test/check_ip_liberty_pins.tcl | 1 + 5 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/dbSta/include/db_sta/IpChecker.hh b/src/dbSta/include/db_sta/IpChecker.hh index 5ec6eed242e..b1524c71080 100644 --- a/src/dbSta/include/db_sta/IpChecker.hh +++ b/src/dbSta/include/db_sta/IpChecker.hh @@ -32,6 +32,7 @@ namespace sta { // LEF-CHK-010b: Pin minimum area // LEF/LIB-CHK-011: Pin direction matches Liberty // LEF/LIB-CHK-012: LEF macros and signal pins exist in Liberty +// LEF/LIB-CHK-013: LEF and Liberty cell areas match class IpChecker { @@ -90,7 +91,7 @@ class IpChecker // LEF-CHK-010b: Pin minimum area void checkPinMinArea(odb::dbMaster* master); - // LEF/LIB-CHK-011-012: Check Liberty pin presence and direction + // LEF/LIB-CHK-011-013: Check Liberty pin presence, direction, and area void checkLibertyPins(odb::dbMaster* master); // Helper: Check if a pin shape has at least one accessible edge diff --git a/src/dbSta/src/IpChecker.cc b/src/dbSta/src/IpChecker.cc index 00b4ab7c1c6..8eb1c26acd3 100644 --- a/src/dbSta/src/IpChecker.cc +++ b/src/dbSta/src/IpChecker.cc @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -792,6 +793,27 @@ void IpChecker::checkLibertyPins(odb::dbMaster* master) return; } + odb::dbTech* tech = db_->getTech(); + if (tech != nullptr) { + const double dbu_per_micron = tech->getDbUnitsPerMicron(); + const double lef_area + = static_cast(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_++; + } + } + for (odb::dbMTerm* mterm : master->getMTerms()) { if (mterm->getSigType().isSupply()) { continue; diff --git a/src/dbSta/test/check_ip_liberty_pins.lef b/src/dbSta/test/check_ip_liberty_pins.lef index f41fcefe56f..bf9ac9fa1fa 100644 --- a/src/dbSta/test/check_ip_liberty_pins.lef +++ b/src/dbSta/test/check_ip_liberty_pins.lef @@ -135,4 +135,27 @@ MACRO lef_lib_direction_mismatch END VDD END lef_lib_direction_mismatch +MACRO lef_lib_area_mismatch + CLASS BLOCK ; + ORIGIN 0 0 ; + SIZE 1.000 BY 1.000 ; + PIN A + DIRECTION INPUT ; + USE SIGNAL ; + ANTENNAMODEL OXIDE1 ; + PORT + LAYER M1 ; + RECT 0.100 0.100 0.300 0.300 ; + END + END A + PIN VDD + DIRECTION INOUT ; + USE POWER ; + PORT + LAYER M1 ; + RECT 0.000 0.000 1.000 0.200 ; + END + END VDD +END lef_lib_area_mismatch + END LIBRARY diff --git a/src/dbSta/test/check_ip_liberty_pins.lib b/src/dbSta/test/check_ip_liberty_pins.lib index e306cc33dc3..7663610429f 100644 --- a/src/dbSta/test/check_ip_liberty_pins.lib +++ b/src/dbSta/test/check_ip_liberty_pins.lib @@ -45,4 +45,16 @@ library (check_ip_liberty_pins) { voltage_name : VDD; } } + + cell (lef_lib_area_mismatch) { + area : 2; + pin (A) { + capacitance : 0.001; + direction : input; + } + pg_pin (VDD) { + pg_type : primary_power; + voltage_name : VDD; + } + } } diff --git a/src/dbSta/test/check_ip_liberty_pins.tcl b/src/dbSta/test/check_ip_liberty_pins.tcl index d62362ecc4b..a5a8794b105 100644 --- a/src/dbSta/test/check_ip_liberty_pins.tcl +++ b/src/dbSta/test/check_ip_liberty_pins.tcl @@ -27,5 +27,6 @@ expect_check_ip_pass lef_lib_pins_match expect_check_ip_fail lef_lib_pin_missing expect_check_ip_fail lef_lib_cell_missing expect_check_ip_fail lef_lib_direction_mismatch +expect_check_ip_fail lef_lib_area_mismatch puts "pass"