19 #ifndef TORC_ROUTER_NETROUTER_HPP
20 #define TORC_ROUTER_NETROUTER_HPP
32 #include <boost/cstdint.hpp>
33 #include <boost/timer.hpp>
34 #include <boost/unordered_map.hpp>
35 #include <boost/unordered_set.hpp>
36 #include <boost/functional/hash.hpp>
53 typedef std::priority_queue<RouteNode*, std::vector<RouteNode*>,
57 typedef boost::unordered_set<Tilewire, boost::hash<architecture::Tilewire> >
TilewireSet;
125 std::cout <<
"NetRouter does not support multiple sources" << std::endl;
130 TilewireVector::iterator p;
131 TilewireVector::iterator e = net.
sinksEnd();
138 std::cout << net.
getName() <<
": source is INVALID" << std::endl;
143 std::cout <<
"!Source already in use! " << source << std::endl;
147 for (p = sinks.begin(); p != e; p++) {
149 std::cout << net.
getName() <<
": sink is INVALID" << std::endl;
154 std::cout <<
"!Sink already in use! " << *p << std::endl;
162 RouteNodePtrVector::iterator p;
163 RouteNodePtrVector::iterator e;
166 for (p =
mPreRoute.begin(); p != e; p++) {
172 std::cout <<
"DISCARDED in expand function: " << net.
getName() << std::endl;
207 TilewireVector::const_iterator p;
208 TilewireVector::const_iterator e = inSinks.end();
209 for (p = inSinks.begin(); p != e; p++) {
217 mOpen.insert(std::pair<Tilewire, RouteNode*>(inSource, s));
220 for (p = inSinks.begin(); p != e; p++) {
222 RouteNodePtrVector::iterator q;
223 RouteNodePtrVector::iterator f = outRoute.end();
224 for (q = outRoute.begin(); q != f; q++) {
226 mOpen.insert(std::pair<Tilewire, RouteNode*>((*q)->getSinkTilewire(), (*q)));
234 for (q = outRoute.begin(); q != f; q++) {
235 Tilewire tw = (*q)->getSinkTilewire();
245 for (p = inSinks.begin(); p != e; p++) {
253 boost::uint32_t expanded = 0;
254 boost::uint32_t processed = 0;
258 std::cout <<
"ROUTING FAILED!" << std::endl;
265 std::cout <<
"ROUTE LIMIT!" << std::endl;
271 RouteNodePtrMap::iterator pk =
mOpen.find(key);
272 mClosed.insert(std::pair<Tilewire, RouteNode*>(key, n));
281 TilewireVector::iterator p;
296 ArcVector::iterator q;
297 ArcVector::iterator f =
mArcsBuf.end();
298 for (q =
mArcsBuf.begin(); q != f; q++) {
311 if (
mOpen.find(arcSink) !=
mOpen.end())
return;
325 mOpen.insert(std::pair<Tilewire, RouteNode*>(arcSink, node));
332 RouteNodePtrVector::iterator p;
333 RouteNodePtrVector::iterator e;
336 for (p =
mPreRoute.begin(); p != e; p++) {
337 outRoute.push_back(*p);
343 for (p = outRoute.begin(); p != e; p++) {
346 outRoute.push_back(node);
347 if (key == inSource)
return;
349 if (node == 0)
return;
356 RouteNodePtrMap::iterator p;
357 RouteNodePtrMap::iterator e =
mOpen.end();
358 for (p =
mOpen.begin(); p != e; p++) {
delete (*p).second; }
360 for (p =
mClosed.begin(); p != e; p++) {
delete (*p).second; }
362 for (p =
mSkipped.begin(); p != e; p++) {
delete (*p).second; }
375 TilewireVector::iterator e = inSinks.end();
376 for (TilewireVector::iterator p = inSinks.begin(); p != e; p++) {
388 while (arcs.size() == 1) {
390 tempRoute.push_back(node);
392 tempsink = arcs[0].getSourceTilewire();
393 if (tempsink == inSource) {
396 for (
unsigned int i = 0; i < tempRoute.size(); i++) {
397 outRoute.push_back(tempRoute[i]);
412 while (arcs.size() == 1) {
415 outRoute.push_back(node);
417 tempsource = arcs[0].getSinkTilewire();
430 while (arcs.size() == 1) {
433 outRoute.push_back(node);
435 tempsink = arcs[0].getSourceTilewire();
439 return arcs[0].getSinkTilewire();
445 #endif // TORC_ROUTER_NETROUTER_HPP
RouteNodePtrVector mPreRoute
Vector of nodes created during pre-routing.
TilewireConstIterator sinksEnd(void) const
Returns the end constant iterator for sink Tilewires.
double mTotalRouteTime
Total routing time since construction.
boost::uint32_t mStatNets
Number of nets routed since construction.
RouteNodePtrQueue mOrder
Pointer to the heuristic for making routing decisions.
Encapsulation of an arc between two tilewires.
std::vector< Tilewire > TilewireVector
Vector of Tilewire objects.
architecture::WireUsage WireUsage
std::vector< RouteNode * > RouteNodePtrVector
Vector of RouteNode pointers.
RouteNode * getParent() const
Get the node's parent.
void clearContainers()
Delete nodes in containers and clear them.
Device database, including complete wiring and logic support.
boost::uint32_t mStatSinks
Number of net sinks seen since construction.
const string & getName() const
Returns the name of the net.
boost::uint32_t mSearchLimit
Maximum number of nodes to explore before failing.
Encapsulation the design wire usage.
Header for the RouteNode class.
boost::uint32_t mStatExpanded
Number of nodes created from expansion.
virtual void expandSegmentSinks(const Tilewire &inTilewire, ArcVector &outArcs)
Heuristically expand a segment.
void graphSearchFilter(RouteNode *inParent, const Arc &inArc, RouteNodePtrVector &outRoute)
Create a new node and put it into the appropriate structure.
const boost::int32_t getDepth() const
Get the node depth.
TilewireConstIterator sinksBegin(void) const
Returns the begin constant iterator for sink Tilewires.
Header for the BasicRouter class.
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.
architecture::ArcUsage ArcUsage
void useArc(const Arc &inArc)
Marks the arc and all of its source and sink segment wires as used.
architecture::DDB DDB
Imported type names.
Binary predicate for comparing RouteNode pointers based on cost.
std::vector< Arc > ArcVector
Vector of Arc objects.
RouteNodePtrVector & routeNodes()
Returns a reference to the RouteNodePtrVector.
virtual void reorderSinks(const Tilewire &inSource, TilewireVector &inSinks)
Reorder the Sinks based on this heuristic.
const Tilewire & getSinkTilewire() const
Get the sink Tilewire.
bool expandNetTerminals(Tilewire &inSource, TilewireVector &inSinks, RouteNodePtrVector &outRoute)
Move net terminals out into the INT tiles.
NetRouterHeuristicBase * mHeuristic
Pointer to the heuristic for making routing decisions.
const Tilewire & getSinkTilewire(void) const
Returns the sink tilewire.
WireUsage & mWireUsage
WireUsage reference.
void recordPath(RouteNode *node, Tilewire key, Tilewire inSource, RouteNodePtrVector &outRoute)
Add the newly found route to the outRoute vector.
void setCost(boost::int32_t inHeuristicCost)
Set the heuristic node cost.
Header for torc::physical output stream helpers.
boost::unordered_map< Tilewire, RouteNode *, boost::hash< architecture::Tilewire > > RouteNodePtrMap
void graphSearch(const Tilewire &inSource, TilewireVector &inSinks, RouteNodePtrVector &outRoute)
Internal top level route function.
Encapsulation of a device tile and wire pair.
RouteNodePtrMap mSkipped
Collection of nodes skipped due to heuristic constraints.
Encapsulation the design arc usage.
boost::unordered_set< Tilewire, boost::hash< architecture::Tilewire > > TilewireSet
ArcUsage & mArcUsage
Database reference.
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.
void use(const Tilewire &inTilewire)
Marks the specified tilewire as being used.
TilewireConstIterator sourcesBegin(void) const
Returns the begin constant iterator for source Tilewires.
TilewireVector mSegmentBuf
Scratch segment storage.
Tilewire expandSourceTerminal(Tilewire inSource, RouteNodePtrVector &outRoute)
Move the source terminal of a net in the sinkwards direction.
ArcVector mArcsBuf
Scratch arc storage.
void routeNet(RouteNet &net)
Route a net.
Header for the HeuristicBase class.
DDB & mDB
Database reference.
boost::uint32_t mStatSources
Number of net sources seen since construction.
virtual void setSink(const Tilewire &inSink)=0
Set the current routing target.
std::priority_queue< RouteNode *, std::vector< RouteNode * >, RouteNodePtrCostCompare > RouteNodePtrQueue
architecture::Tilewire Tilewire
architecture::ArcVector ArcVector
bool hasOneSource(void) const
Returns true if the net has exactly one source.
An object that holds an arc and path information for routing.
void graphSearchLoop(const Tilewire &inSource, const Tilewire &inSink, RouteNodePtrVector &outRoute)
Routing loop function.
NetRouter(DDB &inDB, NetRouterHeuristicBase *inHeuristic)
Public Constructor.
Provides net routing based on the Nilsson graphsearch algorithm.
RouteNodePtrMap mOpen
Collection of candidate nodes the router can expand.
void release(const Tilewire &inTilewire)
Marks the specified tilewire as being unused.
boost::uint32_t mStatLoopPasses
Number of passes through the main loop since construction.
Provides the interface for net routers.
Abstract class for a net router.
bool testDedicatedPath(Tilewire inSource, Tilewire inSink, RouteNodePtrVector &outRoute)
Test for a dedicated routing path.
Header for the DDB class.
static const Tilewire sInvalid
RouteNodePtrMap mClosed
Collection of nodes that have been expanded.
architecture::TilewireVector TilewireVector
Tilewire expandSinkTerminal(Tilewire inSink, RouteNodePtrVector &outRoute)
Move the sink terminal of a net in the sourcewards direction.
bool isUsed(const Tilewire &inTilewire)
Determines whether the specified tilewire is in use.
void printStats(std::ostream &out)
void expandSegment(const Tilewire &inTilewire, TilewireVector &outTilewires, EExpandDirection inExpandDirection=eExpandDirectionNone)
Expands the given tilewire's segment.
TilewireSet mAuxClosed
Set of Closed Tilewires to avoid issues with bidir resources.
Header for the Net class.
virtual void nodeCost(RouteNode &inNode)=0
Calculate the node cost based on distance to the sink and path length.