Skip to content

Commit f54a059

Browse files
authored
Merge pull request #8849 from gadfort/pdn-repair-vias
pdn: correct repair via behavior when repairing the same strap multiple times
2 parents c047d19 + 54d720e commit f54a059

14 files changed

Lines changed: 1886 additions & 41 deletions

src/pdn/src/PdnGen.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,13 @@ void PdnGen::buildGrids(bool trim)
134134
Grid::typeToString(grid->type()));
135135
failed = true;
136136
}
137+
138+
updateRenderer();
139+
137140
if (failed) {
138141
logger_->error(utl::PDN, 233, "Failed to generate full power grid.");
139142
}
140143

141-
updateRenderer();
142144
debugPrint(logger_, utl::PDN, "Make", 1, "Build - end");
143145
}
144146

@@ -154,6 +156,8 @@ void PdnGen::cleanupVias()
154156

155157
void PdnGen::updateVias()
156158
{
159+
debugPrint(logger_, utl::PDN, "Make", 2, "Update vias - start");
160+
157161
const auto grids = getGrids();
158162

159163
for (auto* grid : grids) {
@@ -171,6 +175,8 @@ void PdnGen::updateVias()
171175
via->getUpperShape()->addVia(via);
172176
}
173177
}
178+
179+
debugPrint(logger_, utl::PDN, "Make", 2, "Update vias - end");
174180
}
175181

176182
void PdnGen::trimShapes()

src/pdn/src/grid.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,18 +313,30 @@ bool Grid::repairVias(const Shape::ShapeTreeMap& global_shapes,
313313
}
314314

315315
if (lower_belongs_to_grid && lower_shape->isModifiable()) {
316+
Shape* extend_test = lower_shape.get();
317+
auto find_replace = replace_shapes.find(extend_test);
318+
if (find_replace != replace_shapes.end()) {
319+
extend_test = find_replace->second.get();
320+
}
316321
auto new_lower
317-
= lower_shape->extendTo(upper_shape->getRect(),
318-
obstructions[lower_shape->getLayer()],
322+
= extend_test->extendTo(upper_shape->getRect(),
323+
obstructions[extend_test->getLayer()],
324+
lower_shape.get(),
319325
obs_filter);
320326
if (new_lower != nullptr) {
321327
replace_shapes[lower_shape.get()] = std::move(new_lower);
322328
}
323329
}
324330
if (upper_belongs_to_grid && upper_shape->isModifiable()) {
331+
Shape* extend_test = upper_shape.get();
332+
auto find_replace = replace_shapes.find(extend_test);
333+
if (find_replace != replace_shapes.end()) {
334+
extend_test = find_replace->second.get();
335+
}
325336
auto new_upper
326-
= upper_shape->extendTo(lower_shape->getRect(),
327-
obstructions[upper_shape->getLayer()],
337+
= extend_test->extendTo(lower_shape->getRect(),
338+
obstructions[extend_test->getLayer()],
339+
upper_shape.get(),
328340
obs_filter);
329341
if (new_upper != nullptr) {
330342
replace_shapes[upper_shape.get()] = std::move(new_upper);
@@ -773,7 +785,8 @@ void Grid::makeVias(const Shape::ShapeTreeMap& global_shapes,
773785
void Grid::makeVias(const Shape::ShapeTreeMap& global_shapes,
774786
const Shape::ObstructionTreeMap& obstructions)
775787
{
776-
debugPrint(getLogger(), utl::PDN, "Make", 1, "Making vias in \"{}\"", name_);
788+
debugPrint(
789+
getLogger(), utl::PDN, "Make", 1, "Making vias in \"{}\" - start", name_);
777790
Shape::ShapeTreeMap search_shapes = getShapes();
778791

779792
odb::Rect search_area = getDomainBoundary();
@@ -896,6 +909,8 @@ void Grid::makeVias(const Shape::ShapeTreeMap& global_shapes,
896909
via->getLowerShape()->addVia(via);
897910
via->getUpperShape()->addVia(via);
898911
}
912+
debugPrint(
913+
getLogger(), utl::PDN, "Make", 1, "Making vias in \"{}\" - end", name_);
899914
}
900915

901916
void Grid::getVias(std::vector<ViaPtr>& vias) const

src/pdn/src/grid_component.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ ShapePtr GridComponent::addShape(std::unique_ptr<Shape> shape)
180180

181181
void GridComponent::removeShape(Shape* shape)
182182
{
183+
debugPrint(getLogger(),
184+
utl::PDN,
185+
"Shape",
186+
3,
187+
"Removing shape {}.",
188+
shape->getReportText());
183189
for (const auto& via : shape->getVias()) {
184190
via->removeShape(shape);
185191
}

src/pdn/src/shape.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <vector>
1313

1414
#include "boost/geometry/geometry.hpp"
15+
#include "boost/geometry/index/predicates.hpp"
1516
#include "boost/polygon/polygon.hpp"
1617
#include "grid.h"
1718
#include "grid_component.h"
@@ -596,6 +597,7 @@ std::string Shape::getRectText(const odb::Rect& rect, double dbu_to_micron)
596597
std::unique_ptr<Shape> Shape::extendTo(
597598
const odb::Rect& rect,
598599
const ObstructionTree& obstructions,
600+
Shape* orig_shape,
599601
const std::function<bool(const ShapePtr&)>& obs_filter) const
600602
{
601603
std::unique_ptr<Shape> new_shape = copy();
@@ -616,9 +618,9 @@ std::unique_ptr<Shape> Shape::extendTo(
616618
}
617619

618620
if (obstructions.qbegin(bgi::intersects(new_shape->getRect())
619-
&& bgi::satisfies([this](const auto& other) {
621+
&& bgi::satisfies([&orig_shape](const auto& other) {
620622
// ignore violations that results from itself
621-
return other.get() != this;
623+
return other.get() != orig_shape;
622624
})
623625
&& bgi::satisfies(obs_filter))
624626
!= obstructions.qend()) {

src/pdn/src/shape.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ class Shape
178178
std::unique_ptr<Shape> extendTo(
179179
const odb::Rect& rect,
180180
const ObstructionTree& obstructions,
181+
Shape* orig_shape,
181182
const std::function<bool(const ShapePtr&)>& obs_filter
182183
= [](const ShapePtr&) { return true; }) const;
183184

src/pdn/test/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ COMPULSORY_TESTS = [
5252
"core_grid_with_M7_pins",
5353
"core_grid_with_dual_rings",
5454
"core_grid_with_fixed_pins",
55+
"core_grid_with_m2_straps",
5556
"core_grid_with_rings",
5657
"core_grid_with_rings_connect",
5758
"core_grid_with_rings_different_offset",

src/pdn/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ or_integration_tests(
4949
core_grid_with_M7_pins
5050
core_grid_with_dual_rings
5151
core_grid_with_fixed_pins
52+
core_grid_with_m2_straps
5253
core_grid_with_rings
5354
core_grid_with_rings_connect
5455
core_grid_with_rings_different_offset

0 commit comments

Comments
 (0)