diff --git a/anabatic/src/AnabaticEngine.cpp b/anabatic/src/AnabaticEngine.cpp index 27eda78d..da32a645 100644 --- a/anabatic/src/AnabaticEngine.cpp +++ b/anabatic/src/AnabaticEngine.cpp @@ -17,8 +17,10 @@ #include #include #include "hurricane/Error.h" +#include "hurricane/RegularLayer.h" #include "hurricane/Cell.h" #include "hurricane/UpdateSession.h" +#include "crlcore/RoutingGauge.h" #include "anabatic/GCell.h" #include "anabatic/AnabaticEngine.h" @@ -30,8 +32,11 @@ namespace Anabatic { using std::endl; using std::ostringstream; using Hurricane::Error; + using Hurricane::RegularLayer; using Hurricane::Cell; using Hurricane::UpdateSession; + using CRL::RoutingGauge; + using CRL::RoutingLayerGauge; // ------------------------------------------------------------------- @@ -56,9 +61,8 @@ namespace Anabatic { : Super(cell) , _configuration (new ConfigurationConcrete()) , _matrix () - , _southWestGCell(NULL) { - _matrix.setCell( cell, _configuration->getSliceHeight() ); + _matrix.setCell( cell, _configuration->getSliceHeight()*2 ); } @@ -66,12 +70,8 @@ namespace Anabatic { { Super::_postCreate(); - //cdebug.setMinLevel(110); - //cdebug.setMaxLevel(120); - UpdateSession::open(); - _southWestGCell = GCell::create( this ); - + GCell::create( this ); UpdateSession::close(); } @@ -90,6 +90,7 @@ namespace Anabatic { AnabaticEngine::~AnabaticEngine () { + while ( not _gcells.empty() ) (*_gcells.rbegin())->destroy(); delete _configuration; } @@ -107,6 +108,35 @@ namespace Anabatic { { return _configuration; } + int AnabaticEngine::getCapacity ( Interval span, Flags flags ) const + { + int capacity = 0; + Box ab = getCell()->getAbutmentBox(); + RoutingGauge* rg = _configuration->getRoutingGauge(); + + const vector& layerGauges = rg->getLayerGauges(); + for ( size_t depth=0 ; depth <= _configuration->getAllowedDepth() ; ++depth ) { + if (layerGauges[depth]->getType() != Constant::Default) continue; + + if (flags & Flags::Horizontal) { + if (layerGauges[depth]->getDirection() != Constant::Horizontal) continue; + capacity += layerGauges[depth]->getTrackNumber( span.getVMin() - ab.getYMin() + , span.getVMax() - ab.getYMin() ); + //cdebug.log(110) << "Horizontal edge capacity:" << capacity << endl; + } + + if (flags & Flags::Vertical) { + if (layerGauges[depth]->getDirection() != Constant::Vertical) continue; + capacity += layerGauges[depth]->getTrackNumber( span.getVMin() - ab.getXMin() + , span.getVMax() - ab.getXMin() ); + //cdebug.log(110) << "Vertical edge capacity:" << capacity << endl; + } + } + + return capacity; + } + + void AnabaticEngine::_runTest () { cerr << "AnabaticEngine::_runTest() called." << endl; @@ -128,9 +158,9 @@ namespace Anabatic { Record* AnabaticEngine::_getRecord () const { Record* record = Super::_getRecord(); - record->add( getSlot("_configuration" , _configuration ) ); - record->add( getSlot("_southWestGCell", _southWestGCell) ); - record->add( getSlot("_matrix" , &_matrix ) ); + record->add( getSlot("_configuration", _configuration) ); + record->add( getSlot("_gcells" , &_gcells ) ); + record->add( getSlot("_matrix" , &_matrix ) ); return record; } diff --git a/anabatic/src/Configuration.cpp b/anabatic/src/Configuration.cpp index 847621c7..79997b7b 100644 --- a/anabatic/src/Configuration.cpp +++ b/anabatic/src/Configuration.cpp @@ -71,6 +71,8 @@ namespace Anabatic { , _rg (NULL) , _extensionCaps () , _allowedDepth (0) + , _edgeLength (DbU::fromLambda(Cfg::getParamInt("anabatic.edgeLength",24)->asInt())) + , _edgeWidth (DbU::fromLambda(Cfg::getParamInt("anabatic.edgeWidth" , 4)->asInt())) { if (cg == NULL) cg = AllianceFramework::get()->getCellGauge(); if (rg == NULL) rg = AllianceFramework::get()->getRoutingGauge(); @@ -266,6 +268,15 @@ namespace Anabatic { } + DbU::Unit ConfigurationConcrete::getEdgeLength () const + { return _edgeLength; } + + + DbU::Unit ConfigurationConcrete::getEdgeWidth () const + { return _edgeWidth; } + + + void ConfigurationConcrete::print ( Cell* cell ) const { string topLayerName = "UNKOWN"; diff --git a/anabatic/src/Edge.cpp b/anabatic/src/Edge.cpp index da775b93..56590f14 100644 --- a/anabatic/src/Edge.cpp +++ b/anabatic/src/Edge.cpp @@ -18,6 +18,7 @@ #include "hurricane/Error.h" #include "anabatic/Edge.h" #include "anabatic/GCell.h" +#include "anabatic/AnabaticEngine.h" namespace Anabatic { @@ -84,8 +85,8 @@ namespace Anabatic { edge->_postCreate(); cdebug.log(110,1) << "Edge::create(): " << (void*)edge << ":" << edge << endl; - cdebug.log(110) << "source:" << edge->getSource() << endl; - cdebug.log(110) << "target:" << edge->getTarget() << endl; + cdebug.log(110) << "source:" << (void*)source << ":" << edge->getSource() << endl; + cdebug.log(110) << "target:" << (void*)target << ":" << edge->getTarget() << endl; cdebug.tabw(110,-1); return edge; } @@ -111,6 +112,10 @@ namespace Anabatic { } + AnabaticEngine* Edge::getAnabatic () const + { return (_source) ? _source->getAnabatic() : NULL; } + + DbU::Unit Edge::getAxisMin () const { if (_flags.isset(Flags::Vertical)) @@ -170,9 +175,11 @@ namespace Anabatic { void Edge::_revalidate () { - _axis = getSide().getCenter(); - _flags.reset( Flags::Invalidated ); + Interval side = getSide(); + _axis = side.getCenter(); + _capacity = getAnabatic()->getCapacity( side.inflate(0,-1), _flags ); + _flags.reset( Flags::Invalidated ); cdebug.log(110) << "Edge::_revalidate() " << this << endl; } @@ -183,8 +190,8 @@ namespace Anabatic { Box Edge::getBoundingBox () const { - static DbU::Unit halfThickness = DbU::fromLambda( 2.0 ); - static DbU::Unit halfLength = DbU::fromLambda( 12.0 ); + static DbU::Unit halfThickness = getAnabatic()->getConfiguration()->getEdgeWidth () / 2; + static DbU::Unit halfLength = getAnabatic()->getConfiguration()->getEdgeLength() / 2; if (_flags.isset(Flags::Horizontal)) return Box( _target->getXMin() - halfLength, _axis - halfThickness diff --git a/anabatic/src/GCell.cpp b/anabatic/src/GCell.cpp index e6baa7e9..5ee25582 100644 --- a/anabatic/src/GCell.cpp +++ b/anabatic/src/GCell.cpp @@ -45,6 +45,7 @@ namespace Anabatic { void GCell::_postCreate () { Super::_postCreate(); + _anabatic->_add( this ); } @@ -81,6 +82,7 @@ namespace Anabatic { for ( Edge* edge : _southEdges ) edge->destroy(); for ( Edge* edge : _northEdges ) edge->destroy(); + _anabatic->_remove( this ); Super::_preDestroy(); } @@ -159,6 +161,69 @@ namespace Anabatic { } + GCell* GCell::getWest ( DbU::Unit y ) const + { + for ( Edge* edge : _westEdges ) { + GCell* side = edge->getOpposite(this); + if (y < side->getYMax()) return side; + } + return NULL; + } + + + GCell* GCell::getEast ( DbU::Unit y ) const + { + for ( Edge* edge : _eastEdges ) { + GCell* side = edge->getOpposite(this); + cerr << "east @Y: " << DbU::getValueString(y) << " " << side << endl; + if (y < side->getYMax()) return side; + } + return NULL; + } + + + GCell* GCell::getSouth ( DbU::Unit x ) const + { + for ( Edge* edge : _southEdges ) { + GCell* side = edge->getOpposite(this); + if (x < side->getXMax()) return side; + } + return NULL; + } + + + GCell* GCell::getNorth ( DbU::Unit x ) const + { + for ( Edge* edge : _northEdges ) { + GCell* side = edge->getOpposite(this); + if (x < side->getXMax()) return side; + } + return NULL; + } + + + GCell* GCell::getUnder ( DbU::Unit x, DbU::Unit y ) const + { + const GCell* current = this; + + while ( current ) { + cerr << "current:" << current << endl; + if (not current->isFlat() and current->getBoundingBox().contains(x,y)) break; + + if (x >= current->getXMax()) { current = current->getEast (); continue; } + if (y >= current->getYMax()) { current = current->getNorth(); continue; } + + cerr << Error( "GCell::getUnder(): No GCell under (%s,%s), this must *never* happen." + , DbU::getValueString(x).c_str() + , DbU::getValueString(y).c_str() + ) << endl; + current = NULL; break; + } + + return const_cast( current ); + } + + Box GCell::getBorder ( const GCell* s, const GCell* t ) { Flags flags = Flags::NoFlags; @@ -203,6 +268,7 @@ namespace Anabatic { ); GCell* chunk = _create( x, getYMin() ); + cdebug.log(110) << "New chunk:" << chunk << endl; _moveEdges( chunk, 0, Flags::EastSide|Flags::MoveSide ); Edge::create( this, chunk, Flags::Horizontal ); @@ -254,6 +320,7 @@ namespace Anabatic { ); GCell* chunk = _create( getXMin(), y ); + cdebug.log(110) << "New chunk:" << chunk << endl; _moveEdges( chunk, 0, Flags::NorthSide|Flags::MoveSide ); Edge::create( this, chunk, Flags::Vertical ); @@ -339,6 +406,11 @@ namespace Anabatic { cdebug.log(110,1) << "South side." << endl; for ( Edge* edge : _southEdges ) edge->revalidate(); cdebug.tabw(110,-1); cdebug.log(110,1) << "North side." << endl; for ( Edge* edge : _northEdges ) edge->revalidate(); cdebug.tabw(110,-1); + if (_xmin > getXMax()+1) + cerr << Error( "GCell::_revalidate(): %s, X Min is greater than Max.", getString(this).c_str() ); + if (_ymin > getYMax()+1) + cerr << Error( "GCell::_revalidate(): %s, Y Min is greater than Max.", getString(this).c_str() ); + _anabatic->_updateLookup( this ); cdebug.tabw(110,-1); } @@ -357,8 +429,7 @@ namespace Anabatic { if (iclear < _southEdges.size()) { for ( size_t iedge=ibegin ; (iedge < _southEdges.size()) ; ++iedge ) { - if (flags & Flags::MoveSide) _southEdges[iedge]->_setSource( dest ); - else _southEdges[iedge]->_setTarget( dest ); + _southEdges[iedge]->_setTarget( dest ); dest->_southEdges.push_back( _southEdges[iedge] ); } _southEdges.resize( iclear ); @@ -378,8 +449,7 @@ namespace Anabatic { if (iclear < _northEdges.size()) { for ( size_t iedge=ibegin ; (iedge < _northEdges.size()) ; ++iedge ) { - if (flags & Flags::MoveSide) _northEdges[iedge]->_setTarget( dest ); - else _northEdges[iedge]->_setSource( dest ); + _northEdges[iedge]->_setSource( dest ); dest->_northEdges.push_back( _northEdges[iedge] ); } _northEdges.resize( iclear ); @@ -399,8 +469,7 @@ namespace Anabatic { if (iclear < _westEdges.size()) { for ( size_t iedge=ibegin ; (iedge < _westEdges.size()) ; ++iedge ) { - if (flags & Flags::MoveSide) _westEdges[iedge]->_setSource( dest ); - else _westEdges[iedge]->_setTarget( dest ); + _westEdges[iedge]->_setTarget( dest ); dest->_westEdges.push_back( _westEdges[iedge] ); } _westEdges.resize( iclear ); @@ -420,8 +489,7 @@ namespace Anabatic { if (iclear < _eastEdges.size()) { for ( size_t iedge=ibegin ; (iedge < _eastEdges.size()) ; ++iedge ) { - if (flags & Flags::MoveSide) _eastEdges[iedge]->_setTarget( dest ); - else _eastEdges[iedge]->_setSource( dest ); + _eastEdges[iedge]->_setSource( dest ); dest->_eastEdges.push_back( _eastEdges[iedge] ); } _eastEdges.resize( iclear ); @@ -446,7 +514,7 @@ namespace Anabatic { Box GCell::getBoundingBox () const { - return Box( getXMin(), getYMin(), getXMax(), getYMax() ); + return Box( getXMin(), getYMin(), getXMax(1), getYMax(1) ); } diff --git a/anabatic/src/GraphicAnabaticEngine.cpp b/anabatic/src/GraphicAnabaticEngine.cpp index ddc037ab..ef3861bf 100644 --- a/anabatic/src/GraphicAnabaticEngine.cpp +++ b/anabatic/src/GraphicAnabaticEngine.cpp @@ -51,6 +51,7 @@ namespace Anabatic { using Hurricane::Graphics; using Hurricane::ColorScale; using Hurricane::DisplayStyle; + using Hurricane::DrawingStyle; using Hurricane::ControllerWidget; using Hurricane::ExceptionWidget; using CRL::Catalog; @@ -78,8 +79,8 @@ namespace Anabatic { QPainter& painter = widget->getPainter(); - painter.setPen ( Graphics::getPen ("gcell",widget->getDarkening()) ); - painter.setBrush( Graphics::getBrush("gcell",widget->getDarkening()) ); + painter.setPen ( Graphics::getPen ("Anabatic::GCell",widget->getDarkening()) ); + painter.setBrush( Graphics::getBrush("Anabatic::GCell",widget->getDarkening()) ); painter.drawRect( widget->dbuToScreenRect(gcell->getBoundingBox()) ); } @@ -100,6 +101,7 @@ namespace Anabatic { const Edge* edge = static_cast(go); if (edge) { + Box bb = edge->getBoundingBox(); unsigned int occupancy = 255; if (edge->getRealOccupancy() < edge->getCapacity()) occupancy = (unsigned int)( 255.0 * ( (float)edge->getRealOccupancy() / (float)edge->getCapacity() ) ); @@ -116,7 +118,30 @@ namespace Anabatic { painter.setPen( Qt::NoPen ); painter.setBrush( brush ); - painter.drawRect( widget->dbuToScreenRect(edge->getBoundingBox(), false) ); + painter.drawRect( widget->dbuToScreenRect( bb, false) ); + + QString text = QString("%1/%2").arg(edge->getRealOccupancy()).arg(edge->getCapacity()); + QColor color ( Qt::white ); + QFont font = Graphics::getFixedFont( QFont::Bold ); + painter.setPen (DisplayStyle::darken(color,widget->getDarkening())); + painter.setFont(font); + + if (edge->isVertical()) { + painter.save (); + painter.translate( widget->dbuToScreenPoint(bb.getXMin(), bb.getYMin()) ); + painter.rotate ( -90 ); + painter.drawText (QRect( 0 + , 0 + , widget->dbuToScreenLength(bb.getHeight()) + , widget->dbuToScreenLength(bb.getWidth ())) + , text + , QTextOption(Qt::AlignCenter) + ); + painter.restore (); + } else + painter.drawText( widget->dbuToScreenRect(bb,false ), text, QTextOption(Qt::AlignCenter) ); + + painter.setPen( Qt::NoPen ); } } @@ -159,40 +184,51 @@ namespace Anabatic { if (_viewer) _viewer->emitCellAboutToChange(); AnabaticEngine* engine = getForFramework( CreateEngine ); +#define TEST_2 1 + +#ifdef TEST_1 engine->getSouthWestGCell()->doGrid(); - // GCell* row0 = getSouthWestGCell(); - // DbU::Unit xcorner = getCell()->getAbutmentBox().getXMin(); - // DbU::Unit ycorner = getCell()->getAbutmentBox().getYMin(); + Point position ( DbU::fromLambda(100.0), DbU::fromLambda(100.0) ); + GCell* gcell = engine->getGCellUnder( position ); - // cdebug.log(119,1) << "row0: " << row0 << endl; + cerr << "Gcell under:" << position << " is " << gcell << endl; +#endif - // GCell* row1 = row0->hcut( ycorner+DbU::fromLambda(50.0) ); - // cdebug.tabw(119,-1); - // cdebug.log(119,1) << "row1: " << row1 << endl; +#ifdef TEST_2 + GCell* row0 = engine->getSouthWestGCell(); + DbU::Unit xcorner = getCell()->getAbutmentBox().getXMin(); + DbU::Unit ycorner = getCell()->getAbutmentBox().getYMin(); - // GCell* row2 = row1->hcut( ycorner+DbU::fromLambda(2*50.0) ); - // cdebug.tabw(119,-1); - // cdebug.log(119,1) << "row2: " << row2 << endl; + cdebug.log(119,1) << "row0: " << row0 << endl; - // row0 = row0->vcut( xcorner+DbU::fromLambda(50.0) ); - // cdebug.tabw(119,-1); - // cdebug.log(119,1) << "row0+1: " << row0 << endl; + GCell* row1 = row0->hcut( ycorner+DbU::fromLambda(50.0) ); + cdebug.tabw(119,-1); + cdebug.log(119,1) << "row1: " << row1 << endl; - // row0 = row0->vcut( xcorner+DbU::fromLambda(3*50.0) ); - // cdebug.tabw(119,-1); - // cdebug.log(119,1) << "row0+2: " << row0 << endl; + GCell* row2 = row1->hcut( ycorner+DbU::fromLambda(2*50.0) ); + cdebug.tabw(119,-1); + cdebug.log(119,1) << "row2: " << row2 << endl; - // row0 = row0->vcut( xcorner+DbU::fromLambda(5*50.0) ); - // cdebug.tabw(119,-1); - // cdebug.log(119,1) << "row0+3: " << row0 << endl; + row0 = row0->vcut( xcorner+DbU::fromLambda(50.0) ); + cdebug.tabw(119,-1); + cdebug.log(119,1) << "row0+1: " << row0 << endl; + + row0 = row0->vcut( xcorner+DbU::fromLambda(3*50.0) ); + cdebug.tabw(119,-1); + cdebug.log(119,1) << "row0+2: " << row0 << endl; + + row0 = row0->vcut( xcorner+DbU::fromLambda(5*50.0) ); + cdebug.tabw(119,-1); + cdebug.log(119,1) << "row0+3: " << row0 << endl; - // row1 = row1->vcut( xcorner+DbU::fromLambda(2*50.0) ); - // cdebug.tabw(119,-1); - // cdebug.log(119,1) << "row1+1: " << row1 << endl; + row1 = row1->vcut( xcorner+DbU::fromLambda(2*50.0) ); + cdebug.tabw(119,-1); + cdebug.log(119,1) << "row1+1: " << row1 << endl; - // cdebug.tabw(119,-1); + cdebug.tabw(119,-1); +#endif // gcell = gcell->hcut( ycut+DbU::fromLambda(50.0) ); // cerr << "New GCell: " << gcell << endl; @@ -205,7 +241,7 @@ namespace Anabatic { // cdebug.tabw(119,-2); // } - // if (_viewer) _viewer->emitCellChanged(); + if (_viewer) _viewer->emitCellChanged(); } diff --git a/anabatic/src/Matrix.cpp b/anabatic/src/Matrix.cpp index 5e40d90b..a9dccdbc 100644 --- a/anabatic/src/Matrix.cpp +++ b/anabatic/src/Matrix.cpp @@ -66,9 +66,15 @@ namespace Anabatic { } + GCell* Matrix::getUnder ( DbU::Unit x, DbU::Unit y ) const + { int index = xy2index(x,y); return (index < 0) ? NULL : _gcells[index]->getUnder(x,y); } + + void Matrix::updateLookup ( GCell* gcell ) { - cdebug.log(110,1) << "Matrix::updateLookup(): " << gcell << endl; + //cdebug.log(110,1) << "Matrix::updateLookup(): " << gcell << endl; + + if (gcell->isFlat()) return; Box gcellBb = gcell->getBoundingBox(); Box updateArea = _area.getIntersection( gcellBb ); @@ -80,22 +86,22 @@ namespace Anabatic { ) << endl; } - Index indexMin = Index( this, updateArea.getXMin() , updateArea.getYMin() ); - Index indexMax = Index( this, updateArea.getXMax()-1, updateArea.getYMax()-1 ); + Index indexMin = Index( this, updateArea.getXMin(), updateArea.getYMin() ); + Index indexMax = Index( this, updateArea.getXMax(), updateArea.getYMax() ); int xspan = indexMax.i() - indexMin.i(); - cdebug.log(110) << "indexMin:" << indexMin << endl; - cdebug.log(110) << "indexMax:" << indexMax << endl; + //cdebug.log(110) << "indexMin:" << indexMin << endl; + //cdebug.log(110) << "indexMax:" << indexMax << endl; int index = indexMin.index(); while ( index <= indexMax.index() ) { - _gcells[index] = gcell; + if (updateArea.contains(getGridPoint(index))) _gcells[index] = gcell; if (index <= indexMax.j()) ++index; else index += _imax - xspan; } - cdebug.tabw(110,-1); + //cdebug.tabw(110,-1); } diff --git a/anabatic/src/anabatic/AnabaticEngine.h b/anabatic/src/anabatic/AnabaticEngine.h index 31c0268d..e633d076 100644 --- a/anabatic/src/anabatic/AnabaticEngine.h +++ b/anabatic/src/anabatic/AnabaticEngine.h @@ -29,6 +29,7 @@ namespace Hurricane { #include "crlcore/ToolEngine.h" #include "anabatic/Configuration.h" #include "anabatic/Matrix.h" +#include "anabatic/GCell.h" namespace Anabatic { @@ -36,12 +37,11 @@ namespace Anabatic { using std::string; using Hurricane::Name; using Hurricane::Record; + using Hurricane::Interval; using Hurricane::Cell; using Hurricane::CellViewer; using CRL::ToolEngine; - class GCell; - class AnabaticEngine : public ToolEngine { public: @@ -55,6 +55,11 @@ namespace Anabatic { inline CellViewer* getViewer () const; inline void setViewer ( CellViewer* ); inline GCell* getSouthWestGCell () const; + inline GCell* getGCellUnder ( DbU::Unit x, DbU::Unit y ) const; + inline GCell* getGCellUnder ( Point ) const; + int getCapacity ( Interval, Flags ) const; + inline void _add ( GCell* ); + inline void _remove ( GCell* ); inline void _updateLookup ( GCell* ); void _runTest (); // Inspector support. @@ -73,14 +78,18 @@ namespace Anabatic { static Name _toolName; Configuration* _configuration; Matrix _matrix; - GCell* _southWestGCell; + GCellSet _gcells; CellViewer* _viewer; }; inline CellViewer* AnabaticEngine::getViewer () const { return _viewer; } inline void AnabaticEngine::setViewer ( CellViewer* viewer ) { _viewer=viewer; } - inline GCell* AnabaticEngine::getSouthWestGCell () const { return _southWestGCell; } + inline GCell* AnabaticEngine::getSouthWestGCell () const { return *(_gcells.begin()); } + inline GCell* AnabaticEngine::getGCellUnder ( DbU::Unit x, DbU::Unit y ) const { return _matrix.getUnder(x,y); } + inline GCell* AnabaticEngine::getGCellUnder ( Point p ) const { return _matrix.getUnder(p); } + inline void AnabaticEngine::_add ( GCell* gcell ) { _gcells.insert(gcell); } + inline void AnabaticEngine::_remove ( GCell* gcell ) { _gcells.erase(gcell); } inline void AnabaticEngine::_updateLookup ( GCell* gcell ) { _matrix.updateLookup(gcell); } diff --git a/anabatic/src/anabatic/Configuration.h b/anabatic/src/anabatic/Configuration.h index f9479de2..62fb0e47 100644 --- a/anabatic/src/anabatic/Configuration.h +++ b/anabatic/src/anabatic/Configuration.h @@ -81,6 +81,8 @@ namespace Anabatic { virtual DbU::Unit getExtensionCap ( const Layer* ) const = 0; virtual Flags getDirection ( const Layer* ) const = 0; virtual void setAllowedDepth ( size_t ) = 0; + virtual DbU::Unit getEdgeLength () const = 0; + virtual DbU::Unit getEdgeWidth () const = 0; virtual void print ( Cell* ) const = 0; virtual Record* _getRecord () const = 0; virtual string _getString () const = 0; @@ -129,6 +131,8 @@ namespace Anabatic { virtual DbU::Unit getExtensionCap ( const Layer* ) const; virtual Flags getDirection ( const Layer* ) const; virtual void setAllowedDepth ( size_t ); + virtual DbU::Unit getEdgeLength () const; + virtual DbU::Unit getEdgeWidth () const; virtual void print ( Cell* ) const; virtual Record* _getRecord () const; virtual string _getString () const; @@ -142,6 +146,8 @@ namespace Anabatic { RoutingGauge* _rg; std::vector _extensionCaps; size_t _allowedDepth; + DbU::Unit _edgeLength; + DbU::Unit _edgeWidth; private: ConfigurationConcrete ( const ConfigurationConcrete& ); ConfigurationConcrete& operator= ( const ConfigurationConcrete& ); diff --git a/anabatic/src/anabatic/Edge.h b/anabatic/src/anabatic/Edge.h index 108180e9..e16a3958 100644 --- a/anabatic/src/anabatic/Edge.h +++ b/anabatic/src/anabatic/Edge.h @@ -37,38 +37,42 @@ namespace Anabatic { using Hurricane::ExtensionGo; class GCell; + class AnabaticEngine; class Edge : public ExtensionGo { public: typedef ExtensionGo Super; public: - static Edge* create ( GCell* source, GCell* target, Flags flags=Flags::NoFlags ); - virtual void destroy (); - public: - inline unsigned int getCapacity () const; - inline unsigned int getRealOccupancy () const; - inline unsigned int getEstimateOccupancy () const; - inline GCell* getSource () const; - inline GCell* getTarget () const; - GCell* getOpposite ( const GCell* ) const; - inline DbU::Unit getAxis () const; - DbU::Unit getAxisMin () const; - Interval getSide () const; - inline const Flags& flags () const; - inline Flags& flags (); - inline void invalidate (); - inline void revalidate () const; - void _setSource ( GCell* ); - void _setTarget ( GCell* ); - private: - void _revalidate (); - public: - // ExtensionGo support. - inline const Name& staticGetName (); - virtual const Name& getName () const; - virtual void translate ( const DbU::Unit&, const DbU::Unit& ); - virtual Box getBoundingBox () const; + static Edge* create ( GCell* source, GCell* target, Flags flags=Flags::NoFlags ); + virtual void destroy (); + public: + inline bool isVertical () const; + inline bool isHorizontal () const; + inline unsigned int getCapacity () const; + inline unsigned int getRealOccupancy () const; + inline unsigned int getEstimateOccupancy () const; + inline GCell* getSource () const; + inline GCell* getTarget () const; + GCell* getOpposite ( const GCell* ) const; + AnabaticEngine* getAnabatic () const; + inline DbU::Unit getAxis () const; + DbU::Unit getAxisMin () const; + Interval getSide () const; + inline const Flags& flags () const; + inline Flags& flags (); + inline void invalidate (); + inline void revalidate () const; + void _setSource ( GCell* ); + void _setTarget ( GCell* ); + private: + void _revalidate (); + public: + // ExtensionGo support. + inline const Name& staticGetName (); + virtual const Name& getName () const; + virtual void translate ( const DbU::Unit&, const DbU::Unit& ); + virtual Box getBoundingBox () const; public: // Inspector support. virtual string _getTypeName () const; @@ -95,6 +99,8 @@ namespace Anabatic { inline const Name& Edge::staticGetName () { return _extensionName; } + inline bool Edge::isVertical () const { return _flags.isset(Flags::Vertical); } + inline bool Edge::isHorizontal () const { return _flags.isset(Flags::Horizontal); } inline unsigned int Edge::getCapacity () const { return _capacity; } inline unsigned int Edge::getRealOccupancy () const { return _realOccupancy; } inline unsigned int Edge::getEstimateOccupancy () const { return _estimateOccupancy; } diff --git a/anabatic/src/anabatic/GCell.h b/anabatic/src/anabatic/GCell.h index b921a104..93fb0459 100644 --- a/anabatic/src/anabatic/GCell.h +++ b/anabatic/src/anabatic/GCell.h @@ -19,6 +19,7 @@ #include #include +#include #include "hurricane/Name.h" #include "hurricane/Box.h" #include "hurricane/Cell.h" @@ -36,11 +37,15 @@ namespace Anabatic { using Hurricane::Point; using Hurricane::Interval; using Hurricane::Box; + using Hurricane::Entity; using Hurricane::Cell; class AnabaticEngine; +// ------------------------------------------------------------------- +// Class : "GCell". + class GCell : public ExtensionGo { public: typedef ExtensionGo Super; @@ -50,13 +55,25 @@ namespace Anabatic { static GCell* create ( AnabaticEngine* ); virtual void destroy (); public: + inline bool isHFlat () const; + inline bool isVFlat () const; + inline bool isFlat () const; inline AnabaticEngine* getAnabatic () const; inline DbU::Unit getXMin () const; inline DbU::Unit getYMin () const; - inline DbU::Unit getXMax () const; - inline DbU::Unit getYMax () const; + inline DbU::Unit getXMax ( int shrink=0 ) const; + inline DbU::Unit getYMax ( int shrink=0 ) const; inline Interval getSide ( Flags direction ) const; inline Point getCenter () const; + inline GCell* getWest () const; + inline GCell* getEast () const; + inline GCell* getSouth () const; + inline GCell* getNorth () const; + GCell* getWest ( DbU::Unit y ) const; + GCell* getEast ( DbU::Unit y ) const; + GCell* getSouth ( DbU::Unit x ) const; + GCell* getNorth ( DbU::Unit x ) const; + GCell* getUnder ( DbU::Unit x, DbU::Unit y ) const; GCell* hcut ( DbU::Unit y ); GCell* vcut ( DbU::Unit x ); bool doGrid (); @@ -100,19 +117,26 @@ namespace Anabatic { }; - inline AnabaticEngine* GCell::getAnabatic () const { return _anabatic; } - inline DbU::Unit GCell::getXMin () const { return _xmin; } - inline DbU::Unit GCell::getYMin () const { return _ymin; } - inline const Flags& GCell::flags () const { return _flags; } - inline Flags& GCell::flags () { return _flags; } + inline bool GCell::isHFlat () const { return getYMin() == getYMax(); } + inline bool GCell::isVFlat () const { return getXMin() == getXMax(); } + inline bool GCell::isFlat () const { return isHFlat() or isVFlat(); } + inline AnabaticEngine* GCell::getAnabatic () const { return _anabatic; } + inline DbU::Unit GCell::getXMin () const { return _xmin; } + inline DbU::Unit GCell::getYMin () const { return _ymin; } + inline GCell* GCell::getWest () const { return _westEdges.empty() ? NULL : _westEdges[0]->getOpposite(this); } + inline GCell* GCell::getEast () const { return _eastEdges.empty() ? NULL : _eastEdges[0]->getOpposite(this); } + inline GCell* GCell::getSouth () const { return _southEdges.empty() ? NULL : _southEdges[0]->getOpposite(this); } + inline GCell* GCell::getNorth () const { return _northEdges.empty() ? NULL : _northEdges[0]->getOpposite(this); } + inline const Flags& GCell::flags () const { return _flags; } + inline Flags& GCell::flags () { return _flags; } - inline DbU::Unit GCell::getXMax () const - { return _eastEdges.empty() ? getCell()->getAbutmentBox().getXMax() - : _eastEdges[0]->getOpposite(this)->getXMin(); } + inline DbU::Unit GCell::getXMax ( int shrink ) const + { return _eastEdges.empty() ? getCell()->getAbutmentBox().getXMax() - shrink + : _eastEdges[0]->getOpposite(this)->getXMin() - shrink; } - inline DbU::Unit GCell::getYMax () const - { return _northEdges.empty() ? getCell()->getAbutmentBox().getYMax() - : _northEdges[0]->getOpposite(this)->getYMin(); } + inline DbU::Unit GCell::getYMax ( int shrink ) const + { return _northEdges.empty() ? getCell()->getAbutmentBox().getYMax() - shrink + : _northEdges[0]->getOpposite(this)->getYMin() - shrink; } inline Point GCell::getCenter () const { return Point( (getXMin()+getXMax())/2, (getYMin()+getYMax())/2); } @@ -124,6 +148,12 @@ namespace Anabatic { } +// ------------------------------------------------------------------- +// Class : "GCellSet". + + typedef std::set< GCell*, Entity::CompareById > GCellSet; + + } // Anabatic namespace. diff --git a/anabatic/src/anabatic/Matrix.h b/anabatic/src/anabatic/Matrix.h index 4670bef2..b6357c27 100644 --- a/anabatic/src/anabatic/Matrix.h +++ b/anabatic/src/anabatic/Matrix.h @@ -68,6 +68,9 @@ namespace Anabatic { ~Matrix (); inline Box getArea () const; inline DbU::Unit getSide () const; + inline Point getGridPoint ( int i, int j ) const; + inline Point getGridPoint ( int index ) const; + inline Point getGridPoint ( const Index& ) const; inline int getIMax () const; inline int getJMax () const; inline int index2i ( int ) const; @@ -81,7 +84,7 @@ namespace Anabatic { inline Index& east ( Index& ) const; inline Index& south ( Index& ) const; inline Index& north ( Index& ) const; - inline GCell* getUnder ( DbU::Unit x, DbU::Unit y ) const; + GCell* getUnder ( DbU::Unit x, DbU::Unit y ) const; inline GCell* getUnder ( Point ) const; void setCell ( Cell*, DbU::Unit side ); void updateLookup ( GCell* ); @@ -169,12 +172,17 @@ namespace Anabatic { return index; } - inline GCell* Matrix::getUnder ( DbU::Unit x, DbU::Unit y ) const - { int index = xy2index(x,y); return (index < 0) ? NULL : _gcells[index]; } - inline GCell* Matrix::getUnder ( Point p ) const { return getUnder( p.getX(), p.getY() ); } + inline Point Matrix::getGridPoint ( int i, int j ) const + { return Point( _area.getXMin() + _side*i, _area.getYMin() + _side*j ); } + + inline Point Matrix::getGridPoint ( int index ) const + { return getGridPoint( index2i(index), index2j(index) ); } + + inline Point Matrix::getGridPoint ( const Index& index ) const + { return getGridPoint( index.i(), index.j() ); } // Matrix::Index inline functions. diff --git a/crlcore/etc/cmos/kite.conf b/crlcore/etc/cmos/kite.conf index 7868c088..bc1b0b05 100644 --- a/crlcore/etc/cmos/kite.conf +++ b/crlcore/etc/cmos/kite.conf @@ -20,6 +20,9 @@ parametersTable = \ , ("kite.localRipupLimit" ,TypeInt ,9 , { 'min':1 } ) , ("kite.globalRipupLimit" ,TypeInt ,5 , { 'min':1 } ) , ("kite.longGlobalRipupLimit" ,TypeInt ,5 , { 'min':1 } ) + # Anabatic parameters are temporarily hosted here. + , ("anabatic.edgeLength" ,TypeInt ,24 ) + , ("anabatic.edgeWidth" ,TypeInt ,4 ) ) diff --git a/crlcore/etc/common/display.conf b/crlcore/etc/common/display.conf index 2fba8d12..a44e6fc5 100644 --- a/crlcore/etc/common/display.conf +++ b/crlcore/etc/common/display.conf @@ -84,7 +84,9 @@ stylesTable = \ , (Drawing, 'gmetalh' , { 'color':'128,255,200', 'pattern':'light_antihash0.8', 'border':1 }) , (Drawing, 'gmetalv' , { 'color':'200,200,255', 'pattern':'light_antihash1.8', 'border':1 }) , (Drawing, 'gcut' , { 'color':'255,255,190', 'border':1 }) - , (Drawing, 'gcell' , { 'color':'255,255,190', 'pattern':'0000000000000000', 'border':4 }) + , (Drawing, 'Anabatic::Edge' , { 'color':'255,255,190', 'pattern':'0000000000000000', 'threshold':0.80*scale, 'border':4 }) + , (Drawing, 'Anabatic::GCell', { 'color':'255,0,0', 'pattern':'0000000000000000', 'threshold':0.80*scale, 'border':4 }) + #, (Drawing, 'Anabatic::GCell', { 'color':'255,255,190', 'pattern':'0000000000000000', 'threshold':0.80*scale, 'border':4 }) ) # ---------------------------------------------------------------------- @@ -190,7 +192,8 @@ stylesTable = \ , (Drawing, 'gmetalh' , { 'color':'128,255,200', 'pattern':'antislash2.32' , 'border':1 }) , (Drawing, 'gmetalv' , { 'color':'200,200,255', 'pattern':'light_antihash1.8', 'border':1 }) , (Drawing, 'gcut' , { 'color':'255,255,190', 'border':1 }) - , (Drawing, 'gcell' , { 'color':'255,255,190', 'pattern':'0000000000000000', 'border':4 }) + , (Drawing, 'Anabatic::Edge' , { 'color':'255,255,190', 'pattern':'0000000000000000', 'border':4 }) + , (Drawing, 'Anabatic::GCell', { 'color':'255,255,190', 'pattern':'0000000000000000', 'border':4, 'threshold':0.40*scale }) ) # ---------------------------------------------------------------------- @@ -363,6 +366,7 @@ stylesTable = \ , (Drawing, 'gmetalh' , { 'color':'128,255,200', 'pattern':'light_antihash0.8' , 'border':1 }) , (Drawing, 'gmetalv' , { 'color':'200,200,255', 'pattern':'light_antihash1.8' , 'border':1 }) , (Drawing, 'gcut' , { 'color':'255,255,190', 'border':1 }) - , (Drawing, 'gcell' , { 'color':'255,255,190', 'pattern':'0000000000000000', 'border':4 }) + , (Drawing, 'Anabatic::Edge' , { 'color':'255,255,190', 'pattern':'0000000000000000', 'border':4 }) + , (Drawing, 'Anabatic::GCell', { 'color':'255,255,190', 'pattern':'0000000000000000', 'border':4 }) ) ) diff --git a/hurricane/src/viewer/CellWidget.cpp b/hurricane/src/viewer/CellWidget.cpp index 9930c223..66a06822 100644 --- a/hurricane/src/viewer/CellWidget.cpp +++ b/hurricane/src/viewer/CellWidget.cpp @@ -1563,9 +1563,11 @@ namespace Hurricane { bool CellWidget::isDrawableExtension ( const Name& extensionName ) { - PaletteItem* item = (_palette) ? _palette->find(extensionName) : NULL; + PaletteItem* item = (_palette) ? _palette->find(extensionName) : NULL; + DbU::Unit unity = DbU::lambda(1.0); - return (!item || item->isItemVisible()); + return (!item || item->isItemVisible()) + && ( Graphics::getThreshold(extensionName) < getScale()*unity ); }