Skip to content

Commit 44269ad

Browse files
authored
Merge pull request The-OpenROAD-Project#6867 from eder-matheus/ppl_mirrored
ppl: consider mirrored pin on sections and hungarian matching costs
2 parents be6d1c6 + 233009e commit 44269ad

14 files changed

+137
-111
lines changed

src/ppl/include/ppl/IOPlacer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ class IOPlacer
221221
bool assignPinToSection(IOPin& io_pin,
222222
int idx,
223223
std::vector<Section>& sections);
224-
void assignMirroredPin(IOPin& io_pin);
224+
void assignMirroredPinToSection(IOPin& io_pin);
225+
int getMirroredPinCost(IOPin& io_pin, const odb::Point& position);
225226
int assignGroupsToSections(int& mirrored_pins_cnt);
226227
int updateSection(Section& section, std::vector<Slot>& slots);
227228
int updateConstraintSections(Constraint& constraint);

src/ppl/src/HungarianMatching.cpp

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,17 @@ void HungarianMatching::createMatrix()
7979
int slot_index = 0;
8080
for (int i = begin_slot_; i <= end_slot_; ++i) {
8181
int pinIndex = 0;
82-
Point newPos = slots_[i].pos;
82+
const Point& slot_pos = slots_[i].pos;
8383
if (slots_[i].blocked) {
8484
continue;
8585
}
8686
hungarian_matrix_[slot_index].resize(num_io_pins_,
8787
std::numeric_limits<int>::max());
8888
for (int idx : pin_indices_) {
89-
const IOPin& io_pin = netlist_->getIoPin(idx);
89+
IOPin& io_pin = netlist_->getIoPin(idx);
9090
if (!io_pin.isInGroup()) {
91-
int hpwl = netlist_->computeIONetHPWL(idx, newPos);
91+
int hpwl = netlist_->computeIONetHPWL(idx, slot_pos)
92+
+ getMirroredPinCost(io_pin, slot_pos);
9293
hungarian_matrix_[slot_index][pinIndex] = hpwl;
9394
pinIndex++;
9495
}
@@ -121,7 +122,7 @@ void HungarianMatching::getFinalAssignment(std::vector<IOPin>& assignment,
121122
slot_index++;
122123
continue;
123124
}
124-
if (hungarian_matrix_[row][col] == hungarian_fail) {
125+
if (hungarian_matrix_[row][col] == hungarian_fail_) {
125126
logger_->warn(utl::PPL,
126127
33,
127128
"I/O pin {} cannot be placed in the specified region. "
@@ -238,19 +239,20 @@ void HungarianMatching::createMatrixForGroups()
238239
int slot_index = 0;
239240
for (int i : valid_starting_slots_) {
240241
int groupIndex = 0;
241-
Point newPos = slots_[i].pos;
242+
const Point& slot_pos = slots_[i].pos;
242243

243244
hungarian_matrix_[slot_index].resize(num_pin_groups_,
244245
std::numeric_limits<int>::max());
245246
for (const auto& [pins, order] : pin_groups_) {
246247
int group_hpwl = 0;
247248
for (const int io_idx : pins) {
248-
int pin_hpwl = netlist_->computeIONetHPWL(io_idx, newPos);
249-
if (pin_hpwl == hungarian_fail) {
250-
group_hpwl = hungarian_fail;
249+
IOPin& io_pin = netlist_->getIoPin(io_idx);
250+
int pin_hpwl = netlist_->computeIONetHPWL(io_idx, slot_pos);
251+
if (pin_hpwl == hungarian_fail_) {
252+
group_hpwl = hungarian_fail_;
251253
break;
252254
}
253-
group_hpwl += pin_hpwl;
255+
group_hpwl += pin_hpwl + getMirroredPinCost(io_pin, slot_pos);
254256
}
255257
if (pins.size() > group_slot_capacity[slot_index]) {
256258
group_hpwl = std::numeric_limits<int>::max();
@@ -356,6 +358,17 @@ bool HungarianMatching::groupHasMirroredPin(const std::vector<int>& group)
356358
return false;
357359
}
358360

361+
int HungarianMatching::getMirroredPinCost(IOPin& io_pin,
362+
const odb::Point& position)
363+
{
364+
if (io_pin.getBTerm()->hasMirroredBTerm()) {
365+
odb::Point mirrored_pos = core_->getMirroredPosition(position);
366+
return netlist_->computeIONetHPWL(io_pin.getMirrorPinIdx(), mirrored_pos);
367+
}
368+
369+
return 0;
370+
}
371+
359372
Edge HungarianMatching::getMirroredEdge(const Edge& edge)
360373
{
361374
Edge mirrored_edge = Edge::invalid;

src/ppl/src/HungarianMatching.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class HungarianMatching
9393
int non_blocked_slots_;
9494
int group_slots_;
9595
Edge edge_;
96-
const int hungarian_fail = std::numeric_limits<int>::max();
96+
const int hungarian_fail_ = std::numeric_limits<int>::max();
9797
Logger* logger_;
9898
odb::dbDatabase* db_;
9999

@@ -102,6 +102,7 @@ class HungarianMatching
102102
void assignMirroredPins(IOPin& io_pin, std::vector<IOPin>& assignment);
103103
int getSlotIdxByPosition(const odb::Point& position, int layer) const;
104104
bool groupHasMirroredPin(const std::vector<int>& group);
105+
int getMirroredPinCost(IOPin& io_pin, const odb::Point& position);
105106
Edge getMirroredEdge(const Edge& edge);
106107
};
107108

src/ppl/src/IOPlacer.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,18 +1373,19 @@ int IOPlacer::assignGroupToSection(const std::vector<int>& io_group,
13731373
bool group_assigned = false;
13741374
int total_pins_assigned = 0;
13751375

1376-
IOPin& io_pin = net->getIoPin(io_group[0]);
1376+
IOPin& first_pin = net->getIoPin(io_group[0]);
13771377

1378-
if (!io_pin.isAssignedToSection() && !io_pin.inFallback()) {
1378+
if (!first_pin.isAssignedToSection() && !first_pin.inFallback()) {
13791379
std::vector<int64_t> dst(sections.size(), 0);
13801380
for (int i = 0; i < sections.size(); i++) {
13811381
for (int pin_idx : io_group) {
1382+
IOPin& pin = net->getIoPin(pin_idx);
13821383
int pin_hpwl = net->computeIONetHPWL(pin_idx, sections[i].pos);
13831384
if (pin_hpwl == std::numeric_limits<int>::max()) {
13841385
dst[i] = pin_hpwl;
13851386
break;
13861387
}
1387-
dst[i] += pin_hpwl;
1388+
dst[i] += pin_hpwl + getMirroredPinCost(pin, sections[i].pos);
13881389
}
13891390
}
13901391

@@ -1417,7 +1418,7 @@ int IOPlacer::assignGroupToSection(const std::vector<int>& io_group,
14171418
sections[i].used_slots++;
14181419
io_pin.assignToSection();
14191420
if (io_pin.getBTerm()->hasMirroredBTerm()) {
1420-
assignMirroredPin(io_pin);
1421+
assignMirroredPinToSection(io_pin);
14211422
}
14221423
}
14231424
total_pins_assigned += group_size;
@@ -1529,7 +1530,8 @@ bool IOPlacer::assignPinToSection(IOPin& io_pin,
15291530
&& !io_pin.inFallback()) {
15301531
std::vector<int> dst(sections.size());
15311532
for (int i = 0; i < sections.size(); i++) {
1532-
dst[i] = netlist_->computeIONetHPWL(idx, sections[i].pos);
1533+
dst[i] = netlist_->computeIONetHPWL(idx, sections[i].pos)
1534+
+ getMirroredPinCost(io_pin, sections[i].pos);
15331535
}
15341536
for (auto i : sortIndexes(dst)) {
15351537
if (sections[i].used_slots < sections[i].num_slots) {
@@ -1539,7 +1541,7 @@ bool IOPlacer::assignPinToSection(IOPin& io_pin,
15391541
io_pin.assignToSection();
15401542

15411543
if (io_pin.getBTerm()->hasMirroredBTerm()) {
1542-
assignMirroredPin(io_pin);
1544+
assignMirroredPinToSection(io_pin);
15431545
}
15441546
break;
15451547
}
@@ -1549,16 +1551,25 @@ bool IOPlacer::assignPinToSection(IOPin& io_pin,
15491551
return pin_assigned;
15501552
}
15511553

1552-
void IOPlacer::assignMirroredPin(IOPin& io_pin)
1554+
void IOPlacer::assignMirroredPinToSection(IOPin& io_pin)
15531555
{
15541556
odb::dbBTerm* mirrored_term = io_pin.getBTerm()->getMirroredBTerm();
15551557
int mirrored_pin_idx = netlist_->getIoPinIdx(mirrored_term);
15561558
IOPin& mirrored_pin = netlist_->getIoPin(mirrored_pin_idx);
15571559
// Mark mirrored pin as assigned to section to prevent assigning it to
1558-
// another section that is not aligned with his pair
1560+
// another section that is not aligned with its pair
15591561
mirrored_pin.assignToSection();
15601562
}
15611563

1564+
int IOPlacer::getMirroredPinCost(IOPin& io_pin, const odb::Point& position)
1565+
{
1566+
if (io_pin.getBTerm()->hasMirroredBTerm()) {
1567+
odb::Point mirrored_pos = core_->getMirroredPosition(position);
1568+
return netlist_->computeIONetHPWL(io_pin.getMirrorPinIdx(), mirrored_pos);
1569+
}
1570+
return 0;
1571+
}
1572+
15621573
void IOPlacer::printConfig(bool annealing)
15631574
{
15641575
int available_slots = 0;

src/ppl/test/add_constraint10.defok

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -122,23 +122,23 @@ PINS 54 ;
122122
- req_msg[0] + NET req_msg[0] + DIRECTION INPUT + USE SIGNAL
123123
+ PORT
124124
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
125-
+ PLACED ( 21850 201530 ) N ;
125+
+ PLACED ( 22610 201530 ) N ;
126126
- req_msg[10] + NET req_msg[10] + DIRECTION INPUT + USE SIGNAL
127127
+ PORT
128128
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
129-
+ PLACED ( 34770 201530 ) N ;
129+
+ PLACED ( 34390 201530 ) N ;
130130
- req_msg[11] + NET req_msg[11] + DIRECTION INPUT + USE SIGNAL
131131
+ PORT
132132
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
133-
+ PLACED ( 34390 201530 ) N ;
133+
+ PLACED ( 34010 201530 ) N ;
134134
- req_msg[12] + NET req_msg[12] + DIRECTION INPUT + USE SIGNAL
135135
+ PORT
136136
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
137-
+ PLACED ( 35150 201530 ) N ;
137+
+ PLACED ( 34770 201530 ) N ;
138138
- req_msg[13] + NET req_msg[13] + DIRECTION INPUT + USE SIGNAL
139139
+ PORT
140140
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
141-
+ PLACED ( 33630 201530 ) N ;
141+
+ PLACED ( 33250 201530 ) N ;
142142
- req_msg[14] + NET req_msg[14] + DIRECTION INPUT + USE SIGNAL
143143
+ PORT
144144
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
@@ -166,7 +166,7 @@ PINS 54 ;
166166
- req_msg[1] + NET req_msg[1] + DIRECTION INPUT + USE SIGNAL
167167
+ PORT
168168
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
169-
+ PLACED ( 22610 201530 ) N ;
169+
+ PLACED ( 22230 201530 ) N ;
170170
- req_msg[20] + NET req_msg[20] + DIRECTION INPUT + USE SIGNAL
171171
+ PORT
172172
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
@@ -210,7 +210,7 @@ PINS 54 ;
210210
- req_msg[2] + NET req_msg[2] + DIRECTION INPUT + USE SIGNAL
211211
+ PORT
212212
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
213-
+ PLACED ( 22230 70 ) N ;
213+
+ PLACED ( 35530 70 ) N ;
214214
- req_msg[30] + NET req_msg[30] + DIRECTION INPUT + USE SIGNAL
215215
+ PORT
216216
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
@@ -250,23 +250,23 @@ PINS 54 ;
250250
- req_rdy + NET req_rdy + DIRECTION OUTPUT + USE SIGNAL
251251
+ PORT
252252
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
253-
+ PLACED ( 21470 201530 ) N ;
253+
+ PLACED ( 21850 201530 ) N ;
254254
- req_val + NET req_val + DIRECTION INPUT + USE SIGNAL
255255
+ PORT
256256
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
257-
+ PLACED ( 35530 201530 ) N ;
257+
+ PLACED ( 35150 201530 ) N ;
258258
- reset + NET reset + DIRECTION INPUT + USE SIGNAL
259259
+ PORT
260260
+ LAYER metal3 ( -70 -70 ) ( 70 70 )
261261
+ PLACED ( 70 104860 ) N ;
262262
- resp_msg[0] + NET resp_msg[0] + DIRECTION OUTPUT + USE SIGNAL
263263
+ PORT
264264
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
265-
+ PLACED ( 21850 70 ) N ;
265+
+ PLACED ( 22610 70 ) N ;
266266
- resp_msg[10] + NET resp_msg[10] + DIRECTION OUTPUT + USE SIGNAL
267267
+ PORT
268268
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
269-
+ PLACED ( 21470 70 ) N ;
269+
+ PLACED ( 21850 70 ) N ;
270270
- resp_msg[11] + NET resp_msg[11] + DIRECTION OUTPUT + USE SIGNAL
271271
+ PORT
272272
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
@@ -282,19 +282,19 @@ PINS 54 ;
282282
- resp_msg[14] + NET resp_msg[14] + DIRECTION OUTPUT + USE SIGNAL
283283
+ PORT
284284
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
285-
+ PLACED ( 34010 201530 ) N ;
285+
+ PLACED ( 33630 201530 ) N ;
286286
- resp_msg[15] + NET resp_msg[15] + DIRECTION OUTPUT + USE SIGNAL
287287
+ PORT
288288
+ LAYER metal3 ( -70 -70 ) ( 70 70 )
289289
+ PLACED ( 70 26460 ) N ;
290290
- resp_msg[1] + NET resp_msg[1] + DIRECTION OUTPUT + USE SIGNAL
291291
+ PORT
292292
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
293-
+ PLACED ( 22610 70 ) N ;
293+
+ PLACED ( 22230 70 ) N ;
294294
- resp_msg[2] + NET resp_msg[2] + DIRECTION OUTPUT + USE SIGNAL
295295
+ PORT
296296
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
297-
+ PLACED ( 22230 201530 ) N ;
297+
+ PLACED ( 35530 201530 ) N ;
298298
- resp_msg[3] + NET resp_msg[3] + DIRECTION OUTPUT + USE SIGNAL
299299
+ PORT
300300
+ LAYER metal2 ( -70 -70 ) ( 70 70 )

src/ppl/test/add_constraint10.ok

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ Found 0 macro blocks.
1212
[INFO PPL-0004] Number of I/O w/o sink 0
1313
[INFO PPL-0005] Slots per section 200
1414
[INFO PPL-0008] Successfully assigned pins to sections.
15-
[INFO PPL-0012] I/O nets HPWL: 2264.07 um.
15+
[INFO PPL-0012] I/O nets HPWL: 2264.48 um.
1616
No differences found.

src/ppl/test/add_constraint11.defok

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,15 @@ PINS 54 ;
118118
- clk + NET clk + DIRECTION INPUT + USE SIGNAL
119119
+ PORT
120120
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
121-
+ PLACED ( 25270 70 ) N ;
121+
+ PLACED ( 76950 70 ) N ;
122122
- req_msg[0] + NET req_msg[0] + DIRECTION INPUT + USE SIGNAL
123123
+ PORT
124124
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
125-
+ PLACED ( 24510 201530 ) N ;
125+
+ PLACED ( 76190 201530 ) N ;
126126
- req_msg[10] + NET req_msg[10] + DIRECTION INPUT + USE SIGNAL
127127
+ PORT
128128
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
129-
+ PLACED ( 26410 201530 ) N ;
129+
+ PLACED ( 78090 201530 ) N ;
130130
- req_msg[11] + NET req_msg[11] + DIRECTION INPUT + USE SIGNAL
131131
+ PORT
132132
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
@@ -146,7 +146,7 @@ PINS 54 ;
146146
- req_msg[15] + NET req_msg[15] + DIRECTION INPUT + USE SIGNAL
147147
+ PORT
148148
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
149-
+ PLACED ( 25270 201530 ) N ;
149+
+ PLACED ( 25650 201530 ) N ;
150150
- req_msg[16] + NET req_msg[16] + DIRECTION INPUT + USE SIGNAL
151151
+ PORT
152152
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
@@ -166,7 +166,7 @@ PINS 54 ;
166166
- req_msg[1] + NET req_msg[1] + DIRECTION INPUT + USE SIGNAL
167167
+ PORT
168168
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
169-
+ PLACED ( 24890 201530 ) N ;
169+
+ PLACED ( 76570 201530 ) N ;
170170
- req_msg[20] + NET req_msg[20] + DIRECTION INPUT + USE SIGNAL
171171
+ PORT
172172
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
@@ -250,31 +250,31 @@ PINS 54 ;
250250
- req_rdy + NET req_rdy + DIRECTION OUTPUT + USE SIGNAL
251251
+ PORT
252252
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
253-
+ PLACED ( 26030 201530 ) N ;
253+
+ PLACED ( 77710 201530 ) N ;
254254
- req_val + NET req_val + DIRECTION INPUT + USE SIGNAL
255255
+ PORT
256256
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
257-
+ PLACED ( 25650 201530 ) N ;
257+
+ PLACED ( 77330 201530 ) N ;
258258
- reset + NET reset + DIRECTION INPUT + USE SIGNAL
259259
+ PORT
260260
+ LAYER metal3 ( -70 -70 ) ( 70 70 )
261261
+ PLACED ( 70 104860 ) N ;
262262
- resp_msg[0] + NET resp_msg[0] + DIRECTION OUTPUT + USE SIGNAL
263263
+ PORT
264264
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
265-
+ PLACED ( 24510 70 ) N ;
265+
+ PLACED ( 76190 70 ) N ;
266266
- resp_msg[10] + NET resp_msg[10] + DIRECTION OUTPUT + USE SIGNAL
267267
+ PORT
268268
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
269-
+ PLACED ( 26410 70 ) N ;
269+
+ PLACED ( 78090 70 ) N ;
270270
- resp_msg[11] + NET resp_msg[11] + DIRECTION OUTPUT + USE SIGNAL
271271
+ PORT
272272
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
273-
+ PLACED ( 26790 70 ) N ;
273+
+ PLACED ( 78470 70 ) N ;
274274
- resp_msg[12] + NET resp_msg[12] + DIRECTION OUTPUT + USE SIGNAL
275275
+ PORT
276276
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
277-
+ PLACED ( 27170 70 ) N ;
277+
+ PLACED ( 78850 70 ) N ;
278278
- resp_msg[13] + NET resp_msg[13] + DIRECTION OUTPUT + USE SIGNAL
279279
+ PORT
280280
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
@@ -290,7 +290,7 @@ PINS 54 ;
290290
- resp_msg[1] + NET resp_msg[1] + DIRECTION OUTPUT + USE SIGNAL
291291
+ PORT
292292
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
293-
+ PLACED ( 24890 70 ) N ;
293+
+ PLACED ( 76570 70 ) N ;
294294
- resp_msg[2] + NET resp_msg[2] + DIRECTION OUTPUT + USE SIGNAL
295295
+ PORT
296296
+ LAYER metal3 ( -70 -70 ) ( 70 70 )
@@ -326,11 +326,11 @@ PINS 54 ;
326326
- resp_rdy + NET resp_rdy + DIRECTION INPUT + USE SIGNAL
327327
+ PORT
328328
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
329-
+ PLACED ( 26030 70 ) N ;
329+
+ PLACED ( 77710 70 ) N ;
330330
- resp_val + NET resp_val + DIRECTION OUTPUT + USE SIGNAL
331331
+ PORT
332332
+ LAYER metal2 ( -70 -70 ) ( 70 70 )
333-
+ PLACED ( 25650 70 ) N ;
333+
+ PLACED ( 77330 70 ) N ;
334334
END PINS
335335
NETS 54 ;
336336
- clk ( PIN clk ) ( _858_ CK ) ( _859_ CK ) ( _860_ CK ) ( _861_ CK ) ( _862_ CK ) ( _863_ CK )

src/ppl/test/add_constraint11.ok

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ Found 0 macro blocks.
1313
[INFO PPL-0006] Number of I/O Groups 1
1414
[INFO PPL-0005] Slots per section 200
1515
[INFO PPL-0008] Successfully assigned pins to sections.
16-
[INFO PPL-0012] I/O nets HPWL: 1684.43 um.
16+
[INFO PPL-0012] I/O nets HPWL: 1620.93 um.
1717
No differences found.

0 commit comments

Comments
 (0)