torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NetRouterUnitTest.cpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
16 /// \file
17 /// \brief Regression test for NetRouter class.
18 
19 #include <boost/test/unit_test.hpp>
20 #include <queue>
21 #include <iostream>
22 #include <vector>
23 #include <string>
24 #include <algorithm>
25 #include <functional>
30 #include "torc/router/RouteNet.hpp"
32 
33 namespace torc {
34 namespace router {
35 
36 BOOST_AUTO_TEST_SUITE(router)
37 
38 /// \brief Unit test for the NetRouter.
39 BOOST_AUTO_TEST_CASE(NetRouterT) {
40  architecture::DDB ddb("xc5vlx30");
42  NetRouterBase* r = new NetRouter(ddb, h);
43 
44  architecture::Tilewire twSource = ddb.lookupTilewire("CLBLL_X16Y42", "L_A");
45  architecture::Tilewire twSink1 = ddb.lookupTilewire("CLBLL_X16Y42", "L_C3");
46  architecture::Tilewire twSink2 = ddb.lookupTilewire("CLBLL_X23Y16", "L_B2");
47  std::string netname = "TEST_NET";
48  RouteNet net(netname);
49  net.addSource(twSource);
50  net.addSink(twSink1);
51  net.addSink(twSink2);
52 
53  BOOST_MESSAGE("ROUTE CALL");
54  std::cout << net.routeNodes().size() << std::endl;
55  r->route(net);
56  double t = boost::any_cast<double>(net.mProperties[eRouteTime]);
57  std::cout << t << std::endl;
58  BOOST_MESSAGE("ROUTE FINISHED");
59  std::cout << net.routeNodes().size() << std::endl;
60 
61  RouteNodePtrVector& v = net.routeNodes();
62  std::cout << ddb;
64  for (unsigned int i = 0; i < v.size(); i++) {
65  //std::cout << "pip " << v[i]->getSourceTilewire() << " -> " < v[i]->getSinkTilewire()
66  //std::cout << "pip " << v[i]->getArc() << std::endl;
67  std::cout << "pip ";
68  ewi = v[i]->getSourceTilewire();
69  std::cout << ewi.mTileName << " " << ewi.mWireName << " -> ";
70  ewi = v[i]->getSinkTilewire();
71  std::cout << ewi.mWireName << "," << std::endl;
72  }
73 
74 }
75 
76 BOOST_AUTO_TEST_SUITE_END()
77 
78 } // namespace router
79 } // namespace torc
std::vector< RouteNode * > RouteNodePtrVector
Vector of RouteNode pointers.
Definition: RouteNode.hpp:115
Device database, including complete wiring and logic support.
Definition: DDB.hpp:42
const char * mWireName
The wire name.
Header for the RouteNode class.
std::string string
boost::unordered_map< boost::uint32_t, boost::any > mProperties
Net annotation structure.
Definition: RouteNet.hpp:70
RouteNodePtrVector & routeNodes()
Returns a reference to the RouteNodePtrVector.
Definition: RouteNet.hpp:201
const char * mTileName
The tile name.
Encapsulation of a device tile and wire pair.
Definition: Tilewire.hpp:39
Header for the Heuristic class.
Verbose encapsulation of a wire's information.
Tilewire lookupTilewire(const std::string &inTileName, const std::string &inWireName)
Returns the tilewire for the specified tile and wire names.
Definition: DDB.hpp:257
Provides net routing based on the Nillson graphsearch algorithm.
Header for the ExtendedWireInfo class.
Provides net routing based on the Nilsson graphsearch algorithm.
Definition: NetRouter.hpp:42
void addSource(Tilewire inTilewire)
Adds the given Tilewire as a source for this net.
Definition: RouteNet.hpp:98
Provides the interface for net routers.
Abstract class for a net router.
Header for the DDB class.
void route(RouteNet &inNet)
Primary route call.
Header for the NetRouter class.
BOOST_AUTO_TEST_CASE(NetRouterHeuristicT)
Unit test for the Heuristic.
void addSink(Tilewire inTilewire)
Adds the given Tilewire as a sink for this net.
Definition: RouteNet.hpp:103
Header for the Net class.