33
44#include " xy_routing.h"
55
6+ namespace {
7+
68/* *
79 * @brief Compares two vectors of NocLinks. These vectors represent
810 * two routes between a start and destination routers. This function
911 * verifies whether the two routers are the exact same or not.
1012 *
1113 */
12- static void compare_routes (const std::vector<NocLink>& golden_path, const std::vector<NocLinkId>& found_path, const NocStorage& noc_model) {
14+ void compare_routes (const std::vector<NocLink>& golden_path, const std::vector<NocLinkId>& found_path, const NocStorage& noc_model) {
1315 // make sure that size of the found route and golden route match
1416 REQUIRE (found_path.size () == golden_path.size ());
1517
@@ -86,7 +88,7 @@ TEST_CASE("test_route_flow", "[vpr_noc_xy_routing]") {
8688 // choosing the start and end routers as router 10
8789 auto start_router_id = NocRouterId (10 );
8890 auto sink_router_id = NocRouterId (10 );
89- auto traffic_flow_id = NocTrafficFlowId (33 );
91+ auto traffic_flow_id = NocTrafficFlowId (33 );
9092
9193 // store the route found by the algorithm
9294 std::vector<NocLinkId> found_path;
@@ -101,14 +103,14 @@ TEST_CASE("test_route_flow", "[vpr_noc_xy_routing]") {
101103 // choose start router as 7, and choose the destination router as 4
102104 auto start_router_id = NocRouterId (7 );
103105 auto sink_router_id = NocRouterId (4 );
104- auto traffic_flow_id = NocTrafficFlowId (34 );
106+ auto traffic_flow_id = NocTrafficFlowId (34 );
105107
106108 // build the golden route that we expect the algorithm to produce
107109 // the expectation is a number of links that path horizontally from router 7 to router 4
108110 std::vector<NocLink> golden_path;
109111
110112 for (int current_router = 7 ; current_router != 4 ; current_router--) {
111- NocLinkId link_id = noc_model.get_single_noc_link_id (NocRouterId (current_router), NocRouterId (current_router - 1 ));
113+ NocLinkId link_id = noc_model.get_single_noc_link_id (NocRouterId (current_router), NocRouterId (current_router - 1 ));
112114 const auto & link = noc_model.get_single_noc_link (link_id);
113115 golden_path.push_back (link);
114116 }
@@ -126,14 +128,14 @@ TEST_CASE("test_route_flow", "[vpr_noc_xy_routing]") {
126128 // choose start router as 2, and choose the destination router as 14
127129 auto start_router_id = NocRouterId (2 );
128130 auto sink_router_id = NocRouterId (14 );
129- auto traffic_flow_id = NocTrafficFlowId (35 );
131+ auto traffic_flow_id = NocTrafficFlowId (35 );
130132
131133 // build the golden route that we expect the algorithm to produce
132134 // the expectation is a number of links that path vertically from router 2 to router 14
133135 std::vector<NocLink> golden_path;
134136
135137 for (int current_row = 0 ; current_row < 3 ; current_row++) {
136- NocLinkId link_id = noc_model.get_single_noc_link_id (NocRouterId (current_row * 4 + 2 ), NocRouterId ((current_row + 1 ) * 4 + 2 ));
138+ NocLinkId link_id = noc_model.get_single_noc_link_id (NocRouterId (current_row * 4 + 2 ), NocRouterId ((current_row + 1 ) * 4 + 2 ));
137139 const auto & link = noc_model.get_single_noc_link (link_id);
138140 golden_path.push_back (link);
139141 }
@@ -151,22 +153,22 @@ TEST_CASE("test_route_flow", "[vpr_noc_xy_routing]") {
151153 // choose start router as 3, and choose the destination router as 14
152154 auto start_router_id = NocRouterId (3 );
153155 auto sink_router_id = NocRouterId (12 );
154- auto traffic_flow_id = NocTrafficFlowId (37 );
156+ auto traffic_flow_id = NocTrafficFlowId (37 );
155157
156158 // build the golden route that we expect the algorithm to produce
157159 // the expectation is a number of links that path horizontally from router 3 to router 0 and then vertically from router 0 to 12
158160 std::vector<NocLink> golden_path;
159161
160162 // generate the horizontal path first
161163 for (int current_router = 3 ; current_router != 0 ; current_router--) {
162- NocLinkId link_id = noc_model.get_single_noc_link_id (NocRouterId (current_router), NocRouterId (current_router - 1 ));
164+ NocLinkId link_id = noc_model.get_single_noc_link_id (NocRouterId (current_router), NocRouterId (current_router - 1 ));
163165 const auto & link = noc_model.get_single_noc_link (link_id);
164166 golden_path.push_back (link);
165167 }
166168
167169 // generate the vertical path next
168170 for (int current_row = 0 ; current_row < 3 ; current_row++) {
169- NocLinkId link_id = noc_model.get_single_noc_link_id (NocRouterId (current_row * 4 ), NocRouterId ((current_row + 1 ) * 4 ));
171+ NocLinkId link_id = noc_model.get_single_noc_link_id (NocRouterId (current_row * 4 ), NocRouterId ((current_row + 1 ) * 4 ));
170172 const auto & link = noc_model.get_single_noc_link (link_id);
171173 golden_path.push_back (link);
172174 }
@@ -195,14 +197,14 @@ TEST_CASE("test_route_flow", "[vpr_noc_xy_routing]") {
195197
196198 // generate the horizontal path first
197199 for (int current_router = 12 ; current_router != 15 ; current_router++) {
198- NocLinkId link_id = noc_model.get_single_noc_link_id (NocRouterId (current_router), NocRouterId (current_router + 1 ));
200+ NocLinkId link_id = noc_model.get_single_noc_link_id (NocRouterId (current_router), NocRouterId (current_router + 1 ));
199201 const auto & link = noc_model.get_single_noc_link (link_id);
200202 golden_path.push_back (link);
201203 }
202204
203205 // generate the vertical path next
204206 for (int current_row = 3 ; current_row > 0 ; current_row--) {
205- NocLinkId link_id = noc_model.get_single_noc_link_id (NocRouterId (current_row * 4 + 3 ), NocRouterId ((current_row - 1 ) * 4 + 3 ));
207+ NocLinkId link_id = noc_model.get_single_noc_link_id (NocRouterId (current_row * 4 + 3 ), NocRouterId ((current_row - 1 ) * 4 + 3 ));
206208 const auto & link = noc_model.get_single_noc_link (link_id);
207209 golden_path.push_back (link);
208210 }
@@ -282,7 +284,7 @@ TEST_CASE("test_route_flow when it fails in a mesh topology.", "[vpr_noc_xy_rout
282284 // store the source and destination routers
283285 auto start_router_id = NocRouterId (3 );
284286 auto sink_router_id = NocRouterId (0 );
285- auto traffic_flow_id = NocTrafficFlowId (39 );
287+ auto traffic_flow_id = NocTrafficFlowId (39 );
286288
287289 // routers associated to the link to remove
288290 auto link_to_remove_src_router_id = NocRouterId (2 );
@@ -308,7 +310,7 @@ TEST_CASE("test_route_flow when it fails in a mesh topology.", "[vpr_noc_xy_rout
308310 // store the source and destination routers
309311 auto start_router_id = NocRouterId (3 );
310312 auto sink_router_id = NocRouterId (15 );
311- auto traffic_flow_id = NocTrafficFlowId (41 );
313+ auto traffic_flow_id = NocTrafficFlowId (41 );
312314
313315 // routers associated to the link to remove
314316 auto link_to_remove_src_router_id = NocRouterId (11 );
@@ -366,7 +368,7 @@ TEST_CASE("test_route_flow when it fails in a non mesh topology.", "[vpr_noc_xy_
366368 // now create the start and the destination routers of the route we want to test
367369 auto start_router_id = NocRouterId (3 );
368370 auto sink_router_id = NocRouterId (1 );
369- auto traffic_flow_id = NocTrafficFlowId (40 );
371+ auto traffic_flow_id = NocTrafficFlowId (40 );
370372
371373 // creating the XY routing object
372374 XYRouting routing_algorithm;
@@ -377,4 +379,5 @@ TEST_CASE("test_route_flow when it fails in a non mesh topology.", "[vpr_noc_xy_
377379 // now use the XY router to find a route. We expect this to fail to check that.
378380 REQUIRE_THROWS_WITH (routing_algorithm.route_flow (start_router_id, sink_router_id, traffic_flow_id, found_path, noc_model),
379381 " No route could be found from starting router with ID:'3' and the destination router with ID:'1' using the XY-Routing algorithm." );
380- }
382+ }
383+ } // namespace
0 commit comments