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

Go to the source code of this file.

Functions

void alloc_and_load_cluster_legality_checker (void)
 
void alloc_and_load_legalizer_for_cluster (INP t_block *clb, INP int clb_index, INP const t_arch *arch)
 
void free_legalizer_for_cluster (INP t_block *clb, boolean free_local_rr_graph)
 
void free_cluster_legality_checker (void)
 
void reset_legalizer_for_cluster (t_block *clb)
 
void save_and_reset_routing_cluster (void)
 
void setup_intracluster_routing_for_molecule (INP t_pack_molecule *molecule, INOUTP t_pb_graph_node **primitives_list)
 
boolean try_breadth_first_route_cluster (void)
 
void restore_routing_cluster (void)
 
void save_cluster_solution (void)
 
boolean is_pin_open (int i)
 
void set_pb_graph_mode (t_pb_graph_node *pb_graph_node, int mode, int isOn)
 
void alloc_and_load_rr_graph_for_pb_graph_node (INP t_pb_graph_node *pb_graph_node, INP const t_arch *arch, int mode)
 
void reload_ext_net_rr_terminal_cluster (void)
 
void force_post_place_route_cb_input_pins (int iblock)
 
void setup_intracluster_routing_for_logical_block (INP int iblock, INP t_pb_graph_node *primitive)
 

Function Documentation

void alloc_and_load_cluster_legality_checker ( void  )

Definition at line 202 of file cluster_legality.c.

202  {
204  sizeof(struct s_trace *));
205  nets_in_cluster = (int *) my_malloc(num_logical_nets * sizeof(int));
208 
209  /* inside a cluster, I do not consider rr_indexed_data cost, set to 1 since other costs are multiplied by it */
212  rr_indexed_data[0].base_cost = 1;
213 
214  /* alloc routing structures */
217 }
static void alloc_net_rr_terminals_cluster(void)
t_rr_indexed_data * rr_indexed_data
Definition: globals.c:74
int num_rr_indexed_data
Definition: globals.c:73
void * my_calloc(size_t nelem, size_t size)
Definition: util.c:132
int num_nets
Definition: globals.c:27
int num_logical_nets
Definition: globals.c:17
static void * my_malloc(int ibytes)
Definition: graphics.c:499
static int num_nets_in_cluster
void alloc_route_static_structs(void)
Definition: route_common.c:623
static int * nets_in_cluster
static struct s_trace ** best_routing

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void alloc_and_load_legalizer_for_cluster ( INP t_block clb,
INP int  clb_index,
INP const t_arch arch 
)

Structure: Model external routing and internal routing

  1. Model external routing num input pins == num external sources for input pins, fully connect them to input pins (simulates external routing) num output pins == num external sinks for output pins, fully connect them to output pins (simulates external routing) num clock pins == num external sources for clock pins, fully connect them to clock pins (simulates external routing)
  2. Model internal routing

Definition at line 421 of file cluster_legality.c.

422  {
423 
424  /**
425  * Structure: Model external routing and internal routing
426  *
427  * 1. Model external routing
428  * num input pins == num external sources for input pins, fully connect them to input pins (simulates external routing)
429  * num output pins == num external sinks for output pins, fully connect them to output pins (simulates external routing)
430  * num clock pins == num external sources for clock pins, fully connect them to clock pins (simulates external routing)
431  * 2. Model internal routing
432  *
433  */
434  /* make each rr_node one correspond with pin and correspond with pin's index pin_count_in_cluster */
435  int i, j, k, m, index, pb_graph_rr_index;
436  int count_pins;
437  t_pb_type * pb_type;
438  t_pb_graph_node *pb_graph_node;
439  int ipin;
440 
441  /* Create rr_graph */
442  pb_type = clb->type->pb_type;
443  pb_graph_node = clb->type->pb_graph_head;
444  num_rr_nodes = pb_graph_node->total_pb_pins + pb_type->num_input_pins
445  + pb_type->num_output_pins + pb_type->num_clock_pins;
446 
447  /* allocate memory for rr_node resources + additional memory for any additional sources/sinks, 2x is an overallocation but guarantees that there will be enough sources/sinks available */
448  rr_node = (t_rr_node *) my_calloc(num_rr_nodes * 2, sizeof(t_rr_node));
449  clb->pb->rr_graph = rr_node;
450 
451  alloc_and_load_rr_graph_for_pb_graph_node(pb_graph_node, arch, 0);
452 
453  curr_cluster_index = clb_index;
454 
455  /* Alloc and load rr_graph external sources and sinks */
456  ext_input_rr_node_index = pb_graph_node->total_pb_pins;
458  + pb_graph_node->total_pb_pins;
460  + pb_graph_node->total_pb_pins;
461  max_ext_index = pb_type->num_input_pins + pb_type->num_output_pins
462  + pb_type->num_clock_pins + pb_graph_node->total_pb_pins;
463 
464  for (i = 0; i < pb_type->num_input_pins; i++) {
465  index = i + pb_graph_node->total_pb_pins;
467  rr_node[index].fan_in = 0;
470  + (float) rr_node[index].num_edges / 5; /* need to normalize better than 5 */
471  rr_node[index].edges = (int *) my_malloc(
472  rr_node[index].num_edges * sizeof(int));
473  rr_node[index].switches = (short *) my_calloc(rr_node[index].num_edges,
474  sizeof(int));
475  rr_node[index].capacity = 1;
476  }
477 
478  for (i = 0; i < pb_type->num_output_pins; i++) {
479  index = i + pb_type->num_input_pins + pb_graph_node->total_pb_pins;
480  rr_node[index].type = SINK;
481  rr_node[index].fan_in = pb_type->num_output_pins;
482  rr_node[index].num_edges = 0;
484  + (float) rr_node[index].num_edges / 5; /* need to normalize better than 5 */
485  rr_node[index].capacity = 1;
486  }
487 
488  for (i = 0; i < pb_type->num_clock_pins; i++) {
489  index = i + pb_type->num_input_pins + pb_type->num_output_pins
490  + pb_graph_node->total_pb_pins;
492  rr_node[index].fan_in = 0;
495  + (float) rr_node[index].num_edges / 5; /* need to normalize better than 5 */
496  rr_node[index].edges = (int *) my_malloc(
497  rr_node[index].num_edges * sizeof(int));
498  rr_node[index].switches = (short *) my_calloc(rr_node[index].num_edges,
499  sizeof(int));
500  rr_node[index].capacity = 1;
501  }
502 
503  ipin = 0;
504  for (i = 0; i < pb_graph_node->num_input_ports; i++) {
505  for (j = 0; j < pb_graph_node->num_input_pins[i]; j++) {
506  pb_graph_rr_index =
507  pb_graph_node->input_pins[i][j].pin_count_in_cluster;
508  for (k = 0; k < pb_type->num_input_pins; k++) {
509  index = k + pb_graph_node->total_pb_pins;
510  rr_node[index].edges[ipin] = pb_graph_rr_index;
511  rr_node[index].switches[ipin] = arch->num_switches - 1;
512  }
513  rr_node[pb_graph_rr_index].pack_intrinsic_cost = MAX_SHORT; /* using an input pin should be made costly */
514  ipin++;
515  }
516  }
517 
518  /* Must attach output pins to input pins because if a connection cannot fit using intra-cluster routing, it can also use external routing */
519  for (i = 0; i < pb_graph_node->num_output_ports; i++) {
520  for (j = 0; j < pb_graph_node->num_output_pins[i]; j++) {
521  count_pins = pb_graph_node->output_pins[i][j].num_output_edges
522  + pb_type->num_output_pins + pb_type->num_input_pins;
523  pb_graph_rr_index =
524  pb_graph_node->output_pins[i][j].pin_count_in_cluster;
525  rr_node[pb_graph_rr_index].edges = (int *) my_realloc(
526  rr_node[pb_graph_rr_index].edges,
527  (count_pins) * sizeof(int));
528  rr_node[pb_graph_rr_index].switches = (short *) my_realloc(
529  rr_node[pb_graph_rr_index].switches,
530  (count_pins) * sizeof(int));
531 
532  ipin = 0;
533  for (k = 0; k < pb_graph_node->num_input_ports; k++) {
534  for (m = 0; m < pb_graph_node->num_input_pins[k]; m++) {
535  index =
536  pb_graph_node->input_pins[k][m].pin_count_in_cluster;
537  rr_node[pb_graph_rr_index].edges[ipin
538  + pb_graph_node->output_pins[i][j].num_output_edges] =
539  index;
540  rr_node[pb_graph_rr_index].switches[ipin
541  + pb_graph_node->output_pins[i][j].num_output_edges] =
542  arch->num_switches - 1;
543  ipin++;
544  }
545  }
546  for (k = 0; k < pb_type->num_output_pins; k++) {
547  index = k + pb_type->num_input_pins
548  + pb_graph_node->total_pb_pins;
549  rr_node[pb_graph_rr_index].edges[k + pb_type->num_input_pins
550  + pb_graph_node->output_pins[i][j].num_output_edges] =
551  index;
552  rr_node[pb_graph_rr_index].switches[k + pb_type->num_input_pins
553  + pb_graph_node->output_pins[i][j].num_output_edges] =
554  arch->num_switches - 1;
555  }
556  rr_node[pb_graph_rr_index].num_edges += pb_type->num_output_pins
557  + pb_type->num_input_pins;
558  rr_node[pb_graph_rr_index].pack_intrinsic_cost = 1
559  + (float) rr_node[pb_graph_rr_index].num_edges / 5; /* need to normalize better than 5 */
560  }
561  }
562 
563  ipin = 0;
564  for (i = 0; i < pb_graph_node->num_clock_ports; i++) {
565  for (j = 0; j < pb_graph_node->num_clock_pins[i]; j++) {
566  for (k = 0; k < pb_type->num_clock_pins; k++) {
567  index = k + pb_type->num_input_pins + pb_type->num_output_pins
568  + pb_graph_node->total_pb_pins;
569  pb_graph_rr_index =
570  pb_graph_node->clock_pins[i][j].pin_count_in_cluster;
571  rr_node[index].edges[ipin] = pb_graph_rr_index;
572  rr_node[index].switches[ipin] = arch->num_switches - 1;
573  }
574  ipin++;
575  }
576  }
577 
580 
581 }
short num_edges
Definition: vpr_types.h:901
t_pb_graph_pin ** clock_pins
int index
Definition: vpr_types.h:866
int * edges
Definition: vpr_types.h:903
t_rr_node * rr_node
Definition: globals.c:70
void alloc_and_load_rr_graph_for_pb_graph_node(INP t_pb_graph_node *pb_graph_node, INP const t_arch *arch, int mode)
void * my_calloc(size_t nelem, size_t size)
Definition: util.c:132
t_pb_graph_pin ** output_pins
#define MAX_SHORT
Definition: vpr_types.h:75
static void * my_malloc(int ibytes)
Definition: graphics.c:499
void alloc_and_load_rr_node_route_structs(void)
Definition: route_common.c:785
int num_rr_nodes
Definition: globals.c:69
static int num_nets_in_cluster
short capacity
Definition: vpr_types.h:899
short fan_in
Definition: vpr_types.h:900
static int ext_output_rr_node_index
short * switches
Definition: vpr_types.h:904
static int ext_input_rr_node_index
static void * my_realloc(void *memblk, int ibytes)
Definition: graphics.c:512
static int curr_cluster_index
static int max_ext_index
float pack_intrinsic_cost
Definition: vpr_types.h:920
int num_output_pins
int num_input_pins
static int ext_clock_rr_node_index
t_rr_type type
Definition: vpr_types.h:902
t_pb_graph_pin ** input_pins
int num_clock_pins

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void alloc_and_load_rr_graph_for_pb_graph_node ( INP t_pb_graph_node pb_graph_node,
INP const t_arch arch,
int  mode 
)

Definition at line 237 of file cluster_legality.c.

238  {
239 
240  int i, j, k, index;
241  boolean is_primitive;
242 
243  is_primitive = (boolean) (pb_graph_node->pb_type->num_modes == 0);
244 
245  for (i = 0; i < pb_graph_node->num_input_ports; i++) {
246  for (j = 0; j < pb_graph_node->num_input_pins[i]; j++) {
247  index = pb_graph_node->input_pins[i][j].pin_count_in_cluster;
248  rr_node[index].pb_graph_pin = &pb_graph_node->input_pins[i][j];
249  rr_node[index].fan_in =
250  pb_graph_node->input_pins[i][j].num_input_edges;
252  pb_graph_node->input_pins[i][j].num_output_edges;
254  + (float) rr_node[index].num_edges / 5 + ((float)j/(float)pb_graph_node->num_input_pins[i])/(float)10; /* need to normalize better than 5 and 10, bias router to use earlier inputs pins */
255  rr_node[index].edges = (int *) my_malloc(
256  rr_node[index].num_edges * sizeof(int));
257  rr_node[index].switches = (short *) my_calloc(rr_node[index].num_edges,
258  sizeof(short));
262  if (mode == 0) { /* default mode is the first mode */
263  rr_node[index].capacity = 1;
264  } else {
265  rr_node[index].capacity = 0;
266  }
267  for (k = 0; k < pb_graph_node->input_pins[i][j].num_output_edges;
268  k++) {
269  /* TODO: Intention was to do bus-based implementation here */
270  rr_node[index].edges[k] =
271  pb_graph_node->input_pins[i][j].output_edges[k]->output_pins[0]->pin_count_in_cluster;
272  rr_node[index].switches[k] = arch->num_switches - 1; /* last switch in arch switch properties is a delayless switch */
273  assert(
274  pb_graph_node->input_pins[i][j].output_edges[k]->num_output_pins == 1);
275  }
277  if (is_primitive) {
278  /* This is a terminating pin, add SINK node */
279  assert(rr_node[index].num_edges == 0);
280  rr_node[index].num_edges = 1;
281  rr_node[index].edges = (int *) my_calloc(rr_node[index].num_edges, sizeof(int));
282  rr_node[index].switches = (short *) my_calloc(rr_node[index].num_edges, sizeof(short));
284 
285  /* Create SINK node */
290  rr_node[num_rr_nodes].edges = NULL;
291  rr_node[num_rr_nodes].switches = NULL;
297  num_rr_nodes++;
298 
299  if(pb_graph_node->pb_type->class_type == LUT_CLASS) {
300  /* LUTs are special, they have logical equivalence at inputs, logical equivalence is represented by a single high capacity sink instead of multiple single capacity sinks */
301  rr_node[num_rr_nodes - 1].capacity = pb_graph_node->num_input_pins[i];
302  if(j != 0) {
303  num_rr_nodes--;
304  rr_node[index].edges[0] = num_rr_nodes - 1;
305  }
306  }
307  }
308  }
309  }
310 
311  for (i = 0; i < pb_graph_node->num_output_ports; i++) {
312  for (j = 0; j < pb_graph_node->num_output_pins[i]; j++) {
313  index = pb_graph_node->output_pins[i][j].pin_count_in_cluster;
314  rr_node[index].pb_graph_pin = &pb_graph_node->output_pins[i][j];
315  rr_node[index].fan_in =
316  pb_graph_node->output_pins[i][j].num_input_edges;
318  pb_graph_node->output_pins[i][j].num_output_edges;
320  + (float) rr_node[index].num_edges / 5; /* need to normalize better than 5 */
321  rr_node[index].edges = (int *) my_malloc(
322  rr_node[index].num_edges * sizeof(int));
323  rr_node[index].switches = (short *) my_calloc(rr_node[index].num_edges,
324  sizeof(short));
328  if (mode == 0) { /* Default mode is the first mode */
329  rr_node[index].capacity = 1;
330  } else {
331  rr_node[index].capacity = 0;
332  }
333  for (k = 0; k < pb_graph_node->output_pins[i][j].num_output_edges;
334  k++) {
335  /* TODO: Intention was to do bus-based implementation here */
336  rr_node[index].edges[k] =
337  pb_graph_node->output_pins[i][j].output_edges[k]->output_pins[0]->pin_count_in_cluster;
338  rr_node[index].switches[k] = arch->num_switches - 1;
339  assert(
340  pb_graph_node->output_pins[i][j].output_edges[k]->num_output_pins == 1);
341  }
343  if (is_primitive) {
345  }
346  }
347  }
348 
349  for (i = 0; i < pb_graph_node->num_clock_ports; i++) {
350  for (j = 0; j < pb_graph_node->num_clock_pins[i]; j++) {
351  index = pb_graph_node->clock_pins[i][j].pin_count_in_cluster;
352  rr_node[index].pb_graph_pin = &pb_graph_node->clock_pins[i][j];
353  rr_node[index].fan_in =
354  pb_graph_node->clock_pins[i][j].num_input_edges;
356  pb_graph_node->clock_pins[i][j].num_output_edges;
358  + (float) rr_node[index].num_edges / 5; /* need to normalize better than 5 */
359  rr_node[index].edges = (int *) my_malloc(
360  rr_node[index].num_edges * sizeof(int));
361  rr_node[index].switches = (short *) my_calloc(rr_node[index].num_edges,
362  sizeof(short));
366  if (mode == 0) { /* default mode is the first mode (useful for routing */
367  rr_node[index].capacity = 1;
368  } else {
369  rr_node[index].capacity = 0;
370  }
371  for (k = 0; k < pb_graph_node->clock_pins[i][j].num_output_edges;
372  k++) {
373  /* TODO: Intention was to do bus-based implementation here */
374  rr_node[index].edges[k] =
375  pb_graph_node->clock_pins[i][j].output_edges[k]->output_pins[0]->pin_count_in_cluster;
376  rr_node[index].switches[k] = arch->num_switches - 1;
377  assert(
378  pb_graph_node->clock_pins[i][j].output_edges[k]->num_output_pins == 1);
379  }
381  if (is_primitive) {
382  /* This is a terminating pin, add SINK node */
383  assert(rr_node[index].num_edges == 0);
384  rr_node[index].num_edges = 1;
385  rr_node[index].edges = (int *) my_calloc(rr_node[index].num_edges, sizeof(int));
386  rr_node[index].switches = (short *) my_calloc(rr_node[index].num_edges, sizeof(short));
388 
389  /* Create SINK node */
394  rr_node[num_rr_nodes].edges = NULL;
395  rr_node[num_rr_nodes].switches = NULL;
401  num_rr_nodes++;
402  }
403  }
404  }
405 
406  for (i = 0; i < pb_graph_node->pb_type->num_modes; i++) {
407  for (j = 0; j < pb_graph_node->pb_type->modes[i].num_pb_type_children;
408  j++) {
409  for (k = 0;
410  k
411  < pb_graph_node->pb_type->modes[i].pb_type_children[j].num_pb;
412  k++) {
414  &pb_graph_node->child_pb_graph_nodes[i][j][k], arch, i);
415  }
416  }
417  }
418 
419 }
short num_edges
Definition: vpr_types.h:901
int index
Definition: vpr_types.h:866
int * edges
Definition: vpr_types.h:903
t_rr_node * rr_node
Definition: globals.c:70
int net_num
Definition: vpr_types.h:917
boolean
Definition: util.h:11
int prev_node
Definition: vpr_types.h:915
void alloc_and_load_rr_graph_for_pb_graph_node(INP t_pb_graph_node *pb_graph_node, INP const t_arch *arch, int mode)
void * my_calloc(size_t nelem, size_t size)
Definition: util.c:132
static void * my_malloc(int ibytes)
Definition: graphics.c:499
int num_rr_nodes
Definition: globals.c:69
short capacity
Definition: vpr_types.h:899
short fan_in
Definition: vpr_types.h:900
short * switches
Definition: vpr_types.h:904
t_pb_graph_pin * pb_graph_pin
Definition: vpr_types.h:918
Definition: slre.c:50
float pack_intrinsic_cost
Definition: vpr_types.h:920
int prev_edge
Definition: vpr_types.h:916
t_rr_type type
Definition: vpr_types.h:902

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void force_post_place_route_cb_input_pins ( int  iblock)

Definition at line 1207 of file cluster_legality.c.

1207  {
1208  int i, j, k, ipin, net_index, ext_net;
1209  int pin_offset;
1210  boolean has_ext_source, success;
1211  int curr_ext_output, curr_ext_input, curr_ext_clock;
1212  t_pb_graph_node *pb_graph_node;
1213 
1214  pb_graph_node = block[iblock].pb->pb_graph_node;
1215  pin_offset = block[iblock].z * (pb_graph_node->pb_type->num_input_pins + pb_graph_node->pb_type->num_output_pins + pb_graph_node->pb_type->num_clock_pins);
1216 
1217  curr_ext_input = ext_input_rr_node_index;
1218  curr_ext_output = ext_output_rr_node_index;
1219  curr_ext_clock = ext_clock_rr_node_index;
1220 
1221  for (i = 0; i < num_nets_in_cluster; i++) {
1222  net_index = nets_in_cluster[i];
1223  has_ext_source = (boolean)
1224  (logical_block[vpack_net[net_index].node_block[0]].clb_index
1225  != curr_cluster_index);
1226  if(has_ext_source) {
1227  ext_net = vpack_to_clb_net_mapping[net_index];
1228  assert(ext_net != OPEN);
1229  if (vpack_net[net_index].is_global) {
1230  free(rr_node[curr_ext_clock].edges);
1231  rr_node[curr_ext_clock].edges = NULL;
1232  rr_node[curr_ext_clock].num_edges = 0;
1233 
1234  success = FALSE;
1235  ipin = 0;
1236  /* force intra-cluster net to use pins from ext route */
1237  for(j = 0; j < pb_graph_node->num_clock_ports; j++) {
1238  for(k = 0; k < pb_graph_node->num_clock_pins[j]; k++) {
1239  if(ext_net == block[iblock].nets[ipin + pb_graph_node->pb_type->num_input_pins + pb_graph_node->pb_type->num_output_pins + pin_offset]) {
1240  success = TRUE;
1241  rr_node[curr_ext_clock].num_edges++;
1242  rr_node[curr_ext_clock].edges = (int*)my_realloc(rr_node[curr_ext_clock].edges, rr_node[curr_ext_clock].num_edges * sizeof(int));
1243  rr_node[curr_ext_clock].edges[rr_node[curr_ext_clock].num_edges - 1] = pb_graph_node->clock_pins[j][k].pin_count_in_cluster;
1244  }
1245  ipin++;
1246  }
1247  }
1248  assert(success);
1249  curr_ext_clock++;
1250  } else {
1251  free(rr_node[curr_ext_input].edges);
1252  rr_node[curr_ext_input].edges = NULL;
1253  rr_node[curr_ext_input].num_edges = 0;
1254 
1255  success = FALSE;
1256  ipin = 0;
1257  /* force intra-cluster net to use pins from ext route */
1258  for(j = 0; j < pb_graph_node->num_input_ports; j++) {
1259  for(k = 0; k < pb_graph_node->num_input_pins[j]; k++) {
1260  if(ext_net == block[iblock].nets[ipin + pin_offset]) {
1261  success = TRUE;
1262  rr_node[curr_ext_input].num_edges++;
1263  rr_node[curr_ext_input].edges = (int*)my_realloc(rr_node[curr_ext_input].edges, rr_node[curr_ext_input].num_edges * sizeof(int));
1264  rr_node[curr_ext_input].edges[rr_node[curr_ext_input].num_edges - 1] = pb_graph_node->input_pins[j][k].pin_count_in_cluster;
1265  }
1266  ipin++;
1267  }
1268  }
1269  curr_ext_input++;
1270  assert(success);
1271  }
1272  }
1273  }
1274 }
short num_edges
Definition: vpr_types.h:901
t_pb_graph_pin ** clock_pins
int * edges
Definition: vpr_types.h:903
t_rr_node * rr_node
Definition: globals.c:70
boolean
Definition: util.h:11
Definition: util.h:12
boolean * is_global
int * vpack_to_clb_net_mapping
Definition: globals.c:34
struct s_block * block
Definition: globals.c:31
static int num_nets_in_cluster
int iblock
Definition: vpr_types.h:868
struct s_pb_type * pb_type
static int ext_output_rr_node_index
static int ext_input_rr_node_index
static void * my_realloc(void *memblk, int ibytes)
Definition: graphics.c:512
static int * nets_in_cluster
static int curr_cluster_index
Definition: slre.c:50
t_pb * pb
Definition: vpr_types.h:567
int z
Definition: vpr_types.h:565
struct s_net * vpack_net
Definition: globals.c:19
int num_output_pins
t_pb_graph_node * pb_graph_node
Definition: vpr_types.h:180
int num_input_pins
static int ext_clock_rr_node_index
t_pb_graph_pin ** input_pins
struct s_logical_block * logical_block
Definition: globals.c:20
int num_clock_pins
Definition: util.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void free_cluster_legality_checker ( void  )

Definition at line 219 of file cluster_legality.c.

219  {
220  int inet;
221  free(best_routing);
222  free(rr_indexed_data);
226 
228 
229  for (inet = 0; inet < num_logical_nets; inet++) {
230  free(saved_net_rr_terminals[inet]);
231  }
232  free(net_rr_terminals);
233  free(nets_in_cluster);
235 }
t_rr_indexed_data * rr_indexed_data
Definition: globals.c:74
void free_trace_structs(void)
Definition: route_common.c:733
int num_logical_nets
Definition: globals.c:17
static int * nets_in_cluster
void free_rr_node_route_structs(void)
Definition: route_common.c:828
int ** net_rr_terminals
Definition: globals.c:78
static int ** saved_net_rr_terminals
void free_chunk_memory(t_chunk *chunk_info)
Definition: util.c:270
void free_route_structs()
Definition: route_common.c:750
static t_chunk rr_mem_ch
static struct s_trace ** best_routing

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void free_legalizer_for_cluster ( INP t_block clb,
boolean  free_local_rr_graph 
)

Definition at line 583 of file cluster_legality.c.

583  {
584  int i;
585 
587  if(free_local_rr_graph == TRUE) {
588  for (i = 0; i < num_rr_nodes; i++) {
589  if (clb->pb->rr_graph[i].edges != NULL) {
590  free(clb->pb->rr_graph[i].edges);
591  }
592  if (clb->pb->rr_graph[i].switches != NULL) {
593  free(clb->pb->rr_graph[i].switches);
594  }
595  }
596  free(clb->pb->rr_graph);
597  }
598 }
int num_rr_nodes
Definition: globals.c:69
void free_rr_node_route_structs(void)
Definition: route_common.c:828
Definition: util.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

boolean is_pin_open ( int  i)

Definition at line 1137 of file cluster_legality.c.

1137  {
1138  return (boolean) (rr_node[i].occ == 0);
1139 }
t_rr_node * rr_node
Definition: globals.c:70
short occ
Definition: vpr_types.h:898
void reload_ext_net_rr_terminal_cluster ( void  )

Definition at line 153 of file cluster_legality.c.

153  {
154  int i, j, net_index;
155  boolean has_ext_sink, has_ext_source;
156  int curr_ext_output, curr_ext_input, curr_ext_clock;
157 
158  curr_ext_input = ext_input_rr_node_index;
159  curr_ext_output = ext_output_rr_node_index;
160  curr_ext_clock = ext_clock_rr_node_index;
161 
162  for (i = 0; i < num_nets_in_cluster; i++) {
163  net_index = nets_in_cluster[i];
164  has_ext_sink = FALSE;
165  has_ext_source = (boolean)
166  (logical_block[vpack_net[net_index].node_block[0]].clb_index
167  != curr_cluster_index);
168  if (has_ext_source) {
169  /* Instantiate a source of this net */
170  if (vpack_net[net_index].is_global) {
171  net_rr_terminals[net_index][0] = curr_ext_clock;
172  curr_ext_clock++;
173  } else {
174  net_rr_terminals[net_index][0] = curr_ext_input;
175  curr_ext_input++;
176  }
177  }
178  for (j = 1; j <= vpack_net[net_index].num_sinks; j++) {
179  if (logical_block[vpack_net[net_index].node_block[j]].clb_index
180  != curr_cluster_index) {
181  if (has_ext_sink || has_ext_source) {
182  /* Only need one node driving external routing, either this cluster drives external routing or another cluster does it */
183  net_rr_terminals[net_index][j] = OPEN;
184  } else {
185  /* External sink, only need to route once, externally routing will take care of the rest */
186  net_rr_terminals[net_index][j] = curr_ext_output;
187  curr_ext_output++;
188  has_ext_sink = TRUE;
189  }
190  }
191  }
192 
193  if (curr_ext_input > ext_output_rr_node_index
194  || curr_ext_output > ext_clock_rr_node_index
195  || curr_ext_clock > max_ext_index) {
196  /* failed, not enough pins of proper type, overran index */
197  assert(0);
198  }
199  }
200 }
boolean
Definition: util.h:11
Definition: util.h:12
boolean * is_global
static int num_nets_in_cluster
static int ext_output_rr_node_index
static int ext_input_rr_node_index
static int * nets_in_cluster
static int curr_cluster_index
Definition: slre.c:50
static int max_ext_index
int ** net_rr_terminals
Definition: globals.c:78
struct s_net * vpack_net
Definition: globals.c:19
int num_sinks
Definition: vpr_types.h:506
static int ext_clock_rr_node_index
struct s_logical_block * logical_block
Definition: globals.c:20
Definition: util.h:12

+ Here is the caller graph for this function:

void reset_legalizer_for_cluster ( t_block clb)

Definition at line 600 of file cluster_legality.c.

600  {
601  int i;
602  for (i = 0; i < num_nets_in_cluster; i++) {
604  trace_head[nets_in_cluster[i]] = best_routing[nets_in_cluster[i]];
605  free_traceback(nets_in_cluster[i]);
606  best_routing[nets_in_cluster[i]] = NULL;
607  }
608 
610  num_nets_in_cluster = 0;
612 }
void free_traceback(int inet)
Definition: route_common.c:587
struct s_trace ** trace_head
Definition: globals.c:64
static int num_nets_in_cluster
static int * nets_in_cluster
void free_rr_node_route_structs(void)
Definition: route_common.c:828
static int saved_num_nets_in_cluster
static struct s_trace ** best_routing

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void restore_routing_cluster ( void  )

Definition at line 1048 of file cluster_legality.c.

1048  {
1049 
1050  /* Deallocates any current routing in trace_head, and replaces it with *
1051  * the routing in best_routing. Best_routing is set to NULL to show that *
1052  * it no longer points to a valid routing. NOTE: trace_tail is not *
1053  * restored -- it is set to all NULLs since it is only used in *
1054  * update_traceback. If you need trace_tail restored, modify this *
1055  * routine. Also restores the locally used opin data. */
1056 
1057  int inet, i, j;
1058 
1059  for (i = 0; i < num_nets_in_cluster; i++) {
1060  inet = nets_in_cluster[i];
1061 
1063 
1064  /* Free any current routing. */
1065  free_traceback(inet);
1066 
1067  /* Set the current routing to the saved one. */
1068  trace_head[inet] = best_routing[inet];
1069  best_routing[inet] = NULL; /* No stored routing. */
1070 
1071  /* restore net terminals */
1072  for (j = 0; j <= vpack_net[inet].num_sinks; j++) {
1073  net_rr_terminals[inet][j] = saved_net_rr_terminals[inet][j];
1074  }
1075 
1076  /* restore old routing */
1078  }
1079  num_nets_in_cluster = saved_num_nets_in_cluster;
1080 }
void free_traceback(int inet)
Definition: route_common.c:587
static float pres_fac
struct s_trace ** trace_head
Definition: globals.c:64
static int num_nets_in_cluster
void pathfinder_update_one_cost(struct s_trace *route_segment_start, int add_or_sub, float pres_fac)
Definition: route_common.c:315
static int * nets_in_cluster
int ** net_rr_terminals
Definition: globals.c:78
struct s_net * vpack_net
Definition: globals.c:19
static int ** saved_net_rr_terminals
static int saved_num_nets_in_cluster
int num_sinks
Definition: vpr_types.h:506
static struct s_trace ** best_routing

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void save_and_reset_routing_cluster ( void  )

Definition at line 1011 of file cluster_legality.c.

1011  {
1012 
1013  /* This routing frees any routing currently held in best routing, *
1014  * then copies over the current routing (held in trace_head), and *
1015  * finally sets trace_head and trace_tail to all NULLs so that the *
1016  * connection to the saved routing is broken. This is necessary so *
1017  * that the next iteration of the router does not free the saved *
1018  * routing elements. Also, the routing path costs and net_rr_terminals is stripped from the
1019  * existing rr_graph so that the saved routing does not affect the graph */
1020 
1021  int inet, i, j;
1022  struct s_trace *tempptr;
1024 
1025  for (i = 0; i < num_nets_in_cluster; i++) {
1026  inet = nets_in_cluster[i];
1027  for (j = 0; j <= vpack_net[inet].num_sinks; j++) {
1028  saved_net_rr_terminals[inet][j] = net_rr_terminals[inet][j];
1029  }
1030 
1031  /* Free any previously saved routing. It is no longer best. */
1032  /* Also Save a pointer to the current routing in best_routing. */
1033 
1035  tempptr = trace_head[inet];
1036  trace_head[inet] = best_routing[inet];
1037  free_traceback(inet);
1038  best_routing[inet] = tempptr;
1039 
1040  /* Set the current (working) routing to NULL so the current trace *
1041  * elements won't be reused by the memory allocator. */
1042 
1043  trace_head[inet] = NULL;
1044  trace_tail[inet] = NULL;
1045  }
1046 }
struct s_trace ** trace_tail
Definition: globals.c:65
void free_traceback(int inet)
Definition: route_common.c:587
static float pres_fac
struct s_trace ** trace_head
Definition: globals.c:64
static int num_nets_in_cluster
void pathfinder_update_one_cost(struct s_trace *route_segment_start, int add_or_sub, float pres_fac)
Definition: route_common.c:315
static int * nets_in_cluster
int ** net_rr_terminals
Definition: globals.c:78
struct s_net * vpack_net
Definition: globals.c:19
static int ** saved_net_rr_terminals
static int saved_num_nets_in_cluster
int num_sinks
Definition: vpr_types.h:506
static struct s_trace ** best_routing

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void save_cluster_solution ( void  )

Definition at line 1082 of file cluster_legality.c.

1082  {
1083 
1084  /* This routine updates the occupancy and pres_cost of the rr_nodes that are *
1085  * affected by the portion of the routing of one net that starts at *
1086  * route_segment_start. If route_segment_start is trace_head[inet], the *
1087  * cost of all the nodes in the routing of net inet are updated. If *
1088  * add_or_sub is -1 the net (or net portion) is ripped up, if it is 1 the *
1089  * net is added to the routing. The size of pres_fac determines how severly *
1090  * oversubscribed rr_nodes are penalized. */
1091 
1092  int i, j, net_index;
1093  struct s_trace *tptr, *prev;
1094  int inode;
1095  for (i = 0; i < max_ext_index; i++) {
1096  rr_node[i].net_num = OPEN;
1097  rr_node[i].prev_edge = OPEN;
1098  rr_node[i].prev_node = OPEN;
1099  }
1100  for (i = 0; i < num_nets_in_cluster; i++) {
1101  prev = NULL;
1102  net_index = nets_in_cluster[i];
1103  tptr = trace_head[net_index];
1104  if (tptr == NULL) /* No routing yet. */
1105  return;
1106 
1107  for (;;) {
1108  inode = tptr->index;
1109  rr_node[inode].net_num = net_index;
1110  if (prev != NULL) {
1111  rr_node[inode].prev_node = prev->index;
1112  for (j = 0; j < rr_node[prev->index].num_edges; j++) {
1113  if (rr_node[prev->index].edges[j] == inode) {
1114  rr_node[inode].prev_edge = j;
1115  break;
1116  }
1117  }
1118  assert(j != rr_node[prev->index].num_edges);
1119  } else {
1120  rr_node[inode].prev_node = OPEN;
1121  rr_node[inode].prev_edge = OPEN;
1122  }
1123 
1124  if (rr_node[inode].type == SINK) {
1125  tptr = tptr->next; /* Skip next segment. */
1126  if (tptr == NULL)
1127  break;
1128  }
1129 
1130  prev = tptr;
1131  tptr = tptr->next;
1132 
1133  } /* End while loop -- did an entire traceback. */
1134  }
1135 }
short num_edges
Definition: vpr_types.h:901
int index
Definition: vpr_types.h:866
int * edges
Definition: vpr_types.h:903
t_rr_node * rr_node
Definition: globals.c:70
int net_num
Definition: vpr_types.h:917
int prev_node
Definition: vpr_types.h:915
struct s_trace * next
Definition: vpr_types.h:870
struct s_trace ** trace_head
Definition: globals.c:64
static int num_nets_in_cluster
static int * nets_in_cluster
Definition: slre.c:50
static int max_ext_index
int prev_edge
Definition: vpr_types.h:916

+ Here is the caller graph for this function:

void set_pb_graph_mode ( t_pb_graph_node pb_graph_node,
int  mode,
int  isOn 
)

Definition at line 1149 of file cluster_legality.c.

1149  {
1150  int i, j, index;
1151  int i_pb_type, i_pb_inst;
1152  const t_pb_type *pb_type;
1153 
1154  pb_type = pb_graph_node->pb_type;
1155  for (i_pb_type = 0; i_pb_type < pb_type->modes[mode].num_pb_type_children;
1156  i_pb_type++) {
1157  for (i_pb_inst = 0;
1158  i_pb_inst
1159  < pb_type->modes[mode].pb_type_children[i_pb_type].num_pb;
1160  i_pb_inst++) {
1161  for (i = 0;
1162  i
1163  < pb_graph_node->child_pb_graph_nodes[mode][i_pb_type][i_pb_inst].num_input_ports;
1164  i++) {
1165  for (j = 0;
1166  j
1167  < pb_graph_node->child_pb_graph_nodes[mode][i_pb_type][i_pb_inst].num_input_pins[i];
1168  j++) {
1169  index =
1170  pb_graph_node->child_pb_graph_nodes[mode][i_pb_type][i_pb_inst].input_pins[i][j].pin_count_in_cluster;
1171  rr_node[index].capacity = isOn;
1172  }
1173  }
1174 
1175  for (i = 0;
1176  i
1177  < pb_graph_node->child_pb_graph_nodes[mode][i_pb_type][i_pb_inst].num_output_ports;
1178  i++) {
1179  for (j = 0;
1180  j
1181  < pb_graph_node->child_pb_graph_nodes[mode][i_pb_type][i_pb_inst].num_output_pins[i];
1182  j++) {
1183  index =
1184  pb_graph_node->child_pb_graph_nodes[mode][i_pb_type][i_pb_inst].output_pins[i][j].pin_count_in_cluster;
1185  rr_node[index].capacity = isOn;
1186  }
1187  }
1188 
1189  for (i = 0;
1190  i
1191  < pb_graph_node->child_pb_graph_nodes[mode][i_pb_type][i_pb_inst].num_clock_ports;
1192  i++) {
1193  for (j = 0;
1194  j
1195  < pb_graph_node->child_pb_graph_nodes[mode][i_pb_type][i_pb_inst].num_clock_pins[i];
1196  j++) {
1197  index =
1198  pb_graph_node->child_pb_graph_nodes[mode][i_pb_type][i_pb_inst].clock_pins[i][j].pin_count_in_cluster;
1199  rr_node[index].capacity = isOn;
1200  }
1201  }
1202  }
1203  }
1204 }
t_pb_graph_pin ** clock_pins
int index
Definition: vpr_types.h:866
struct s_pb_type * pb_type_children
t_rr_node * rr_node
Definition: globals.c:70
t_mode * modes
t_pb_graph_pin ** output_pins
short capacity
Definition: vpr_types.h:899
struct s_pb_graph_node *** child_pb_graph_nodes
int num_pb_type_children
struct s_pb_type * pb_type
t_pb_graph_pin ** input_pins

+ Here is the caller graph for this function:

void setup_intracluster_routing_for_logical_block ( INP int  iblock,
INP t_pb_graph_node primitive 
)

Definition at line 947 of file cluster_legality.c.

948  {
949 
950  /* Allocates and loads the net_rr_terminals data structure. For each net *
951  * it stores the rr_node index of the SOURCE of the net and all the SINKs *
952  * of the net. [0..num_logical_nets-1][0..num_pins-1]. */
953  int ipin, iblk_net;
954  t_model_ports *port;
955 
956  assert(primitive->pb_type->num_modes == 0);
957  /* check if primitive */
958  assert(logical_block[iblock].clb_index != NO_CLUSTER);
959  /* check if primitive and block is open */
960 
961  /* check if block type matches primitive type */
962  if (logical_block[iblock].model != primitive->pb_type->model) {
963  /* End early, model is incompatible */
964  assert(0);
965  }
966 
967  /* for each net of logical block, check if it is in cluster, if not add it */
968  /* also check if pins on primitive can fit logical block */
969 
970  port = logical_block[iblock].model->inputs;
971 
972  while (port) {
973  for (ipin = 0; ipin < port->size; ipin++) {
974  if (port->is_clock) {
975  assert(port->size == 1);
976  iblk_net = logical_block[iblock].clock_net;
977  } else {
978  iblk_net = logical_block[iblock].input_nets[port->index][ipin];
979  }
980  if (iblk_net == OPEN) {
981  continue;
982  }
983  if (!is_net_in_cluster(iblk_net)) {
986  }
987  add_net_rr_terminal_cluster(iblk_net, primitive, iblock, port,
988  ipin);
989  }
990  port = port->next;
991  }
992 
994  while (port) {
995  for (ipin = 0; ipin < port->size; ipin++) {
996  iblk_net = logical_block[iblock].output_nets[port->index][ipin];
997  if (iblk_net == OPEN) {
998  continue;
999  }
1000  if (!is_net_in_cluster(iblk_net)) {
1003  }
1004  add_net_rr_terminal_cluster(iblk_net, primitive, iblock, port,
1005  ipin);
1006  }
1007  port = port->next;
1008  }
1009 }
static void add_net_rr_terminal_cluster(int iblk_net, t_pb_graph_node *primitive, int ilogical_block, t_model_ports *model_port, int ipin)
int ** input_nets
Definition: vpr_types.h:211
struct s_model_ports * next
Definition: logic_types.h:28
boolean is_clock
Definition: logic_types.h:26
#define NO_CLUSTER
Definition: vpr_types.h:98
t_model_ports * inputs
Definition: logic_types.h:35
static int num_nets_in_cluster
t_model_ports * outputs
Definition: logic_types.h:36
static char * model
Definition: read_blif.c:45
int iblock
Definition: vpr_types.h:868
static boolean is_net_in_cluster(INP int inet)
static int * nets_in_cluster
Definition: slre.c:50
t_model * model
Definition: vpr_types.h:209
int ** output_nets
Definition: vpr_types.h:212
struct s_logical_block * logical_block
Definition: globals.c:20

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void setup_intracluster_routing_for_molecule ( INP t_pack_molecule molecule,
INOUTP t_pb_graph_node **  primitives_list 
)
boolean try_breadth_first_route_cluster ( void  )

internal_nets: index of nets to route [0..num_internal_nets - 1]

Definition at line 618 of file cluster_legality.c.

618  {
619 
620  /* Iterated maze router ala Pathfinder Negotiated Congestion algorithm, *
621  * (FPGA 95 p. 111). Returns TRUE if it can route this FPGA, FALSE if *
622  * it can't. */
623 
624  /* For different modes, when a mode is turned on, I set the max occupancy of all rr_nodes in the mode to 1 and all others to 0 */
625  /* TODO: There is a bug for route-throughs where edges in route-throughs do not get turned off because the rr_edge is in a particular mode but the two rr_nodes are outside */
626 
627  boolean success, is_routable;
628  int itry, inet, net_index;
629  struct s_router_opts router_opts;
630 
631  /* Usually the first iteration uses a very small (or 0) pres_fac to find *
632  * the shortest path and get a congestion map. For fast compiles, I set *
633  * pres_fac high even for the first iteration. */
634 
635  /* sets up a fast breadth-first router */
636  router_opts.first_iter_pres_fac = 10;
637  router_opts.max_router_iterations = 20;
638  router_opts.initial_pres_fac = 10;
639  router_opts.pres_fac_mult = 2;
640  router_opts.acc_fac = 1;
641 
642  reset_rr_node_route_structs(); /* Clear all prior rr_graph history */
643 
644  pres_fac = router_opts.first_iter_pres_fac;
645 
646  for (itry = 1; itry <= router_opts.max_router_iterations; itry++) {
647  for (inet = 0; inet < num_nets_in_cluster; inet++) {
648  net_index = nets_in_cluster[inet];
649 
651 
652  is_routable = breadth_first_route_net_cluster(net_index);
653 
654  /* Impossible to route? (disconnected rr_graph) */
655 
656  if (!is_routable) {
657  /* TODO: Inelegant, can be more intelligent */
658  vpr_printf(TIO_MESSAGE_INFO, "Failed routing net %s\n", vpack_net[net_index].name);
659  vpr_printf(TIO_MESSAGE_INFO, "Routing failed. Disconnected rr_graph.\n");
660  return FALSE;
661  }
662 
664 
665  }
666 
667  success = feasible_routing();
668  if (success) {
669  return (TRUE);
670  }
671 
672  if (itry == 1)
673  pres_fac = router_opts.initial_pres_fac;
674  else
675  pres_fac *= router_opts.pres_fac_mult;
676 
677  pres_fac = std::min(pres_fac, static_cast<float>(HUGE_POSITIVE_FLOAT / 1e5));
678 
679  pathfinder_update_cost(pres_fac, router_opts.acc_fac);
680  }
681 
682  return (FALSE);
683 }
boolean feasible_routing(void)
Definition: route_common.c:298
float first_iter_pres_fac
Definition: vpr_types.h:696
void pathfinder_update_cost(float pres_fac, float acc_fac)
Definition: route_common.c:363
Definition: util.h:12
static float pres_fac
#define min(a, b)
Definition: graphics.c:174
#define HUGE_POSITIVE_FLOAT
Definition: vpr_types.h:79
struct s_trace ** trace_head
Definition: globals.c:64
static int num_nets_in_cluster
static boolean breadth_first_route_net_cluster(int inet)
void pathfinder_update_one_cost(struct s_trace *route_segment_start, int add_or_sub, float pres_fac)
Definition: route_common.c:315
void reset_rr_node_route_structs(void)
Definition: route_common.c:809
static int * nets_in_cluster
struct s_net * vpack_net
Definition: globals.c:19
messagelogger vpr_printf
Definition: util.c:17
Definition: util.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function: