VPR-7.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
check_route.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void check_route (enum e_route_type route_type, int num_switch, t_ivec **clb_opins_used_locally)
 

Function Documentation

void check_route ( enum e_route_type  route_type,
int  num_switch,
t_ivec **  clb_opins_used_locally 
)

Definition at line 27 of file check_route.c.

28  {
29 
30  /* This routine checks that a routing: (1) Describes a properly *
31  * connected path for each net, (2) this path connects all the *
32  * pins spanned by that net, and (3) that no routing resources are *
33  * oversubscribed (the occupancy of everything is recomputed from *
34  * scratch). */
35 
36  int inet, ipin, max_pins, inode, prev_node;
37  boolean valid, connects;
38  boolean * connected_to_route; /* [0 .. num_rr_nodes-1] */
39  struct s_trace *tptr;
40  boolean * pin_done;
41 
42  vpr_printf(TIO_MESSAGE_INFO, "\n");
43  vpr_printf(TIO_MESSAGE_INFO, "Checking to ensure routing is legal...\n");
44 
45  /* Recompute the occupancy from scratch and check for overuse of routing *
46  * resources. This was already checked in order to determine that this *
47  * is a successful routing, but I want to double check it here. */
48 
49  recompute_occupancy_from_scratch(clb_opins_used_locally);
50  valid = feasible_routing();
51  if (valid == FALSE) {
52  vpr_printf(TIO_MESSAGE_ERROR, "Error in check_route -- routing resources are overused.\n");
53  exit(1);
54  }
55 
56  check_locally_used_clb_opins(clb_opins_used_locally, route_type);
57 
58  connected_to_route = (boolean *) my_calloc(num_rr_nodes, sizeof(boolean));
59 
60  max_pins = 0;
61  for (inet = 0; inet < num_nets; inet++)
62  max_pins = std::max(max_pins, (clb_net[inet].num_sinks + 1));
63 
64  pin_done = (boolean *) my_malloc(max_pins * sizeof(boolean));
65 
66  /* Now check that all nets are indeed connected. */
67 
68  for (inet = 0; inet < num_nets; inet++) {
69 
70  if (clb_net[inet].is_global || clb_net[inet].num_sinks == 0) /* Skip global nets. */
71  continue;
72 
73  for (ipin = 0; ipin < (clb_net[inet].num_sinks + 1); ipin++)
74  pin_done[ipin] = FALSE;
75 
76  /* Check the SOURCE of the net. */
77 
78  tptr = trace_head[inet];
79  if (tptr == NULL) {
80  vpr_printf(TIO_MESSAGE_ERROR, "in check_route: net %d has no routing.\n", inet);
81  exit(1);
82  }
83 
84  inode = tptr->index;
85  check_node_and_range(inode, route_type);
86  check_switch(tptr, num_switch);
87  connected_to_route[inode] = TRUE; /* Mark as in path. */
88 
89  check_source(inode, inet);
90  pin_done[0] = TRUE;
91 
92  prev_node = inode;
93  tptr = tptr->next;
94 
95  /* Check the rest of the net */
96 
97  while (tptr != NULL) {
98  inode = tptr->index;
99  check_node_and_range(inode, route_type);
100  check_switch(tptr, num_switch);
101 
102  if (rr_node[prev_node].type == SINK) {
103  if (connected_to_route[inode] == FALSE) {
104  vpr_printf(TIO_MESSAGE_ERROR, "in check_route: node %d does not link into existing routing for net %d.\n", inode, inet);
105  exit(1);
106  }
107  }
108 
109  else {
110  connects = check_adjacent(prev_node, inode);
111  if (!connects) {
112  vpr_printf(TIO_MESSAGE_ERROR, "in check_route: found non-adjacent segments in traceback while checking net %d.\n", inet);
113  exit(1);
114  }
115 
116  if (connected_to_route[inode] && rr_node[inode].type != SINK) {
117 
118  /* Note: Can get multiple connections to the same logically-equivalent *
119  * SINK in some logic blocks. */
120 
121  vpr_printf(TIO_MESSAGE_ERROR, "in check_route: net %d routing is not a tree.\n", inet);
122  exit(1);
123  }
124 
125  connected_to_route[inode] = TRUE; /* Mark as in path. */
126 
127  if (rr_node[inode].type == SINK)
128  check_sink(inode, inet, pin_done);
129 
130  } /* End of prev_node type != SINK */
131  prev_node = inode;
132  tptr = tptr->next;
133  } /* End while */
134 
135  if (rr_node[prev_node].type != SINK) {
136  vpr_printf(TIO_MESSAGE_ERROR, "in check_route: net %d does not end with a SINK.\n", inet);
137  exit(1);
138  }
139 
140  for (ipin = 0; ipin < (clb_net[inet].num_sinks + 1); ipin++) {
141  if (pin_done[ipin] == FALSE) {
142  vpr_printf(TIO_MESSAGE_ERROR, "in check_route: net %d does not connect to pin %d.\n", inet, ipin);
143  exit(1);
144  }
145  }
146 
147  reset_flags(inet, connected_to_route);
148 
149  } /* End for each net */
150 
151  free(pin_done);
152  free(connected_to_route);
153  vpr_printf(TIO_MESSAGE_INFO, "Completed routing consistency check successfully.\n");
154  vpr_printf(TIO_MESSAGE_INFO, "\n");
155 }
static void recompute_occupancy_from_scratch(t_ivec **clb_opins_used_locally)
Definition: check_route.c:535
boolean feasible_routing(void)
Definition: route_common.c:298
int index
Definition: vpr_types.h:866
t_rr_node * rr_node
Definition: globals.c:70
static void check_locally_used_clb_opins(t_ivec **clb_opins_used_locally, enum e_route_type route_type)
Definition: check_route.c:590
static void check_node_and_range(int inode, enum e_route_type route_type)
Definition: check_route.c:632
void * my_calloc(size_t nelem, size_t size)
Definition: util.c:132
int num_nets
Definition: globals.c:27
Definition: util.h:12
struct s_trace * next
Definition: vpr_types.h:870
static void * my_malloc(int ibytes)
Definition: graphics.c:499
boolean * is_global
#define max(a, b)
Definition: graphics.c:171
static void check_source(int inode, int inet)
Definition: check_route.c:204
struct s_net * clb_net
Definition: globals.c:28
int num_rr_nodes
Definition: globals.c:69
static boolean check_adjacent(int from_node, int to_node)
Definition: check_route.c:289
struct s_trace ** trace_head
Definition: globals.c:64
static void reset_flags(int inet, boolean *connected_to_route)
Definition: check_route.c:270
static void check_sink(int inode, int inet, boolean *pin_done)
Definition: check_route.c:157
messagelogger vpr_printf
Definition: util.c:17
static void check_switch(struct s_trace *tptr, int num_switch)
Definition: check_route.c:238
int num_sinks
Definition: vpr_types.h:506
Definition: util.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function: