* Most of tools:

- Bug: In top CMakeLists.txt the SETUP_PROJECT_PATHS was not inserting
        X_USER_TOP *before* X_TOP, thus potentially allowing an obsolete
        system-wide configuration to shadow an up-to-date local one.

  * ./katabatic:
    - Change: In Configuration/KatabaticEngine, introduce a static Configuration
        object (singleton) to handle the default configuration. Configuration are
        now created only through cloning operations. In KatabaticEngine, the
        _configuration becomes a pointer (previoulsy an value).
          Confifuration becames a singleton and a decorator.
          Also adds a print method to nicely display configurations values on
        the terminal.
This commit is contained in:
Jean-Paul Chaput 2010-04-28 15:43:30 +00:00
parent 9ca0332d1e
commit 388b8b3ce0
6 changed files with 129 additions and 67 deletions

View File

@ -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)

View File

@ -23,8 +23,14 @@
// x-----------------------------------------------------------------x
#include <iostream>
#include <iomanip>
#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<Katabatic> 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";

View File

@ -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;

View File

@ -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<Net*>& 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 ) );

View File

@ -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;

View File

@ -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<Net*> _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<Net*> _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<Net*>& 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; }