Skip to content

Commit 40f0809

Browse files
committed
odb: Fixed a bug in restoring dbModule::*_hash_
- Previously, dbModules in a child block (not top block) suffers from empty dbModule::*_hash_ containers because the deserialization logic always searches top block even for the child block. - Corrected the module search logic to find the child blocks correctly Signed-off-by: Jaehyun Kim <[email protected]>
1 parent 79574f7 commit 40f0809

File tree

6 files changed

+87
-31
lines changed

6 files changed

+87
-31
lines changed

src/odb/src/db/dbBlock.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,17 +950,67 @@ dbIStream& operator>>(dbIStream& stream, _dbBlock& block)
950950
stream >> *block.inst_tbl_;
951951
stream >> *block.module_tbl_;
952952
}
953+
954+
if (db->isSchema(kSchemaDbRemoveHash)) {
955+
// Construct dbinst_hash_
956+
dbSet<dbInst> insts((dbBlock*) &block, block.inst_tbl_);
957+
for (dbInst* obj : insts) {
958+
_dbInst* _obj = (_dbInst*) obj;
959+
_dbModule* module = nullptr;
960+
if (_obj->module_ == 0) {
961+
module = block.module_tbl_->getPtr(block.top_module_);
962+
} else {
963+
module = block.module_tbl_->getPtr(_obj->module_);
964+
}
965+
if (_obj->name_) {
966+
module->dbinst_hash_[_obj->name_] = _obj->getId();
967+
}
968+
}
969+
}
953970
if (db->isSchema(kSchemaBlockOwnsScanInsts)) {
954971
stream >> *block.scan_inst_tbl_;
955972
}
956973
stream >> *block.modinst_tbl_;
974+
if (db->isSchema(kSchemaDbRemoveHash)) {
975+
// Construct modinst_hash_
976+
dbSet<dbModInst> modinsts((dbBlock*) &block, block.modinst_tbl_);
977+
for (dbModInst* obj : modinsts) {
978+
_dbModInst* _obj = (_dbModInst*) obj;
979+
_dbModule* module = block.module_tbl_->getPtr(_obj->parent_);
980+
if (_obj->name_) {
981+
module->modinst_hash_[_obj->name_] = _obj->getId();
982+
}
983+
}
984+
}
957985
if (db->isSchema(kSchemaUpdateHierarchy)) {
958986
stream >> *block.modbterm_tbl_;
987+
if (db->isSchema(kSchemaDbRemoveHash)) {
988+
// Construct modbterm_hash_
989+
dbSet<dbModBTerm> modbterms((dbBlock*) &block, block.modbterm_tbl_);
990+
for (dbModBTerm* obj : modbterms) {
991+
_dbModBTerm* _obj = (_dbModBTerm*) obj;
992+
_dbModule* module = block.module_tbl_->getPtr(_obj->parent_);
993+
if (_obj->name_) {
994+
module->modbterm_hash_[_obj->name_] = _obj->getId();
995+
}
996+
}
997+
}
959998
if (db->isSchema(kSchemaDbRemoveHash)) {
960999
stream >> *block.busport_tbl_;
9611000
}
9621001
stream >> *block.moditerm_tbl_;
9631002
stream >> *block.modnet_tbl_;
1003+
if (db->isSchema(db_schema_db_remove_hash)) {
1004+
// Construct modnet_hash_
1005+
dbSet<dbModNet> modnets((dbBlock*) &block, block.modnet_tbl_);
1006+
for (dbModNet* obj : modnets) {
1007+
_dbModNet* _obj = (_dbModNet*) obj;
1008+
_dbModule* module = block.module_tbl_->getPtr(_obj->parent_);
1009+
if (_obj->name_) {
1010+
module->modnet_hash_[_obj->name_] = _obj->getId();
1011+
}
1012+
}
1013+
}
9641014
}
9651015
stream >> *block.powerdomain_tbl_;
9661016
stream >> *block.logicport_tbl_;

src/odb/src/db/dbInst.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -194,20 +194,20 @@ dbIStream& operator>>(dbIStream& stream, _dbInst& inst)
194194

195195
dbDatabase* db = (dbDatabase*) (inst.getDatabase());
196196
if (((_dbDatabase*) db)->isSchema(kSchemaDbRemoveHash)) {
197-
_dbBlock* block = (_dbBlock*) (db->getChip()->getBlock());
198-
_dbModule* module = nullptr;
199-
// if the instance has no module parent put in the top module
200-
// We sometimes see instances with _module set to 0 (possibly
201-
// introduced downstream) so we stick them in the hash for the
202-
// top module.
203-
if (inst.module_ == 0) {
204-
module = (_dbModule*) (((dbBlock*) block)->getTopModule());
205-
} else {
206-
module = block->module_tbl_->getPtr(inst.module_);
207-
}
208-
if (inst.name_) {
209-
module->dbinst_hash_[inst.name_] = dbId<_dbInst>(inst.getId());
210-
}
197+
// _dbBlock* block = (_dbBlock*) (db->getChip()->getBlock());
198+
// _dbModule* module = nullptr;
199+
// // if the instance has no module parent put in the top module
200+
// // We sometimes see instances with _module set to 0 (possibly
201+
// // introduced downstream) so we stick them in the hash for the
202+
// // top module.
203+
// if (inst.module_ == 0) {
204+
// module = (_dbModule*) (((dbBlock*) block)->getTopModule());
205+
// } else {
206+
// module = block->module_tbl_->getPtr(inst.module_);
207+
// }
208+
// if (inst.name_) {
209+
// module->dbinst_hash_[inst.name_] = dbId<_dbInst>(inst.getId());
210+
// }
211211
}
212212
return stream;
213213
}

src/odb/src/db/dbModBTerm.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ dbIStream& operator>>(dbIStream& stream, _dbModBTerm& obj)
109109
}
110110
// User Code Begin >>
111111
if (obj.getDatabase()->isSchema(kSchemaDbRemoveHash)) {
112-
dbDatabase* db = (dbDatabase*) (obj.getDatabase());
113-
_dbBlock* block = (_dbBlock*) (db->getChip()->getBlock());
114-
_dbModule* module = block->module_tbl_->getPtr(obj.parent_);
115-
if (obj.name_) {
116-
module->modbterm_hash_[obj.name_] = obj.getId();
117-
}
112+
// dbDatabase* db = (dbDatabase*) (obj.getDatabase());
113+
// _dbBlock* block = (_dbBlock*) (db->getChip()->getBlock());
114+
// _dbModule* module = block->module_tbl_->getPtr(obj.parent_);
115+
// if (obj.name_) {
116+
// module->modbterm_hash_[obj.name_] = obj.getId();
117+
// }
118118
}
119119
// User Code End >>
120120
return stream;

src/odb/src/db/dbModInst.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ dbIStream& operator>>(dbIStream& stream, _dbModInst& obj)
107107
stream >> obj.moditerms_;
108108
}
109109
if (db_->isSchema(kSchemaDbRemoveHash)) {
110-
_dbBlock* block = (_dbBlock*) (((dbDatabase*) db_)->getChip()->getBlock());
111-
_dbModule* module = block->module_tbl_->getPtr(obj.parent_);
112-
if (obj.name_) {
113-
module->modinst_hash_[obj.name_] = obj.getId();
114-
}
110+
// _dbBlock* block = (_dbBlock*) (((dbDatabase*)
111+
// db_)->getChip()->getBlock()); _dbModule* module =
112+
// block->module_tbl_->getPtr(obj.parent_); if (obj.name_) {
113+
// module->modinst_hash_[obj.name_] = obj.getId();
114+
// }
115115
}
116116
// User Code End >>
117117
return stream;

src/odb/src/db/dbModNet.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ dbIStream& operator>>(dbIStream& stream, _dbModNet& obj)
108108
}
109109
// User Code Begin >>
110110
if (obj.getDatabase()->isSchema(kSchemaDbRemoveHash)) {
111-
dbDatabase* db = (dbDatabase*) (obj.getDatabase());
112-
_dbBlock* block = (_dbBlock*) (db->getChip()->getBlock());
113-
_dbModule* module = block->module_tbl_->getPtr(obj.parent_);
114-
if (obj.name_) {
115-
module->modnet_hash_[obj.name_] = dbId<_dbModNet>(obj.getId());
116-
}
111+
// dbDatabase* db = (dbDatabase*) (obj.getDatabase());
112+
// _dbBlock* block = (_dbBlock*) (db->getChip()->getBlock());
113+
// _dbModule* module = block->module_tbl_->getPtr(obj.parent_);
114+
// if (obj.name_) {
115+
// module->modnet_hash_[obj.name_] = obj.getId();
116+
// }
117117
}
118118
// User Code End >>
119119
return stream;

src/rsz/src/ConcreteSwapArithModules.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,11 @@ bool ConcreteSwapArithModules::doSwapInstances(
261261
logger_->warn(RSZ, 158, "Module {} has no owner block", old_name);
262262
continue;
263263
}
264+
#include "db_sta/dbSta.hh"
265+
#include "odb/db.h"
266+
267+
// ...
268+
264269
dbModule* new_master = block->findModule(new_name.c_str());
265270
if (!new_master) {
266271
logger_->warn(
@@ -271,6 +276,7 @@ bool ConcreteSwapArithModules::doSwapInstances(
271276
inst->getName(),
272277
old_name,
273278
new_name);
279+
274280
inst->swapMaster(new_master);
275281
swapped_count++;
276282
}

0 commit comments

Comments
 (0)