torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RoutingNet.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 RoutingNet class.
18 
19 #ifndef TORC_PACKER_ROUTINGNET_HPP
20 #define TORC_PACKER_ROUTINGNET_HPP
21 
22 #include "torc/physical/Net.hpp"
23 #include <vector>
24 
25 namespace torc {
26 namespace physical {
27 
28  /// \brief Routing net.
29 
30  class RoutingNet:public Named {
31  // friends
32  /// \brief The Factory class has direct access to our internals.
33  friend class RcFactory;
34  protected:
35  // types
36  /// \brief Imported type name.
38 
39  // members
40  /// \brief The original net
42  /// \brife combinational path count
43  std::vector<size_t> pathCounts;
44 
45  public:
46 
47  // constructors
48  /// \brief Constructor.
49  /// \param original net
50  RoutingNet(NetSharedPtr snet) : Named(snet->getName()) {
51  pathCounts.resize(snet->getSourceCount() + snet->getSinkCount(),0);
52  superNet=snet;
53  }
54 
55  // functions
56  /// \brief Returns net supernet
58  return superNet;
59  }
60 
61  /// \brief Sets super net
63  return (superNet=snet);
64  }
65 
66  /// \brief Returns path count for pin index
67  size_t getPathCount(size_t index){
68  return pathCounts[index];
69  }
70 
71  /// \brief Sets path count for pin index
72  bool setPathCount(size_t index, size_t pCount){
73  pathCounts[index] = pCount;
74  return true;
75  }
76 
77  /// \brief Returns path count for pin
79  size_t index =0;
80  Net::InstancePinSharedPtrIterator sip = superNet->sourcesBegin();
81  Net::InstancePinSharedPtrIterator sie = superNet->sourcesEnd();
82  while(sip != sie){
83  if(**sip == *pinPtr)
84  return getPathCount(index);;
85  ++index;
86  ++sip;
87  }
88 
89  sip = superNet->sinksBegin();
90  sie = superNet->sinksEnd();
91  while(sip != sie){
92  if(**sip == *pinPtr)
93  return getPathCount(index);;
94  ++index;
95  ++sip;
96  }
97  return getPathCount(index);
98  }
99 
100  /// \brief Sets path count for pin
101  bool setPathCount(InstancePinSharedPtr pinPtr, size_t pCount){
102  size_t index =0;
103  Net::InstancePinSharedPtrIterator sip = superNet->sourcesBegin();
104  Net::InstancePinSharedPtrIterator sie = superNet->sourcesEnd();
105  while(sip != sie){
106  if(**sip == *pinPtr)
107  return setPathCount(index, pCount);
108  ++index;
109  ++sip;
110  }
111  sip = superNet->sinksBegin();
112  sie = superNet->sinksEnd();
113  while(sip != sie){
114  if(**sip == *pinPtr)
115  return setPathCount(index, pCount);
116  ++index;
117  ++sip;
118  }
119  return setPathCount(index, pCount);
120  }
121 
122  // operators
123  /// \brief Equality operator.
124  /// \details This function deems nets equal if their names are identical.
125  /// \param rhs The net to compare against.
126  /// \returns true if both net names are identical, or false otherwise.
127  bool operator ==(const RoutingNet& rhs) const { return getName() == rhs.getName(); }
128  };
129 
130  /// \brief Shared pointer encapsulation of a RoutingNet.
131  typedef boost::shared_ptr<RoutingNet> RoutingNetSharedPtr;
132 
133  /// \brief Vector of RoutingNet shared pointers.
134  typedef std::vector<RoutingNetSharedPtr> RoutingNetSharedPtrVector;
135 
136 } // namespace physical
137 } // namespace torc
138 
139 #endif // TORC_PACKER_ROUTINGNET_HPP
RoutingNet(NetSharedPtr snet)
Constructor.
Definition: RoutingNet.hpp:50
std::string string
Imported type name.
Definition: RoutingNet.hpp:37
size_t getPathCount(InstancePinSharedPtr pinPtr)
Returns path count for pin.
Definition: RoutingNet.hpp:78
InstancePinSharedPtrVector::iterator InstancePinSharedPtrIterator
Non-constant iterator to InstancePin shared pointer objects.
RcFactory class for physical netlist elements.
Definition: RcFactory.hpp:34
std::vector< size_t > pathCounts
combinational path count
Definition: RoutingNet.hpp:43
boost::shared_ptr< class InstancePin > InstancePinSharedPtr
Shared pointer encapsulation of an InstancePin.
bool operator==(const RoutingNet &rhs) const
Equality operator.
Definition: RoutingNet.hpp:127
Concept for any object that can be named.
Definition: Named.hpp:36
std::string string
std::vector< RoutingNetSharedPtr > RoutingNetSharedPtrVector
Vector of RoutingNet shared pointers.
Definition: RoutingNet.hpp:134
bool setPathCount(size_t index, size_t pCount)
Sets path count for pin index.
Definition: RoutingNet.hpp:72
const string & getName(void) const
Returns the object name.
Definition: Named.hpp:51
boost::shared_ptr< Net > NetSharedPtr
Shared pointer encapsulation of a Net.
NetSharedPtr getSuperNet(void)
Returns net supernet.
Definition: RoutingNet.hpp:57
NetSharedPtr setSuperNet(NetSharedPtr snet)
Sets super net.
Definition: RoutingNet.hpp:62
Header for the Net class.
boost::shared_ptr< RoutingNet > RoutingNetSharedPtr
Shared pointer encapsulation of a RoutingNet.
Definition: RoutingNet.hpp:131
bool setPathCount(InstancePinSharedPtr pinPtr, size_t pCount)
Sets path count for pin.
Definition: RoutingNet.hpp:101
NetSharedPtr superNet
The original net.
Definition: RoutingNet.hpp:41
size_t getPathCount(size_t index)
Returns path count for pin index.
Definition: RoutingNet.hpp:67