Skip to content

Commit fd416f6

Browse files
authored
Merge pull request #8776 from The-OpenROAD-Project-staging/odb-dbuperuu
odb: unify DBUPERMICRON
2 parents 92f9b27 + 3e6b1f5 commit fd416f6

File tree

20 files changed

+128
-124
lines changed

20 files changed

+128
-124
lines changed

src/drt/src/DesignCallBack.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99

1010
namespace drt {
1111

12-
static inline int defdist(odb::dbBlock* block, int x)
13-
{
14-
return x * (double) block->getDefUnits()
15-
/ (double) block->getDbUnitsPerMicron();
16-
}
17-
1812
void DesignCallBack::inDbPreMoveInst(odb::dbInst* db_inst)
1913
{
2014
auto design = router_->getDesign();
@@ -43,9 +37,6 @@ void DesignCallBack::inDbPostMoveInst(odb::dbInst* db_inst)
4337
}
4438
int x, y;
4539
db_inst->getLocation(x, y);
46-
auto block = db_inst->getBlock();
47-
x = defdist(block, x);
48-
y = defdist(block, y);
4940
inst->setOrigin({x, y});
5041
inst->setOrient(db_inst->getOrient());
5142
router_->addInstancePAData(inst);

src/grt/src/GlobalRouter.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ proc set_global_routing_region_adjustment { args } {
4848
utl::error GRT 47 "Missing dbTech."
4949
}
5050
set tech [ord::get_db_tech]
51-
set lef_units [$tech getLefUnits]
51+
set lef_units [$tech getDbUnitsPerMicron]
5252

5353
if { [info exists keys(-layer)] } {
5454
set layer $keys(-layer)

src/gui/src/gui.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ void Gui::saveImage(const std::string& filename,
779779
if (tech == nullptr) {
780780
logger_->error(utl::GUI, 16, "No design loaded.");
781781
}
782-
const double dbu_per_micron = tech->getLefUnits();
782+
const double dbu_per_micron = tech->getDbUnitsPerMicron();
783783

784784
std::string save_cmds;
785785
// build display control commands

src/gui/src/gui.tcl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ proc save_image { args } {
100100
if { $tech == "NULL" } {
101101
utl::error GUI 17 "No technology loaded."
102102
}
103-
set resolution [expr $keys(-resolution) * [$tech getLefUnits]]
103+
set resolution [expr $keys(-resolution) * [$tech getDbUnitsPerMicron]]
104104
if { $resolution < 1 } {
105105
set resolution 1.0
106-
set res_per_pixel [expr $resolution / [$tech getLefUnits]]
106+
set res_per_pixel [expr $resolution / [$tech getDbUnitsPerMicron]]
107107
utl::warn GUI 31 "Resolution too high for design, defaulting to ${res_per_pixel}um per pixel"
108108
}
109109
}
@@ -156,10 +156,10 @@ proc save_animated_gif { args } {
156156
if { $tech == "NULL" } {
157157
utl::error GUI 52 "No technology loaded."
158158
}
159-
set resolution [expr $keys(-resolution) * [$tech getLefUnits]]
159+
set resolution [expr $keys(-resolution) * [$tech getDbUnitsPerMicron]]
160160
if { $resolution < 1 } {
161161
set resolution 1.0
162-
set res_per_pixel [expr $resolution / [$tech getLefUnits]]
162+
set res_per_pixel [expr $resolution / [$tech getDbUnitsPerMicron]]
163163
utl::warn GUI 55 "Resolution too high for design, defaulting to ${res_per_pixel}um per pixel"
164164
}
165165
}

src/odb/include/odb/db.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5697,13 +5697,6 @@ class dbTech : public dbObject
56975697
///
56985698
std::string getName();
56995699

5700-
///
5701-
/// Set the Database distance units per micron.
5702-
///
5703-
/// Legal values are 100, 200, 1000, 2000, 10000, 20000
5704-
///
5705-
void setDbUnitsPerMicron(int value);
5706-
57075700
///
57085701
/// Get the Database units per micron.
57095702
///
@@ -5880,9 +5873,7 @@ class dbTech : public dbObject
58805873
/// Create a new technology.
58815874
/// Returns nullptr if a database technology already exists
58825875
///
5883-
static dbTech* create(dbDatabase* db,
5884-
const char* name,
5885-
int dbu_per_micron = 1000);
5876+
static dbTech* create(dbDatabase* db, const char* name);
58865877

58875878
///
58885879
/// Translate a database-id back to a pointer.

src/odb/src/db/dbDatabase.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ namespace odb {
4848
inline constexpr uint db_schema_major = 0; // Not used...
4949
inline constexpr uint db_schema_initial = 57;
5050

51-
inline constexpr uint db_schema_minor = 121; // Current revision number
51+
inline constexpr uint db_schema_minor = 122; // Current revision number
52+
53+
// Revision where dbTech::dbu_per_micron_ was removed
54+
inline constexpr uint db_schema_remove_dbu_per_micron = 122;
5255

5356
// Revision where core area is stored as a polygon
5457
inline constexpr uint db_schema_core_area_is_polygon = 121;

src/odb/src/db/dbTech.cpp

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ bool _dbTech::operator==(const _dbTech& rhs) const
101101
return false;
102102
}
103103

104-
if (_dbu_per_micron != rhs._dbu_per_micron) {
105-
return false;
106-
}
107-
108104
if (_mfgrid != rhs._mfgrid) {
109105
return false;
110106
}
@@ -203,7 +199,6 @@ _dbTech::_dbTech(_dbDatabase* db)
203199
_layer_cnt = 0;
204200
_rlayer_cnt = 0;
205201
_lef_units = 0;
206-
_dbu_per_micron = 1000;
207202
_mfgrid = 0;
208203

209204
_flags._namecase = dbOnOffType::ON;
@@ -307,7 +302,6 @@ dbOStream& operator<<(dbOStream& stream, const _dbTech& tech)
307302
stream << tech._layer_cnt;
308303
stream << tech._rlayer_cnt;
309304
stream << tech._lef_units;
310-
stream << tech._dbu_per_micron;
311305
stream << tech._mfgrid;
312306

313307
uint* bit_field = (uint*) &tech._flags;
@@ -350,7 +344,11 @@ dbIStream& operator>>(dbIStream& stream, _dbTech& tech)
350344
stream >> tech._layer_cnt;
351345
stream >> tech._rlayer_cnt;
352346
stream >> tech._lef_units;
353-
stream >> tech._dbu_per_micron;
347+
if (db->isLessThanSchema(db_schema_remove_dbu_per_micron)) {
348+
int dbu_per_micron;
349+
stream >> dbu_per_micron;
350+
db->dbu_per_micron_ = dbu_per_micron;
351+
}
354352
stream >> tech._mfgrid;
355353

356354
uint* bit_field = (uint*) &tech._flags;
@@ -501,16 +499,9 @@ dbTechLayer* dbTech::findRoutingLayer(int level_number)
501499
return nullptr;
502500
}
503501

504-
void dbTech::setDbUnitsPerMicron(int value)
505-
{
506-
_dbTech* tech = (_dbTech*) this;
507-
tech->_dbu_per_micron = value;
508-
}
509-
510502
int dbTech::getDbUnitsPerMicron()
511503
{
512-
_dbTech* tech = (_dbTech*) this;
513-
return tech->_dbu_per_micron;
504+
return getDb()->getDbuPerMicron();
514505
}
515506

516507
dbSet<dbTechVia> dbTech::getVias()
@@ -831,12 +822,11 @@ void dbTech::checkLayer(bool typeChk,
831822
}
832823
}
833824
}
834-
dbTech* dbTech::create(dbDatabase* db_, const char* name, int dbu_per_micron)
825+
dbTech* dbTech::create(dbDatabase* db_, const char* name)
835826
{
836827
_dbDatabase* db = (_dbDatabase*) db_;
837828

838829
_dbTech* tech = db->_tech_tbl->create();
839-
tech->_dbu_per_micron = dbu_per_micron;
840830
tech->_name = name;
841831
return (dbTech*) tech;
842832
}

src/odb/src/db/dbTech.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ class _dbTech : public _dbObject
6464
int _layer_cnt;
6565
int _rlayer_cnt;
6666
int _lef_units;
67-
int _dbu_per_micron;
6867
int _mfgrid;
6968
_dbTechFlags _flags;
7069
dbId<_dbTechLayer> _bottom;

src/odb/src/db/dbUtil.h

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,17 @@ void checkNetSanity(const NetType* net,
113113
//
114114
if (drvr_count > 1) {
115115
if constexpr (std::is_same_v<NetType, dbNet>) {
116-
logger->warn(
117-
utl::ODB,
118-
49,
119-
"SanityCheck: dbNet '{}' has multiple drivers: {}",
120-
net->getName(),
121-
fmt::join(drvr_info_list, "")); // NOLINT(misc-include-cleaner)
116+
logger->warn(utl::ODB,
117+
49,
118+
"SanityCheck: dbNet '{}' has multiple drivers: {}",
119+
net->getName(),
120+
drvr_info_list.size()); // NOLINT(misc-include-cleaner)
122121
} else {
123-
logger->warn(
124-
utl::ODB,
125-
481, // Reusing error code from dbNet
126-
"SanityCheck: dbModNet '{}' has multiple drivers: {}",
127-
net->getHierarchicalName(),
128-
fmt::join(drvr_info_list, "")); // NOLINT(misc-include-cleaner)
122+
logger->warn(utl::ODB,
123+
481, // Reusing error code from dbNet
124+
"SanityCheck: dbModNet '{}' has multiple drivers: {}",
125+
net->getHierarchicalName(),
126+
drvr_info_list.size()); // NOLINT(misc-include-cleaner)
129127
}
130128
}
131129

src/odb/src/lefin/lefin.cpp

Lines changed: 60 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,18 +1862,13 @@ void lefinReader::units(LefParser::lefiUnits* unit)
18621862
if (unit->hasDatabase()) {
18631863
_lef_units = (int) unit->databaseNumber();
18641864

1865-
if (_override_lef_dbu == false) {
1866-
if (_create_tech) {
1867-
if (_lef_units
1868-
< 1000) { // historically the database was always stored in nm
1869-
setDBUPerMicron(1000);
1870-
} else {
1871-
setDBUPerMicron(_lef_units);
1872-
}
1873-
1874-
_tech->setDbUnitsPerMicron(_dbu_per_micron);
1875-
_tech->setLefUnits(_lef_units);
1865+
if (_create_tech && !_override_lef_dbu) {
1866+
// historically the database was always stored in nm
1867+
setDBUPerMicron(std::max(_lef_units, 1000));
1868+
if (_db->getDbuPerMicron() == 0) {
1869+
_db->setDbuPerMicron(_dbu_per_micron);
18761870
}
1871+
_tech->setLefUnits(_lef_units);
18771872
}
18781873

18791874
if (_lef_units > _dbu_per_micron) {
@@ -1889,33 +1884,61 @@ void lefinReader::units(LefParser::lefiUnits* unit)
18891884
}
18901885
}
18911886

1892-
void lefinReader::setDBUPerMicron(int dbu)
1887+
namespace {
1888+
bool isValidDBUPerMicron(int dbu)
18931889
{
18941890
switch (dbu) {
1895-
case 100:
1896-
case 200:
1897-
case 400:
1898-
case 800:
18991891
case 1000:
19001892
case 2000:
19011893
case 4000:
19021894
case 8000:
19031895
case 10000:
19041896
case 20000:
1905-
_dist_factor = dbu;
1906-
_dbu_per_micron = dbu;
1907-
_area_factor = _dbu_per_micron * _dbu_per_micron;
1908-
break;
1897+
return true;
19091898
default:
1899+
return false;
1900+
}
1901+
}
1902+
} // namespace
1903+
1904+
void lefinReader::setDBUPerMicron(int dbu)
1905+
{
1906+
if (!isValidDBUPerMicron(dbu)) {
1907+
++_errors;
1908+
_logger->warn(utl::ODB,
1909+
400,
1910+
"error: invalid dbu-per-micron value {}; valid units (1000, "
1911+
"2000, 4000, 8000, 10000, 20000)",
1912+
dbu);
1913+
1914+
return;
1915+
}
1916+
if (_db->getDbuPerMicron() != 0) {
1917+
if (dbu > _db->getDbuPerMicron()) {
1918+
++_errors;
1919+
_logger->warn(
1920+
utl::ODB,
1921+
401,
1922+
"The LEF UNITS DATABASE MICRON convert factor ({}) is greater than "
1923+
"the database units per micron ({}) of the current database.",
1924+
dbu,
1925+
_db->getDbuPerMicron());
1926+
}
1927+
if (_db->getDbuPerMicron() % dbu != 0) {
19101928
++_errors;
19111929
_logger->warn(utl::ODB,
1912-
206,
1913-
"error: invalid dbu-per-micron value {}; valid units (100, "
1914-
"200, 400, 800"
1915-
"1000, 2000, 4000, 8000, 10000, 20000)",
1916-
_lef_units);
1917-
break;
1930+
402,
1931+
"The LEF UNITS DATABASE MICRON convert factor ({}) is "
1932+
"not a multiplier of the database units per micron ({}) of "
1933+
"the current database.",
1934+
dbu,
1935+
_db->getDbuPerMicron());
1936+
}
1937+
dbu = _db->getDbuPerMicron();
19181938
}
1939+
_dist_factor = dbu;
1940+
_dbu_per_micron = dbu;
1941+
_area_factor = _dbu_per_micron * _dbu_per_micron;
19191942
}
19201943

19211944
void lefinReader::useMinSpacing(LefParser::lefiUseMinSpacing* spacing)
@@ -2370,15 +2393,17 @@ dbTech* lefinReader::createTech(const char* name, const char* lef_file)
23702393
lefrSetRelaxMode();
23712394
init();
23722395

2373-
_tech = dbTech::create(_db, name, _dbu_per_micron);
2396+
_tech = dbTech::create(_db, name);
23742397
_create_tech = true;
23752398

23762399
if (!readLef(lef_file) || _errors != 0) {
23772400
dbTech::destroy(_tech);
23782401
_logger->error(
23792402
utl::ODB, 288, "LEF data from {} is discarded due to errors", lef_file);
23802403
}
2381-
2404+
if (_db->getDbuPerMicron() == 0) {
2405+
_db->setDbuPerMicron(_dbu_per_micron);
2406+
}
23822407
_db->triggerPostReadLef(_tech, nullptr);
23832408

23842409
return _tech;
@@ -2414,7 +2439,9 @@ dbLib* lefinReader::createLib(dbTech* tech,
24142439
_logger->error(
24152440
utl::ODB, 292, "LEF data from {} is discarded due to errors", lef_file);
24162441
}
2417-
2442+
if (_db->getDbuPerMicron() == 0) {
2443+
_db->setDbuPerMicron(_dbu_per_micron);
2444+
}
24182445
_db->triggerPostReadLef(_tech, _lib);
24192446
return _lib;
24202447
}
@@ -2439,7 +2466,7 @@ dbLib* lefinReader::createTechAndLib(const char* tech_name,
24392466
return nullptr;
24402467
};
24412468

2442-
_tech = dbTech::create(_db, tech_name, _dbu_per_micron);
2469+
_tech = dbTech::create(_db, tech_name);
24432470
_lib_name = lib_name;
24442471
_create_lib = true;
24452472
_create_tech = true;
@@ -2458,7 +2485,9 @@ dbLib* lefinReader::createTechAndLib(const char* tech_name,
24582485
if (rules.orderReversed()) {
24592486
rules.reverse();
24602487
}
2461-
2488+
if (_db->getDbuPerMicron() == 0) {
2489+
_db->setDbuPerMicron(_dbu_per_micron);
2490+
}
24622491
_db->triggerPostReadLef(_tech, _lib);
24632492

24642493
return _lib;

0 commit comments

Comments
 (0)