Skip to content

Commit c654d16

Browse files
authored
Merge pull request #3070 from w0lek/vpr_viewer_and_flat_routing_on
Vpr viewer and flat routing on
2 parents 6f4290b + 05af555 commit c654d16

File tree

8 files changed

+149
-30
lines changed

8 files changed

+149
-30
lines changed

vpr/src/base/vpr_api.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,8 @@ bool vpr_flow(t_vpr_setup& vpr_setup, t_arch& arch) {
466466
}
467467

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

471472
vpr_init_server(vpr_setup);
472473

@@ -510,7 +511,6 @@ bool vpr_flow(t_vpr_setup& vpr_setup, t_arch& arch) {
510511
block_locs);
511512
}
512513

513-
bool is_flat = vpr_setup.RouterOpts.flat_routing;
514514
const Netlist<>& router_net_list = is_flat ? (const Netlist<>&)g_vpr_ctx.atom().netlist() : (const Netlist<>&)g_vpr_ctx.clustering().clb_nlist;
515515
if (is_flat) {
516516
VTR_LOG_WARN("Disabling port equivalence in the architecture since flat routing is enabled.\n");

vpr/src/draw/draw.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ void alloc_draw_structs(const t_arch* arch) {
489489
t_draw_state* draw_state = get_draw_state_vars();
490490
auto& device_ctx = g_vpr_ctx.device();
491491
auto& cluster_ctx = g_vpr_ctx.clustering();
492+
const AtomContext& atom_ctx = g_vpr_ctx.atom();
492493

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

501-
draw_state->net_color.resize(cluster_ctx.clb_nlist.nets().size());
502+
if (draw_state->is_flat) {
503+
draw_state->net_color.resize(atom_ctx.netlist().nets().size());
504+
} else {
505+
draw_state->net_color.resize(cluster_ctx.clb_nlist.nets().size());
506+
}
507+
502508
draw_state->block_color_.resize(cluster_ctx.clb_nlist.blocks().size());
503509
draw_state->use_default_block_color_.resize(
504510
cluster_ctx.clb_nlist.blocks().size());

vpr/src/draw/draw_basic.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ void drawroute(enum e_draw_net_type draw_net_type, ezgl::renderer* g) {
537537
/* Next free track in each channel segment if routing is GLOBAL */
538538

539539
auto& cluster_ctx = g_vpr_ctx.clustering();
540+
const AtomContext& atom_ctx = g_vpr_ctx.atom();
540541

541542
t_draw_state* draw_state = get_draw_state_vars();
542543

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

548549
/* Now draw each net, one by one. */
550+
if (draw_state->is_flat) {
551+
for (AtomNetId net_id : atom_ctx.netlist().nets()) {
552+
if (draw_net_type == HIGHLIGHTED
553+
&& draw_state->net_color[net_id] == ezgl::BLACK)
554+
continue;
555+
556+
draw_routed_net((ParentNetId&)net_id, g);
557+
} /* End for (each net) */
558+
} else {
559+
for (ClusterNetId net_id : cluster_ctx.clb_nlist.nets()) {
560+
if (draw_net_type == HIGHLIGHTED
561+
&& draw_state->net_color[net_id] == ezgl::BLACK)
562+
continue;
549563

550-
for (auto net_id : cluster_ctx.clb_nlist.nets()) {
551-
if (draw_net_type == HIGHLIGHTED
552-
&& draw_state->net_color[net_id] == ezgl::BLACK)
553-
continue;
554-
555-
draw_routed_net((ParentNetId&)net_id, g);
556-
} /* End for (each net) */
564+
draw_routed_net((ParentNetId&)net_id, g);
565+
} /* End for (each net) */
566+
}
557567
}
558568

559569
void draw_routed_net(ParentNetId net_id, ezgl::renderer* g) {

vpr/src/draw/draw_searchbar.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ void deselect_all() {
231231

232232
t_draw_state* draw_state = get_draw_state_vars();
233233
const auto& cluster_ctx = g_vpr_ctx.clustering();
234+
const AtomContext& atom_ctx = g_vpr_ctx.atom();
234235
const auto& device_ctx = g_vpr_ctx.device();
235236

236237
/* Create some colour highlighting */
@@ -239,8 +240,13 @@ void deselect_all() {
239240
draw_reset_blk_color(blk_id);
240241
}
241242

242-
for (auto net_id : cluster_ctx.clb_nlist.nets())
243-
draw_state->net_color[net_id] = ezgl::BLACK;
243+
if (draw_state->is_flat) {
244+
for (auto net_id : atom_ctx.netlist().nets())
245+
draw_state->net_color[net_id] = ezgl::BLACK;
246+
} else {
247+
for (auto net_id : cluster_ctx.clb_nlist.nets())
248+
draw_state->net_color[net_id] = ezgl::BLACK;
249+
}
244250

245251
for (RRNodeId inode : device_ctx.rr_graph.nodes()) {
246252
draw_state->draw_rr_node[inode].color = DEFAULT_RR_NODE_COLOR;

vpr/src/draw/draw_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ struct t_draw_state {
234234
char default_message[vtr::bufsize];
235235

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

239239
/**
240240
* @brief stores the state information of each routing resource.

vpr/src/draw/search_bar.cpp

Lines changed: 62 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "vtr_log.h"
2222

2323
#include "vpr_utils.h"
24+
#include "route_utils.h"
2425

2526
#include "globals.h"
2627
#include "draw.h"
@@ -30,6 +31,7 @@
3031
#include "intra_logic_block.h"
3132
#include "atom_netlist.h"
3233
#include "search_bar.h"
34+
#include "old_traceback.h"
3335
#include "physical_types.h"
3436
#include "place_macro.h"
3537

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

64+
t_draw_state* draw_state = get_draw_state_vars();
65+
6266
if (search_type == "RR Node ID") {
6367
int rr_node_id = -1;
6468
ss >> rr_node_id;
@@ -122,32 +126,73 @@ void search_and_highlight(GtkWidget* /*widget*/, ezgl::application* app) {
122126
else if (search_type == "Net ID") {
123127
int net_id = -1;
124128
ss >> net_id;
125-
126-
// valid net id check
127-
if (!cluster_ctx.clb_nlist.valid_net_id(ClusterNetId(net_id))) {
128-
warning_dialog_box("Invalid Net ID");
129-
app->refresh_drawing();
130-
return;
129+
if (draw_state->is_flat) {
130+
AtomNetId atom_net_id = AtomNetId(net_id);
131+
if (!atom_ctx.netlist().valid_net_id(atom_net_id)) {
132+
warning_dialog_box("Invalid Net ID");
133+
app->refresh_drawing();
134+
return;
135+
}
136+
if (!is_net_routed(atom_net_id)) {
137+
warning_dialog_box("Net is unrouted");
138+
app->refresh_drawing();
139+
return;
140+
}
141+
if (is_net_fully_absorbed(atom_net_id)) {
142+
warning_dialog_box("Net is fully absorbed");
143+
app->refresh_drawing();
144+
return;
145+
}
146+
highlight_nets((ClusterNetId)net_id);
147+
} else {
148+
// valid net id check
149+
if (!cluster_ctx.clb_nlist.valid_net_id(ClusterNetId(net_id))) {
150+
warning_dialog_box("Invalid Net ID");
151+
app->refresh_drawing();
152+
return;
153+
}
154+
highlight_nets((ClusterNetId)net_id);
131155
}
132-
133-
highlight_nets((ClusterNetId)net_id);
134156
}
135157

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

143-
if (atom_net_id == AtomNetId::INVALID()) {
144-
warning_dialog_box("Invalid Net Name");
145-
return; //name not exist
146-
}
147-
148-
const auto clb_nets = atom_ctx.lookup().clb_nets(atom_net_id);
149-
for (auto clb_net_id : clb_nets.value()) {
150-
highlight_nets(clb_net_id);
164+
if (draw_state->is_flat) {
165+
AtomNetId atom_net_id = atom_ctx.netlist().find_net(net_name);
166+
if (atom_net_id == AtomNetId::INVALID()) {
167+
warning_dialog_box("Invalid Net Name");
168+
app->refresh_drawing();
169+
return;
170+
}
171+
if (!is_net_routed(atom_net_id)) {
172+
warning_dialog_box("Net is unrouted");
173+
app->refresh_drawing();
174+
return;
175+
}
176+
if (is_net_fully_absorbed(atom_net_id)) {
177+
warning_dialog_box("Net is fully absorbed");
178+
app->refresh_drawing();
179+
return;
180+
}
181+
highlight_nets(convert_to_cluster_net_id(atom_net_id));
182+
} else {
183+
AtomNetId atom_net_id = atom_ctx.netlist().find_net(net_name);
184+
185+
if (atom_net_id == AtomNetId::INVALID()) {
186+
warning_dialog_box("Invalid Net Name");
187+
app->refresh_drawing();
188+
return;
189+
}
190+
auto clb_net_ids_opt = atom_ctx.lookup().clb_nets(atom_net_id);
191+
if (clb_net_ids_opt.has_value()) {
192+
for (auto clb_net_id : clb_net_ids_opt.value()) {
193+
highlight_nets(clb_net_id);
194+
}
195+
}
151196
}
152197
}
153198

vpr/src/route/route_utils.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,3 +673,29 @@ void update_router_info_and_check_bp(bp_router_type type, int net_id) {
673673
}
674674
}
675675
#endif
676+
677+
bool is_net_routed(ParentNetId net_id) {
678+
const auto& route_ctx = g_vpr_ctx.routing();
679+
//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
680+
return route_ctx.route_trees[net_id].has_value();
681+
}
682+
683+
bool is_net_fully_absorbed(ParentNetId net_id) {
684+
const RRGraphView& rr_graph = g_vpr_ctx.device().rr_graph;
685+
const RoutingContext& route_ctx = g_vpr_ctx.routing();
686+
687+
bool is_absorbed = true;
688+
689+
for (auto& rt_node : route_ctx.route_trees[net_id].value().all_nodes()) {
690+
RRNodeId inode = rt_node.inode;
691+
692+
e_rr_type rr_type = rr_graph.node_type(inode);
693+
694+
if (rr_type == e_rr_type::CHANX || rr_type == e_rr_type::CHANY) {
695+
is_absorbed = false;
696+
break;
697+
}
698+
}
699+
700+
return is_absorbed;
701+
}

vpr/src/route/route_utils.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,29 @@ void update_draw_pres_fac(const float new_pres_fac);
157157
* Stops after the specified router iteration or net id is encountered */
158158
void update_router_info_and_check_bp(bp_router_type type, int net_id);
159159
#endif
160+
161+
/**
162+
* @brief Checks whether a given net has been routed.
163+
*
164+
* This function determines if the specified net (identified by `net_id`)
165+
* has routing information associated with it in the current routing context.
166+
*
167+
* @param net_id The identifier of the net to check.
168+
* @return true if the net is routed; false otherwise.
169+
*/
170+
bool is_net_routed(ParentNetId net_id);
171+
172+
/**
173+
* @brief Checks whether a given net is fully absorbed within sink nodes.
174+
*
175+
* This function inspects the route tree of the specified net and determines
176+
* whether it is fully absorbed into non-routing resources (i.e., it does not
177+
* occupy any routing channels such as CHANX or CHANY).
178+
*
179+
* A net is considered fully absorbed if all its route tree nodes are of types
180+
* other than CHANX or CHANY (e.g., IPIN, SINK, OPIN).
181+
*
182+
* @param net_id The identifier of the net to be checked.
183+
* @return true if the net is fully absorbed (uses no routing channels); false otherwise.
184+
*/
185+
bool is_net_fully_absorbed(ParentNetId net_id);

0 commit comments

Comments
 (0)