Skip to content

Commit 7eece62

Browse files
committed
pdn: fix repair via behavior when repairing the same shape multiple times
Signed-off-by: Peter Gadfort <gadfort@zeroasic.com>
1 parent f68042b commit 7eece62

5 files changed

Lines changed: 37 additions & 8 deletions

File tree

src/pdn/src/PdnGen.cc

Lines changed: 9 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,9 @@ void PdnGen::cleanupVias()
154156

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

159164
for (auto* grid : grids) {
@@ -171,6 +176,9 @@ void PdnGen::updateVias()
171176
via->getUpperShape()->addVia(via);
172177
}
173178
}
179+
180+
debugPrint(
181+
logger_, utl::PDN, "Make", 2, "Update vias - end");
174182
}
175183

176184
void PdnGen::trimShapes()

src/pdn/src/grid.cpp

Lines changed: 18 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,7 @@ 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(getLogger(), utl::PDN, "Make", 1, "Making vias in \"{}\" - start", name_);
777789
Shape::ShapeTreeMap search_shapes = getShapes();
778790

779791
odb::Rect search_area = getDomainBoundary();
@@ -896,6 +908,7 @@ void Grid::makeVias(const Shape::ShapeTreeMap& global_shapes,
896908
via->getLowerShape()->addVia(via);
897909
via->getUpperShape()->addVia(via);
898910
}
911+
debugPrint(getLogger(), utl::PDN, "Make", 1, "Making vias in \"{}\" - end", name_);
899912
}
900913

901914
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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ std::string Shape::getRectText(const odb::Rect& rect, double dbu_to_micron)
596596
std::unique_ptr<Shape> Shape::extendTo(
597597
const odb::Rect& rect,
598598
const ObstructionTree& obstructions,
599+
Shape* orig_shape,
599600
const std::function<bool(const ShapePtr&)>& obs_filter) const
600601
{
601602
std::unique_ptr<Shape> new_shape = copy();
@@ -616,9 +617,9 @@ std::unique_ptr<Shape> Shape::extendTo(
616617
}
617618

618619
if (obstructions.qbegin(bgi::intersects(new_shape->getRect())
619-
&& bgi::satisfies([this](const auto& other) {
620+
&& bgi::satisfies([&orig_shape](const auto& other) {
620621
// ignore violations that results from itself
621-
return other.get() != this;
622+
return other.get() != orig_shape;
622623
})
623624
&& bgi::satisfies(obs_filter))
624625
!= 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

0 commit comments

Comments
 (0)