torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RouteUtilities.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 Utilities class.
18 
19 #ifndef TORC_ROUTER_ROUTUTILITIES_HPP
20 #define TORC_ROUTER_ROUTUTILITIES_HPP
21 
22 #include "torc/router/RouteNet.hpp"
23 #include "torc/Physical.hpp"
27 
28 #include <string>
29 #include <map>
30 #include <boost/unordered_map.hpp>
31 #include <boost/any.hpp>
32 
33 namespace torc {
34 namespace router {
35 
36 
37  /// \brief Router net.
38  /// \details The RouteNet class contains architecture specific sources and sinks.
40  // types
41  /// Imported type names
47 
49  typedef std::vector<NetSharedPtr> NetSharedPtrVector;
57 
58  public:
59  typedef ArcVector::const_iterator ArcConstIterator;
60  typedef ArcVector::iterator ArcIterator;
61  typedef TilewireVector::const_iterator TilewireConstIterator;
62  typedef TilewireVector::iterator TilewireIterator;
63  typedef RouteNodePtrVector::const_iterator RouteNodePtrConstIterator;
64  typedef RouteNodePtrVector::iterator RouteNodePtrIterator;
65 
66  protected:
67  // members
68  /// \brief Name of the net.
69  string mName;
70  /// \brief Vector of net source Tilewires.
72  /// \brief Vector of net sink Tilewires.
74  /// \brief Vector of arcs representing net connectivity.
76  /// \brief Vector of RouteNodes representing net connectivity.
78  /// \brief Net annotation structure.
79  public:
80  boost::unordered_map<boost::uint32_t, boost::any> mProperties;
81 
82  public:
83  // constructors
84  /// \brief Constructor.
86 
88  RouteNetVector& routenets) {
89  NetSharedPtrIterator p = netsbegin;
90  for (p = netsbegin; p != netsend; p++) {
91  TilewireVector sources;
92  TilewireVector sinks;
93 //std::cout << "Converting: " << (*p)->getName() << std::endl;
94  //for (InstancePinSharedPtrConstIterator pinPtr = (*p)->sourcesBegin();
95  for (InstancePinSharedPtrIterator pinPtr = (*p)->sourcesBegin();
96  pinPtr != (*p)->sourcesEnd(); pinPtr++) {
97  //sources.push_back((((architecture::InstancePin)(*pinPtr)).getTilewire());
98  sources.push_back(INSTANCE_PIN_PHYSICAL_TO_ARCHITECTURE(*pinPtr)->getTilewire());
99 //std::cout << "Source: " << sources.back() << std::endl;
100  if (sources.back() == Tilewire::sInvalid) {
101  std::cout << "BAD IMPORT: " << (*p)->getName() << " - "
102  << (*pinPtr)->getPinName() << std::endl;
103  }
104  }
105  for (InstancePinSharedPtrIterator pinPtr = (*p)->sinksBegin();
106  pinPtr != (*p)->sinksEnd(); pinPtr++) {
107  sinks.push_back(INSTANCE_PIN_PHYSICAL_TO_ARCHITECTURE(*pinPtr)->getTilewire());
108 //std::cout << "Sink: " << sinks.back() << std::endl;
109  if (sinks.back() == Tilewire::sInvalid) {
110  std::cout << "BAD IMPORT: " << (*p)->getName() << " - "
111  << (*pinPtr)->getPinName() << std::endl;
112  }
113  }
114 
115 
116  std::string name = (*p)->getName();
117  routenets.push_back(RouteNet(name, sources, sinks));
118  }
119  }
121  NetSharedPtrIterator netsend, architecture::DDB& ddb) {
122  NetSharedPtrIterator p = netsbegin;
123  architecture::ExtendedWireInfo ewisource(ddb);
124  architecture::ExtendedWireInfo ewisink(ddb);
125  unsigned int i = 0;
126  for (p = netsbegin; p != netsend; p++) {
127  if (!((*p)->getName() == routenets[i].getName())) {
128  std::cout << "Name mismatch for corresponding entry: "
129  << (*p)->getName() << " " << routenets[i].getName() << std::endl;
130  throw;
131  }
132  // convert route nodes to pips
133  RouteNodePtrVector& routeNodes = routenets[i].routeNodes();
134  for (unsigned int j = 0; j < routeNodes.size(); j++) {
135  Arc arc = routeNodes[j]->getArc();
136 
137  if (arc.getSourceTilewire() == arc.getSinkTilewire()) continue;
138 
139  ewisource = arc.getSourceTilewire();
140  ewisink = arc.getSinkTilewire();
141 
142  Pip pip = physical::Factory::newPip(ewisource.mTileName, ewisource.mWireName,
144 
145  (*p)->addPip(pip);
146  }
147 
148 
149 
150  i++;
151  }
152  }
153  };
154 
155 
156 } // namespace router
157 } // namespace torc
158 
159 #endif // TORC_ROUTER_ROUTEUTILITIES_HPP
string mName
Name of the net.
Encapsulation of an arc between two tilewires.
Definition: Arc.hpp:28
std::vector< Tilewire > TilewireVector
Vector of Tilewire objects.
Definition: Tilewire.hpp:101
boost::unordered_map< boost::uint32_t, boost::any > mProperties
Net annotation structure.
std::vector< RouteNode * > RouteNodePtrVector
Vector of RouteNode pointers.
Definition: RouteNode.hpp:115
Device database, including complete wiring and logic support.
Definition: DDB.hpp:42
void design2routenets(NetSharedPtrIterator netsbegin, NetSharedPtrIterator netsend, RouteNetVector &routenets)
std::vector< RouteNet > RouteNetVector
Vector of RouteNet objects.
Definition: RouteNet.hpp:205
const char * mWireName
The wire name.
InstancePinSharedPtrVector::iterator InstancePinSharedPtrIterator
Non-constant iterator to InstancePin shared pointer objects.
torc::physical::Circuit::NetSharedPtrIterator NetSharedPtrIterator
void routenets2design(RouteNetVector &routenets, NetSharedPtrIterator netsbegin, NetSharedPtrIterator netsend, architecture::DDB &ddb)
RouteNodePtrVector::iterator RouteNodePtrIterator
ArcVector::const_iterator ArcConstIterator
std::vector< Arc > ArcVector
Vector of Arc objects.
Definition: Arc.hpp:78
ArcVector::iterator ArcIterator
std::string string
const Tilewire & getSourceTilewire(void) const
Returns the source tilewire.
Definition: Arc.hpp:45
architecture::ArcVector ArcVector
const Tilewire & getSinkTilewire(void) const
Returns the sink tilewire.
Definition: Arc.hpp:47
torc::physical::Net::InstancePinSharedPtrConstIterator InstancePinSharedPtrConstIterator
const char * mTileName
The tile name.
Main torc::physical namespace header.
Encapsulation of a device tile and wire pair.
Definition: Tilewire.hpp:39
ArcVector mArcs
Vector of arcs representing net connectivity.
static torc::physical::Pip newPip(const string &inTileName, const string &inSourceWireName, const string &inSinkWireName, EPipDirection inPipDirection, RoutethroughSharedPtr inRoutethroughPtr=RoutethroughSharedPtr())
Construct a pip and return it.
boost::shared_ptr< Net > NetSharedPtr
Shared pointer encapsulation of a Net.
Verbose encapsulation of a wire's information.
architecture::TilewireVector TilewireVector
torc::physical::NetSharedPtr NetSharedPtr
TilewireVector mSources
Vector of net source Tilewires.
TilewireVector::const_iterator TilewireConstIterator
Header for the Tilewire class.
InstancePinSharedPtrVector::const_iterator InstancePinSharedPtrConstIterator
Constant iterator to InstancePin shared pointer objects.
torc::physical::Net::InstancePinSharedPtrIterator InstancePinSharedPtrIterator
NetSharedPtrVector::iterator NetSharedPtrIterator
Non-constant iterator to Net shared pointers.
Definition: Circuit.hpp:78
std::vector< NetSharedPtr > NetSharedPtrVector
Physical design programmable interconnect point.
Definition: Pip.hpp:34
#define INSTANCE_PIN_PHYSICAL_TO_ARCHITECTURE(x)
Reinterpret the given torc::physical::InstancePinSharedPtr as a torc::architecture::InstancePinShared...
torc::physical::Circuit::NetSharedPtrConstIterator NetSharedPtrConstIterator
TilewireVector::iterator TilewireIterator
RouteNodePtrVector mRouteNodes
Vector of RouteNodes representing net connectivity.
Header for the DDB class.
static const Tilewire sInvalid
Definition: Tilewire.hpp:93
std::string string
Imported type names.
RouteNodePtrVector::const_iterator RouteNodePtrConstIterator
Header for the XdlImporter class.
TilewireVector mSinks
Vector of net sink Tilewires.
architecture::Tilewire Tilewire
NetSharedPtrVector::const_iterator NetSharedPtrConstIterator
Constant iterator to Net shared pointers.
Definition: Circuit.hpp:76
Header for the Net class.