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/packer/RoutingNet.hpp $ 00003 // $Id: RoutingNet.hpp 10 2011-10-12 18:40: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 RoutingNet class. 00018 00019 #ifndef TORC_PACKER_ROUTINGNET_HPP 00020 #define TORC_PACKER_ROUTINGNET_HPP 00021 00022 #include "torc/physical/Net.hpp" 00023 #include <vector> 00024 00025 namespace torc { 00026 namespace physical { 00027 00028 /// \brief Routing net. 00029 00030 class RoutingNet:public Named { 00031 // friends 00032 /// \brief The Factory class has direct access to our internals. 00033 friend class RcFactory; 00034 protected: 00035 // types 00036 /// \brief Imported type name. 00037 typedef std::string string; 00038 00039 // members 00040 /// \brief The original net 00041 NetSharedPtr superNet; 00042 /// \brife combinational path count 00043 std::vector<size_t> pathCounts; 00044 00045 public: 00046 00047 // constructors 00048 /// \brief Constructor. 00049 /// \param original net 00050 RoutingNet(NetSharedPtr snet) : Named(snet->getName()) { 00051 pathCounts.resize(snet->getSourceCount() + snet->getSinkCount(),0); 00052 superNet=snet; 00053 } 00054 00055 // functions 00056 /// \brief Returns net supernet 00057 NetSharedPtr getSuperNet(void){ 00058 return superNet; 00059 } 00060 00061 /// \brief Sets super net 00062 NetSharedPtr setSuperNet(NetSharedPtr snet){ 00063 return (superNet=snet); 00064 } 00065 00066 /// \brief Returns path count for pin index 00067 size_t getPathCount(size_t index){ 00068 return pathCounts[index]; 00069 } 00070 00071 /// \brief Sets path count for pin index 00072 bool setPathCount(size_t index, size_t pCount){ 00073 pathCounts[index] = pCount; 00074 return true; 00075 } 00076 00077 /// \brief Returns path count for pin 00078 size_t getPathCount(InstancePinSharedPtr pinPtr){ 00079 size_t index =0; 00080 Net::InstancePinSharedPtrIterator sip = superNet->sourcesBegin(); 00081 Net::InstancePinSharedPtrIterator sie = superNet->sourcesEnd(); 00082 while(sip != sie){ 00083 if(**sip == *pinPtr) 00084 return getPathCount(index);; 00085 ++index; 00086 ++sip; 00087 } 00088 00089 sip = superNet->sinksBegin(); 00090 sie = superNet->sinksEnd(); 00091 while(sip != sie){ 00092 if(**sip == *pinPtr) 00093 return getPathCount(index);; 00094 ++index; 00095 ++sip; 00096 } 00097 return getPathCount(index); 00098 } 00099 00100 /// \brief Sets path count for pin 00101 bool setPathCount(InstancePinSharedPtr pinPtr, size_t pCount){ 00102 size_t index =0; 00103 Net::InstancePinSharedPtrIterator sip = superNet->sourcesBegin(); 00104 Net::InstancePinSharedPtrIterator sie = superNet->sourcesEnd(); 00105 while(sip != sie){ 00106 if(**sip == *pinPtr) 00107 return setPathCount(index, pCount); 00108 ++index; 00109 ++sip; 00110 } 00111 sip = superNet->sinksBegin(); 00112 sie = superNet->sinksEnd(); 00113 while(sip != sie){ 00114 if(**sip == *pinPtr) 00115 return setPathCount(index, pCount); 00116 ++index; 00117 ++sip; 00118 } 00119 return setPathCount(index, pCount); 00120 } 00121 00122 // operators 00123 /// \brief Equality operator. 00124 /// \details This function deems nets equal if their names are identical. 00125 /// \param rhs The net to compare against. 00126 /// \returns true if both net names are identical, or false otherwise. 00127 bool operator ==(const RoutingNet& rhs) const { return getName() == rhs.getName(); } 00128 }; 00129 00130 /// \brief Shared pointer encapsulation of a RoutingNet. 00131 typedef boost::shared_ptr<RoutingNet> RoutingNetSharedPtr; 00132 00133 /// \brief Vector of RoutingNet shared pointers. 00134 typedef std::vector<RoutingNetSharedPtr> RoutingNetSharedPtrVector; 00135 00136 } // namespace physical 00137 } // namespace torc 00138 00139 #endif // TORC_PACKER_ROUTINGNET_HPP