@@ -427,7 +427,6 @@ void SACoreSoftMacro::calBoundaryPenalty()
427427// 1) Number of macros to prioritize clusters with more macros.
428428// 2) The macro area percentage over the cluster's total area so that
429429// mixed clusters with large std cell area have less penalty.
430-
431430void SACoreSoftMacro::calMacroBlockagePenalty ()
432431{
433432 macro_blockage_penalty_ = 0.0 ;
@@ -445,32 +444,22 @@ void SACoreSoftMacro::calMacroBlockagePenalty()
445444
446445 for (auto & blockage : blockages_) {
447446 for (const auto & macro_id : pos_seq_) {
448- if (macros_[macro_id].getNumMacro () > 0 ) {
449- const float soft_macro_x_min = macros_[macro_id].getX ();
450- const float soft_macro_x_max
451- = soft_macro_x_min + macros_[macro_id].getWidth ();
452- const float soft_macro_y_min = macros_[macro_id].getY ();
453- const float soft_macro_y_max
454- = soft_macro_y_min + macros_[macro_id].getHeight ();
455-
456- const float overlap_width
457- = std::min (blockage.xMax (), soft_macro_x_max)
458- - std::max (blockage.xMin (), soft_macro_x_min);
459- const float overlap_height
460- = std::min (blockage.yMax (), soft_macro_y_max)
461- - std::max (blockage.yMin (), soft_macro_y_min);
447+ const SoftMacro& soft_macro = macros_[macro_id];
448+ if (soft_macro.getNumMacro () > 0 ) {
449+ Tiling overlap_shape
450+ = computeOverlapShape (blockage, soft_macro.getBBox ());
462451
463452 // If any of the dimensions is negative, then there's no overlap.
464- if (overlap_width < 0 || overlap_height < 0 ) {
453+ if (overlap_shape. width () < 0 || overlap_shape. height () < 0 ) {
465454 continue ;
466455 }
467456
468- Cluster* cluster = macros_[macro_id] .getCluster ();
457+ Cluster* cluster = soft_macro .getCluster ();
469458 float macro_dominance = cluster->getMacroArea () / cluster->getArea ();
470459
471- macro_blockage_penalty_ += overlap_width * overlap_height
472- * macros_[macro_id]. getNumMacro ()
473- * macro_dominance;
460+ macro_blockage_penalty_ += overlap_shape. width ()
461+ * overlap_shape. height ()
462+ * soft_macro. getNumMacro () * macro_dominance;
474463 }
475464 }
476465 }
@@ -1086,4 +1075,15 @@ void SACoreSoftMacro::moveFloorplan(const std::pair<float, float>& offset)
10861075 calPenalty ();
10871076}
10881077
1078+ Tiling SACoreSoftMacro::computeOverlapShape (const Rect& rect_a,
1079+ const Rect& rect_b) const
1080+ {
1081+ const float overlap_width = std::min (rect_a.xMax (), rect_b.xMax ())
1082+ - std::max (rect_a.xMin (), rect_b.xMin ());
1083+ const float overlap_height = std::min (rect_a.yMax (), rect_b.yMax ())
1084+ - std::max (rect_a.yMin (), rect_b.yMin ());
1085+
1086+ return Tiling (overlap_width, overlap_height);
1087+ }
1088+
10891089} // namespace mpl
0 commit comments