Skip to content

Commit eb3be2b

Browse files
authored
Merge pull request #1837 from verilog-to-routing/rr_graph_api_doc
Add ``RRGraph``-related API to documentation and clean-up ``RRSpatialLookup`` methods
2 parents f4cc9a3 + e7d2255 commit eb3be2b

File tree

4 files changed

+138
-74
lines changed

4 files changed

+138
-74
lines changed

doc/src/api/vpr/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ VPR API
88

99
contexts
1010
netlist
11+
rr_graph

doc/src/api/vpr/rr_graph.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
======================
2+
Routing Resource Graph
3+
======================
4+
5+
RRGraphView
6+
-----------
7+
8+
.. doxygenfile:: rr_graph_view.h
9+
:project: vpr
10+
:sections: detaileddescription
11+
12+
.. doxygenclass:: RRGraphView
13+
:project: vpr
14+
:members:
15+
16+
RRGraphBuilder
17+
--------------
18+
19+
.. doxygenfile:: rr_graph_builder.h
20+
:project: vpr
21+
:sections: detaileddescription
22+
23+
.. doxygenclass:: RRGraphBuilder
24+
:project: vpr
25+
:members:
26+
27+
RRSpatialLookup
28+
---------------
29+
30+
.. doxygenfile:: rr_spatial_lookup.h
31+
:project: vpr
32+
:sections: detaileddescription
33+
34+
.. doxygenclass:: RRSpatialLookup
35+
:project: vpr
36+
:members:
37+

vpr/src/device/rr_graph_builder.h

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
#ifndef RR_GRAPH_BUILDER_H
22
#define RR_GRAPH_BUILDER_H
33

4-
#include "rr_graph_storage.h"
5-
#include "rr_spatial_lookup.h"
6-
7-
/* A data structure allows data modification on a routing resource graph
4+
/**
5+
* @file
6+
* @brief This file defines the RRGraphBuilder data structure which allows data modification on a routing resource graph
87
*
9-
* Note that the builder does not own the storage
10-
* It serves a virtual protocol for
11-
* - node_storage: store the node list
12-
* - node_lookup: store a fast look-up for the nodes
8+
* The builder does not own the storage but it serves a virtual protocol for
9+
* - node_storage: store the node list
10+
* - node_lookup: store a fast look-up for the nodes
1311
*
14-
* Note:
15-
* - This is the only data structre allowed to modify a routing resource graph
12+
* @note
13+
* - This is the only data structure allowed to modify a routing resource graph
1614
*
1715
*/
16+
#include "rr_graph_storage.h"
17+
#include "rr_spatial_lookup.h"
18+
1819
class RRGraphBuilder {
1920
/* -- Constructors -- */
2021
public:
@@ -32,23 +33,26 @@ class RRGraphBuilder {
3233

3334
/* -- Mutators -- */
3435
public:
35-
/* Return a writable object for rr_nodes */
36+
/** @brief Return a writable object for rr_nodes */
3637
t_rr_graph_storage& node_storage();
37-
/* Return a writable object for update the fast look-up of rr_node */
38+
/** @brief Return a writable object for update the fast look-up of rr_node */
3839
RRSpatialLookup& node_lookup();
39-
/* Add an existing rr_node in the node storage to the node look-up
40+
/**
41+
* @brief Add an existing rr_node in the node storage to the node look-up
42+
*
4043
* The node will be added to the lookup for every side it is on (for OPINs and IPINs)
4144
* and for every (x,y) location at which it exists (for wires that span more than one (x,y)).
45+
*
4246
* This function requires a valid node which has already been allocated in the node storage, with
43-
* - a valid node id
44-
* - valid geometry information: xlow/ylow/xhigh/yhigh
45-
* - a valid node type
46-
* - a valid node ptc number
47-
* - a valid side (applicable to OPIN and IPIN nodes only
47+
* - a valid node id
48+
* - valid geometry information: xlow/ylow/xhigh/yhigh
49+
* - a valid node type
50+
* - a valid node ptc number
51+
* - a valid side (applicable to OPIN and IPIN nodes only
4852
*/
4953
void add_node_to_all_locs(RRNodeId node);
5054

51-
/* Clear all the underlying data storage */
55+
/** @brief Clear all the underlying data storage */
5256
void clear();
5357

5458
/* -- Internal data storage -- */

vpr/src/device/rr_spatial_lookup.h

Lines changed: 77 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
#ifndef RR_SPATIAL_LOOKUP_H
22
#define RR_SPATIAL_LOOKUP_H
33

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+
*
99
* A data structure built to find the id of an routing resource node
1010
* (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
1212
*
1313
* 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+
1722
class RRSpatialLookup {
1823
/* -- Constructors -- */
1924
public:
@@ -32,26 +37,28 @@ class RRSpatialLookup {
3237
/* -- Accessors -- */
3338
public:
3439
/**
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).
4745
*
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)
4954
*
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
5158
* given an rr_index based on the (x,y) location at which it starts (i.e.
5259
* lowest (x,y) location at which this segment exists).
5360
*
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
5562
* side of the grid tile the node should be located on. The value is ignored
5663
* for non-IPIN/OPIN types
5764
*
@@ -65,12 +72,12 @@ class RRSpatialLookup {
6572
e_side side = NUM_SIDES) const;
6673

6774
/**
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
7279
*
73-
* Note:
80+
* @note
7481
* - Return an empty list if there are no routing channel at the given (x, y) location
7582
* - The node list returned only contain valid ids
7683
* For example, if the 2nd routing track does not exist in a routing channel at (x, y) location,
@@ -83,7 +90,8 @@ class RRSpatialLookup {
8390
t_rr_type type) const;
8491

8592
/**
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+
*
8795
* This is particularly useful for getting all instances
8896
* of a specific IPIN/OPIN at a specific grid tile (x,y) location.
8997
*/
@@ -93,7 +101,8 @@ class RRSpatialLookup {
93101
int ptc) const;
94102

95103
/**
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+
*
97106
* As this is applicable to grid pins, the type of nodes are limited to SOURCE/SINK/IPIN/OPIN
98107
*/
99108
std::vector<RRNodeId> find_grid_nodes_at_all_sides(int x,
@@ -102,29 +111,30 @@ class RRSpatialLookup {
102111

103112
/* -- Mutators -- */
104113
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 */
108115
void reserve_nodes(int x,
109116
int y,
110117
t_rr_type type,
111118
int num_nodes,
112119
e_side side = SIDES[0]);
113120

114121
/**
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
127125
*
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+
/*
128138
* TODO: Consider to try to return a reference to *this so that we can do chain calls
129139
* - .add_node(...)
130140
* - .add_node(...)
@@ -139,14 +149,17 @@ class RRSpatialLookup {
139149
e_side side = SIDES[0]);
140150

141151
/**
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
143153
* a destination coordinate.
154+
*
144155
* This function is mostly need by SOURCE and SINK nodes which are indexable in multiple locations.
145156
* Considering a bounding box (x, y)->(x + width, y + height) of a multi-height and multi-width grid,
146157
* SOURCE and SINK nodes are indexable in any location inside the boundry.
147158
*
148159
* An example of usage:
149-
*
160+
*
161+
*
162+
* ```
150163
* // Create a empty lookup
151164
* RRSpatialLookup rr_lookup;
152165
* // Adding other nodes ...
@@ -155,14 +168,21 @@ class RRSpatialLookup {
155168
* vtr::Point<int>(1, 2),
156169
* SOURCE,
157170
* TOP);
171+
* ```
158172
*
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
160174
* depending on needs
161-
*
175+
*/
176+
/*
162177
* TODO: Consider to make a high-level API to duplicate the nodes for large blocks.
163178
* Then this API can become a private one
164179
* For example,
180+
*
181+
*
182+
* ```
165183
* expand_nodes(source_coordinate, bounding_box_coordinate, type, side);
184+
* ```
185+
*
166186
* Alternatively, we can rework the ``find_node()`` API so that we always search the lowest (x,y)
167187
* corner when dealing with large blocks. But this may require the data structure to be dependent
168188
* on DeviceGrid information (it needs to identify if a grid has height > 1 as well as width > 1)
@@ -173,11 +193,13 @@ class RRSpatialLookup {
173193
e_side side);
174194

175195
/**
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
178197
*
179-
* Strongly recommend to use when the sizes of dimensions are deterministic
198+
* This function will keep any existing data
180199
*
200+
* @note Strongly recommend to use when the sizes of dimensions are deterministic
201+
*/
202+
/*
181203
* TODO: should have a reserve function but vtd::ndmatrix does not have such API
182204
* as a result, resize can be an internal one while reserve function is a public mutator
183205
*/
@@ -186,10 +208,10 @@ class RRSpatialLookup {
186208
t_rr_type type,
187209
e_side side);
188210

189-
/* Reorder the internal look up to be more memory efficient */
211+
/** @brief Reorder the internal look up to be more memory efficient */
190212
void reorder(const vtr::vector<RRNodeId, RRNodeId> dest_order);
191213

192-
/* Clear all the data inside */
214+
/** @brief Clear all the data inside */
193215
void clear();
194216

195217
/* -- Internal data queries -- */

0 commit comments

Comments
 (0)