Skip to content

Commit 0bc30cf

Browse files
Merge pull request #10590 from osamahammad21/odb-dbinst-chipbump
odb: add inst-to-chip-bump back-reference
2 parents e03cf07 + 79deaf0 commit 0bc30cf

7 files changed

Lines changed: 64 additions & 2 deletions

File tree

src/odb/include/odb/db.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3190,6 +3190,12 @@ class dbInst : public dbObject
31903190

31913191
uint32_t getPinAccessIdx() const;
31923192

3193+
///
3194+
/// Get the chip bump associated with this instance.
3195+
/// Returns a pointer to the dbChipBump object if present, otherwise nullptr.
3196+
///
3197+
dbChipBump* getChipBump() const;
3198+
31933199
///
31943200
/// Create a new instance.
31953201
/// If physical_only is true, the instance can only be added to a top module.

src/odb/src/db/dbBTerm.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,9 @@ void dbBTerm::destroy(dbBTerm* bterm_)
820820
if (bterm->net_) {
821821
bterm->disconnectNet(bterm, block);
822822
}
823+
if (auto bump = (_dbChipBump*) (bterm_->getChipBump())) {
824+
bump->bterm_ = 0;
825+
}
823826
for (auto callback : block->callbacks_) {
824827
callback->inDbBTermDestroy(bterm_);
825828
}

src/odb/src/db/dbChipBump.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,21 @@ dbChipBump* dbChipBump::create(dbChipRegion* chip_region, dbInst* inst)
163163
"as the chip region {}",
164164
inst->getName(),
165165
chip_region->getName());
166-
return nullptr;
167166
}
167+
if (inst->getChipBump() != nullptr) {
168+
logger->error(
169+
utl::ODB,
170+
534,
171+
"Cannot create chip bump. Inst {} already has an associated chip bump",
172+
inst->getName());
173+
}
174+
168175
_dbChipBump* obj = _chip_region->chip_bump_tbl_->create();
169176
obj->inst_ = _inst->getOID();
170177
obj->chip_ = _chip->getOID();
171178
obj->chip_region_ = _chip_region->getOID();
179+
_inst->chip_region_ = _chip_region->getOID();
180+
_inst->bump_ = obj->getOID();
172181
return (dbChipBump*) obj;
173182
}
174183

src/odb/src/db/dbDatabase.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ namespace odb {
5050
inline constexpr uint32_t kSchemaMajor = 0; // Not used...
5151
inline constexpr uint32_t kSchemaInitial = 57;
5252

53-
inline constexpr uint32_t kSchemaMinor = 131; // Current revision number
53+
inline constexpr uint32_t kSchemaMinor = 132; // Current revision number
5454

55+
// Revision where dbInst::bump_ was added
56+
inline constexpr uint32_t kSchemaInstBump = 132;
5557
// Revision where all areas in the are switched to be stored as int64_t
5658
inline constexpr uint32_t kSchemaStoreAreaAsInt64 = 131;
5759

src/odb/src/db/dbInst.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "dbBlock.h"
1717
#include "dbBox.h"
1818
#include "dbChip.h"
19+
#include "dbChipBump.h"
20+
#include "dbChipRegion.h"
1921
#include "dbCommon.h"
2022
#include "dbCore.h"
2123
#include "dbDatabase.h"
@@ -125,6 +127,8 @@ _dbInst::_dbInst(_dbDatabase*, const _dbInst& i)
125127
region_prev_(i.region_prev_),
126128
module_prev_(i.module_prev_),
127129
hierarchy_(i.hierarchy_),
130+
chip_region_(i.chip_region_),
131+
bump_(i.bump_),
128132
iterms_(i.iterms_),
129133
halo_(i.halo_),
130134
pin_access_idx_(i.pin_access_idx_)
@@ -161,6 +165,8 @@ dbOStream& operator<<(dbOStream& stream, const _dbInst& inst)
161165
stream << inst.region_prev_;
162166
stream << inst.module_prev_;
163167
stream << inst.hierarchy_;
168+
stream << inst.chip_region_;
169+
stream << inst.bump_;
164170
stream << inst.iterms_;
165171
stream << inst.halo_;
166172
stream << inst.pin_access_idx_;
@@ -187,6 +193,10 @@ dbIStream& operator>>(dbIStream& stream, _dbInst& inst)
187193
stream >> inst.region_prev_;
188194
stream >> inst.module_prev_;
189195
stream >> inst.hierarchy_;
196+
if (inst.getDatabase()->isSchema(kSchemaInstBump)) {
197+
stream >> inst.chip_region_;
198+
stream >> inst.bump_;
199+
}
190200
stream >> inst.iterms_;
191201
stream >> inst.halo_;
192202
stream >> inst.pin_access_idx_;
@@ -300,6 +310,14 @@ bool _dbInst::operator==(const _dbInst& rhs) const
300310
return false;
301311
}
302312

313+
if (chip_region_ != rhs.chip_region_) {
314+
return false;
315+
}
316+
317+
if (bump_ != rhs.bump_) {
318+
return false;
319+
}
320+
303321
if (iterms_ != rhs.iterms_) {
304322
return false;
305323
}
@@ -1292,6 +1310,18 @@ uint32_t dbInst::getPinAccessIdx() const
12921310
return inst->pin_access_idx_;
12931311
}
12941312

1313+
dbChipBump* dbInst::getChipBump() const
1314+
{
1315+
_dbInst* inst = (_dbInst*) this;
1316+
if (inst->bump_ == 0) {
1317+
return nullptr;
1318+
}
1319+
_dbChip* chip = (_dbChip*) getBlock()->getChip();
1320+
_dbChipRegion* chip_region
1321+
= (_dbChipRegion*) chip->chip_region_tbl_->getPtr(inst->chip_region_);
1322+
return (dbChipBump*) chip_region->chip_bump_tbl_->getPtr(inst->bump_);
1323+
}
1324+
12951325
dbInst* dbInst::create(dbBlock* block,
12961326
dbMaster* master,
12971327
const char* name,
@@ -1492,6 +1522,13 @@ void dbInst::destroy(dbInst* inst_)
14921522
"Attempt to destroy dont_touch instance {}",
14931523
inst->name_);
14941524
}
1525+
if (inst->bump_.isValid()) {
1526+
inst->getLogger()->error(
1527+
utl::ODB,
1528+
546,
1529+
"Cannot destroy instance {} with an associated chip bump",
1530+
inst->name_);
1531+
}
14951532

14961533
dbScanInst* scan_inst = inst_->getScanInst();
14971534
if (scan_inst) {

src/odb/src/db/dbInst.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class _dbRegion;
2121
class _dbDatabase;
2222
class _dbModule;
2323
class _dbGroup;
24+
class _dbChipBump;
25+
class _dbChipRegion;
2426
class dbInst;
2527
class dbIStream;
2628
class dbOStream;
@@ -85,6 +87,8 @@ class _dbInst : public _dbObject
8587
dbId<_dbInst> region_prev_;
8688
dbId<_dbInst> module_prev_;
8789
dbId<_dbHier> hierarchy_;
90+
dbId<_dbChipRegion> chip_region_;
91+
dbId<_dbChipBump> bump_;
8892
dbVector<uint32_t> iterms_;
8993
dbId<_dbBox> halo_;
9094
uint32_t pin_access_idx_;

src/odb/test/cpp/TestChips.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ TEST_F(ChipHierarchyFixture, test_chip_bumps)
367367
auto io_inst_region_r1_bump_inst
368368
= *io_inst_region_r1->getChipBumpInsts().begin();
369369
EXPECT_EQ(io_inst_region_r1_bump_inst->getChipBump(), io_bump);
370+
EXPECT_EQ(io_bump->getInst()->getChipBump(), io_bump);
370371
EXPECT_EQ(io_inst_region_r1_bump_inst->getChipRegionInst(),
371372
io_inst_region_r1);
372373

0 commit comments

Comments
 (0)