58
58
#include " draw_noc.h"
59
59
60
60
#include " move_utils.h"
61
+ #include " ui_setup.h"
62
+ #include " buttons.h"
61
63
62
64
#ifdef VTR_ENABLE_DEBUG_LOGGING
63
65
# include " move_utils.h"
@@ -104,6 +106,7 @@ static float get_router_expansion_cost(const t_rr_node_route_inf node_inf,
104
106
static void draw_router_expansion_costs (ezgl::renderer* g);
105
107
106
108
static void draw_main_canvas (ezgl::renderer* g);
109
+ static void default_setup (ezgl::application* app);
107
110
static void initial_setup_NO_PICTURE_to_PLACEMENT (ezgl::application* app,
108
111
bool is_new_window);
109
112
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,
118
121
static void initial_setup_NO_PICTURE_to_ROUTING_with_crit_path (
119
122
ezgl::application* app,
120
123
bool is_new_window);
121
- static void toggle_window_mode (GtkWidget* /* widget*/ ,
122
- ezgl::application* /* app*/ );
123
124
static void setup_default_ezgl_callbacks (ezgl::application* app);
124
125
static void set_force_pause (GtkWidget* /* widget*/ , gint /* response_id*/ , gpointer /* data*/ );
125
126
static void set_block_outline (GtkWidget* widget, gint /* response_id*/ , gpointer /* data*/ );
@@ -269,6 +270,20 @@ static void draw_main_canvas(ezgl::renderer* g) {
269
270
}
270
271
}
271
272
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
+
272
287
/* function below intializes the interface window with a set of buttons and links
273
288
* signals to corresponding functions for situation where the window is opened from
274
289
* NO_PICTURE_to_PLACEMENT */
@@ -277,40 +292,15 @@ static void initial_setup_NO_PICTURE_to_PLACEMENT(ezgl::application* app,
277
292
if (!is_new_window)
278
293
return ;
279
294
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);
289
297
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
307
299
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);
314
304
button_for_displaying_noc ();
315
305
}
316
306
@@ -320,43 +310,40 @@ static void initial_setup_NO_PICTURE_to_PLACEMENT(ezgl::application* app,
320
310
static void initial_setup_NO_PICTURE_to_PLACEMENT_with_crit_path (
321
311
ezgl::application* app,
322
312
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);
325
320
}
326
321
327
322
/* function below intializes the interface window with a set of buttons and links
328
323
* signals to corresponding functions for situation where the window is opened from
329
324
* PLACEMENT_to_ROUTING */
330
325
static void initial_setup_PLACEMENT_to_ROUTING (ezgl::application* app,
331
326
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);
339
333
}
340
334
341
335
/* function below intializes the interface window with a set of buttons and links
342
336
* signals to corresponding functions for situation where the window is opened from
343
337
* ROUTING_to_PLACEMENT */
344
338
static void initial_setup_ROUTING_to_PLACEMENT (ezgl::application* app,
345
339
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);
360
347
}
361
348
362
349
/* 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,
366
353
bool is_new_window) {
367
354
if (!is_new_window)
368
355
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);
407
359
button_for_displaying_noc ();
408
360
}
409
361
@@ -413,8 +365,11 @@ static void initial_setup_NO_PICTURE_to_ROUTING(ezgl::application* app,
413
365
static void initial_setup_NO_PICTURE_to_ROUTING_with_crit_path (
414
366
ezgl::application* app,
415
367
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);
418
373
}
419
374
#endif // NO_GRAPHICS
420
375
@@ -531,8 +486,8 @@ void update_screen(ScreenUpdatePriority priority, const char* msg, enum pic_type
531
486
}
532
487
533
488
#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*/ ) {
536
491
window_mode = true ;
537
492
}
538
493
@@ -1383,5 +1338,27 @@ ezgl::color lighten_color(ezgl::color color, float amount) {
1383
1338
1384
1339
return hsl2color (hsl);
1385
1340
}
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
+ }
1386
1363
1387
1364
#endif /* NO_GRAPHICS */
0 commit comments