Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions src/mpl/src/SACoreSoftMacro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ void SACoreSoftMacro::calBoundaryPenalty()
// 1) Number of macros to prioritize clusters with more macros.
// 2) The macro area percentage over the cluster's total area so that
// mixed clusters with large std cell area have less penalty.

void SACoreSoftMacro::calMacroBlockagePenalty()
{
macro_blockage_penalty_ = 0.0;
Expand All @@ -445,32 +444,22 @@ void SACoreSoftMacro::calMacroBlockagePenalty()

for (auto& blockage : blockages_) {
for (const auto& macro_id : pos_seq_) {
if (macros_[macro_id].getNumMacro() > 0) {
const float soft_macro_x_min = macros_[macro_id].getX();
const float soft_macro_x_max
= soft_macro_x_min + macros_[macro_id].getWidth();
const float soft_macro_y_min = macros_[macro_id].getY();
const float soft_macro_y_max
= soft_macro_y_min + macros_[macro_id].getHeight();

const float overlap_width
= std::min(blockage.xMax(), soft_macro_x_max)
- std::max(blockage.xMin(), soft_macro_x_min);
const float overlap_height
= std::min(blockage.yMax(), soft_macro_y_max)
- std::max(blockage.yMin(), soft_macro_y_min);
const SoftMacro& soft_macro = macros_[macro_id];
if (soft_macro.getNumMacro() > 0) {
Tiling overlap_shape
= computeOverlapShape(blockage, soft_macro.getBBox());

// If any of the dimensions is negative, then there's no overlap.
if (overlap_width < 0 || overlap_height < 0) {
if (overlap_shape.width() < 0 || overlap_shape.height() < 0) {
continue;
}

Cluster* cluster = macros_[macro_id].getCluster();
Cluster* cluster = soft_macro.getCluster();
float macro_dominance = cluster->getMacroArea() / cluster->getArea();

macro_blockage_penalty_ += overlap_width * overlap_height
* macros_[macro_id].getNumMacro()
* macro_dominance;
macro_blockage_penalty_ += overlap_shape.width()
* overlap_shape.height()
* soft_macro.getNumMacro() * macro_dominance;
}
}
}
Expand Down Expand Up @@ -1086,4 +1075,15 @@ void SACoreSoftMacro::moveFloorplan(const std::pair<float, float>& offset)
calPenalty();
}

Tiling SACoreSoftMacro::computeOverlapShape(const Rect& rect_a,
const Rect& rect_b) const
{
const float overlap_width = std::min(rect_a.xMax(), rect_b.xMax())
- std::max(rect_a.xMin(), rect_b.xMin());
const float overlap_height = std::min(rect_a.yMax(), rect_b.yMax())
- std::max(rect_a.yMin(), rect_b.yMin());

return Tiling(overlap_width, overlap_height);
}

} // namespace mpl
2 changes: 2 additions & 0 deletions src/mpl/src/SACoreSoftMacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ class SACoreSoftMacro : public SimulatedAnnealingCore<SoftMacro>
void attemptCentralization(float pre_cost);
void moveFloorplan(const std::pair<float, float>& offset);

Tiling computeOverlapShape(const Rect& rect_a, const Rect& rect_b) const;

std::vector<Rect> blockages_;

Cluster* root_;
Expand Down
1 change: 0 additions & 1 deletion src/mpl/src/shapes.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ struct Interval
float max{0.0f};
};

// Coarse shape of a cluster that contains macros.
class Tiling
{
public:
Expand Down