From e968a5088f95d474390dc5df32bbf7f4b6036206 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Tue, 28 Mar 2023 16:08:11 +0200 Subject: [PATCH] Added recursive extraction of all instances models in Tramontana. --- tramontana/src/TramontanaEngine.cpp | 55 +++++++++++++++++--- tramontana/src/tramontana/TramontanaEngine.h | 8 ++- 2 files changed, 53 insertions(+), 10 deletions(-) diff --git a/tramontana/src/TramontanaEngine.cpp b/tramontana/src/TramontanaEngine.cpp index bf5c8490..e31252f2 100644 --- a/tramontana/src/TramontanaEngine.cpp +++ b/tramontana/src/TramontanaEngine.cpp @@ -100,9 +100,10 @@ namespace Tramontana { { return static_cast(ToolEngine::get(cell,staticGetName())); } - TramontanaEngine::TramontanaEngine ( Cell* cell ) - : Super (cell) + TramontanaEngine::TramontanaEngine ( Cell* cell, uint32_t depth ) + : Super (cell, (depth==0)) , _viewer (NULL) + , _depth (depth) , _equipotentials() { } @@ -113,9 +114,9 @@ namespace Tramontana { } - TramontanaEngine* TramontanaEngine::create ( Cell* cell ) + TramontanaEngine* TramontanaEngine::create ( Cell* cell, uint32_t depth ) { - TramontanaEngine* tramontana = new TramontanaEngine ( cell ); + TramontanaEngine* tramontana = new TramontanaEngine ( cell, depth ); tramontana->_postCreate(); @@ -145,14 +146,52 @@ namespace Tramontana { void TramontanaEngine::extract () { - cmess1 << " o Extracting " << getCell() << endl; - startMeasures(); + if (getDepth() == 0) { + cmess1 << " o Extracting " << getCell() << endl; + startMeasures(); + } + + for ( Instance* instance : getCell()->getInstances() ) { + Cell* master = instance->getMasterCell(); + TramontanaEngine* extractor = TramontanaEngine::get( master ); + if (not extractor) { + extractor = TramontanaEngine::create( master, getDepth()+1 ); + extractor->extract(); + } + } + _extract(); + + if (getDepth() == 0) { + stopMeasures(); + printMeasures(); + } + } + + + void TramontanaEngine::_extract () + { + if (getDepth()) { + startMeasures(); + } + SweepLine sweepLine ( this ); sweepLine.run(); consolidate(); //showEquipotentials(); - stopMeasures(); - printMeasures(); + + if (getDepth()) { + stopMeasures(); + + ostringstream header; + ostringstream result; + + header << " "; + for ( size_t i=0 ; igetName() ); + result << Timer::getStringTime (getTimer().getCombTime()) + << ", " << Timer::getStringMemory(getTimer().getIncrease()); + cmess1 << Dots::asString( header.str(), result.str() ) << endl; + } } diff --git a/tramontana/src/tramontana/TramontanaEngine.h b/tramontana/src/tramontana/TramontanaEngine.h index 95c07e68..d5beae81 100644 --- a/tramontana/src/tramontana/TramontanaEngine.h +++ b/tramontana/src/tramontana/TramontanaEngine.h @@ -49,15 +49,17 @@ namespace Tramontana { typedef ToolEngine Super; public: static const Name& staticGetName (); - static TramontanaEngine* create ( Cell* ); + static TramontanaEngine* create ( Cell*, uint32_t depth=0 ); static TramontanaEngine* get ( const Cell* ); public: const Name& getName () const; + inline uint32_t getDepth () const; inline const std::set getEquipotentials () const; inline void setViewer ( CellViewer* ); inline CellViewer* getViewer (); void extract (); + void _extract (); void consolidate (); void showEquipotentials () const; void add ( Equipotential* ); @@ -69,10 +71,11 @@ namespace Tramontana { static Name _toolName; private: CellViewer* _viewer; + uint32_t _depth; std::set _equipotentials; protected: // Constructors & Destructors. - TramontanaEngine ( Cell* ); + TramontanaEngine ( Cell*, uint32_t depth ); virtual ~TramontanaEngine (); virtual void _postCreate (); virtual void _preDestroy (); @@ -84,6 +87,7 @@ namespace Tramontana { inline void TramontanaEngine::setViewer ( CellViewer* viewer ) { _viewer=viewer; } inline CellViewer* TramontanaEngine::getViewer () { return _viewer; } + inline uint32_t TramontanaEngine::getDepth () const { return _depth; } inline const std::set TramontanaEngine::getEquipotentials () const { return _equipotentials; }