Skip to content

Commit e885f48

Browse files
authored
Merge pull request #8385 from The-OpenROAD-Project-staging/odb-gcell-float
odb: store dbGCellGrid::GCellData in float for CUGR
2 parents 7136f1c + 2d02448 commit e885f48

File tree

4 files changed

+47
-19
lines changed

4 files changed

+47
-19
lines changed

src/odb/include/odb/db.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7446,8 +7446,8 @@ class dbGCellGrid : public dbObject
74467446
public:
74477447
struct GCellData
74487448
{
7449-
uint8_t usage = 0;
7450-
uint8_t capacity = 0;
7449+
float usage = 0;
7450+
float capacity = 0;
74517451
};
74527452

74537453
// User Code Begin dbGCellGrid
@@ -7511,16 +7511,13 @@ class dbGCellGrid : public dbObject
75117511

75127512
uint getYIdx(int y);
75137513

7514-
uint8_t getCapacity(dbTechLayer* layer, uint x_idx, uint y_idx) const;
7514+
float getCapacity(dbTechLayer* layer, uint x_idx, uint y_idx) const;
75157515

7516-
uint8_t getUsage(dbTechLayer* layer, uint x_idx, uint y_idx) const;
7516+
float getUsage(dbTechLayer* layer, uint x_idx, uint y_idx) const;
75177517

7518-
void setCapacity(dbTechLayer* layer,
7519-
uint x_idx,
7520-
uint y_idx,
7521-
uint8_t capacity);
7518+
void setCapacity(dbTechLayer* layer, uint x_idx, uint y_idx, float capacity);
75227519

7523-
void setUsage(dbTechLayer* layer, uint x_idx, uint y_idx, uint8_t use);
7520+
void setUsage(dbTechLayer* layer, uint x_idx, uint y_idx, float use);
75247521

75257522
void resetCongestionMap();
75267523

src/odb/src/codeGenerator/schema/chip/dbGCellGrid.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@
8787
"fields": [
8888
{
8989
"name": "usage",
90-
"type": "uint8_t",
90+
"type": "float",
9191
"flags": [],
9292
"default": 0
9393
},
9494
{
9595
"name": "capacity",
96-
"type": "uint8_t",
96+
"type": "float",
9797
"flags": [],
9898
"default": 0
9999
}

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 = 118; // Current revision number
51+
inline constexpr uint db_schema_minor = 119; // Current revision number
52+
53+
// Revision where dbGCellGrid::GCellData moved to float (for cugr)
54+
inline constexpr uint db_schema_float_gcelldata = 119;
5255

5356
// Revision where dbTech was moved from dbBlock to dbChip
5457
inline constexpr uint db_schema_chip_tech = 118;

src/odb/src/db/dbGCellGrid.cpp

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,20 @@
2323
// User Code End Includes
2424
namespace odb {
2525
template class dbTable<_dbGCellGrid>;
26+
// User Code Begin Static
27+
struct OldGCellData
28+
{
29+
uint8_t usage = 0;
30+
uint8_t capacity = 0;
31+
};
32+
33+
dbIStream& operator>>(dbIStream& stream, OldGCellData& obj)
34+
{
35+
stream >> obj.usage;
36+
stream >> obj.capacity;
37+
return stream;
38+
}
39+
// User Code End Static
2640

2741
bool _dbGCellGrid::operator==(const _dbGCellGrid& rhs) const
2842
{
@@ -92,8 +106,24 @@ dbIStream& operator>>(dbIStream& stream, _dbGCellGrid& obj)
92106
stream >> obj.y_grid_;
93107
// User Code Begin >>
94108
_dbDatabase* db = obj.getDatabase();
95-
if (db->isSchema(db_schema_gcell_grid_matrix)) {
109+
if (db->isSchema(db_schema_float_gcelldata)) {
96110
stream >> obj.congestion_map_;
111+
} else if (db->isSchema(db_schema_gcell_grid_matrix)) {
112+
std::map<dbId<_dbTechLayer>, dbMatrix<OldGCellData>> old_format;
113+
stream >> old_format;
114+
for (const auto& [lid, cells] : old_format) {
115+
auto& matrix = obj.get(lid);
116+
const uint num_rows = cells.numRows();
117+
const uint num_cols = cells.numCols();
118+
for (int row = 0; row < num_rows; ++row) {
119+
for (int col = 0; col < num_cols; ++col) {
120+
auto& old = cells(row, col);
121+
const float usage = old.usage;
122+
const float capacity = old.capacity;
123+
matrix(row, col) = {usage, capacity};
124+
}
125+
}
126+
}
97127
} else {
98128
std::map<dbId<_dbTechLayer>,
99129
std::map<std::pair<uint, uint>, dbGCellGrid::GCellData>>
@@ -412,16 +442,14 @@ uint dbGCellGrid::getYIdx(int y)
412442
return (int) std::distance(grid.begin(), pos);
413443
}
414444

415-
uint8_t dbGCellGrid::getCapacity(dbTechLayer* layer,
416-
uint x_idx,
417-
uint y_idx) const
445+
float dbGCellGrid::getCapacity(dbTechLayer* layer, uint x_idx, uint y_idx) const
418446
{
419447
_dbGCellGrid* _grid = (_dbGCellGrid*) this;
420448
uint lid = layer->getId();
421449
return _grid->get(lid)(x_idx, y_idx).capacity;
422450
}
423451

424-
uint8_t dbGCellGrid::getUsage(dbTechLayer* layer, uint x_idx, uint y_idx) const
452+
float dbGCellGrid::getUsage(dbTechLayer* layer, uint x_idx, uint y_idx) const
425453
{
426454
_dbGCellGrid* _grid = (_dbGCellGrid*) this;
427455
uint lid = layer->getId();
@@ -431,7 +459,7 @@ uint8_t dbGCellGrid::getUsage(dbTechLayer* layer, uint x_idx, uint y_idx) const
431459
void dbGCellGrid::setCapacity(dbTechLayer* layer,
432460
uint x_idx,
433461
uint y_idx,
434-
uint8_t capacity)
462+
float capacity)
435463
{
436464
_dbGCellGrid* _grid = (_dbGCellGrid*) this;
437465
uint lid = layer->getId();
@@ -441,7 +469,7 @@ void dbGCellGrid::setCapacity(dbTechLayer* layer,
441469
void dbGCellGrid::setUsage(dbTechLayer* layer,
442470
uint x_idx,
443471
uint y_idx,
444-
uint8_t use)
472+
float use)
445473
{
446474
_dbGCellGrid* _grid = (_dbGCellGrid*) this;
447475
uint lid = layer->getId();

0 commit comments

Comments
 (0)