@@ -96,7 +96,6 @@ static void draw_routing_bb(ezgl::renderer* g);
96
96
static void draw_routing_util (ezgl::renderer* g);
97
97
static void draw_crit_path (ezgl::renderer* g);
98
98
static void draw_placement_macros (ezgl::renderer* g);
99
- static void draw_noc (ezgl::renderer* g);
100
99
101
100
void act_on_key_press (ezgl::application* /* app*/ , GdkEventKey* /* event*/ , char * key_name);
102
101
void act_on_mouse_press (ezgl::application* app, GdkEventButton* event, double x, double y);
@@ -154,8 +153,6 @@ static bool trace_routed_connection_rr_nodes_recurr(const t_rt_node* rt_node,
154
153
std::vector<int >& rr_nodes_on_path);
155
154
static t_edge_size find_edge (int prev_inode, int inode);
156
155
157
- static void draw_color_map_legend (const vtr::ColorMap& cmap, ezgl::renderer* g);
158
-
159
156
ezgl::color lighten_color (ezgl::color color, float amount);
160
157
161
158
static void draw_block_pin_util ();
@@ -189,26 +186,13 @@ static void set_block_text(GtkWidget* widget, gint /*response_id*/, gpointer /*d
189
186
static void clip_routing_util (GtkWidget* widget, gint /* response_id*/ , gpointer /* data*/ );
190
187
static void run_graphics_commands (std::string commands);
191
188
192
- // draw_noc helper functions
193
- static ezgl::rectangle get_noc_connection_marker_bbox (const t_logical_block_type_ptr noc_router_logical_block_type);
194
-
195
- static void draw_noc_connection_marker (ezgl::renderer* g, const vtr::vector<NocRouterId, NocRouter>& router_list, ezgl::rectangle connection_marker_bbox);
196
-
197
- static void draw_noc_links (ezgl::renderer* g, const t_logical_block_type_ptr noc_router_logical_block_type, vtr::vector<NocLinkId, ezgl::color>& noc_link_colors, ezgl::rectangle noc_connection_marker_bbox, const vtr::vector<NocLinkId, NocLinkShift>& list_of_noc_link_shift_directions);
198
-
199
- static void draw_noc_usage (vtr::vector<NocLinkId, ezgl::color>& noc_link_colors);
200
-
201
189
/* ************************* File Scope Variables ****************************/
202
190
203
191
// The arrow head position for turning/straight-thru connections in a switch box
204
192
constexpr float SB_EDGE_TURN_ARROW_POSITION = 0.2 ;
205
193
constexpr float SB_EDGE_STRAIGHT_ARROW_POSITION = 0.95 ;
206
194
constexpr float EMPTY_BLOCK_LIGHTEN_FACTOR = 0.20 ;
207
195
208
- // defines the area of the marker that represents connection points between links
209
- // area is equivalent to the %x of the area of the router
210
- constexpr float SIZE_OF_NOC_MARKER = 0.30 ;
211
-
212
196
// Kelly's maximum contrast colors are selected to be easily distinguishable as described in:
213
197
// Kenneth Kelly, "Twenty-Two Colors of Maximum Contrast", Color Eng. 3(6), 1943
214
198
// We use these to highlight a relatively small number of things (e.g. stages in a critical path,
@@ -3680,292 +3664,6 @@ static void draw_routed_timing_edge(tatum::NodeId start_tnode,
3680
3664
g->set_line_dash (ezgl::line_dash::none);
3681
3665
}
3682
3666
3683
- /*
3684
- * Draw the NoC by drawing the links of the NoC and highlights the connection points between links.The drawing is done on top of all the placment and routing, so this acts as an overlay.
3685
- *
3686
- */
3687
- static void draw_noc (ezgl::renderer* g) {
3688
- t_draw_state* draw_state = get_draw_state_vars ();
3689
- auto & noc_ctx = g_vpr_ctx.noc ();
3690
- auto & device_ctx = g_vpr_ctx.device ();
3691
-
3692
- // vector of routers in the NoC
3693
- vtr::vector<NocRouterId, NocRouter> router_list = noc_ctx.noc_model .get_noc_routers ();
3694
-
3695
- // a vector of colors to use for the NoC links, determines the colors used when drawing each link
3696
- vtr::vector<NocLinkId, ezgl::color> noc_link_colors;
3697
-
3698
- // initialize all the link colors to black and set the vector size to the total number of links
3699
- noc_link_colors.resize (noc_ctx.noc_model .get_noc_links ().size (), ezgl::BLACK);
3700
-
3701
- // variables to keep track of how each link is drawn
3702
- vtr::vector<NocLinkId, NocLinkShift> list_of_noc_link_shift_directions;
3703
-
3704
- // initialize all the link shift directions to no shift and set the vector size to the total number of links
3705
- list_of_noc_link_shift_directions.resize (noc_ctx.noc_model .get_noc_links ().size (), NocLinkShift::NO_SHIFT);
3706
-
3707
- // start by checking to see if the NoC display button was selected
3708
- // if the noc display option was not selected then don't draw the noc
3709
- if (draw_state->draw_noc == DRAW_NO_NOC) {
3710
- return ;
3711
- }
3712
-
3713
- // check that the NoC tile has a capacity greater than 0 (can we assume it always will?) and if not then we cant draw anythign as the NoC tile wont be drawn
3714
- /* since the vector of routers all have a reference positions on the grid to the corresponding physical tile, just use the first router in the vector and get its position, then use this to get the capcity of a noc router tile
3715
- */
3716
- int num_subtiles = device_ctx.grid [router_list.begin ()->get_router_grid_position_x ()][router_list.begin ()->get_router_grid_position_y ()].type ->capacity ;
3717
-
3718
- if (num_subtiles == 0 ) {
3719
- return ;
3720
- }
3721
-
3722
- // get the logical type of a noc router tile
3723
- t_logical_block_type_ptr noc_router_logical_type = pick_logical_type (device_ctx.grid [router_list.begin ()->get_router_grid_position_x ()][router_list.begin ()->get_router_grid_position_y ()].type );
3724
-
3725
- // Now construct the coordinates for the markers that represent the connections between links (relative to the noc router tile position)
3726
- ezgl::rectangle noc_connection_marker_bbox = get_noc_connection_marker_bbox (noc_router_logical_type);
3727
-
3728
- // only draw the noc useage if the user selected the option
3729
- if (draw_state->draw_noc == DRAW_NOC_LINK_USAGE) {
3730
- draw_noc_usage (noc_link_colors);
3731
-
3732
- // draw the color map legend
3733
- draw_color_map_legend (*(draw_state->noc_usage_color_map ), g);
3734
- }
3735
-
3736
- // go through all the pairs of parallel links (if there are any) and assign a shift direction to them.
3737
- // One link will shift in one direction (knows as TOP) and the other link will shift in the opposite direction (known as BOTTOM)
3738
- determine_direction_to_shift_noc_links (list_of_noc_link_shift_directions);
3739
-
3740
- draw_noc_links (g, noc_router_logical_type, noc_link_colors, noc_connection_marker_bbox, list_of_noc_link_shift_directions);
3741
-
3742
- draw_noc_connection_marker (g, router_list, noc_connection_marker_bbox);
3743
-
3744
- return ;
3745
- }
3746
-
3747
- /*
3748
- * Go through each NoC link and assign a color based on how much the link is being used (its bandwidth). The colors are determined from the PLasma colormap.
3749
- */
3750
- static void draw_noc_usage (vtr::vector<NocLinkId, ezgl::color>& noc_link_colors) {
3751
- t_draw_state* draw_state = get_draw_state_vars ();
3752
- auto & noc_ctx = g_vpr_ctx.noc ();
3753
-
3754
- // get the maximum badnwidth per link
3755
- double max_noc_link_bandwidth = noc_ctx.noc_model .get_noc_link_bandwidth ();
3756
-
3757
- // check to see if a color map was already created previously
3758
- if (draw_state->noc_usage_color_map == nullptr ) {
3759
- // we havent created a color map yet for the noc link usage, so create it here
3760
- // the color map creates a color spectrum that gradually changes from a dark to light color. Where a dark color represents low noc link usage (low bandwidth) and a light color represents high noc link usage (high bandwidth)
3761
- // The color map needs a min and max value to generate the color range.
3762
- // The noc usage is calculated by taking the ratio of the links current bandwidth over the maximum allowable bandwidth
3763
- // for the NoC, the min value is 0, since you cannot go lower than 0 badnwidth.
3764
- // The max value is going to be 1 and represents the case where the link is used to full capacity on the noc link (as provided by the user)
3765
- draw_state->noc_usage_color_map = std::make_shared<vtr::PlasmaColorMap>(0.0 , 1.0 );
3766
- }
3767
-
3768
- // get the list of links in the NoC
3769
- vtr::vector<NocLinkId, NocLink> link_list = noc_ctx.noc_model .get_noc_links ();
3770
-
3771
- // store each links bandwidth usage
3772
- double link_bandwidth_usage;
3773
-
3774
- // represents the color to draw each noc link
3775
- ezgl::color current_noc_link_color;
3776
-
3777
- // now we need to determine the colors for each link
3778
- for (int link = 0 ; link < (int )link_list.size (); link++) {
3779
- // get the current link id
3780
- NocLinkId link_id (link);
3781
-
3782
- // only update the color of the link if it wasnt updated previously
3783
- if (noc_link_colors[link_id] == ezgl::BLACK) {
3784
- // if we are here then the link was not updated previously, so assign the color here
3785
-
3786
- // get the current link bandwidth usage (ratio calculation)
3787
- link_bandwidth_usage = (link_list[link_id].get_bandwidth_usage ()) / max_noc_link_bandwidth;
3788
-
3789
- // check if the link is being overused and if it is then cap it at 1.0
3790
- if (link_bandwidth_usage > 1.0 ) {
3791
- link_bandwidth_usage = 1.0 ;
3792
- }
3793
-
3794
- // get the corresponding color that represents the link bandwidth usgae
3795
- current_noc_link_color = to_ezgl_color (draw_state->noc_usage_color_map ->color (link_bandwidth_usage));
3796
-
3797
- // set the colors of the link
3798
- noc_link_colors[link_id] = current_noc_link_color;
3799
- }
3800
- }
3801
-
3802
- return ;
3803
- }
3804
-
3805
- /* ************ draw_noc helper functions below *************/
3806
-
3807
- /*
3808
- * This function calculates the position of the marker that will be drawn inside the noc router tile on the FPGA. This marker will be located in the center of the tile and represents a connection point between links that connect to the router.
3809
- */
3810
- static ezgl::rectangle get_noc_connection_marker_bbox (const t_logical_block_type_ptr noc_router_logical_block_type) {
3811
- t_draw_coords* draw_coords = get_draw_coords_vars ();
3812
-
3813
- // get the drawing information for a noc router
3814
- t_draw_pb_type_info& blk_type_info = draw_coords->blk_info .at (noc_router_logical_block_type->index );
3815
-
3816
- // get the drawing coordinates for the noc router tile
3817
- auto & pb_gnode = *noc_router_logical_block_type->pb_graph_head ;
3818
- ezgl::rectangle noc_router_pb_bbox = blk_type_info.get_pb_bbox (pb_gnode);
3819
-
3820
- /*
3821
- * The connection marker will be positioned at the center of the noc router tile. For example it will look like below:
3822
- *
3823
- *********************
3824
- * *
3825
- * *
3826
- * **** *
3827
- * * * *
3828
- * **** *
3829
- * *
3830
- * *
3831
- *********************
3832
- *
3833
- * We do the following to calculate the position of the marker:
3834
- * 1. Get the area of the larger router tile
3835
- * 2. Calculate the area of the marker (based on a predefined percentage of the area of the larger noc tile)
3836
- * 3. The marker is a square, so we can can calculate the lengths
3837
- * of the sides of the marker
3838
- * 4. Divide the side length by 2 and subtract this from the x & y coordinates of the center of the larger noc router tile. This is the bottom left corner of the rectangle.
3839
- * 5. Then add the side length to the x & y coordinate of the center of the larger noc router tile. THis is the top right corner of the rectangle.
3840
- */
3841
- double noc_router_bbox_area = noc_router_pb_bbox.area ();
3842
- ezgl::point2d noc_router_bbox_center = noc_router_pb_bbox.center ();
3843
-
3844
- double connection_marker_bbox_area = noc_router_bbox_area * SIZE_OF_NOC_MARKER;
3845
- double connection_marker_bbox_side_length = sqrt (connection_marker_bbox_area);
3846
-
3847
- double half_of_connection_marker_bbox_side_length = connection_marker_bbox_side_length / 2 ;
3848
-
3849
- // calculate bottom left corner coordinate of marker
3850
- ezgl::point2d connection_marker_origin_pt (noc_router_bbox_center.x - half_of_connection_marker_bbox_side_length, noc_router_bbox_center.y - half_of_connection_marker_bbox_side_length);
3851
- // calculate upper right corner coordinate of marker
3852
- ezgl::point2d connection_marker_top_right_pt (noc_router_bbox_center.x + half_of_connection_marker_bbox_side_length, noc_router_bbox_center.y + half_of_connection_marker_bbox_side_length);
3853
-
3854
- ezgl::rectangle connection_marker_bbox (connection_marker_origin_pt, connection_marker_top_right_pt);
3855
-
3856
- return connection_marker_bbox;
3857
- }
3858
-
3859
- /*
3860
- * This function draws the markers inside the noc router tiles. This marker represents a connection that is an intersection points between multiple links.
3861
- */
3862
- static void draw_noc_connection_marker (ezgl::renderer* g, const vtr::vector<NocRouterId, NocRouter>& router_list, ezgl::rectangle connection_marker_bbox) {
3863
- t_draw_coords* draw_coords = get_draw_coords_vars ();
3864
-
3865
- // set the color of the marker
3866
- g->set_color (ezgl::BLACK);
3867
-
3868
- int router_grid_position_x = 0 ;
3869
- int router_grid_position_y = 0 ;
3870
-
3871
- ezgl::rectangle updated_connection_marker_bbox;
3872
-
3873
- // go through the routers and create the connection marker
3874
- for (auto router = router_list.begin (); router != router_list.end (); router++) {
3875
- router_grid_position_x = router->get_router_grid_position_x ();
3876
- router_grid_position_y = router->get_router_grid_position_y ();
3877
-
3878
- // get the coordinates to draw the marker given the current routers tile position
3879
- updated_connection_marker_bbox = connection_marker_bbox + ezgl::point2d (draw_coords->tile_x [router_grid_position_x], draw_coords->tile_y [router_grid_position_y]);
3880
-
3881
- // draw the marker
3882
- g->fill_rectangle (updated_connection_marker_bbox);
3883
- }
3884
-
3885
- return ;
3886
- }
3887
-
3888
- /*
3889
- * This function draws the links within the noc. So based on a given noc topology, this function draws the links that connect the routers in the noc together.
3890
- */
3891
- static void draw_noc_links (ezgl::renderer* g, const t_logical_block_type_ptr noc_router_logical_block_type, vtr::vector<NocLinkId, ezgl::color>& noc_link_colors, ezgl::rectangle noc_connection_marker_bbox, const vtr::vector<NocLinkId, NocLinkShift>& list_of_noc_link_shift_directions) {
3892
- t_draw_coords* draw_coords = get_draw_coords_vars ();
3893
- auto & noc_ctx = g_vpr_ctx.noc ();
3894
-
3895
- // vector of routers in the NoC
3896
- vtr::vector<NocRouterId, NocRouter> router_list = noc_ctx.noc_model .get_noc_routers ();
3897
-
3898
- // get the links of the NoC
3899
- vtr::vector<NocLinkId, NocLink> link_list = noc_ctx.noc_model .get_noc_links ();
3900
-
3901
- // set the width of the link
3902
- g->set_line_width (2 );
3903
-
3904
- // routers connecting links
3905
- NocRouterId source_router;
3906
- NocRouterId sink_router;
3907
-
3908
- // source router grid coordinates
3909
- int source_router_x_position = 0 ;
3910
- int source_router_y_position = 0 ;
3911
-
3912
- // sink router grid coordinates
3913
- int sink_router_x_position = 0 ;
3914
- int sink_router_y_position = 0 ;
3915
-
3916
- // coordinates of source and sink routers
3917
- ezgl::rectangle abs_source_router_bbox;
3918
- ezgl::rectangle abs_sink_router_bbox;
3919
-
3920
- // the coordinates to draw the link
3921
- noc_link_draw_coords link_coords;
3922
-
3923
- // the type of the noc link
3924
- NocLinkType link_type;
3925
-
3926
- // get half the width and height of the noc connection marker
3927
- // we will shift the links based on this parameters since the links will be drawn at the boundaries of connection marker instead of the center
3928
- double noc_connection_marker_quarter_width = (noc_connection_marker_bbox.center ().x - noc_connection_marker_bbox.bottom_left ().x ) / 2 ;
3929
- double noc_connection_marker_quarter_height = (noc_connection_marker_bbox.center ().y - noc_connection_marker_bbox.bottom_left ().y ) / 2 ;
3930
-
3931
- // loop through the links and draw them
3932
- for (int link = 0 ; link < (int )link_list.size (); link++) {
3933
- // get the converted link if
3934
- NocLinkId link_id (link);
3935
-
3936
- // get the routers
3937
- source_router = link_list[link_id].get_source_router ();
3938
- sink_router = link_list[link_id].get_sink_router ();
3939
-
3940
- // calculate the grid positions of the source and sink routers
3941
- source_router_x_position = router_list[source_router].get_router_grid_position_x ();
3942
- source_router_y_position = router_list[source_router].get_router_grid_position_y ();
3943
-
3944
- sink_router_x_position = router_list[sink_router].get_router_grid_position_x ();
3945
- sink_router_y_position = router_list[sink_router].get_router_grid_position_y ();
3946
-
3947
- // get the initial drawing coordinates of the noc link
3948
- // it will be drawn from the center of two routers it connects
3949
- link_coords.start = draw_coords->get_absolute_clb_bbox (source_router_x_position, source_router_y_position, 0 , noc_router_logical_block_type).center ();
3950
- link_coords.end = draw_coords->get_absolute_clb_bbox (sink_router_x_position, sink_router_y_position, 0 , noc_router_logical_block_type).center ();
3951
-
3952
- // determine the current noc link type
3953
- link_type = determine_noc_link_type (link_coords.start , link_coords.end );
3954
-
3955
- shift_noc_link (link_coords, list_of_noc_link_shift_directions[link_id], link_type, noc_connection_marker_quarter_width, noc_connection_marker_quarter_height);
3956
-
3957
- // set the color to draw the current link
3958
- g->set_color (noc_link_colors[link_id]);
3959
-
3960
- // draw a line between the center of the two routers this link connects
3961
- g->draw_line (link_coords.start , link_coords.end );
3962
- }
3963
-
3964
- return ;
3965
- }
3966
-
3967
- /* ************ end of draw_noc helper functions *************/
3968
-
3969
3667
// Collect all the drawing locations associated with the timing edge between start and end
3970
3668
static void draw_routed_timing_edge_connection (tatum::NodeId src_tnode,
3971
3669
tatum::NodeId sink_tnode,
@@ -4125,7 +3823,7 @@ ezgl::color to_ezgl_color(vtr::Color<float> color) {
4125
3823
return ezgl::color (color.r * 255 , color.g * 255 , color.b * 255 );
4126
3824
}
4127
3825
4128
- static void draw_color_map_legend (const vtr::ColorMap& cmap,
3826
+ void draw_color_map_legend (const vtr::ColorMap& cmap,
4129
3827
ezgl::renderer* g) {
4130
3828
constexpr float LEGEND_WIDTH_FAC = 0.075 ;
4131
3829
constexpr float LEGEND_VERT_OFFSET_FAC = 0.05 ;
0 commit comments