Skip to content

Commit f463523

Browse files
committed
ppl: adjust assignment costs when design has mirrored pins for pin groups
Signed-off-by: Eder Monteiro <emrmonteiro@precisioninno.com>
1 parent 634e70b commit f463523

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

src/ppl/src/HungarianMatching.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,11 @@ void HungarianMatching::createMatrixForGroups()
225225
}
226226

227227
hungarian_matrix_.resize(group_slots_);
228-
int groupIndex = 0;
228+
int group_index = 0;
229229
for (const auto& [pins, order] : pin_groups_) {
230230
int slot_index = 0;
231+
bool is_mirrored = false;
232+
std::vector<int> larger_costs(valid_starting_slots_.size(), 0);
231233
for (int i : valid_starting_slots_) {
232234
int group_hpwl = 0;
233235
for (const int io_idx : pins) {
@@ -243,14 +245,27 @@ void HungarianMatching::createMatrixForGroups()
243245
}
244246
const int mirrored_cost = getMirroredPinCost(io_pin, slot_pos);
245247
group_hpwl += pin_hpwl + mirrored_cost;
248+
larger_costs[slot_index] += std::max(pin_hpwl, mirrored_cost);
249+
is_mirrored = is_mirrored || mirrored_cost != 0;
246250
}
247251
if (pins.size() > group_slot_capacity[slot_index]) {
248252
group_hpwl = std::numeric_limits<int>::max();
249253
}
250-
hungarian_matrix_[slot_index][groupIndex] = group_hpwl;
254+
hungarian_matrix_[slot_index][group_index] = group_hpwl;
251255
slot_index++;
252256
}
253-
groupIndex++;
257+
258+
if (is_mirrored) {
259+
std::vector<uint8_t> rank = getTieBreakRank(larger_costs);
260+
for (int idx = 0; idx < slot_index; idx++) {
261+
const int hpwl = hungarian_matrix_[idx][group_index];
262+
if ((hpwl >> 24) != 0) {
263+
logger_->critical(utl::PPL, 211, "Cost for pin exceeds 24 bits.");
264+
}
265+
hungarian_matrix_[idx][group_index] = (hpwl << 8) | rank[idx];
266+
}
267+
}
268+
group_index++;
254269
}
255270

256271
if (hungarian_matrix_.empty()) {
@@ -380,7 +395,7 @@ Edge HungarianMatching::getMirroredEdge(const Edge& edge)
380395
std::vector<uint8_t> HungarianMatching::getTieBreakRank(
381396
const std::vector<int>& costs)
382397
{
383-
std::vector<uint8_t> rank(non_blocked_slots_);
398+
std::vector<uint8_t> rank(costs.size());
384399
uint8_t ranking = 1;
385400
for (int i : sortIndexes(costs, costs)) {
386401
rank[i] = ranking;

0 commit comments

Comments
 (0)