Skip to content

Commit fa4c247

Browse files
committed
drt: pa on max spacing violations
Signed-off-by: osamahammad21 <[email protected]>
1 parent 88a8f4c commit fa4c247

File tree

9 files changed

+79
-9
lines changed

9 files changed

+79
-9
lines changed

src/drt/include/drt/TritonRoute.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct FlexDRViaData;
5454
class frMarker;
5555
struct RouterConfiguration;
5656
class AbstractGraphicsFactory;
57+
class frViaDef;
5758

5859
struct ParamStruct
5960
{
@@ -184,6 +185,7 @@ class TritonRoute
184185
void fixMaxSpacing(int num_threads);
185186
void deleteInstancePAData(frInst* inst, bool delete_inst = false);
186187
void addInstancePAData(frInst* inst);
188+
void addAvoidViaDefPA(const frViaDef* via_def);
187189
void updateDirtyPAData();
188190

189191
private:

src/drt/src/TritonRoute.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "db/obj/frVia.h"
2727
#include "db/tech/frLayer.h"
2828
#include "db/tech/frTechObject.h"
29+
#include "db/tech/frViaDef.h"
2930
#include "distributed/PinAccessJobDescription.h"
3031
#include "distributed/RoutingCallBack.h"
3132
#include "distributed/drUpdate.h"
@@ -59,7 +60,6 @@
5960
using odb::dbTechLayerType;
6061

6162
namespace drt {
62-
6363
TritonRoute::TritonRoute(odb::dbDatabase* db,
6464
utl::Logger* logger,
6565
utl::CallBackHandler* callback_handler,
@@ -1126,6 +1126,12 @@ void TritonRoute::addInstancePAData(frInst* inst)
11261126
}
11271127
}
11281128

1129+
void TritonRoute::addAvoidViaDefPA(const frViaDef* via_def)
1130+
{
1131+
if (pa_) {
1132+
pa_->addAvoidViaDef(via_def);
1133+
}
1134+
}
11291135
void TritonRoute::updateDirtyPAData()
11301136
{
11311137
if (pa_) {

src/drt/src/db/obj/frInstTerm.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ class frInstTerm : public frBlockObject
4747
odb::Rect getBBox() const;
4848
void setIndexInOwner(int in) { index_in_owner_ = in; }
4949
int getIndexInOwner() const { return index_in_owner_; }
50+
bool isStubborn() const { return is_stubborn_; }
51+
void setStubborn(bool in) { is_stubborn_ = in; }
5052

5153
private:
5254
// Place this first so it is adjacent to "int id_" inherited from
@@ -56,6 +58,7 @@ class frInstTerm : public frBlockObject
5658
frMTerm* term_;
5759
frNet* net_{nullptr};
5860
std::vector<frAccessPoint*> ap_; // follows pin index
61+
bool is_stubborn_{false};
5962
};
6063

6164
} // namespace drt

src/drt/src/dr/FlexDR.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,6 +1688,11 @@ void FlexDR::fixMaxSpacing()
16881688
auto result = getLonelyVias(
16891689
layer.get(), rule->getMaxSpacing(), rule->getCutClassIdx());
16901690
lonely_vias.insert(lonely_vias.end(), result.begin(), result.end());
1691+
for (const auto via_def : layer->getViaDefs()) {
1692+
if (via_def->getCutClassIdx() == rule->getCutClassIdx()) {
1693+
router_->addAvoidViaDefPA(via_def);
1694+
}
1695+
}
16911696
}
16921697
}
16931698
}
@@ -1722,7 +1727,27 @@ void FlexDR::fixMaxSpacing()
17221727
region.set_xhi(tmp_box.xMax());
17231728
region.set_yhi(tmp_box.yMax());
17241729
lonely_vias_regions.emplace_back(region);
1730+
if (via->isBottomConnected() || via->isTopConnected()) {
1731+
// get pins connected to the via
1732+
frRegionQuery::Objects<frBlockObject> result;
1733+
getRegionQuery()->query(
1734+
via->isTopConnected() ? via->getLayer2BBox() : via->getLayer1BBox(),
1735+
via->isTopConnected() ? via->getViaDef()->getLayer2Num()
1736+
: via->getViaDef()->getLayer1Num(),
1737+
result);
1738+
for (auto& [bx, obj] : result) {
1739+
if (obj->typeId() == frcInstTerm) {
1740+
auto inst_term = static_cast<frInstTerm*>(obj);
1741+
if (inst_term->getNet() != via->getNet()) {
1742+
continue;
1743+
}
1744+
inst_term->setStubborn(true);
1745+
router_->addInstancePAData(inst_term->getInst());
1746+
}
1747+
}
1748+
}
17251749
}
1750+
router_->updateDirtyPAData();
17261751
// merge intersecting regions
17271752
std::sort(lonely_vias_regions.begin(),
17281753
lonely_vias_regions.end(),

src/drt/src/pa/FlexPA.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ void FlexPA::addDirtyInst(frInst* inst)
107107
dirty_insts_.insert(inst);
108108
}
109109

110+
void FlexPA::addAvoidViaDef(const frViaDef* via_def)
111+
{
112+
avoid_via_defs_.insert(via_def);
113+
}
114+
110115
void FlexPA::removeDirtyInst(frInst* inst)
111116
{
112117
dirty_insts_.erase(inst);

src/drt/src/pa/FlexPA.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ using frInstLocationSet = std::set<frInst*, frInstLocationComp>;
7777
class FlexPinAccessPattern;
7878
class FlexDPNode;
7979
class AbstractPAGraphics;
80+
class frViaDef;
81+
class frInstTerm;
8082

8183
class FlexPA
8284
{
@@ -109,6 +111,7 @@ class FlexPA
109111

110112
void deleteInst(frInst* inst);
111113
void addDirtyInst(frInst* inst);
114+
void addAvoidViaDef(const frViaDef* via_def);
112115
void removeDirtyInst(frInst* inst);
113116
void updateDirtyInsts();
114117
void removeFromInstsSet(frInst* inst);
@@ -139,6 +142,7 @@ class FlexPA
139142
unique_inst_patterns_;
140143

141144
UniqueInsts unique_insts_;
145+
std::set<const frViaDef*> avoid_via_defs_;
142146

143147
// helper structures
144148
std::vector<std::map<frCoord, frAccessPointEnum>> track_coords_;

src/drt/src/pa/FlexPA_acc_point.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,10 @@ void FlexPA::filterViaAccess(
887887
if (via_defs.empty()) { // no via map entry
888888
// hardcode first two single vias
889889
for (auto& [tup, via_def] : layer_num_to_via_defs_[layer_num + 1][1]) {
890+
if (inst_term && inst_term->isStubborn()
891+
&& avoid_via_defs_.contains(via_def)) {
892+
continue;
893+
}
890894
via_defs.emplace_back(via_defs.size(), via_def);
891895
if (via_defs.size() >= max_num_via_trial && !deep_search) {
892896
break;

src/drt/src/pa/FlexPA_unique.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,14 @@ UniqueClassKey UniqueInsts::computeUniqueClassKey(frInst* inst) const
197197
if (!router_cfg_->AUTO_TAPER_NDR_NETS && isNDRInst(inst)) {
198198
ndr_inst = inst;
199199
}
200-
return UniqueClassKey(inst->getMaster(), orient, offset, ndr_inst);
200+
std::set<frTerm*> stubborn_terms;
201+
for (auto& term : inst->getInstTerms()) {
202+
if (term->isStubborn()) {
203+
stubborn_terms.insert(term->getTerm());
204+
}
205+
}
206+
return UniqueClassKey(
207+
inst->getMaster(), orient, offset, ndr_inst, stubborn_terms);
201208
}
202209

203210
UniqueClass* UniqueInsts::computeUniqueClass(frInst* inst)

src/drt/src/pa/FlexPA_unique.h

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,39 @@ struct UniqueClassKey
2929
odb::dbOrientType orient{odb::dbOrientType::R0};
3030
std::vector<frCoord> offsets;
3131
frInst* ndr_inst{nullptr};
32+
std::set<frTerm*> stubborn_terms;
3233

3334
UniqueClassKey(frMaster* master_in,
3435
const odb::dbOrientType& orient_in,
3536
std::vector<frCoord> offsets_in,
36-
frInst* ndr_inst_in = nullptr)
37+
frInst* ndr_inst_in = nullptr,
38+
std::set<frTerm*> stubborn_terms_in = {})
3739
: master(master_in),
3840
orient(orient_in),
3941
offsets(std::move(offsets_in)),
40-
ndr_inst(ndr_inst_in)
42+
ndr_inst(ndr_inst_in),
43+
stubborn_terms(std::move(stubborn_terms_in))
4144
{
4245
}
4346

4447
bool operator<(const UniqueClassKey& other) const
4548
{
46-
return std::tie(master, orient, offsets, ndr_inst) < std::tie(
47-
other.master, other.orient, other.offsets, other.ndr_inst);
49+
return std::tie(master, orient, offsets, ndr_inst, stubborn_terms)
50+
< std::tie(other.master,
51+
other.orient,
52+
other.offsets,
53+
other.ndr_inst,
54+
other.stubborn_terms);
4855
}
4956

5057
bool operator==(const UniqueClassKey& other) const
5158
{
52-
return std::tie(master, orient, offsets, ndr_inst)
53-
== std::tie(
54-
other.master, other.orient, other.offsets, other.ndr_inst);
59+
return std::tie(master, orient, offsets, ndr_inst, stubborn_terms)
60+
== std::tie(other.master,
61+
other.orient,
62+
other.offsets,
63+
other.ndr_inst,
64+
other.stubborn_terms);
5565
}
5666
};
5767

@@ -66,6 +76,10 @@ class UniqueClass
6676
frMaster* getMaster() const { return key_.master; }
6777
odb::dbOrientType getOrient() const { return key_.orient; }
6878
const std::vector<frCoord>& getOffsets() const { return key_.offsets; }
79+
const std::set<frTerm*>& getStubbornTerms() const
80+
{
81+
return key_.stubborn_terms;
82+
}
6983
const InstSet& getInsts() const { return insts_; }
7084
int getPinAccessIdx() const { return pin_access_idx_; }
7185
void setPinAccessIdx(int idx) { pin_access_idx_ = idx; }

0 commit comments

Comments
 (0)