torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
torc::router::NetRouterHeuristic Class Reference

Provides net routing based on the Nillson graphsearch algorithm. More...

#include <NetRouterHeuristic.hpp>

+ Inheritance diagram for torc::router::NetRouterHeuristic:
+ Collaboration diagram for torc::router::NetRouterHeuristic:

Public Member Functions

 NetRouterHeuristic (DDB &inDB)
 Public Constructor. More...
 
 ~NetRouterHeuristic ()
 Destructor. More...
 
virtual void setSink (const Tilewire &inSink)
 Set the current routing target. More...
 
virtual void nodeCost (RouteNode &inNode)
 Calculate the node cost based on distance to the sink and path length. More...
 
virtual void nodeCostInitial (RouteNode &inNode)
 
virtual void reorderSinks (const Tilewire &inSource, TilewireVector &inSinks)
 Reorder the Sinks based on this heuristic. More...
 
virtual void expandSegmentSinks (const Tilewire &inTilewire, ArcVector &outArcs)
 Heuristic handling of expansion of a node. More...
 
boost::any getParameter (boost::uint32_t index)
 Get a parameter. More...
 
void setParameter (boost::uint32_t index, boost::any inParameter)
 Set a parameter. More...
 
virtual void processParameters ()
 Do something with the parameters. More...
 

Protected Member Functions

virtual boost::int32_t distanceToSink (const Tilewire &inTilewire)
 
virtual boost::int32_t clkDistanceToSink (const Tilewire &inTilewire)
 
boost::int32_t distanceFromParent (const Tilewire &inParent, const Tilewire &inCurrent)
 

Protected Attributes

ArcUsagemArcUsage
 ArcUsage reference. More...
 
const TilesmTiles
 Tiles reference. More...
 
Tilewire mTargetSink
 Target sink tilewire. More...
 
const TileInfomSinkTileInfo
 Target sink tile information. More...
 
boost::int32_t mRow
 Target row coordinate. More...
 
boost::int32_t mCol
 Target column coordinate. More...
 
TilewireVector mSegmentBuf
 Segment tilewire buffer. More...
 
ArcVector mArcsBuf
 Arc buffer. More...
 
DDBmDB
 Database reference. More...
 
ParameterMap mParameters
 Parameter map. More...
 

Private Types

typedef architecture::DDB DDB
 Imported type names. More...
 
typedef architecture::Tiles Tiles
 
typedef architecture::ArcUsage ArcUsage
 
typedef architecture::WireUsage WireUsage
 
typedef architecture::Tilewire Tilewire
 
typedef architecture::TileInfo TileInfo
 
typedef architecture::Arc Arc
 
typedef
architecture::TilewireVector 
TilewireVector
 
typedef architecture::ArcVector ArcVector
 
typedef
architecture::xilinx::TileRow 
TileRow
 
typedef
architecture::xilinx::TileCol 
TileCol
 

Detailed Description

Provides net routing based on the Nillson graphsearch algorithm.

The router can either return a vector of nodes or directly populate DDB usage.

Definition at line 43 of file NetRouterHeuristic.hpp.

Member Typedef Documentation

Imported type names.

Definition at line 46 of file NetRouterHeuristic.hpp.

Constructor & Destructor Documentation

torc::router::NetRouterHeuristic::NetRouterHeuristic ( DDB inDB)
inline

Public Constructor.

Definition at line 83 of file NetRouterHeuristic.hpp.

83  : NetRouterHeuristicBase(inDB),
84  mArcUsage(inDB.getArcUsage()), mTiles(inDB.getTiles()) {}
ArcUsage & mArcUsage
ArcUsage reference.
NetRouterHeuristicBase(DDB &inDB)
Public Constructor.
const Tiles & mTiles
Tiles reference.
torc::router::NetRouterHeuristic::~NetRouterHeuristic ( )
inline

Destructor.

Definition at line 86 of file NetRouterHeuristic.hpp.

86 {}

Member Function Documentation

virtual boost::int32_t torc::router::NetRouterHeuristic::clkDistanceToSink ( const Tilewire inTilewire)
inlineprotectedvirtual

Definition at line 206 of file NetRouterHeuristic.hpp.

206  {
207  return -100;
208  }
boost::int32_t torc::router::NetRouterHeuristic::distanceFromParent ( const Tilewire inParent,
const Tilewire inCurrent 
)
inlineprotected

Definition at line 210 of file NetRouterHeuristic.hpp.

210  {
211  const TileInfo* parentInfo = &mTiles.getTileInfo(inParent.getTileIndex());
212  const TileInfo* currentInfo = &mTiles.getTileInfo(inCurrent.getTileIndex());
213 
214  boost::int32_t distance = 0;
215  boost::int32_t pRow = parentInfo->getRow();
216  boost::int32_t pCol = parentInfo->getCol();
217  boost::int32_t cRow = currentInfo->getRow();
218  boost::int32_t cCol = currentInfo->getCol();
219  distance += pRow < cRow ? cRow - pRow : pRow - cRow;
220  distance += pCol < cCol ? cCol - pCol : pCol - cCol;
221  return distance;
222  }
const TileRow & getRow(void) const
Returns the row for this tile.
Definition: TileInfo.hpp:94
const TileInfo & getTileInfo(TileIndex inTileIndex) const
Returns the TileInfo object for the specified tile.
Definition: Tiles.hpp:137
const Tiles & mTiles
Tiles reference.

+ Here is the call graph for this function:

virtual boost::int32_t torc::router::NetRouterHeuristic::distanceToSink ( const Tilewire inTilewire)
inlineprotectedvirtual

Definition at line 196 of file NetRouterHeuristic.hpp.

196  {
197  const TileInfo* tileInfo = &mTiles.getTileInfo(inTilewire.getTileIndex());
198  boost::int32_t distance = 0;
199  boost::int32_t iRow = tileInfo->getRow();
200  boost::int32_t iCol = tileInfo->getCol();
201  distance += iRow < mRow ? mRow - iRow : iRow - mRow;
202  distance += iCol < mCol ? mCol - iCol : iCol - mCol;
203  return distance;
204  }
const TileRow & getRow(void) const
Returns the row for this tile.
Definition: TileInfo.hpp:94
const TileInfo & getTileInfo(TileIndex inTileIndex) const
Returns the TileInfo object for the specified tile.
Definition: Tiles.hpp:137
const Tiles & mTiles
Tiles reference.
boost::int32_t mRow
Target row coordinate.
boost::int32_t mCol
Target column coordinate.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void torc::router::NetRouterHeuristic::expandSegmentSinks ( const Tilewire inTilewire,
ArcVector outArcs 
)
inlinevirtual

Heuristic handling of expansion of a node.

Reimplemented from torc::router::NetRouterHeuristicBase.

Definition at line 174 of file NetRouterHeuristic.hpp.

174  {
175  ArcVector tempArcs;
176 
177  const architecture::TileInfo& tileInfo = mTiles.getTileInfo(inTilewire.getTileIndex());
178  const architecture::WireInfo& wireInfo = mTiles.getWireInfo(
179  tileInfo.getTypeIndex(), inTilewire.getWireIndex());
180  if (wireInfo.isInput()) return;
181 
182  mDB.expandSegmentSinks(inTilewire, tempArcs, DDB::eExpandDirectionNone,
183  true, true, true, false);
184  unsigned int s = tempArcs.size();
185  if (s == 0) return;
186  unsigned int t = inTilewire.getTileIndex() % s;
187  for (unsigned int i = t; i < s; i++) {
188  outArcs.push_back(tempArcs[i]);
189  }
190  for (unsigned int i = 0; i < t; i++) {
191  outArcs.push_back(tempArcs[i]);
192  }
193  }
const TileInfo & getTileInfo(TileIndex inTileIndex) const
Returns the TileInfo object for the specified tile.
Definition: Tiles.hpp:137
const Array< const WireInfo > & getWireInfo(TileTypeIndex inTileTypeIndex) const
Returns the WireInfo array for the specified tile type.
Definition: Tiles.hpp:140
void expandSegmentSinks(const Tilewire &inTilewire, ArcVector &outSinks, EExpandDirection inExpandDirection=eExpandDirectionNone, bool inUseTied=true, bool inUseRegular=true, bool inUseIrregular=true, bool inUseRoutethrough=true)
Expands all sink arcs for the given tilewire's segment.
Definition: DDB.cpp:314
const Tiles & mTiles
Tiles reference.

+ Here is the call graph for this function:

boost::any torc::router::RouterHeuristicBase::getParameter ( boost::uint32_t  index)
inlineinherited

Get a parameter.

Definition at line 52 of file RouterHeuristicBase.hpp.

52  {
53  ParameterMap::iterator p = mParameters.find(index);
54  if (p != mParameters.end()) {
55  return p->second;
56  }
57  return boost::any();
58  }
ParameterMap mParameters
Parameter map.

+ Here is the caller graph for this function:

virtual void torc::router::NetRouterHeuristic::nodeCost ( RouteNode inNode)
inlinevirtual

Calculate the node cost based on distance to the sink and path length.

Todo:
provide an additional field in RouteNode to store path cost

Implements torc::router::NetRouterHeuristicBase.

Definition at line 96 of file NetRouterHeuristic.hpp.

96  {
97  Tilewire sinkTilewire = inNode.getSinkTilewire();
98  boost::int32_t bestDistance = boost::integer_traits<boost::int32_t>::max();
99  boost::int32_t distance = boost::integer_traits<boost::int32_t>::max();
100  boost::int32_t cost = 0;
101  if (sinkTilewire == mTargetSink) {
102  inNode.setCost(0);
103  return;
104  }
105  mArcsBuf.clear();
106  mDB.expandSegmentSinks(sinkTilewire, mArcsBuf);
107  if (mArcsBuf.size() == 0) {
108  inNode.setCost(bestDistance);
109  return;
110  }
111  ArcVector::iterator p;
112  ArcVector::iterator e = mArcsBuf.end();
113  for (p = mArcsBuf.begin(); p != e; p++) {
114  if (mArcUsage.isUsed(*p)) continue;
115  if (sinkTilewire == mTargetSink) {
116  inNode.setCost(0);
117  return;
118  }
119  distance = distanceToSink(p->getSinkTilewire());
120  if (distance < bestDistance) bestDistance = distance;
121  }
122  if (bestDistance == boost::integer_traits<boost::int32_t>::max()) {
123  inNode.setCost(bestDistance);
124  return;
125  }
126  cost += bestDistance; // heuristic cost
127  /// \todo provide an additional field in RouteNode to store path cost
128  if (inNode.getParent() == NULL)
129  std::cout << "NULL PARENT" << std::endl;
130  else
131  cost += inNode.getParent()->getCost(); //add cost to parent;
132  inNode.setCost(cost);
133 
134  }
ArcUsage & mArcUsage
ArcUsage reference.
virtual boost::int32_t distanceToSink(const Tilewire &inTilewire)
void expandSegmentSinks(const Tilewire &inTilewire, ArcVector &outSinks, EExpandDirection inExpandDirection=eExpandDirectionNone, bool inUseTied=true, bool inUseRegular=true, bool inUseIrregular=true, bool inUseRoutethrough=true)
Expands all sink arcs for the given tilewire's segment.
Definition: DDB.cpp:314
Tilewire mTargetSink
Target sink tilewire.
bool isUsed(const Arc &inArc)
Determines whether the specified arc is in use.
Definition: ArcUsage.hpp:209

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void torc::router::NetRouterHeuristic::nodeCostInitial ( RouteNode inNode)
inlinevirtual

Definition at line 136 of file NetRouterHeuristic.hpp.

136  {
137  Tilewire sinkTilewire = inNode.getSinkTilewire();
138  boost::int32_t bestDistance = boost::integer_traits<boost::int32_t>::max();
139  boost::int32_t distance = boost::integer_traits<boost::int32_t>::max();
140  boost::int32_t cost = 0;
141  if (sinkTilewire == mTargetSink) {
142  inNode.setCost(0);
143  return;
144  }
145  mArcsBuf.clear();
146  mDB.expandSegmentSinks(sinkTilewire, mArcsBuf);
147  if (mArcsBuf.size() == 0) {
148  inNode.setCost(bestDistance);
149  return;
150  }
151  ArcVector::iterator p;
152  ArcVector::iterator e = mArcsBuf.end();
153  for (p = mArcsBuf.begin(); p != e; p++) {
154  if (mArcUsage.isUsed(*p)) continue;
155  if (sinkTilewire == mTargetSink) {
156  inNode.setCost(0);
157  return;
158  }
159  distance = distanceToSink(p->getSinkTilewire());
160  if (distance < bestDistance) bestDistance = distance;
161  }
162  if (bestDistance == boost::integer_traits<boost::int32_t>::max()) {
163  inNode.setCost(bestDistance);
164  return;
165  }
166  cost += bestDistance; // heuristic cost
167  inNode.setCost(cost);
168  }
ArcUsage & mArcUsage
ArcUsage reference.
virtual boost::int32_t distanceToSink(const Tilewire &inTilewire)
void expandSegmentSinks(const Tilewire &inTilewire, ArcVector &outSinks, EExpandDirection inExpandDirection=eExpandDirectionNone, bool inUseTied=true, bool inUseRegular=true, bool inUseIrregular=true, bool inUseRoutethrough=true)
Expands all sink arcs for the given tilewire's segment.
Definition: DDB.cpp:314
Tilewire mTargetSink
Target sink tilewire.
bool isUsed(const Arc &inArc)
Determines whether the specified arc is in use.
Definition: ArcUsage.hpp:209

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void torc::router::RouterHeuristicBase::processParameters ( )
inlinevirtualinherited

Do something with the parameters.

Reimplemented in torc::router::PathFinderNetRouterHeuristic.

Definition at line 64 of file RouterHeuristicBase.hpp.

64 {}

+ Here is the caller graph for this function:

virtual void torc::router::NetRouterHeuristic::reorderSinks ( const Tilewire inSource,
TilewireVector inSinks 
)
inlinevirtual

Reorder the Sinks based on this heuristic.

Reimplemented from torc::router::NetRouterHeuristicBase.

Definition at line 170 of file NetRouterHeuristic.hpp.

170  {
171  // do nothing for now
172  }
void torc::router::RouterHeuristicBase::setParameter ( boost::uint32_t  index,
boost::any  inParameter 
)
inlineinherited

Set a parameter.

Definition at line 60 of file RouterHeuristicBase.hpp.

60  {
61  mParameters[index] = inParameter;
62  }
ParameterMap mParameters
Parameter map.

+ Here is the caller graph for this function:

virtual void torc::router::NetRouterHeuristic::setSink ( const Tilewire inSink)
inlinevirtual

Set the current routing target.

Implements torc::router::NetRouterHeuristicBase.

Definition at line 89 of file NetRouterHeuristic.hpp.

89  {
90  mSinkTileInfo = &mTiles.getTileInfo(inSink.getTileIndex());
91  mTargetSink = inSink;
94  }
const TileCol & getCol(void) const
Returns the column for this tile.
Definition: TileInfo.hpp:96
const TileRow & getRow(void) const
Returns the row for this tile.
Definition: TileInfo.hpp:94
const TileInfo * mSinkTileInfo
Target sink tile information.
const TileInfo & getTileInfo(TileIndex inTileIndex) const
Returns the TileInfo object for the specified tile.
Definition: Tiles.hpp:137
const Tiles & mTiles
Tiles reference.
Tilewire mTargetSink
Target sink tilewire.
boost::int32_t mRow
Target row coordinate.
boost::int32_t mCol
Target column coordinate.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ArcVector torc::router::NetRouterHeuristic::mArcsBuf
protected

Arc buffer.

Definition at line 76 of file NetRouterHeuristic.hpp.

ArcUsage& torc::router::NetRouterHeuristic::mArcUsage
protected

ArcUsage reference.

Definition at line 61 of file NetRouterHeuristic.hpp.

boost::int32_t torc::router::NetRouterHeuristic::mCol
protected

Target column coordinate.

Definition at line 71 of file NetRouterHeuristic.hpp.

DDB& torc::router::RouterHeuristicBase::mDB
protectedinherited

Database reference.

Definition at line 40 of file RouterHeuristicBase.hpp.

ParameterMap torc::router::RouterHeuristicBase::mParameters
protectedinherited

Parameter map.

Definition at line 42 of file RouterHeuristicBase.hpp.

boost::int32_t torc::router::NetRouterHeuristic::mRow
protected

Target row coordinate.

Definition at line 69 of file NetRouterHeuristic.hpp.

TilewireVector torc::router::NetRouterHeuristic::mSegmentBuf
protected

Segment tilewire buffer.

Definition at line 74 of file NetRouterHeuristic.hpp.

const TileInfo* torc::router::NetRouterHeuristic::mSinkTileInfo
protected

Target sink tile information.

Definition at line 67 of file NetRouterHeuristic.hpp.

Tilewire torc::router::NetRouterHeuristic::mTargetSink
protected

Target sink tilewire.

Definition at line 65 of file NetRouterHeuristic.hpp.

const Tiles& torc::router::NetRouterHeuristic::mTiles
protected

Tiles reference.

Definition at line 63 of file NetRouterHeuristic.hpp.


The documentation for this class was generated from the following file: