@@ -74,17 +74,18 @@ RRNodeId RRSpatialLookup::find_node(int x,
74
74
return RRNodeId (rr_node_indices_[type][node_x][node_y][node_side][ptc]);
75
75
}
76
76
77
- std::vector<RRNodeId> RRSpatialLookup::find_channel_nodes (int x,
78
- int y,
79
- t_rr_type type) const {
77
+ std::vector<RRNodeId> RRSpatialLookup::find_nodes (int x,
78
+ int y,
79
+ t_rr_type type,
80
+ e_side side) const {
80
81
/* TODO: The implementation of this API should be worked
81
82
* when rr_node_indices adapts RRNodeId natively!
82
83
*/
83
- std::vector<RRNodeId> channel_nodes ;
84
+ std::vector<RRNodeId> nodes ;
84
85
85
86
/* Pre-check: the x, y, type are valid! Otherwise, return an empty vector */
86
- if (( x < 0 || y < 0 ) && (type == CHANX || type == CHANY) ) {
87
- return channel_nodes ;
87
+ if (x < 0 || y < 0 ) {
88
+ return nodes ;
88
89
}
89
90
90
91
/* Currently need to swap x and y for CHANX because of chan, seg convention
@@ -106,76 +107,44 @@ std::vector<RRNodeId> RRSpatialLookup::find_channel_nodes(int x,
106
107
* - Return an empty list if any out-of-range is detected
107
108
*/
108
109
if (size_t (type) >= rr_node_indices_.size ()) {
109
- return channel_nodes ;
110
+ return nodes ;
110
111
}
111
112
112
113
if (node_x >= rr_node_indices_[type].dim_size (0 )) {
113
- return channel_nodes ;
114
+ return nodes ;
114
115
}
115
116
116
117
if (node_y >= rr_node_indices_[type].dim_size (1 )) {
117
- return channel_nodes ;
118
+ return nodes ;
118
119
}
119
120
120
- /* By default, we always added the channel nodes to the TOP side (to save memory) */
121
- e_side node_side = TOP;
122
- if (node_side >= rr_node_indices_[type].dim_size (2 )) {
123
- return channel_nodes;
121
+ if (side >= rr_node_indices_[type].dim_size (2 )) {
122
+ return nodes;
124
123
}
125
124
126
- for (const auto & node : rr_node_indices_[type][node_x][node_y][node_side ]) {
125
+ for (const auto & node : rr_node_indices_[type][node_x][node_y][side ]) {
127
126
if (RRNodeId (node)) {
128
- channel_nodes .push_back (RRNodeId (node));
127
+ nodes .push_back (RRNodeId (node));
129
128
}
130
129
}
131
130
132
- return channel_nodes ;
131
+ return nodes ;
133
132
}
134
133
135
- std::vector<RRNodeId> RRSpatialLookup::find_sink_nodes (int x,
136
- int y) const {
137
- /* TODO: The implementation of this API should be worked
138
- * when rr_node_indices adapts RRNodeId natively!
139
- */
140
- std::vector<RRNodeId> sink_nodes;
141
-
142
- /* Pre-check: the x, y, type are valid! Otherwise, return an empty vector */
143
- if (x < 0 || y < 0 ) {
144
- return sink_nodes;
145
- }
146
-
147
- VTR_ASSERT_SAFE (3 == rr_node_indices_[SINK].ndims ());
148
-
149
- /* Sanity check to ensure the x, y, side are in range
150
- * - Return a list of valid ids by searching in look-up when all the parameters are in range
151
- * - Return an empty list if any out-of-range is detected
152
- */
153
- if (size_t (SINK) >= rr_node_indices_.size ()) {
154
- return sink_nodes;
155
- }
156
-
157
- if (size_t (x) >= rr_node_indices_[SINK].dim_size (0 )) {
158
- return sink_nodes;
159
- }
160
-
161
- if (size_t (y) >= rr_node_indices_[SINK].dim_size (1 )) {
162
- return sink_nodes;
163
- }
164
-
165
- /* By default, we always added the sink nodes to the TOP side (to save memory) */
166
- e_side node_side = TOP;
167
- if (node_side >= rr_node_indices_[SINK].dim_size (2 )) {
168
- return sink_nodes;
134
+ std::vector<RRNodeId> RRSpatialLookup::find_channel_nodes (int x,
135
+ int y,
136
+ t_rr_type type) const {
137
+ /* Pre-check: node type should be routing tracks! */
138
+ if (type != CHANX && type != CHANY) {
139
+ return std::vector<RRNodeId>();
169
140
}
170
141
171
- /* Only insert valid ids in the returned vector */
172
- for (const auto & node : rr_node_indices_[SINK][x][y][node_side]) {
173
- if (RRNodeId (node)) {
174
- sink_nodes.push_back (RRNodeId (node));
175
- }
176
- }
142
+ return find_nodes (x, y, type);
143
+ }
177
144
178
- return sink_nodes;
145
+ std::vector<RRNodeId> RRSpatialLookup::find_sink_nodes (int x,
146
+ int y) const {
147
+ return find_nodes (x, y, SINK);
179
148
}
180
149
181
150
std::vector<RRNodeId> RRSpatialLookup::find_nodes_at_all_sides (int x,
0 commit comments