route util adopt RRGraph object

This commit is contained in:
tangxifan 2020-02-01 18:01:05 -07:00
parent 400bd76bdc
commit f139a844ca
1 changed files with 12 additions and 14 deletions

View File

@ -11,13 +11,13 @@ vtr::Matrix<float> calculate_routing_usage(t_rr_type rr_type) {
vtr::Matrix<float> usage({{device_ctx.grid.width(), device_ctx.grid.height()}}, 0.); vtr::Matrix<float> usage({{device_ctx.grid.width(), device_ctx.grid.height()}}, 0.);
//Collect all the in-use RR nodes //Collect all the in-use RR nodes
std::set<int> rr_nodes; std::set<RRNodeId> rr_nodes;
for (auto net : cluster_ctx.clb_nlist.nets()) { for (auto net : cluster_ctx.clb_nlist.nets()) {
t_trace* tptr = route_ctx.trace[net].head; t_trace* tptr = route_ctx.trace[net].head;
while (tptr != nullptr) { while (tptr != nullptr) {
int inode = tptr->index; RRNodeId inode = tptr->index;
if (device_ctx.rr_nodes[inode].type() == rr_type) { if (device_ctx.rr_graph.node_type(inode) == rr_type) {
rr_nodes.insert(inode); rr_nodes.insert(inode);
} }
tptr = tptr->next; tptr = tptr->next;
@ -25,24 +25,22 @@ vtr::Matrix<float> calculate_routing_usage(t_rr_type rr_type) {
} }
//Record number of used resources in each x/y channel //Record number of used resources in each x/y channel
for (int inode : rr_nodes) { for (const RRNodeId& inode : rr_nodes) {
auto& rr_node = device_ctx.rr_nodes[inode];
if (rr_type == CHANX) { if (rr_type == CHANX) {
VTR_ASSERT(rr_node.type() == CHANX); VTR_ASSERT(device_ctx.rr_graph.node_type(inode) == CHANX);
VTR_ASSERT(rr_node.ylow() == rr_node.yhigh()); VTR_ASSERT(device_ctx.rr_graph.node_ylow(inode) == device_ctx.rr_graph.node_yhigh(inode));
int y = rr_node.ylow(); int y = device_ctx.rr_graph.node_ylow(inode);
for (int x = rr_node.xlow(); x <= rr_node.xhigh(); ++x) { for (int x = device_ctx.rr_graph.node_xlow(inode); x <= device_ctx.rr_graph.node_xhigh(inode); ++x) {
usage[x][y] += route_ctx.rr_node_route_inf[inode].occ(); usage[x][y] += route_ctx.rr_node_route_inf[inode].occ();
} }
} else { } else {
VTR_ASSERT(rr_type == CHANY); VTR_ASSERT(rr_type == CHANY);
VTR_ASSERT(rr_node.type() == CHANY); VTR_ASSERT(device_ctx.rr_graph.node_type(inode) == CHANY);
VTR_ASSERT(rr_node.xlow() == rr_node.xhigh()); VTR_ASSERT(device_ctx.rr_graph.node_xlow(inode) == device_ctx.rr_graph.node_xhigh(inode));
int x = rr_node.xlow(); int x = device_ctx.rr_graph.node_xlow(inode);
for (int y = rr_node.ylow(); y <= rr_node.yhigh(); ++y) { for (int y = device_ctx.rr_graph.node_ylow(inode); y <= device_ctx.rr_graph.node_yhigh(inode); ++y) {
usage[x][y] += route_ctx.rr_node_route_inf[inode].occ(); usage[x][y] += route_ctx.rr_node_route_inf[inode].occ();
} }
} }