1111 * Overview
1212 * ========
1313 * 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.
1418 * 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
1623 * router locations in a mesh or torus topology. TurnModelRouting class
1724 * exposes a shared interface for all Turn Model routing algorithms.
1825 * Derived classes can implement specific routing algorithms by implementing
1926 * 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
2229 * 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
2431 * methods, but calls them in route_flow(). For example, XYRouting can be
2532 * implemented by overriding these two methods. get_legal_directions()
2633 * should return horizontal directions when the current router and the
3037 * select_next_direction() selects one of two available directions to get
3138 * closer to the destination.
3239 *
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+ *
3350 * TurnModelRouting also provides multiple helper methods that can be used
3451 * by derived classes.
3552 */
@@ -142,7 +159,8 @@ class TurnModelRouting : public NocRouting {
142159 * sure that the link chosen points in the intended direction.
143160 *
144161 * @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.
146164 * @param curr_router_position The grid position of the router that is
147165 * currently being visited on the FPGA
148166 * @param next_step_direction The direction to travel next
@@ -164,7 +182,13 @@ class TurnModelRouting : public NocRouting {
164182
165183 /* *
166184 * @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
168192 * @param key Contains elements to be hashed
169193 * @param seed The initialization value.
170194 * @return uint32_t Computed hash value.
0 commit comments