@@ -29,9 +29,7 @@ SACoreSoftMacro::SACoreSoftMacro(PhysicalHierarchy* tree,
2929 const Rect& outline,
3030 const std::vector<SoftMacro>& macros,
3131 const SACoreWeights& core_weights,
32- float boundary_weight,
33- float macro_blockage_weight,
34- float notch_weight,
32+ const SASoftWeights& soft_weights,
3533 // notch threshold
3634 float notch_h_threshold,
3735 float notch_v_threshold,
@@ -66,9 +64,9 @@ SACoreSoftMacro::SACoreSoftMacro(PhysicalHierarchy* tree,
6664 block),
6765 root_ (tree->root.get())
6866{
69- boundary_weight_ = boundary_weight ;
70- macro_blockage_weight_ = macro_blockage_weight ;
71- notch_weight_ = notch_weight ;
67+ boundary_weight_ = soft_weights. boundary ;
68+ macro_blockage_weight_ = soft_weights. macro_blockage ;
69+ notch_weight_ = soft_weights. notch ;
7270 resize_prob_ = resize_prob;
7371 notch_h_th_ = notch_h_threshold;
7472 notch_v_th_ = notch_v_threshold;
@@ -429,7 +427,6 @@ void SACoreSoftMacro::calBoundaryPenalty()
429427// 1) Number of macros to prioritize clusters with more macros.
430428// 2) The macro area percentage over the cluster's total area so that
431429// mixed clusters with large std cell area have less penalty.
432-
433430void SACoreSoftMacro::calMacroBlockagePenalty ()
434431{
435432 macro_blockage_penalty_ = 0.0 ;
@@ -447,32 +444,22 @@ void SACoreSoftMacro::calMacroBlockagePenalty()
447444
448445 for (auto & blockage : blockages_) {
449446 for (const auto & macro_id : pos_seq_) {
450- if (macros_[macro_id].getNumMacro () > 0 ) {
451- const float soft_macro_x_min = macros_[macro_id].getX ();
452- const float soft_macro_x_max
453- = soft_macro_x_min + macros_[macro_id].getWidth ();
454- const float soft_macro_y_min = macros_[macro_id].getY ();
455- const float soft_macro_y_max
456- = soft_macro_y_min + macros_[macro_id].getHeight ();
457-
458- const float overlap_width
459- = std::min (blockage.xMax (), soft_macro_x_max)
460- - std::max (blockage.xMin (), soft_macro_x_min);
461- const float overlap_height
462- = std::min (blockage.yMax (), soft_macro_y_max)
463- - 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 ());
464451
465452 // If any of the dimensions is negative, then there's no overlap.
466- if (overlap_width < 0 || overlap_height < 0 ) {
453+ if (overlap_shape. width () < 0 || overlap_shape. height () < 0 ) {
467454 continue ;
468455 }
469456
470- Cluster* cluster = macros_[macro_id] .getCluster ();
457+ Cluster* cluster = soft_macro .getCluster ();
471458 float macro_dominance = cluster->getMacroArea () / cluster->getArea ();
472459
473- macro_blockage_penalty_ += overlap_width * overlap_height
474- * macros_[macro_id]. getNumMacro ()
475- * macro_dominance;
460+ macro_blockage_penalty_ += overlap_shape. width ()
461+ * overlap_shape. height ()
462+ * soft_macro. getNumMacro () * macro_dominance;
476463 }
477464 }
478465 }
@@ -967,4 +954,15 @@ void SACoreSoftMacro::moveFloorplan(const std::pair<float, float>& offset)
967954 calPenalty ();
968955}
969956
957+ Tiling SACoreSoftMacro::computeOverlapShape (const Rect& rect_a,
958+ const Rect& rect_b) const
959+ {
960+ const float overlap_width = std::min (rect_a.xMax (), rect_b.xMax ())
961+ - std::max (rect_a.xMin (), rect_b.xMin ());
962+ const float overlap_height = std::min (rect_a.yMax (), rect_b.yMax ())
963+ - std::max (rect_a.yMin (), rect_b.yMin ());
964+
965+ return Tiling (overlap_width, overlap_height);
966+ }
967+
970968} // namespace mpl
0 commit comments