torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NetRouterHeuristicUnitTest.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 Heuristic class.
18 
19 #include <boost/test/unit_test.hpp>
23 #include <iostream>
24 #include <vector>
25 
26 namespace torc {
27 namespace router {
28 
29 BOOST_AUTO_TEST_SUITE(router)
30 
31 /// \brief Unit test for the Heuristic.
32 BOOST_AUTO_TEST_CASE(NetRouterHeuristicT) {
33 
34  typedef architecture::Tilewire Tilewire;
35  typedef architecture::ExtendedWireInfo ExtendedWireInfo;
36 
37  architecture::DDB db("xc5vlx30");
38  //architecture::DDB db("torc/devices/xc5vlx30");
39  NetRouterHeuristic h(db);
40 
43 
44  RouteNode* node1 = new RouteNode(tw1, tw1, 50, 50, 0, 0);
45  RouteNode* node2 = new RouteNode(tw1, tw1, 0, 0, 1, node1);
46 
47 // ExtendedWireInfo ewi1(db, tw1);
48 // ExtendedWireInfo ewi2(db, tw2);
49 
50 // std::cout << ewi1 << std::endl;
51 // std::cout << ewi2 << std::endl;
52 
53  h.setSink(tw2);
54  h.nodeCostInitial(*node1);
55  h.nodeCost(*node2);
56 
57  BOOST_CHECK_EQUAL(node1->getCost() == 74, true);
58  BOOST_CHECK_EQUAL(node2->getCost() == 148, true);
59 
60  delete node1;
61  delete node2;
62 }
63 
64 BOOST_AUTO_TEST_SUITE_END()
65 
66 } // namespace router
67 } // namespace torc
Encapsulation of a tile index in an unsigned 32-bit integer.
Device database, including complete wiring and logic support.
Definition: DDB.hpp:42
virtual void nodeCostInitial(RouteNode &inNode)
virtual void nodeCost(RouteNode &inNode)
Calculate the node cost based on distance to the sink and path length.
Encapsulation of a wire index in an unsigned 16-bit integer.
Header for torc::physical output stream helpers.
Encapsulation of a device tile and wire pair.
Definition: Tilewire.hpp:39
Header for the Heuristic class.
Verbose encapsulation of a wire's information.
Provides net routing based on the Nillson graphsearch algorithm.
virtual void setSink(const Tilewire &inSink)
Set the current routing target.
An object that holds an arc and path information for routing.
Definition: RouteNode.hpp:40
Header for the DDB class.
BOOST_AUTO_TEST_CASE(NetRouterHeuristicT)
Unit test for the Heuristic.
const boost::int32_t getCost() const
Get the heuristic node cost.
Definition: RouteNode.hpp:86