Skip to content

Commit e1fc13d

Browse files
committed
drt: avoid bottom routing layer patching
Signed-off-by: osamahammad21 <[email protected]>
1 parent 19294a8 commit e1fc13d

File tree

2 files changed

+62
-37
lines changed

2 files changed

+62
-37
lines changed

src/drt/src/io/GuideProcessor.cpp

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ Point3D findBestPinLocation(frDesign* design,
207207
*/
208208
int findClosestGuide(const Point3D& best_pin_loc_coords,
209209
const std::vector<frRect>& guides,
210-
const frCoord layer_change_penalty)
210+
const frCoord layer_change_penalty,
211+
const RouterConfiguration* router_cfg)
211212
{
212213
int closest_guide_idx = 0;
213214
int dist = 0;
@@ -217,6 +218,9 @@ int findClosestGuide(const Point3D& best_pin_loc_coords,
217218
dist = odb::manhattanDistance(guide.getBBox(), best_pin_loc_coords);
218219
dist += abs(guide.getLayerNum() - best_pin_loc_coords.z())
219220
* layer_change_penalty;
221+
if (guide.getLayerNum() < router_cfg->BOTTOM_ROUTING_LAYER) {
222+
dist += 1e9;
223+
}
220224
if (dist < min_dist) {
221225
min_dist = dist;
222226
closest_guide_idx = guide_idx;
@@ -352,41 +356,6 @@ void fillGuidesUpToZ(const Point3D& best_pin_loc_coords,
352356
net);
353357
}
354358
}
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-
}
390359

391360
/**
392361
* @brief logs the number of guides read so far
@@ -949,6 +918,43 @@ void GuideProcessor::buildGCellPatterns()
949918
}
950919
}
951920

921+
void GuideProcessor::connectGuidesWithBestPinLoc(
922+
Point3D& guide_pt,
923+
const odb::Point& best_pin_loc_coords,
924+
const frCoord gcell_half_size_horz,
925+
const frCoord gcell_half_size_vert,
926+
frNet* net,
927+
std::vector<frRect>& guides)
928+
{
929+
if (guide_pt.x() != best_pin_loc_coords.x()
930+
|| guide_pt.y() != best_pin_loc_coords.y()) {
931+
const odb::Point pl = {std::min(best_pin_loc_coords.x(), guide_pt.x()),
932+
std::min(best_pin_loc_coords.y(), guide_pt.y())};
933+
const odb::Point ph = {std::max(best_pin_loc_coords.x(), guide_pt.x()),
934+
std::max(best_pin_loc_coords.y(), guide_pt.y())};
935+
bool is_horizontal = pl.x() != ph.x();
936+
bool is_vertical = pl.y() != ph.y();
937+
frLayerNum layer_num = guide_pt.z();
938+
if (is_horizontal ^ is_vertical) {
939+
if ((is_vertical && design_->isHorizontalLayer(layer_num))
940+
|| (is_horizontal && design_->isVerticalLayer(layer_num))) {
941+
if (layer_num + 2 <= router_cfg_->TOP_ROUTING_LAYER) {
942+
layer_num += 2;
943+
} else {
944+
layer_num -= 2;
945+
}
946+
}
947+
}
948+
guide_pt.setZ(layer_num);
949+
guides.emplace_back(pl.x() - gcell_half_size_horz,
950+
pl.y() - gcell_half_size_vert,
951+
ph.x() + gcell_half_size_horz,
952+
ph.y() + gcell_half_size_vert,
953+
layer_num,
954+
net);
955+
}
956+
}
957+
952958
void GuideProcessor::patchGuides_helper(frNet* net,
953959
std::vector<frRect>& guides,
954960
const Point3D& best_pin_loc_idx,
@@ -1012,7 +1018,7 @@ void GuideProcessor::patchGuides(frNet* net,
10121018
// get the guide that is closest to the gCell
10131019
// TODO: test passing layer_change_penalty = gcell size
10141020
const int closest_guide_idx
1015-
= findClosestGuide(best_pin_loc_coords, guides, 1);
1021+
= findClosestGuide(best_pin_loc_coords, guides, 1, router_cfg_);
10161022

10171023
patchGuides_helper(
10181024
net, guides, best_pin_loc_idx, best_pin_loc_coords, closest_guide_idx);

src/drt/src/io/GuideProcessor.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,25 @@ class GuideProcessor
9191
const Point3D& best_pin_loc_idx,
9292
const Point3D& best_pin_loc_coords,
9393
int closest_guide_idx);
94+
/**
95+
* @brief Connects the guides with the best pin shape location (on the 2D
96+
* plane only)
97+
*
98+
* The function creates a patch guide that connects the closest guide to
99+
* best_pin_loc_coords (without consideration to different layers)
100+
*
101+
* @param guide_pt The center of the gcell on the guide that is closest to
102+
* best_pin_loc_coords
103+
* @param best_pin_loc_coords The gcell center point of the chosen pin shape
104+
* @param gcell_half_size_horz Half the horizontal size of the gcell
105+
* @param gcell_half_size_vert Half the vertical size of the gcell
106+
*/
107+
void connectGuidesWithBestPinLoc(Point3D& guide_pt,
108+
const odb::Point& best_pin_loc_coords,
109+
const frCoord gcell_half_size_horz,
110+
const frCoord gcell_half_size_vert,
111+
frNet* net,
112+
std::vector<frRect>& guides);
94113
/**
95114
* @brief Patches guides to cover part of the pin if needed.
96115
*

0 commit comments

Comments
 (0)