Skip to content

Commit 25e723a

Browse files
authored
Merge pull request #2085 from verilog-to-routing/Seb_GraphicsUpdate
Graphics Update/New UI for VPR
2 parents 0f23dde + ff5e191 commit 25e723a

9 files changed

+1121
-766
lines changed

vpr/main.ui

Lines changed: 631 additions & 121 deletions
Large diffs are not rendered by default.

vpr/src/draw/buttons.cpp

Lines changed: 0 additions & 368 deletions
Large diffs are not rendered by default.

vpr/src/draw/buttons.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,8 @@
99
# include "ezgl/application.hpp"
1010
# include "ezgl/graphics.hpp"
1111

12-
void button_for_toggle_nets();
13-
void button_for_toggle_blk_internal();
14-
void button_for_toggle_block_pin_util();
15-
void button_for_toggle_placement_macros();
16-
void button_for_toggle_crit_path();
17-
void button_for_net_max_fanout();
18-
void button_for_net_alpha();
1912
void button_for_displaying_noc();
2013

21-
void button_for_toggle_rr();
22-
void button_for_toggle_congestion();
23-
void button_for_toggle_congestion_cost();
24-
void button_for_toggle_routing_bounding_box();
25-
void button_for_toggle_routing_util();
26-
void button_for_toggle_router_expansion_costs();
2714
void delete_button(const char* button_name);
2815
GtkWidget* find_button(const char* button_name);
2916
#endif /* NO_GRAPHICS */

vpr/src/draw/draw.cpp

Lines changed: 76 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
#include "draw_noc.h"
5959

6060
#include "move_utils.h"
61+
#include "ui_setup.h"
62+
#include "buttons.h"
6163

6264
#ifdef VTR_ENABLE_DEBUG_LOGGING
6365
# include "move_utils.h"
@@ -104,6 +106,7 @@ static float get_router_expansion_cost(const t_rr_node_route_inf node_inf,
104106
static void draw_router_expansion_costs(ezgl::renderer* g);
105107

106108
static void draw_main_canvas(ezgl::renderer* g);
109+
static void default_setup(ezgl::application* app);
107110
static void initial_setup_NO_PICTURE_to_PLACEMENT(ezgl::application* app,
108111
bool is_new_window);
109112
static void initial_setup_NO_PICTURE_to_PLACEMENT_with_crit_path(
@@ -118,8 +121,6 @@ static void initial_setup_NO_PICTURE_to_ROUTING(ezgl::application* app,
118121
static void initial_setup_NO_PICTURE_to_ROUTING_with_crit_path(
119122
ezgl::application* app,
120123
bool is_new_window);
121-
static void toggle_window_mode(GtkWidget* /*widget*/,
122-
ezgl::application* /*app*/);
123124
static void setup_default_ezgl_callbacks(ezgl::application* app);
124125
static void set_force_pause(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/);
125126
static void set_block_outline(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/);
@@ -269,6 +270,20 @@ static void draw_main_canvas(ezgl::renderer* g) {
269270
}
270271
}
271272

273+
/**
274+
* @brief Default setup function, connects signals/sets up ui created in main.ui file
275+
*
276+
* To minimize code repetition, this function sets up all buttons that ALWAYS get set up.
277+
* If you want to add to the initial setup functions, and your new setup function will always be called,
278+
* please put it here instead of writing it 5 independent times. Thanks!
279+
* @param app ezgl application
280+
*/
281+
static void default_setup(ezgl::application* app) {
282+
basic_button_setup(app);
283+
net_button_setup(app);
284+
block_button_setup(app);
285+
}
286+
272287
/* function below intializes the interface window with a set of buttons and links
273288
* signals to corresponding functions for situation where the window is opened from
274289
* NO_PICTURE_to_PLACEMENT */
@@ -277,40 +292,15 @@ static void initial_setup_NO_PICTURE_to_PLACEMENT(ezgl::application* app,
277292
if (!is_new_window)
278293
return;
279294

280-
//button to enter window_mode, created in main.ui
281-
GtkButton* window = (GtkButton*)app->get_object("Window");
282-
gtk_button_set_label(window, "Window");
283-
g_signal_connect(window, "clicked", G_CALLBACK(toggle_window_mode), app);
284-
285-
//button to search, created in main.ui
286-
GtkButton* search = (GtkButton*)app->get_object("Search");
287-
gtk_button_set_label(search, "Search");
288-
g_signal_connect(search, "clicked", G_CALLBACK(search_and_highlight), app);
295+
//Configuring visible buttons
296+
default_setup(app);
289297

290-
//button for save graphcis, created in main.ui
291-
GtkButton* save = (GtkButton*)app->get_object("SaveGraphics");
292-
g_signal_connect(save, "clicked", G_CALLBACK(save_graphics_dialog_box),
293-
app);
294-
295-
//combo box for search type, created in main.ui
296-
GObject* search_type = (GObject*)app->get_object("SearchType");
297-
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(search_type), "Block ID"); // index 0
298-
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(search_type),
299-
"Block Name"); // index 1
300-
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(search_type), "Net ID"); // index 2
301-
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(search_type), "Net Name"); // index 3
302-
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(search_type),
303-
"RR Node ID"); // index 4
304-
//Important to have default option set, or else user can search w. no selected type which can cause crash
305-
gtk_combo_box_set_active((GtkComboBox*)search_type, 0); // default set to Block ID which has an index 0
306-
g_signal_connect(search_type, "changed", G_CALLBACK(search_type_changed), app);
298+
//THIS WILL BE CHANGED SOON IGNORE
307299
load_block_names(app);
308-
button_for_toggle_nets();
309-
button_for_net_max_fanout();
310-
button_for_net_alpha();
311-
button_for_toggle_blk_internal();
312-
button_for_toggle_block_pin_util();
313-
button_for_toggle_placement_macros();
300+
301+
//Hiding unused functionality
302+
hide_widget("RoutingMenuButton", app);
303+
hide_crit_path_button(app);
314304
button_for_displaying_noc();
315305
}
316306

@@ -320,43 +310,40 @@ static void initial_setup_NO_PICTURE_to_PLACEMENT(ezgl::application* app,
320310
static void initial_setup_NO_PICTURE_to_PLACEMENT_with_crit_path(
321311
ezgl::application* app,
322312
bool is_new_window) {
323-
initial_setup_NO_PICTURE_to_PLACEMENT(app, is_new_window);
324-
button_for_toggle_crit_path();
313+
if (!is_new_window)
314+
return;
315+
default_setup(app);
316+
crit_path_button_setup(app);
317+
318+
//Hiding unused routing menu
319+
hide_widget("RoutingMenuButton", app);
325320
}
326321

327322
/* function below intializes the interface window with a set of buttons and links
328323
* signals to corresponding functions for situation where the window is opened from
329324
* PLACEMENT_to_ROUTING */
330325
static void initial_setup_PLACEMENT_to_ROUTING(ezgl::application* app,
331326
bool is_new_window) {
332-
initial_setup_NO_PICTURE_to_PLACEMENT_with_crit_path(app, is_new_window);
333-
button_for_toggle_rr();
334-
button_for_toggle_congestion();
335-
button_for_toggle_congestion_cost();
336-
button_for_toggle_routing_bounding_box();
337-
button_for_toggle_routing_util();
338-
button_for_toggle_router_expansion_costs();
327+
if (!is_new_window)
328+
return;
329+
default_setup(app);
330+
routing_button_setup(app);
331+
332+
hide_crit_path_button(app);
339333
}
340334

341335
/* function below intializes the interface window with a set of buttons and links
342336
* signals to corresponding functions for situation where the window is opened from
343337
* ROUTING_to_PLACEMENT */
344338
static void initial_setup_ROUTING_to_PLACEMENT(ezgl::application* app,
345339
bool is_new_window) {
346-
initial_setup_PLACEMENT_to_ROUTING(app, is_new_window);
347-
std::string toggle_rr = "toggle_rr";
348-
std::string toggle_congestion = "toggle_congestion";
349-
std::string toggle_routing_congestion_cost = "toggle_routing_congestion_cost";
350-
std::string toggle_routing_bounding_box = "toggle_routing_bounding_box";
351-
std::string toggle_routing_util = "toggle_rr";
352-
std::string toggle_router_expansion_costs = "toggle_router_expansion_costs";
353-
354-
delete_button(toggle_rr.c_str());
355-
delete_button(toggle_congestion.c_str());
356-
delete_button(toggle_routing_congestion_cost.c_str());
357-
delete_button(toggle_routing_bounding_box.c_str());
358-
delete_button(toggle_routing_util.c_str());
359-
delete_button(toggle_router_expansion_costs.c_str());
340+
if (!is_new_window)
341+
return;
342+
default_setup(app);
343+
344+
//Hiding unused functionality
345+
hide_widget("RoutingMenuButton", app);
346+
hide_crit_path_button(app);
360347
}
361348

362349
/* function below intializes the interface window with a set of buttons and links
@@ -366,44 +353,9 @@ static void initial_setup_NO_PICTURE_to_ROUTING(ezgl::application* app,
366353
bool is_new_window) {
367354
if (!is_new_window)
368355
return;
369-
370-
GtkButton* window = (GtkButton*)app->get_object("Window");
371-
gtk_button_set_label(window, "Window");
372-
g_signal_connect(window, "clicked", G_CALLBACK(toggle_window_mode), app);
373-
374-
GtkButton* search = (GtkButton*)app->get_object("Search");
375-
gtk_button_set_label(search, "Search");
376-
g_signal_connect(search, "clicked", G_CALLBACK(search_and_highlight), app);
377-
378-
GtkButton* save = (GtkButton*)app->get_object("SaveGraphics");
379-
g_signal_connect(save, "clicked", G_CALLBACK(save_graphics_dialog_box),
380-
app);
381-
382-
GObject* search_type = (GObject*)app->get_object("SearchType");
383-
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(search_type), "Block ID");
384-
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(search_type),
385-
"Block Name");
386-
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(search_type), "Net ID");
387-
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(search_type), "Net Name");
388-
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(search_type),
389-
"RR Node ID");
390-
//Important to have default option set, or else user can search w. no selected type which can cause crash
391-
gtk_combo_box_set_active((GtkComboBox*)search_type, 0); // default set to Block ID which has an index 0
392-
g_signal_connect(search_type, "changed", G_CALLBACK(search_type_changed), app);
393-
load_block_names(app);
394-
395-
button_for_toggle_nets();
396-
button_for_net_max_fanout();
397-
button_for_net_alpha();
398-
button_for_toggle_blk_internal();
399-
button_for_toggle_block_pin_util();
400-
button_for_toggle_placement_macros();
401-
button_for_toggle_rr();
402-
button_for_toggle_congestion();
403-
button_for_toggle_congestion_cost();
404-
button_for_toggle_routing_bounding_box();
405-
button_for_toggle_routing_util();
406-
button_for_toggle_router_expansion_costs();
356+
default_setup(app);
357+
routing_button_setup(app);
358+
hide_crit_path_button(app);
407359
button_for_displaying_noc();
408360
}
409361

@@ -413,8 +365,11 @@ static void initial_setup_NO_PICTURE_to_ROUTING(ezgl::application* app,
413365
static void initial_setup_NO_PICTURE_to_ROUTING_with_crit_path(
414366
ezgl::application* app,
415367
bool is_new_window) {
416-
initial_setup_NO_PICTURE_to_ROUTING(app, is_new_window);
417-
button_for_toggle_crit_path();
368+
if (!is_new_window)
369+
return;
370+
default_setup(app);
371+
routing_button_setup(app);
372+
crit_path_button_setup(app);
418373
}
419374
#endif //NO_GRAPHICS
420375

@@ -531,8 +486,8 @@ void update_screen(ScreenUpdatePriority priority, const char* msg, enum pic_type
531486
}
532487

533488
#ifndef NO_GRAPHICS
534-
static void toggle_window_mode(GtkWidget* /*widget*/,
535-
ezgl::application* /*app*/) {
489+
void toggle_window_mode(GtkWidget* /*widget*/,
490+
ezgl::application* /*app*/) {
536491
window_mode = true;
537492
}
538493

@@ -1383,5 +1338,27 @@ ezgl::color lighten_color(ezgl::color color, float amount) {
13831338

13841339
return hsl2color(hsl);
13851340
}
1341+
/**
1342+
* @brief Returns the max fanout
1343+
*
1344+
* @return size_t
1345+
*/
1346+
size_t get_max_fanout() {
1347+
//find maximum fanout
1348+
auto& cluster_ctx = g_vpr_ctx.clustering();
1349+
auto& clb_nlist = cluster_ctx.clb_nlist;
1350+
size_t max_fanout = 0;
1351+
for (ClusterNetId net_id : clb_nlist.nets())
1352+
max_fanout = std::max(max_fanout, clb_nlist.net_sinks(net_id).size());
1353+
1354+
auto& atom_ctx = g_vpr_ctx.atom();
1355+
auto& atom_nlist = atom_ctx.nlist;
1356+
size_t max_fanout2 = 0;
1357+
for (AtomNetId net_id : atom_nlist.nets())
1358+
max_fanout2 = std::max(max_fanout2, atom_nlist.net_sinks(net_id).size());
1359+
1360+
size_t max = std::max(max_fanout2, max_fanout);
1361+
return max;
1362+
}
13861363

13871364
#endif /* NO_GRAPHICS */

vpr/src/draw/draw.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ ezgl::color get_block_type_color(t_physical_tile_type_ptr type);
103103
/* Lightens a color's luminance [0, 1] by an aboslute 'amount' */
104104
ezgl::color lighten_color(ezgl::color color, float amount);
105105

106+
void toggle_window_mode(GtkWidget* /*widget*/, ezgl::application* /*app*/);
107+
108+
size_t get_max_fanout();
109+
106110
#endif /* NO_GRAPHICS */
107111

108112
#endif /* DRAW_H */

0 commit comments

Comments
 (0)