torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PathFinderRegressionTest.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 Tests for PathFinder class.
18 
19 #include <boost/test/unit_test.hpp>
24 
25 #include "PathFinder.hpp"
26 #include "NetRouter.hpp"
27 //#include "NetRouterHeuristic.hpp"
28 #include "PathFinderHeuristic.hpp"
29 #include "RouteUtilities.hpp"
31 
32 namespace torc {
33 namespace router {
34 
35 BOOST_AUTO_TEST_SUITE(router)
36 BOOST_AUTO_TEST_SUITE(regression)
37 
38 void testRouteDesign(std::string path, std::string exportpath);
39 void testRouteDesign(std::string path, std::string exportpath) {
40 
41  typedef torc::physical::Circuit::NetSharedPtrIterator NetSharedPtrIterator;
42 
43  std::fstream fileStream(path.c_str());
44  BOOST_REQUIRE(fileStream.good());
45 
47  importer(fileStream, path);
48 
49  torc::physical::DesignSharedPtr designPtr = importer.getDesignPtr();
50  BOOST_REQUIRE(designPtr.get() != 0);
51  //BOOST_CHECK_EQUAL(designPtr->getNetCount(), netCount);
52  architecture::DDB* ddbPtr = importer.releaseDDBPtr();
53 
55  NetRouterBase* r = new NetRouter(*ddbPtr, h);
57  NetVectorRouterBase* vr = new PathFinder(*ddbPtr, vh, r);
58 
59  RouteUtilities ru;
60  RouteNetVector nets;
61 
62  std::cout << "RouteNets: " << nets.size() << std::endl;
63  ru.design2routenets(designPtr->netsBegin(), designPtr->netsEnd(), nets);
64  BOOST_CHECK_EQUAL(designPtr->getNetCount(), nets.size());
65 
66  std::cout << "Unrouting nets..." << std::endl;
67  NetSharedPtrIterator p;
68  for (p = designPtr->netsBegin(); p != designPtr->netsEnd(); p++) {
69  (*p)->unroute();
70  }
71 
72  std::cout << "RouteNets: " << nets.size() << std::endl;
73  std::cout << *ddbPtr;
74  std::cout << "Clearing usage from import" << std::endl;
75  ddbPtr->clearUsage();
76  vr->route(nets);
77  std::cout << "Finished routing: " << path << std::endl;
78 
79  std::cout << "Exporting route nets to physical" << std::endl;
80  ru.routenets2design(nets, designPtr->netsBegin(), designPtr->netsEnd(), *ddbPtr);
81 
82  std::cout << "Exporting XDL" << std::endl;
83  std::fstream xdlExport(exportpath.c_str(), std::ios_base::out);
84  physical::XdlExporter fileExporter(xdlExport);
85  fileExporter(designPtr);
86 }
87 
88 /// \brief Spartan3E regression.
89 /*BOOST_AUTO_TEST_CASE(pathfinder_spartan3e) {
90 
91  int& argc = boost::unit_test::framework::master_test_suite().argc;;
92  BOOST_REQUIRE(argc >= 1);
93  char**&argv = boost::unit_test::framework::master_test_suite().argv;;
94  torc::common::DirectoryTree directoryTree(argv[0]);
95  boost::filesystem::path testPath(directoryTree.getExecutablePath()
96  / "torc" / "router" / "PathFinderRegression");
97  boost::filesystem::path referencePath(testPath / "PathFinderRegression.Spartan3E.Test1.xdl");
98  boost::filesystem::path generatedPath(testPath /
99  "PathFinderRegression.Spartan3E.Test1.generated.xdl");
100 std::cout << referencePath.string() << std::endl;
101 
102  testRouteDesign(referencePath.string(), generatedPath.string());
103 }*/
104 /// \brief Spartan6 regression
105 /*BOOST_AUTO_TEST_CASE(pathfinder_spartan6) {
106 
107  int& argc = boost::unit_test::framework::master_test_suite().argc;;
108  BOOST_REQUIRE(argc >= 1);
109  char**&argv = boost::unit_test::framework::master_test_suite().argv;;
110  torc::common::DirectoryTree directoryTree(argv[0]);
111  boost::filesystem::path testPath(directoryTree.getExecutablePath()
112  / "torc" / "router" / "PathFinderRegression");
113  boost::filesystem::path referencePath(testPath / "PathFinderRegression.Spartan6.Test1.xdl");
114  boost::filesystem::path generatedPath(testPath /
115  "PathFinderRegression.Spartan6.Test1.generated.xdl");
116 std::cout << referencePath.string() << std::endl;
117 
118  testRouteDesign(referencePath.string(), generatedPath.string());
119 }*/
120 /// \brief Spartan6 regression
121 /*BOOST_AUTO_TEST_CASE(pathfinder_spartan6_big) {
122 
123  int& argc = boost::unit_test::framework::master_test_suite().argc;;
124  BOOST_REQUIRE(argc >= 1);
125  char**&argv = boost::unit_test::framework::master_test_suite().argv;;
126  torc::common::DirectoryTree directoryTree(argv[0]);
127  boost::filesystem::path testPath(directoryTree.getExecutablePath()
128  / "torc" / "router" / "PathFinderRegression");
129  boost::filesystem::path referencePath(testPath / "PathFinderRegression.Spartan6.Test2.xdl");
130  boost::filesystem::path generatedPath(testPath /
131  "PathFinderRegression.Spartan6.Test2.generated.xdl");
132 std::cout << referencePath.string() << std::endl;
133 
134  testRouteDesign(referencePath.string(), generatedPath.string());
135 }*/
136 /// \brief VirtexE regression
137 /*BOOST_AUTO_TEST_CASE(pathfinder_virtexE) {
138 
139  int& argc = boost::unit_test::framework::master_test_suite().argc;;
140  BOOST_REQUIRE(argc >= 1);
141  char**&argv = boost::unit_test::framework::master_test_suite().argv;;
142  torc::common::DirectoryTree directoryTree(argv[0]);
143  boost::filesystem::path testPath(directoryTree.getExecutablePath()
144  / "torc" / "router" / "PathFinderRegression");
145  boost::filesystem::path referencePath(testPath / "PathFinderRegression.VirtexE.Test1.xdl");
146  boost::filesystem::path generatedPath(testPath /
147  "PathFinderRegression.VirtexE.Test1.generated.xdl");
148 std::cout << referencePath.string() << std::endl;
149 
150  testRouteDesign(referencePath.string(), generatedPath.string());
151 }*/
152 /// \brief Virtex2P regression
153 BOOST_AUTO_TEST_CASE(pathfinder_virtex2p) {
154 
155  int& argc = boost::unit_test::framework::master_test_suite().argc;;
156  BOOST_REQUIRE(argc >= 1);
157  char**&argv = boost::unit_test::framework::master_test_suite().argv;;
158  torc::common::DirectoryTree directoryTree(argv[0]);
159  boost::filesystem::path testPath(directoryTree.getExecutablePath()
160  / "torc" / "router" / "PathFinderRegression");
161  boost::filesystem::path referencePath(testPath / "PathFinderRegression.Virtex2P.Test1.xdl");
162  boost::filesystem::path generatedPath(testPath /
163  "PathFinderRegression.Virtex2P.Test1.generated.xdl");
164  std::cout << referencePath.string() << std::endl;
165 
166  testRouteDesign(referencePath.string(), generatedPath.string());
167 }
168 /// \brief Virtex4 regression
169 BOOST_AUTO_TEST_CASE(pathfinder_virtex4) {
170 
171  int& argc = boost::unit_test::framework::master_test_suite().argc;;
172  BOOST_REQUIRE(argc >= 1);
173  char**&argv = boost::unit_test::framework::master_test_suite().argv;;
174  torc::common::DirectoryTree directoryTree(argv[0]);
175  boost::filesystem::path testPath(directoryTree.getExecutablePath()
176  / "torc" / "router" / "PathFinderRegression");
177  boost::filesystem::path referencePath(testPath / "PathFinderRegression.Virtex4.Test1.xdl");
178  boost::filesystem::path generatedPath(testPath /
179  "PathFinderRegression.Virtex4.Test1.generated.xdl");
180  std::cout << referencePath.string() << std::endl;
181 
182  testRouteDesign(referencePath.string(), generatedPath.string());
183 }
184 /// \brief Virtex5 regression
185 BOOST_AUTO_TEST_CASE(pathfinder_virtex5) {
186 
187  int& argc = boost::unit_test::framework::master_test_suite().argc;;
188  BOOST_REQUIRE(argc >= 1);
189  char**&argv = boost::unit_test::framework::master_test_suite().argv;;
190  torc::common::DirectoryTree directoryTree(argv[0]);
191  boost::filesystem::path testPath(directoryTree.getExecutablePath()
192  / "torc" / "router" / "PathFinderRegression");
193  boost::filesystem::path referencePath(testPath / "PathFinderRegression.Virtex5.Test1.xdl");
194  boost::filesystem::path generatedPath(testPath /
195  "PathFinderRegression.Virtex5.Test1.generated.xdl");
196  std::cout << referencePath.string() << std::endl;
197 
198  testRouteDesign(referencePath.string(), generatedPath.string());
199 }
200 /// \brief Virtex6 regression
201 BOOST_AUTO_TEST_CASE(pathfinder_virtex6) {
202 
203  int& argc = boost::unit_test::framework::master_test_suite().argc;;
204  BOOST_REQUIRE(argc >= 1);
205  char**&argv = boost::unit_test::framework::master_test_suite().argv;;
206  torc::common::DirectoryTree directoryTree(argv[0]);
207  boost::filesystem::path testPath(directoryTree.getExecutablePath()
208  / "torc" / "router" / "PathFinderRegression");
209  boost::filesystem::path referencePath(testPath / "PathFinderRegression.Virtex6.Test1.xdl");
210  boost::filesystem::path generatedPath(testPath /
211  "PathFinderRegression.Virtex6.Test1.generated.xdl");
212  std::cout << referencePath.string() << std::endl;
213 
214  testRouteDesign(referencePath.string(), generatedPath.string());
215 }
216 
217 BOOST_AUTO_TEST_SUITE_END()
218 BOOST_AUTO_TEST_SUITE_END()
219 
220 } // namespace router
221 } // namespace torc
void route(RouteNetVector &inNets)
Primary route call.
Device database, including complete wiring and logic support.
Definition: DDB.hpp:42
void design2routenets(NetSharedPtrIterator netsbegin, NetSharedPtrIterator netsend, RouteNetVector &routenets)
std::vector< RouteNet > RouteNetVector
Vector of RouteNet objects.
Definition: RouteNet.hpp:205
Header for the DirectoryTree class.
Provides net routing based on the Nillson graphsearch algorithm.
Provides net routing based on the Nillson graphsearch algorithm.
Header for the Heuristic class.
void routenets2design(RouteNetVector &routenets, NetSharedPtrIterator netsbegin, NetSharedPtrIterator netsend, architecture::DDB &ddb)
Architecture aware importer from XDL format into a physical design.
Provides net routing based on the Nillson graphsearch algorithm.
Header for the XdlExport class.
Encapsulation of filesystem paths that are used by the library.
boost::filesystem::path path
boost::shared_ptr< Design > DesignSharedPtr
Shared pointer encapsulation of a Design.
void testRouteDesign(std::string path, std::string exportpath)
NetSharedPtrVector::iterator NetSharedPtrIterator
Non-constant iterator to Net shared pointers.
Definition: Circuit.hpp:78
Header for the Utilities class.
Provides net routing based on the Nilsson graphsearch algorithm.
Definition: NetRouter.hpp:42
Provides the interface for net routers.
Abstract class for a net router.
Abstract class for a net router.
Header for the DDB class.
Header for the PathfinderHeuristic class.
Header for the NetRouter class.
BOOST_AUTO_TEST_CASE(NetRouterHeuristicT)
Unit test for the Heuristic.
Header for the XdlImporter class.
static const boost::filesystem::path & getExecutablePath(void)
Returns the absolute path to the executable directory.
Physical design exporter for XDL.
Definition: XdlExporter.hpp:31