Skip to content

Commit 2845fbd

Browse files
committed
Merge remote-tracking branch 'private/master' into gui-tcl-worst-path-image
2 parents 024409e + c71fb38 commit 2845fbd

File tree

20 files changed

+241
-112
lines changed

20 files changed

+241
-112
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: 5 additions & 1 deletion
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;
@@ -898,7 +902,7 @@ void FlexPA::filterViaAccess(
898902
for (auto& [idx, via_def] : via_defs) {
899903
auto via = std::make_unique<frVia>(via_def, begin_point);
900904
const odb::Rect box = via->getLayer1BBox();
901-
if (inst_term) {
905+
if (inst_term && !deep_search) {
902906
odb::Rect boundary_bbox = inst_term->getInst()->getBoundaryBBox();
903907
if (!boundary_bbox.contains(box)) {
904908
continue;

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: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <map>
77
#include <memory>
8+
#include <set>
89
#include <tuple>
910
#include <unordered_map>
1011
#include <utility>
@@ -29,29 +30,39 @@ struct UniqueClassKey
2930
odb::dbOrientType orient{odb::dbOrientType::R0};
3031
std::vector<frCoord> offsets;
3132
frInst* ndr_inst{nullptr};
33+
std::set<frTerm*> stubborn_terms;
3234

3335
UniqueClassKey(frMaster* master_in,
3436
const odb::dbOrientType& orient_in,
3537
std::vector<frCoord> offsets_in,
36-
frInst* ndr_inst_in = nullptr)
38+
frInst* ndr_inst_in = nullptr,
39+
std::set<frTerm*> stubborn_terms_in = {})
3740
: master(master_in),
3841
orient(orient_in),
3942
offsets(std::move(offsets_in)),
40-
ndr_inst(ndr_inst_in)
43+
ndr_inst(ndr_inst_in),
44+
stubborn_terms(std::move(stubborn_terms_in))
4145
{
4246
}
4347

4448
bool operator<(const UniqueClassKey& other) const
4549
{
46-
return std::tie(master, orient, offsets, ndr_inst) < std::tie(
47-
other.master, other.orient, other.offsets, other.ndr_inst);
50+
return std::tie(master, orient, offsets, ndr_inst, stubborn_terms)
51+
< std::tie(other.master,
52+
other.orient,
53+
other.offsets,
54+
other.ndr_inst,
55+
other.stubborn_terms);
4856
}
4957

5058
bool operator==(const UniqueClassKey& other) const
5159
{
52-
return std::tie(master, orient, offsets, ndr_inst)
53-
== std::tie(
54-
other.master, other.orient, other.offsets, other.ndr_inst);
60+
return std::tie(master, orient, offsets, ndr_inst, stubborn_terms)
61+
== std::tie(other.master,
62+
other.orient,
63+
other.offsets,
64+
other.ndr_inst,
65+
other.stubborn_terms);
5566
}
5667
};
5768

@@ -66,6 +77,10 @@ class UniqueClass
6677
frMaster* getMaster() const { return key_.master; }
6778
odb::dbOrientType getOrient() const { return key_.orient; }
6879
const std::vector<frCoord>& getOffsets() const { return key_.offsets; }
80+
const std::set<frTerm*>& getStubbornTerms() const
81+
{
82+
return key_.stubborn_terms;
83+
}
6984
const InstSet& getInsts() const { return insts_; }
7085
int getPinAccessIdx() const { return pin_access_idx_; }
7186
void setPinAccessIdx(int idx) { pin_access_idx_ = idx; }

src/grt/include/grt/GlobalRouter.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ class GlobalRouter
165165
void readGuides(const char* file_name);
166166
void loadGuidesFromDB();
167167
void ensurePinsPositions(odb::dbNet* db_net);
168+
bool findCoveredAccessPoint(const Net* net, Pin& pin);
168169
void saveGuidesFromFile(std::unordered_map<odb::dbNet*, Guides>& guides);
169170
void saveGuides(const std::vector<odb::dbNet*>& nets);
170171
void writeSegments(const char* file_name);
@@ -302,7 +303,8 @@ class GlobalRouter
302303

303304
bool findPinAccessPointPositions(
304305
const Pin& pin,
305-
std::map<int, std::vector<PointPair>>& ap_positions);
306+
std::map<int, std::vector<PointPair>>& ap_positions,
307+
bool all_access_points = false);
306308
void getNetLayerRange(odb::dbNet* db_net, int& min_layer, int& max_layer);
307309
void getGridSize(int& x_grids, int& y_grids);
308310
int getGridTileSize();

0 commit comments

Comments
 (0)