1
1
#ifndef RR_SPATIAL_LOOKUP_H
2
2
#define RR_SPATIAL_LOOKUP_H
3
3
4
- # include " vtr_geometry.h "
5
- # include " vtr_vector.h "
6
- # include " vpr_types.h "
7
-
8
- /* *******************************************************************
4
+ /* *
5
+ * @file
6
+ * @brief This RRSpatialLookup class encapsulates
7
+ * the node-lookup for a routing resource graph
8
+ *
9
9
* A data structure built to find the id of an routing resource node
10
10
* (rr_node) given information about its physical position and type.
11
- * The data structure is mostly needed during rr_graph building
11
+ * The data structure is mostly needed during building a routing resource graph
12
12
*
13
13
* The data structure allows users to
14
- * - Update the look-up with new nodes
15
- * - Find the id of a node with given information, e.g., x, y, type etc.
16
- ********************************************************************/
14
+ *
15
+ * - Update the look-up with new nodes
16
+ * - Find the id of a node with given information, e.g., x, y, type etc.
17
+ */
18
+ #include " vtr_geometry.h"
19
+ #include " vtr_vector.h"
20
+ #include " vpr_types.h"
21
+
17
22
class RRSpatialLookup {
18
23
/* -- Constructors -- */
19
24
public:
@@ -32,26 +37,28 @@ class RRSpatialLookup {
32
37
/* -- Accessors -- */
33
38
public:
34
39
/* *
35
- * Returns the index of the specified routing resource node.
36
- * - (x, y) are the grid location within the FPGA
37
- * - rr_type specifies the type of resource,
38
- * - ptc gives a unique number of resources of that type (e.g. CHANX) at that (x,y).
39
- * All ptcs start at 0 and are positive.
40
- * Depending on what type of resource this is, ptc can be
41
- * - the class number of a common SINK/SOURCE node of grid,
42
- * starting at 0 and go up to class_inf size - 1 of SOURCEs + SINKs in a grid
43
- * - pin number of an input/output pin of a grid. They would normally start at 0
44
- * and go to the number of pins on a block at that (x, y) location
45
- * - track number of a routing wire in a channel. They would normally go from 0
46
- * to channel_width - 1 at that (x,y)
40
+ * @brief Returns the index of the specified routing resource node.
41
+ *
42
+ * @param (x, y) are the grid location within the FPGA
43
+ * @param rr_type specifies the type of resource,
44
+ * @param ptc gives a unique number of resources of that type (e.g. CHANX) at that (x,y).
47
45
*
48
- * An invalid id will be returned if the node does not exist
46
+ * @note All ptcs start at 0 and are positive.
47
+ * Depending on what type of resource this is, ptc can be
48
+ * - the class number of a common SINK/SOURCE node of grid,
49
+ * starting at 0 and go up to class_inf size - 1 of SOURCEs + SINKs in a grid
50
+ * - pin number of an input/output pin of a grid. They would normally start at 0
51
+ * and go to the number of pins on a block at that (x, y) location
52
+ * - track number of a routing wire in a channel. They would normally go from 0
53
+ * to channel_width - 1 at that (x,y)
49
54
*
50
- * Note that for segments (CHANX and CHANY) of length > 1, the segment is
55
+ * @note An invalid id will be returned if the node does not exist
56
+ *
57
+ * @note For segments (CHANX and CHANY) of length > 1, the segment is
51
58
* given an rr_index based on the (x,y) location at which it starts (i.e.
52
59
* lowest (x,y) location at which this segment exists).
53
60
*
54
- * The 'side' argument only applies to IPIN/OPIN types, and specifies which
61
+ * @note The 'side' argument only applies to IPIN/OPIN types, and specifies which
55
62
* side of the grid tile the node should be located on. The value is ignored
56
63
* for non-IPIN/OPIN types
57
64
*
@@ -65,12 +72,12 @@ class RRSpatialLookup {
65
72
e_side side = NUM_SIDES) const ;
66
73
67
74
/* *
68
- * Returns the indices of the specified routing resource nodes,
69
- * representing routing tracks in a channel.
70
- * - (x, y) are the coordinate of the routing channel within the FPGA
71
- * - rr_type specifies the type of routing channel, either x-direction or y-direction
75
+ * @brief Returns the indices of the specified routing resource nodes, representing routing tracks in a channel.
76
+ *
77
+ * @param (x, y) are the coordinate of the routing channel within the FPGA
78
+ * @param rr_type specifies the type of routing channel, either x-direction or y-direction
72
79
*
73
- * Note:
80
+ * @note
74
81
* - Return an empty list if there are no routing channel at the given (x, y) location
75
82
* - The node list returned only contain valid ids
76
83
* For example, if the 2nd routing track does not exist in a routing channel at (x, y) location,
@@ -83,7 +90,8 @@ class RRSpatialLookup {
83
90
t_rr_type type) const ;
84
91
85
92
/* *
86
- * Like find_node() but returns all matching nodes on all the sides.
93
+ * @brief Like find_node() but returns all matching nodes on all the sides.
94
+ *
87
95
* This is particularly useful for getting all instances
88
96
* of a specific IPIN/OPIN at a specific grid tile (x,y) location.
89
97
*/
@@ -93,7 +101,8 @@ class RRSpatialLookup {
93
101
int ptc) const ;
94
102
95
103
/* *
96
- * Returns all matching nodes on all the sides at a specific grid tile (x,y) location.
104
+ * @brief Returns all matching nodes on all the sides at a specific grid tile (x,y) location.
105
+ *
97
106
* As this is applicable to grid pins, the type of nodes are limited to SOURCE/SINK/IPIN/OPIN
98
107
*/
99
108
std::vector<RRNodeId> find_grid_nodes_at_all_sides (int x,
@@ -102,29 +111,30 @@ class RRSpatialLookup {
102
111
103
112
/* -- Mutators -- */
104
113
public:
105
- /* *
106
- * Reserve the memory for a list of nodes at (x, y) location with given type and side
107
- */
114
+ /* * @brief Reserve the memory for a list of nodes at (x, y) location with given type and side */
108
115
void reserve_nodes (int x,
109
116
int y,
110
117
t_rr_type type,
111
118
int num_nodes,
112
119
e_side side = SIDES[0 ]);
113
120
114
121
/* *
115
- * Register a node in the fast look-up
116
- * - You must have a valid node id to register the node in the lookup
117
- * - (x, y) are the coordinate of the node to be indexable in the fast look-up
118
- * - type is the type of a node
119
- * - ptc is a feature number of a node, which can be
120
- * - the class number of a common SINK/SOURCE node of grid,
121
- * - pin index in a tile when type is OPIN/IPIN
122
- * - track index in a routing channel when type is CHANX/CHANY
123
- * - side is the side of node on the tile, applicable to OPIN/IPIN
124
- *
125
- * Note that a node added with this call will not create a node in the rr_graph_storage node list
126
- * You MUST add the node in the rr_graph_storage so that the node is valid
122
+ * @brief Register a node in the fast look-up
123
+ *
124
+ * @note You must have a valid node id to register the node in the lookup
127
125
*
126
+ * @param (x, y) are the coordinate of the node to be indexable in the fast look-up
127
+ * @param type is the type of a node
128
+ * @param ptc is a feature number of a node, which can be
129
+ * - the class number of a common SINK/SOURCE node of grid,
130
+ * - pin index in a tile when type is OPIN/IPIN
131
+ * - track index in a routing channel when type is CHANX/CHANY
132
+ * @param side is the side of node on the tile, applicable to OPIN/IPIN
133
+ *
134
+ * @note a node added with this call will not create a node in the rr_graph_storage node list
135
+ * You MUST add the node in the rr_graph_storage so that the node is valid
136
+ */
137
+ /*
128
138
* TODO: Consider to try to return a reference to *this so that we can do chain calls
129
139
* - .add_node(...)
130
140
* - .add_node(...)
@@ -139,14 +149,17 @@ class RRSpatialLookup {
139
149
e_side side = SIDES[0 ]);
140
150
141
151
/* *
142
- * Mirror the last dimension of a look-up, i.e., a list of nodes, from a source coordinate to
152
+ * @brief Mirror the last dimension of a look-up, i.e., a list of nodes, from a source coordinate to
143
153
* a destination coordinate.
154
+ *
144
155
* This function is mostly need by SOURCE and SINK nodes which are indexable in multiple locations.
145
156
* Considering a bounding box (x, y)->(x + width, y + height) of a multi-height and multi-width grid,
146
157
* SOURCE and SINK nodes are indexable in any location inside the boundry.
147
158
*
148
159
* An example of usage:
149
- *
160
+ *
161
+ *
162
+ * ```
150
163
* // Create a empty lookup
151
164
* RRSpatialLookup rr_lookup;
152
165
* // Adding other nodes ...
@@ -155,14 +168,21 @@ class RRSpatialLookup {
155
168
* vtr::Point<int>(1, 2),
156
169
* SOURCE,
157
170
* TOP);
171
+ * ```
158
172
*
159
- * Note: currently this function only accepts SOURCE/SINK nodes. May unlock for the other types
173
+ * @note currently this function only accepts SOURCE/SINK nodes. May unlock for the other types
160
174
* depending on needs
161
- *
175
+ */
176
+ /*
162
177
* TODO: Consider to make a high-level API to duplicate the nodes for large blocks.
163
178
* Then this API can become a private one
164
179
* For example,
180
+ *
181
+ *
182
+ * ```
165
183
* expand_nodes(source_coordinate, bounding_box_coordinate, type, side);
184
+ * ```
185
+ *
166
186
* Alternatively, we can rework the ``find_node()`` API so that we always search the lowest (x,y)
167
187
* corner when dealing with large blocks. But this may require the data structure to be dependent
168
188
* on DeviceGrid information (it needs to identify if a grid has height > 1 as well as width > 1)
@@ -173,11 +193,13 @@ class RRSpatialLookup {
173
193
e_side side);
174
194
175
195
/* *
176
- * Resize the given 3 dimensions (x, y, side) of the RRSpatialLookup data structure for the given type
177
- * This function will keep any existing data
196
+ * @brief Resize the given 3 dimensions (x, y, side) of the RRSpatialLookup data structure for the given type
178
197
*
179
- * Strongly recommend to use when the sizes of dimensions are deterministic
198
+ * This function will keep any existing data
180
199
*
200
+ * @note Strongly recommend to use when the sizes of dimensions are deterministic
201
+ */
202
+ /*
181
203
* TODO: should have a reserve function but vtd::ndmatrix does not have such API
182
204
* as a result, resize can be an internal one while reserve function is a public mutator
183
205
*/
@@ -186,10 +208,10 @@ class RRSpatialLookup {
186
208
t_rr_type type,
187
209
e_side side);
188
210
189
- /* Reorder the internal look up to be more memory efficient */
211
+ /* * @brief Reorder the internal look up to be more memory efficient */
190
212
void reorder (const vtr::vector<RRNodeId, RRNodeId> dest_order);
191
213
192
- /* Clear all the data inside */
214
+ /* * @brief Clear all the data inside */
193
215
void clear ();
194
216
195
217
/* -- Internal data queries -- */
0 commit comments