2424#include < X11/keysym.h>
2525#endif
2626
27- void draw_chany_to_chany_edge (RRNodeId from_node, RRNodeId to_node, short switch_type , ezgl::renderer* g) {
27+ void draw_chany_to_chany_edge (RRNodeId from_node, RRNodeId to_node, RRSwitchId rr_switch_id , ezgl::renderer* g) {
2828 t_draw_coords* draw_coords = get_draw_coords_vars ();
2929 const DeviceContext& device_ctx = g_vpr_ctx.device ();
3030 const RRGraphView& rr_graph = device_ctx.rr_graph ;
3131
32- /* Draws a connection between two y-channel segments. Passing in the track *
33- * numbers allows this routine to be used for both rr_graph and routing *
34- * drawing-> */
35-
36- float x1, x2, y1, y2;
37- ezgl::rectangle from_chan;
38- ezgl::rectangle to_chan;
39- int from_ylow, to_ylow, from_yhigh, to_yhigh; // , from_x, to_x;
40-
4132 // Get the coordinates of the channel wires.
42- from_chan = draw_get_rr_chan_bbox (from_node);
43- to_chan = draw_get_rr_chan_bbox (to_node);
44-
45- // from_x = rr_graph.node_xlow(RRNodeId(from_node));
46- // to_x = rr_graph.node_xlow(RRNodeId(to_node));
47- from_ylow = rr_graph.node_ylow (from_node);
48- from_yhigh = rr_graph.node_yhigh (from_node);
49- to_ylow = rr_graph.node_ylow (to_node);
50- to_yhigh = rr_graph.node_yhigh (to_node);
33+ ezgl::rectangle from_chan = draw_get_rr_chan_bbox (from_node);
34+ ezgl::rectangle to_chan = draw_get_rr_chan_bbox (to_node);
5135
52- /* (x1, y1) point on from_node, (x2, y2) point on to_node. */
36+ int from_ylow = rr_graph.node_ylow (from_node);
37+ int from_yhigh = rr_graph.node_yhigh (from_node);
38+ int to_ylow = rr_graph.node_ylow (to_node);
39+ int to_yhigh = rr_graph.node_yhigh (to_node);
5340
54- x1 = from_chan.left ();
55- x2 = to_chan.left ();
41+ // (x1, y1) point on from_node, (x2, y2) point on to_node.
42+ float x1 = from_chan.left ();
43+ float x2 = to_chan.left ();
5644
57- if (to_yhigh < from_ylow) { /* From upper to lower */
45+ float y1, y2;
46+ if (to_yhigh < from_ylow) { // From upper to lower
5847 y1 = from_chan.bottom ();
5948 y2 = to_chan.top ();
60- } else if (to_ylow > from_yhigh) { /* From lower to upper */
49+ } else if (to_ylow > from_yhigh) { // From lower to upper
6150 y1 = from_chan.top ();
6251 y2 = to_chan.bottom ();
6352 }
64-
65- /* Segments overlap in the channel. Figure out best way to draw. Have to *
66- * make sure the drawing is symmetric in the from rr and to rr so the edges *
67- * will be drawn on top of each other for bidirectional connections. */
68-
69- /* UDSD Modification by WMF Begin */
53+ // Segments overlap in the channel. Figure out the best way to draw. Have to
54+ // make sure the drawing is symmetric in the from rr and to rr so the edges
55+ // will be drawn on top of each other for bidirectional connections.
7056 else {
7157 if (rr_graph.node_direction (to_node) != Direction::BIDIR) {
72- if (rr_graph.node_direction (to_node) == Direction::INC) { /* INC wire starts at bottom edge */
58+ if (rr_graph.node_direction (to_node) == Direction::INC) { // INC wire starts at bottom edge
7359
7460 y2 = to_chan.bottom ();
75- /* since no U-turns from_tracks must be INC as well */
61+ // since no U-turns from_tracks must be INC as well
7662 y1 = draw_coords->tile_y [to_ylow - 1 ]
7763 + draw_coords->get_tile_width ();
78- } else { /* DEC wire starts at top edge */
64+ } else { // DEC wire starts at top edge
7965
8066 y2 = to_chan.top ();
8167 y1 = draw_coords->tile_y [to_yhigh + 1 ];
8268 }
8369 } else {
84- if (to_ylow < from_ylow) { /* Draw from bottom edge of one to other. */
70+ if (to_ylow < from_ylow) { // Draw from bottom edge of one to other.
8571 y1 = from_chan.bottom ();
8672 y2 = draw_coords->tile_y [from_ylow - 1 ]
8773 + draw_coords->get_tile_width ();
8874 } else if (from_ylow < to_ylow) {
8975 y1 = draw_coords->tile_y [to_ylow - 1 ]
9076 + draw_coords->get_tile_width ();
9177 y2 = to_chan.bottom ();
92- } else if (to_yhigh > from_yhigh) { /* Draw from top edge of one to other. */
78+ } else if (to_yhigh > from_yhigh) { // Draw from top edge of one to other.
9379 y1 = from_chan.top ();
9480 y2 = draw_coords->tile_y [from_yhigh + 1 ];
9581 } else if (from_yhigh > to_yhigh) {
9682 y1 = draw_coords->tile_y [to_yhigh + 1 ];
9783 y2 = to_chan.top ();
98- } else { /* Complete overlap: start and end both align. Draw outside the sbox */
84+ } else { // Complete overlap: start and end both align. Draw outside the sbox
9985 y1 = from_chan.bottom ();
10086 y2 = from_chan.bottom () + draw_coords->get_tile_width ();
10187 }
10288 }
10389 }
10490
105- /* UDSD Modification by WMF End */
10691 g->draw_line ({x1, y1}, {x2, y2});
10792
10893 draw_rr_switch (x1, y1, x2, y2,
109- rr_graph.rr_switch_inf (RRSwitchId (switch_type) ).buffered (),
110- rr_graph.rr_switch_inf (RRSwitchId (switch_type) ).configurable (), g);
94+ rr_graph.rr_switch_inf (rr_switch_id ).buffered (),
95+ rr_graph.rr_switch_inf (rr_switch_id ).configurable (), g);
11196}
11297
113- void draw_chanx_to_chanx_edge (RRNodeId from_node, RRNodeId to_node, short switch_type, ezgl::renderer* g) {
114- /* Draws a connection between two x-channel segments. Passing in the track *
115- * numbers allows this routine to be used for both rr_graph and routing *
116- * drawing-> */
117-
98+ void draw_chanx_to_chanx_edge (RRNodeId from_node, RRNodeId to_node, RRSwitchId rr_switch_id, ezgl::renderer* g) {
11899 t_draw_coords* draw_coords = get_draw_coords_vars ();
119100 const DeviceContext& device_ctx = g_vpr_ctx.device ();
120101 const RRGraphView& rr_graph = device_ctx.rr_graph ;
121102
122- float x1, x2, y1, y2;
123- ezgl::rectangle from_chan;
124- ezgl::rectangle to_chan;
125- int from_xlow, to_xlow, from_xhigh, to_xhigh;
126-
127103 // Get the coordinates of the channel wires.
128- from_chan = draw_get_rr_chan_bbox (from_node);
129- to_chan = draw_get_rr_chan_bbox (to_node);
130-
131- /* (x1, y1) point on from_node, (x2, y2) point on to_node. */
132-
133- y1 = from_chan.bottom ();
134- y2 = to_chan.bottom ();
135-
136- from_xlow = rr_graph.node_xlow (from_node);
137- from_xhigh = rr_graph.node_xhigh (from_node);
138- to_xlow = rr_graph.node_xlow (to_node);
139- to_xhigh = rr_graph.node_xhigh (to_node);
104+ ezgl::rectangle from_chan = draw_get_rr_chan_bbox (from_node);
105+ ezgl::rectangle to_chan = draw_get_rr_chan_bbox (to_node);
106+
107+ // (x1, y1) point on from_node, (x2, y2) point on to_node.
108+ float x1, x2;
109+ float y1 = from_chan.bottom ();
110+ float y2 = to_chan.bottom ();
111+
112+ int from_xlow = rr_graph.node_xlow (from_node);
113+ int from_xhigh = rr_graph.node_xhigh (from_node);
114+ int to_xlow = rr_graph.node_xlow (to_node);
115+ int to_xhigh = rr_graph.node_xhigh (to_node);
140116 if (to_xhigh < from_xlow) { /* From right to left */
141- /* UDSD Note by WMF: could never happen for INC wires, unless U-turn. For DEC
142- * wires this handles well */
117+ // Could never happen for INC wires, unless U-turn. For DEC wires this handles well
143118 x1 = from_chan.left ();
144119 x2 = to_chan.right ();
145120 } else if (to_xlow > from_xhigh) { /* From left to right */
146- /* UDSD Note by WMF: could never happen for DEC wires, unless U-turn. For INC
147- * wires this handles well */
121+ // Could never happen for DEC wires, unless U-turn. For INC wires this handles well
148122 x1 = from_chan.right ();
149123 x2 = to_chan.left ();
150124 }
151-
152125 /* Segments overlap in the channel. Figure out best way to draw. Have to *
153126 * make sure the drawing is symmetric in the from rr and to rr so the edges *
154127 * will be drawn on top of each other for bidirectional connections. */
155-
156128 else {
157129 if (rr_graph.node_direction (to_node) != Direction::BIDIR) {
158- /* must connect to to_node's wire beginning at x2 */
159- if (rr_graph.node_direction (to_node) == Direction::INC) { /* INC wire starts at leftmost edge */
130+ // must connect to to_node's wire beginning at x2
131+ if (rr_graph.node_direction (to_node) == Direction::INC) { // INC wire starts at leftmost edge
160132 VTR_ASSERT (from_xlow < to_xlow);
161133 x2 = to_chan.left ();
162- /* since no U-turns from_tracks must be INC as well */
134+ // since no U-turns from_tracks must be INC as well
163135 x1 = draw_coords->tile_x [to_xlow - 1 ]
164136 + draw_coords->get_tile_width ();
165- } else { /* DEC wire starts at rightmost edge */
137+ } else { // DEC wire starts at rightmost edge
166138 VTR_ASSERT (from_xhigh > to_xhigh);
167139 x2 = to_chan.right ();
168140 x1 = draw_coords->tile_x [to_xhigh + 1 ];
169141 }
170142 } else {
171- if (to_xlow < from_xlow) { /* Draw from left edge of one to other */
143+ if (to_xlow < from_xlow) { // Draw from left edge of one to other
172144 x1 = from_chan.left ();
173145 x2 = draw_coords->tile_x [from_xlow - 1 ]
174146 + draw_coords->get_tile_width ();
@@ -177,14 +149,14 @@ void draw_chanx_to_chanx_edge(RRNodeId from_node, RRNodeId to_node, short switch
177149 + draw_coords->get_tile_width ();
178150 x2 = to_chan.left ();
179151
180- } /* The following then is executed when from_xlow == to_xlow */
181- else if (to_xhigh > from_xhigh) { /* Draw from right edge of one to other */
152+ } // The following then is executed when from_xlow == to_xlow
153+ else if (to_xhigh > from_xhigh) { // Draw from right edge of one to other
182154 x1 = from_chan.right ();
183155 x2 = draw_coords->tile_x [from_xhigh + 1 ];
184156 } else if (from_xhigh > to_xhigh) {
185157 x1 = draw_coords->tile_x [to_xhigh + 1 ];
186158 x2 = to_chan.right ();
187- } else { /* Complete overlap: start and end both align. Draw outside the sbox */
159+ } else { // Complete overlap: start and end both align. Draw outside the sbox
188160 x1 = from_chan.left ();
189161 x2 = from_chan.left () + draw_coords->get_tile_width ();
190162 }
@@ -194,77 +166,75 @@ void draw_chanx_to_chanx_edge(RRNodeId from_node, RRNodeId to_node, short switch
194166 g->draw_line ({x1, y1}, {x2, y2});
195167
196168 draw_rr_switch (x1, y1, x2, y2,
197- rr_graph.rr_switch_inf (RRSwitchId (switch_type) ).buffered (),
198- rr_graph.rr_switch_inf (RRSwitchId (switch_type) ).configurable (), g);
169+ rr_graph.rr_switch_inf (rr_switch_id ).buffered (),
170+ rr_graph.rr_switch_inf (rr_switch_id ).configurable (), g);
199171}
200172
201- void draw_chanx_to_chany_edge (RRNodeId chanx_node, RRNodeId chany_node, enum e_chan_edge_dir edge_dir, short switch_type, ezgl::renderer* g) {
173+ void draw_chanx_to_chany_edge (RRNodeId chanx_node,
174+ RRNodeId chany_node,
175+ e_chan_edge_dir edge_dir,
176+ RRSwitchId rr_switch_id,
177+ ezgl::renderer* g) {
202178 t_draw_coords* draw_coords = get_draw_coords_vars ();
203179 const DeviceContext& device_ctx = g_vpr_ctx.device ();
204180 const RRGraphView& rr_graph = device_ctx.rr_graph ;
205181
206- /* Draws an edge (SBOX connection) between an x-directed channel and a *
207- * y-directed channel. */
208-
209- float x1, y1, x2, y2;
210- ezgl::rectangle chanx_bbox;
211- ezgl::rectangle chany_bbox;
212- int chanx_xlow, chany_x, chany_ylow, chanx_y;
213-
214- /* Get the coordinates of the CHANX and CHANY segments. */
215- chanx_bbox = draw_get_rr_chan_bbox (chanx_node);
216- chany_bbox = draw_get_rr_chan_bbox (chany_node);
182+ const t_rr_switch_inf& rr_switch_inf = rr_graph.rr_switch_inf (rr_switch_id);
217183
218- /* (x1,y1): point on CHANX segment, (x2,y2): point on CHANY segment. */
184+ // Get the coordinates of the CHANX and CHANY segments.
185+ ezgl::rectangle chanx_bbox = draw_get_rr_chan_bbox (chanx_node);
186+ ezgl::rectangle chany_bbox = draw_get_rr_chan_bbox (chany_node);
219187
220- y1 = chanx_bbox.bottom ();
221- x2 = chany_bbox.left ();
188+ // (x1,y1): point on CHANX segment, (x2,y2): point on CHANY segment.
189+ float y1 = chanx_bbox.bottom ();
190+ float x2 = chany_bbox.left ();
191+ float x1, y2;
222192
223- // these values xhigh/low yhigh/low mark the cordinates for the begining and ends of the wire.
224- chanx_xlow = rr_graph.node_xlow (chanx_node);
225- chanx_y = rr_graph.node_ylow (chanx_node);
226- chany_x = rr_graph.node_xlow (chany_node);
227- chany_ylow = rr_graph.node_ylow (chany_node);
193+ // these values xhigh/low yhigh/low mark the coordinates for the beginning and ends of the wire.
194+ int chanx_xlow = rr_graph.node_xlow (chanx_node);
195+ int chanx_y = rr_graph.node_ylow (chanx_node);
196+ int chany_x = rr_graph.node_xlow (chany_node);
197+ int chany_ylow = rr_graph.node_ylow (chany_node);
228198
229- if (chanx_xlow <= chany_x) { /* Can draw connection going right */
230- /* Connection not at end of the CHANX segment. */
199+ if (chanx_xlow <= chany_x) { // Can draw connection going right
200+ // Connection not at end of the CHANX segment.
231201 x1 = draw_coords->tile_x [chany_x] + draw_coords->get_tile_width ();
232- if (rr_graph.node_direction (chanx_node) != Direction::BIDIR && (e_switch_type)switch_type != e_switch_type::SHORT) {
233- if (edge_dir == FROM_X_TO_Y) {
234- if (rr_graph.node_direction (chanx_node) == Direction::DEC) { /* If dec wire, then going left */
202+ if (rr_graph.node_direction (chanx_node) != Direction::BIDIR && rr_switch_inf. type () != e_switch_type::SHORT) {
203+ if (edge_dir == e_chan_edge_dir:: FROM_X_TO_Y) {
204+ if (rr_graph.node_direction (chanx_node) == Direction::DEC) { // If dec wire, then going left
235205 x1 = draw_coords->tile_x [chany_x + 1 ];
236206 }
237207 }
238208 }
239- } else { /* Must draw connection going left. */
209+ } else { // Must draw connection going left.
240210 x1 = chanx_bbox.left ();
241211 }
242- if (chany_ylow <= chanx_y) { /* Can draw connection going up. */
243- /* Connection not at end of the CHANY segment. */
212+ if (chany_ylow <= chanx_y) { // Can draw connection going up.
213+ // Connection not at end of the CHANY segment.
244214 y2 = draw_coords->tile_y [chanx_y] + draw_coords->get_tile_width ();
245215
246- if (rr_graph.node_direction (chany_node) != Direction::BIDIR && (e_switch_type)switch_type != e_switch_type::SHORT) {
247- if (edge_dir == FROM_Y_TO_X) {
248- if (rr_graph.node_direction (chany_node) == Direction::DEC) { /* If dec wire, then going down */
216+ if (rr_graph.node_direction (chany_node) != Direction::BIDIR && rr_switch_inf. type () != e_switch_type::SHORT) {
217+ if (edge_dir == e_chan_edge_dir:: FROM_Y_TO_X) {
218+ if (rr_graph.node_direction (chany_node) == Direction::DEC) { // If dec wire, then going down
249219 y2 = draw_coords->tile_y [chanx_y + 1 ];
250220 }
251221 }
252222 }
253223
254- } else { /* Must draw connection going down. */
224+ } else { // Must draw connection going down.
255225 y2 = chany_bbox.bottom ();
256226 }
257227
258228 g->draw_line ({x1, y1}, {x2, y2});
259229
260- if (edge_dir == FROM_X_TO_Y) {
230+ if (edge_dir == e_chan_edge_dir:: FROM_X_TO_Y) {
261231 draw_rr_switch (x1, y1, x2, y2,
262- rr_graph. rr_switch_inf ( RRSwitchId (switch_type)) .buffered (),
263- rr_graph. rr_switch_inf ( RRSwitchId (switch_type)) .configurable (), g);
232+ rr_switch_inf.buffered (),
233+ rr_switch_inf.configurable (), g);
264234 } else {
265235 draw_rr_switch (x2, y2, x1, y1,
266- rr_graph. rr_switch_inf ( RRSwitchId (switch_type)) .buffered (),
267- rr_graph. rr_switch_inf ( RRSwitchId (switch_type)) .configurable (), g);
236+ rr_switch_inf.buffered (),
237+ rr_switch_inf.configurable (), g);
268238 }
269239}
270240
@@ -646,7 +616,7 @@ void draw_rr_edge(RRNodeId inode, RRNodeId prev_node, ezgl::color color, ezgl::r
646616void draw_inter_cluster_rr_edge (RRNodeId inode, RRNodeId prev_node, e_rr_type rr_type, e_rr_type prev_type, ezgl::renderer* g) {
647617 const RRGraphView& rr_graph = g_vpr_ctx.device ().rr_graph ;
648618 t_edge_size iedge = find_edge (prev_node, inode);
649- short switch_type = rr_graph.edge_switch (prev_node, iedge);
619+ RRSwitchId rr_switch_id = (RRSwitchId) rr_graph.edge_switch (prev_node, iedge);
650620
651621 switch (rr_type) {
652622 case e_rr_type::IPIN:
@@ -660,11 +630,11 @@ void draw_inter_cluster_rr_edge(RRNodeId inode, RRNodeId prev_node, e_rr_type rr
660630 case e_rr_type::CHANX:
661631 switch (prev_type) {
662632 case e_rr_type::CHANX:
663- draw_chanx_to_chanx_edge (prev_node, inode, switch_type , g);
633+ draw_chanx_to_chanx_edge (prev_node, inode, rr_switch_id , g);
664634 break ;
665635
666636 case e_rr_type::CHANY:
667- draw_chanx_to_chany_edge (inode, prev_node, FROM_Y_TO_X, switch_type , g);
637+ draw_chanx_to_chany_edge (inode, prev_node, e_chan_edge_dir:: FROM_Y_TO_X, rr_switch_id , g);
668638 break ;
669639
670640 case e_rr_type::OPIN:
@@ -682,13 +652,11 @@ void draw_inter_cluster_rr_edge(RRNodeId inode, RRNodeId prev_node, e_rr_type rr
682652 case e_rr_type::CHANY:
683653 switch (prev_type) {
684654 case e_rr_type::CHANX:
685- draw_chanx_to_chany_edge (prev_node, inode,
686- FROM_X_TO_Y, switch_type, g);
655+ draw_chanx_to_chany_edge (prev_node, inode, e_chan_edge_dir::FROM_X_TO_Y, rr_switch_id, g);
687656 break ;
688657
689658 case e_rr_type::CHANY:
690- draw_chany_to_chany_edge (prev_node, inode,
691- switch_type, g);
659+ draw_chany_to_chany_edge (prev_node, inode, rr_switch_id, g);
692660 break ;
693661
694662 case e_rr_type::OPIN:
0 commit comments