Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
58 changes: 35 additions & 23 deletions src/grt/src/cugr/include/geo.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,59 @@ namespace grt {
class PointT
{
public:
int x, y;
PointT(int xx = std::numeric_limits<int>::max(),
int yy = std::numeric_limits<int>::max())
: x(xx), y(yy)
PointT(int x = std::numeric_limits<int>::max(),
int y = std::numeric_limits<int>::max())
: x_(x), y_(y)
{
}
bool IsValid() { return *this != PointT(); }

int x() const { return x_; }
int y() const { return y_; }

// Operators
const int& operator[](const unsigned d) const
{
assert(d == 0 || d == 1);
return (d == 0 ? x : y);
return (d == 0 ? x_ : y_);
}
int& operator[](const unsigned d)
{
assert(d == 0 || d == 1);
return (d == 0 ? x : y);
return (d == 0 ? x_ : y_);
}
PointT operator+(const PointT& rhs)
{
return PointT(x_ + rhs.x_, y_ + rhs.y_);
}
PointT operator+(const PointT& rhs) { return PointT(x + rhs.x, y + rhs.y); }
PointT operator/(int divisor) { return PointT(x / divisor, y / divisor); }
PointT operator/(int divisor) { return PointT(x_ / divisor, y_ / divisor); }
PointT& operator+=(const PointT& rhs)
{
x += rhs.x;
y += rhs.y;
x_ += rhs.x_;
y_ += rhs.y_;
return *this;
}
PointT& operator-=(const PointT& rhs)
{
x -= rhs.x;
y -= rhs.y;
x_ -= rhs.x_;
y_ -= rhs.y_;
return *this;
}
bool operator==(const PointT& rhs) const { return x == rhs.x && y == rhs.y; }
bool operator==(const PointT& rhs) const
{
return x_ == rhs.x_ && y_ == rhs.y_;
}
bool operator!=(const PointT& rhs) const { return !(*this == rhs); }

friend std::ostream& operator<<(std::ostream& os, const PointT& pt)
{
os << "(" << pt.x << ", " << pt.y << ")";
os << "(" << pt.x_ << ", " << pt.y_ << ")";
return os;
}

private:
int x_;
int y_;
};

// Interval template
Expand Down Expand Up @@ -228,7 +240,7 @@ class BoxT
x.Set(xVal);
y.Set(yVal);
}
void Set(const PointT& pt) { Set(pt.x, pt.y); }
void Set(const PointT& pt) { Set(pt.x(), pt.y()); }
void Set(int lx, int ly, int hx, int hy)
{
x.Set(lx, hx);
Expand All @@ -241,7 +253,7 @@ class BoxT
}
void Set(const PointT& low, const PointT& high)
{
Set(low.x, low.y, high.x, high.y);
Set(low.x(), low.y(), high.x(), high.y());
}
void Set(const BoxT& box) { Set(box.x, box.y); }

Expand Down Expand Up @@ -282,8 +294,8 @@ class BoxT
x.FastUpdate(xVal);
y.FastUpdate(yVal);
}
void Update(const PointT& pt) { Update(pt.x, pt.y); }
void FastUpdate(const PointT& pt) { FastUpdate(pt.x, pt.y); }
void Update(const PointT& pt) { Update(pt.x(), pt.y()); }
void FastUpdate(const PointT& pt) { FastUpdate(pt.x(), pt.y()); }

// Geometric Query/Update
BoxT UnionWith(const BoxT& rhs) const
Expand All @@ -304,15 +316,15 @@ class BoxT
} // tighter
bool Contain(const PointT& pt) const
{
return x.Contain(pt.x) && y.Contain(pt.y);
return x.Contain(pt.x()) && y.Contain(pt.y());
}
bool StrictlyContain(const PointT& pt) const
{
return x.StrictlyContain(pt.x) && y.StrictlyContain(pt.y);
return x.StrictlyContain(pt.x()) && y.StrictlyContain(pt.y());
}
PointT GetNearestPointTo(const PointT& pt)
{
return {x.GetNearestPointTo(pt.x), y.GetNearestPointTo(pt.y)};
return {x.GetNearestPointTo(pt.x()), y.GetNearestPointTo(pt.y())};
}
BoxT GetNearestPointsTo(BoxT val) const
{
Expand All @@ -321,8 +333,8 @@ class BoxT

void ShiftBy(const PointT& rhs)
{
x.ShiftBy(rhs.x);
y.ShiftBy(rhs.y);
x.ShiftBy(rhs.x());
y.ShiftBy(rhs.y());
}

bool operator==(const BoxT& rhs) const
Expand Down
54 changes: 28 additions & 26 deletions src/grt/src/cugr/src/CUGR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ NetRouteMap CUGR::getRoutes()
routing_tree, [&](const std::shared_ptr<GRTreeNode>& node) {
for (const auto& child : node->children) {
if (node->getLayerIdx() == child->getLayerIdx()) {
auto [min_x, max_x] = std::minmax(node->x, child->x);
auto [min_y, max_y] = std::minmax(node->y, child->y);
auto [min_x, max_x] = std::minmax({node->x(), child->x()});
auto [min_y, max_y] = std::minmax({node->y(), child->y()});
GSegment segment(
grid_graph_->getGridline(0, min_x) + half_gcell_size,
grid_graph_->getGridline(1, min_y) + half_gcell_size,
Expand All @@ -223,11 +223,11 @@ NetRouteMap CUGR::getRoutes()
for (int layer_idx = bottom_layer; layer_idx < top_layer;
layer_idx++) {
GSegment segment(
grid_graph_->getGridline(0, node->x) + half_gcell_size,
grid_graph_->getGridline(1, node->y) + half_gcell_size,
grid_graph_->getGridline(0, node->x()) + half_gcell_size,
grid_graph_->getGridline(1, node->y()) + half_gcell_size,
layer_idx + 1,
grid_graph_->getGridline(0, node->x) + half_gcell_size,
grid_graph_->getGridline(1, node->y) + half_gcell_size,
grid_graph_->getGridline(0, node->x()) + half_gcell_size,
grid_graph_->getGridline(1, node->y()) + half_gcell_size,
layer_idx + 2,
true);
route.push_back(segment);
Expand Down Expand Up @@ -266,18 +266,18 @@ void CUGR::getGuides(const GRNet* net,
for (const auto& child : node->children) {
if (node->getLayerIdx() == child->getLayerIdx()) {
guides.emplace_back(node->getLayerIdx(),
BoxT(std::min(node->x, child->x),
std::min(node->y, child->y),
std::max(node->x, child->x),
std::max(node->y, child->y)));
BoxT(std::min(node->x(), child->x()),
std::min(node->y(), child->y()),
std::max(node->x(), child->x()),
std::max(node->y(), child->y())));
} else {
int maxLayerIndex
= std::max(node->getLayerIdx(), child->getLayerIdx());
for (int layerIdx
= std::min(node->getLayerIdx(), child->getLayerIdx());
layerIdx <= maxLayerIndex;
layerIdx++) {
guides.emplace_back(layerIdx, BoxT(node->x, node->y));
guides.emplace_back(layerIdx, BoxT(node->x(), node->y()));
}
}
}
Expand All @@ -287,18 +287,18 @@ void CUGR::getGuides(const GRNet* net,
double resource = std::numeric_limits<double>::max();
unsigned direction = grid_graph_->getLayerDirection(point.getLayerIdx());
if (point[direction] + 1 < grid_graph_->getSize(direction)) {
resource
= std::min(resource,
grid_graph_->getEdge(point.getLayerIdx(), point.x, point.y)
.getResource());
resource = std::min(
resource,
grid_graph_->getEdge(point.getLayerIdx(), point.x(), point.y())
.getResource());
}
if (point[direction] > 0) {
GRPoint lower = point;
lower[direction] -= 1;
resource
= std::min(resource,
grid_graph_->getEdge(lower.getLayerIdx(), point.x, point.y)
.getResource());
resource = std::min(
resource,
grid_graph_->getEdge(lower.getLayerIdx(), point.x(), point.y())
.getResource());
}
return resource;
};
Expand All @@ -309,7 +309,7 @@ void CUGR::getGuides(const GRNet* net,
for (auto& gpt : gpts) {
if (gpt.getLayerIdx() < constants_.min_routing_layer) {
int padding = 0;
if (getSpareResource({constants_.min_routing_layer, gpt.x, gpt.y})
if (getSpareResource({constants_.min_routing_layer, gpt.x(), gpt.y()})
< constants_.pin_patch_threshold) {
padding = constants_.pin_patch_padding;
}
Expand All @@ -318,10 +318,11 @@ void CUGR::getGuides(const GRNet* net,
layerIdx++) {
guides.emplace_back(
layerIdx,
BoxT(std::max(gpt.x - padding, 0),
std::max(gpt.y - padding, 0),
std::min(gpt.x + padding, (int) grid_graph_->getSize(0) - 1),
std::min(gpt.y + padding,
BoxT(std::max(gpt.x() - padding, 0),
std::max(gpt.y() - padding, 0),
std::min(gpt.x() + padding,
(int) grid_graph_->getSize(0) - 1),
std::min(gpt.y() + padding,
(int) grid_graph_->getSize(1) - 1)));
area_of_pin_patches_ += (guides.back().second.x.range() + 1)
* (guides.back().second.y.range() + 1);
Expand Down Expand Up @@ -354,8 +355,9 @@ void CUGR::getGuides(const GRNet* net,
|| layerIndex >= grid_graph_->getNumLayers()) {
continue;
}
if (getSpareResource({layerIndex, point.x, point.y}) >= 1.0) {
guides.emplace_back(layerIndex, BoxT(point.x, point.y));
if (getSpareResource({layerIndex, point.x(), point.y()})
>= 1.0) {
guides.emplace_back(layerIndex, BoxT(point.x(), point.y()));
area_of_wire_patches_ += 1;
patched = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/grt/src/cugr/src/GRTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class GRPoint : public PointT
GRPoint(int l, int _x, int _y) : PointT(_x, _y), layer_idx_(l) {}
friend std::ostream& operator<<(std::ostream& os, const GRPoint& pt)
{
os << "(" << pt.layer_idx_ << ", " << pt.x << ", " << pt.y << ")";
os << "(" << pt.layer_idx_ << ", " << pt.x() << ", " << pt.y() << ")";
return os;
}
int getLayerIdx() const { return layer_idx_; }
Expand Down
Loading