Skip to content

Commit ec1fd9b

Browse files
committed
mpl: simplify pad handling by using a vector
Signed-off-by: Arthur Koucher <[email protected]>
1 parent ba961b7 commit ec1fd9b

File tree

3 files changed

+23
-42
lines changed

3 files changed

+23
-42
lines changed

src/mpl/src/clusterEngine.cpp

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ void ClusteringEngine::run()
4242
createRoot();
4343
setBaseThresholds();
4444

45-
mapIOPinsAndPads();
4645
createDataFlow();
4746

4847
createIOClusters();
@@ -77,7 +76,8 @@ void ClusteringEngine::setTree(PhysicalHierarchy* tree)
7776
}
7877

7978
// Check if macro placement is both needed and feasible.
80-
// Also report some design data relevant for the user.
79+
// Also report some design data relevant for the user and
80+
// initialize the tree with data from the design.
8181
void ClusteringEngine::init()
8282
{
8383
const std::vector<odb::dbInst*> unfixed_macros = getUnfixedMacros();
@@ -103,6 +103,8 @@ void ClusteringEngine::init()
103103
tree_->floorplan_shape.getArea());
104104
}
105105

106+
tree_->io_pads = getIOPads();
107+
106108
reportDesignData();
107109
}
108110

@@ -207,6 +209,17 @@ Metrics* ClusteringEngine::computeModuleMetrics(odb::dbModule* module)
207209
return tree_->maps.module_to_metrics[module].get();
208210
}
209211

212+
std::vector<odb::dbInst*> ClusteringEngine::getIOPads() const
213+
{
214+
std::vector<odb::dbInst*> io_pads;
215+
for (odb::dbInst* inst : block_->getInsts()) {
216+
if (inst->isPad()) {
217+
io_pads.push_back(inst);
218+
}
219+
}
220+
return io_pads;
221+
}
222+
210223
void ClusteringEngine::reportDesignData()
211224
{
212225
const odb::Rect& die = block_->getDieArea();
@@ -341,7 +354,7 @@ void ClusteringEngine::setBaseThresholds()
341354
// - If an IO pin has no constraints, it is constrained to all boundaries.
342355
void ClusteringEngine::createIOClusters()
343356
{
344-
if (!tree_->maps.pad_to_bterm.empty()) {
357+
if (!tree_->io_pads.empty()) {
345358
createIOPadClusters();
346359
return;
347360
}
@@ -493,38 +506,9 @@ void ClusteringEngine::setIOClusterDimensions(const odb::Rect& die,
493506
}
494507
}
495508

496-
void ClusteringEngine::mapIOPinsAndPads()
497-
{
498-
bool design_has_io_pads = false;
499-
for (auto inst : block_->getInsts()) {
500-
if (inst->getMaster()->isPad()) {
501-
design_has_io_pads = true;
502-
break;
503-
}
504-
}
505-
506-
if (!design_has_io_pads) {
507-
return;
508-
}
509-
510-
for (odb::dbNet* net : block_->getNets()) {
511-
if (net->getBTerms().size() == 0) {
512-
continue;
513-
}
514-
515-
for (odb::dbBTerm* bterm : net->getBTerms()) {
516-
for (odb::dbITerm* iterm : net->getITerms()) {
517-
odb::dbInst* inst = iterm->getInst();
518-
tree_->maps.pad_to_bterm[inst] = bterm;
519-
tree_->maps.bterm_to_pad[bterm] = inst;
520-
}
521-
}
522-
}
523-
}
524-
525509
void ClusteringEngine::createIOPadClusters()
526510
{
527-
for (const auto& [bterm, pad] : tree_->maps.bterm_to_pad) {
511+
for (odb::dbInst* pad : tree_->io_pads) {
528512
createIOPadCluster(pad);
529513
}
530514
}
@@ -611,7 +595,7 @@ VerticesMaps ClusteringEngine::computeVertices()
611595
{
612596
VerticesMaps vertices_maps;
613597

614-
if (tree_->maps.bterm_to_pad.empty()) {
598+
if (tree_->io_pads.empty()) {
615599
computeIOVertices(vertices_maps);
616600
} else {
617601
computePadVertices(vertices_maps);
@@ -642,7 +626,7 @@ void ClusteringEngine::computeIOVertices(VerticesMaps& vertices_maps)
642626

643627
void ClusteringEngine::computePadVertices(VerticesMaps& vertices_maps)
644628
{
645-
for (const auto& [bterm, pad] : tree_->maps.bterm_to_pad) {
629+
for (odb::dbInst* pad : tree_->io_pads) {
646630
const int id = static_cast<int>(vertices_maps.stoppers.size());
647631
odb::dbIntProperty::create(pad, "vertex_id", id);
648632
vertices_maps.id_to_std_cell[id] = pad;
@@ -1785,7 +1769,7 @@ void ClusteringEngine::updateConnections()
17851769
}
17861770

17871771
bool net_has_io_pin = false;
1788-
if (tree_->maps.bterm_to_pad.empty()) {
1772+
if (!tree_->io_pads.empty()) {
17891773
for (odb::dbBTerm* bterm : net->getBTerms()) {
17901774
const int cluster_id = tree_->maps.bterm_to_cluster_id.at(bterm);
17911775
net_has_io_pin = true;

src/mpl/src/clusterEngine.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,12 @@ struct PhysicalHierarchyMaps
7777

7878
InstToHardMap inst_to_hard;
7979
ModuleToMetricsMap module_to_metrics;
80-
81-
// Only for designs with IO Pads
82-
std::map<odb::dbInst*, odb::dbBTerm*> pad_to_bterm;
83-
std::map<odb::dbBTerm*, odb::dbInst*> bterm_to_pad;
8480
};
8581

8682
struct PhysicalHierarchy
8783
{
8884
std::unique_ptr<Cluster> root;
85+
std::vector<odb::dbInst*> io_pads;
8986
PhysicalHierarchyMaps maps;
9087

9188
// This is set according to the ppl -exclude constraints
@@ -160,6 +157,7 @@ class ClusteringEngine
160157
void searchForFixedInstsInsideFloorplanShape();
161158
float computeMacroWithHaloArea(
162159
const std::vector<odb::dbInst*>& unfixed_macros);
160+
std::vector<odb::dbInst*> getIOPads() const;
163161
void reportDesignData();
164162
void createRoot();
165163
void setBaseThresholds();
@@ -180,7 +178,6 @@ class ClusteringEngine
180178
int& y,
181179
int& width,
182180
int& height);
183-
void mapIOPinsAndPads();
184181
void treatEachMacroAsSingleCluster();
185182
void incorporateNewCluster(std::unique_ptr<Cluster> cluster, Cluster* parent);
186183
void setClusterMetrics(Cluster* cluster);

src/mpl/src/hier_rtlmp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ void HierRTLMP::setTightPackingTilings(Cluster* macro_array)
869869

870870
void HierRTLMP::setPinAccessBlockages()
871871
{
872-
if (!tree_->maps.pad_to_bterm.empty()) {
872+
if (!tree_->io_pads.empty()) {
873873
return;
874874
}
875875

0 commit comments

Comments
 (0)