Skip to content

Commit ba52c3a

Browse files
authored
Merge pull request #2049 from verilog-to-routing/draw_refactor
Refactored vpr/src/draw
2 parents 6c38ea7 + edd4f69 commit ba52c3a

24 files changed

+4497
-3526
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,4 @@ tags
140140
#
141141
.idea
142142
cmake-build-debug
143+
/.metadata/

vpr/src/draw/buttons.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
# include "draw_global.h"
1414
# include "draw.h"
15+
# include "draw_toggle_functions.h"
1516
# include "buttons.h"
1617
# include "intra_logic_block.h"
1718
# include "clustered_netlist.h"
@@ -36,7 +37,7 @@ void button_for_net_alpha() {
3637
gtk_grid_insert_column((GtkGrid*)grid, 0);
3738

3839
//text entry for apha value
39-
GtkWidget* alpha_widget = gtk_spin_button_new_with_range(0, 100, 1);
40+
GtkWidget* alpha_widget = gtk_spin_button_new_with_range(1, 255, 1);
4041
GtkWidget* alpha_label = gtk_label_new("Set Net Transparency:");
4142
gtk_widget_set_name(alpha_widget, "netAlpha");
4243

vpr/src/draw/draw.cpp

Lines changed: 157 additions & 3477 deletions
Large diffs are not rendered by default.

vpr/src/draw/draw.h

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,75 +15,68 @@
1515
# include "search_bar.h"
1616
# include "draw_debug.h"
1717
# include "manual_moves.h"
18+
# include "vtr_ndoffsetmatrix.h"
1819

1920
extern ezgl::application::settings settings;
2021
extern ezgl::application application;
2122

2223
#endif /* NO_GRAPHICS */
2324

2425
void update_screen(ScreenUpdatePriority priority, const char* msg, enum pic_type pic_on_screen_val, std::shared_ptr<SetupTimingInfo> timing_info);
26+
2527
//Initializes the drawing locations.
2628
//FIXME: Currently broken if no rr-graph is loaded
2729
void init_draw_coords(float clb_width);
2830

31+
/* Sets the static show_graphics and gr_automode variables to the *
32+
* desired values. They control if graphics are enabled and, if so, *
33+
* how often the user is prompted for input. */
2934
void init_graphics_state(bool show_graphics_val, int gr_automode_val, enum e_route_type route_type, bool save_graphics, std::string graphics_commands);
3035

36+
/* Allocates the structures needed to draw the placement and routing.*/
3137
void alloc_draw_structs(const t_arch* arch);
38+
39+
/* Free everything allocated by alloc_draw_structs. Called after close_graphics()
40+
* in vpr_api.c. */
3241
void free_draw_structs();
3342

3443
#ifndef NO_GRAPHICS
35-
36-
void draw_get_rr_pin_coords(int inode, float* xcen, float* ycen, const e_side& pin_side);
37-
void draw_get_rr_pin_coords(const t_rr_node& node, float* xcen, float* ycen, const e_side& pin_side);
38-
39-
void draw_triangle_along_line(ezgl::renderer* g, ezgl::point2d start, ezgl::point2d end, float relative_position = 1., float arrow_size = DEFAULT_ARROW_SIZE);
40-
void draw_triangle_along_line(ezgl::renderer* g, ezgl::point2d loc, ezgl::point2d start, ezgl::point2d end, float arrow_size = DEFAULT_ARROW_SIZE);
41-
void draw_triangle_along_line(ezgl::renderer* g, float xend, float yend, float x1, float x2, float y1, float y2, float arrow_size = DEFAULT_ARROW_SIZE);
42-
4344
const ezgl::color SELECTED_COLOR = ezgl::GREEN;
4445
const ezgl::color DRIVES_IT_COLOR = ezgl::RED;
4546
const ezgl::color DRIVEN_BY_IT_COLOR = ezgl::LIGHT_MEDIUM_BLUE;
4647

4748
const float WIRE_DRAWING_WIDTH = 0.5;
4849

50+
/* Find the edge between two rr nodes */
51+
t_edge_size find_edge(int prev_inode, int inode);
52+
53+
/* Returns the track number of this routing resource node inode. */
54+
int get_track_num(int inode, const vtr::OffsetMatrix<int>& chanx_track, const vtr::OffsetMatrix<int>& chany_track);
55+
4956
//Returns the drawing coordinates of the specified pin
5057
ezgl::point2d atom_pin_draw_coord(AtomPinId pin);
5158

5259
//Returns the drawing coordinates of the specified tnode
5360
ezgl::point2d tnode_draw_coord(tatum::NodeId node);
5461

55-
void annotate_draw_rr_node_costs(ClusterNetId net, int sink_rr_node);
56-
void clear_draw_rr_annotations();
57-
62+
/* Converts a vtr Color to a ezgl Color. */
5863
ezgl::color to_ezgl_color(vtr::Color<float> color);
5964

60-
void draw_screen();
61-
62-
// search bar related functions
63-
ezgl::rectangle draw_get_rr_chan_bbox(int inode);
64-
void draw_highlight_blocks_color(t_logical_block_type_ptr type, ClusterBlockId blk_id);
65-
void highlight_nets(char* message, int hit_node);
66-
void draw_highlight_fan_in_fan_out(const std::set<int>& nodes);
67-
std::set<int> draw_expand_non_configurable_rr_nodes(int hit_node);
68-
void deselect_all();
69-
70-
// toggle functions
71-
void toggle_nets(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/);
72-
void toggle_rr(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/);
73-
void toggle_congestion(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/);
74-
void toggle_routing_congestion_cost(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/);
75-
void toggle_routing_bounding_box(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/);
76-
void toggle_routing_util(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/);
77-
void toggle_crit_path(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/);
78-
void toggle_block_pin_util(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/);
79-
void toggle_router_expansion_costs(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/);
80-
void toggle_placement_macros(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/);
81-
void net_max_fanout(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/);
82-
void set_net_alpha_value(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/);
83-
void set_net_alpha_value_with_enter(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/);
84-
float get_net_alpha();
85-
86-
ezgl::color get_block_type_color(t_physical_tile_type_ptr type);
65+
/* This helper function determines whether a net has been highlighted. The highlighting
66+
* could be caused by the user clicking on a routing resource, toggled, or
67+
* fan-in/fan-out of a highlighted node. */
68+
bool draw_if_net_highlighted(ClusterNetId inet);
69+
std::vector<int> trace_routed_connection_rr_nodes(
70+
const ClusterNetId net_id,
71+
const int driver_pin,
72+
const int sink_pin);
73+
74+
/* Helper function for trace_routed_connection_rr_nodes
75+
* Adds the rr nodes linking rt_node to sink_rr_node to rr_nodes_on_path
76+
* Returns true if rt_node is on the path. */
77+
bool trace_routed_connection_rr_nodes_recurr(const t_rt_node* rt_node,
78+
int sink_rr_node,
79+
std::vector<int>& rr_nodes_on_path);
8780

8881
/* This routine highlights the blocks affected in the latest move *
8982
* It highlights the old and new locations of the moved blocks *
@@ -103,6 +96,13 @@ void clear_colored_locations();
10396
// otherwise, the function returns false (the location isn't among the highlighted locations)
10497
bool highlight_loc_with_specific_color(int x, int y, ezgl::color& loc_color);
10598

99+
/* Because the list of possible block type colours is finite, we wrap around possible colours if there are more
100+
* block types than colour choices. This ensures we support any number of types, although the colours may repeat.*/
101+
ezgl::color get_block_type_color(t_physical_tile_type_ptr type);
102+
103+
/* Lightens a color's luminance [0, 1] by an aboslute 'amount' */
104+
ezgl::color lighten_color(ezgl::color color, float amount);
105+
106106
#endif /* NO_GRAPHICS */
107107

108108
#endif /* DRAW_H */

0 commit comments

Comments
 (0)