Skip to content

Commit 177f6e9

Browse files
committed
odb: dbChip::getBBox and dbChipInst::getBBox
Signed-off-by: osamahammad21 <[email protected]>
1 parent 22a4b4c commit 177f6e9

File tree

5 files changed

+40
-1
lines changed

5 files changed

+40
-1
lines changed

src/odb/include/odb/3dblox.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class ThreeDBlox
3838
dbChipRegionInst* resolvePath(const std::string& path,
3939
std::vector<dbChipInst*>& path_insts);
4040
void readHeaderIncludes(const std::vector<std::string>& includes);
41+
void calculateSize(dbChip* chip);
4142

4243
utl::Logger* logger_ = nullptr;
4344
odb::dbDatabase* db_ = nullptr;

src/odb/include/odb/db.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7072,6 +7072,8 @@ class dbChip : public dbObject
70727072

70737073
dbTech* getTech() const;
70747074

7075+
Rect getBBox() const;
7076+
70757077
///
70767078
/// Create a new chip.
70777079
/// Returns nullptr if there is no database technology.
@@ -7181,6 +7183,8 @@ class dbChipInst : public dbObject
71817183

71827184
dbTransform getTransform() const;
71837185

7186+
Rect getBBox() const;
7187+
71847188
dbSet<dbChipRegionInst> getRegions() const;
71857189

71867190
dbChipRegionInst* findChipRegionInst(dbChipRegion* chip_region) const;

src/odb/src/3dblox/3dblox.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,21 @@ void ThreeDBlox::readDbx(const std::string& dbx_file)
7777
for (const auto& [_, connection] : data.connections) {
7878
createConnection(connection);
7979
}
80-
80+
calculateSize(db_->getChip());
8181
db_->triggerPostRead3Dbx(chip);
8282
}
8383

84+
void ThreeDBlox::calculateSize(dbChip* chip)
85+
{
86+
Rect box;
87+
box.mergeInit();
88+
for (auto inst : chip->getChipInsts()) {
89+
box.merge(inst->getBBox());
90+
}
91+
chip->setWidth(box.dx());
92+
chip->setHeight(box.dy());
93+
}
94+
8495
void ThreeDBlox::readHeaderIncludes(const std::vector<std::string>& includes)
8596
{
8697
for (const auto& include : includes) {

src/odb/src/db/dbChip.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,20 @@ dbTech* dbChip::getTech() const
591591
return (dbTech*) db->_tech_tbl->getPtr(chip->tech_);
592592
}
593593

594+
Rect dbChip::getBBox() const
595+
{
596+
_dbChip* _chip = (_dbChip*) this;
597+
const int llx = 0 - _chip->scribe_line_east_ - _chip->seal_ring_west_;
598+
const int lly = 0 - _chip->scribe_line_south_ - _chip->seal_ring_south_;
599+
const int urx
600+
= _chip->width_ + _chip->scribe_line_east_ + _chip->seal_ring_east_;
601+
const int ury
602+
= _chip->height_ + _chip->scribe_line_north_ + _chip->seal_ring_north_;
603+
Rect box(llx, lly, urx, ury);
604+
box.moveTo(_chip->offset_.x(), _chip->offset_.y());
605+
return box;
606+
}
607+
594608
dbChip* dbChip::create(dbDatabase* db_,
595609
dbTech* tech,
596610
const std::string& name,

src/odb/src/db/dbChipInst.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ dbTransform dbChipInst::getTransform() const
160160
Point(obj->loc_.x(), obj->loc_.y()));
161161
}
162162

163+
Rect dbChipInst::getBBox() const
164+
{
165+
_dbChipInst* _chipinst = (_dbChipInst*) this;
166+
Rect box = getMasterChip()->getBBox();
167+
box.moveTo(_chipinst->loc_.x(), _chipinst->loc_.y());
168+
getTransform().apply(box);
169+
return box;
170+
}
171+
163172
dbSet<dbChipRegionInst> dbChipInst::getRegions() const
164173
{
165174
_dbChipInst* _chipinst = (_dbChipInst*) this;

0 commit comments

Comments
 (0)