Skip to content

Commit 2abe4b4

Browse files
authored
Merge pull request #2726 from eder-matheus/ppl_coverity
ppl: fix coverity issue
2 parents 5e78e00 + e485c11 commit 2abe4b4

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

src/ppl/src/HungarianMatching.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ HungarianMatching::HungarianMatching(Section& section,
4343
Netlist* netlist,
4444
Core* core,
4545
std::vector<Slot>& slots,
46-
Logger* logger)
46+
Logger* logger,
47+
odb::dbDatabase* db)
4748
: netlist_(netlist),
4849
core_(core),
4950
pin_indices_(section.pin_indices),
5051
pin_groups_(section.pin_groups),
51-
slots_(slots)
52+
slots_(slots),
53+
db_(db)
5254
{
5355
num_io_pins_ = section.pin_indices.size();
5456
num_pin_groups_ = netlist_->numIOGroups();
@@ -148,7 +150,19 @@ void HungarianMatching::getFinalAssignment(std::vector<IOPin>& assigment,
148150
mirrored_pin.setLayer(slots_[slot_index].layer);
149151
mirrored_pin.setPlaced();
150152
assigment.push_back(mirrored_pin);
151-
slot_index = getSlotIdxByPosition(mirrored_pos);
153+
slot_index
154+
= getSlotIdxByPosition(mirrored_pos, mirrored_pin.getLayer());
155+
if (slot_index < 0) {
156+
odb::dbTechLayer* layer
157+
= db_->getTech()->findRoutingLayer(mirrored_pin.getLayer());
158+
logger_->error(utl::PPL,
159+
82,
160+
"Mirrored position ({}, {}) at layer {} is not a "
161+
"valid position for pin placement.",
162+
mirrored_pos.getX(),
163+
mirrored_pos.getY(),
164+
layer->getName());
165+
}
152166
slots_[slot_index].used = true;
153167
}
154168
break;
@@ -266,11 +280,12 @@ void HungarianMatching::getAssignmentForGroups(std::vector<IOPin>& assigment)
266280
assignment_.clear();
267281
}
268282

269-
int HungarianMatching::getSlotIdxByPosition(const odb::Point& position) const
283+
int HungarianMatching::getSlotIdxByPosition(const odb::Point& position,
284+
int layer) const
270285
{
271286
int slot_idx = -1;
272287
for (int i = 0; i < slots_.size(); i++) {
273-
if (slots_[i].pos == position) {
288+
if (slots_[i].pos == position && slots_[i].layer == layer) {
274289
slot_idx = i;
275290
break;
276291
}

src/ppl/src/HungarianMatching.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ class HungarianMatching
6565
Netlist* netlist,
6666
Core* core,
6767
std::vector<Slot>& slots,
68-
Logger* logger);
68+
Logger* logger,
69+
odb::dbDatabase* db);
6970
virtual ~HungarianMatching() = default;
7071
void findAssignment();
7172
void findAssignmentForGroups();
@@ -94,10 +95,11 @@ class HungarianMatching
9495
Edge edge_;
9596
const int hungarian_fail = std::numeric_limits<int>::max();
9697
Logger* logger_;
98+
odb::dbDatabase* db_;
9799

98100
void createMatrix();
99101
void createMatrixForGroups();
100-
int getSlotIdxByPosition(const odb::Point& position) const;
102+
int getSlotIdxByPosition(const odb::Point& position, int layer) const;
101103
};
102104

103105
} // namespace ppl

src/ppl/src/IOPlacer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,14 +1209,16 @@ void IOPlacer::findPinAssignment(std::vector<Section>& sections)
12091209
netlist_io_pins_.get(),
12101210
core_.get(),
12111211
top_layer_slots_,
1212-
logger_);
1212+
logger_,
1213+
db_);
12131214
hg_vec.push_back(hg);
12141215
} else {
12151216
HungarianMatching hg(sections[idx],
12161217
netlist_io_pins_.get(),
12171218
core_.get(),
12181219
slots_,
1219-
logger_);
1220+
logger_,
1221+
db_);
12201222
hg_vec.push_back(hg);
12211223
}
12221224
}

0 commit comments

Comments
 (0)