Skip to content

Commit 2fe22e8

Browse files
add comments in is_turn_legal() overrides
1 parent d509ecd commit 2fe22e8

5 files changed

+22
-1
lines changed

vpr/src/noc/negative_first_routing.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ bool NegativeFirstRouting::is_turn_legal(const std::array<std::reference_wrapper
119119
const int x3 = noc_routers[2].get().get_router_grid_position_x();
120120
const int y3 = noc_routers[2].get().get_router_grid_position_y();
121121

122+
// check if the given routers can be traversed one after another
122123
VTR_ASSERT(x2 == x1 || y2 == y1);
123124
VTR_ASSERT(x3 == x2 || y3 == y2);
124125

@@ -127,10 +128,16 @@ bool NegativeFirstRouting::is_turn_legal(const std::array<std::reference_wrapper
127128
return false;
128129
}
129130

131+
/* In negative-first routing algorithm, a traffic flow
132+
* can't take a downward turn if it is travelling toward right direction.
133+
*/
130134
if (x2 > x1 && y3 < y2) {
131135
return false;
132136
}
133137

138+
/* In negative-first routing algorithm, a traffic flow
139+
* can't take a left turn if it is travelling upwards.
140+
*/
134141
if (y2 > y1 && x3 < x2) {
135142
return false;
136143
}

vpr/src/noc/north_last_routing.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ bool NorthLastRouting::is_turn_legal(const std::array<std::reference_wrapper<con
108108
const int x3 = noc_routers[2].get().get_router_grid_position_x();
109109
const int y3 = noc_routers[2].get().get_router_grid_position_y();
110110

111+
// check if the given routers can be traversed one after another
111112
VTR_ASSERT(x2 == x1 || y2 == y1);
112113
VTR_ASSERT(x3 == x2 || y3 == y2);
113114

@@ -116,6 +117,11 @@ bool NorthLastRouting::is_turn_legal(const std::array<std::reference_wrapper<con
116117
return false;
117118
}
118119

120+
/* In the north-last algorithm, once the north direction is taken, no other
121+
* direction can be followed. Therefore, if the first link moves upward, the
122+
* second one cannot move horizontally. The case where the second link goes
123+
* back to the first router was checked in the previous if statement.
124+
*/
119125
if (y2 > y1 && x2 != x3) {
120126
return false;
121127
}

vpr/src/noc/odd_even_routing.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,13 @@ bool OddEvenRouting::is_turn_legal(const std::array<std::reference_wrapper<const
171171
const int x3 = noc_routers[2].get().get_router_grid_position_x();
172172
const int y3 = noc_routers[2].get().get_router_grid_position_y();
173173

174+
// check if the given routers can be traversed one after another
174175
VTR_ASSERT(x2 == x1 || y2 == y1);
175176
VTR_ASSERT(x3 == x2 || y3 == y2);
176177

177178
// get the position of the second NoC routers
178179
const auto router2_pos = noc_routers[1].get().get_router_physical_location();
179180

180-
181181
// Get the logical block type for router
182182
const auto router_block_type = cluster_ctx.clb_nlist.block_type(noc_ctx.noc_traffic_flows_storage.get_router_clusters_in_netlist()[0]);
183183

@@ -192,6 +192,7 @@ bool OddEvenRouting::is_turn_legal(const std::array<std::reference_wrapper<const
192192
return false;
193193
}
194194

195+
// check if the turn is compatible with odd-even routing algorithm turn restrictions
195196
if (is_odd(compressed_2_loc.x)) {
196197
if (y2 != y1 && x3 < x2) {
197198
return false;

vpr/src/noc/west_first_routing.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ bool WestFirstRouting::is_turn_legal(const std::array<std::reference_wrapper<con
105105
const int x3 = noc_routers[2].get().get_router_grid_position_x();
106106
const int y3 = noc_routers[2].get().get_router_grid_position_y();
107107

108+
// check if the given routers can be traversed one after another
108109
VTR_ASSERT(x2 == x1 || y2 == y1);
109110
VTR_ASSERT(x3 == x2 || y3 == y2);
110111

@@ -113,6 +114,11 @@ bool WestFirstRouting::is_turn_legal(const std::array<std::reference_wrapper<con
113114
return false;
114115
}
115116

117+
/* In the west-first routing algorithm, once the traffic flow
118+
* moved in a vertical direction, it is no longer allowed to move
119+
* towards west. Therefore, if the first link was travelling in a
120+
* vertical direction, the second link can't move towards left.
121+
*/
116122
if (y2 != y1 && x3 < x2) {
117123
return false;
118124
}

vpr/src/noc/xy_routing.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ bool XYRouting::is_turn_legal(const std::array<std::reference_wrapper<const NocR
9292
const int x3 = noc_routers[2].get().get_router_grid_position_x();
9393
const int y3 = noc_routers[2].get().get_router_grid_position_y();
9494

95+
// check if the given routers can be traversed one after another
9596
VTR_ASSERT(x2 == x1 || y2 == y1);
9697
VTR_ASSERT(x3 == x2 || y3 == y2);
9798

0 commit comments

Comments
 (0)