Skip to content

Commit 40063b9

Browse files
authored
Merge pull request #8628 from gadfort/core-area
odb: save core area as a polygon
2 parents 9a0e3df + 492628a commit 40063b9

File tree

10 files changed

+109
-18
lines changed

10 files changed

+109
-18
lines changed

src/gui/src/renderThread.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,17 +1112,21 @@ void RenderThread::drawBlock(QPainter* painter,
11121112
viewer_->pixels_per_dbu_,
11131113
block->getDbUnitsPerMicron());
11141114

1115-
// Draw die area, if set
11161115
painter->setPen(QPen(Qt::gray, 0));
11171116
painter->setBrush(QBrush());
1118-
odb::Polygon die_area = block->getDieAreaPolygon();
1117+
1118+
// Draw die area, if set
1119+
const odb::Polygon die_area = block->getDieAreaPolygon();
11191120

11201121
if (die_area.getEnclosingRect().area() > 0) {
1121-
QPolygon die_area_qpoly;
1122-
for (const odb::Point& point : die_area.getPoints()) {
1123-
die_area_qpoly << QPoint(point.getX(), point.getY());
1124-
}
1125-
painter->drawPolygon(die_area_qpoly);
1122+
gui_painter.drawPolygon(die_area);
1123+
}
1124+
1125+
// Draw core area, if set
1126+
const odb::Polygon core_area = block->getCoreAreaPolygon();
1127+
1128+
if (core_area.getEnclosingRect().area() > 0) {
1129+
gui_painter.drawPolygon(core_area);
11261130
}
11271131

11281132
drawManufacturingGrid(painter, bounds);

src/gui/src/search.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ void Search::inDbBlockSetDieArea(odb::dbBlock* block)
126126
setTopBlock(block);
127127
}
128128

129+
void Search::inDbBlockSetCoreArea(odb::dbBlock* block)
130+
{
131+
emit modified();
132+
}
133+
129134
void Search::inDbRegionAddBox(odb::dbRegion*, odb::dbBox*)
130135
{
131136
emit modified();

src/gui/src/search.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ class Search : public QObject, public odb::dbBlockCallBackObj
235235
void inDbSWireAddSBox(odb::dbSBox* box) override;
236236
void inDbSWireRemoveSBox(odb::dbSBox* box) override;
237237
void inDbBlockSetDieArea(odb::dbBlock* block) override;
238+
void inDbBlockSetCoreArea(odb::dbBlock* block) override;
238239
void inDbBlockageCreate(odb::dbBlockage* blockage) override;
239240
void inDbBlockageDestroy(odb::dbBlockage* blockage) override;
240241
void inDbObstructionCreate(odb::dbObstruction* obs) override;

src/ifp/src/InitFloorplan.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ void InitFloorplan::makeUniformRows(odb::dbSite* base_site,
709709
}
710710
make_rows(site);
711711
}
712+
block_->setCoreArea(block_->computeCoreArea());
712713
}
713714

714715
int InitFloorplan::getOffset(dbSite* base_hybrid_site,
@@ -831,6 +832,7 @@ void InitFloorplan::makeHybridRows(dbSite* base_hybrid_site,
831832
make_rows(site);
832833
}
833834
}
835+
block_->setCoreArea(block_->computeCoreArea());
834836
}
835837

836838
dbSite* InitFloorplan::findSite(const char* site_name)
@@ -1293,6 +1295,8 @@ void InitFloorplan::makeUniformRowsPolygon(
12931295
y += site_dy;
12941296
}
12951297

1298+
block_->setCoreArea(block_->computeCoreArea());
1299+
12961300
logger_->info(IFP,
12971301
1002,
12981302
"Added {} polygon-aware rows for site {}.",

src/odb/include/odb/db.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,11 +1118,30 @@ class dbBlock : public dbObject
11181118
Polygon getDieAreaPolygon();
11191119

11201120
///
1121-
/// Get the core area. This computes the bbox of the rows
1122-
/// and is O(#rows) in runtime.
1121+
/// Compute the core area based on rows
1122+
///
1123+
odb::Polygon computeCoreArea();
1124+
1125+
///
1126+
/// Set the core area.
1127+
///
1128+
void setCoreArea(const Rect& new_area);
1129+
1130+
///
1131+
/// Set the core area with polygon. Allows for non-rectangular floorplans
1132+
///
1133+
void setCoreArea(const Polygon& new_area);
1134+
1135+
///
1136+
/// Get the core area.
11231137
///
11241138
Rect getCoreArea();
11251139

1140+
///
1141+
/// Get the core area.
1142+
///
1143+
Polygon getCoreAreaPolygon();
1144+
11261145
///
11271146
/// Add region in the die area where IO pins cannot be placed
11281147
///

src/odb/include/odb/dbBlockCallBackObj.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ class dbBlockCallBackObj
192192
virtual void inDbBlockStreamOutAfter(dbBlock*) {}
193193
virtual void inDbBlockReadNetsBefore(dbBlock*) {}
194194
virtual void inDbBlockSetDieArea(dbBlock*) {}
195+
virtual void inDbBlockSetCoreArea(dbBlock*) {}
195196

196197
// allow ECO client initialization - payam
197198
virtual dbBlockCallBackObj& operator()() { return *this; }

src/odb/src/db/dbBlock.cpp

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ _dbBlock::_dbBlock(_dbDatabase* db)
181181
_corner_name_list = nullptr;
182182
_name = nullptr;
183183
_die_area = Rect(0, 0, 0, 0);
184+
_core_area = Rect(0, 0, 0, 0);
184185
_maxCapNodeId = 0;
185186
_maxRSegId = 0;
186187
_maxCCSegId = 0;
@@ -778,6 +779,7 @@ dbOStream& operator<<(dbOStream& stream, const _dbBlock& block)
778779
stream << block._corner_name_list;
779780
stream << block._name;
780781
stream << block._die_area;
782+
stream << block._core_area;
781783
stream << block._blocked_regions_for_pins;
782784
stream << block._chip;
783785
stream << block._bbox;
@@ -906,6 +908,9 @@ dbIStream& operator>>(dbIStream& stream, _dbBlock& block)
906908
stream >> rect;
907909
block._die_area = rect;
908910
}
911+
if (db->isSchema(db_schema_core_area_is_polygon)) {
912+
stream >> block._core_area;
913+
}
909914
if (db->isSchema(db_schema_dbblock_blocked_regions_for_pins)) {
910915
stream >> block._blocked_regions_for_pins;
911916
}
@@ -1078,6 +1083,12 @@ dbIStream& operator>>(dbIStream& stream, _dbBlock& block)
10781083
chip->tech_ = old_db_tech;
10791084
}
10801085

1086+
if (!db->isSchema(db_schema_core_area_is_polygon)) {
1087+
// Wait for rows to be available
1088+
dbBlock* blk = (dbBlock*) (&block);
1089+
block._core_area = blk->computeCoreArea();
1090+
}
1091+
10811092
return stream;
10821093
}
10831094

@@ -1185,6 +1196,10 @@ bool _dbBlock::operator==(const _dbBlock& rhs) const
11851196
return false;
11861197
}
11871198

1199+
if (_core_area != rhs._core_area) {
1200+
return false;
1201+
}
1202+
11881203
if (_chip != rhs._chip) {
11891204
return false;
11901205
}
@@ -2195,6 +2210,21 @@ void dbBlock::getMasters(std::vector<dbMaster*>& masters)
21952210
}
21962211
}
21972212

2213+
void dbBlock::setCoreArea(const Rect& new_area)
2214+
{
2215+
setCoreArea(Polygon(new_area));
2216+
}
2217+
2218+
void dbBlock::setCoreArea(const Polygon& new_area)
2219+
{
2220+
_dbBlock* block = (_dbBlock*) this;
2221+
2222+
block->_core_area = new_area;
2223+
for (auto callback : block->_callbacks) {
2224+
callback->inDbBlockSetCoreArea(this);
2225+
}
2226+
}
2227+
21982228
void dbBlock::setDieArea(const Rect& new_area)
21992229
{
22002230
_dbBlock* block = (_dbBlock*) this;
@@ -2275,6 +2305,18 @@ Polygon dbBlock::getDieAreaPolygon()
22752305
return block->_die_area;
22762306
}
22772307

2308+
Rect dbBlock::getCoreArea()
2309+
{
2310+
_dbBlock* block = (_dbBlock*) this;
2311+
return block->_core_area.getEnclosingRect();
2312+
}
2313+
2314+
Polygon dbBlock::getCoreAreaPolygon()
2315+
{
2316+
_dbBlock* block = (_dbBlock*) this;
2317+
return block->_core_area;
2318+
}
2319+
22782320
void dbBlock::addBlockedRegionForPins(const Rect& region)
22792321
{
22802322
_dbBlock* block = (_dbBlock*) this;
@@ -2287,23 +2329,32 @@ const std::vector<Rect>& dbBlock::getBlockedRegionsForPins()
22872329
return block->_blocked_regions_for_pins;
22882330
}
22892331

2290-
Rect dbBlock::getCoreArea()
2332+
Polygon dbBlock::computeCoreArea()
22912333
{
2292-
Rect rect;
2293-
rect.mergeInit();
2294-
2334+
std::vector<odb::Rect> rows;
22952335
for (dbRow* row : getRows()) {
22962336
if (row->getSite()->getClass() != odb::dbSiteClass::PAD) {
2297-
rect.merge(row->getBBox());
2337+
rows.push_back(row->getBBox());
22982338
}
22992339
}
23002340

2301-
if (!rect.isInverted()) {
2302-
return rect;
2341+
if (!rows.empty()) {
2342+
const auto polys = Polygon::merge(rows);
2343+
2344+
if (polys.size() > 1) {
2345+
odb::Rect area;
2346+
area.mergeInit();
2347+
for (const auto& row : rows) {
2348+
area.merge(row);
2349+
}
2350+
return area;
2351+
}
2352+
2353+
return polys[0];
23032354
}
23042355

23052356
// Default to die area if there aren't any rows.
2306-
return getDieArea();
2357+
return getDieAreaPolygon();
23072358
}
23082359

23092360
void dbBlock::setExtmi(void* ext)

src/odb/src/db/dbBlock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ class _dbBlock : public _dbObject
162162
char* _corner_name_list;
163163
char* _name;
164164
Polygon _die_area;
165+
Polygon _core_area;
165166
std::vector<Rect> _blocked_regions_for_pins;
166167
dbId<_dbChip> _chip;
167168
dbId<_dbBox> _bbox;

src/odb/src/db/dbDatabase.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,8 @@ void dbDatabase::triggerPostReadLef(dbTech* tech, dbLib* library)
913913

914914
void dbDatabase::triggerPostReadDef(dbBlock* block, const bool floorplan)
915915
{
916+
block->setCoreArea(block->computeCoreArea());
917+
916918
_dbDatabase* db = (_dbDatabase*) this;
917919
for (dbDatabaseObserver* observer : db->observers_) {
918920
if (floorplan) {

src/odb/src/db/dbDatabase.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ namespace odb {
4848
inline constexpr uint db_schema_major = 0; // Not used...
4949
inline constexpr uint db_schema_initial = 57;
5050

51-
inline constexpr uint db_schema_minor = 120; // Current revision number
51+
inline constexpr uint db_schema_minor = 121; // Current revision number
52+
53+
// Revision where core area is stored as a polygon
54+
inline constexpr uint db_schema_core_area_is_polygon = 121;
5255

5356
// Revision where _dbDatabase::dbu_per_micron_ was added
5457
inline constexpr uint db_schema_dbu_per_micron = 120;

0 commit comments

Comments
 (0)