11
11
* Overview
12
12
* ========
13
13
* The TurnModelRouting class abstracts Turn Model routing algorithms.
14
+ * The route_flow() method implemented in this class, routes a traffic flow
15
+ * by adding a NoC link at a time to form a route between two NoC routers.
16
+ * The destination router of the last added NoC link is called the current
17
+ * NoC router.
14
18
* The main idea in Turn Model algorithm is to forbid specific turns
15
- * for traffic flows based on the source, destination, and current NoC
19
+ * for traffic flows to avoid deadlock. If at least one clockwise turn
20
+ * and one anticlockwise turn are forbidden, no cyclic dependency can
21
+ * happen, making deadlock impossible. Turn model algorithms forbid
22
+ * specific turns based on the source, destination, and current NoC
16
23
* router locations in a mesh or torus topology. TurnModelRouting class
17
24
* exposes a shared interface for all Turn Model routing algorithms.
18
25
* Derived classes can implement specific routing algorithms by implementing
19
26
* their override of the exposed interface. More specifically,
20
- * get_legal_directions() method returns legal directions that a
21
- * traffic flow can follow based on the source, destination, and current
27
+ * the get_legal_directions() method returns legal directions that a
28
+ * traffic flow can follow based on where the source, destination, and current
22
29
* NoC routers are located. select_next_direction() selects one of these
23
- * legal directions. TurnModelRouting() method does not implement these
30
+ * legal directions. The TurnModelRouting() class does not implement these
24
31
* methods, but calls them in route_flow(). For example, XYRouting can be
25
32
* implemented by overriding these two methods. get_legal_directions()
26
33
* should return horizontal directions when the current router and the
30
37
* select_next_direction() selects one of two available directions to get
31
38
* closer to the destination.
32
39
*
40
+ * When the routing algorithm presents two possible direction choices
41
+ * at a router, we use a biased coin flip to randomly select one of them.
42
+ * This random decision is biased towards choosing the direction in which
43
+ * the distance to the destination is longer. For example, if the last router
44
+ * added to a partial route is located at (3, 5) while the route is destined
45
+ * for (7, 7), the random decision favors the X-direction twice as much as
46
+ * the Y-direction. This approach distributes the chance of selecting
47
+ * a shortest path more evenly among all possible paths between two
48
+ * NoC routers.
49
+ *
33
50
* TurnModelRouting also provides multiple helper methods that can be used
34
51
* by derived classes.
35
52
*/
@@ -142,7 +159,8 @@ class TurnModelRouting : public NocRouting {
142
159
* sure that the link chosen points in the intended direction.
143
160
*
144
161
* @param curr_router_id The physical router on the FPGA that the routing
145
- * algorithm is currently visiting.
162
+ * algorithm is currently visiting. This argument is updated in this method
163
+ * returned by reference.
146
164
* @param curr_router_position The grid position of the router that is
147
165
* currently being visited on the FPGA
148
166
* @param next_step_direction The direction to travel next
@@ -164,7 +182,13 @@ class TurnModelRouting : public NocRouting {
164
182
165
183
/* *
166
184
* @brief Computes MurmurHash3 for an array of 32-bit words initialized
167
- * with seed.
185
+ * with seed. As discussed in the comment at the top of this file,
186
+ * when two possible directions are presented by get_legal_directions(),
187
+ * we flip a biased coin by favoring the direction along which the distance
188
+ * to the destination is longer. This hash function is used to generate
189
+ * a hash value, which is treated as random value. The generated
190
+ * hash value is compared with a threshold to determine the next
191
+ * direction to be taken
168
192
* @param key Contains elements to be hashed
169
193
* @param seed The initialization value.
170
194
* @return uint32_t Computed hash value.
0 commit comments