@@ -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+
21982228void 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+
22782320void 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
23092360void dbBlock::setExtmi (void * ext)
0 commit comments