From 1ce139408d656904bf2f8e9e46ab0e4d7576c9bc Mon Sep 17 00:00:00 2001 From: Peter Gadfort Date: Wed, 15 May 2024 10:13:42 -0400 Subject: [PATCH 1/2] odb: provide dbuToMicrons for various datatypes to avoid casting errors Signed-off-by: Peter Gadfort --- src/odb/include/odb/db.h | 5 ++++- src/odb/src/db/dbBlock.cpp | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/odb/include/odb/db.h b/src/odb/include/odb/db.h index 89e30ac18f4..d5eadc285ad 100644 --- a/src/odb/include/odb/db.h +++ b/src/odb/include/odb/db.h @@ -1185,7 +1185,10 @@ class dbBlock : public dbObject /// /// Convert a length from database units (DBUs) to microns. /// - double dbuToMicrons(int dbu); + double dbuToMicrons(const int dbu); + double dbuToMicrons(const unsigned int dbu); + double dbuToMicrons(const int64_t dbu); + double dbuToMicrons(const double dbu); /// /// Convert an area from database units squared (DBU^2) to square microns. diff --git a/src/odb/src/db/dbBlock.cpp b/src/odb/src/db/dbBlock.cpp index de736358011..083dec51d27 100644 --- a/src/odb/src/db/dbBlock.cpp +++ b/src/odb/src/db/dbBlock.cpp @@ -2325,6 +2325,24 @@ double dbBlock::dbuToMicrons(const int dbu) return dbu / dbu_micron; } +double dbBlock::dbuToMicrons(const unsigned int dbu) +{ + const double dbu_micron = getTech()->getDbUnitsPerMicron(); + return dbu / dbu_micron; +} + +double dbBlock::dbuToMicrons(const int64_t dbu) +{ + const double dbu_micron = getTech()->getDbUnitsPerMicron(); + return dbu / dbu_micron; +} + +double dbBlock::dbuToMicrons(const double dbu) +{ + const double dbu_micron = getTech()->getDbUnitsPerMicron(); + return dbu / dbu_micron; +} + double dbBlock::dbuAreaToMicrons(const int64_t dbu_area) { const double dbu_micron = getTech()->getDbUnitsPerMicron(); From fe51ff89a96df9f4e2ca284a6fdee9de6b02f8a2 Mon Sep 17 00:00:00 2001 From: Peter Gadfort Date: Wed, 15 May 2024 11:49:00 -0400 Subject: [PATCH 2/2] odb: fix clang-tidy for const in dbuToMicrons Signed-off-by: Peter Gadfort --- src/odb/include/odb/db.h | 8 ++++---- src/odb/src/db/dbBlock.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/odb/include/odb/db.h b/src/odb/include/odb/db.h index d5eadc285ad..036fae4a4c8 100644 --- a/src/odb/include/odb/db.h +++ b/src/odb/include/odb/db.h @@ -1185,10 +1185,10 @@ class dbBlock : public dbObject /// /// Convert a length from database units (DBUs) to microns. /// - double dbuToMicrons(const int dbu); - double dbuToMicrons(const unsigned int dbu); - double dbuToMicrons(const int64_t dbu); - double dbuToMicrons(const double dbu); + double dbuToMicrons(int dbu); + double dbuToMicrons(unsigned int dbu); + double dbuToMicrons(int64_t dbu); + double dbuToMicrons(double dbu); /// /// Convert an area from database units squared (DBU^2) to square microns. diff --git a/src/odb/src/db/dbBlock.cpp b/src/odb/src/db/dbBlock.cpp index 083dec51d27..2a7859197b3 100644 --- a/src/odb/src/db/dbBlock.cpp +++ b/src/odb/src/db/dbBlock.cpp @@ -2319,25 +2319,25 @@ int dbBlock::getDbUnitsPerMicron() return block->_dbu_per_micron; } -double dbBlock::dbuToMicrons(const int dbu) +double dbBlock::dbuToMicrons(int dbu) { const double dbu_micron = getTech()->getDbUnitsPerMicron(); return dbu / dbu_micron; } -double dbBlock::dbuToMicrons(const unsigned int dbu) +double dbBlock::dbuToMicrons(unsigned int dbu) { const double dbu_micron = getTech()->getDbUnitsPerMicron(); return dbu / dbu_micron; } -double dbBlock::dbuToMicrons(const int64_t dbu) +double dbBlock::dbuToMicrons(int64_t dbu) { const double dbu_micron = getTech()->getDbUnitsPerMicron(); return dbu / dbu_micron; } -double dbBlock::dbuToMicrons(const double dbu) +double dbBlock::dbuToMicrons(double dbu) { const double dbu_micron = getTech()->getDbUnitsPerMicron(); return dbu / dbu_micron;