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

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

#include <PathFinderNetRouterHeuristic.hpp>

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

Public Member Functions

 PathFinderNetRouterHeuristic (DDB &inDB)
 Public Constructor. More...
 
 ~PathFinderNetRouterHeuristic ()
 Destructor. More...
 
void processParameters ()
 
void setSink (const Tilewire &inSink)
 Set the current routing target. More...
 
void nodeCost (RouteNode &inNode)
 Calculate the node cost based on distance to the sink and path length. More...
 
void nodeCostInitial (RouteNode &inNode)
 
virtual void reorderSinks (const Tilewire &inSource, TilewireVector &inSinks)
 Reorder the Sinks based on this heuristic. More...
 
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...
 

Protected Member Functions

virtual boost::int32_t distanceToSink (const Tilewire &inTilewire)
 
virtual boost::int32_t clkDistanceToSink (const Tilewire &inTilewire)
 

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...
 
PathFinderSharingMapmConflictMap
 PathFinder sharing information. 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
 
typedef boost::unordered_map
< Tilewire, TilewireData
PathFinderSharingMap
 

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 44 of file PathFinderNetRouterHeuristic.hpp.

Member Typedef Documentation

Imported type names.

Definition at line 47 of file PathFinderNetRouterHeuristic.hpp.

Constructor & Destructor Documentation

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

Public Constructor.

Definition at line 88 of file PathFinderNetRouterHeuristic.hpp.

88  : NetRouterHeuristicBase(inDB),
89  mArcUsage(inDB.getArcUsage()), mTiles(inDB.getTiles()) {}
NetRouterHeuristicBase(DDB &inDB)
Public Constructor.
torc::router::PathFinderNetRouterHeuristic::~PathFinderNetRouterHeuristic ( )
inline

Destructor.

Definition at line 91 of file PathFinderNetRouterHeuristic.hpp.

91 {}

Member Function Documentation

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

Definition at line 223 of file PathFinderNetRouterHeuristic.hpp.

223  {
224  return -100;
225  }
virtual boost::int32_t torc::router::PathFinderNetRouterHeuristic::distanceToSink ( const Tilewire inTilewire)
inlineprotectedvirtual

Definition at line 213 of file PathFinderNetRouterHeuristic.hpp.

213  {
214  const TileInfo* tileInfo = &mTiles.getTileInfo(inTilewire.getTileIndex());
215  boost::int32_t distance = 0;
216  boost::int32_t iRow = tileInfo->getRow();
217  boost::int32_t iCol = tileInfo->getCol();
218  distance += iRow < mRow ? mRow - iRow : iRow - mRow;
219  distance += iCol < mCol ? mCol - iCol : iCol - mCol;
220  return distance;
221  }
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
boost::int32_t mCol
Target column coordinate.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Heuristic handling of expansion of a node.

Reimplemented from torc::router::NetRouterHeuristicBase.

Definition at line 190 of file PathFinderNetRouterHeuristic.hpp.

190  {
191  ArcVector tempArcs;
192 
193  //const architecture::TileInfo& tileInfo = mTiles.getTileInfo(inTilewire.getTileIndex());
194  //const architecture::WireInfo& wireInfo = mTiles.getWireInfo(
195  // tileInfo.getTypeIndex(), inTilewire.getWireIndex());
196  //if (wireInfo.isInput()) return;
197 
198  mDB.expandSegmentSinks(inTilewire, tempArcs, DDB::eExpandDirectionNone,
199  true, true, true, false);
200 
201  unsigned int s = tempArcs.size();
202  if (s == 0) return;
203  unsigned int t = inTilewire.getTileIndex() % s;
204  for (unsigned int i = t; i < s; i++) {
205  outArcs.push_back(tempArcs[i]);
206  }
207  for (unsigned int i = 0; i < t; i++) {
208  outArcs.push_back(tempArcs[i]);
209  }
210  }
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

+ Here is the call graph for this function:

+ Here is the caller 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:

void torc::router::PathFinderNetRouterHeuristic::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 107 of file PathFinderNetRouterHeuristic.hpp.

107  {
108  Tilewire sinkTilewire = inNode.getSinkTilewire();
109  boost::int32_t bestDistance = boost::integer_traits<boost::int32_t>::max();
110  boost::int32_t distance = boost::integer_traits<boost::int32_t>::max();
111  boost::int32_t cost = 0;
112  if (sinkTilewire == mTargetSink) {
113  inNode.setCost(0);
114  return;
115  }
116  mArcsBuf.clear();
117  expandSegmentSinks(sinkTilewire, mArcsBuf);
118  if (mArcsBuf.size() == 0) {
119  inNode.setCost(bestDistance);
120  return;
121  }
122  ArcVector::iterator p;
123  ArcVector::iterator e = mArcsBuf.end();
124  for (p = mArcsBuf.begin(); p != e; p++) {
125  if (mArcUsage.isUsed(*p)) continue;
126  if (sinkTilewire == mTargetSink) {
127  inNode.setCost(0);
128  return;
129  }
130  distance = distanceToSink(p->getSinkTilewire());
131  if (distance < bestDistance) bestDistance = distance;
132  }
133  if (bestDistance == boost::integer_traits<boost::int32_t>::max()) {
134  inNode.setCost(bestDistance);
135  return;
136  }
137  cost += bestDistance; // heuristic cost
138  /// \todo provide an additional field in RouteNode to store path cost
139  if (inNode.getParent() == NULL)
140  std::cout << "NULL PARENT" << std::endl;
141  else
142  cost += inNode.getParent()->getCost(); //add cost to parent;
143 
144  if (mConflictMap->find(sinkTilewire) != mConflictMap->end()) {
145  cost = (cost + (*mConflictMap)[sinkTilewire].mHistorySharing)
146  * (*mConflictMap)[sinkTilewire].mPresentSharing;
147  }
148 
149  inNode.setCost(cost);
150  }
void expandSegmentSinks(const Tilewire &inTilewire, ArcVector &outArcs)
Heuristic handling of expansion of a node.
PathFinderSharingMap * mConflictMap
PathFinder sharing information.
virtual boost::int32_t distanceToSink(const Tilewire &inTilewire)
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:

void torc::router::PathFinderNetRouterHeuristic::nodeCostInitial ( RouteNode inNode)
inline

Definition at line 152 of file PathFinderNetRouterHeuristic.hpp.

152  {
153  Tilewire sinkTilewire = inNode.getSinkTilewire();
154  boost::int32_t bestDistance = boost::integer_traits<boost::int32_t>::max();
155  boost::int32_t distance = boost::integer_traits<boost::int32_t>::max();
156  boost::int32_t cost = 0;
157  if (sinkTilewire == mTargetSink) {
158  inNode.setCost(0);
159  return;
160  }
161  mArcsBuf.clear();
162  expandSegmentSinks(sinkTilewire, mArcsBuf);
163  if (mArcsBuf.size() == 0) {
164  inNode.setCost(bestDistance);
165  return;
166  }
167  ArcVector::iterator p;
168  ArcVector::iterator e = mArcsBuf.end();
169  for (p = mArcsBuf.begin(); p != e; p++) {
170  if (mArcUsage.isUsed(*p)) continue;
171  if (sinkTilewire == mTargetSink) {
172  inNode.setCost(0);
173  return;
174  }
175  distance = distanceToSink(p->getSinkTilewire());
176  if (distance < bestDistance) bestDistance = distance;
177  }
178  if (bestDistance == boost::integer_traits<boost::int32_t>::max()) {
179  inNode.setCost(bestDistance);
180  return;
181  }
182  cost += bestDistance; // heuristic cost
183  inNode.setCost(cost);
184  }
void expandSegmentSinks(const Tilewire &inTilewire, ArcVector &outArcs)
Heuristic handling of expansion of a node.
virtual boost::int32_t distanceToSink(const Tilewire &inTilewire)
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:

void torc::router::PathFinderNetRouterHeuristic::processParameters ( )
inlinevirtual

Reimplemented from torc::router::RouterHeuristicBase.

Definition at line 93 of file PathFinderNetRouterHeuristic.hpp.

93  {
94  boost::any map = getParameter(0);
95  mConflictMap = boost::any_cast<PathFinderSharingMap*>(map);
96  std::cout<< "SETUP CONFLICT MAP" << std::endl;
97  }
boost::any getParameter(boost::uint32_t index)
Get a parameter.
PathFinderSharingMap * mConflictMap
PathFinder sharing information.
boost::unordered_map< Tilewire, TilewireData > PathFinderSharingMap

+ Here is the call graph for this function:

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

Reorder the Sinks based on this heuristic.

Reimplemented from torc::router::NetRouterHeuristicBase.

Definition at line 186 of file PathFinderNetRouterHeuristic.hpp.

186  {
187  // do nothing for now
188  }
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:

void torc::router::PathFinderNetRouterHeuristic::setSink ( const Tilewire inSink)
inlinevirtual

Set the current routing target.

Implements torc::router::NetRouterHeuristicBase.

Definition at line 100 of file PathFinderNetRouterHeuristic.hpp.

100  {
101  mSinkTileInfo = &mTiles.getTileInfo(inSink.getTileIndex());
102  mTargetSink = inSink;
105  }
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 & getTileInfo(TileIndex inTileIndex) const
Returns the TileInfo object for the specified tile.
Definition: Tiles.hpp:137
boost::int32_t mCol
Target column coordinate.
const TileInfo * mSinkTileInfo
Target sink tile information.

+ Here is the call graph for this function:

Field Documentation

ArcVector torc::router::PathFinderNetRouterHeuristic::mArcsBuf
protected

Arc buffer.

Definition at line 79 of file PathFinderNetRouterHeuristic.hpp.

ArcUsage& torc::router::PathFinderNetRouterHeuristic::mArcUsage
protected

ArcUsage reference.

Definition at line 64 of file PathFinderNetRouterHeuristic.hpp.

boost::int32_t torc::router::PathFinderNetRouterHeuristic::mCol
protected

Target column coordinate.

Definition at line 74 of file PathFinderNetRouterHeuristic.hpp.

PathFinderSharingMap* torc::router::PathFinderNetRouterHeuristic::mConflictMap
protected

PathFinder sharing information.

Definition at line 82 of file PathFinderNetRouterHeuristic.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::PathFinderNetRouterHeuristic::mRow
protected

Target row coordinate.

Definition at line 72 of file PathFinderNetRouterHeuristic.hpp.

TilewireVector torc::router::PathFinderNetRouterHeuristic::mSegmentBuf
protected

Segment tilewire buffer.

Definition at line 77 of file PathFinderNetRouterHeuristic.hpp.

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

Target sink tile information.

Definition at line 70 of file PathFinderNetRouterHeuristic.hpp.

Tilewire torc::router::PathFinderNetRouterHeuristic::mTargetSink
protected

Target sink tilewire.

Definition at line 68 of file PathFinderNetRouterHeuristic.hpp.

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

Tiles reference.

Definition at line 66 of file PathFinderNetRouterHeuristic.hpp.


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