Skip to content

Commit c9add04

Browse files
authored
Merge pull request #9077 from AcKoucher/mpl-macros-without-pins
mpl: properly handle fixed macros outside the macro placement area
2 parents 8c623a8 + 6c1f0bb commit c9add04

20 files changed

+1301
-56
lines changed

src/mpl/src/clusterEngine.cpp

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ ClusteringEngine::ClusteringEngine(odb::dbBlock* block,
4242

4343
void ClusteringEngine::run()
4444
{
45-
design_metrics_ = computeModuleMetrics(block_->getTopModule());
4645
init();
4746

4847
if (!tree_->has_unfixed_macros) {
@@ -88,17 +87,18 @@ void ClusteringEngine::setTree(PhysicalHierarchy* tree)
8887
// initialize the tree with data from the design.
8988
void ClusteringEngine::init()
9089
{
90+
setDieArea();
91+
setFloorplanShape();
92+
93+
design_metrics_ = computeModuleMetrics(block_->getTopModule());
94+
9195
const std::vector<odb::dbInst*> unfixed_macros = getUnfixedMacros();
9296
if (unfixed_macros.empty()) {
9397
tree_->has_unfixed_macros = false;
9498
logger_->info(MPL, 17, "No unfixed macros.");
9599
return;
96100
}
97101

98-
setDieArea();
99-
setFloorplanShape();
100-
searchForFixedInstsInsideFloorplanShape();
101-
102102
tree_->macro_with_halo_area = computeMacroWithHaloArea(unfixed_macros);
103103
const float inst_area_with_halos
104104
= tree_->macro_with_halo_area + design_metrics_->getStdCellArea();
@@ -154,25 +154,6 @@ void ClusteringEngine::setFloorplanShape()
154154
tree_->floorplan_shape = block_->getCoreArea().intersect(tree_->global_fence);
155155
}
156156

157-
void ClusteringEngine::searchForFixedInstsInsideFloorplanShape()
158-
{
159-
for (odb::dbInst* inst : block_->getInsts()) {
160-
odb::dbMaster* master = inst->getMaster();
161-
162-
if (master->isBlock() || master->isCover()) {
163-
continue;
164-
}
165-
166-
if (inst->isFixed()
167-
&& inst->getBBox()->getBox().overlaps(tree_->floorplan_shape)) {
168-
logger_->error(MPL,
169-
50,
170-
"Found fixed instance {} inside the floorplan area.",
171-
inst->getName());
172-
}
173-
}
174-
}
175-
176157
Metrics* ClusteringEngine::computeModuleMetrics(odb::dbModule* module)
177158
{
178159
unsigned int num_std_cell = 0;
@@ -183,15 +164,25 @@ Metrics* ClusteringEngine::computeModuleMetrics(odb::dbModule* module)
183164
const odb::Rect& core = block_->getCoreArea();
184165

185166
for (odb::dbInst* inst : module->getInsts()) {
186-
if (isIgnoredInst(inst)) {
187-
continue;
188-
}
189-
190-
int64_t inst_area = computeArea(inst);
191-
192-
if (inst->isBlock()) { // a macro
167+
if (inst->isBlock()) {
193168
num_macro += 1;
194-
macro_area += inst_area;
169+
macro_area += computeArea(inst);
170+
171+
if (inst->isFixed()) {
172+
logger_->info(MPL, 62, "Found fixed macro {}.", inst->getName());
173+
174+
if (!inst->getBBox()->getBox().overlaps(tree_->floorplan_shape)) {
175+
ignorable_macros_.insert(inst);
176+
logger_->info(MPL,
177+
63,
178+
"{} is outside the macro placement area and will be "
179+
"ignored.",
180+
inst->getName());
181+
continue;
182+
}
183+
184+
tree_->has_fixed_macros = true;
185+
}
195186

196187
auto macro = std::make_unique<HardMacro>(
197188
inst, tree_->halo_width, tree_->halo_height);
@@ -205,14 +196,17 @@ Metrics* ClusteringEngine::computeModuleMetrics(odb::dbModule* module)
205196
generateMacroAndCoreDimensionsTable(macro.get(), core));
206197
}
207198

208-
if (macro->isFixed()) {
209-
tree_->has_fixed_macros = true;
210-
}
211-
212199
tree_->maps.inst_to_hard[inst] = std::move(macro);
213-
} else {
200+
} else if (inst->isFixed() && !inst->getMaster()->isCover()
201+
&& inst->getBBox()->getBox().overlaps(tree_->floorplan_shape)) {
202+
logger_->error(MPL,
203+
50,
204+
"Found fixed non-macro instance {} inside the macro "
205+
"placement area.",
206+
inst->getName());
207+
} else if (!isIgnoredInst(inst)) {
214208
num_std_cell += 1;
215-
std_cell_area += inst_area;
209+
std_cell_area += computeArea(inst);
216210
}
217211
}
218212

@@ -856,12 +850,15 @@ DataFlowHypergraph ClusteringEngine::computeHypergraph(
856850
return graph;
857851
}
858852

859-
/* static */
860853
bool ClusteringEngine::isIgnoredInst(odb::dbInst* inst)
861854
{
855+
if (inst->isBlock()
856+
&& (ignorable_macros_.find(inst) != ignorable_macros_.end())) {
857+
return true;
858+
}
859+
862860
odb::dbMaster* master = inst->getMaster();
863-
return master->isPad() || master->isCover() || master->isEndCap()
864-
|| inst->getITerms().empty();
861+
return master->isPad() || master->isCover() || master->isEndCap();
865862
}
866863

867864
// Forward or Backward DFS search to find sequential paths from/to IO pins based

src/mpl/src/clusterEngine.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <set>
1111
#include <string>
1212
#include <unordered_map>
13+
#include <unordered_set>
1314
#include <utility>
1415
#include <vector>
1516

@@ -161,7 +162,7 @@ class ClusteringEngine
161162

162163
int getNumberOfIOs(Cluster* target) const;
163164

164-
static bool isIgnoredInst(odb::dbInst* inst);
165+
bool isIgnoredInst(odb::dbInst* inst);
165166

166167
private:
167168
using UniqueClusterQueue = std::queue<std::unique_ptr<Cluster>>;
@@ -179,7 +180,6 @@ class ClusteringEngine
179180
std::vector<odb::dbInst*> getUnfixedMacros();
180181
void setDieArea();
181182
void setFloorplanShape();
182-
void searchForFixedInstsInsideFloorplanShape();
183183
int64_t computeMacroWithHaloArea(
184184
const std::vector<odb::dbInst*>& unfixed_macros);
185185
std::vector<odb::dbInst*> getIOPads() const;
@@ -316,11 +316,12 @@ class ClusteringEngine
316316
// The register distance between two macros for
317317
// them to be considered connected when creating data flow.
318318
const int max_num_of_hops_ = 5;
319-
320319
const float minimum_connection_ratio_{0.08};
321320

322321
int first_io_bundle_id_{-1};
323322
IOBundleSpans io_bundle_spans_;
323+
324+
std::unordered_set<odb::dbInst*> ignorable_macros_;
324325
};
325326

326327
} // namespace mpl

src/mpl/test/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ COMPULSORY_TESTS = [
3636
"keep_clustering_data",
3737
"fixed_macros",
3838
"fixed_covers",
39+
"macros_without_pins1",
3940
]
4041

4142
# Disabled in CMakeLists.txt
@@ -104,6 +105,7 @@ filegroup(
104105
"testcases/macro_only.lef",
105106
"testcases/macro_only.lib",
106107
"testcases/macro_only.v",
108+
"testcases/macros_without_pins1.def",
107109
"testcases/mixed_ios1.def",
108110
"testcases/no_unfixed_macros.def",
109111
"testcases/orientation_improve1.def",

src/mpl/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ or_integration_tests(
2929
keep_clustering_data
3030
fixed_macros
3131
fixed_covers
32+
macros_without_pins1
3233
)
3334

3435
# Skipped

src/mpl/test/boundary_push1.ok

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[INFO ODB-0227] LEF file: ./Nangate45/Nangate45.lef, created 22 layers, 27 vias, 135 library cells
2-
[INFO ODB-0227] LEF file: ./testcases/orientation_improve1.lef, created 9 library cells
2+
[INFO ODB-0227] LEF file: ./testcases/orientation_improve1.lef, created 10 library cells
33
[INFO ODB-0128] Design: boundary_push1
44
[INFO ODB-0130] Created 4 pins.
55
[INFO ODB-0131] Created 4 components and 8 component-terminals.

src/mpl/test/boundary_push2.ok

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[INFO ODB-0227] LEF file: ./Nangate45/Nangate45.lef, created 22 layers, 27 vias, 135 library cells
2-
[INFO ODB-0227] LEF file: ./testcases/orientation_improve1.lef, created 9 library cells
2+
[INFO ODB-0227] LEF file: ./testcases/orientation_improve1.lef, created 10 library cells
33
[INFO ODB-0128] Design: boundary_push1
44
[INFO ODB-0130] Created 4 pins.
55
[INFO ODB-0131] Created 54 components and 308 component-terminals.

src/mpl/test/boundary_push3.ok

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[INFO ODB-0227] LEF file: ./Nangate45/Nangate45.lef, created 22 layers, 27 vias, 135 library cells
2-
[INFO ODB-0227] LEF file: ./testcases/orientation_improve1.lef, created 9 library cells
2+
[INFO ODB-0227] LEF file: ./testcases/orientation_improve1.lef, created 10 library cells
33
[INFO ODB-0128] Design: boundary_push1
44
[INFO ODB-0130] Created 4 pins.
55
[INFO ODB-0131] Created 54 components and 308 component-terminals.

src/mpl/test/centralization1.ok

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[INFO ODB-0227] LEF file: ./Nangate45/Nangate45.lef, created 22 layers, 27 vias, 135 library cells
2-
[INFO ODB-0227] LEF file: ./testcases/orientation_improve1.lef, created 9 library cells
2+
[INFO ODB-0227] LEF file: ./testcases/orientation_improve1.lef, created 10 library cells
33
[INFO ODB-0128] Design: centralization1
44
[INFO ODB-0130] Created 1 pins.
55
[INFO ODB-0131] Created 1 components and 2 component-terminals.

src/mpl/test/fixed_covers.ok

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[INFO ODB-0227] LEF file: ./Nangate45/Nangate45.lef, created 22 layers, 27 vias, 135 library cells
22
[INFO ODB-0227] LEF file: ./Nangate45_io/dummy_pads.lef, created 29 library cells
3-
[INFO ODB-0227] LEF file: ./testcases/orientation_improve1.lef, created 9 library cells
3+
[INFO ODB-0227] LEF file: ./testcases/orientation_improve1.lef, created 10 library cells
44
[INFO ODB-0128] Design: boundary_push1
55
[INFO ODB-0131] Created 402 components and 2404 component-terminals.
6+
[INFO MPL-0062] Found fixed macro MACRO_1.
67
Die Area: (0.00, 0.00) (220.02, 221.20), Floorplan Area: (0.00, 0.00) (220.02, 221.20)
78
Number of std cell instances: 400
89
Area of std cell instances: 1808.80

src/mpl/test/fixed_covers.tcl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# Test if the packing engine can handle one fixed
2-
# macro and two movable macros without generating
3-
# overlap.
1+
# Test if firm COVERs are properly ignored.
42
source "helpers.tcl"
53

64
read_lef "./Nangate45/Nangate45.lef"

0 commit comments

Comments
 (0)