diff --git a/katabatic/CMakeLists.txt b/katabatic/CMakeLists.txt index 8104ef05..ef3a5ba9 100644 --- a/katabatic/CMakeLists.txt +++ b/katabatic/CMakeLists.txt @@ -21,15 +21,6 @@ ENDIF(COMMAND CMAKE_POLICY) # This macro has to be included in all the tools CMakeLists.txt as it's # the sole means of localizing other tools/projects. MACRO(SETUP_PROJECT_PATHS project) - IF( NOT("$ENV{${project}_USER_TOP}" STREQUAL "") ) - MESSAGE("-- ${project}_USER_TOP is set to $ENV{${project}_USER_TOP}") - SET(PROJECT_MODULE_PATH "$ENV{${project}_USER_TOP}/share/cmake_modules/") - LIST(FIND CMAKE_MODULE_PATH "${PROJECT_MODULE_PATH}" DIR_INDEX) - IF( DIR_INDEX LESS 0) - LIST(INSERT CMAKE_MODULE_PATH 0 "${PROJECT_MODULE_PATH}") - ENDIF( DIR_INDEX LESS 0) - ENDIF( NOT("$ENV{${project}_USER_TOP}" STREQUAL "") ) - IF( NOT("$ENV{${project}_TOP}" STREQUAL "") ) MESSAGE("-- ${project}_TOP is set to $ENV{${project}_TOP}") SET(PROJECT_MODULE_PATH "$ENV{${project}_TOP}/share/cmake_modules/") @@ -38,6 +29,15 @@ MACRO(SETUP_PROJECT_PATHS project) LIST(INSERT CMAKE_MODULE_PATH 0 "${PROJECT_MODULE_PATH}") ENDIF( DIR_INDEX LESS 0) ENDIF( NOT("$ENV{${project}_TOP}" STREQUAL "") ) + + IF( NOT("$ENV{${project}_USER_TOP}" STREQUAL "") ) + MESSAGE("-- ${project}_USER_TOP is set to $ENV{${project}_USER_TOP}") + SET(PROJECT_MODULE_PATH "$ENV{${project}_USER_TOP}/share/cmake_modules/") + LIST(FIND CMAKE_MODULE_PATH "${PROJECT_MODULE_PATH}" DIR_INDEX) + IF( DIR_INDEX LESS 0) + LIST(INSERT CMAKE_MODULE_PATH 0 "${PROJECT_MODULE_PATH}") + ENDIF( DIR_INDEX LESS 0) + ENDIF( NOT("$ENV{${project}_USER_TOP}" STREQUAL "") ) ENDMACRO(SETUP_PROJECT_PATHS project) SETUP_PROJECT_PATHS(IO) diff --git a/katabatic/src/Configuration.cpp b/katabatic/src/Configuration.cpp index 96f93084..7b21e575 100644 --- a/katabatic/src/Configuration.cpp +++ b/katabatic/src/Configuration.cpp @@ -23,8 +23,14 @@ // x-----------------------------------------------------------------x +#include +#include + #include "hurricane/Technology.h" #include "hurricane/DataBase.h" +#include "hurricane/Cell.h" +#include "crlcore/Utilities.h" +#include "crlcore/AllianceFramework.h" #include "katabatic/Configuration.h" @@ -32,19 +38,34 @@ namespace Katabatic { + using std::cout; using std::cerr; using std::endl; + using std::setprecision; using std::ostringstream; using Hurricane::tab; using Hurricane::inltrace; using Hurricane::Technology; using Hurricane::DataBase; + using CRL::AllianceFramework; // ------------------------------------------------------------------- // Class : "Katabatic::Configuration". + Configuration* Configuration::_default = NULL; + + + Configuration* Configuration::getDefault () + { + if ( _default == NULL ) { + _default = new ConfigurationConcrete ( AllianceFramework::get()->getRoutingGauge() ); + } + return _default; + } + + Configuration::Configuration () { } Configuration::~Configuration () { } @@ -68,6 +89,20 @@ namespace Katabatic { } + ConfigurationConcrete::ConfigurationConcrete ( const ConfigurationConcrete& other ) + : Configuration() + , _gmetalh (other._gmetalh) + , _gmetalv (other._gmetalv) + , _gcontact (other._gcontact) + , _rg (NULL) + , _extensionCap (other._extensionCap) + , _saturateRatio (other._saturateRatio) + , _globalThreshold (other._globalThreshold) + { + if ( other._rg ) _rg = other._rg->getClone(); + } + + ConfigurationConcrete::~ConfigurationConcrete () { ltrace(89) << "About to delete attribute _rg (RoutingGauge)." << endl; @@ -75,6 +110,10 @@ namespace Katabatic { } + ConfigurationConcrete* ConfigurationConcrete::clone () const + { return new ConfigurationConcrete(*this); } + + bool ConfigurationConcrete::isGMetal ( const Layer* layer ) const { if ( !layer ) return false; @@ -131,6 +170,15 @@ namespace Katabatic { { _globalThreshold = threshold; } + void ConfigurationConcrete::print ( Cell* cell ) const + { + cout << " o Configuration of ToolEngine for Cell <" << cell->getName() << ">" << endl; + cout << Dots::asIdentifier(" - Routing Gauge" ,getString(_rg->getName())) << endl; + cout << Dots::asPercentage(" - GCell saturation threshold" ,_saturateRatio) << endl; + cout << Dots::asDouble (" - Long global length threshold",DbU::getLambda(_globalThreshold)) << endl; + } + + string ConfigurationConcrete::_getTypeName () const { return "ConfigurationConcrete"; diff --git a/katabatic/src/GraphicKatabaticEngine.cpp b/katabatic/src/GraphicKatabaticEngine.cpp index 55a5d4b3..79955f1c 100644 --- a/katabatic/src/GraphicKatabaticEngine.cpp +++ b/katabatic/src/GraphicKatabaticEngine.cpp @@ -101,7 +101,7 @@ namespace Katabatic { { KatabaticEngine* ktbt = KatabaticEngine::get ( cell ); if ( !ktbt ) - ktbt = KatabaticEngine::create ( rg, cell ); + ktbt = KatabaticEngine::create ( cell ); else cerr << Warning("%s already has a Katabatic engine.",getString(cell).c_str()) << endl; diff --git a/katabatic/src/KatabaticEngine.cpp b/katabatic/src/KatabaticEngine.cpp index e764768c..27c3894e 100644 --- a/katabatic/src/KatabaticEngine.cpp +++ b/katabatic/src/KatabaticEngine.cpp @@ -221,7 +221,7 @@ namespace Katabatic { } - KatabaticEngine::KatabaticEngine ( const RoutingGauge* gauge, Cell* cell ) + KatabaticEngine::KatabaticEngine ( Cell* cell ) : ToolEngine (cell) , _timer () , _state (StateCreation) @@ -229,7 +229,7 @@ namespace Katabatic { , _destroyBaseSegment(false) , _demoMode (false) , _warnGCellOverload (false) - , _configuration (gauge) + , _configuration (Configuration::getDefault()->clone()) , _gcellGrid (NULL) , _routingNets () { @@ -254,11 +254,11 @@ namespace Katabatic { } - KatabaticEngine* KatabaticEngine::create ( const RoutingGauge* gauge, Cell* cell ) + KatabaticEngine* KatabaticEngine::create ( Cell* cell ) { ltrace(90) << "KatabaticEngine::create() - " << cell << endl; - KatabaticEngine* katabatic = new KatabaticEngine ( gauge, cell ); + KatabaticEngine* katabatic = new KatabaticEngine ( cell ); katabatic->_postCreate (); @@ -267,7 +267,9 @@ namespace Katabatic { KatabaticEngine::~KatabaticEngine () - { } + { + delete _configuration; + } void KatabaticEngine::_preDestroy () @@ -306,8 +308,8 @@ namespace Katabatic { ltrace(90) << "Saving AutoContacts/AutoSegments." << endl; cmess1 << " o Driving Hurricane data-base." << endl; - cmess1 << " - AutoSegments := " << AutoSegment::getAllocateds() << endl; - cmess1 << " - AutoContacts := " << AutoContact::getAllocateds() << endl; + cmess1 << Dots::asSizet(" - AutoSegments",AutoSegment::getAllocateds()) << endl; + cmess1 << Dots::asSizet(" - AutoContacts",AutoContact::getAllocateds())<< endl; forEach ( Net*, inet, _cell->getNets() ) _saveNet ( *inet ); @@ -502,7 +504,7 @@ namespace Katabatic { Configuration* KatabaticEngine::getConfiguration () - { return &_configuration; } + { return _configuration; } void KatabaticEngine::loadGlobalRouting ( unsigned int method, vector& nets ) @@ -907,7 +909,7 @@ namespace Katabatic { { ostringstream os; - os << "<" << "Katabatic " << _cell->getName () << " " << _configuration.getRoutingGauge()->getName() << ">"; + os << "<" << "Katabatic " << _cell->getName () << " " << _configuration->getRoutingGauge()->getName() << ">"; return ( os.str() ); } @@ -918,7 +920,7 @@ namespace Katabatic { Record* record = ToolEngine::_getRecord (); record->add ( getSlot ( "_demoMode" , _demoMode ) ); record->add ( getSlot ( "_state" , _state ) ); - record->add ( getSlot ( "_configuration" , &_configuration ) ); + record->add ( getSlot ( "_configuration" , _configuration ) ); record->add ( getSlot ( "_gcellGrid" , _gcellGrid ) ); record->add ( getSlot ( "_routingNets" , &_routingNets ) ); record->add ( getSlot ( "_autoContactLut" , &_autoContactLut ) ); diff --git a/katabatic/src/katabatic/Configuration.h b/katabatic/src/katabatic/Configuration.h index 749e3037..346a6b84 100644 --- a/katabatic/src/katabatic/Configuration.h +++ b/katabatic/src/katabatic/Configuration.h @@ -31,6 +31,7 @@ #include "hurricane/DbU.h" namespace Hurricane { class Layer; + class Cell; } #include "crlcore/RoutingGauge.h" @@ -46,6 +47,7 @@ namespace Katabatic { using Hurricane::Record; using Hurricane::Layer; using Hurricane::DbU; + using Hurricane::Cell; using CRL::RoutingGauge; using CRL::RoutingLayerGauge; @@ -55,10 +57,12 @@ namespace Katabatic { class Configuration { + public: + static Configuration* getDefault (); public: // Constructor & Destructor. - Configuration (); virtual ~Configuration (); + virtual Configuration* clone () const = 0; // Methods. virtual bool isGMetal ( const Layer* ) const = 0; virtual size_t getDepth () const = 0; @@ -72,12 +76,17 @@ namespace Katabatic { virtual DbU::Unit getGlobalThreshold () const = 0; virtual void setSaturateRatio ( float ) = 0; virtual void setGlobalThreshold ( DbU::Unit ) = 0; + virtual void print ( Cell* ) const = 0; virtual Record* _getRecord () const = 0; virtual string _getString () const = 0; virtual string _getTypeName () const = 0; + protected: + Configuration (); private: - Configuration ( const Configuration& ); - Configuration& operator= ( const Configuration& ); + Configuration ( const Configuration& ); + Configuration& operator= ( const Configuration& ); + private: + static Configuration* _default; }; @@ -86,27 +95,30 @@ namespace Katabatic { class ConfigurationConcrete : public Configuration { + friend class Configuration; public: // Constructor & Destructor. - ConfigurationConcrete ( const RoutingGauge* ); - virtual ~ConfigurationConcrete (); + virtual ConfigurationConcrete* clone () const; + virtual ~ConfigurationConcrete (); // Methods. - virtual bool isGMetal ( const Layer* ) const; - virtual size_t getDepth () const; - virtual size_t getLayerDepth ( const Layer* ) const; - virtual RoutingGauge* getRoutingGauge () const; - virtual RoutingLayerGauge* getLayerGauge ( size_t depth ) const; - virtual const Layer* getRoutingLayer ( size_t depth ) const; - virtual Layer* getContactLayer ( size_t depth ) const; - virtual DbU::Unit getExtensionCap () const; - virtual float getSaturateRatio () const; - virtual DbU::Unit getGlobalThreshold () const; - virtual void setSaturateRatio ( float ); - virtual void setGlobalThreshold ( DbU::Unit ); - virtual Record* _getRecord () const; - virtual string _getString () const; - virtual string _getTypeName () const; - + virtual bool isGMetal ( const Layer* ) const; + virtual size_t getDepth () const; + virtual size_t getLayerDepth ( const Layer* ) const; + virtual RoutingGauge* getRoutingGauge () const; + virtual RoutingLayerGauge* getLayerGauge ( size_t depth ) const; + virtual const Layer* getRoutingLayer ( size_t depth ) const; + virtual Layer* getContactLayer ( size_t depth ) const; + virtual DbU::Unit getExtensionCap () const; + virtual float getSaturateRatio () const; + virtual DbU::Unit getGlobalThreshold () const; + virtual void setSaturateRatio ( float ); + virtual void setGlobalThreshold ( DbU::Unit ); + virtual void print ( Cell* ) const; + virtual Record* _getRecord () const; + virtual string _getString () const; + virtual string _getTypeName () const; + protected: + ConfigurationConcrete ( const RoutingGauge* ); protected: // Attributes. const Layer* _gmetalh; diff --git a/katabatic/src/katabatic/KatabaticEngine.h b/katabatic/src/katabatic/KatabaticEngine.h index cb3cfacc..4e208660 100644 --- a/katabatic/src/katabatic/KatabaticEngine.h +++ b/katabatic/src/katabatic/KatabaticEngine.h @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved // // =================================================================== // @@ -103,7 +103,7 @@ namespace Katabatic { public: // Constructor. - static KatabaticEngine* create ( const RoutingGauge*, Cell* ); + static KatabaticEngine* create ( Cell* ); // Accessors. static KatabaticEngine* get ( const Cell* ); static const Name& staticGetName (); @@ -188,22 +188,22 @@ namespace Katabatic { protected: // Attributes. - static Name _toolName; - Timer _timer; - EngineState _state; - bool _destroyBaseContact; - bool _destroyBaseSegment; - bool _demoMode; - bool _warnGCellOverload; - ConfigurationConcrete _configuration; - GCellGrid* _gcellGrid; - vector _routingNets; - AutoSegmentLut _autoSegmentLut; - AutoContactLut _autoContactLut; + static Name _toolName; + Timer _timer; + EngineState _state; + bool _destroyBaseContact; + bool _destroyBaseSegment; + bool _demoMode; + bool _warnGCellOverload; + Configuration* _configuration; + GCellGrid* _gcellGrid; + vector _routingNets; + AutoSegmentLut _autoSegmentLut; + AutoContactLut _autoContactLut; protected: // Constructors & Destructors. - KatabaticEngine ( const RoutingGauge*, Cell* ); + KatabaticEngine ( Cell* ); virtual ~KatabaticEngine (); virtual void _postCreate (); virtual void _preDestroy (); @@ -219,24 +219,24 @@ namespace Katabatic { inline bool KatabaticEngine::doDestroyTool () const { return _state >= StateGutted; } inline bool KatabaticEngine::setDestroyBaseContact ( bool state ) { bool p=_destroyBaseContact; _destroyBaseContact = state; return p; } inline bool KatabaticEngine::setDestroyBaseSegment ( bool state ) { bool p=_destroyBaseSegment; _destroyBaseSegment = state; return p; } - inline Configuration* KatabaticEngine::getKatabaticConfiguration () { return &_configuration; } - inline bool KatabaticEngine::isGMetal ( const Layer* layer ) const { return _configuration.isGMetal(layer); } + inline Configuration* KatabaticEngine::getKatabaticConfiguration () { return _configuration; } + inline bool KatabaticEngine::isGMetal ( const Layer* layer ) const { return _configuration->isGMetal(layer); } inline void KatabaticEngine::setDemoMode ( bool mode ) { _demoMode = mode; } inline void KatabaticEngine::setWarnGCellOverload ( bool mode ) { _warnGCellOverload = mode; } - inline void KatabaticEngine::setSaturateRatio ( float ratio ) { _configuration.setSaturateRatio(ratio); } - inline void KatabaticEngine::setGlobalThreshold ( DbU::Unit threshold ) { _configuration.setGlobalThreshold(threshold); } + inline void KatabaticEngine::setSaturateRatio ( float ratio ) { _configuration->setSaturateRatio(ratio); } + inline void KatabaticEngine::setGlobalThreshold ( DbU::Unit threshold ) { _configuration->setGlobalThreshold(threshold); } inline bool KatabaticEngine::getDemoMode () { return _demoMode; } inline bool KatabaticEngine::getWarnGCellOverload () { return _warnGCellOverload; } inline EngineState KatabaticEngine::getState () const { return _state; } - inline RoutingGauge* KatabaticEngine::getRoutingGauge () const { return _configuration.getRoutingGauge(); } - inline RoutingLayerGauge* KatabaticEngine::getLayerGauge ( size_t depth ) const { return _configuration.getLayerGauge(depth); } - inline const Layer* KatabaticEngine::getRoutingLayer ( size_t depth ) const { return _configuration.getRoutingLayer(depth); } - inline Layer* KatabaticEngine::getContactLayer ( size_t depth ) const { return _configuration.getContactLayer(depth); } + inline RoutingGauge* KatabaticEngine::getRoutingGauge () const { return _configuration->getRoutingGauge(); } + inline RoutingLayerGauge* KatabaticEngine::getLayerGauge ( size_t depth ) const { return _configuration->getLayerGauge(depth); } + inline const Layer* KatabaticEngine::getRoutingLayer ( size_t depth ) const { return _configuration->getRoutingLayer(depth); } + inline Layer* KatabaticEngine::getContactLayer ( size_t depth ) const { return _configuration->getContactLayer(depth); } inline GCellGrid* KatabaticEngine::getGCellGrid () const { return _gcellGrid; } inline const vector& KatabaticEngine::getRoutingNets () const { return _routingNets; } - inline DbU::Unit KatabaticEngine::getGlobalThreshold () const { return _configuration.getGlobalThreshold(); } - inline float KatabaticEngine::getSaturateRatio () const { return _configuration.getSaturateRatio(); } - inline DbU::Unit KatabaticEngine::getExtensionCap () const { return _configuration.getExtensionCap(); } + inline DbU::Unit KatabaticEngine::getGlobalThreshold () const { return _configuration->getGlobalThreshold(); } + inline float KatabaticEngine::getSaturateRatio () const { return _configuration->getSaturateRatio(); } + inline DbU::Unit KatabaticEngine::getExtensionCap () const { return _configuration->getExtensionCap(); } inline AutoContactLut& KatabaticEngine::_getAutoContactLut () { return _autoContactLut; } inline AutoSegmentLut& KatabaticEngine::_getAutoSegmentLut () { return _autoSegmentLut; } inline void KatabaticEngine::setState ( EngineState state ) { _state = state; }