Add net driver detection in Dijkstra (just a check for now).

This commit is contained in:
Jean-Paul Chaput 2021-01-13 19:08:00 +01:00
parent 2b0a2c88b7
commit 79e47d1ef2
2 changed files with 66 additions and 9 deletions

View File

@ -19,6 +19,7 @@
#include "hurricane/Error.h"
#include "hurricane/Warning.h"
#include "hurricane/Net.h"
#include "hurricane/Pin.h"
#include "hurricane/RoutingPad.h"
#include "hurricane/Horizontal.h"
#include "hurricane/Vertical.h"
@ -42,6 +43,7 @@ namespace Anabatic {
using Hurricane::Error;
using Hurricane::Warning;
using Hurricane::Component;
using Hurricane::Pin;
using Hurricane::Segment;
using Hurricane::Horizontal;
using Hurricane::Vertical;
@ -1546,7 +1548,6 @@ namespace Anabatic {
cdebug_log(112,0) << "@ frp:" << rp << endl;
rps.push_back( rp );
continue;
}
}
@ -1555,14 +1556,16 @@ namespace Anabatic {
return;
}
uint32_t driverCount = 0;
for ( auto rp : rps ) {
if (not _anabatic->getConfiguration()->selectRpComponent(rp))
cerr << Warning( "Dijktra::load(): %s has no components on grid.", getString(rp).c_str() ) << endl;
cdebug_log(112,0) << "@ rp: " << rp << ", getCenter(): " << rp->getBoundingBox().getCenter() << endl;
Point center = rp->getBoundingBox().getCenter();
GCell* gcell = _anabatic->getGCellUnder( center );
Box bb = rp->getBoundingBox();
Point center = rp->getBoundingBox().getCenter();
GCell* gcell = _anabatic->getGCellUnder( center );
Box bb = rp->getBoundingBox();
bool isDriver = false;
cdebug_log(112,0) << bb.getXMin() << " " << bb.getXMax() << endl;
cdebug_log(112,0) << "center X:" << center.getX() << " gcell Xmax:" << gcell->getXMax() << endl;
@ -1580,6 +1583,29 @@ namespace Anabatic {
continue;
}
Net* rpNet = NULL;
Plug* plug = dynamic_cast<Plug*>( rp->getPlugOccurrence().getEntity() );
if (plug) {
rpNet = plug->getMasterNet();
if (rpNet->getDirection() & Net::Direction::DirOut) {
cdebug_log(112,0) << "Driver/cell: " << rp << endl;
cdebug_log(112,0) << "masterNet: " << rpNet << endl;
++driverCount;
isDriver = true;
}
} else {
Pin* pin = dynamic_cast<Pin*>( rp->getPlugOccurrence().getEntity() );
if (pin) {
rpNet = pin->getNet();
if (rpNet->getDirection() & Net::Direction::DirIn) {
cdebug_log(112,0) << "Driver/pin: " << rp << endl;
cdebug_log(112,0) << "masterNet: " << rpNet << endl;
++driverCount;
isDriver = true;
}
}
}
_searchArea.merge( gcell->getBoundingBox() ); // TO CHANGE
cdebug_log(112,0) << "| Merged search area: " << _searchArea << ", gcell: " << gcell << endl;
@ -1604,6 +1630,8 @@ namespace Anabatic {
vertex->setDegree ( 0 );
vertex->setRpCount ( 0 );
vertex->setFrom ( NULL );
if (isDriver)
vertex->setDriver( true );
vertex->setFrom2 ( NULL);
vertex->unsetFlags ( Vertex::UseFromFrom2 );
@ -1629,6 +1657,17 @@ namespace Anabatic {
rp->getBodyHook()->attach( vcontact->getBodyHook() );
}
if (driverCount == 0) {
cerr << Error( "Diskstra::load(): Net \"%s\" do not have a driver.\n"
, getString(_net->getName()).c_str()
) << endl;
}
if (driverCount > 1) {
cerr << Error( "Diskstra::load(): Net \"%s\" have multiple drivers (%u).\n"
, getString(_net->getName()).c_str(), driverCount
) << endl;
}
if (state and state->isSymmetric() and not state->isSelfSym() and state->isSymMaster()) {
if (state->isSymVertical()) {
if ( (_searchArea.getXMin() < state->getSymAxis())
@ -1805,8 +1844,15 @@ namespace Anabatic {
return;
}
Vertex* firstSource = NULL;
Vertex* firstSource = NULL;
VertexSet drivers;
for ( Vertex* vertex : _targets ) {
if (vertex->isDriver()) drivers.insert( vertex );
}
if (drivers.empty()) drivers = _targets;
#if THIS_IS_DISABLED
if (_mode & Mode::Monotonic) {
if (_targets.size() == 2) {
auto ivertex = _targets.begin();
@ -1823,24 +1869,25 @@ namespace Anabatic {
_mode = Mode::Standart;
}
}
#endif
if (not firstSource) {
// Standart routing.
bool hasDevice = false;
for ( Vertex* ivertex : _targets ) {
if (ivertex->getGCell()->isDevice()) hasDevice = true;
for ( Vertex* vertex : drivers ) {
if (vertex->getGCell()->isDevice()) hasDevice = true;
}
Point areaCenter;
if (hasDevice) areaCenter = _getPonderedPoint();
else areaCenter = _searchArea.getCenter();
auto ivertex = _targets.begin();
auto ivertex = drivers.begin();
firstSource = *ivertex++;
DbU::Unit minDistance = areaCenter.manhattanDistance( firstSource->getCenter() );
for ( ; ivertex != _targets.end() ; ++ivertex ) {
for ( ; ivertex != drivers.end() ; ++ivertex ) {
DbU::Unit distance = areaCenter.manhattanDistance( (*ivertex)->getCenter() );
if (distance < minDistance) {
minDistance = distance;

View File

@ -187,6 +187,7 @@ namespace Anabatic {
, iHorizontal = (1<<7)
, iVertical = (1<<8)
, iSet = (1<<9)
, Driver = (1<<10)
};
public:
static DbU::Unit unreached;
@ -198,6 +199,7 @@ namespace Anabatic {
inline Vertex ( GCell* );
//inline Vertex ( size_t id );
inline ~Vertex ();
inline bool isDriver () const;
inline bool isAnalog () const;
inline bool hasDoneAllRps () const;
inline Contact* hasGContact ( Net* ) const;
@ -218,6 +220,7 @@ namespace Anabatic {
Edge* getFrom () const;
inline Vertex* getPredecessor () const;
inline Vertex* getNeighbor ( Edge* ) const;
inline void setDriver ( bool state );
inline void setDistance ( DbU::Unit );
inline void setStamp ( int );
inline void setConnexId ( int );
@ -331,6 +334,7 @@ namespace Anabatic {
inline Vertex* Vertex::lookup ( GCell* gcell ) { return gcell->getObserver<Vertex>(GCell::Observable::Vertex); }
inline Vertex::~Vertex () { _gcell->setObserver( GCell::Observable::Vertex, NULL ); }
inline bool Vertex::isDriver () const { return _flags & Driver; }
inline bool Vertex::isAnalog () const { return _gcell->isAnalog(); }
inline Box Vertex::getBoundingBox () const { return _gcell->getBoundingBox(); }
inline Edges Vertex::getEdges ( Flags sides ) const { return _gcell->getEdges(sides); }
@ -367,6 +371,12 @@ namespace Anabatic {
return (gcell) ? gcell->getObserver<Vertex>(GCell::Observable::Vertex) : NULL;
}
inline void Vertex::setDriver ( bool state )
{
if (state) _flags |= Driver;
else _flags &= ~Driver;
}
inline bool Vertex::CompareById::operator() ( const Vertex* lhs, const Vertex* rhs ) const
{ return lhs->getId() < rhs->getId(); }