torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NetRouterBase.hpp
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 Header for the BasicRouter class.
18 
19 #ifndef TORC_ROUTER_NETROUTERBASE_HPP
20 #define TORC_ROUTER_NETROUTERBASE_HPP
21 
25 #include "torc/router/RouteNet.hpp"
26 
28 #include <set>
29 #include <iostream>
30 #include <algorithm>
31 #include <queue>
32 #include <boost/cstdint.hpp>
33 #include <boost/timer.hpp>
34 #include <boost/unordered_map.hpp>
35 #include <boost/functional/hash.hpp>
37 
38 namespace torc {
39 namespace router {
40 
41  /// \brief Abstract class for a net router.
42  /// \details This base class provides a virtual route function.
43  class NetRouterBase {
44  // types
45  /// \brief Imported type names
49 
50  protected:
51  // members
52  /// \brief Database reference.
53  DDB& mDB;
54  /// \brief Pointer to the heuristic for making routing decisions.
56  /// \brief Timer object for performance analysis.
57  boost::timer mRouteTimer;
58  /// \brief Total routing time since construction.
60 
61  public:
62  // constructor
63  /// \brief Public Constructor
64  NetRouterBase(DDB& inDB, NetRouterHeuristicBase* inHeuristic) : mDB(inDB),
65  mHeuristic(inHeuristic) {
66  mTotalRouteTime = 0;
67  }
68  /// \brief Destructor.
69  virtual ~NetRouterBase() {}
70 
71  /// \brief Primary route call.
72  void route(RouteNet& inNet) {
73  mRouteTimer.restart();
74  routeNet(inNet);
75  double routeTime = mRouteTimer.elapsed();
76  mTotalRouteTime += routeTime;
77  inNet.mProperties[eRouteTime] = routeTime;
78  }
79 
80  /// \brief Get total route time.
81  double getTotalRouteTime() { return mTotalRouteTime; }
82  /// \brief Get the current heuristic.
84  /// \brief Set the current heuristic.
85  void setHeuristic(NetRouterHeuristicBase* inHeuristic) { mHeuristic = inHeuristic; }
86 
87  protected:
88  /// \brief Virtual route call.
89  virtual void routeNet(RouteNet& inNet) = 0;
90  }; // class SignalRouterBase
91 
92 
93 } // namespace router
94 } // namespace torc
95 
96 #endif // TORC_ROUTER_NETROUTERBASE_HPP
double mTotalRouteTime
Total routing time since construction.
Device database, including complete wiring and logic support.
Definition: DDB.hpp:42
Encapsulation the design wire usage.
Definition: WireUsage.hpp:35
Header for the RouteNode class.
architecture::Tilewire Tilewire
boost::unordered_map< boost::uint32_t, boost::any > mProperties
Net annotation structure.
Definition: RouteNet.hpp:70
NetRouterHeuristicBase * mHeuristic
Pointer to the heuristic for making routing decisions.
boost::timer mRouteTimer
Timer object for performance analysis.
Header for torc::physical output stream helpers.
architecture::DDB DDB
Imported type names.
Encapsulation of a device tile and wire pair.
Definition: Tilewire.hpp:39
NetRouterHeuristicBase * getHeuristic()
Get the current heuristic.
virtual void routeNet(RouteNet &inNet)=0
Virtual route call.
Header for the HeuristicBase class.
DDB & mDB
Database reference.
void setHeuristic(NetRouterHeuristicBase *inHeuristic)
Set the current heuristic.
virtual ~NetRouterBase()
Destructor.
Provides the interface for net routers.
Abstract class for a net router.
Header for the DDB class.
architecture::WireUsage WireUsage
void route(RouteNet &inNet)
Primary route call.
double getTotalRouteTime()
Get total route time.
NetRouterBase(DDB &inDB, NetRouterHeuristicBase *inHeuristic)
Public Constructor.
Header for the Net class.