Skip to content

Commit 031fbc6

Browse files
committed
[draw ap] Now able to draw arbitrary things at AP stage
This will not break place and route drawing and it creates a initial world of different dimension than place and route drawing
1 parent 7b55b70 commit 031fbc6

File tree

6 files changed

+84
-43
lines changed

6 files changed

+84
-43
lines changed

vpr/src/analytical_place/global_placer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "ap_netlist_fwd.h"
1919
#include "atom_netlist.h"
2020
#include "device_grid.h"
21+
#include "draw.h"
2122
#include "flat_placement_bins.h"
2223
#include "flat_placement_density_manager.h"
2324
#include "globals.h"
@@ -450,6 +451,7 @@ PartialPlacement SimPLGlobalPlacer::place() {
450451
*density_manager_,
451452
pre_cluster_timing_manager_);
452453

454+
update_screen(ScreenUpdatePriority::MAJOR, "Global Placement Complete", ANALYTICAL_PLACEMENT, nullptr);
453455
// Return the placement from the final iteration.
454456
return best_p_placement;
455457
}

vpr/src/base/vpr_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ enum class e_sched_type {
386386
enum pic_type {
387387
NO_PICTURE,
388388
PLACEMENT,
389+
ANALYTICAL_PLACEMENT,
389390
ROUTING
390391
};
391392
/* What's on screen? */

vpr/src/draw/draw.cpp

Lines changed: 67 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "physical_types.h"
2121

2222
#include "move_utils.h"
23+
#include "vpr_types.h"
2324

2425
#ifndef NO_GRAPHICS
2526

@@ -174,63 +175,65 @@ static void draw_main_canvas(ezgl::renderer* g) {
174175
t_draw_state* draw_state = get_draw_state_vars();
175176

176177
g->set_font_size(14);
178+
if (draw_state->pic_on_screen != ANALYTICAL_PLACEMENT) {
179+
draw_block_pin_util();
180+
drawplace(g);
181+
draw_internal_draw_subblk(g);
177182

178-
draw_block_pin_util();
179-
drawplace(g);
180-
draw_internal_draw_subblk(g);
183+
if (draw_state->pic_on_screen == ROUTING) { // ROUTING on screen
181184

182-
if (draw_state->pic_on_screen == ROUTING) { // ROUTING on screen
185+
draw_rr(g);
183186

184-
draw_rr(g);
187+
if (draw_state->show_nets && draw_state->draw_nets == DRAW_ROUTED_NETS) {
188+
draw_route(ALL_NETS, g);
185189

186-
if (draw_state->show_nets && draw_state->draw_nets == DRAW_ROUTED_NETS) {
187-
draw_route(ALL_NETS, g);
188-
189-
if (draw_state->highlight_fan_in_fan_out) {
190-
draw_route(HIGHLIGHTED, g);
190+
if (draw_state->highlight_fan_in_fan_out) {
191+
draw_route(HIGHLIGHTED, g);
192+
}
191193
}
192-
}
193194

194-
draw_congestion(g);
195+
draw_congestion(g);
195196

196-
draw_routing_costs(g);
197+
draw_routing_costs(g);
197198

198-
draw_router_expansion_costs(g);
199+
draw_router_expansion_costs(g);
199200

200-
draw_routing_util(g);
201+
draw_routing_util(g);
201202

202-
draw_routing_bb(g);
203-
}
203+
draw_routing_bb(g);
204+
}
204205

205-
draw_placement_macros(g);
206+
draw_placement_macros(g);
206207

207208
#ifndef NO_SERVER
208-
if (g_vpr_ctx.server().gate_io.is_running()) {
209-
const ServerContext& server_ctx = g_vpr_ctx.server(); // shortcut
210-
draw_crit_path_elements(server_ctx.crit_paths, server_ctx.crit_path_element_indexes, server_ctx.draw_crit_path_contour, g);
211-
} else {
212-
draw_crit_path(g);
213-
}
209+
if (g_vpr_ctx.server().gate_io.is_running()) {
210+
const ServerContext& server_ctx = g_vpr_ctx.server(); // shortcut
211+
draw_crit_path_elements(server_ctx.crit_paths, server_ctx.crit_path_element_indexes, server_ctx.draw_crit_path_contour, g);
212+
} else {
213+
draw_crit_path(g);
214+
}
214215
#else
215-
draw_crit_path(g);
216+
draw_crit_path(g);
216217
#endif /* NO_SERVER */
217218

218-
draw_logical_connections(g);
219+
draw_logical_connections(g);
219220

220-
draw_selected_pb_flylines(g);
221+
draw_selected_pb_flylines(g);
221222

222-
draw_noc(g);
223+
draw_noc(g);
223224

224-
if (draw_state->draw_partitions) {
225-
highlight_all_regions(g);
226-
draw_constrained_atoms(g);
227-
}
225+
if (draw_state->draw_partitions) {
226+
highlight_all_regions(g);
227+
draw_constrained_atoms(g);
228+
}
228229

229-
if (draw_state->color_map) {
230-
draw_color_map_legend(*draw_state->color_map, g);
231-
draw_state->color_map.reset(); //Free color map in preparation for next redraw
230+
if (draw_state->color_map) {
231+
draw_color_map_legend(*draw_state->color_map, g);
232+
draw_state->color_map.reset(); //Free color map in preparation for next redraw
233+
}
234+
} else {
235+
draw_analytical_place(g);
232236
}
233-
234237
if (draw_state->auto_proceed) {
235238
//Automatically exit the event loop, so user's don't need to manually click proceed
236239

@@ -302,16 +305,28 @@ void update_screen(ScreenUpdatePriority priority, const char* msg, enum pic_type
302305

303306
state_change = true;
304307

308+
if (pic_on_screen_val == ANALYTICAL_PLACEMENT) {
309+
set_initial_world_ap();
310+
} else {
311+
set_initial_world();
312+
}
313+
305314
if (draw_state->pic_on_screen == NO_PICTURE) {
306315
// Only add the canvas the first time we open graphics
307-
application.add_canvas("MainCanvas", draw_main_canvas,
308-
initial_world);
316+
application.add_canvas("MainCanvas", draw_main_canvas, initial_world);
317+
} else {
318+
// TODO: will this ever be null?
319+
auto canvas = application.get_canvas(application.get_main_canvas_id());
320+
if (canvas != nullptr) {
321+
canvas->get_camera().set_world(initial_world);
322+
}
309323
}
310324

311325
draw_state->setup_timing_info = setup_timing_info;
312326
draw_state->pic_on_screen = pic_on_screen_val;
313327
}
314328

329+
// What is this? Always true!
315330
bool should_pause = int(priority) >= draw_state->gr_automode;
316331

317332
//If there was a state change, we must call ezgl::application::run() to update the buttons.
@@ -481,7 +496,16 @@ void init_draw_coords(float clb_width, const BlkLocRegistry& blk_loc_registry) {
481496
//Margin beyond edge of the drawn device to extend the visible world
482497
//Setting this to > 0.0 means 'Zoom Fit' leave some fraction of white
483498
//space around the device edges
499+
#else
500+
(void)clb_width;
501+
(void)blk_loc_registry;
502+
#endif /* NO_GRAPHICS */
503+
}
504+
505+
void set_initial_world() {
484506
constexpr float VISIBLE_MARGIN = 0.01;
507+
t_draw_coords* draw_coords = get_draw_coords_vars();
508+
const DeviceContext& device_ctx = g_vpr_ctx.device();
485509

486510
float draw_width = draw_coords->tile_x[device_ctx.grid.width() - 1]
487511
+ draw_coords->get_tile_width();
@@ -491,11 +515,11 @@ void init_draw_coords(float clb_width, const BlkLocRegistry& blk_loc_registry) {
491515
initial_world = ezgl::rectangle(
492516
{-VISIBLE_MARGIN * draw_width, -VISIBLE_MARGIN * draw_height},
493517
{(1. + VISIBLE_MARGIN) * draw_width, (1. + VISIBLE_MARGIN)
494-
* draw_height});
495-
#else
496-
(void)clb_width;
497-
(void)blk_loc_registry;
498-
#endif /* NO_GRAPHICS */
518+
* draw_height});
519+
}
520+
521+
void set_initial_world_ap() {
522+
initial_world = ezgl::rectangle({-1, -1}, {1, 1});
499523
}
500524

501525
#ifndef NO_GRAPHICS

vpr/src/draw/draw.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ void update_screen(ScreenUpdatePriority priority, const char* msg, enum pic_type
5252
*/
5353
void init_draw_coords(float clb_width, const BlkLocRegistry& blk_loc_registry);
5454

55+
void set_initial_world_ap();
56+
void set_initial_world();
57+
5558
/* Sets the static show_graphics and gr_automode variables to the *
5659
* desired values. They control if graphics are enabled and, if so, *
5760
* how often the user is prompted for input. */

vpr/src/draw/draw_basic.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,15 @@ void drawplace(ezgl::renderer* g) {
193193
}
194194
}
195195

196+
void draw_analytical_place(ezgl::renderer* g) {
197+
// Fill the entire visible world with green
198+
ezgl::rectangle vw = g->get_visible_world();
199+
g->set_line_dash(ezgl::line_dash::none);
200+
g->set_line_width(0);
201+
g->set_color(ezgl::color(0, 180, 0)); // green fill
202+
g->fill_rectangle(vw);
203+
}
204+
196205
/* This routine draws the nets on the placement. The nets have not *
197206
* yet been routed, so we just draw a chain showing a possible path *
198207
* for each net. This gives some idea of future congestion. */

vpr/src/draw/draw_basic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
* Blocks are drawn in layer order (so that semi-transparent blocks/grids render well)*/
3030
void drawplace(ezgl::renderer* g);
3131

32+
void draw_analytical_place(ezgl::renderer* g);
33+
3234
/** This routine draws the nets on the placement. The nets have not
3335
* yet been routed, so we just draw a chain showing a possible path
3436
* for each net. This gives some idea of future congestion.

0 commit comments

Comments
 (0)