2323// User Code End Includes
2424namespace odb {
2525template 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
2741bool _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
431459void 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,
441469void 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