VPR-7.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
rr_graph_util.c
Go to the documentation of this file.
1 #include "util.h"
2 #include "vpr_types.h"
3 #include "globals.h"
4 #include "rr_graph_util.h"
5 
7 insert_in_edge_list(INP t_linked_edge * head, INP int edge, INP short iswitch) {
8 
9  /* Inserts a new element at the head of a linked list. Returns the new head *
10  * of the list. One argument is the address of the head of a list of free *
11  * edge_list elements. If there are any elements on this free list, the new *
12  * element is taken from it. Otherwise a new one is malloced. */
13 
14  t_linked_edge *linked_edge;
15 
16  linked_edge = (t_linked_edge *) my_malloc(sizeof(t_linked_edge));
17 
18  linked_edge->edge = edge;
19  linked_edge->iswitch = iswitch;
20  linked_edge->next = head;
21 
22  return linked_edge;
23 }
24 
25 #if 0
26 void
27 free_linked_edge_soft(INOUT t_linked_edge * edge_ptr,
28  INOUT t_linked_edge ** free_list_head_ptr)
29 {
30 
31  /* This routine does a soft free of the structure pointed to by edge_ptr by *
32  * adding it to the free list. You have to pass in the address of the *
33  * head of the free list. */
34 
35  edge_ptr->next = *free_list_head_ptr;
36  *free_list_head_ptr = edge_ptr;
37 }
38 #endif
39 
40 int seg_index_of_cblock(t_rr_type from_rr_type, int to_node) {
41 
42  /* Returns the segment number (distance along the channel) of the connection *
43  * box from from_rr_type (CHANX or CHANY) to to_node (IPIN). */
44 
45  if (from_rr_type == CHANX)
46  return (rr_node[to_node].xlow);
47  else
48  /* CHANY */
49  return (rr_node[to_node].ylow);
50 }
51 
52 int seg_index_of_sblock(int from_node, int to_node) {
53 
54  /* Returns the segment number (distance along the channel) of the switch box *
55  * box from from_node (CHANX or CHANY) to to_node (CHANX or CHANY). The *
56  * switch box on the left side of a CHANX segment at (i,j) has seg_index = *
57  * i-1, while the switch box on the right side of that segment has seg_index *
58  * = i. CHANY stuff works similarly. Hence the range of values returned is *
59  * 0 to nx (if from_node is a CHANX) or 0 to ny (if from_node is a CHANY). */
60 
61  t_rr_type from_rr_type, to_rr_type;
62 
63  from_rr_type = rr_node[from_node].type;
64  to_rr_type = rr_node[to_node].type;
65 
66  if (from_rr_type == CHANX) {
67  if (to_rr_type == CHANY) {
68  return (rr_node[to_node].xlow);
69  } else if (to_rr_type == CHANX) {
70  if (rr_node[to_node].xlow > rr_node[from_node].xlow) { /* Going right */
71  return (rr_node[from_node].xhigh);
72  } else { /* Going left */
73  return (rr_node[to_node].xhigh);
74  }
75  } else {
76  vpr_printf(TIO_MESSAGE_ERROR, "in seg_index_of_sblock: to_node %d is of type %d.\n",
77  to_node, to_rr_type);
78  exit(1);
79  }
80  }
81  /* End from_rr_type is CHANX */
82  else if (from_rr_type == CHANY) {
83  if (to_rr_type == CHANX) {
84  return (rr_node[to_node].ylow);
85  } else if (to_rr_type == CHANY) {
86  if (rr_node[to_node].ylow > rr_node[from_node].ylow) { /* Going up */
87  return (rr_node[from_node].yhigh);
88  } else { /* Going down */
89  return (rr_node[to_node].yhigh);
90  }
91  } else {
92  vpr_printf(TIO_MESSAGE_ERROR, "in seg_index_of_sblock: to_node %d is of type %d.\n",
93  to_node, to_rr_type);
94  exit(1);
95  }
96  }
97  /* End from_rr_type is CHANY */
98  else {
99  vpr_printf(TIO_MESSAGE_ERROR, "in seg_index_of_sblock: from_node %d is of type %d.\n",
100  from_node, from_rr_type);
101  exit(1);
102  }
103 }
int seg_index_of_cblock(t_rr_type from_rr_type, int to_node)
Definition: rr_graph_util.c:40
t_rr_node * rr_node
Definition: globals.c:70
t_linked_edge * insert_in_edge_list(INP t_linked_edge *head, INP int edge, INP short iswitch)
Definition: rr_graph_util.c:7
int seg_index_of_sblock(int from_node, int to_node)
Definition: rr_graph_util.c:52
static void * my_malloc(int ibytes)
Definition: graphics.c:499
#define INP
Definition: util.h:19
enum e_rr_type t_rr_type
void free_linked_edge_soft(t_linked_edge *edge_ptr, t_linked_edge **free_list_head_ptr)
messagelogger vpr_printf
Definition: util.c:17
t_rr_type type
Definition: vpr_types.h:902
struct s_linked_edge * next
Definition: rr_graph_util.h:4