Skip to content

Vpr viewer and flat routing on #3070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions vpr/src/base/vpr_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,8 @@ bool vpr_flow(t_vpr_setup& vpr_setup, t_arch& arch) {
}

// TODO: Placer still assumes that cluster net list is used - graphics can not work with flat routing yet
vpr_init_graphics(vpr_setup, arch, false);
bool is_flat = vpr_setup.RouterOpts.flat_routing;
vpr_init_graphics(vpr_setup, arch, is_flat);

vpr_init_server(vpr_setup);

Expand Down Expand Up @@ -510,7 +511,6 @@ bool vpr_flow(t_vpr_setup& vpr_setup, t_arch& arch) {
block_locs);
}

bool is_flat = vpr_setup.RouterOpts.flat_routing;
const Netlist<>& router_net_list = is_flat ? (const Netlist<>&)g_vpr_ctx.atom().netlist() : (const Netlist<>&)g_vpr_ctx.clustering().clb_nlist;
if (is_flat) {
VTR_LOG_WARN("Disabling port equivalence in the architecture since flat routing is enabled.\n");
Expand Down
8 changes: 7 additions & 1 deletion vpr/src/draw/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ void alloc_draw_structs(const t_arch* arch) {
t_draw_state* draw_state = get_draw_state_vars();
auto& device_ctx = g_vpr_ctx.device();
auto& cluster_ctx = g_vpr_ctx.clustering();
const AtomContext& atom_ctx = g_vpr_ctx.atom();

/* Allocate the structures needed to draw the placement and routing-> Set *
* up the default colors for blocks and nets. */
Expand All @@ -498,7 +499,12 @@ void alloc_draw_structs(const t_arch* arch) {
/* For sub-block drawings inside clbs */
draw_internal_alloc_blk();

draw_state->net_color.resize(cluster_ctx.clb_nlist.nets().size());
if (draw_state->is_flat) {
draw_state->net_color.resize(atom_ctx.netlist().nets().size());
} else {
draw_state->net_color.resize(cluster_ctx.clb_nlist.nets().size());
}

draw_state->block_color_.resize(cluster_ctx.clb_nlist.blocks().size());
draw_state->use_default_block_color_.resize(
cluster_ctx.clb_nlist.blocks().size());
Expand Down
24 changes: 17 additions & 7 deletions vpr/src/draw/draw_basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ void drawroute(enum e_draw_net_type draw_net_type, ezgl::renderer* g) {
/* Next free track in each channel segment if routing is GLOBAL */

auto& cluster_ctx = g_vpr_ctx.clustering();
const AtomContext& atom_ctx = g_vpr_ctx.atom();

t_draw_state* draw_state = get_draw_state_vars();

Expand All @@ -546,14 +547,23 @@ void drawroute(enum e_draw_net_type draw_net_type, ezgl::renderer* g) {
g->set_color(ezgl::BLACK, ezgl::BLACK.alpha * NET_ALPHA);

/* Now draw each net, one by one. */
if (draw_state->is_flat) {
for (AtomNetId net_id : atom_ctx.netlist().nets()) {
if (draw_net_type == HIGHLIGHTED
&& draw_state->net_color[net_id] == ezgl::BLACK)
continue;

draw_routed_net((ParentNetId&)net_id, g);
} /* End for (each net) */
} else {
for (ClusterNetId net_id : cluster_ctx.clb_nlist.nets()) {
if (draw_net_type == HIGHLIGHTED
&& draw_state->net_color[net_id] == ezgl::BLACK)
continue;

for (auto net_id : cluster_ctx.clb_nlist.nets()) {
if (draw_net_type == HIGHLIGHTED
&& draw_state->net_color[net_id] == ezgl::BLACK)
continue;

draw_routed_net((ParentNetId&)net_id, g);
} /* End for (each net) */
draw_routed_net((ParentNetId&)net_id, g);
} /* End for (each net) */
}
}

void draw_routed_net(ParentNetId net_id, ezgl::renderer* g) {
Expand Down
10 changes: 8 additions & 2 deletions vpr/src/draw/draw_searchbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ void deselect_all() {

t_draw_state* draw_state = get_draw_state_vars();
const auto& cluster_ctx = g_vpr_ctx.clustering();
const AtomContext& atom_ctx = g_vpr_ctx.atom();
const auto& device_ctx = g_vpr_ctx.device();

/* Create some colour highlighting */
Expand All @@ -239,8 +240,13 @@ void deselect_all() {
draw_reset_blk_color(blk_id);
}

for (auto net_id : cluster_ctx.clb_nlist.nets())
draw_state->net_color[net_id] = ezgl::BLACK;
if (draw_state->is_flat) {
for (auto net_id : atom_ctx.netlist().nets())
draw_state->net_color[net_id] = ezgl::BLACK;
} else {
for (auto net_id : cluster_ctx.clb_nlist.nets())
draw_state->net_color[net_id] = ezgl::BLACK;
}

for (RRNodeId inode : device_ctx.rr_graph.nodes()) {
draw_state->draw_rr_node[inode].color = DEFAULT_RR_NODE_COLOR;
Expand Down
2 changes: 1 addition & 1 deletion vpr/src/draw/draw_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ struct t_draw_state {
char default_message[vtr::bufsize];

///@brief color in which each net should be drawn. [0..cluster_ctx.clb_nlist.nets().size()-1]
vtr::vector<ClusterNetId, ezgl::color> net_color;
vtr::vector<ParentNetId, ezgl::color> net_color;

/**
* @brief stores the state information of each routing resource.
Expand Down
79 changes: 62 additions & 17 deletions vpr/src/draw/search_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "vtr_log.h"

#include "vpr_utils.h"
#include "route_utils.h"

#include "globals.h"
#include "draw.h"
Expand All @@ -30,6 +31,7 @@
#include "intra_logic_block.h"
#include "atom_netlist.h"
#include "search_bar.h"
#include "old_traceback.h"
#include "physical_types.h"
#include "place_macro.h"

Expand Down Expand Up @@ -59,6 +61,8 @@ void search_and_highlight(GtkWidget* /*widget*/, ezgl::application* app) {
// reset
deselect_all();

t_draw_state* draw_state = get_draw_state_vars();

if (search_type == "RR Node ID") {
int rr_node_id = -1;
ss >> rr_node_id;
Expand Down Expand Up @@ -122,32 +126,73 @@ void search_and_highlight(GtkWidget* /*widget*/, ezgl::application* app) {
else if (search_type == "Net ID") {
int net_id = -1;
ss >> net_id;

// valid net id check
if (!cluster_ctx.clb_nlist.valid_net_id(ClusterNetId(net_id))) {
warning_dialog_box("Invalid Net ID");
app->refresh_drawing();
return;
if (draw_state->is_flat) {
AtomNetId atom_net_id = AtomNetId(net_id);
if (!atom_ctx.netlist().valid_net_id(atom_net_id)) {
warning_dialog_box("Invalid Net ID");
app->refresh_drawing();
return;
}
if (!is_net_routed(atom_net_id)) {
warning_dialog_box("Net is unrouted");
app->refresh_drawing();
return;
}
if (is_net_fully_absorbed(atom_net_id)) {
warning_dialog_box("Net is fully absorbed");
app->refresh_drawing();
return;
}
highlight_nets((ClusterNetId)net_id);
} else {
// valid net id check
if (!cluster_ctx.clb_nlist.valid_net_id(ClusterNetId(net_id))) {
warning_dialog_box("Invalid Net ID");
app->refresh_drawing();
return;
}
highlight_nets((ClusterNetId)net_id);
}

highlight_nets((ClusterNetId)net_id);
}

else if (search_type == "Net Name") {
//in this case, all nets (clb and non-clb) are contained in the atom netlist
//So we only need to search this one
std::string net_name;
ss >> net_name;
AtomNetId atom_net_id = atom_ctx.netlist().find_net(net_name);

if (atom_net_id == AtomNetId::INVALID()) {
warning_dialog_box("Invalid Net Name");
return; //name not exist
}

const auto clb_nets = atom_ctx.lookup().clb_nets(atom_net_id);
for (auto clb_net_id : clb_nets.value()) {
highlight_nets(clb_net_id);
if (draw_state->is_flat) {
AtomNetId atom_net_id = atom_ctx.netlist().find_net(net_name);
if (atom_net_id == AtomNetId::INVALID()) {
warning_dialog_box("Invalid Net Name");
app->refresh_drawing();
return;
}
if (!is_net_routed(atom_net_id)) {
warning_dialog_box("Net is unrouted");
app->refresh_drawing();
return;
}
if (is_net_fully_absorbed(atom_net_id)) {
warning_dialog_box("Net is fully absorbed");
app->refresh_drawing();
return;
}
highlight_nets(convert_to_cluster_net_id(atom_net_id));
} else {
AtomNetId atom_net_id = atom_ctx.netlist().find_net(net_name);

if (atom_net_id == AtomNetId::INVALID()) {
warning_dialog_box("Invalid Net Name");
app->refresh_drawing();
return;
}
auto clb_net_ids_opt = atom_ctx.lookup().clb_nets(atom_net_id);
if (clb_net_ids_opt.has_value()) {
for (auto clb_net_id : clb_net_ids_opt.value()) {
highlight_nets(clb_net_id);
}
}
}
}

Expand Down
26 changes: 26 additions & 0 deletions vpr/src/route/route_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,3 +673,29 @@ void update_router_info_and_check_bp(bp_router_type type, int net_id) {
}
}
#endif

bool is_net_routed(ParentNetId net_id) {
const auto& route_ctx = g_vpr_ctx.routing();
//Note: we can't use route_ctx.net_status.is_routed(atom_net_id), because net_status is filled only when route stage took place
return route_ctx.route_trees[net_id].has_value();
}

bool is_net_fully_absorbed(ParentNetId net_id) {
const RRGraphView& rr_graph = g_vpr_ctx.device().rr_graph;
const RoutingContext& route_ctx = g_vpr_ctx.routing();

bool is_absorbed = true;

for (auto& rt_node : route_ctx.route_trees[net_id].value().all_nodes()) {
RRNodeId inode = rt_node.inode;

e_rr_type rr_type = rr_graph.node_type(inode);

if (rr_type == e_rr_type::CHANX || rr_type == e_rr_type::CHANY) {
is_absorbed = false;
break;
}
}

return is_absorbed;
}
26 changes: 26 additions & 0 deletions vpr/src/route/route_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,29 @@ void update_draw_pres_fac(const float new_pres_fac);
* Stops after the specified router iteration or net id is encountered */
void update_router_info_and_check_bp(bp_router_type type, int net_id);
#endif

/**
* @brief Checks whether a given net has been routed.
*
* This function determines if the specified net (identified by `net_id`)
* has routing information associated with it in the current routing context.
*
* @param net_id The identifier of the net to check.
* @return true if the net is routed; false otherwise.
*/
bool is_net_routed(ParentNetId net_id);

/**
* @brief Checks whether a given net is fully absorbed within sink nodes.
*
* This function inspects the route tree of the specified net and determines
* whether it is fully absorbed into non-routing resources (i.e., it does not
* occupy any routing channels such as CHANX or CHANY).
*
* A net is considered fully absorbed if all its route tree nodes are of types
* other than CHANX or CHANY (e.g., IPIN, SINK, OPIN).
*
* @param net_id The identifier of the net to be checked.
* @return true if the net is fully absorbed (uses no routing channels); false otherwise.
*/
bool is_net_fully_absorbed(ParentNetId net_id);