diff --git a/katabatic/src/AutoHorizontal.cpp b/katabatic/src/AutoHorizontal.cpp index 7ae78a7f..a0ab6c3e 100644 --- a/katabatic/src/AutoHorizontal.cpp +++ b/katabatic/src/AutoHorizontal.cpp @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved // // =================================================================== // diff --git a/katabatic/src/AutoSegment.cpp b/katabatic/src/AutoSegment.cpp index bd9f9c2e..a5537739 100644 --- a/katabatic/src/AutoSegment.cpp +++ b/katabatic/src/AutoSegment.cpp @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved // // =================================================================== // @@ -300,8 +300,9 @@ namespace Katabatic { // Class : "Katabatic::AutoSegment". - size_t AutoSegment::_allocateds = 0; - unsigned long AutoSegment::_maxId = 0; + size_t AutoSegment::_allocateds = 0; + size_t AutoSegment::_globalsCount = 0; + unsigned long AutoSegment::_maxId = 0; DbU::Unit AutoSegment::getX () const @@ -831,11 +832,11 @@ namespace Katabatic { #if defined(CHECK_DETERMINISM) cerr << "Order: AutoSegment::AutoSegment() - " << endl; #endif - _allocateds++; - AutoContact* source = Session::lookup(dynamic_cast(segment->getSource())); AutoContact* target = Session::lookup(dynamic_cast(segment->getTarget())); + _allocateds++; + _gcell = source->getGCell(); setOptimalMax ( (_isHorizontal) ? _gcell->getBoundingBox().getYMax() : _gcell->getBoundingBox().getXMax() ); @@ -847,8 +848,8 @@ namespace Katabatic { _isGlobal = ( source->getGCell() != target->getGCell() ); break; } - - _isCanonicalLocal = !_isGlobal; + _globalsCount += (_isGlobal) ? 1 : 0; + _isCanonicalLocal = not _isGlobal; _computeTerminal ( segment ); //if ( source->isTerminal() or target->isTerminal() ) _isTerminal = true; @@ -907,6 +908,7 @@ namespace Katabatic { AutoSegment::~AutoSegment () { _allocateds--; + if ( _isGlobal and (_globalsCount > 0) ) _globalsCount--; } @@ -1238,7 +1240,7 @@ namespace Katabatic { } - bool AutoSegment::canPivotUp ( bool propagate ) + bool AutoSegment::canPivotUp ( bool propagate, float reserve ) { ltrace(200) << "AutoSegment::canPivotUp()" << endl; @@ -1250,7 +1252,7 @@ namespace Katabatic { vector gcells; getGCells ( gcells ); for ( size_t i=0 ; ihasFreeTrack(depth) ) return false; + if ( !gcells[i]->hasFreeTrack(depth,reserve) ) return false; } ltrace(200) << getAutoSource() << endl; @@ -1270,7 +1272,7 @@ namespace Katabatic { forEach ( AutoSegment*, isegment, getCollapseds() ) { isegment->getGCells ( gcells ); for ( size_t i=0 ; ihasFreeTrack(depth) ) return false; + if ( !gcells[i]->hasFreeTrack(depth,reserve) ) return false; } if ( isegment->getAutoSource()->getMinDepth() < depth ) return false; if ( isegment->getAutoTarget()->getMinDepth() < depth ) return false; @@ -1283,7 +1285,7 @@ namespace Katabatic { } - bool AutoSegment::canMoveUp ( bool propagate ) + bool AutoSegment::canMoveUp ( bool propagate, float reserve ) { ltrace(200) << "AutoSegment::canMoveUp()" << endl; @@ -1296,7 +1298,7 @@ namespace Katabatic { vector gcells; getGCells ( gcells ); for ( size_t i=0 ; ihasFreeTrack(depth) ) return false; + if ( not gcells[i]->hasFreeTrack(depth,reserve) ) return false; } if ( isLocal() and not propagate ) { @@ -1314,7 +1316,7 @@ namespace Katabatic { isegment->getGCells ( gcells ); for ( size_t i=0 ; ihasFreeTrack(depth) ) { + if ( not gcells[i]->hasFreeTrack(depth,reserve) ) { ltrace(200) << "Not enough free track in " << gcells[i] << endl; return false; } @@ -1523,9 +1525,9 @@ namespace Katabatic { Contact* contact = dynamic_cast(hurricaneSegment->getSource()); AutoContact* autoContact = Session::lookup(contact); - if ( !contact ) { + if ( contact == NULL ) { throw Error ( badSegmentSource, getString(hurricaneSegment).c_str() ); - if ( autoContact && ( autoContact != source ) ) + if ( autoContact and ( autoContact != source ) ) throw Error ( mismatchSegmentSource , getString(hurricaneSegment).c_str() , getString(contact).c_str() ); @@ -1533,9 +1535,9 @@ namespace Katabatic { contact = dynamic_cast(hurricaneSegment->getTarget()); autoContact = Session::lookup(contact); - if ( !contact ) { + if ( contact == NULL ) { throw Error ( badSegmentTarget, getString(hurricaneSegment).c_str() ); - if ( autoContact && ( autoContact != target ) ) + if ( autoContact and ( autoContact != target ) ) throw Error ( mismatchSegmentTarget , getString(hurricaneSegment).c_str() , getString(contact).c_str() ); diff --git a/katabatic/src/AutoSegments.cpp b/katabatic/src/AutoSegments.cpp index 1ba4c7f9..94430bed 100644 --- a/katabatic/src/AutoSegments.cpp +++ b/katabatic/src/AutoSegments.cpp @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved // // =================================================================== // diff --git a/katabatic/src/Configuration.cpp b/katabatic/src/Configuration.cpp index fb0aa992..96f93084 100644 --- a/katabatic/src/Configuration.cpp +++ b/katabatic/src/Configuration.cpp @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved // // =================================================================== // diff --git a/katabatic/src/GCell.cpp b/katabatic/src/GCell.cpp index 8df443a4..ae9f467e 100644 --- a/katabatic/src/GCell.cpp +++ b/katabatic/src/GCell.cpp @@ -721,7 +721,7 @@ namespace Katabatic { } - bool GCell::hasFreeTrack ( size_t depth ) const + bool GCell::hasFreeTrack ( size_t depth, float reserve ) const { if (_invalid) const_cast(this)->updateDensity(); @@ -765,7 +765,7 @@ namespace Katabatic { << " " << (_saturateDensities[depth]*capacity) << " vs. " << capacity << endl; - return (_saturateDensities[depth]*capacity + 1.0 <= capacity); + return (_saturateDensities[depth]*capacity + 1.0 + reserve <= capacity); } diff --git a/katabatic/src/GCellGrid.cpp b/katabatic/src/GCellGrid.cpp index 8f187e3c..7efd7edd 100644 --- a/katabatic/src/GCellGrid.cpp +++ b/katabatic/src/GCellGrid.cpp @@ -54,7 +54,7 @@ namespace Katabatic { GCellGrid::GCellGrid ( KatabaticEngine* ktbt ) - : Grid() + : Grid(ktbt->getCell()->getAbutmentBox()) , _katabatic(ktbt) { } @@ -140,6 +140,18 @@ namespace Katabatic { } + Interval GCellGrid::getUSide ( unsigned int direction ) const + { + Interval side; + switch ( direction ) { + default: + case Constant::Horizontal: side = Interval(_boundingBox.getXMin(),_boundingBox.getXMax()); break; + case Constant::Vertical: side = Interval(_boundingBox.getYMin(),_boundingBox.getYMax()); break; + } + return side; + } + + void GCellGrid::updateContacts ( bool openSession ) { if ( openSession ) Session::open ( _katabatic ); diff --git a/katabatic/src/Grid.cpp b/katabatic/src/Grid.cpp index 1da6c3c2..24872bd6 100644 --- a/katabatic/src/Grid.cpp +++ b/katabatic/src/Grid.cpp @@ -49,6 +49,11 @@ namespace Katabatic { unsigned int BaseGrid::Axis::getGraduationNumber ( DbU::Unit position, bool& onGraduation ) const { + if ( position == _graduations[_graduations.size()-1] ) { + onGraduation = true; + return _graduations.size()-2; + } + vector::const_iterator it = lower_bound ( _graduations.begin() , _graduations.end() , position+1 @@ -99,11 +104,13 @@ namespace Katabatic { // Class : "Katabatic::BaseGrid::Axis". - BaseGrid::BaseGrid () : _xGraduations() - , _yGraduations() - , _rows(0) - , _columns(0) - , _rawSize(0) + BaseGrid::BaseGrid ( const Box& bb ) + : _boundingBox (bb) + , _xGraduations() + , _yGraduations() + , _rows (0) + , _columns (0) + , _rawSize (0) { } diff --git a/katabatic/src/KatabaticEngine.cpp b/katabatic/src/KatabaticEngine.cpp index ebce2122..e764768c 100644 --- a/katabatic/src/KatabaticEngine.cpp +++ b/katabatic/src/KatabaticEngine.cpp @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved // // =================================================================== // @@ -38,6 +38,7 @@ #include "hurricane/Cell.h" #include "crlcore/Utilities.h" +#include "crlcore/Catalog.h" #include "crlcore/Measures.h" #include "crlcore/AllianceFramework.h" @@ -170,6 +171,8 @@ namespace Katabatic { using Hurricane::BasicLayer; using Hurricane::NetExternalComponents; using CRL::AllianceFramework; + using CRL::Catalog; + using CRL::CatalogProperty; using CRL::Measures; using CRL::addMeasure; using CRL::getMeasure; @@ -230,7 +233,9 @@ namespace Katabatic { , _gcellGrid (NULL) , _routingNets () { - addMeasure ( cell, "Gates", cell->getInstances().getSize() ); + addMeasure ( cell, "Gates" + , AllianceFramework::getInstancesCount(cell,AllianceFramework::IgnoreFeeds + |AllianceFramework::Recursive) ); } diff --git a/katabatic/src/LoadGrByNet.cpp b/katabatic/src/LoadGrByNet.cpp index 1014e3fb..0acc7973 100644 --- a/katabatic/src/LoadGrByNet.cpp +++ b/katabatic/src/LoadGrByNet.cpp @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved // // =================================================================== // @@ -39,11 +39,13 @@ #include "hurricane/RoutingPads.h" #include "hurricane/Pad.h" #include "hurricane/Plug.h" +#include "hurricane/Cell.h" #include "hurricane/Instance.h" #include "hurricane/Vertical.h" #include "hurricane/Horizontal.h" #include "crlcore/RoutingGauge.h" +#include "crlcore/Measures.h" #include "katabatic/AutoContact.h" #include "katabatic/AutoSegment.h" @@ -2217,16 +2219,18 @@ namespace { return; } - if ( routingPads.size() > 2 ) { - cerr << Error("For %s, more than two Plugs/Pins (%d) in single GCell." - ,getString(net).c_str() - ,routingPads.size()) << endl; - ltraceout(99); - return; - } + // if ( routingPads.size() > 2 ) { + // cerr << Error("For %s, more than two Plugs/Pins (%d) in single GCell." + // ,getString(net).c_str() + // ,routingPads.size()) << endl; + // ltraceout(99); + // return; + // } - GCell* gcell = ktbt->getGCellGrid()->getGCell ( routingPads[0]->getCenter() - , routingPads[1]->getCenter() ); + sort ( routingPads.begin(), routingPads.end(), SortRpByX(false) ); // increasing X. + + GCell* gcell = ktbt->getGCellGrid()->getGCell ( (*routingPads.begin ())->getCenter() + , (*routingPads.rbegin())->getCenter() ); if ( !gcell ) { cerr << Error("No GCell under %s.",getString(routingPads[0]).c_str()) << endl; @@ -2239,36 +2243,30 @@ namespace { AutoContact* dummy = NULL; AutoContact* source = NULL; AutoContact* target = NULL; - GCellConfiguration::_GCell_rp_AutoContacts ( gcell, routingPads[0], source, dummy, true ); - GCellConfiguration::_GCell_rp_AutoContacts ( gcell, routingPads[1], target, dummy, true ); - // AutoContact* source = AutoContact::fromRp ( gcell - // , routingPads[0] - // , Session::getContactLayer(0) - // , routingPads[0]->getCenter() - // , DbU::lambda(1.0), DbU::lambda(1.0) - // ); - // AutoContact* target = AutoContact::fromRp ( gcell - // , routingPads[1] - // , Session::getContactLayer(0) - // , routingPads[1]->getCenter() - // , DbU::lambda(1.0), DbU::lambda(1.0) - // ); - - Box sourceBox = source->getNativeConstraintBox (); - Box targetBox = target->getNativeConstraintBox (); - - if ( ( sourceBox.getYMax() < targetBox.getYMin() ) - || ( sourceBox.getYMin() > targetBox.getYMax() ) ) { - AutoContact* subContact1 = AutoContact::create ( gcell, net, Session::getContactLayer(1) ); - AutoSegment::create ( source, subContact1, Constant::Vertical, AutoSegment::Local, true ); - - AutoContact* subContact2 = AutoContact::create ( gcell, net, Session::getContactLayer(1) ); - AutoSegment::create ( target, subContact2, Constant::Vertical, AutoSegment::Local, true ); - - AutoSegment::create ( subContact1, subContact2, Constant::Horizontal, AutoSegment::Local, false ); - } else + for ( size_t irp=1 ; irpgetNativeConstraintBox (); + // Box targetBox = target->getNativeConstraintBox (); + + // if ( ( sourceBox.getYMax() < targetBox.getYMin() ) + // || ( sourceBox.getYMin() > targetBox.getYMax() ) ) { + // AutoContact* subContact1 = AutoContact::create ( gcell, net, Session::getContactLayer(1) ); + // AutoSegment::create ( source, subContact1, Constant::Vertical, AutoSegment::Local, true ); + + // AutoContact* subContact2 = AutoContact::create ( gcell, net, Session::getContactLayer(1) ); + // AutoSegment::create ( target, subContact2, Constant::Vertical, AutoSegment::Local, true ); + + // AutoSegment::create ( subContact1, subContact2, Constant::Horizontal, AutoSegment::Local, false ); + // } else + // AutoSegment::create ( source, target, Constant::Horizontal, AutoSegment::Local, true ); ltraceout(99); } @@ -2282,10 +2280,12 @@ namespace { namespace Katabatic { + using Hurricane::Name; using Hurricane::DebugSession; using Hurricane::Error; using Hurricane::Warning; using Hurricane::Bug; + using CRL::addMeasure; void KatabaticEngine::_loadGrByNet () @@ -2316,6 +2316,9 @@ namespace Katabatic { stopMeasures (); printMeasures ( "load" ); + + addMeasure ( getCell(), "Globals", AutoSegment::getGlobalsCount() ); + addMeasure ( getCell(), "Edges" , AutoSegment::getAllocateds() ); } diff --git a/katabatic/src/katabatic/AutoSegment.h b/katabatic/src/katabatic/AutoSegment.h index 64d3ad93..2918ba84 100644 --- a/katabatic/src/katabatic/AutoSegment.h +++ b/katabatic/src/katabatic/AutoSegment.h @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved // // =================================================================== // @@ -131,7 +131,8 @@ namespace Katabatic { , vector& collapseds ); static inline int getTerminalCount ( AutoSegment* seed ); - static size_t getAllocateds () { return _allocateds; }; + static inline size_t getGlobalsCount (); + static inline size_t getAllocateds (); static inline unsigned long getMaxId (); // Constructors & Destructor. static AutoSegment* create ( AutoContact* source @@ -195,8 +196,8 @@ namespace Katabatic { inline bool allowOutsideGCell () const; bool canDesalignate (); virtual bool canDesalignate ( AutoContact* ) const = 0; - bool canMoveUp ( bool propagate=false ); - bool canPivotUp ( bool propagate=false ); + bool canMoveUp ( bool propagate=false, float reserve=0.0 ); + bool canPivotUp ( bool propagate=false, float reserve=0.0 ); bool canSlacken ( bool propagate=false ); virtual bool _canSlacken () const = 0; bool canGoOutsideGCell () const; @@ -302,6 +303,7 @@ namespace Katabatic { protected: // Internal: Static Attributes. static size_t _allocateds; + static size_t _globalsCount; static bool _destroyBase; static bool _destroyTool; static unsigned long _maxId; @@ -469,6 +471,10 @@ namespace Katabatic { } + inline size_t AutoSegment::getGlobalsCount () { return _globalsCount; } + inline size_t AutoSegment::getAllocateds () { return _allocateds; } + + } // End of Katabatic namespace. diff --git a/katabatic/src/katabatic/Configuration.h b/katabatic/src/katabatic/Configuration.h index 7f227225..749e3037 100644 --- a/katabatic/src/katabatic/Configuration.h +++ b/katabatic/src/katabatic/Configuration.h @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved // // =================================================================== // diff --git a/katabatic/src/katabatic/GCell.h b/katabatic/src/katabatic/GCell.h index 03ecb5f6..1264093e 100644 --- a/katabatic/src/katabatic/GCell.h +++ b/katabatic/src/katabatic/GCell.h @@ -110,7 +110,7 @@ namespace Katabatic { bool isSaturated ( size_t depth ) const; inline bool isValid () const; bool isAboveDensity ( float threshold ) const; - bool hasFreeTrack ( size_t depth ) const; + bool hasFreeTrack ( size_t depth, float reserve ) const; inline GCellGrid* getGCellGrid () const; inline unsigned int getDepth () const; inline unsigned int getIndex () const; diff --git a/katabatic/src/katabatic/GCellGrid.h b/katabatic/src/katabatic/GCellGrid.h index 518edb14..281f63a0 100644 --- a/katabatic/src/katabatic/GCellGrid.h +++ b/katabatic/src/katabatic/GCellGrid.h @@ -50,15 +50,16 @@ namespace Katabatic { class GCellGrid : public Grid { public: - Cell* getCell () const; - void updateContacts ( bool openSession=true ); - size_t checkDensity () const; - size_t updateDensity (); - bool checkEdgeSaturation ( float threshold ) const; - void _xmlWrite ( ostream& ); - virtual Record* _getRecord () const; - virtual string _getString () const; - virtual string _getTypeName () const; + Cell* getCell () const; + Interval getUSide ( unsigned int ) const; + void updateContacts ( bool openSession=true ); + size_t checkDensity () const; + size_t updateDensity (); + bool checkEdgeSaturation ( float threshold ) const; + void _xmlWrite ( ostream& ); + virtual Record* _getRecord () const; + virtual string _getString () const; + virtual string _getTypeName () const; // Attributes. protected: diff --git a/katabatic/src/katabatic/Grid.h b/katabatic/src/katabatic/Grid.h index fb39af77..4a70bec8 100644 --- a/katabatic/src/katabatic/Grid.h +++ b/katabatic/src/katabatic/Grid.h @@ -58,19 +58,20 @@ namespace Katabatic { public: class Axis; public: - inline void destroy (); + inline void destroy (); // Accessors. - inline unsigned int getColumns () const; - inline unsigned int getRows () const; - inline unsigned int getRawSize () const; - inline unsigned int getIndex ( unsigned int c, unsigned int r ) const; - inline unsigned int getRow ( unsigned int ) const; - inline unsigned int getColumn ( unsigned int ) const; - inline const Axis& getXGrads () const; - inline const Axis& getYGrads () const; - // Inspector Managment. - virtual Record* _getRecord () const; - virtual string _getString () const = 0; + inline const Box& getBoundingBox () const; + inline unsigned int getColumns () const; + inline unsigned int getRows () const; + inline unsigned int getRawSize () const; + inline unsigned int getIndex ( unsigned int c, unsigned int r ) const; + inline unsigned int getRow ( unsigned int ) const; + inline unsigned int getColumn ( unsigned int ) const; + inline const Axis& getXGrads () const; + inline const Axis& getYGrads () const; + // Inspector Managment. + virtual Record* _getRecord () const; + virtual string _getString () const = 0; public: // Sub-Class Grid::Axis. @@ -96,6 +97,7 @@ namespace Katabatic { protected: // Attributes. + Box _boundingBox; Axis _xGraduations; Axis _yGraduations; unsigned int _rows; @@ -104,7 +106,7 @@ namespace Katabatic { // Constructors & Destructors. protected: - BaseGrid (); + BaseGrid ( const Box& ); virtual ~BaseGrid (); virtual void _postCreate (); virtual void _preDestroy (); @@ -120,13 +122,14 @@ namespace Katabatic { inline DbU::Unit& BaseGrid::Axis::operator[] ( unsigned int i ) { return _graduations[i]; } inline string BaseGrid::Axis::_getTypeName () const { return _TName("BaseGrid::Axis"); } - inline void BaseGrid::destroy () { _preDestroy(); delete this; } - inline unsigned int BaseGrid::getColumns () const { return _columns; }; - inline unsigned int BaseGrid::getRows () const { return _rows; }; - inline unsigned int BaseGrid::getRawSize () const { return getColumns() * getRows(); } - inline unsigned int BaseGrid::getIndex ( unsigned int c, unsigned int r ) const { return c+(r*getColumns()); } - inline unsigned int BaseGrid::getRow ( unsigned int i ) const { return i / getColumns(); } - inline unsigned int BaseGrid::getColumn ( unsigned int i ) const { return i % getColumns(); } + inline void BaseGrid::destroy () { _preDestroy(); delete this; } + inline const Box& BaseGrid::getBoundingBox () const { return _boundingBox; }; + inline unsigned int BaseGrid::getColumns () const { return _columns; }; + inline unsigned int BaseGrid::getRows () const { return _rows; }; + inline unsigned int BaseGrid::getRawSize () const { return getColumns() * getRows(); } + inline unsigned int BaseGrid::getIndex ( unsigned int c, unsigned int r ) const { return c+(r*getColumns()); } + inline unsigned int BaseGrid::getRow ( unsigned int i ) const { return i / getColumns(); } + inline unsigned int BaseGrid::getColumn ( unsigned int i ) const { return i % getColumns(); } inline const BaseGrid::Axis& BaseGrid::getXGrads () const { return _xGraduations; } inline const BaseGrid::Axis& BaseGrid::getYGrads () const { return _yGraduations; } @@ -166,7 +169,7 @@ namespace Katabatic { // Constructors & Destructors. protected: - inline Grid (); + inline Grid ( const Box& ); virtual ~Grid (); private: Grid ( const Grid& ); @@ -187,8 +190,9 @@ namespace Katabatic { // Inline Functions. template - Grid::Grid () : BaseGrid() - , _gcells() + Grid::Grid ( const Box& bb ) + : BaseGrid(bb) + , _gcells () { }