2424#include " frBaseTypes.h"
2525#include " frDesign.h"
2626#include " frProfileTask.h"
27+ #include " global.h"
2728#include " odb/db.h"
2829#include " odb/dbTypes.h"
2930#include " odb/geom.h"
@@ -207,7 +208,8 @@ Point3D findBestPinLocation(frDesign* design,
207208 */
208209int findClosestGuide (const Point3D& best_pin_loc_coords,
209210 const std::vector<frRect>& guides,
210- const frCoord layer_change_penalty)
211+ const frCoord layer_change_penalty,
212+ const RouterConfiguration* router_cfg)
211213{
212214 int closest_guide_idx = 0 ;
213215 int dist = 0 ;
@@ -217,6 +219,9 @@ int findClosestGuide(const Point3D& best_pin_loc_coords,
217219 dist = odb::manhattanDistance (guide.getBBox (), best_pin_loc_coords);
218220 dist += abs (guide.getLayerNum () - best_pin_loc_coords.z ())
219221 * layer_change_penalty;
222+ if (guide.getLayerNum () < router_cfg->BOTTOM_ROUTING_LAYER ) {
223+ dist += 1e9 ;
224+ }
220225 if (dist < min_dist) {
221226 min_dist = dist;
222227 closest_guide_idx = guide_idx;
@@ -352,41 +357,6 @@ void fillGuidesUpToZ(const Point3D& best_pin_loc_coords,
352357 net);
353358 }
354359}
355- /* *
356- * @brief Connects the guides with the best pin shape location (on the 2D
357- * plane only)
358- *
359- * The function creates a patch guide that connects the closest guide to
360- * best_pin_loc_coords (without consideration to different layers)
361- *
362- * @param guide_pt The center of the gcell on the guide that is closest to
363- * best_pin_loc_coords
364- * @param best_pin_loc_coords The gcell center point of the chosen pin shape
365- * @param gcell_half_size_horz Half the horizontal size of the gcell
366- * @param gcell_half_size_vert Half the vertical size of the gcell
367- */
368- void connectGuidesWithBestPinLoc (const Point3D& guide_pt,
369- const odb::Point& best_pin_loc_coords,
370- const frCoord gcell_half_size_horz,
371- const frCoord gcell_half_size_vert,
372- frNet* net,
373- std::vector<frRect>& guides)
374- {
375- if (guide_pt.x () != best_pin_loc_coords.x ()
376- || guide_pt.y () != best_pin_loc_coords.y ()) {
377- const odb::Point pl = {std::min (best_pin_loc_coords.x (), guide_pt.x ()),
378- std::min (best_pin_loc_coords.y (), guide_pt.y ())};
379- const odb::Point ph = {std::max (best_pin_loc_coords.x (), guide_pt.x ()),
380- std::max (best_pin_loc_coords.y (), guide_pt.y ())};
381-
382- guides.emplace_back (pl.x () - gcell_half_size_horz,
383- pl.y () - gcell_half_size_vert,
384- ph.x () + gcell_half_size_horz,
385- ph.y () + gcell_half_size_vert,
386- guide_pt.z (),
387- net);
388- }
389- }
390360
391361/* *
392362 * @brief logs the number of guides read so far
@@ -949,6 +919,43 @@ void GuideProcessor::buildGCellPatterns()
949919 }
950920}
951921
922+ void GuideProcessor::connectGuidesWithBestPinLoc (
923+ Point3D& guide_pt,
924+ const odb::Point& best_pin_loc_coords,
925+ const frCoord gcell_half_size_horz,
926+ const frCoord gcell_half_size_vert,
927+ frNet* net,
928+ std::vector<frRect>& guides)
929+ {
930+ if (guide_pt.x () != best_pin_loc_coords.x ()
931+ || guide_pt.y () != best_pin_loc_coords.y ()) {
932+ const odb::Point pl = {std::min (best_pin_loc_coords.x (), guide_pt.x ()),
933+ std::min (best_pin_loc_coords.y (), guide_pt.y ())};
934+ const odb::Point ph = {std::max (best_pin_loc_coords.x (), guide_pt.x ()),
935+ std::max (best_pin_loc_coords.y (), guide_pt.y ())};
936+ bool is_horizontal = pl.x () != ph.x ();
937+ bool is_vertical = pl.y () != ph.y ();
938+ frLayerNum layer_num = guide_pt.z ();
939+ if (is_horizontal ^ is_vertical) {
940+ if ((is_vertical && design_->isHorizontalLayer (layer_num))
941+ || (is_horizontal && design_->isVerticalLayer (layer_num))) {
942+ if (layer_num + 2 <= router_cfg_->TOP_ROUTING_LAYER ) {
943+ layer_num += 2 ;
944+ } else {
945+ layer_num -= 2 ;
946+ }
947+ }
948+ }
949+ guide_pt.setZ (layer_num);
950+ guides.emplace_back (pl.x () - gcell_half_size_horz,
951+ pl.y () - gcell_half_size_vert,
952+ ph.x () + gcell_half_size_horz,
953+ ph.y () + gcell_half_size_vert,
954+ layer_num,
955+ net);
956+ }
957+ }
958+
952959void GuideProcessor::patchGuides_helper (frNet* net,
953960 std::vector<frRect>& guides,
954961 const Point3D& best_pin_loc_idx,
@@ -1012,7 +1019,7 @@ void GuideProcessor::patchGuides(frNet* net,
10121019 // get the guide that is closest to the gCell
10131020 // TODO: test passing layer_change_penalty = gcell size
10141021 const int closest_guide_idx
1015- = findClosestGuide (best_pin_loc_coords, guides, 1 );
1022+ = findClosestGuide (best_pin_loc_coords, guides, 1 , router_cfg_ );
10161023
10171024 patchGuides_helper (
10181025 net, guides, best_pin_loc_idx, best_pin_loc_coords, closest_guide_idx);
0 commit comments