Skip to content

Commit 8bf4755

Browse files
Merge pull request #10684 from gudeh/dpl-cell-height
dpl: remove universal cell height assumption
2 parents a9147cf + 777d157 commit 8bf4755

7 files changed

Lines changed: 53 additions & 21 deletions

src/dpl/src/NegotiationLegalizer.cpp

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <cstddef>
1111
#include <functional>
1212
#include <limits>
13+
#include <map>
1314
#include <queue>
1415
#include <tuple>
1516
#include <unordered_map>
@@ -523,13 +524,8 @@ bool NegotiationLegalizer::initFromDb()
523524
die_xhi_ = core_area.xMax();
524525
die_yhi_ = core_area.yMax();
525526

526-
// Site width from the DPL grid; row height from the first DB row.
527527
site_width_ = dpl_grid->getSiteWidth().v;
528-
for (auto* row : block->getRows()) {
529-
row_height_ = row->getSite()->getHeight();
530-
break;
531-
}
532-
assert(site_width_ > 0 && row_height_ > 0);
528+
assert(site_width_ > 0);
533529

534530
// Grid dimensions from the DPL grid (accounts for actual DB rows).
535531
grid_w_ = dpl_grid->getRowSiteCount().v;
@@ -578,10 +574,7 @@ bool NegotiationLegalizer::initFromDb()
578574
1,
579575
static_cast<int>(
580576
std::round(static_cast<double>(master->getWidth()) / site_width_)));
581-
cell.height = std::max(
582-
1,
583-
static_cast<int>(std::round(static_cast<double>(master->getHeight())
584-
/ row_height_)));
577+
cell.height = dpl_grid->gridHeight(master).v;
585578

586579
// Clamp to valid grid range – gridRoundY can return grid_h_ when the
587580
// instance is near the top edge. Use (grid_w_ - width) so the full
@@ -647,9 +640,9 @@ bool NegotiationLegalizer::initFromDb()
647640
for (auto* box : odb_region->getBoundaries()) {
648641
RegionRectInline r;
649642
r.xlo = (box->xMin() - die_xlo_) / site_width_;
650-
r.ylo = (box->yMin() - die_ylo_) / row_height_;
643+
r.ylo = dpl_grid->gridEndY(DbuY{box->yMin() - die_ylo_}).v;
651644
r.xhi = (box->xMax() - die_xlo_) / site_width_;
652-
r.yhi = (box->yMax() - die_ylo_) / row_height_;
645+
r.yhi = dpl_grid->gridSnapDownY(DbuY{box->yMax() - die_ylo_}).v;
653646
rects.push_back(r);
654647
}
655648
it = region_rect_cache.emplace(odb_region, std::move(rects)).first;
@@ -684,11 +677,12 @@ bool NegotiationLegalizer::initFromDb()
684677
db_x,
685678
db_y,
686679
die_xlo_ + cell.init_x * site_width_,
687-
die_ylo_ + cell.init_y * row_height_);
680+
die_ylo_ + dpl_grid->gridYToDbu(GridY{cell.init_y}).v);
688681

689682
// Priority queue keyed on physical Manhattan distance (DBU) so the
690683
// search expands in true physical proximity, not grid-unit proximity.
691-
// One step in X = site_width_ DBU; one step in Y = row_height_ DBU.
684+
// One step in X = site_width_ DBU; Y distance is computed via the
685+
// DPL grid since pixel rows may have non-uniform heights.
692686
using PQEntry = std::tuple<int, int, int>; // physDist, gx, gy
693687
std::
694688
priority_queue<PQEntry, std::vector<PQEntry>, std::greater<PQEntry>>
@@ -704,8 +698,10 @@ bool NegotiationLegalizer::initFromDb()
704698
if (!visited.insert(gy * grid_w_ + gx).second) {
705699
return;
706700
}
707-
const int dist = std::abs(gx - cell.init_x) * site_width_
708-
+ std::abs(gy - cell.init_y) * row_height_;
701+
const int dy_dbu = dpl_grid->gridYToDbu(GridY{gy}).v
702+
- dpl_grid->gridYToDbu(GridY{cell.init_y}).v;
703+
const int dist
704+
= std::abs(gx - cell.init_x) * site_width_ + std::abs(dy_dbu);
709705
pq.emplace(dist, gx, gy);
710706
};
711707

@@ -745,6 +741,19 @@ bool NegotiationLegalizer::initFromDb()
745741
cells_.push_back(cell);
746742
}
747743

744+
std::map<int, int> neg_height_counts;
745+
for (const NegCell& c : cells_) {
746+
neg_height_counts[c.height]++;
747+
}
748+
logger_->info(
749+
utl::DPL,
750+
392,
751+
"Negotiation cell height distribution ({} unique row-count(s)):",
752+
neg_height_counts.size());
753+
for (const auto& [height, count] : neg_height_counts) {
754+
logger_->info(utl::DPL, 393, " height {} row(s): {} cells", height, count);
755+
}
756+
748757
return true;
749758
}
750759

@@ -813,12 +822,13 @@ void NegotiationLegalizer::initFenceRegions()
813822
FenceRegion fr;
814823
fr.id = region->getId();
815824

825+
const Grid* dpl_grid = opendp_->grid_.get();
816826
for (auto* box : region->getBoundaries()) {
817827
FenceRect r;
818828
r.xlo = (box->xMin() - die_xlo_) / site_width_;
819-
r.ylo = (box->yMin() - die_ylo_) / row_height_;
829+
r.ylo = dpl_grid->gridEndY(DbuY{box->yMin() - die_ylo_}).v;
820830
r.xhi = (box->xMax() - die_xlo_) / site_width_;
821-
r.yhi = (box->yMax() - die_ylo_) / row_height_;
831+
r.yhi = dpl_grid->gridSnapDownY(DbuY{box->yMax() - die_ylo_}).v;
822832
fr.rects.push_back(r);
823833
}
824834

src/dpl/src/NegotiationLegalizer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ class NegotiationLegalizer
233233
Network* network_{nullptr};
234234

235235
int site_width_{0};
236-
int row_height_{0};
237236
int die_xlo_{0};
238237
int die_ylo_{0};
239238
int die_xhi_{0};

src/dpl/src/NegotiationLegalizerPass.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,10 @@ void NegotiationLegalizer::place(int cell_idx, int x, int y)
418418
pushNegotiationPixels();
419419
const NegCell& c = cells_[cell_idx];
420420
const int orig_x_dbu = die_xlo_ + c.init_x * site_width_;
421-
const int orig_y_dbu = die_ylo_ + c.init_y * row_height_;
421+
const int orig_y_dbu
422+
= die_ylo_ + opendp_->grid_->gridYToDbu(GridY{c.init_y}).v;
422423
const int tgt_x_dbu = die_xlo_ + c.x * site_width_;
423-
const int tgt_y_dbu = die_ylo_ + c.y * row_height_;
424+
const int tgt_y_dbu = die_ylo_ + opendp_->grid_->gridYToDbu(GridY{c.y}).v;
424425
logger_->report(
425426
"Pause at placing of cell {}. orig=({},{}) target=({},{}) dbu. "
426427
"rowidx={}.",

src/dpl/src/dbToOpendp.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,22 @@ void Opendp::importDb()
187187
createNetwork();
188188
createArchitecture();
189189
setUpPlacementGroups();
190+
191+
if (logger_->debugCheck(utl::DPL, "hybrid", 1)) {
192+
std::map<int, int> height_counts;
193+
for (const auto& node : network_->getNodes()) {
194+
if (node->getType() != Node::CELL) {
195+
continue;
196+
}
197+
height_counts[node->getHeight().v]++;
198+
}
199+
logger_->report("Cell height distribution ({} unique micron height(s)):",
200+
height_counts.size());
201+
for (const auto& [height, count] : height_counts) {
202+
logger_->report(
203+
" height {:.3f} um: {} cells", block_->dbuToMicrons(height), count);
204+
}
205+
}
190206
}
191207

192208
void Opendp::importClear()

src/dpl/test/negotiation01.ok

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
[INFO DPL-0006] Core area: 14266.91 um^2, Instances area: 637.60 um^2, Utilization: 4.5%
77
[INFO DPL-0005] Diamond search max displacement: +/- 500 sites horizontally, +/- 100 rows vertically.
88
[INFO DPL-1102] Legalizing using negotiation legalizer.
9+
[INFO DPL-0392] Negotiation cell height distribution (1 unique row-count(s)):
10+
[INFO DPL-0393] height 1 row(s): 549 cells
911
Negotiation iteration 0: total overflow 12.
1012
Negotiation iteration 1: total overflow 0.
1113
Placement Analysis

src/dpl/test/negotiation_one_site_gap.ok

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
[INFO DPL-0006] Core area: 16.49 um^2, Instances area: 3.72 um^2, Utilization: 22.6%
77
[INFO DPL-0005] Diamond search max displacement: +/- 500 sites horizontally, +/- 100 rows vertically.
88
[INFO DPL-1102] Legalizing using negotiation legalizer.
9+
[INFO DPL-0392] Negotiation cell height distribution (1 unique row-count(s)):
10+
[INFO DPL-0393] height 1 row(s): 4 cells
911
Negotiation iteration 0: total overflow 0.
1012
Placement Analysis
1113
---------------------------------

src/dpl/test/negotiation_regions.ok

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
[INFO DPL-0006] Core area: 16.49 um^2, Instances area: 2.93 um^2, Utilization: 17.7%
77
[INFO DPL-0005] Diamond search max displacement: +/- 500 sites horizontally, +/- 100 rows vertically.
88
[INFO DPL-1102] Legalizing using negotiation legalizer.
9+
[INFO DPL-0392] Negotiation cell height distribution (1 unique row-count(s)):
10+
[INFO DPL-0393] height 1 row(s): 5 cells
911
Negotiation iteration 0: total overflow 0.
1012
Placement Analysis
1113
---------------------------------

0 commit comments

Comments
 (0)