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

Provides path extraction from usage information in a DDB instance.. More...

#include <Trace.hpp>

+ Collaboration diagram for torc::router::Trace:

Public Types

enum  ETraceMode {
  eTraceFullNet = 0, eTraceToSinks, eTraceToBranch, eTraceToSources,
  eTraceSinglePath
}
 Enumeration for Trace modes. More...
 

Public Member Functions

 Trace (DDB &inDB, Tilewire inTilewire, ETraceMode inTraceMode=eTraceFullNet)
 Public Constructor. More...
 
 ~Trace ()
 Destructor. More...
 
TraceNodePtrVectorgetSinks ()
 Get trace sink nodes. More...
 
TraceNodePtrVectorgetSources ()
 Get trace source nodes. More...
 
TraceNodePtrVectorgetBranchPoints ()
 Get trace branch point nodes. More...
 
ArcVectorgetArcs ()
 Get all Arcs found during the trace. More...
 

Protected Member Functions

void traceWorker (TraceNode *inNode, ETraceMode inMode)
 Recursively traces from the specified TraceNode in the specified mode. More...
 
void normalizeDepth (TraceNode *inNode)
 Normalize depth of nodes. More...
 
TraceNodecreateNode (Tilewire inTilewire)
 Create a TraceNode and update auxiliary structures. More...
 
TraceNodegetNode (Tilewire inTilewire)
 Get a TraceNode based on its owning Tilewire. More...
 
Arc findArc (TraceNode *source, TraceNode *sink)
 Find a traced Arc from the nodes that it connects. More...
 

Protected Attributes

DDBmDB
 Database reference. More...
 
ArcUsagemArcUsage
 ArcUsage reference. More...
 
TraceNodemInitialNode
 TraceNode representing the starting point for this trace. More...
 
TraceNodePtrVector mSinks
 Vector of net sink nodes. More...
 
TraceNodePtrVector mSources
 Vector of net source nodes. More...
 
TraceNodePtrVector mBranchPoints
 Vector of net branch nodes. More...
 
TraceNodePtrVector mAllNodes
 Vector of all TraceNode pointers. More...
 
std::map< Tilewire, TraceNode * > mTilewireToTraceNode
 Map of Tilewires to owning TraceNode. More...
 
std::map< TraceNode
*, std::map< TraceNode *, Arc > > 
mTraceNodesToArc
 Map of TraceNode pointers to Arc that connects them. More...
 
ArcVector mArcVector
 Vector of all arcs, populated on a getArcs call. More...
 

Private Types

typedef architecture::DDB DDB
 Imported type name. More...
 
typedef architecture::ArcUsage ArcUsage
 
typedef architecture::Tilewire Tilewire
 
typedef architecture::Arc Arc
 
typedef
architecture::TilewireVector 
TilewireVector
 
typedef architecture::ArcVector ArcVector
 

Detailed Description

Provides path extraction from usage information in a DDB instance..

The tracer provides functions that recover a set of connected routing resources to build up complete or partial nets from the device usage information.

Definition at line 36 of file Trace.hpp.

Member Typedef Documentation

Definition at line 42 of file Trace.hpp.

Definition at line 40 of file Trace.hpp.

Definition at line 44 of file Trace.hpp.

Imported type name.

Definition at line 39 of file Trace.hpp.

Definition at line 41 of file Trace.hpp.

Member Enumeration Documentation

Enumeration for Trace modes.

Enumerator
eTraceFullNet 
eTraceToSinks 
eTraceToBranch 
eTraceToSources 
eTraceSinglePath 

Definition at line 72 of file Trace.hpp.

Constructor & Destructor Documentation

torc::router::Trace::Trace ( DDB inDB,
Tilewire  inTilewire,
ETraceMode  inTraceMode = eTraceFullNet 
)
inline

Public Constructor.

Definition at line 78 of file Trace.hpp.

79  : mDB(inDB), mArcUsage(inDB.getArcUsage()) {
80  mInitialNode = createNode(inTilewire);
81  switch (inTraceMode) {
82  case eTraceFullNet:
83  case eTraceToSinks:
84  case eTraceToBranch:
85  case eTraceToSources:
86  case eTraceSinglePath:
87  break;
88  default:
89  std::cout << "Invalid Trace mode setting." << std::endl;
90  return;
91  }
92  traceWorker(mInitialNode, inTraceMode);
93  }
TraceNode * createNode(Tilewire inTilewire)
Create a TraceNode and update auxiliary structures.
Definition: Trace.hpp:319
void traceWorker(TraceNode *inNode, ETraceMode inMode)
Recursively traces from the specified TraceNode in the specified mode.
Definition: Trace.hpp:141
ArcUsage & mArcUsage
ArcUsage reference.
Definition: Trace.hpp:50
TraceNode * mInitialNode
TraceNode representing the starting point for this trace.
Definition: Trace.hpp:53
DDB & mDB
Database reference.
Definition: Trace.hpp:48

+ Here is the call graph for this function:

torc::router::Trace::~Trace ( )
inline

Destructor.

Definition at line 95 of file Trace.hpp.

95  {
96  std::cout << "Destroying Trace!" << std::endl;
97  TraceNodePtrVector::iterator p;
98  TraceNodePtrVector::iterator e = mAllNodes.end();
99  for (p = mAllNodes.begin(); p != e; p++) {
100  delete *p;
101  }
102  mAllNodes.clear();
103  mSinks.clear();
104  mSources.clear();
105  mBranchPoints.clear();
106  //delete mInitialNode;
107  }
TraceNodePtrVector mBranchPoints
Vector of net branch nodes.
Definition: Trace.hpp:59
TraceNodePtrVector mSources
Vector of net source nodes.
Definition: Trace.hpp:57
TraceNodePtrVector mSinks
Vector of net sink nodes.
Definition: Trace.hpp:55
TraceNodePtrVector mAllNodes
Vector of all TraceNode pointers.
Definition: Trace.hpp:62

Member Function Documentation

TraceNode* torc::router::Trace::createNode ( Tilewire  inTilewire)
inlineprotected

Create a TraceNode and update auxiliary structures.

Definition at line 319 of file Trace.hpp.

319  {
320  std::map<Tilewire, TraceNode*>::iterator it;
321  it = mTilewireToTraceNode.find(inTilewire);
322  if (it != mTilewireToTraceNode.end()) {
323  return 0;
324  }
325  TilewireVector segmentTilewires;
326  mDB.expandSegment(inTilewire, segmentTilewires);
327  TraceNode* newNode = new TraceNode(inTilewire);
328  mAllNodes.push_back(newNode);
329  for (unsigned int i = 0; i < segmentTilewires.size(); i++) {
330  mTilewireToTraceNode.insert(
331  std::pair<Tilewire, TraceNode*>(segmentTilewires[i], newNode));
332  }
333  return newNode;
334  }
architecture::TilewireVector TilewireVector
Definition: Trace.hpp:43
std::map< Tilewire, TraceNode * > mTilewireToTraceNode
Map of Tilewires to owning TraceNode.
Definition: Trace.hpp:64
TraceNodePtrVector mAllNodes
Vector of all TraceNode pointers.
Definition: Trace.hpp:62
DDB & mDB
Database reference.
Definition: Trace.hpp:48
void expandSegment(const Tilewire &inTilewire, TilewireVector &outTilewires, EExpandDirection inExpandDirection=eExpandDirectionNone)
Expands the given tilewire's segment.
Definition: DDB.cpp:154

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Arc torc::router::Trace::findArc ( TraceNode source,
TraceNode sink 
)
inlineprotected

Find a traced Arc from the nodes that it connects.

Definition at line 346 of file Trace.hpp.

346  {
347  // returns the Arc connecting the two nodes if the arc exists.
348  std::map<TraceNode*, std::map<TraceNode*, Arc> >::iterator outer_p;
349  std::map<TraceNode*, std::map<TraceNode*, Arc> >::iterator outer_end;
350  std::map<TraceNode*, Arc>::iterator inner_p;
351  std::map<TraceNode*, Arc>::iterator inner_end;
352  outer_end = mTraceNodesToArc.end();
353  outer_p = mTraceNodesToArc.find(source);
354  if (outer_p != outer_end) {
355  std::map<TraceNode*, Arc> innermap = outer_p->second;
356  inner_end = innermap.end();
357  inner_p = innermap.find(sink);
358  if (inner_p != inner_end) {
359  return inner_p->second;
360  }
361  }
362  return Arc();
363  }
std::map< TraceNode *, std::map< TraceNode *, Arc > > mTraceNodesToArc
Map of TraceNode pointers to Arc that connects them.
Definition: Trace.hpp:66
architecture::Arc Arc
Definition: Trace.hpp:42

+ Here is the caller graph for this function:

ArcVector& torc::router::Trace::getArcs ( )
inline

Get all Arcs found during the trace.

Definition at line 121 of file Trace.hpp.

121  {
122  mArcVector.clear();
123  std::map<TraceNode*, std::map<TraceNode*, Arc> >::iterator outer_p;
124  std::map<TraceNode*, std::map<TraceNode*, Arc> >::iterator outer_end;
125  std::map<TraceNode*, Arc>::iterator inner_p;
126  std::map<TraceNode*, Arc>::iterator inner_end;
127  outer_end = mTraceNodesToArc.end();
128  for (outer_p = mTraceNodesToArc.begin(); outer_p != outer_end; outer_p++) {
129  std::map<TraceNode*, Arc> innermap = outer_p->second;
130  inner_end = innermap.end();
131  for (inner_p = innermap.begin(); inner_p != inner_end; inner_p++) {
132  mArcVector.push_back(inner_p->second);
133  //std::cout << mArcVector.back() << std::endl;
134  }
135  }
136  //std::cout << mArcVector.size() << std::endl;
137  return mArcVector;
138  }
std::map< TraceNode *, std::map< TraceNode *, Arc > > mTraceNodesToArc
Map of TraceNode pointers to Arc that connects them.
Definition: Trace.hpp:66
ArcVector mArcVector
Vector of all arcs, populated on a getArcs call.
Definition: Trace.hpp:68

+ Here is the caller graph for this function:

TraceNodePtrVector& torc::router::Trace::getBranchPoints ( )
inline

Get trace branch point nodes.

Definition at line 117 of file Trace.hpp.

117  {
118  return mBranchPoints;
119  }
TraceNodePtrVector mBranchPoints
Vector of net branch nodes.
Definition: Trace.hpp:59

+ Here is the caller graph for this function:

TraceNode* torc::router::Trace::getNode ( Tilewire  inTilewire)
inlineprotected

Get a TraceNode based on its owning Tilewire.

Definition at line 336 of file Trace.hpp.

336  {
337  std::map<Tilewire, TraceNode*>::iterator it;
338  it = mTilewireToTraceNode.find(inTilewire);
339  if (it == mTilewireToTraceNode.end()) {
340  return 0;
341  } else {
342  return it->second;
343  }
344  }
std::map< Tilewire, TraceNode * > mTilewireToTraceNode
Map of Tilewires to owning TraceNode.
Definition: Trace.hpp:64

+ Here is the caller graph for this function:

TraceNodePtrVector& torc::router::Trace::getSinks ( )
inline

Get trace sink nodes.

Definition at line 109 of file Trace.hpp.

109  {
110  return mSinks;
111  }
TraceNodePtrVector mSinks
Vector of net sink nodes.
Definition: Trace.hpp:55

+ Here is the caller graph for this function:

TraceNodePtrVector& torc::router::Trace::getSources ( )
inline

Get trace source nodes.

Definition at line 113 of file Trace.hpp.

113  {
114  return mSources;
115  }
TraceNodePtrVector mSources
Vector of net source nodes.
Definition: Trace.hpp:57

+ Here is the caller graph for this function:

void torc::router::Trace::normalizeDepth ( TraceNode inNode)
inlineprotected

Normalize depth of nodes.

Definition at line 270 of file Trace.hpp.

270  {
272  TraceNode::TraceNodePtrList wavefront;
273  TraceNode* node;
274  std::set<Tilewire> nodesVisited;
275 
276  // not needed anymore since we save sources
277  //findTop(parents, inNode);
278 
279  for (unsigned int i = 0; i < parents.size(); i++) {
280  parents[i]->setDepth(0);
281  std::cout << "PARENT " << parents[i]->getTilewire() << std::endl;
282  nodesVisited.insert(parents[i]->getTilewire());
283  for (unsigned int j = 0; j < parents[i]->getNumChildren(); j++) {
284  wavefront.push_back(parents[i]->getChild(j));
285  }
286  }
287  while (wavefront.size() != 0) {
288  node = wavefront.front();
289  wavefront.pop_front();
290 
291  Tilewire tw = node->getTilewire();
292  if (nodesVisited.find(tw) == nodesVisited.end()) {
293  nodesVisited.insert(node->getTilewire());
294  } else {
295  std::cout << "Already visited " << tw << std::endl;
296  }
297 
298  if (node->getNumParents() == 0) {
299  std::cout << "SOURCE NODE" << std::endl;
300  node->setDepth(0);
301  } else {
302  for (unsigned int i = 0; i < node->getNumParents(); i++) {
303  std::cout << "PARENT DEPTH " << node->getParent(i)->getDepth() << std::endl;
304  if (node->getParent(i)->getDepth() + 1 > node->getDepth()) {
305  node->setDepth(node->getParent(i)->getDepth() + 1);
306  }
307  }
308  }
309  if (node->getNumChildren() == 0) {
310  std::cout << "SINK NODE" << std::endl;
311  }
312  for (unsigned int i = 0; i < node->getNumChildren(); i++) {
313  wavefront.push_back(node->getChild(i));
314  }
315  }
316 
317  }
architecture::Tilewire Tilewire
Definition: Trace.hpp:41
std::vector< TraceNode * > TraceNodePtrVector
Vector of TraceNode pointers.
Definition: TraceNode.hpp:57
std::list< TraceNode * > TraceNodePtrList
List of TraceNode pointers.
Definition: TraceNode.hpp:59

+ Here is the call graph for this function:

void torc::router::Trace::traceWorker ( TraceNode inNode,
ETraceMode  inMode 
)
inlineprotected

Recursively traces from the specified TraceNode in the specified mode.

Definition at line 141 of file Trace.hpp.

141  {
142  TraceNodePtrVector activeArcs;
143 
144  //std::cout << "\t## traceWorker ## " << inNode->getTilewire() << std::endl;
145 
146  ArcVector outArcs;
147  ArcVector inArcs;
148  TraceNodePtrVector activeSinks;
149  TraceNodePtrVector activeSources;
150  Tilewire nodeTilewire = inNode->getTilewire();
151 
152  unsigned int childCount = 0;
153  unsigned int parentCount = 0;
154  mDB.expandSegmentSinks(nodeTilewire, outArcs);
155  for (unsigned int i = 0 ; i < outArcs.size(); i++) {
156  if (mArcUsage.isUsed(outArcs[i]))
157  childCount++;
158  }
159  mDB.expandSegmentSources(nodeTilewire, inArcs);
160  for (unsigned int i = 0; i < inArcs.size(); i++) {
161  if (mArcUsage.isUsed(inArcs[i]))
162  parentCount++;
163  }
164  bool isBranch;
165  if (childCount == 0) {
166  mSinks.push_back(inNode);
167  std::cout << "FOUND A SINK NODE: " << nodeTilewire << std::endl;
168  }
169  if (parentCount == 0) {
170  mSources.push_back(inNode);
171  std::cout << "FOUND A SOURCE NODE: " << nodeTilewire << std::endl;
172  }
173  if (childCount > 1 || parentCount > 1) {
174  mBranchPoints.push_back(inNode);
175  std::cout << "FOUND A BRANCH NODE: " << nodeTilewire
176  << " children: " << childCount << " parents: " << parentCount << std::endl;
177  isBranch = true;
178  } else {
179  isBranch = false;
180  }
181  if (childCount == 1 && parentCount == 1) {
182  //std::cout << "NODE: " << inNode->getTilewire() << std::endl;
183  }
184 
185  // mode selection
186  bool traceSinks = inMode != eTraceToSources;
187  bool traceSources = inMode != eTraceToSinks;
188  if (inMode == eTraceToBranch || inMode == eTraceSinglePath) {
189  traceSinks = !isBranch;
190  }
191  if (inMode == eTraceToBranch || inMode == eTraceSinglePath) {
192  traceSources = !isBranch;
193  }
194 
195  // node creation
196  if (traceSinks) { // only trace to sources doesn't look at sinks
197  for (unsigned int i = 0; i < outArcs.size(); i++) {
198  const Tilewire& sinkTilewire = outArcs[i].getSinkTilewire();
199  // if the arc is used we need to check this out
200  if (mArcUsage.isUsed(outArcs[i])) {
201  //std::cout << "\tOUT ARC USED " << outArcs[i] << std::endl;
202  // get the node
203  TraceNode* arcNode = getNode(sinkTilewire);
204  if (arcNode == 0) {
205  // node doesn't exist, create it
206  arcNode = createNode(sinkTilewire);
207  // store it for traversal
208  activeSinks.push_back(arcNode);
209  }
210  if (findArc(inNode, arcNode) == Arc()) {
211  // arc does not exist so add it
212  inNode->addChild(arcNode);
213  arcNode->addParent(inNode);
214  } else {
215  // arc already traversed, don't do it again
216  continue;
217  }
218  // record this arc in the trace
219  mTraceNodesToArc[inNode][arcNode] = outArcs[i];
220  }
221  }
222  }
223  if (traceSources) { // only trace to sinks doesn't look at sources
224  for (unsigned int i = 0; i < inArcs.size(); i++) {
225  const Tilewire& sourceTilewire = inArcs[i].getSourceTilewire();
226  // if the arc is used we need to check this out
227  if (mArcUsage.isUsed(inArcs[i])) {
228  //std::cout << "\tIN ARC USED " << inArcs[i] << std::endl;
229  // get the node
230  TraceNode* arcNode = getNode(sourceTilewire);
231  if (arcNode == 0) {
232  // node doesn't exist, create it
233  arcNode = createNode(sourceTilewire);
234  // store it for traversal
235  activeSources.push_back(arcNode);
236  }
237  if (findArc(arcNode, inNode) == Arc()) {
238  // arc does not exist so add it
239  arcNode->addChild(inNode);
240  inNode->addParent(arcNode);
241  } else {
242  // arc already traversed, don't do it again
243  continue;
244  }
245  // record this arc in the trace
246  mTraceNodesToArc[arcNode][inNode] = inArcs[i];
247  }
248  }
249  }
250 
251  // recursive calls
252  if (traceSinks) {
253  for (unsigned int i = 0; i < activeSinks.size(); i++) {
254  if (inMode == eTraceToBranch)
255  traceWorker(activeSinks[i], eTraceToSinks);
256  else
257  traceWorker(activeSinks[i], inMode);
258  }
259  }
260  if (traceSources) { // only trace to sinks doesn't look at sources
261  for (unsigned int i = 0; i < activeSources.size(); i++) {
262  traceWorker(activeSources[i], inMode);
263  }
264  }
265  }
TraceNode * createNode(Tilewire inTilewire)
Create a TraceNode and update auxiliary structures.
Definition: Trace.hpp:319
void traceWorker(TraceNode *inNode, ETraceMode inMode)
Recursively traces from the specified TraceNode in the specified mode.
Definition: Trace.hpp:141
std::map< TraceNode *, std::map< TraceNode *, Arc > > mTraceNodesToArc
Map of TraceNode pointers to Arc that connects them.
Definition: Trace.hpp:66
architecture::ArcVector ArcVector
Definition: Trace.hpp:44
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
std::vector< TraceNode * > TraceNodePtrVector
Vector of TraceNode pointer.
Definition: TraceNode.hpp:192
TraceNode * getNode(Tilewire inTilewire)
Get a TraceNode based on its owning Tilewire.
Definition: Trace.hpp:336
ArcUsage & mArcUsage
ArcUsage reference.
Definition: Trace.hpp:50
TraceNodePtrVector mBranchPoints
Vector of net branch nodes.
Definition: Trace.hpp:59
TraceNodePtrVector mSources
Vector of net source nodes.
Definition: Trace.hpp:57
architecture::Tilewire Tilewire
Definition: Trace.hpp:41
void expandSegmentSources(const Tilewire &inTilewire, ArcVector &outSources, EExpandDirection inExpandDirection=eExpandDirectionNone, bool inUseTied=true, bool inUseRegular=true, bool inUseIrregular=true, bool inUseRoutethrough=true)
Expands all source arcs for the given tilewire's segment.
Definition: DDB.cpp:336
TraceNodePtrVector mSinks
Vector of net sink nodes.
Definition: Trace.hpp:55
architecture::Arc Arc
Definition: Trace.hpp:42
Arc findArc(TraceNode *source, TraceNode *sink)
Find a traced Arc from the nodes that it connects.
Definition: Trace.hpp:346
DDB & mDB
Database reference.
Definition: Trace.hpp:48
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:

Field Documentation

TraceNodePtrVector torc::router::Trace::mAllNodes
protected

Vector of all TraceNode pointers.

Definition at line 62 of file Trace.hpp.

ArcUsage& torc::router::Trace::mArcUsage
protected

ArcUsage reference.

Definition at line 50 of file Trace.hpp.

ArcVector torc::router::Trace::mArcVector
protected

Vector of all arcs, populated on a getArcs call.

Definition at line 68 of file Trace.hpp.

TraceNodePtrVector torc::router::Trace::mBranchPoints
protected

Vector of net branch nodes.

Definition at line 59 of file Trace.hpp.

DDB& torc::router::Trace::mDB
protected

Database reference.

Definition at line 48 of file Trace.hpp.

TraceNode* torc::router::Trace::mInitialNode
protected

TraceNode representing the starting point for this trace.

Definition at line 53 of file Trace.hpp.

TraceNodePtrVector torc::router::Trace::mSinks
protected

Vector of net sink nodes.

Definition at line 55 of file Trace.hpp.

TraceNodePtrVector torc::router::Trace::mSources
protected

Vector of net source nodes.

Definition at line 57 of file Trace.hpp.

std::map<Tilewire, TraceNode*> torc::router::Trace::mTilewireToTraceNode
protected

Map of Tilewires to owning TraceNode.

Definition at line 64 of file Trace.hpp.

std::map<TraceNode*, std::map<TraceNode*, Arc> > torc::router::Trace::mTraceNodesToArc
protected

Map of TraceNode pointers to Arc that connects them.

Definition at line 66 of file Trace.hpp.


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