21 #define MAX_BLOCK_COLOURS 5
87 static const char *
name_type[] = {
"SOURCE",
"SINK",
"IPIN",
"OPIN",
"CHANX",
"CHANY",
88 "INTRA_CLUSTER_EDGE" };
125 static void draw_x(
float x,
float y,
float size);
127 int to_track,
short switch_type);
129 int to_track,
short switch_type);
131 int chany_node,
int chany_track,
enum e_edge_dir edge_dir,
133 static int get_track_num(
int inode,
int **chanx_track,
int **chany_track);
134 static void draw_rr_switch(
float from_x,
float from_y,
float to_x,
float to_y,
157 boolean crit_path_button_enabled) {
176 if (crit_path_button_enabled) {
183 if (crit_path_button_enabled) {
186 }
else if (pic_on_screen_val ==
ROUTING
193 if (crit_path_button_enabled) {
291 int inode, num_congested;
307 sprintf(msg,
"%d routing resources are overused.", num_congested);
319 int inode, iblk, inet, num_nets_seen;
320 static int nets_to_highlight = 1;
323 if (nets_to_highlight == 0) {
324 nets_to_highlight = 1;
332 critical_path_node = critical_path_head;
335 while (critical_path_node != NULL) {
336 inode = critical_path_node->
data;
339 if (num_nets_seen == nets_to_highlight) {
341 }
else if (num_nets_seen == nets_to_highlight - 1) {
343 }
else if (num_nets_seen < nets_to_highlight) {
350 if (num_nets_seen < nets_to_highlight) {
352 }
else if (num_nets_seen == nets_to_highlight) {
357 critical_path_node = critical_path_node->
next;
360 if (nets_to_highlight == num_nets_seen) {
361 nets_to_highlight = 0;
362 sprintf(msg,
"All %d nets on the critical path highlighted.",
365 sprintf(msg,
"First %d nets on the critical path highlighted.",
470 for (i = 0; i < (
nx + 1); i++) {
477 for (i = 0; i < (
ny + 1); ++i) {
493 float x1, y1, x2, y2;
500 for (i = 0; i <= (
nx + 1); i++) {
501 for (j = 0; j <= (
ny + 1); j++) {
503 if (
grid[i][j].offset > 0)
507 if (((i < 1) || (i >
nx)) && ((j < 1) || (j >
ny)))
514 if (num_sub_tiles < 1) {
523 for (k = 0; k < num_sub_tiles; ++k) {
525 assert(height == 1 || num_sub_tiles == 1);
527 if ((i < 1) || (i >
nx)) {
529 y1 =
tile_y[j] + (k * sub_tile_step);
531 y2 = y1 + sub_tile_step;
532 }
else if ((j < 1) || (j >
ny)) {
533 x1 =
tile_x[i] + (k * sub_tile_step);
535 x2 = x1 + sub_tile_step;
538 assert(num_sub_tiles <= 1);
556 if (
grid[i][j].type->index < 3) {
578 if (
grid[i][j].offset == 0) {
579 if (i > 0 && i <= nx && j > 0 && j <=
ny) {
595 int inet, ipin, b1, b2;
596 float x1, y1, x2, y2;
604 for (inet = 0; inet <
num_nets; inet++) {
638 if ((i < 1) || (i >
nx)) {
639 *x =
tile_x[i] + (sub_tile_step * (k + 0.5));
644 if ((j < 1) || (j >
ny)) {
645 *y =
tile_y[j] + (sub_tile_step * (k + 0.5));
734 if (
rr_node[inode].capacity < 0)
736 else if (
rr_node[inode].occ > 0)
746 if (
rr_node[inode].capacity < 0)
748 else if (
rr_node[inode].occ > 0)
762 vpr_printf(TIO_MESSAGE_ERROR,
"in draw_rr: Unexpected rr_node type: %d.\n",
rr_node[inode].type);
789 y =
tile_y[rr_node[inode].ylow] + tile_width + 1.0 + itrack;
815 sprintf(str,
"%d", rr_node[inode].fan_in);
824 for (k = rr_node[inode].xlow; k < rr_node[inode].xhigh; k++) {
838 sprintf(str,
"%d", rr_node[inode].fan_in);
844 for (k = rr_node[inode].xhigh; k > rr_node[inode].xlow; k--) {
897 sprintf(str,
"%d", rr_node[inode].fan_in);
905 for (k = rr_node[inode].ylow; k < rr_node[inode].yhigh; k++) {
919 sprintf(str,
"%d", rr_node[inode].fan_in);
927 for (k = rr_node[inode].yhigh; k > rr_node[inode].ylow; k--) {
944 int iedge, to_node, from_ptc_num, to_ptc_num;
946 boolean defective =
FALSE;
984 vpr_printf(TIO_MESSAGE_ERROR,
"in draw_rr_edges: node %d (type: %d) connects to node %d (type: %d).\n",
985 inode, from_type, to_node, to_type);
1018 to_ptc_num, switch_type);
1035 vpr_printf(TIO_MESSAGE_ERROR,
"in draw_rr_edges: node %d (type: %d) connects to node %d (type: %d).\n",
1036 inode, from_type, to_node, to_type);
1082 to_ptc_num, switch_type);
1086 vpr_printf(TIO_MESSAGE_ERROR,
"in draw_rr_edges: node %d (type: %d) connects to node %d (type: %d).\n",
1087 inode, from_type, to_node, to_type);
1094 vpr_printf(TIO_MESSAGE_ERROR,
"draw_rr_edges called with node %d of type %d.\n",
1102 static void draw_x(
float x,
float y,
float size) {
1107 drawline(x - size, y + size, x + size, y - size);
1108 drawline(x - size, y - size, x + size, y + size);
1113 int chany_node,
int chany_track,
enum e_edge_dir edge_dir,
1114 short switch_type) {
1119 float x1, y1, x2, y2;
1120 int chanx_y, chany_x, chanx_xlow, chany_ylow;
1132 if (chanx_xlow <= chany_x) {
1137 if ((chanx_track % 2) == 1) {
1138 x1 =
tile_x[chany_x + 1];
1147 if (chany_ylow <= chanx_y) {
1152 if ((chany_track % 2) == 1) {
1153 y2 =
tile_y[chanx_y + 1];
1174 int to_track,
short switch_type) {
1180 float x1, x2, y1, y2;
1181 int from_y, to_y, from_xlow, to_xlow, from_xhigh, to_xhigh;
1195 if (to_xhigh < from_xlow) {
1200 }
else if (to_xlow > from_xhigh) {
1215 if (to_track % 2 == 0) {
1216 assert(from_xlow < to_xlow);
1221 assert(from_xhigh > to_xhigh);
1223 x1 =
tile_x[to_xhigh + 1];
1226 if (to_xlow < from_xlow) {
1229 }
else if (from_xlow < to_xlow) {
1233 else if (to_xhigh > from_xhigh) {
1235 x2 =
tile_x[from_xhigh + 1];
1236 }
else if (from_xhigh > to_xhigh) {
1237 x1 =
tile_x[to_xhigh + 1];
1253 int to_track,
short switch_type) {
1259 float x1, x2, y1, y2;
1260 int from_x, to_x, from_ylow, to_ylow, from_yhigh, to_yhigh;
1274 if (to_yhigh < from_ylow) {
1277 }
else if (to_ylow > from_yhigh) {
1289 if (to_track % 2 == 0) {
1290 assert(from_ylow < to_ylow);
1295 if (!(from_yhigh > to_yhigh)) {
1296 vpr_printf(TIO_MESSAGE_INFO,
"from_yhigh (%d) !> to_yhigh (%d).\n",
1297 from_yhigh, to_yhigh);
1298 vpr_printf(TIO_MESSAGE_INFO,
"from is (%d, %d) to (%d, %d) track %d.\n",
1302 vpr_printf(TIO_MESSAGE_INFO,
"to is (%d, %d) to (%d, %d) track %d.\n",
1309 y1 =
tile_y[to_yhigh + 1];
1312 if (to_ylow < from_ylow) {
1315 }
else if (from_ylow < to_ylow) {
1318 }
else if (to_yhigh > from_yhigh) {
1320 y2 =
tile_y[from_yhigh + 1];
1321 }
else if (from_yhigh > to_yhigh) {
1322 y1 =
tile_y[to_yhigh + 1];
1344 const float switch_rad = 0.15;
1345 float magnitude, xcen, ycen, xdelta, ydelta, xbaseline, ybaseline;
1349 xcen = from_x + (to_x - from_x) / 10.;
1350 ycen = from_y + (to_y - from_y) / 10.;
1353 drawarc(xcen, ycen, switch_rad, 0., 360.);
1355 xdelta = to_x - from_x;
1356 ydelta = to_y - from_y;
1357 magnitude = sqrt(xdelta * xdelta + ydelta * ydelta);
1358 xunit = xdelta / magnitude;
1359 yunit = ydelta / magnitude;
1360 poly[0].
x = xcen + xunit * switch_rad;
1361 poly[0].
y = ycen + yunit * switch_rad;
1362 xbaseline = xcen - xunit * switch_rad;
1363 ybaseline = ycen - yunit * switch_rad;
1368 poly[1].
x = xbaseline + yunit * switch_rad;
1369 poly[1].
y = ybaseline - xunit * switch_rad;
1370 poly[2].
x = xbaseline - yunit * switch_rad;
1371 poly[2].
y = ybaseline + xunit * switch_rad;
1382 int ipin, i, j, iside, ioff;
1395 for (iside = 0; iside < 4; iside++) {
1400 sprintf(str,
"%d", ipin);
1415 int i, j, k, ipin, pins_per_sub_tile;
1416 float offset, xc, yc, step;
1428 k = ipin / pins_per_sub_tile;
1435 offset = (ipin + k + 1) * step;
1457 vpr_printf(TIO_MESSAGE_ERROR,
"in get_rr_pin_draw_coords: Unexpected iside %d.\n", iside);
1474 static int **chanx_track = NULL;
1475 static int **chany_track = NULL;
1477 int inet, i, j, inode, prev_node, prev_track, itrack;
1484 if (chanx_track == NULL) {
1488 if (chany_track == NULL) {
1492 for (i = 1; i <=
nx; i++)
1493 for (j = 0; j <=
ny; j++)
1494 chanx_track[i][j] = (-1);
1496 for (i = 0; i <=
nx; i++)
1497 for (j = 1; j <=
ny; j++)
1498 chany_track[i][j] = (-1);
1505 for (inet = 0; inet <
num_nets; inet++) {
1517 inode = tptr->
index;
1522 prev_type = rr_type;
1525 inode = tptr->
index;
1539 prev_track =
get_track_num(prev_node, chanx_track, chany_track);
1551 switch (prev_type) {
1557 itrack, switch_type);
1572 vpr_printf(TIO_MESSAGE_ERROR,
"in drawroute: Unexpected connection from an rr_node of type %d to one of type %d.\n",
1573 prev_type, rr_type);
1581 chany_track[rr_node[inode].xlow][rr_node[inode].ylow]++;
1586 switch (prev_type) {
1599 itrack, switch_type);
1608 vpr_printf(TIO_MESSAGE_ERROR,
"in drawroute: Unexpected connection from an rr_node of type %d to one of type %d.\n",
1609 prev_type, rr_type);
1620 if (rr_type ==
SINK) {
1624 inode = tptr->
index;
1640 return (
rr_node[inode].ptc_num);
1650 return (chanx_track[i][j]);
1653 return (chany_track[i][j]);
1656 vpr_printf(TIO_MESSAGE_ERROR,
"in get_track_num: Unexpected node type %d for node %d.\n", rr_type, inode);
1665 for (inet = 0; inet <
num_nets; inet++) {
1669 sprintf(message,
"%s || Net:%d %d", message, inet,
1681 char message[250] =
"";
1700 sprintf(message,
"%s%s %d: %s (%d,%d) -> (%d,%d) track: %d",
1701 message, (hit ?
" | " :
""), inode,
name_type[rr_type],
1702 xlow, ylow, xhigh, yhigh, ptc_num);
1746 int i, j, k, hit, bnum, ipin, netnum, fanblk;
1754 hit = i = j = k = 0;
1756 for (i = 0; i <= (
nx + 1) && !hit; i++) {
1759 for (j = 0; j <= (
ny + 1) && !hit; j++) {
1760 if (
grid[i][j].offset != 0)
1793 if ((i < 1) || (i >
nx))
1794 k = (int) ((y -
tile_y[j]) / io_step);
1796 k = (int) ((x -
tile_x[i]) / io_step);
1798 assert(k < type->capacity);
1808 for (k = 0; k < type->
num_pins; k++) {
1831 sprintf(msg,
"Block %d (%s) at (%d, %d) selected.", bnum,
block[bnum].name,
1844 if (
block[i].type->index < 3) {
1863 float y1,
float y2) {
1864 float switch_rad = 0.15;
1865 float xdelta, ydelta;
1868 float xbaseline, ybaseline;
1873 magnitude = sqrt(xdelta * xdelta + ydelta * ydelta);
1874 xunit = xdelta / magnitude;
1875 yunit = ydelta / magnitude;
1877 poly[0].
x = xend + xunit * switch_rad;
1878 poly[0].
y = yend + yunit * switch_rad;
1879 xbaseline = xend - xunit * switch_rad;
1880 ybaseline = yend - yunit * switch_rad;
1881 poly[1].
x = xbaseline + yunit * switch_rad;
1882 poly[1].
y = ybaseline - xunit * switch_rad;
1883 poly[2].
x = xbaseline - yunit * switch_rad;
1884 poly[2].
y = ybaseline + xunit * switch_rad;
1900 int grid_x, grid_y, pin_num, chan_xlow, chan_ylow, ioff, height;
1901 float x1, x2, y1, y2;
1920 grid_y = grid_y - ioff;
1927 switch (chan_type) {
1942 assert(end >= start);
1945 if ((grid_y + height - 1) == chan_ylow) {
1950 assert((grid_y - 1) == chan_ylow);
1956 assert(
grid[grid_x][grid_y].type->
pinloc[ioff][iside][pin_num]);
1984 end =
std::min(end, (grid_y + height - 1));
1985 assert(end >= start);
1988 if ((grid_x) == chan_xlow) {
1992 assert((grid_x - 1) == chan_xlow);
1996 for (i = start; i <= end; i++) {
1998 assert(ioff >= 0 && ioff < type->height);
2004 if (
grid[grid_x][grid_y].type->
pinloc[ioff][iside][pin_num]) {
2008 assert(
grid[grid_x][grid_y].type->
pinloc[ioff][iside][pin_num]);
2025 vpr_printf(TIO_MESSAGE_ERROR,
"in draw_pin_to_chan_edge: Invalid channel node %d.\n", chan_node);
2033 xend = x2 + (x1 - x2) / 10.;
2034 yend = y2 + (y1 - y2) / 10.;
2042 int opin_grid_x, opin_grid_y, opin_pin_num, opin;
2043 int ipin_grid_x, ipin_grid_y, ipin_pin_num, ipin;
2046 float x1, x2, y1, y2;
2048 enum e_side iside, pin_side;
2054 x1 = y1 = x2 = y2 = 0;
2061 opin_grid_y = opin_grid_y -
grid[opin_grid_x][opin_grid_y].
offset;
2064 type =
grid[opin_grid_x][opin_grid_y].
type;
2067 for (ofs = 0; ofs < type->
height && !found; ++ofs) {
2068 for (iside = (
enum e_side)0; iside < 4 && !found; iside = (
enum e_side)(iside + 1)) {
2070 if (1 == type->
pinloc[ofs][iside][opin]) {
2084 ipin_grid_y = ipin_grid_y -
grid[ipin_grid_x][ipin_grid_y].
offset;
2087 type =
grid[ipin_grid_x][ipin_grid_y].
type;
2090 for (ofs = 0; ofs < type->
height && !found; ++ofs) {
2091 for (iside = (
enum e_side)0; iside < 4 && !found; iside = (
enum e_side)(iside + 1)) {
2093 if (1 == type->
pinloc[ofs][iside][ipin]) {
2103 xend = x2 + (x1 - x2) / 10.;
2104 yend = y2 + (y1 - y2) / 10.;
static void toggle_nets(void(*drawscreen)(void))
static float * x_rr_node_right
static void get_block_center(int bnum, float *x, float *y)
void init_world(float x1, float y1, float x2, float y2)
void update_screen(int priority, char *msg, enum pic_type pic_on_screen_val, boolean crit_path_button_enabled)
static float * y_rr_node_bottom
void ** alloc_matrix(int nrmin, int nrmax, int ncmin, int ncmax, size_t elsize)
static boolean show_congestion
boolean is_opin(int ipin, t_type_ptr type)
void fillpoly(t_point *points, int npoints)
static void draw_rr(void)
char * my_strncpy(char *dest, const char *src, size_t size)
static void draw_rr_switch(float from_x, float from_y, float to_x, float to_y, boolean buffered)
struct s_class * class_inf
void drawrect(float x1, float y1, float x2, float y2)
static enum e_draw_rr_toggle draw_rr_toggle
void get_tnode_block_and_output_net(int inode, int *iblk_ptr, int *inet_ptr)
static void highlight_rr_nodes(float x, float y)
static void draw_rr_chanx(int inode, int itrack)
void destroy_button(const char *button_text)
enum e_direction direction
static void get_rr_pin_draw_coords(int inode, int iside, int ioff, float *xcen, float *ycen)
static void draw_triangle_along_line(float xend, float yend, float x1, float x2, float y1, float y2)
t_linked_int * allocate_and_load_critical_path(void)
static int get_track_num(int inode, int **chanx_track, int **chany_track)
static void drawnets(void)
static enum e_route_type draw_route_type
static void toggle_rr(void(*drawscreen)(void))
static const char * name_type[]
void drawline(float x1, float y1, float x2, float y2)
static void drawscreen(void)
static void highlight_crit_path(void(*drawscreen_ptr)(void))
static char default_message[BUFSIZE]
void create_button(const char *prev_button_text, const char *button_text, void(*button_func)(void(*drawscreen)(void)))
void drawtext(float xc, float yc, const char *text, float boundx)
void fillrect(float x1, float y1, float x2, float y2)
void init_draw_coords(float width_val)
static void deselect_all(void)
static void draw_chany_to_chany_edge(int from_node, int from_track, int to_node, int to_track, short switch_type)
static void * my_malloc(int ibytes)
static void draw_pin_to_chan_edge(int pin_node, int chan_node)
static void redraw_screen(void)
static void draw_rr_chany(int inode, int itrack)
void free_draw_structs(void)
void setfontsize(int pointsize)
static enum color_types * net_color
static void draw_chanx_to_chany_edge(int chanx_node, int chanx_track, int chany_node, int chany_track, enum e_edge_dir edge_dir, short switch_type)
void drawarc(float xc, float yc, float rad, float startang, float angextent)
void print_rr_node(FILE *fp, t_rr_node *L_rr_node, int inode)
void free_int_list(t_linked_int **int_list_head_ptr)
static boolean show_defects
struct s_trace ** trace_head
static void draw_x(float x, float y, float size)
static void toggle_congestion(void(*drawscreen)(void))
struct s_switch_inf * switch_inf
void setlinewidth(int linewidth)
static enum color_types * rr_node_color
static void toggle_defects(void(*drawscreen)(void))
static void draw_pin_to_pin(int opin, int ipin)
static enum pic_type pic_on_screen
void event_loop(void(*act_on_mousebutton)(float x, float y), void(*act_on_mousemove)(float x, float y), void(*act_on_keypress)(char key_pressed), void(*drawscreen)(void))
static void draw_rr_pin(int inode, enum color_types color)
struct s_grid_tile ** grid
void setlinestyle(int linestyle)
static void * my_realloc(void *memblk, int ibytes)
void set_graphics_state(boolean show_graphics_val, int gr_automode_val, enum e_route_type route_type)
#define MAX_BLOCK_COLOURS
static void drawplace(void)
static void draw_chanx_to_chanx_edge(int from_node, int from_track, int to_node, int to_track, short switch_type)
static void draw_rr_edges(int from_node)
static float * x_rr_node_left
void alloc_draw_structs(void)
struct s_linked_int * next
static void drawroute(enum e_draw_net_type draw_net_type)
struct s_type_descriptor * type_descriptors
static void highlight_nets(char *message)
void update_message(const char *msg)
static int old_num_rr_nodes
static enum color_types * block_color
static float * y_rr_node_top
static void highlight_blocks(float x, float y)
static void draw_congestion(void)
void setcolor(int cindex)
static boolean show_graphics