Skip to content

Commit 5f11b9b

Browse files
cherrypick calculate_channel_width();
1 parent 06fe567 commit 5f11b9b

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

vpr/src/base/stats.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,41 @@ void routing_stats(const Netlist<>& net_list,
113113
}
114114
}
115115

116+
std::pair<vtr::NdMatrix<int, 3>, vtr::NdMatrix<int, 3>> calculate_channel_width() {
117+
const auto& device_ctx = g_vpr_ctx.device();
118+
const auto& rr_graph = device_ctx.rr_graph;
119+
120+
auto chanx_width = vtr::NdMatrix<int, 3>({{(size_t)device_ctx.grid.get_num_layers(),
121+
device_ctx.grid.width(),
122+
device_ctx.grid.height()}},
123+
0);
124+
125+
auto chany_width = vtr::NdMatrix<int, 3>({{(size_t)device_ctx.grid.get_num_layers(),
126+
device_ctx.grid.width(),
127+
device_ctx.grid.height()}},
128+
0);
129+
130+
for (RRNodeId node_id : rr_graph.nodes()) {
131+
e_rr_type rr_type = rr_graph.node_type(node_id);
132+
133+
if (rr_type == e_rr_type::CHANX) {
134+
int y = rr_graph.node_ylow(node_id);
135+
int layer = rr_graph.node_layer(node_id);
136+
for (int x = rr_graph.node_xlow(node_id); x <= rr_graph.node_xhigh(node_id); x++) {
137+
chanx_width[layer][x][y]++;
138+
}
139+
} else if (rr_type == e_rr_type::CHANY) {
140+
int x = rr_graph.node_xlow(node_id);
141+
int layer = rr_graph.node_layer(node_id);
142+
for (int y = rr_graph.node_ylow(node_id); y <= rr_graph.node_yhigh(node_id); y++) {
143+
chany_width[layer][x][y]++;
144+
}
145+
}
146+
}
147+
148+
return {chanx_width, chany_width};
149+
}
150+
116151
void length_and_bends_stats(const Netlist<>& net_list, bool is_flat) {
117152
int max_bends = 0;
118153
int total_bends = 0;

vpr/src/base/stats.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ void routing_stats(const Netlist<>& net_list,
2222
int wire_to_ipin_switch,
2323
bool is_flat);
2424

25+
std::pair<vtr::NdMatrix<int, 3>, vtr::NdMatrix<int, 3>> calculate_channel_width();
26+
2527
void print_wirelen_prob_dist(bool is_flat);
2628

2729
void print_lambda();

0 commit comments

Comments
 (0)