Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 109 additions & 43 deletions src/grt/src/cugr/src/GridGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "GRNet.h"
#include "GRTree.h"
#include "geo.h"
#include "odb/db.h"
#include "robin_hood.h"
#include "utl/Logger.h"

Expand All @@ -36,6 +37,7 @@ GridGraph::GridGraph(const Design* design,
num_layers_(design->getNumLayers()),
x_size_(gridlines_[0].size() - 1),
y_size_(gridlines_[1].size() - 1),
design_(design),
constants_(constants)
{
grid_centers_.resize(2);
Expand Down Expand Up @@ -365,6 +367,65 @@ CostT GridGraph::getViaCost(const int layer_index, const PointT loc) const
return cost;
}

bool GridGraph::findODBAccessPoints(
const GRNet* net,
AccessPointSet& selected_access_points) const
{
std::vector<odb::dbAccessPoint*> access_points;
int amount_per_x = design_->getDieRegion().hx() / x_size_;
int amount_per_y = design_->getDieRegion().hy() / y_size_;
odb::dbNet* db_net = net->getDbNet();
if (db_net->getBTermCount() != 0) {
for (odb::dbBTerm* bterms : db_net->getBTerms()) {
for (const odb::dbBPin* bpin : bterms->getBPins()) {
const std::vector<odb::dbAccessPoint*>& bpin_pas
= bpin->getAccessPoints();
// Iterates per each AP and converts to CUGR structures
access_points.insert(
access_points.begin(), bpin_pas.begin(), bpin_pas.end());
for (auto ap : bpin_pas) {
auto point = ap->getPoint();
auto layer = ap->getLayer();
const PointT selected_point = PointT(point.getX() / amount_per_x,
point.getY() / amount_per_y);
const IntervalT selected_layer = IntervalT(layer->getNumber() - 2);
const AccessPoint ap_new{.point = selected_point,
.layers = selected_layer};
selected_access_points.emplace(ap_new).first;
}
}
}
} else {
for (auto iterms : db_net->getITerms()) {
auto pref_access_points = iterms->getPrefAccessPoints();
if (!pref_access_points.empty()) {
access_points.insert(access_points.end(),
pref_access_points.begin(),
pref_access_points.end());
// Iterates in ITerm prefered APs and convert to CUGR strucutres
for (auto ap : pref_access_points) {
int x, y;
iterms->getInst()->getLocation(x, y);
auto point = ap->getPoint();
auto layer = ap->getLayer();
const PointT selected_point
= PointT((point.getX() + x) / amount_per_x,
(point.getY() + y) / amount_per_y);
const IntervalT selected_layer = IntervalT(layer->getNumber() - 2);
const AccessPoint ap_new{.point = selected_point,
.layers = selected_layer};
selected_access_points.emplace(ap_new).first;
}
}
// Currently ignoring non preferred APs
}
}
if (access_points.empty()) {
return false;
}
return true;
}

AccessPointSet GridGraph::selectAccessPoints(const GRNet* net) const
{
AccessPointHash hasher(y_size_);
Expand All @@ -373,61 +434,66 @@ AccessPointSet GridGraph::selectAccessPoints(const GRNet* net) const
selected_access_points.reserve(net->getNumPins());
const auto& boundingBox = net->getBoundingBox();
const PointT netCenter(boundingBox.cx(), boundingBox.cy());
for (const std::vector<GRPoint>& accessPoints : net->getPinAccessPoints()) {
std::pair<int, int> bestAccessDist = {0, std::numeric_limits<int>::max()};
int bestIndex = -1;
for (int index = 0; index < accessPoints.size(); index++) {
const GRPoint& point = accessPoints[index];
int accessibility = 0;
if (point.getLayerIdx() >= constants_.min_routing_layer) {
const int direction = getLayerDirection(point.getLayerIdx());
accessibility
+= getEdge(point.getLayerIdx(), point.x(), point.y()).capacity >= 1;
if (point[direction] > 0) {
auto lower = point;
lower[direction] -= 1;
if (findODBAccessPoints(net, selected_access_points)) {
// Skips calculations if DRT already created APs in ODB
} else {
for (const std::vector<GRPoint>& accessPoints : net->getPinAccessPoints()) {
std::pair<int, int> bestAccessDist = {0, std::numeric_limits<int>::max()};
int bestIndex = -1;
for (int index = 0; index < accessPoints.size(); index++) {
const GRPoint& point = accessPoints[index];
int accessibility = 0;
if (point.getLayerIdx() >= constants_.min_routing_layer) {
const int direction = getLayerDirection(point.getLayerIdx());
accessibility
+= getEdge(lower.getLayerIdx(), lower.x(), lower.y()).capacity
+= getEdge(point.getLayerIdx(), point.x(), point.y()).capacity
>= 1;
if (point[direction] > 0) {
auto lower = point;
lower[direction] -= 1;
accessibility
+= getEdge(lower.getLayerIdx(), lower.x(), lower.y()).capacity
>= 1;
}
} else {
accessibility = 1;
}
const int distance
= abs(netCenter.x() - point.x()) + abs(netCenter.y() - point.y());
if (accessibility > bestAccessDist.first
|| (accessibility == bestAccessDist.first
&& distance < bestAccessDist.second)) {
bestIndex = index;
bestAccessDist = {accessibility, distance};
}
} else {
accessibility = 1;
}
const int distance
= abs(netCenter.x() - point.x()) + abs(netCenter.y() - point.y());
if (accessibility > bestAccessDist.first
|| (accessibility == bestAccessDist.first
&& distance < bestAccessDist.second)) {
bestIndex = index;
bestAccessDist = {accessibility, distance};
if (bestAccessDist.first == 0) {
logger_->warn(utl::GRT, 274, "pin is hard to access.");
}

if (bestIndex == -1) {
logger_->error(utl::GRT,
283,
"No preferred access point found for pin on net {}.",
net->getName());
}
}
if (bestAccessDist.first == 0) {
logger_->warn(utl::GRT, 274, "pin is hard to access.");
}

if (bestIndex == -1) {
logger_->error(utl::GRT,
283,
"No preferred access point found for pin on net {}.",
net->getName());
}

const PointT selectedPoint = accessPoints[bestIndex];
const AccessPoint ap{selectedPoint, {}};
auto it = selected_access_points.emplace(ap).first;
IntervalT& fixedLayerInterval = it->layers;
for (const auto& point : accessPoints) {
if (point.x() == selectedPoint.x() && point.y() == selectedPoint.y()) {
fixedLayerInterval.Update(point.getLayerIdx());
const PointT selectedPoint = accessPoints[bestIndex];
const AccessPoint ap{selectedPoint, {}};
auto it = selected_access_points.emplace(ap).first;
IntervalT& fixedLayerInterval = it->layers;
for (const auto& point : accessPoints) {
if (point.x() == selectedPoint.x() && point.y() == selectedPoint.y()) {
fixedLayerInterval.Update(point.getLayerIdx());
}
}
}
}
// Extend the fixed layers to 2 layers higher to facilitate track switching
// TODO: Removing this part is causing issues, but it shouldnt
for (auto& accessPoint : selected_access_points) {
IntervalT& fixedLayers = accessPoint.layers;
fixedLayers.SetHigh(
std::min(fixedLayers.high() + 2, (int) getNumLayers() - 1));
std::min(fixedLayers.high() + 0, (int) getNumLayers() - 1));
}
return selected_access_points;
}
Expand Down
5 changes: 5 additions & 0 deletions src/grt/src/cugr/src/GridGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ class GridGraph
return unit_length_short_costs_[layer_index];
}

bool findODBAccessPoints(const GRNet* net,
AccessPointSet& selected_access_points) const;

double logistic(const CapacityT& input, double slope) const;
CostT getWireCost(int layer_index,
PointT lower,
Expand All @@ -175,6 +178,8 @@ class GridGraph
const int x_size_;
const int y_size_;

const Design* design_;

// Unit costs
CostT unit_length_wire_cost_;
CostT unit_via_cost_;
Expand Down
2 changes: 2 additions & 0 deletions src/grt/test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ TESTS = [
"pd3",
"pd4",
"pin_access1",
"pin_access1_cugr",
"pin_access2",
"pin_access2_cugr",
"pin_edge",
"pin_track_not_aligned",
"pre_routed1",
Expand Down
2 changes: 2 additions & 0 deletions src/grt/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ or_integration_tests(
pd3
pd4
pin_access1
pin_access1_cugr
pin_access2
pin_access2_cugr
pin_edge
pin_track_not_aligned
pre_routed1
Expand Down
18 changes: 4 additions & 14 deletions src/grt/test/clock_route_cugr.guideok
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
clk
(
0 201600 7200 208800 met3
0 151200 7200 208800 met4
0 201600 7200 208800 met4
0 151200 7200 158400 met3
0 151200 136800 158400 met3
0 201600 136800 208800 met3
129600 201600 136800 208800 met3
129600 151200 136800 208800 met4
129600 151200 136800 158400 li1
129600 151200 136800 158400 met1
129600 151200 136800 158400 met2
129600 151200 136800 158400 met3
)
clknet_0_clk
(
Expand Down Expand Up @@ -272,7 +271,6 @@ net56
129600 122400 136800 129600 met2
115200 122400 122400 144000 met2
115200 136800 122400 144000 met1
115200 136800 122400 144000 met2
)
net57
(
Expand All @@ -289,22 +287,16 @@ net58
108000 172800 115200 180000 met1
108000 172800 115200 187200 met2
108000 180000 115200 187200 met1
108000 180000 115200 187200 met2
)
net59
(
108000 194400 115200 201600 li1
108000 194400 115200 201600 met1
108000 194400 115200 201600 met1
108000 194400 115200 201600 met2
108000 194400 115200 201600 met2
108000 194400 115200 201600 met3
)
net60
(
115200 194400 122400 201600 met1
115200 194400 122400 208800 met2
115200 194400 122400 201600 met2
115200 201600 122400 208800 li1
115200 201600 122400 208800 met1
)
Expand All @@ -314,7 +306,6 @@ net61
122400 187200 129600 194400 met1
122400 187200 129600 201600 met2
122400 194400 129600 201600 met1
122400 194400 129600 201600 met2
)
net62
(
Expand All @@ -330,7 +321,6 @@ net63
(
129600 187200 136800 194400 met1
129600 187200 136800 201600 met2
129600 187200 136800 194400 met2
129600 194400 136800 208800 met2
129600 194400 136800 201600 li1
129600 194400 136800 201600 met1
Expand Down
2 changes: 1 addition & 1 deletion src/grt/test/clock_route_cugr.ok
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ stage 1: pattern routing
0 / 15 nets have overflow.
routing statistics
wire length (metric): 2918
total via count: 211
total via count: 203
total wire overflow: 0
min resource: 2
bottleneck: (5, 0, 0)
Expand Down
11 changes: 0 additions & 11 deletions src/grt/test/clock_route_cugr2.guideok
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
clk
(
0 201600 136800 208800 met3
0 201600 7200 208800 met3
0 201600 7200 208800 met4
129600 201600 136800 208800 met3
129600 151200 136800 208800 met4
129600 151200 136800 158400 li1
Expand Down Expand Up @@ -274,7 +272,6 @@ net56
129600 122400 136800 129600 met2
115200 122400 122400 144000 met2
115200 136800 122400 144000 met1
115200 136800 122400 144000 met2
)
net57
(
Expand All @@ -291,22 +288,16 @@ net58
108000 172800 115200 180000 met1
108000 172800 115200 187200 met2
108000 180000 115200 187200 met1
108000 180000 115200 187200 met2
)
net59
(
108000 194400 115200 201600 li1
108000 194400 115200 201600 met1
108000 194400 115200 201600 met1
108000 194400 115200 201600 met2
108000 194400 115200 201600 met2
108000 194400 115200 201600 met3
)
net60
(
115200 194400 122400 201600 met1
115200 194400 122400 208800 met2
115200 194400 122400 201600 met2
115200 201600 122400 208800 li1
115200 201600 122400 208800 met1
)
Expand All @@ -316,7 +307,6 @@ net61
122400 187200 129600 194400 met1
122400 187200 129600 201600 met2
122400 194400 129600 201600 met1
122400 194400 129600 201600 met2
)
net62
(
Expand All @@ -332,7 +322,6 @@ net63
(
129600 187200 136800 194400 met1
129600 187200 136800 201600 met2
129600 187200 136800 194400 met2
129600 194400 136800 208800 met2
129600 194400 136800 201600 li1
129600 194400 136800 201600 met1
Expand Down
2 changes: 1 addition & 1 deletion src/grt/test/clock_route_cugr2.ok
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ stage 1: pattern routing
0 / 15 nets have overflow.
routing statistics
wire length (metric): 2918
total via count: 213
total via count: 204
total wire overflow: 0
min resource: 1
bottleneck: (5, 0, 0)
Expand Down
Loading
Loading