@@ -36,10 +36,9 @@ SimulatedAnnealingCore<T>::SimulatedAnnealingCore(PhysicalHierarchy* tree,
3636 int num_perturb_per_step,
3737 unsigned seed,
3838 MplObserver* graphics,
39- utl::Logger* logger)
40- : outline_(outline),
41- blocked_boundaries_ (tree->blocked_boundaries),
42- graphics_(graphics)
39+ utl::Logger* logger,
40+ odb::dbBlock* block)
41+ : outline_(outline), graphics_(graphics), block_(block)
4342{
4443 core_weights_ = weights;
4544
@@ -62,7 +61,10 @@ SimulatedAnnealingCore<T>::SimulatedAnnealingCore(PhysicalHierarchy* tree,
6261 macros_ = macros;
6362
6463 setDieArea (tree->die_area );
65- setBlockedBoundariesForIOs ();
64+ setAvailableRegionsForUnconstrainedPins (
65+ tree->available_regions_for_unconstrained_pins );
66+
67+ io_cluster_to_constraint_ = tree->io_cluster_to_constraint ;
6668}
6769
6870template <class T >
@@ -74,22 +76,14 @@ void SimulatedAnnealingCore<T>::setDieArea(const Rect& die_area)
7476}
7577
7678template <class T >
77- void SimulatedAnnealingCore<T>::setBlockedBoundariesForIOs()
79+ void SimulatedAnnealingCore<T>::setAvailableRegionsForUnconstrainedPins(
80+ const BoundaryRegionList& regions)
7881{
79- if (blocked_boundaries_.find (Boundary::L) != blocked_boundaries_.end ()) {
80- left_is_blocked_ = true ;
81- }
82-
83- if (blocked_boundaries_.find (Boundary::R) != blocked_boundaries_.end ()) {
84- right_is_blocked_ = true ;
85- }
82+ available_regions_for_unconstrained_pins_ = regions;
8683
87- if (blocked_boundaries_.find (Boundary::B) != blocked_boundaries_.end ()) {
88- bottom_is_blocked_ = true ;
89- }
90-
91- if (blocked_boundaries_.find (Boundary::T) != blocked_boundaries_.end ()) {
92- top_is_blocked_ = true ;
84+ for (BoundaryRegion& region : available_regions_for_unconstrained_pins_) {
85+ region.line .addX (-block_->micronsToDbu (outline_.xMin ()));
86+ region.line .addY (-block_->micronsToDbu (outline_.yMin ()));
9387 }
9488}
9589
@@ -284,7 +278,7 @@ void SimulatedAnnealingCore<T>::calWirelength()
284278 T& target = macros_[net.terminals .second ];
285279
286280 if (target.isClusterOfUnplacedIOPins ()) {
287- addBoundaryDistToWirelength (source, target, net.weight );
281+ computeWLForClusterOfUnplacedIOPins (source, target, net.weight );
288282 continue ;
289283 }
290284
@@ -308,7 +302,7 @@ void SimulatedAnnealingCore<T>::calWirelength()
308302}
309303
310304template <class T >
311- void SimulatedAnnealingCore<T>::addBoundaryDistToWirelength (
305+ void SimulatedAnnealingCore<T>::computeWLForClusterOfUnplacedIOPins (
312306 const T& macro,
313307 const T& unplaced_ios,
314308 const float net_weight)
@@ -321,46 +315,27 @@ void SimulatedAnnealingCore<T>::addBoundaryDistToWirelength(
321315 return ;
322316 }
323317
324- const float x1 = macro.getPinX ();
325- const float y1 = macro.getPinY ();
326-
327- Boundary constraint_boundary
328- = unplaced_ios.getCluster ()->getConstraintBoundary ();
329-
330- if (constraint_boundary == NONE ) {
331- float dist_to_left = max_dist;
332- if (!left_is_blocked_) {
333- dist_to_left = std::abs (x1 - die_area_.xMin ());
318+ const odb::Point macro_location (block_->micronsToDbu (macro.getPinX ()),
319+ block_->micronsToDbu (macro.getPinY ()));
320+ double smallest_distance;
321+ if (unplaced_ios.getCluster ()->isClusterOfUnconstrainedIOPins ()) {
322+ if (available_regions_for_unconstrained_pins_.empty ()) {
323+ logger_->critical (
324+ utl::MPL ,
325+ 47 ,
326+ " There's no available region for the unconstrained pins!" );
334327 }
335328
336- float dist_to_right = max_dist;
337- if (!right_is_blocked_) {
338- dist_to_right = std::abs (x1 - die_area_.xMax ());
339- }
340-
341- float dist_to_bottom = max_dist;
342- if (!bottom_is_blocked_) {
343- dist_to_right = std::abs (y1 - die_area_.yMin ());
344- }
345-
346- float dist_to_top = max_dist;
347- if (!top_is_blocked_) {
348- dist_to_top = std::abs (y1 - die_area_.yMax ());
349- }
350-
351- wirelength_
352- += net_weight
353- * std::min (
354- {dist_to_left, dist_to_right, dist_to_bottom, dist_to_top});
355- } else if (constraint_boundary == Boundary::L
356- || constraint_boundary == Boundary::R) {
357- const float x2 = unplaced_ios.getPinX ();
358- wirelength_ += net_weight * std::abs (x2 - x1);
359- } else if (constraint_boundary == Boundary::T
360- || constraint_boundary == Boundary::B) {
361- const float y2 = unplaced_ios.getPinY ();
362- wirelength_ += net_weight * std::abs (y2 - y1);
329+ smallest_distance = computeDistToNearestRegion (
330+ macro_location, available_regions_for_unconstrained_pins_, nullptr );
331+ } else {
332+ Cluster* cluster = unplaced_ios.getCluster ();
333+ const BoundaryRegion& constraint = io_cluster_to_constraint_.at (cluster);
334+ smallest_distance
335+ = computeDistToNearestRegion (macro_location, {constraint}, nullptr );
363336 }
337+
338+ wirelength_ += net_weight * block_->dbuToMicrons (smallest_distance);
364339}
365340
366341// We consider the macro outside the outline based on the location of
0 commit comments