Repository navigation
pdn: enforce effective enclosure validation for generated vias #11539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ecfe74b
6b3d456
a69d08e
3396a19
1ec9fa0
1dff4db
ca5be04
0eaf087
dd71460
b5d6449
26f0193
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -156,8 +156,13 @@ bool Enclosure::isPreferredOver(const Enclosure* other, bool minimize_x) const | |
|
|
||
| void Enclosure::snap(odb::dbTech* tech) | ||
| { | ||
| x_ = TechLayer::snapToManufacturingGrid(tech, x_); | ||
| y_ = TechLayer::snapToManufacturingGrid(tech, y_); | ||
| // Do not round an enclosure deficit up to an apparently legal zero. | ||
| auto snap = [tech](int value) { | ||
| return value < 0 ? -TechLayer::snapToManufacturingGrid(tech, -value, true) | ||
| : TechLayer::snapToManufacturingGrid(tech, value); | ||
| }; | ||
| x_ = snap(x_); | ||
| y_ = snap(y_); | ||
| } | ||
|
|
||
| void Enclosure::copy(const Enclosure* other) | ||
|
|
@@ -2101,28 +2106,30 @@ void ViaGenerator::determineRowsAndColumns( | |
| + (last_rows > 0 ? array_spacing_y_ : 0); | ||
| const int double_enc_y = height - via_width_y; | ||
|
|
||
| bottom_enclosure_->setX( | ||
| determine_enclosure(use_bottom_min_enclosure, | ||
| true, | ||
| bottom_min_enclosure.getX(), | ||
| double_enc_x / 2, | ||
| lower_constraint_)); | ||
| bottom_enclosure_->setY( | ||
| determine_enclosure(use_bottom_min_enclosure, | ||
| false, | ||
| bottom_min_enclosure.getY(), | ||
| double_enc_y / 2, | ||
| lower_constraint_)); | ||
| top_enclosure_->setX(determine_enclosure(use_top_min_enclosure, | ||
| true, | ||
| top_min_enclosure.getX(), | ||
| double_enc_x / 2, | ||
| upper_constraint_)); | ||
| top_enclosure_->setY(determine_enclosure(use_top_min_enclosure, | ||
| false, | ||
| top_min_enclosure.getY(), | ||
| double_enc_y / 2, | ||
| upper_constraint_)); | ||
| bottom_enclosure_->setX(determine_enclosure( | ||
| use_bottom_min_enclosure, | ||
| true, | ||
| bottom_min_enclosure.getX(), | ||
| static_cast<int>(std::floor(double_enc_x / 2.0)), | ||
| lower_constraint_)); | ||
| bottom_enclosure_->setY(determine_enclosure( | ||
| use_bottom_min_enclosure, | ||
| false, | ||
| bottom_min_enclosure.getY(), | ||
| static_cast<int>(std::floor(double_enc_y / 2.0)), | ||
| lower_constraint_)); | ||
| top_enclosure_->setX(determine_enclosure( | ||
| use_top_min_enclosure, | ||
| true, | ||
| top_min_enclosure.getX(), | ||
| static_cast<int>(std::floor(double_enc_x / 2.0)), | ||
| upper_constraint_)); | ||
| top_enclosure_->setY(determine_enclosure( | ||
| use_top_min_enclosure, | ||
| false, | ||
| top_min_enclosure.getY(), | ||
| static_cast<int>(std::floor(double_enc_y / 2.0)), | ||
| upper_constraint_)); | ||
|
|
||
| max_cut_area = total_cut_area; | ||
| } | ||
|
|
@@ -2153,26 +2160,30 @@ void ViaGenerator::determineRowsAndColumns( | |
| top_enclosure_->setX(top_min_enclosure.getX()); | ||
| top_enclosure_->setY(top_min_enclosure.getY()); | ||
| } else { | ||
| bottom_enclosure_->setX(determine_enclosure(use_bottom_min_enclosure, | ||
| true, | ||
| bottom_min_enclosure.getX(), | ||
| double_enc_x / 2, | ||
| lower_constraint_)); | ||
| bottom_enclosure_->setY(determine_enclosure(use_bottom_min_enclosure, | ||
| false, | ||
| bottom_min_enclosure.getY(), | ||
| double_enc_y / 2, | ||
| lower_constraint_)); | ||
| top_enclosure_->setX(determine_enclosure(use_top_min_enclosure, | ||
| true, | ||
| top_min_enclosure.getX(), | ||
| double_enc_x / 2, | ||
| upper_constraint_)); | ||
| top_enclosure_->setY(determine_enclosure(use_top_min_enclosure, | ||
| false, | ||
| top_min_enclosure.getY(), | ||
| double_enc_y / 2, | ||
| upper_constraint_)); | ||
| bottom_enclosure_->setX( | ||
| determine_enclosure(use_bottom_min_enclosure, | ||
| true, | ||
| bottom_min_enclosure.getX(), | ||
| static_cast<int>(std::floor(double_enc_x / 2.0)), | ||
| lower_constraint_)); | ||
| bottom_enclosure_->setY( | ||
| determine_enclosure(use_bottom_min_enclosure, | ||
| false, | ||
| bottom_min_enclosure.getY(), | ||
| static_cast<int>(std::floor(double_enc_y / 2.0)), | ||
| lower_constraint_)); | ||
| top_enclosure_->setX( | ||
| determine_enclosure(use_top_min_enclosure, | ||
| true, | ||
| top_min_enclosure.getX(), | ||
| static_cast<int>(std::floor(double_enc_x / 2.0)), | ||
| upper_constraint_)); | ||
| top_enclosure_->setY( | ||
| determine_enclosure(use_top_min_enclosure, | ||
| false, | ||
| top_min_enclosure.getY(), | ||
| static_cast<int>(std::floor(double_enc_y / 2.0)), | ||
| upper_constraint_)); | ||
|
Comment on lines
+2163
to
+2186
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using floating-point division bottom_enclosure_->setX(
determine_enclosure(use_bottom_min_enclosure,
true,
bottom_min_enclosure.getX(),
double_enc_x >> 1,
lower_constraint_));
bottom_enclosure_->setY(
determine_enclosure(use_bottom_min_enclosure,
false,
bottom_min_enclosure.getY(),
double_enc_y >> 1,
lower_constraint_));
top_enclosure_->setX(
determine_enclosure(use_top_min_enclosure,
true,
top_min_enclosure.getX(),
double_enc_x >> 1,
upper_constraint_));
top_enclosure_->setY(
determine_enclosure(use_top_min_enclosure,
false,
top_min_enclosure.getY(),
double_enc_y >> 1,
upper_constraint_)); |
||
| } | ||
|
|
||
| if (isSplitCutArray()) { | ||
|
|
@@ -2686,12 +2697,15 @@ void GenerateViaGenerator::getMinimumEnclosures(std::vector<Enclosure>& bottom, | |
| { | ||
| ViaGenerator::getMinimumEnclosures(bottom, top, true); | ||
|
|
||
| if (rules_only) { | ||
| return; | ||
| // Applicable cut-layer enclosure rules override VIARULE defaults. When | ||
| // validating a generated via, retain the default for a side with no such | ||
| // rule; otherwise a forced single cut can pass with insufficient enclosure. | ||
| if (!rules_only || bottom.empty()) { | ||
| bottom.emplace_back(getBottomLayerRule(), getBottomLayer()); | ||
| } | ||
| if (!rules_only || top.empty()) { | ||
| top.emplace_back(getTopLayerRule(), getTopLayer()); | ||
| } | ||
|
|
||
| bottom.emplace_back(getBottomLayerRule(), getBottomLayer()); | ||
| top.emplace_back(getTopLayerRule(), getTopLayer()); | ||
| } | ||
|
|
||
| ///////// | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using floating-point division
double_enc_x / 2.0,std::floor, and casting back tointintroduces unnecessary overhead. Sincedouble_enc_xanddouble_enc_yare signed integers, we can perform highly efficient integer-only floor division by 2 using the arithmetic right shift operator>> 1(which is guaranteed to be arithmetic and perform floor division in C++20, and is universally supported as such in C++17). This avoids floating-point conversions entirely.