00001 // Torc - Copyright 2011 University of Southern California. All Rights Reserved. 00002 // $HeadURL: https://torc-isi.svn.sourceforge.net/svnroot/torc-isi/branches/staging/0.9/src/torc/router/NetVectorRouterBase.hpp $ 00003 // $Id: NetVectorRouterBase.hpp 1 2011-02-25 22:11:16Z nsteiner $ 00004 00005 // This program is free software: you can redistribute it and/or modify it under the terms of the 00006 // GNU General Public License as published by the Free Software Foundation, either version 3 of the 00007 // License, or (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 00010 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 00011 // the GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License along with this program. If 00014 // not, see <http://www.gnu.org/licenses/>. 00015 00016 /// \file 00017 /// \brief Header for the NetVectorRouterBase class. 00018 00019 #ifndef TORC_ROUTER_NETVECTORROUTERBASE_HPP 00020 #define TORC_ROUTER_NETVECTORROUTERBASE_HPP 00021 00022 #include "torc/architecture/DDB.hpp" 00023 #include "torc/router/RouteNode.hpp" 00024 #include "torc/router/NetVectorRouterHeuristicBase.hpp" 00025 #include "torc/router/RouteNet.hpp" 00026 00027 #include <algorithm> 00028 #include <queue> 00029 #include <boost/cstdint.hpp> 00030 #include <boost/timer.hpp> 00031 #include <boost/unordered_map.hpp> 00032 #include "NetVectorRouterHeuristicBase.hpp" 00033 #include "NetRouterBase.hpp" 00034 00035 namespace torc { 00036 namespace router { 00037 00038 /// \brief Abstract class for a net router. 00039 /// \details This base class provides a virtual route function. 00040 class NetVectorRouterBase { 00041 // types 00042 /// \brief Imported type names 00043 typedef architecture::DDB DDB; 00044 typedef architecture::WireUsage WireUsage; 00045 typedef architecture::Tilewire Tilewire; 00046 00047 protected: 00048 // members 00049 /// \brief Database reference. 00050 DDB& mDB; 00051 /// \brief Pointer to the heuristic for making routing decisions. 00052 NetVectorRouterHeuristicBase* mHeuristic; 00053 /// \brief Pointer to the underlying net router. 00054 NetRouterBase* mNetRouter; 00055 /// \brief Timer object for performance analysis. 00056 boost::timer mRouteTimer; 00057 /// \brief Total routing time since construction. 00058 double mTotalRouteTime; 00059 00060 public: 00061 // constructor 00062 /// \brief Public Constructor 00063 NetVectorRouterBase(DDB& inDB, NetVectorRouterHeuristicBase* inHeuristic, 00064 NetRouterBase* inNetRouter) : mDB(inDB), mHeuristic(inHeuristic), 00065 mNetRouter(inNetRouter) { 00066 mTotalRouteTime = 0; 00067 } 00068 /// \brief Destructor. 00069 virtual ~NetVectorRouterBase() {} 00070 00071 /// \brief Primary route call 00072 void route(RouteNetVector& inNets) { 00073 mRouteTimer.restart(); 00074 routeNets(inNets); 00075 mTotalRouteTime += mRouteTimer.elapsed(); 00076 } 00077 /// \brief Accessor for the heuristic. 00078 NetVectorRouterHeuristicBase* getHeuristic() { return mHeuristic; } 00079 /// \brief Set method for the heuristic. 00080 void setHeuristic(NetVectorRouterHeuristicBase* inHeuristic) { mHeuristic = inHeuristic; } 00081 /// \brief Accessor for the underlying Net Router. 00082 NetRouterBase* getNetRouter() { return mNetRouter; } 00083 /// \brief Set method for the net router. 00084 void setNetRouter(NetRouterBase* inNetRouter) { mNetRouter = inNetRouter; } 00085 00086 protected: 00087 /// brief protected routing call 00088 virtual void routeNets(RouteNetVector& inNets) = 0; 00089 00090 }; // class SignalRouterBase 00091 00092 00093 } // namespace router 00094 } // namespace torc 00095 00096 #endif // TORC_ROUTER_NETVECTORROUTERBASE_HPP