|
4 | 4 | #pragma once |
5 | 5 |
|
6 | 6 | #include <algorithm> |
| 7 | +#include <functional> |
7 | 8 | #include <iostream> |
8 | 9 | #include <map> |
9 | 10 | #include <set> |
10 | 11 | #include <string> |
| 12 | +#include <utility> |
11 | 13 | #include <vector> |
12 | 14 |
|
13 | 15 | #include "db/infra/frSegStyle.h" |
@@ -629,15 +631,53 @@ class frLayer |
629 | 631 | } |
630 | 632 | void addLef58AreaConstraint(frLef58AreaConstraint* in) |
631 | 633 | { |
632 | | - lef58AreaConstraints_.push_back(in); |
| 634 | + // This vector should be sorted by area in a descending order |
| 635 | + auto area = in->getODBRule()->getArea(); |
| 636 | + auto it = std::ranges::lower_bound(lef58AreaConstraints_.begin(), |
| 637 | + lef58AreaConstraints_.end(), |
| 638 | + area, |
| 639 | + std::ranges::greater{}, |
| 640 | + [](const frLef58AreaConstraint* a) { |
| 641 | + return a->getODBRule()->getArea(); |
| 642 | + }); |
| 643 | + lef58AreaConstraints_.insert(it, in); |
633 | 644 | } |
634 | 645 |
|
635 | 646 | const std::vector<frLef58AreaConstraint*>& getLef58AreaConstraints() const |
636 | 647 | { |
637 | 648 | return lef58AreaConstraints_; |
638 | 649 | } |
639 | 650 |
|
640 | | - bool hasLef58AreaConstraint() const { return !lef58AreaConstraints_.empty(); } |
| 651 | + bool hasLef58AreaConstraint() const |
| 652 | + { |
| 653 | + return !lef58AreaConstraints_.empty() |
| 654 | + || !lef58AreaConstraintsRectWidth_.empty(); |
| 655 | + } |
| 656 | + |
| 657 | + void addLef58AreaConstraintRectWidth(frLef58AreaConstraint* in) |
| 658 | + { |
| 659 | + // This vector should be sorted by rectwidth in an ascending order, |
| 660 | + // tie-broken by area in an ascending order so that for equal rectwidth the |
| 661 | + // smallest area constraint takes preference |
| 662 | + auto rule = in->getODBRule(); |
| 663 | + auto key = std::make_pair(rule->getRectWidth(), rule->getArea()); |
| 664 | + auto it = std::ranges::lower_bound(lef58AreaConstraintsRectWidth_.begin(), |
| 665 | + lef58AreaConstraintsRectWidth_.end(), |
| 666 | + key, |
| 667 | + std::ranges::less{}, |
| 668 | + [](const frLef58AreaConstraint* a) { |
| 669 | + return std::make_pair( |
| 670 | + a->getODBRule()->getRectWidth(), |
| 671 | + a->getODBRule()->getArea()); |
| 672 | + }); |
| 673 | + lef58AreaConstraintsRectWidth_.insert(it, in); |
| 674 | + } |
| 675 | + |
| 676 | + const std::vector<frLef58AreaConstraint*>& getLef58AreaConstraintsRectWidth() |
| 677 | + const |
| 678 | + { |
| 679 | + return lef58AreaConstraintsRectWidth_; |
| 680 | + } |
641 | 681 |
|
642 | 682 | void addKeepOutZoneConstraint(frLef58KeepOutZoneConstraint* in) |
643 | 683 | { |
@@ -937,6 +977,7 @@ class frLayer |
937 | 977 | std::vector<frLef58EolKeepOutConstraint*> lef58EolKeepOutConstraints_; |
938 | 978 | std::vector<frMetalWidthViaConstraint*> metalWidthViaConstraints_; |
939 | 979 | std::vector<frLef58AreaConstraint*> lef58AreaConstraints_; |
| 980 | + std::vector<frLef58AreaConstraint*> lef58AreaConstraintsRectWidth_; |
940 | 981 | std::vector<frLef58KeepOutZoneConstraint*> keepOutZoneConstraints_; |
941 | 982 | std::vector<frSpacingRangeConstraint*> spacingRangeConstraints_; |
942 | 983 | std::vector<frLef58TwoWiresForbiddenSpcConstraint*> |
|
0 commit comments