@@ -42,7 +42,6 @@ ClusteringEngine::ClusteringEngine(odb::dbBlock* block,
4242
4343void 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.
8988void 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-
176157Metrics* 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 */
860853bool 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
0 commit comments