Rewrite the Unicorn ImportCell to allow new formats to be hooked in.

* New: In Hurricane, In CellWidget, add methods to emit CellPreModificated
    and CellPostModificated Qt signals (from non-Qt aware objects).
* New: In Unicorn, In ImportCell, parsers are now dynamically hooked
    in the importer, allowing third party application (i.e. Chams) to
    add their own. See the ImportCell::addImporter() method.
* Bug: In Unicorn, in FindUNICORN.cmake, seems to be unable to detect
    the UnicornGui.h. Not a blocking problem because the include dir
    is shared with other tools correctly detected. But still...
This commit is contained in:
Jean-Paul Chaput 2015-03-21 17:29:04 +01:00
parent f18922a0bb
commit 69c75b9ea9
13 changed files with 128 additions and 93 deletions

View File

@ -336,10 +336,9 @@ namespace CRL {
ToolEngine* ToolEngine::get ( const Cell* cell, const Name& name ) ToolEngine* ToolEngine::get ( const Cell* cell, const Name& name )
{ {
ToolEnginesRelation* relation = ToolEnginesRelation::getToolEnginesRelation(cell); ToolEnginesRelation* relation = ToolEnginesRelation::getToolEnginesRelation(cell);
if (!relation) if (not relation) {
return NULL; return NULL;
else } else {
{
forEach ( ToolEngine*, itool, relation->getSlaveOwners().getSubSet<ToolEngine*>()) { forEach ( ToolEngine*, itool, relation->getSlaveOwners().getSubSet<ToolEngine*>()) {
if (itool->getName() == name) if (itool->getName() == name)
return *itool; return *itool;

View File

@ -1,15 +1,9 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2010-2010, All Rights Reserved // Copyright (c) UPMC 2010-2015, All Rights Reserved
// //
// =================================================================== // +-----------------------------------------------------------------+
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | C O R I O L I S | // | C O R I O L I S |
// | C a d e n c e D E F I m p o r t e r | // | C a d e n c e D E F I m p o r t e r |
// | | // | |
@ -17,16 +11,13 @@
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Header : "./crlcore/DefImport.h" | // | C++ Header : "./crlcore/DefImport.h" |
// | *************************************************************** | // +-----------------------------------------------------------------+
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#ifndef __CRL_DEF_IMPORT__ #ifndef CRL_DEF_IMPORT_H
#define __CRL_DEF_IMPORT__ #define CRL_DEF_IMPORT_H
#include <string> #include <string>
namespace Hurricane { namespace Hurricane {
class Cell; class Cell;
@ -47,4 +38,4 @@ namespace CRL {
} // End of CRL namespace. } // End of CRL namespace.
#endif // __CRL_DEF_IMPORT__ #endif // CRL_DEF_IMPORT_H

View File

@ -58,11 +58,11 @@
PREFIX "" PREFIX ""
OUTPUT_NAME "Etesian" OUTPUT_NAME "Etesian"
) )
target_link_libraries ( pyEtesian etesian
${CORIOLIS_PYTHON_LIBRARIES}
# add_executable ( etesian.bin ${etesiancpps} ) # add_executable ( etesian.bin ${etesiancpps} )
#target_link_libraries ( etesian.bin etesian ) #target_link_libraries ( etesian.bin etesian )
target_link_libraries ( pyEtesian etesian
${CORIOLIS_PYTHON_LIBRARIES}
) )
install ( TARGETS etesian DESTINATION lib${LIB_SUFFIX} ) install ( TARGETS etesian DESTINATION lib${LIB_SUFFIX} )
# install ( TARGETS etesian.bin DESTINATION bin ) # install ( TARGETS etesian.bin DESTINATION bin )

View File

@ -51,7 +51,6 @@ namespace Etesian {
// Class : "Etesian::EtesianEngine". // Class : "Etesian::EtesianEngine".
class EtesianEngine : public CRL::ToolEngine { class EtesianEngine : public CRL::ToolEngine {
public:
public: public:
static const Name& staticGetName (); static const Name& staticGetName ();
static EtesianEngine* create ( Cell* ); static EtesianEngine* create ( Cell* );

View File

@ -1,7 +1,7 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2015, All Rights Reserved // Copyright (c) UPMC 2008-2015, All Rights Reserved
// //
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
// | H U R R I C A N E | // | H U R R I C A N E |
@ -144,6 +144,8 @@ namespace Hurricane {
void runStressScript (); void runStressScript ();
inline void emitCellAboutToChange (); inline void emitCellAboutToChange ();
inline void emitCellChanged (); inline void emitCellChanged ();
inline void emitCellPreModificated ();
inline void emitCellPostModificated ();
signals: signals:
void showSelectionToggled ( bool ); void showSelectionToggled ( bool );
void stateChanged ( shared_ptr<CellWidget::State>& ); void stateChanged ( shared_ptr<CellWidget::State>& );
@ -190,15 +192,17 @@ namespace Hurricane {
// Inline Functions. // Inline Functions.
inline bool CellViewer::isToolInterrupted () const { return _toolInterrupt; } inline bool CellViewer::isToolInterrupted () const { return _toolInterrupt; }
inline CellObserver* CellViewer::getCellObserver () { return &_cellObserver; } inline CellObserver* CellViewer::getCellObserver () { return &_cellObserver; }
inline CellWidget* CellViewer::getCellWidget () { return _cellWidget; } inline CellWidget* CellViewer::getCellWidget () { return _cellWidget; }
inline const CellWidget* CellViewer::getCellWidget () const { return _cellWidget; } inline const CellWidget* CellViewer::getCellWidget () const { return _cellWidget; }
inline ControllerWidget* CellViewer::getControllerWidget () { return _controller; } inline ControllerWidget* CellViewer::getControllerWidget () { return _controller; }
inline void CellViewer::setApplicationName ( const QString& name ) { _applicationName = name; } inline void CellViewer::setApplicationName ( const QString& name ) { _applicationName = name; }
inline void CellViewer::setLayerVisible ( const Name& layer, bool visible ) { _cellWidget->setLayerVisible(layer,visible); } inline void CellViewer::setLayerVisible ( const Name& layer, bool visible ) { _cellWidget->setLayerVisible(layer,visible); }
inline void CellViewer::emitCellAboutToChange () { _flags |= InCellChange; emit cellPreModificated(); } inline void CellViewer::emitCellAboutToChange () { _flags |= InCellChange; emit cellPreModificated(); }
inline void CellViewer::emitCellChanged () { _flags &= ~InCellChange; emit cellPostModificated(); } inline void CellViewer::emitCellChanged () { _flags &= ~InCellChange; emit cellPostModificated(); }
inline void CellViewer::emitCellPreModificated () { emit cellPreModificated(); }
inline void CellViewer::emitCellPostModificated () { emit cellPostModificated(); }
inline void CellViewer::setEnableRedrawInterrupt ( bool state ) inline void CellViewer::setEnableRedrawInterrupt ( bool state )
{ _cellWidget->setEnableRedrawInterrupt(state); } { _cellWidget->setEnableRedrawInterrupt(state); }

View File

@ -35,6 +35,7 @@
#find_package(SOLSTICE REQUIRED) #find_package(SOLSTICE REQUIRED)
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(cmake_modules)
if(BUILD_DOC) if(BUILD_DOC)
find_package(Doxygen REQUIRED) find_package(Doxygen REQUIRED)

View File

@ -15,7 +15,7 @@ IF(UNIX)
# #
# Look for an installation. # Look for an installation.
# #
FIND_PATH(UNICORN_INCLUDE_PATH NAMES unicorn/UnicornEngine.h PATHS FIND_PATH(UNICORN_INCLUDE_PATH NAMES unicorn/UnicornGui.h PATHS
# Look in other places. # Look in other places.
${CORIOLIS_DIR_SEARCH} ${CORIOLIS_DIR_SEARCH}
PATH_SUFFIXES include/coriolis PATH_SUFFIXES include/coriolis

View File

@ -1,7 +1,7 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2014-2015, All Rights Reserved // Copyright (c) UPMC 2014-2015, All Rights Reserved
// //
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
// | C O R I O L I S | // | C O R I O L I S |
@ -16,12 +16,8 @@
#include <iostream> #include <iostream>
#include "hurricane/Error.h" #include "hurricane/Error.h"
#include "crlcore/AcmSigda.h"
#include "crlcore/Ispd04Bookshelf.h"
#include "crlcore/Ispd05Bookshelf.h"
#include "crlcore/Iccad04Lefdef.h"
#include "crlcore/DefImport.h"
#include "unicorn/ImportCell.h" #include "unicorn/ImportCell.h"
#include "unicorn/ImportCellDialog.h"
namespace Unicorn { namespace Unicorn {
@ -31,35 +27,34 @@ namespace Unicorn {
using std::string; using std::string;
using Hurricane::Error; using Hurricane::Error;
using Hurricane::Cell; using Hurricane::Cell;
using CRL::AcmSigda;
using CRL::Ispd04;
using CRL::Ispd05; ImportCell::ImportCell ()
using CRL::Iccad04Lefdef; : _count (0)
using CRL::DefImport; , _lut ()
, _dialog(NULL)
{ }
void ImportCell::addImporter ( std::string menuName, std::function<Cell*(std::string)> callback )
{
_lut.insert( make_pair( _count, make_pair(menuName,callback) ) );
_dialog->addFormat( menuName.c_str(), _count++ );
}
Cell* ImportCell::load ( const string& cellName, int format ) Cell* ImportCell::load ( const string& cellName, int format )
{ {
Cell* cell = NULL; Cell* cell = NULL;
switch ( format ) { ImportLut::iterator iimport = _lut.find( format );
case AcmSigda: if (iimport == _lut.end()) {
cell = AcmSigda::load( cellName ); cerr << Error( "Importer id:%d for cell %s not found.", format, cellName.c_str() ) << endl;
break; return NULL;
case Ispd04:
cell = Ispd04::load( cellName );
break;
case Ispd05:
cell = Ispd05::load( cellName );
break;
case Iccad04:
cell = Iccad04Lefdef::load( cellName, 0 );
break;
case AllianceDef:
cell = DefImport::load( cellName.c_str() , DefImport::FitAbOnCells );
break;
} }
cell = iimport->second.second( cellName );
if (not cell) { if (not cell) {
cerr << Error( "Cell not found: %s", cellName.c_str() ) << endl; cerr << Error( "Cell not found: %s", cellName.c_str() ) << endl;
} }

View File

@ -81,11 +81,13 @@ namespace Unicorn {
formatLabel->setFont ( Graphics::getNormalFont(true) ); formatLabel->setFont ( Graphics::getNormalFont(true) );
hLayout2->addWidget ( formatLabel ); hLayout2->addWidget ( formatLabel );
#if 0
_formatComboBox->addItem ( tr("ACM/SIGDA (aka MCNC, .bench)"), ImportCell::AcmSigda ); _formatComboBox->addItem ( tr("ACM/SIGDA (aka MCNC, .bench)"), ImportCell::AcmSigda );
_formatComboBox->addItem ( tr("ISPD'04 (Bookshelf)") , ImportCell::Ispd04 ); _formatComboBox->addItem ( tr("ISPD'04 (Bookshelf)") , ImportCell::Ispd04 );
_formatComboBox->addItem ( tr("ISPD'05 (Bookshelf)") , ImportCell::Ispd05 ); _formatComboBox->addItem ( tr("ISPD'05 (Bookshelf)") , ImportCell::Ispd05 );
_formatComboBox->addItem ( tr("ICCAD'04 (LEF/DEF)") , ImportCell::Iccad04 ); _formatComboBox->addItem ( tr("ICCAD'04 (LEF/DEF)") , ImportCell::Iccad04 );
_formatComboBox->addItem ( tr("Alliance compliant DEF") , ImportCell::AllianceDef ); _formatComboBox->addItem ( tr("Alliance compliant DEF") , ImportCell::AllianceDef );
#endif
hLayout2->addWidget ( _formatComboBox ); hLayout2->addWidget ( _formatComboBox );
QVBoxLayout* vLayout = new QVBoxLayout (); QVBoxLayout* vLayout = new QVBoxLayout ();
@ -105,6 +107,12 @@ namespace Unicorn {
} }
void ImportCellDialog::addFormat ( QString menuName, int index )
{
_formatComboBox->addItem( menuName, index );
}
const QString ImportCellDialog::getCellName () const const QString ImportCellDialog::getCellName () const
{ return _lineEdit->text(); } { return _lineEdit->text(); }

View File

@ -25,6 +25,11 @@
#include "crlcore/Catalog.h" #include "crlcore/Catalog.h"
#include "crlcore/AllianceFramework.h" #include "crlcore/AllianceFramework.h"
#include "crlcore/GraphicToolEngine.h" #include "crlcore/GraphicToolEngine.h"
#include "crlcore/AcmSigda.h"
#include "crlcore/Ispd04Bookshelf.h"
#include "crlcore/Ispd05Bookshelf.h"
#include "crlcore/Iccad04Lefdef.h"
#include "crlcore/DefImport.h"
#include "crlcore/DefExport.h" #include "crlcore/DefExport.h"
#include "crlcore/GdsDriver.h" #include "crlcore/GdsDriver.h"
#include "unicorn/ImportCell.h" #include "unicorn/ImportCell.h"
@ -43,6 +48,11 @@ namespace Unicorn {
using CRL::System; using CRL::System;
using CRL::Catalog; using CRL::Catalog;
using CRL::AllianceFramework; using CRL::AllianceFramework;
using CRL::AcmSigda;
using CRL::Ispd04;
using CRL::Ispd05;
using CRL::Iccad04Lefdef;
using CRL::DefImport;
using CRL::DefExport; using CRL::DefExport;
using CRL::GdsDriver; using CRL::GdsDriver;
@ -61,16 +71,24 @@ namespace Unicorn {
UnicornGui::UnicornGui ( QWidget* parent ) UnicornGui::UnicornGui ( QWidget* parent )
: CellViewer (parent) : CellViewer (parent)
, _tools () , _tools ()
, _importDialog(new ImportCellDialog(this)) , _importCell ()
, _exportDialog(new ExportCellDialog(this)) , _importDialog (new ImportCellDialog(this))
, _exportDialog (new ExportCellDialog(this))
{ {
addMenu ( "placeAndRoute" , "P&&R" , CellViewer::TopMenu ); addMenu ( "placeAndRoute" , "P&&R" , CellViewer::TopMenu );
addMenu ( "placeAndRoute.stepByStep", "&Step by Step" ); addMenu ( "placeAndRoute.stepByStep", "&Step by Step" );
addToMenu( "placeAndRoute.========" ); addToMenu( "placeAndRoute.========" );
_runUnicornInit(); _runUnicornInit();
_importCell.setDialog( _importDialog );
_importCell.addImporter( "ACM/SIGDA (aka MCNC, .bench)", std::bind( &AcmSigda::load , placeholders::_1 ) );
_importCell.addImporter( "ISPD'04 (Bookshelf)" , std::bind( &Ispd04::load , placeholders::_1 ) );
_importCell.addImporter( "ISPD'05 (Bookshelf)" , std::bind( &Ispd05::load , placeholders::_1 ) );
_importCell.addImporter( "ICCAD'04 (LEF/DEF)" , std::bind( &Iccad04Lefdef::load, placeholders::_1, 0 ) );
_importCell.addImporter( "Alliance compliant DEF" , std::bind( &DefImport::load , placeholders::_1, DefImport::FitAbOnCells) );
} }
@ -210,7 +228,7 @@ namespace Unicorn {
int format; int format;
if ( _importDialog->runDialog( cellName, format, newViewer ) ) { if ( _importDialog->runDialog( cellName, format, newViewer ) ) {
Cell* cell = ImportCell::load( cellName.toStdString(), format ); Cell* cell = _importCell.load( cellName.toStdString(), format );
if (cell) { if (cell) {
UnicornGui* viewer = this; UnicornGui* viewer = this;

View File

@ -18,6 +18,8 @@
#define UNICORN_IMPORT_CELL_H #define UNICORN_IMPORT_CELL_H
#include <string> #include <string>
#include <map>
#include <functional>
namespace Hurricane { namespace Hurricane {
class Cell; class Cell;
@ -25,15 +27,27 @@ namespace Hurricane {
namespace Unicorn { namespace Unicorn {
class ImportCellDialog;
class ImportCell { class ImportCell {
public: public:
enum Formats { AcmSigda=1, Ispd04, Ispd05, Iccad04, AllianceDef }; typedef std::map< int, std::pair< std::string, std::function<Hurricane::Cell*(std::string)> > > ImportLut;
public: public:
static Hurricane::Cell* load ( const std::string&, int format ); ImportCell ();
inline void setDialog ( ImportCellDialog* );
Hurricane::Cell* load ( const std::string&, int format );
void addImporter ( std::string, std::function<Hurricane::Cell*(std::string)> );
private:
int _count;
ImportLut _lut;
ImportCellDialog* _dialog;
}; };
inline void ImportCell::setDialog ( ImportCellDialog* dialog ) { _dialog = dialog; }
} // Unicorn namespace. } // Unicorn namespace.
#endif #endif

View File

@ -10,7 +10,7 @@
// | Author : Jean-Paul CHAPUT | // | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Header : "./ImportCellDialog.h" | // | C++ Header : "./unicorn/ImportCellDialog.h" |
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
@ -32,6 +32,7 @@ namespace Unicorn {
public: public:
ImportCellDialog ( QWidget* parent=NULL ); ImportCellDialog ( QWidget* parent=NULL );
void addFormat ( QString menuName, int index );
bool runDialog ( QString& name, int& format, bool& newViewerRequest ); bool runDialog ( QString& name, int& format, bool& newViewerRequest );
const QString getCellName () const; const QString getCellName () const;
bool useNewViewer () const; bool useNewViewer () const;

View File

@ -19,16 +19,18 @@
#ifndef UNICORN_UNICORN_H #ifndef UNICORN_UNICORN_H
#define UNICORN_UNICORN_H #define UNICORN_UNICORN_H
#include <set> #include <set>
#include <iostream> #include <iostream>
using namespace std; #include <functional>
#include <boost/any.hpp>
#include "hurricane/viewer/CellViewer.h" #include "hurricane/viewer/CellViewer.h"
#include "crlcore/Banner.h" #include "crlcore/Banner.h"
namespace CRL { namespace CRL {
class GraphicTool; class GraphicTool;
} }
#include "unicorn/ImportCell.h"
namespace Unicorn { namespace Unicorn {
@ -46,32 +48,35 @@ namespace Unicorn {
class UnicornGui : public CellViewer { class UnicornGui : public CellViewer {
Q_OBJECT; Q_OBJECT;
public: public:
static UnicornGui* create ( QWidget* parent=NULL ); static UnicornGui* create ( QWidget* parent=NULL );
void destroy (); void destroy ();
static inline Banner& getBanner (); static inline Banner& getBanner ();
virtual Cell* getCellFromDb ( const char* name ); virtual Cell* getCellFromDb ( const char* name );
void registerTool ( GraphicTool* ); inline ImportCell* getImportCell ();
virtual std::string _getString () const; void registerTool ( GraphicTool* );
public slots: virtual std::string _getString () const;
void openCell (); public slots:
void saveCell (); void openCell ();
void importCell (); void saveCell ();
void exportCell (); void importCell ();
protected: void exportCell ();
UnicornGui ( QWidget* parent ); protected:
virtual ~UnicornGui (); UnicornGui ( QWidget* parent );
virtual void _postCreate (); virtual ~UnicornGui ();
virtual void _preDestroy (); virtual void _postCreate ();
void _runUnicornInit (); virtual void _preDestroy ();
void _runUnicornInit ();
protected: protected:
static Banner _banner; static Banner _banner;
set<GraphicTool*> _tools; set<GraphicTool*> _tools;
ImportCell _importCell;
ImportCellDialog* _importDialog; ImportCellDialog* _importDialog;
ExportCellDialog* _exportDialog; ExportCellDialog* _exportDialog;
}; };
inline Banner& UnicornGui::getBanner () { return _banner; } inline Banner& UnicornGui::getBanner () { return _banner; }
inline ImportCell* UnicornGui::getImportCell () { return &_importCell; }
} // End of Unicorn namespace. } // End of Unicorn namespace.