Skip to content

Commit b10fa4c

Browse files
Merge pull request #8956 from osamahammad21/3dblox-update
ODB: fix multiple 3dblox issues
2 parents cfc0bad + e4de365 commit b10fa4c

File tree

14 files changed

+289
-146
lines changed

14 files changed

+289
-146
lines changed

src/OpenRoad.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ void OpenRoad::read3Dbx(const std::string& filename)
495495
{
496496
odb::ThreeDBlox parser(logger_, db_, sta_);
497497
parser.readDbx(filename);
498+
parser.check();
498499
}
499500

500501
void OpenRoad::read3DBloxBMap(const std::string& filename)

src/odb/include/odb/db.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7247,12 +7247,6 @@ class dbChipInst : public dbObject
72477247
public:
72487248
std::string getName() const;
72497249

7250-
void setLoc(const Point3D& loc);
7251-
7252-
Point3D getLoc() const;
7253-
7254-
void setOrient(dbOrientType3D orient);
7255-
72567250
dbOrientType3D getOrient() const;
72577251

72587252
dbChip* getMasterChip() const;
@@ -7263,6 +7257,12 @@ class dbChipInst : public dbObject
72637257

72647258
dbTransform getTransform() const;
72657259

7260+
void setOrient(dbOrientType3D orient);
7261+
7262+
void setLoc(const Point3D& loc);
7263+
7264+
Point3D getLoc() const;
7265+
72667266
Rect getBBox() const;
72677267

72687268
Cuboid getCuboid() const;

src/odb/include/odb/dbTransform.h

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,44 +18,75 @@ class dbIStream;
1818
class dbTransform
1919
{
2020
public:
21-
// T = <R0, (0,0)>
21+
// T = <R0, (0,0,0), false>
2222
dbTransform() = default;
2323

24-
// T = <R0, offset>
25-
dbTransform(const Point offset) : offset_(offset) {}
24+
// T = <R0, (offset,0), false>
25+
dbTransform(const Point offset) : offset_(offset, 0) {}
2626

27-
// T = <orient, (0,0)>
27+
// T = <R0, offset, false>
28+
dbTransform(const Point3D& offset) : offset_(offset) {}
29+
30+
// T = <orient, (0,0,0), false>
2831
dbTransform(const dbOrientType orient) : orient_(orient) {}
2932

30-
// T = <orient, offset>
33+
// T = <orient, (0,0,0), orient.mirror_z_>
34+
dbTransform(const dbOrientType3D& orient)
35+
: orient_(orient.getOrientType2D()), mirror_z_(orient.isMirrorZ())
36+
{
37+
}
38+
39+
// T = <orient, (offset,0), false>
3140
dbTransform(const dbOrientType orient, const Point& offset)
32-
: orient_(orient), offset_(offset)
41+
: orient_(orient), offset_(offset, 0)
42+
{
43+
}
44+
45+
dbTransform(const dbOrientType3D orient, const Point3D& offset)
46+
: orient_(orient.getOrientType2D()),
47+
offset_(offset),
48+
mirror_z_(orient.isMirrorZ())
3349
{
3450
}
3551

3652
bool operator==(const dbTransform& t) const
3753
{
38-
return (orient_ == t.orient_) && (offset_ == t.offset_);
54+
return (orient_ == t.orient_) && (offset_ == t.offset_)
55+
&& (mirror_z_ == t.mirror_z_);
3956
}
4057

4158
bool operator!=(const dbTransform& t) const { return !operator==(t); }
4259

4360
void setOrient(const dbOrientType orient) { orient_ = orient; }
4461

45-
void setOffset(const Point offset) { offset_ = offset; }
62+
void setOrient(const dbOrientType3D& orient)
63+
{
64+
orient_ = orient.getOrientType2D();
65+
mirror_z_ = orient.isMirrorZ();
66+
}
67+
68+
void setOffset(const Point offset) { offset_ = Point3D(offset, 0); }
69+
70+
void setOffset(const Point3D& offset) { offset_ = offset; }
4671

4772
void setTransform(const dbOrientType orient, const Point& offset)
4873
{
4974
orient_ = orient;
50-
offset_ = offset;
75+
offset_ = Point3D(offset, 0);
5176
}
5277

5378
// Apply transform to this point
5479
void apply(Point& p) const;
5580

81+
// Apply transform to this point3D
82+
void apply(Point3D& p) const;
83+
5684
// Apply transform to this Rect
5785
void apply(Rect& r) const;
5886

87+
// Apply transform to this Cuboid
88+
void apply(Cuboid& c) const;
89+
5990
// Apply transform to this polygon
6091
void apply(Polygon& p) const;
6192

@@ -72,16 +103,16 @@ class dbTransform
72103
void invert();
73104

74105
dbOrientType getOrient() const { return orient_; }
75-
Point getOffset() const { return offset_; }
106+
Point getOffset() const { return Point(offset_.x(), offset_.y()); }
76107

77108
friend dbOStream& operator<<(dbOStream& stream, const dbTransform& t);
78109
friend dbIStream& operator>>(dbIStream& stream, dbTransform& t);
79110

80111
private:
81112
friend class _dbBlock;
82-
83113
dbOrientType::Value orient_ = dbOrientType::R0;
84-
Point offset_;
114+
Point3D offset_;
115+
bool mirror_z_ = false;
85116
};
86117

87118
dbOStream& operator<<(dbOStream& stream, const dbTransform& t);

src/odb/include/odb/geom.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ class Cuboid
217217
int yhi_ = 0;
218218
int zhi_ = 0;
219219
};
220+
std::ostream& operator<<(std::ostream& os, const Cuboid& cIn);
220221

221222
/*
222223
an Oct represents a 45-degree routing segment as 2 connected octagons

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

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ void ThreeDBlox::readDbx(const std::string& dbx_file)
8989
}
9090
calculateSize(db_->getChip());
9191
db_->triggerPostRead3Dbx(chip);
92-
check();
9392
}
9493

9594
void ThreeDBlox::check()
@@ -192,13 +191,14 @@ void ThreeDBlox::writeDbx(const std::string& dbx_file, odb::dbChip* chip)
192191

193192
void ThreeDBlox::calculateSize(dbChip* chip)
194193
{
195-
Rect box;
196-
box.mergeInit();
194+
Cuboid cuboid;
195+
cuboid.mergeInit();
197196
for (auto inst : chip->getChipInsts()) {
198-
box.merge(inst->getBBox());
197+
cuboid.merge(inst->getCuboid());
199198
}
200-
chip->setWidth(box.dx());
201-
chip->setHeight(box.dy());
199+
chip->setWidth(cuboid.dx());
200+
chip->setHeight(cuboid.dy());
201+
chip->setThickness(cuboid.dz());
202202
}
203203

204204
void ThreeDBlox::readHeaderIncludes(const std::vector<std::string>& includes)
@@ -302,30 +302,46 @@ void ThreeDBlox::createChiplet(const ChipletDef& chiplet)
302302
chip,
303303
/*issue_callback*/ false);
304304
}
305-
chip->setWidth(chiplet.design_width * db_->getDbuPerMicron());
306-
chip->setHeight(chiplet.design_height * db_->getDbuPerMicron());
307-
chip->setThickness(chiplet.thickness * db_->getDbuPerMicron());
308-
chip->setShrink(chiplet.shrink);
305+
if (chiplet.design_width != -1.0) {
306+
chip->setWidth(chiplet.design_width * db_->getDbuPerMicron());
307+
}
308+
if (chiplet.design_height != -1.0) {
309+
chip->setHeight(chiplet.design_height * db_->getDbuPerMicron());
310+
}
311+
if (chiplet.thickness != -1.0) {
312+
chip->setThickness(chiplet.thickness * db_->getDbuPerMicron());
313+
}
314+
if (chiplet.shrink != -1.0) {
315+
chip->setShrink(chiplet.shrink);
316+
}
309317
chip->setTsv(chiplet.tsv);
310318

311-
chip->setScribeLineEast(chiplet.scribe_line_right * db_->getDbuPerMicron());
312-
chip->setScribeLineWest(chiplet.scribe_line_left * db_->getDbuPerMicron());
313-
chip->setScribeLineNorth(chiplet.scribe_line_top * db_->getDbuPerMicron());
314-
chip->setScribeLineSouth(chiplet.scribe_line_bottom * db_->getDbuPerMicron());
315-
316-
chip->setSealRingEast(chiplet.seal_ring_right * db_->getDbuPerMicron());
317-
chip->setSealRingWest(chiplet.seal_ring_left * db_->getDbuPerMicron());
318-
chip->setSealRingNorth(chiplet.seal_ring_top * db_->getDbuPerMicron());
319-
chip->setSealRingSouth(chiplet.seal_ring_bottom * db_->getDbuPerMicron());
319+
if (chiplet.scribe_line_right != -1.0) {
320+
chip->setScribeLineEast(chiplet.scribe_line_right * db_->getDbuPerMicron());
321+
chip->setScribeLineWest(chiplet.scribe_line_left * db_->getDbuPerMicron());
322+
chip->setScribeLineNorth(chiplet.scribe_line_top * db_->getDbuPerMicron());
323+
chip->setScribeLineSouth(chiplet.scribe_line_bottom
324+
* db_->getDbuPerMicron());
325+
}
326+
if (chiplet.seal_ring_right != -1.0) {
327+
chip->setSealRingEast(chiplet.seal_ring_right * db_->getDbuPerMicron());
328+
chip->setSealRingWest(chiplet.seal_ring_left * db_->getDbuPerMicron());
329+
chip->setSealRingNorth(chiplet.seal_ring_top * db_->getDbuPerMicron());
330+
chip->setSealRingSouth(chiplet.seal_ring_bottom * db_->getDbuPerMicron());
331+
}
320332

321333
chip->setOffset(Point(chiplet.offset.x * db_->getDbuPerMicron(),
322334
chiplet.offset.y * db_->getDbuPerMicron()));
323335
if (chip->getChipType() != dbChip::ChipType::HIER
324336
&& chip->getBlock() == nullptr) {
325337
// blackbox stage, create block
326338
auto block = odb::dbBlock::create(chip, chiplet.name.c_str());
327-
block->setDieArea(Rect(0, 0, chip->getWidth(), chip->getHeight()));
328-
block->setCoreArea(Rect(0, 0, chip->getWidth(), chip->getHeight()));
339+
const int x_min = chip->getScribeLineWest() + chip->getSealRingWest();
340+
const int y_min = chip->getScribeLineSouth() + chip->getSealRingSouth();
341+
const int x_max = x_min + chip->getWidth();
342+
const int y_max = y_min + chip->getHeight();
343+
block->setDieArea(Rect(x_min, y_min, x_max, y_max));
344+
block->setCoreArea(Rect(x_min, y_min, x_max, y_max));
329345
}
330346
for (const auto& [_, region] : chiplet.regions) {
331347
createRegion(region, chip);
@@ -405,8 +421,11 @@ void ThreeDBlox::createBump(const BumpMapEntry& entry,
405421
auto bump = dbChipBump::create(chip_region, inst);
406422
Rect bbox;
407423
inst->getMaster()->getPlacementBoundary(bbox);
408-
inst->setOrigin((entry.x * db_->getDbuPerMicron()) - bbox.xCenter(),
409-
(entry.y * db_->getDbuPerMicron()) - bbox.yCenter());
424+
int x = (entry.x * db_->getDbuPerMicron()) - bbox.xCenter()
425+
+ chip->getOffset().x();
426+
int y = (entry.y * db_->getDbuPerMicron()) - bbox.yCenter()
427+
+ chip->getOffset().y();
428+
inst->setOrigin(x, y);
410429
inst->setPlacementStatus(dbPlacementStatus::FIRM);
411430
if (entry.net_name != "-") {
412431
auto net = block->findNet(entry.net_name.c_str());
@@ -454,9 +473,6 @@ void ThreeDBlox::createChipInst(const ChipletInst& chip_inst)
454473
chip_inst.name);
455474
}
456475
dbChipInst* inst = dbChipInst::create(db_->getChip(), chip, chip_inst.name);
457-
inst->setLoc(Point3D(chip_inst.loc.x * db_->getDbuPerMicron(),
458-
chip_inst.loc.y * db_->getDbuPerMicron(),
459-
chip_inst.z * db_->getDbuPerMicron()));
460476
auto orient_str = chip_inst.orient;
461477
if (dup_orient_map.find(orient_str) != dup_orient_map.end()) {
462478
orient_str = dup_orient_map[orient_str];
@@ -470,6 +486,9 @@ void ThreeDBlox::createChipInst(const ChipletInst& chip_inst)
470486
chip_inst.name);
471487
}
472488
inst->setOrient(orient.value());
489+
inst->setLoc(Point3D(chip_inst.loc.x * db_->getDbuPerMicron(),
490+
chip_inst.loc.y * db_->getDbuPerMicron(),
491+
chip_inst.z * db_->getDbuPerMicron()));
473492
}
474493
std::vector<std::string> splitPath(const std::string& path)
475494
{

0 commit comments

Comments
 (0)