Skip to content

Commit

Permalink
Merge pull request #2381 from verilog-to-routing/3D-Routing-Util
Browse files Browse the repository at this point in the history
Routing Util 3d
  • Loading branch information
vaughnbetz authored Sep 7, 2023
2 parents fbc635a + 17a38ce commit 190fc90
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
4 changes: 2 additions & 2 deletions vpr/src/draw/draw_basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,8 @@ void draw_routing_util(ezgl::renderer* g) {
t_draw_coords* draw_coords = get_draw_coords_vars();
auto& device_ctx = g_vpr_ctx.device();

auto chanx_usage = calculate_routing_usage(CHANX, draw_state->is_flat);
auto chany_usage = calculate_routing_usage(CHANY, draw_state->is_flat);
auto chanx_usage = calculate_routing_usage(CHANX, draw_state->is_flat, false);
auto chany_usage = calculate_routing_usage(CHANY, draw_state->is_flat, false);

auto chanx_avail = calculate_routing_avail(CHANX);
auto chany_avail = calculate_routing_avail(CHANY);
Expand Down
4 changes: 2 additions & 2 deletions vpr/src/route/channel_stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ void print_channel_stats(bool is_flat) {
histogram.emplace_back(0.9, 1.0);
histogram.emplace_back(1.0, std::numeric_limits<float>::infinity());

auto chanx_usage = calculate_routing_usage(CHANX, is_flat);
auto chany_usage = calculate_routing_usage(CHANY, is_flat);
auto chanx_usage = calculate_routing_usage(CHANX, is_flat, true);
auto chany_usage = calculate_routing_usage(CHANY, is_flat, true);

auto chanx_avail = calculate_routing_avail(CHANX);
auto chany_avail = calculate_routing_avail(CHANY);
Expand Down
13 changes: 12 additions & 1 deletion vpr/src/route/route_util.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "route_util.h"
#include "globals.h"
#include "draw_types.h"
#include "draw_global.h"

vtr::Matrix<float> calculate_routing_usage(t_rr_type rr_type, bool is_flat) {
vtr::Matrix<float> calculate_routing_usage(t_rr_type rr_type, bool is_flat, bool is_print) {
VTR_ASSERT(rr_type == CHANX || rr_type == CHANY);

auto& device_ctx = g_vpr_ctx.device();
Expand All @@ -27,6 +29,15 @@ vtr::Matrix<float> calculate_routing_usage(t_rr_type rr_type, bool is_flat) {

//Record number of used resources in each x/y channel
for (RRNodeId rr_node : rr_nodes) {
#ifndef NO_GRAPHICS
if (!is_print) {
t_draw_state* draw_state = get_draw_state_vars();
int layer_num = rr_graph.node_layer(rr_node);
if (!draw_state->draw_layer_display[layer_num].visible)
continue; // don't count usage if layer is not visible
}
#endif

if (rr_type == CHANX) {
VTR_ASSERT(rr_graph.node_type(rr_node) == CHANX);
VTR_ASSERT(rr_graph.node_ylow(rr_node) == rr_graph.node_yhigh(rr_node));
Expand Down
14 changes: 13 additions & 1 deletion vpr/src/route/route_util.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
#ifndef VPR_ROUTE_UTIL_H
#define VPR_ROUTE_UTIL_H
#include "vpr_types.h"
#include "draw_types.h"
#include "draw_global.h"

vtr::Matrix<float> calculate_routing_avail(t_rr_type rr_type);
vtr::Matrix<float> calculate_routing_usage(t_rr_type rr_type, bool is_flat);

/**
* @brief: Calculates and returns the usage over the entire grid for the specified
* type of rr_node to the usage array. The usage is recorded at each (x,y) location.
*
* @param rr_type: Type of rr_node that we are calculating the usage of; can be CHANX or CHANY
* @param is_flat: Is the flat router being used or not?
* @param only_visible: If true, only record the usage of rr_nodes on layers that are visible according to the current
* drawing settings.
*/
vtr::Matrix<float> calculate_routing_usage(t_rr_type rr_type, bool is_flat, bool is_print);
float routing_util(float used, float avail);

#endif

0 comments on commit 190fc90

Please sign in to comment.