@@ -85,8 +85,16 @@ SimulatedAnnealingCore<T>::SimulatedAnnealingCore(PhysicalHierarchy* tree,
8585 logger_ = logger;
8686 macros_ = macros;
8787
88+ setDieArea (tree->die_area );
8889 setBlockedBoundariesForIOs ();
89- die_hpwl_ = tree->die_area .getPerimeter () / 2 ;
90+ }
91+
92+ template <class T >
93+ void SimulatedAnnealingCore<T>::setDieArea(const Rect& die_area)
94+ {
95+ die_area_ = die_area;
96+ die_area_.moveHor (-outline_.xMin ());
97+ die_area_.moveVer (-outline_.yMin ());
9098}
9199
92100template <class T >
@@ -326,47 +334,42 @@ void SimulatedAnnealingCore<T>::calWirelength()
326334template <class T >
327335void SimulatedAnnealingCore<T>::addBoundaryDistToWirelength(
328336 const T& macro,
329- const T& io ,
337+ const T& unplaced_ios ,
330338 const float net_weight)
331339{
340+ // To generate maximum cost.
341+ const float max_dist = die_area_.getPerimeter () / 2 ;
342+
332343 if (isOutsideTheOutline (macro)) {
333- wirelength_ += net_weight * die_hpwl_ ;
344+ wirelength_ += net_weight * max_dist ;
334345 return ;
335346 }
336347
337348 const float x1 = macro.getPinX ();
338349 const float y1 = macro.getPinY ();
339350
340- Boundary constraint_boundary = io.getCluster ()->getConstraintBoundary ();
351+ Boundary constraint_boundary
352+ = unplaced_ios.getCluster ()->getConstraintBoundary ();
341353
342354 if (constraint_boundary == NONE) {
343- // We need to use the bbox of the SoftMacro and NOT the Cluster to
344- // get shape of the cluster of unconstrained IOs - which has the
345- // shape of the die but it's offset based on the current outline.
346- // Reminder:
347- // - The SoftMacro bbox is the bbox w.r.t to the current outline.
348- // - The Cluster bbox is the bbox w.r.t. to the origin of the actual
349- // die area.
350- const Rect& offset_die = io.getBBox ();
351-
352- float dist_to_left = die_hpwl_;
355+ float dist_to_left = max_dist;
353356 if (!left_is_blocked_) {
354- dist_to_left = std::abs (x1 - offset_die .xMin ());
357+ dist_to_left = std::abs (x1 - die_area_ .xMin ());
355358 }
356359
357- float dist_to_right = die_hpwl_ ;
360+ float dist_to_right = max_dist ;
358361 if (!right_is_blocked_) {
359- dist_to_right = std::abs (x1 - offset_die .xMax ());
362+ dist_to_right = std::abs (x1 - die_area_ .xMax ());
360363 }
361364
362- float dist_to_bottom = die_hpwl_ ;
365+ float dist_to_bottom = max_dist ;
363366 if (!bottom_is_blocked_) {
364- dist_to_right = std::abs (y1 - offset_die .yMin ());
367+ dist_to_right = std::abs (y1 - die_area_ .yMin ());
365368 }
366369
367- float dist_to_top = die_hpwl_ ;
370+ float dist_to_top = max_dist ;
368371 if (!top_is_blocked_) {
369- dist_to_top = std::abs (y1 - offset_die .yMax ());
372+ dist_to_top = std::abs (y1 - die_area_ .yMax ());
370373 }
371374
372375 wirelength_
@@ -375,11 +378,11 @@ void SimulatedAnnealingCore<T>::addBoundaryDistToWirelength(
375378 {dist_to_left, dist_to_right, dist_to_bottom, dist_to_top});
376379 } else if (constraint_boundary == Boundary::L
377380 || constraint_boundary == Boundary::R) {
378- const float x2 = io .getPinX ();
381+ const float x2 = unplaced_ios .getPinX ();
379382 wirelength_ += net_weight * std::abs (x2 - x1);
380383 } else if (constraint_boundary == Boundary::T
381384 || constraint_boundary == Boundary::B) {
382- const float y2 = io .getPinY ();
385+ const float y2 = unplaced_ios .getPinY ();
383386 wirelength_ += net_weight * std::abs (y2 - y1);
384387 }
385388}
0 commit comments