Skip to content

Commit 5f41a6e

Browse files
committed
change pin_done to a set
1 parent c93941d commit 5f41a6e

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

vpr/src/route/check_route.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/******************** Subroutines local to this module **********************/
2121
static void check_node_and_range(int inode, enum e_route_type route_type);
2222
static void check_source(int inode, ClusterNetId net_id);
23-
static void check_sink(int inode, ClusterNetId net_id, bool* pin_done);
23+
static void check_sink(int inode, ClusterNetId net_id, std::set<vtr::StrongId<cluster_pin_id_tag>>& pin_done);
2424
static void check_switch(t_trace* tptr, int num_switch);
2525
static bool check_adjacent(int from_node, int to_node);
2626
static int chanx_chany_adjacent(int chanx_node, int chany_node);
@@ -47,7 +47,6 @@ void check_route(enum e_route_type route_type, e_check_route_option check_route_
4747
}
4848

4949
int max_pins, inode, prev_node;
50-
unsigned int ipin;
5150
bool valid, connects;
5251
t_trace* tptr;
5352

@@ -80,15 +79,13 @@ void check_route(enum e_route_type route_type, e_check_route_option check_route_
8079
for (auto net_id : cluster_ctx.clb_nlist.nets())
8180
max_pins = std::max(max_pins, (int)cluster_ctx.clb_nlist.net_pins(net_id).size());
8281

83-
auto pin_done = std::make_unique<bool[]>(max_pins);
82+
std::set<vtr::StrongId<cluster_pin_id_tag>> pin_done;
8483

8584
/* Now check that all nets are indeed connected. */
8685
for (auto net_id : cluster_ctx.clb_nlist.nets()) {
8786
if (cluster_ctx.clb_nlist.net_is_ignored(net_id) || cluster_ctx.clb_nlist.net_sinks(net_id).size() == 0) /* Skip ignored nets. */
8887
continue;
8988

90-
std::fill_n(pin_done.get(), cluster_ctx.clb_nlist.net_pins(net_id).size(), false);
91-
9289
/* Check the SOURCE of the net. */
9390
tptr = route_ctx.trace[net_id].head;
9491
if (tptr == nullptr) {
@@ -102,7 +99,8 @@ void check_route(enum e_route_type route_type, e_check_route_option check_route_
10299
connected_to_route[inode] = true; /* Mark as in path. */
103100

104101
check_source(inode, net_id);
105-
pin_done[0] = true;
102+
auto first_net_id = cluster_ctx.clb_nlist.net_pins(net_id).begin();
103+
pin_done.insert(*first_net_id); /* Insert the source */
106104

107105
prev_node = inode;
108106
int prev_switch = tptr->iswitch;
@@ -135,7 +133,7 @@ void check_route(enum e_route_type route_type, e_check_route_option check_route_
135133
connected_to_route[inode] = true; /* Mark as in path. */
136134

137135
if (device_ctx.rr_nodes[inode].type() == SINK) {
138-
check_sink(inode, net_id, pin_done.get());
136+
check_sink(inode, net_id, pin_done);
139137
num_sinks += 1;
140138
}
141139

@@ -152,10 +150,11 @@ void check_route(enum e_route_type route_type, e_check_route_option check_route_
152150
num_sinks, cluster_ctx.clb_nlist.net_sinks(net_id).size());
153151
}
154152

155-
for (ipin = 0; ipin < cluster_ctx.clb_nlist.net_pins(net_id).size(); ipin++) {
156-
if (pin_done[ipin] == false) {
153+
for (auto pin_id : cluster_ctx.clb_nlist.net_pins(net_id)) {
154+
if (pin_done.find(pin_id) == pin_done.end()) {
155+
int net_pin_index = tile_pin_index(pin_id);
157156
VPR_FATAL_ERROR(VPR_ERROR_ROUTE,
158-
"in check_route: net %zu does not connect to pin %d.\n", size_t(net_id), ipin);
157+
"in check_route: net %zu does not connect to pin %d.\n", size_t(net_id), net_pin_index);
159158
}
160159
}
161160

@@ -177,7 +176,7 @@ void check_route(enum e_route_type route_type, e_check_route_option check_route_
177176

178177
/* Checks that this SINK node is one of the terminals of inet, and marks *
179178
* the appropriate pin as being reached. */
180-
static void check_sink(int inode, ClusterNetId net_id, bool* pin_done) {
179+
static void check_sink(int inode, ClusterNetId net_id, std::set<vtr::StrongId<cluster_pin_id_tag>>& pin_done) {
181180
auto& device_ctx = g_vpr_ctx.device();
182181
auto& cluster_ctx = g_vpr_ctx.clustering();
183182
auto& place_ctx = g_vpr_ctx.placement();
@@ -191,22 +190,20 @@ static void check_sink(int inode, ClusterNetId net_id, bool* pin_done) {
191190
int ifound = 0;
192191

193192
for (auto bnum : place_ctx.grid_blocks[i][j].blocks) {
194-
unsigned int ipin = 1;
195193
for (auto pin_id : cluster_ctx.clb_nlist.net_sinks(net_id)) {
196194
if (cluster_ctx.clb_nlist.pin_block(pin_id) == bnum) {
197195
int pin_index = tile_pin_index(pin_id);
198196
int iclass = type->pin_class[pin_index];
199197
if (iclass == ptc_num) {
200198
/* Could connect to same pin class on the same clb more than once. Only *
201199
* update pin_done for a pin that hasn't been reached yet. */
202-
if (pin_done[ipin] == false) {
200+
if (pin_done.find(pin_id) == pin_done.end()) {
203201
ifound++;
204-
pin_done[ipin] = true;
202+
pin_done.insert(pin_id);
205203
break;
206204
}
207205
}
208206
}
209-
ipin++;
210207
}
211208
}
212209

0 commit comments

Comments
 (0)