@@ -1730,6 +1730,8 @@ Polygon dbBlock::getBTermTopLayerGridRegion()
17301730
17311731Rect dbBlock::findConstraintRegion (const Direction2D& edge, int begin, int end)
17321732{
1733+ _dbBlock* block = (_dbBlock*) this ;
1734+ block->ensureConstraintRegion (edge, begin, end);
17331735 Rect constraint_region;
17341736 const Rect& die_bounds = getDieArea ();
17351737 if (edge == south) {
@@ -3633,4 +3635,36 @@ void _dbBlock::collectMemInfo(MemInfo& info)
36333635 info.children_ [" module_name_id_map" ].add (_module_name_id_map);
36343636}
36353637
3638+ void _dbBlock::ensureConstraintRegion (const Direction2D& edge,
3639+ int & begin,
3640+ int & end)
3641+ {
3642+ // / Ensure that the constraint region defined in the given edge is completely
3643+ // / inside the die area.
3644+ dbBlock* block = (dbBlock*) this ;
3645+ const int input_begin = begin;
3646+ const int input_end = end;
3647+ const Rect& die_bounds = block->getDieArea ();
3648+ if (edge == south || edge == north) {
3649+ begin = std::max (begin, die_bounds.xMin ());
3650+ end = std::min (end, die_bounds.xMax ());
3651+ } else if (edge == west || edge == east) {
3652+ begin = std::max (begin, die_bounds.yMin ());
3653+ end = std::min (end, die_bounds.yMax ());
3654+ }
3655+
3656+ if (input_begin != begin || input_end != end) {
3657+ utl::Logger* logger = getImpl ()->getLogger ();
3658+ logger->warn (utl::ODB,
3659+ 11 ,
3660+ " Region {}-{} on edge {} modified to {}-{} to respect the "
3661+ " die area limits." ,
3662+ block->dbuToMicrons (input_begin),
3663+ block->dbuToMicrons (input_end),
3664+ edge,
3665+ block->dbuToMicrons (begin),
3666+ block->dbuToMicrons (end));
3667+ }
3668+ }
3669+
36363670} // namespace odb
0 commit comments