Skip to content

Commit 22cf9d1

Browse files
authored
Merge pull request #7887 from AcKoucher/mpl-convert-methods-global
mpl: make conversion methods usable across MPL namespace
2 parents 0b2b56c + d91d4e6 commit 22cf9d1

File tree

4 files changed

+118
-122
lines changed

4 files changed

+118
-122
lines changed

src/mpl/src/hier_rtlmp.cpp

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ void HierRTLMP::calculateChildrenTilings(Cluster* parent)
462462
outline.getWidth() * vary_factor_list[run_id++],
463463
outline.getHeight());
464464
if (graphics_) {
465-
graphics_->setOutline(micronsToDbu(new_outline));
465+
graphics_->setOutline(micronsToDbu(block_, new_outline));
466466
}
467467
std::unique_ptr<SACoreSoftMacro> sa
468468
= std::make_unique<SACoreSoftMacro>(tree_.get(),
@@ -522,7 +522,7 @@ void HierRTLMP::calculateChildrenTilings(Cluster* parent)
522522
outline.getWidth(),
523523
outline.getHeight() * vary_factor_list[run_id++]);
524524
if (graphics_) {
525-
graphics_->setOutline(micronsToDbu(new_outline));
525+
graphics_->setOutline(micronsToDbu(block_, new_outline));
526526
}
527527
std::unique_ptr<SACoreSoftMacro> sa
528528
= std::make_unique<SACoreSoftMacro>(tree_.get(),
@@ -710,7 +710,7 @@ void HierRTLMP::calculateMacroTilings(Cluster* cluster)
710710
outline.getWidth() * vary_factor_list[run_id++],
711711
outline.getHeight());
712712
if (graphics_) {
713-
graphics_->setOutline(micronsToDbu(new_outline));
713+
graphics_->setOutline(micronsToDbu(block_, new_outline));
714714
}
715715
std::unique_ptr<SACoreHardMacro> sa
716716
= std::make_unique<SACoreHardMacro>(tree_.get(),
@@ -765,7 +765,7 @@ void HierRTLMP::calculateMacroTilings(Cluster* cluster)
765765
outline.getWidth(),
766766
outline.getHeight() * vary_factor_list[run_id++]);
767767
if (graphics_) {
768-
graphics_->setOutline(micronsToDbu(new_outline));
768+
graphics_->setOutline(micronsToDbu(block_, new_outline));
769769
}
770770
std::unique_ptr<SACoreHardMacro> sa
771771
= std::make_unique<SACoreHardMacro>(tree_.get(),
@@ -930,7 +930,7 @@ void HierRTLMP::createPinAccessBlockages()
930930

931931
void HierRTLMP::computePinAccessDepthLimits()
932932
{
933-
const Rect die = dbuToMicrons(block_->getDieArea());
933+
const Rect die = dbuToMicrons(block_, block_->getDieArea());
934934

935935
constexpr float max_depth_proportion = 0.20;
936936
pin_access_depth_limits_.x.max = max_depth_proportion * die.getWidth();
@@ -979,7 +979,7 @@ void HierRTLMP::createBlockagesForIOBundles()
979979
= static_cast<float>(clustering_engine_->getNumberOfIOs(io_bundle));
980980
const float io_density_factor = number_of_ios / total_fixed_ios;
981981
const float depth = base_depth * io_density_factor;
982-
const odb::Rect rect = micronsToDbu(io_bundle->getBBox());
982+
const odb::Rect rect = micronsToDbu(block_, io_bundle->getBBox());
983983
const odb::Line line = rectToLine(block_, rect, logger_);
984984
const BoundaryRegion region(line, getBoundary(block_, rect));
985985
createPinAccessBlockage(region, depth);
@@ -1081,7 +1081,7 @@ void HierRTLMP::createBlockagesForConstraintRegions()
10811081
const float depth = base_depth * io_density_factor;
10821082

10831083
const odb::Rect region_rect
1084-
= micronsToDbu(cluster_of_unplaced_ios->getBBox());
1084+
= micronsToDbu(block_, cluster_of_unplaced_ios->getBBox());
10851085
const odb::Line region_line = rectToLine(block_, region_rect, logger_);
10861086
const BoundaryRegion region(region_line, getBoundary(block_, region_rect));
10871087
createPinAccessBlockage(region, depth);
@@ -1181,7 +1181,7 @@ void HierRTLMP::createPinAccessBlockage(const BoundaryRegion& region,
11811181
region.line.pt1(),
11821182
blockage_depth);
11831183

1184-
Rect blockage = dbuToMicrons(lineToRect(region.line));
1184+
Rect blockage = dbuToMicrons(block_, lineToRect(region.line));
11851185
switch (region.boundary) {
11861186
case (Boundary::L): {
11871187
blockage.setXMax(blockage.xMin() + blockage_depth);
@@ -1359,7 +1359,7 @@ void HierRTLMP::placeChildren(Cluster* parent)
13591359

13601360
const Rect outline = parent->getBBox();
13611361
if (graphics_) {
1362-
graphics_->setOutline(micronsToDbu(outline));
1362+
graphics_->setOutline(micronsToDbu(block_, outline));
13631363
}
13641364

13651365
// Suppose the region, fence, guide has been mapped to cooresponding macros
@@ -1761,7 +1761,7 @@ void HierRTLMP::placeChildrenUsingMinimumTargetUtil(Cluster* parent)
17611761

17621762
const Rect outline = parent->getBBox();
17631763
if (graphics_) {
1764-
graphics_->setOutline(micronsToDbu(outline));
1764+
graphics_->setOutline(micronsToDbu(block_, outline));
17651765
}
17661766

17671767
// Suppose the region, fence, guide has been mapped to cooresponding macros
@@ -2509,7 +2509,7 @@ void HierRTLMP::placeMacros(Cluster* cluster)
25092509

25102510
for (int i = 0; i < run_thread; i++) {
25112511
if (graphics_) {
2512-
graphics_->setOutline(micronsToDbu(outline));
2512+
graphics_->setOutline(micronsToDbu(block_, outline));
25132513
}
25142514

25152515
SACoreWeights new_weights = placement_core_weights_;
@@ -3018,22 +3018,6 @@ void HierRTLMP::setDebugTargetClusterId(const int target_cluster_id)
30183018
graphics_->setTargetClusterId(target_cluster_id);
30193019
}
30203020

3021-
odb::Rect HierRTLMP::micronsToDbu(const Rect& micron_rect) const
3022-
{
3023-
return odb::Rect(block_->micronsToDbu(micron_rect.xMin()),
3024-
block_->micronsToDbu(micron_rect.yMin()),
3025-
block_->micronsToDbu(micron_rect.xMax()),
3026-
block_->micronsToDbu(micron_rect.yMax()));
3027-
}
3028-
3029-
Rect HierRTLMP::dbuToMicrons(const odb::Rect& dbu_rect) const
3030-
{
3031-
return Rect(block_->dbuToMicrons(dbu_rect.xMin()),
3032-
block_->dbuToMicrons(dbu_rect.yMin()),
3033-
block_->dbuToMicrons(dbu_rect.xMax()),
3034-
block_->dbuToMicrons(dbu_rect.yMax()));
3035-
}
3036-
30373021
// Example for a vertical region:
30383022
// Base - Overlay = Result
30393023
// | |

src/mpl/src/hier_rtlmp.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,6 @@ class HierRTLMP
225225
void adjustRealMacroOrientation(const bool& is_vertical_flip);
226226
void flipRealMacro(odb::dbInst* macro, const bool& is_vertical_flip);
227227

228-
// Aux for conversion
229-
odb::Rect micronsToDbu(const Rect& micron_rect) const;
230-
Rect dbuToMicrons(const odb::Rect& dbu_rect) const;
231-
232228
template <typename Macro>
233229
void createFixedTerminal(Cluster* cluster,
234230
const Rect& outline,

src/mpl/src/object.h

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -549,97 +549,6 @@ struct BundledNet
549549
int target_cluster_id = -1;
550550
};
551551

552-
// Here we redefine the Rect class
553-
// odb::Rect use database unit
554-
// Rect class use float type for Micron unit
555-
struct Rect
556-
{
557-
Rect() = default;
558-
Rect(const float lx,
559-
const float ly,
560-
const float ux,
561-
const float uy,
562-
bool fixed_flag = false)
563-
: lx(lx), ly(ly), ux(ux), uy(uy), fixed_flag(fixed_flag)
564-
{
565-
}
566-
567-
float xMin() const { return lx; }
568-
float yMin() const { return ly; }
569-
float xMax() const { return ux; }
570-
float yMax() const { return uy; }
571-
572-
void setXMin(float lx) { this->lx = lx; }
573-
void setYMin(float ly) { this->ly = ly; }
574-
void setXMax(float ux) { this->ux = ux; }
575-
void setYMax(float uy) { this->uy = uy; }
576-
577-
float xCenter() const { return (lx + ux) / 2.0; }
578-
float yCenter() const { return (ly + uy) / 2.0; }
579-
580-
float getWidth() const { return ux - lx; }
581-
float getHeight() const { return uy - ly; }
582-
583-
float getPerimeter() const { return 2 * getWidth() + 2 * getHeight(); }
584-
float getArea() const { return getWidth() * getHeight(); }
585-
586-
void moveHor(float dist)
587-
{
588-
lx = lx + dist;
589-
ux = ux + dist;
590-
}
591-
592-
void moveVer(float dist)
593-
{
594-
ly = ly + dist;
595-
uy = uy + dist;
596-
}
597-
598-
bool isValid() const { return (lx < ux) && (ly < uy); }
599-
600-
void mergeInit()
601-
{
602-
lx = std::numeric_limits<float>::max();
603-
ly = lx;
604-
ux = std::numeric_limits<float>::lowest();
605-
uy = ux;
606-
}
607-
608-
void merge(const Rect& rect)
609-
{
610-
lx = std::min(lx, rect.lx);
611-
ly = std::min(ly, rect.ly);
612-
ux = std::max(ux, rect.ux);
613-
uy = std::max(uy, rect.uy);
614-
}
615-
616-
void relocate(float outline_lx,
617-
float outline_ly,
618-
float outline_ux,
619-
float outline_uy)
620-
{
621-
if (!isValid()) {
622-
return;
623-
}
624-
625-
lx = std::max(lx, outline_lx);
626-
ly = std::max(ly, outline_ly);
627-
ux = std::min(ux, outline_ux);
628-
uy = std::min(uy, outline_uy);
629-
lx -= outline_lx;
630-
ly -= outline_ly;
631-
ux -= outline_lx;
632-
uy -= outline_ly;
633-
}
634-
635-
float lx = 0.0;
636-
float ly = 0.0;
637-
float ux = 0.0;
638-
float uy = 0.0;
639-
640-
bool fixed_flag = false;
641-
};
642-
643552
struct SequencePair
644553
{
645554
std::vector<int> pos_sequence;

src/mpl/src/util.h

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,111 @@ inline double computeDistToNearestRegion(
201201
return std::sqrt(smallest_distance);
202202
}
203203

204+
// Here we redefine the Rect class
205+
// odb::Rect use database unit
206+
// Rect class use float type for Micron unit
207+
struct Rect
208+
{
209+
Rect() = default;
210+
Rect(const float lx,
211+
const float ly,
212+
const float ux,
213+
const float uy,
214+
bool fixed_flag = false)
215+
: lx(lx), ly(ly), ux(ux), uy(uy), fixed_flag(fixed_flag)
216+
{
217+
}
218+
219+
float xMin() const { return lx; }
220+
float yMin() const { return ly; }
221+
float xMax() const { return ux; }
222+
float yMax() const { return uy; }
223+
224+
void setXMin(float lx) { this->lx = lx; }
225+
void setYMin(float ly) { this->ly = ly; }
226+
void setXMax(float ux) { this->ux = ux; }
227+
void setYMax(float uy) { this->uy = uy; }
228+
229+
float xCenter() const { return (lx + ux) / 2.0; }
230+
float yCenter() const { return (ly + uy) / 2.0; }
231+
232+
float getWidth() const { return ux - lx; }
233+
float getHeight() const { return uy - ly; }
234+
235+
float getPerimeter() const { return 2 * getWidth() + 2 * getHeight(); }
236+
float getArea() const { return getWidth() * getHeight(); }
237+
238+
void moveHor(float dist)
239+
{
240+
lx = lx + dist;
241+
ux = ux + dist;
242+
}
243+
244+
void moveVer(float dist)
245+
{
246+
ly = ly + dist;
247+
uy = uy + dist;
248+
}
249+
250+
bool isValid() const { return (lx < ux) && (ly < uy); }
251+
252+
void mergeInit()
253+
{
254+
lx = std::numeric_limits<float>::max();
255+
ly = lx;
256+
ux = std::numeric_limits<float>::lowest();
257+
uy = ux;
258+
}
259+
260+
void merge(const Rect& rect)
261+
{
262+
lx = std::min(lx, rect.lx);
263+
ly = std::min(ly, rect.ly);
264+
ux = std::max(ux, rect.ux);
265+
uy = std::max(uy, rect.uy);
266+
}
267+
268+
void relocate(float outline_lx,
269+
float outline_ly,
270+
float outline_ux,
271+
float outline_uy)
272+
{
273+
if (!isValid()) {
274+
return;
275+
}
276+
277+
lx = std::max(lx, outline_lx);
278+
ly = std::max(ly, outline_ly);
279+
ux = std::min(ux, outline_ux);
280+
uy = std::min(uy, outline_uy);
281+
lx -= outline_lx;
282+
ly -= outline_ly;
283+
ux -= outline_lx;
284+
uy -= outline_ly;
285+
}
286+
287+
float lx = 0.0;
288+
float ly = 0.0;
289+
float ux = 0.0;
290+
float uy = 0.0;
291+
292+
bool fixed_flag = false;
293+
};
294+
295+
inline odb::Rect micronsToDbu(odb::dbBlock* block, const Rect& micron_rect)
296+
{
297+
return odb::Rect(block->micronsToDbu(micron_rect.xMin()),
298+
block->micronsToDbu(micron_rect.yMin()),
299+
block->micronsToDbu(micron_rect.xMax()),
300+
block->micronsToDbu(micron_rect.yMax()));
301+
}
302+
303+
inline Rect dbuToMicrons(odb::dbBlock* block, const odb::Rect& dbu_rect)
304+
{
305+
return Rect(block->dbuToMicrons(dbu_rect.xMin()),
306+
block->dbuToMicrons(dbu_rect.yMin()),
307+
block->dbuToMicrons(dbu_rect.xMax()),
308+
block->dbuToMicrons(dbu_rect.yMax()));
309+
}
310+
204311
} // namespace mpl

0 commit comments

Comments
 (0)