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/NetRouterBase.hpp $ 00003 // $Id: NetRouterBase.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 BasicRouter class. 00018 00019 #ifndef TORC_ROUTER_NETROUTERBASE_HPP 00020 #define TORC_ROUTER_NETROUTERBASE_HPP 00021 00022 #include "torc/architecture/DDB.hpp" 00023 #include "torc/router/RouteNode.hpp" 00024 #include "torc/router/NetRouterHeuristicBase.hpp" 00025 #include "torc/router/RouteNet.hpp" 00026 00027 #include "torc/architecture/OutputStreamHelpers.hpp" 00028 #include <set> 00029 #include <iostream> 00030 #include <algorithm> 00031 #include <queue> 00032 #include <boost/cstdint.hpp> 00033 #include <boost/timer.hpp> 00034 #include <boost/unordered_map.hpp> 00035 #include <boost/functional/hash.hpp> 00036 #include "NetRouterHeuristicBase.hpp" 00037 00038 namespace torc { 00039 namespace router { 00040 00041 /// \brief Abstract class for a net router. 00042 /// \details This base class provides a virtual route function. 00043 class NetRouterBase { 00044 // types 00045 /// \brief Imported type names 00046 typedef architecture::DDB DDB; 00047 typedef architecture::WireUsage WireUsage; 00048 typedef architecture::Tilewire Tilewire; 00049 00050 protected: 00051 // members 00052 /// \brief Database reference. 00053 DDB& mDB; 00054 /// \brief Pointer to the heuristic for making routing decisions. 00055 NetRouterHeuristicBase* mHeuristic; 00056 /// \brief Timer object for performance analysis. 00057 boost::timer mRouteTimer; 00058 /// \brief Total routing time since construction. 00059 double mTotalRouteTime; 00060 00061 public: 00062 // constructor 00063 /// \brief Public Constructor 00064 NetRouterBase(DDB& inDB, NetRouterHeuristicBase* inHeuristic) : mDB(inDB), 00065 mHeuristic(inHeuristic) { 00066 mTotalRouteTime = 0; 00067 } 00068 /// \brief Destructor. 00069 virtual ~NetRouterBase() {} 00070 00071 /// \brief Primary route call. 00072 void route(RouteNet& inNet) { 00073 mRouteTimer.restart(); 00074 routeNet(inNet); 00075 double routeTime = mRouteTimer.elapsed(); 00076 mTotalRouteTime += routeTime; 00077 inNet.mProperties[eRouteTime] = routeTime; 00078 } 00079 00080 /// \brief Get total route time. 00081 double getTotalRouteTime() { return mTotalRouteTime; } 00082 /// \brief Get the current heuristic. 00083 NetRouterHeuristicBase* getHeuristic() { return mHeuristic; } 00084 /// \brief Set the current heuristic. 00085 void setHeuristic(NetRouterHeuristicBase* inHeuristic) { mHeuristic = inHeuristic; } 00086 00087 protected: 00088 /// \brief Virtual route call. 00089 virtual void routeNet(RouteNet& inNet) = 0; 00090 }; // class SignalRouterBase 00091 00092 00093 } // namespace router 00094 } // namespace torc 00095 00096 #endif // TORC_ROUTER_NETROUTERBASE_HPP