Skip to content

Commit 73edb0f

Browse files
committed
[vpr][route][crr] add is_valid to segmentinfo
1 parent 4ed0868 commit 73edb0f

File tree

2 files changed

+38
-29
lines changed

2 files changed

+38
-29
lines changed

vpr/src/route/rr_graph_generation/tileable_rr_graph/crr_generator/crr_connection_builder.cpp

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -96,38 +96,41 @@ void CRRConnectionBuilder::build_connections_for_location(size_t x,
9696
auto source_it = source_nodes.find(row_idx);
9797
auto sink_it = sink_nodes.find(col_idx);
9898

99-
if (source_it != source_nodes.end() && sink_it != sink_nodes.end()) {
100-
RRNodeId source_node = source_it->second;
101-
e_rr_type source_node_type = rr_graph_.node_type(source_node);
102-
RRNodeId sink_node = sink_it->second;
103-
e_rr_type sink_node_type = rr_graph_.node_type(sink_node);
104-
std::string sw_template_id = sw_block_file_name + "_" + std::to_string(row_idx) + "_" + std::to_string(col_idx);
105-
// If the source node is an IPIN, then it should be considered as
106-
// a sink of the connection.
107-
if (source_node_type == e_rr_type::IPIN) {
108-
int delay_ps = get_connection_delay_ps(cell.as_string(),
109-
rr_node_typename[source_node_type],
110-
sink_node,
111-
source_node);
112-
113-
tile_connections.emplace_back(source_node, sink_node, delay_ps, sw_template_id);
114-
} else {
115-
int segment_length = -1;
116-
if (sink_node_type == e_rr_type::CHANX || sink_node_type == e_rr_type::CHANY) {
117-
segment_length = rr_graph_.node_length(sink_node);
118-
}
119-
int delay_ps = get_connection_delay_ps(cell.as_string(),
120-
rr_node_typename[sink_node_type],
121-
source_node,
122-
sink_node,
123-
segment_length);
124-
125-
tile_connections.emplace_back(sink_node, source_node, delay_ps, sw_template_id);
99+
if (source_it == source_nodes.end() || sink_it == sink_nodes.end()) {
100+
continue;
101+
}
102+
103+
RRNodeId source_node = source_it->second;
104+
e_rr_type source_node_type = rr_graph_.node_type(source_node);
105+
RRNodeId sink_node = sink_it->second;
106+
e_rr_type sink_node_type = rr_graph_.node_type(sink_node);
107+
std::string sw_template_id = sw_block_file_name + "_" + std::to_string(row_idx) + "_" + std::to_string(col_idx);
108+
// If the source node is an IPIN, then it should be considered as
109+
// a sink of the connection.
110+
if (source_node_type == e_rr_type::IPIN) {
111+
int delay_ps = get_connection_delay_ps(cell.as_string(),
112+
rr_node_typename[source_node_type],
113+
sink_node,
114+
source_node);
115+
116+
tile_connections.emplace_back(source_node, sink_node, delay_ps, sw_template_id);
117+
} else {
118+
int segment_length = -1;
119+
if (sink_node_type == e_rr_type::CHANX || sink_node_type == e_rr_type::CHANY) {
120+
segment_length = rr_graph_.node_length(sink_node);
126121
}
122+
int delay_ps = get_connection_delay_ps(cell.as_string(),
123+
rr_node_typename[sink_node_type],
124+
source_node,
125+
sink_node,
126+
segment_length);
127+
128+
tile_connections.emplace_back(sink_node, source_node, delay_ps, sw_template_id);
127129
}
128130
}
129131
}
130132

133+
// Uniqueify the connections
131134
std::sort(tile_connections.begin(), tile_connections.end());
132135
tile_connections.erase(std::unique(tile_connections.begin(),
133136
tile_connections.end()),
@@ -157,8 +160,11 @@ std::map<size_t, RRNodeId> CRRConnectionBuilder::get_tile_source_nodes(int x,
157160

158161
for (size_t row = NUM_EMPTY_ROWS; row < df.rows(); ++row) {
159162
SegmentInfo info = parse_segment_info(df, row, true);
160-
RRNodeId node_id;
163+
if (!info.is_valid()) {
164+
continue;
165+
}
161166

167+
RRNodeId node_id;
162168
if (info.side == e_sw_template_dir::IPIN || info.side == e_sw_template_dir::OPIN) {
163169
node_id = process_opin_ipin_node(info, x, y, node_lookup);
164170
} else if (info.side == e_sw_template_dir::LEFT || info.side == e_sw_template_dir::RIGHT || info.side == e_sw_template_dir::TOP || info.side == e_sw_template_dir::BOTTOM) {
@@ -189,7 +195,7 @@ std::map<size_t, RRNodeId> CRRConnectionBuilder::get_tile_sink_nodes(int x,
189195

190196
for (size_t col = NUM_EMPTY_COLS; col < df.cols(); ++col) {
191197
SegmentInfo info = parse_segment_info(df, col, false);
192-
if (info.side == e_sw_template_dir::NUM_SIDES) {
198+
if (!info.is_valid()) {
193199
continue;
194200
}
195201
RRNodeId node_id;

vpr/src/route/rr_graph_generation/tileable_rr_graph/crr_generator/crr_connection_builder.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ class CRRConnectionBuilder {
9292
, seg_type(type)
9393
, seg_index(index)
9494
, tap(t) {}
95+
bool is_valid() const {
96+
return side != e_sw_template_dir::NUM_SIDES;
97+
}
9598
};
9699

97100
SegmentInfo parse_segment_info(const DataFrame& df, size_t row_or_col, bool is_vertical) const;

0 commit comments

Comments
 (0)