44#include " hier_rtlmp.h"
55
66#include < algorithm>
7+ #include < boost/polygon/polygon.hpp>
78#include < cmath>
89#include < fstream>
910#include < iostream>
2930#include " mpl-util.h"
3031#include " object.h"
3132#include " odb/db.h"
32- #include " odb/geom .h"
33+ #include " odb/geom_boost .h"
3334#include " odb/util.h"
3435#include " par/PartitionMgr.h"
3536#include " utl/Logger.h"
@@ -850,22 +851,26 @@ void HierRTLMP::setTightPackingTilings(Cluster* macro_array)
850851{
851852 TilingList tight_packing_tilings;
852853
853- int divider = 1 ;
854- int columns = 0 , rows = 0 ;
854+ int num_macro = static_cast <int >(macro_array->getNumMacro ());
855+ float macro_width = macro_array->getHardMacros ().front ()->getWidth ();
856+ float macro_height = macro_array->getHardMacros ().front ()->getHeight ();
855857
856- while (divider <= macro_array->getNumMacro ()) {
857- if (macro_array->getNumMacro () % divider == 0 ) {
858- columns = macro_array->getNumMacro () / divider;
859- rows = divider;
858+ const Rect outline = tree_->root ->getBBox ();
859+
860+ int columns = 0 ;
861+ for (int rows = 1 ; rows < std::sqrt (num_macro) + 1 ; rows++) {
862+ if (num_macro % rows == 0 ) {
863+ columns = num_macro / rows;
860864
861865 // We don't consider tilings for right angle rotation orientations,
862866 // because they're not allowed in our macro placer.
863- tight_packing_tilings.emplace_back (
864- columns * macro_array->getHardMacros ().front ()->getWidth (),
865- rows * macro_array->getHardMacros ().front ()->getHeight ());
867+ // Tiling needs to fit inside outline
868+ if (columns * macro_width <= outline.getWidth ()
869+ && rows * macro_height <= outline.getHeight ()) {
870+ tight_packing_tilings.emplace_back (columns * macro_width,
871+ rows * macro_height);
872+ }
866873 }
867-
868- ++divider;
869874 }
870875
871876 macro_array->setTilings (tight_packing_tilings);
@@ -932,8 +937,20 @@ void HierRTLMP::computePinAccessDepthLimits()
932937 pin_access_depth_limits_.y .max = max_depth_proportion * die.getHeight ();
933938
934939 constexpr float min_depth_proportion = 0.04 ;
935- pin_access_depth_limits_.x .min = min_depth_proportion * die.getWidth ();
936- pin_access_depth_limits_.y .min = min_depth_proportion * die.getHeight ();
940+ const float proportional_min_width = min_depth_proportion * die.getWidth ();
941+ const float proportional_min_height = min_depth_proportion * die.getHeight ();
942+
943+ const Tiling tiling = tree_->root ->getTilings ().front ();
944+ // Required for designs that are too tight (i.e. MockArray)
945+ const float tiling_min_width
946+ = std::floor ((die.getWidth () - tiling.width ())) / 2 ;
947+ const float tiling_min_height
948+ = std::floor ((die.getHeight () - tiling.height ())) / 2 ;
949+
950+ pin_access_depth_limits_.x .min
951+ = std::min (proportional_min_width, tiling_min_width);
952+ pin_access_depth_limits_.y .min
953+ = std::min (proportional_min_height, tiling_min_height);
937954
938955 if (logger_->debugCheck (MPL, " coarse_shaping" , 1 )) {
939956 logger_->report (" \n Pin Access Depth (μm) | Min | Max" );
@@ -1385,10 +1402,9 @@ void HierRTLMP::placeChildren(Cluster* parent, bool ignore_std_cell_area)
13851402 std::vector<SoftMacro> macros;
13861403 std::vector<BundledNet> nets;
13871404
1388- std::vector<Rect> placement_blockages;
1389- std::vector<Rect> macro_blockages;
1390-
1391- findBlockagesWithinOutline (macro_blockages, placement_blockages, outline);
1405+ std::vector<Rect> blockages = findBlockagesWithinOutline (outline);
1406+ eliminateOverlaps (blockages);
1407+ createSoftMacrosForBlockages (blockages, macros);
13921408
13931409 // We store the io clusters to push them into the macros' vector
13941410 // only after it is already populated with the clusters we're trying to
@@ -1655,8 +1671,6 @@ void HierRTLMP::placeChildren(Cluster* parent, bool ignore_std_cell_area)
16551671 sa->setFences (fences);
16561672 sa->setGuides (guides);
16571673 sa->setNets (nets);
1658- sa->addBlockages (placement_blockages);
1659- sa->addBlockages (macro_blockages);
16601674 sa_batch.push_back (std::move (sa));
16611675 }
16621676
@@ -1733,23 +1747,20 @@ void HierRTLMP::placeChildren(Cluster* parent, bool ignore_std_cell_area)
17331747}
17341748
17351749// Find the area of blockages that are inside the outline.
1736- void HierRTLMP::findBlockagesWithinOutline (
1737- std::vector<Rect>& macro_blockages,
1738- std::vector<Rect>& placement_blockages,
1750+ std::vector<Rect> HierRTLMP::findBlockagesWithinOutline (
17391751 const Rect& outline) const
17401752{
1753+ std::vector<Rect> blockages_within_outline;
1754+
17411755 for (auto & blockage : placement_blockages_) {
1742- getBlockageRegionWithinOutline (placement_blockages , blockage, outline);
1756+ getBlockageRegionWithinOutline (blockages_within_outline , blockage, outline);
17431757 }
17441758
17451759 for (auto & blockage : io_blockages_) {
1746- getBlockageRegionWithinOutline (macro_blockages , blockage, outline);
1760+ getBlockageRegionWithinOutline (blockages_within_outline , blockage, outline);
17471761 }
17481762
1749- if (graphics_) {
1750- graphics_->setMacroBlockages (macro_blockages);
1751- graphics_->setPlacementBlockages (placement_blockages);
1752- }
1763+ return blockages_within_outline;
17531764}
17541765
17551766void HierRTLMP::getBlockageRegionWithinOutline (
@@ -1770,6 +1781,37 @@ void HierRTLMP::getBlockageRegionWithinOutline(
17701781 }
17711782}
17721783
1784+ void HierRTLMP::eliminateOverlaps (std::vector<Rect>& blockages) const
1785+ {
1786+ namespace gtl = boost::polygon;
1787+ using gtl::operators::operator +=;
1788+ using PolygonSet = gtl::polygon_90_set_data<int >;
1789+
1790+ PolygonSet polygons;
1791+ for (const Rect& blockage : blockages) {
1792+ const odb::Rect dbu_blockage = micronsToDbu (block_, blockage);
1793+ polygons += dbu_blockage;
1794+ }
1795+
1796+ blockages.clear ();
1797+
1798+ std::vector<odb::Rect> new_blockages;
1799+ polygons.get_rectangles (new_blockages);
1800+
1801+ for (const odb::Rect& new_blockage : new_blockages) {
1802+ blockages.push_back (dbuToMicrons (block_, new_blockage));
1803+ }
1804+ }
1805+
1806+ void HierRTLMP::createSoftMacrosForBlockages (const std::vector<Rect>& blockages,
1807+ std::vector<SoftMacro>& macros)
1808+ {
1809+ for (int id = 0 ; id < blockages.size (); id++) {
1810+ std::string name = fmt::format (" blockage_{}" , id);
1811+ macros.emplace_back (blockages[id], name);
1812+ }
1813+ }
1814+
17731815// Create terminals for cluster placement (Soft) annealing.
17741816void HierRTLMP::createFixedTerminals (
17751817 Cluster* parent,
@@ -1943,10 +1985,14 @@ bool HierRTLMP::runFineShaping(Cluster* parent,
19431985 MPL,
19441986 " fine_shaping" ,
19451987 1 ,
1946- " No valid solution for children of {}"
1947- " avail_space = {}, min_target_util = {}" ,
1988+ " No valid solution for children of {} "
1989+ " std_cell_area = {} avail_space = {} pa area = {} "
1990+ " std_cell_mixed_area = {} min_target_util = {}" ,
19481991 parent->getName (),
1992+ std_cell_cluster_area,
19491993 avail_space,
1994+ pin_access_area,
1995+ std_cell_mixed_cluster_area,
19501996 min_target_util);
19511997
19521998 return false ;
0 commit comments