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 )
{
ToolEnginesRelation* relation = ToolEnginesRelation::getToolEnginesRelation(cell);
if (!relation)
return NULL;
else
{
if (not relation) {
return NULL;
} else {
forEach ( ToolEngine*, itool, relation->getSlaveOwners().getSubSet<ToolEngine*>()) {
if (itool->getName() == name)
return *itool;

View File

@ -1,15 +1,9 @@
// -*- C++ -*-
//
// 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 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 |
// | =============================================================== |
// | C++ Header : "./crlcore/DefImport.h" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
// +-----------------------------------------------------------------+
#ifndef __CRL_DEF_IMPORT__
#define __CRL_DEF_IMPORT__
#ifndef CRL_DEF_IMPORT_H
#define CRL_DEF_IMPORT_H
#include <string>
#include <string>
namespace Hurricane {
class Cell;
@ -47,4 +38,4 @@ namespace CRL {
} // End of CRL namespace.
#endif // __CRL_DEF_IMPORT__
#endif // CRL_DEF_IMPORT_H

View File

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

View File

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

View File

@ -1,7 +1,7 @@
// -*- C++ -*-
//
// 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 |
@ -144,6 +144,8 @@ namespace Hurricane {
void runStressScript ();
inline void emitCellAboutToChange ();
inline void emitCellChanged ();
inline void emitCellPreModificated ();
inline void emitCellPostModificated ();
signals:
void showSelectionToggled ( bool );
void stateChanged ( shared_ptr<CellWidget::State>& );
@ -190,15 +192,17 @@ namespace Hurricane {
// Inline Functions.
inline bool CellViewer::isToolInterrupted () const { return _toolInterrupt; }
inline CellObserver* CellViewer::getCellObserver () { return &_cellObserver; }
inline CellWidget* CellViewer::getCellWidget () { return _cellWidget; }
inline const CellWidget* CellViewer::getCellWidget () const { return _cellWidget; }
inline ControllerWidget* CellViewer::getControllerWidget () { return _controller; }
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::emitCellAboutToChange () { _flags |= InCellChange; emit cellPreModificated(); }
inline void CellViewer::emitCellChanged () { _flags &= ~InCellChange; emit cellPostModificated(); }
inline bool CellViewer::isToolInterrupted () const { return _toolInterrupt; }
inline CellObserver* CellViewer::getCellObserver () { return &_cellObserver; }
inline CellWidget* CellViewer::getCellWidget () { return _cellWidget; }
inline const CellWidget* CellViewer::getCellWidget () const { return _cellWidget; }
inline ControllerWidget* CellViewer::getControllerWidget () { return _controller; }
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::emitCellAboutToChange () { _flags |= InCellChange; emit cellPreModificated(); }
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 )
{ _cellWidget->setEnableRedrawInterrupt(state); }

View File

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

View File

@ -15,7 +15,7 @@ IF(UNIX)
#
# 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.
${CORIOLIS_DIR_SEARCH}
PATH_SUFFIXES include/coriolis

View File

@ -1,7 +1,7 @@
// -*- C++ -*-
//
// 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 |
@ -16,12 +16,8 @@
#include <iostream>
#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/ImportCellDialog.h"
namespace Unicorn {
@ -31,35 +27,34 @@ namespace Unicorn {
using std::string;
using Hurricane::Error;
using Hurricane::Cell;
using CRL::AcmSigda;
using CRL::Ispd04;
using CRL::Ispd05;
using CRL::Iccad04Lefdef;
using CRL::DefImport;
ImportCell::ImportCell ()
: _count (0)
, _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* cell = NULL;
switch ( format ) {
case AcmSigda:
cell = AcmSigda::load( cellName );
break;
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;
ImportLut::iterator iimport = _lut.find( format );
if (iimport == _lut.end()) {
cerr << Error( "Importer id:%d for cell %s not found.", format, cellName.c_str() ) << endl;
return NULL;
}
cell = iimport->second.second( cellName );
if (not cell) {
cerr << Error( "Cell not found: %s", cellName.c_str() ) << endl;
}

View File

@ -81,11 +81,13 @@ namespace Unicorn {
formatLabel->setFont ( Graphics::getNormalFont(true) );
hLayout2->addWidget ( formatLabel );
#if 0
_formatComboBox->addItem ( tr("ACM/SIGDA (aka MCNC, .bench)"), ImportCell::AcmSigda );
_formatComboBox->addItem ( tr("ISPD'04 (Bookshelf)") , ImportCell::Ispd04 );
_formatComboBox->addItem ( tr("ISPD'05 (Bookshelf)") , ImportCell::Ispd05 );
_formatComboBox->addItem ( tr("ICCAD'04 (LEF/DEF)") , ImportCell::Iccad04 );
_formatComboBox->addItem ( tr("Alliance compliant DEF") , ImportCell::AllianceDef );
#endif
hLayout2->addWidget ( _formatComboBox );
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
{ return _lineEdit->text(); }

View File

@ -25,6 +25,11 @@
#include "crlcore/Catalog.h"
#include "crlcore/AllianceFramework.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/GdsDriver.h"
#include "unicorn/ImportCell.h"
@ -43,6 +48,11 @@ namespace Unicorn {
using CRL::System;
using CRL::Catalog;
using CRL::AllianceFramework;
using CRL::AcmSigda;
using CRL::Ispd04;
using CRL::Ispd05;
using CRL::Iccad04Lefdef;
using CRL::DefImport;
using CRL::DefExport;
using CRL::GdsDriver;
@ -61,16 +71,24 @@ namespace Unicorn {
UnicornGui::UnicornGui ( QWidget* parent )
: CellViewer (parent)
, _tools ()
, _importDialog(new ImportCellDialog(this))
, _exportDialog(new ExportCellDialog(this))
: CellViewer (parent)
, _tools ()
, _importCell ()
, _importDialog (new ImportCellDialog(this))
, _exportDialog (new ExportCellDialog(this))
{
addMenu ( "placeAndRoute" , "P&&R" , CellViewer::TopMenu );
addMenu ( "placeAndRoute.stepByStep", "&Step by Step" );
addToMenu( "placeAndRoute.========" );
_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;
if ( _importDialog->runDialog( cellName, format, newViewer ) ) {
Cell* cell = ImportCell::load( cellName.toStdString(), format );
Cell* cell = _importCell.load( cellName.toStdString(), format );
if (cell) {
UnicornGui* viewer = this;

View File

@ -18,6 +18,8 @@
#define UNICORN_IMPORT_CELL_H
#include <string>
#include <map>
#include <functional>
namespace Hurricane {
class Cell;
@ -25,15 +27,27 @@ namespace Hurricane {
namespace Unicorn {
class ImportCellDialog;
class ImportCell {
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:
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.
#endif

View File

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

View File

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