Skip to content

Commit 05c6828

Browse files
litghostacomodi
authored andcommitted
Adjust connection_box verification logic to handle different definition order.
Signed-off-by: Keith Rothman <[email protected]>
1 parent 6c1419c commit 05c6828

File tree

3 files changed

+31
-11
lines changed

3 files changed

+31
-11
lines changed

vpr/src/route/connection_box.cpp

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ bool ConnectionBoxes::find_connection_box(int inode,
5353
// Clear IPIN map and set connection box grid size and box ids.
5454
void ConnectionBoxes::reset_boxes(std::pair<size_t, size_t> size,
5555
const std::vector<ConnectionBox> boxes) {
56-
clear();
57-
5856
size_ = size;
5957
boxes_ = boxes;
6058
}
@@ -75,15 +73,34 @@ void ConnectionBoxes::clear() {
7573
sink_to_ipin_.clear();
7674
}
7775

78-
void ConnectionBoxes::add_connection_box(int inode, ConnectionBoxId box_id, std::pair<size_t, size_t> box_location, float site_pin_delay) {
79-
// Ensure that box location is in bounds
80-
VTR_ASSERT(box_location.first < size_.first);
81-
VTR_ASSERT(box_location.second < size_.second);
76+
void ConnectionBoxes::verify_connection_boxes() {
77+
if (size_.first == 0 && size_.second == 0) {
78+
return;
79+
}
80+
81+
for (const auto& loc : canonical_loc_map_) {
82+
VTR_ASSERT(loc.first < size_.first);
83+
VTR_ASSERT(loc.second < size_.second);
84+
}
85+
86+
for (const auto& conn_box_loc : ipin_map_) {
87+
if (conn_box_loc.box_id == ConnectionBoxId::INVALID()) {
88+
continue;
89+
}
90+
const auto& box_location = conn_box_loc.box_location;
91+
const auto& box_id = conn_box_loc.box_id;
92+
93+
// Ensure that box location is in bounds
94+
VTR_ASSERT(box_location.first < size_.first);
95+
VTR_ASSERT(box_location.second < size_.second);
8296

83-
// Bounds check box_id
84-
VTR_ASSERT(bool(box_id));
85-
VTR_ASSERT(size_t(box_id) < boxes_.size());
97+
// Bounds check box_id
98+
VTR_ASSERT(bool(box_id));
99+
VTR_ASSERT(size_t(box_id) < boxes_.size());
100+
}
101+
}
86102

103+
void ConnectionBoxes::add_connection_box(int inode, ConnectionBoxId box_id, std::pair<size_t, size_t> box_location, float site_pin_delay) {
87104
// Make sure sink map will not be invalidated upon insertion.
88105
VTR_ASSERT(sink_to_ipin_.size() == 0);
89106

@@ -94,8 +111,6 @@ void ConnectionBoxes::add_connection_box(int inode, ConnectionBoxId box_id, std:
94111
}
95112

96113
void ConnectionBoxes::add_canonical_loc(int inode, std::pair<size_t, size_t> loc) {
97-
VTR_ASSERT(loc.first < size_.first);
98-
VTR_ASSERT(loc.second < size_.second);
99114
if (inode >= (ssize_t)(canonical_loc_map_.size())) {
100115
canonical_loc_map_.resize(inode + 1);
101116
}
@@ -117,6 +132,7 @@ const std::pair<size_t, size_t>* ConnectionBoxes::find_canonical_loc(int inode)
117132

118133
void ConnectionBoxes::create_sink_back_ref() {
119134
const auto& device_ctx = g_vpr_ctx.device();
135+
verify_connection_boxes();
120136

121137
sink_to_ipin_.resize(device_ctx.rr_nodes.size(), {{0, 0, 0, 0}, 0});
122138

vpr/src/route/connection_box.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ class ConnectionBoxes {
6363
void add_connection_box(int inode, ConnectionBoxId box_id, std::pair<size_t, size_t> box_location, float site_pin_delay);
6464
void add_canonical_loc(int inode, std::pair<size_t, size_t> loc);
6565

66+
// Verify that all connection box annotations match defined connection boxes.
67+
void verify_connection_boxes();
68+
6669
// Create map from SINK's back to IPIN's
6770
//
6871
// This must be called after all connection boxes have been added.

vpr/src/route/rr_graph_uxsdcxx_serializer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
303303
// report_error_in should be invoked if RrGraphSerializer encounters
304304
// an error during the read.
305305
report_error_ = report_error_in;
306+
connection_boxes_->clear();
306307
}
307308
void start_write() final {}
308309
void finish_write() final {}

0 commit comments

Comments
 (0)