diff --git a/bora/src/DSlicingNode.cpp b/bora/src/DSlicingNode.cpp index 0f4f6a69..d87a6f90 100644 --- a/bora/src/DSlicingNode.cpp +++ b/bora/src/DSlicingNode.cpp @@ -91,7 +91,7 @@ namespace Bora { else if (isAlignTop ()) cerr << "Alignment : Top" << endl; else if (isAlignBottom()) cerr << "Alignment : Bottom" << endl; else cerr << "Alignment : Unknown" << endl; - cerr << "NFingers : " << getNFing() << endl; + cerr << "BoxSetIndex : " << getBoxSetIndex() << endl; if (_instance) cerr << "Instance : " << _instance << endl; else cerr << "Instance : None" << endl; SlicingNode::print(); @@ -112,12 +112,12 @@ namespace Bora { } - void DSlicingNode::setNFing ( int nfing ) - { _boxSet = _nodeSets->find( nfing ); } + void DSlicingNode::setBoxSetIndex ( size_t index ) + { _boxSet = _nodeSets->find( index ); } - int DSlicingNode::getNFing () const - { return (_boxSet) ? _boxSet->getNFing() : 1 ; } + size_t DSlicingNode::getBoxSetIndex () const + { return (_boxSet) ? _boxSet->getIndex() : 0 ; } void DSlicingNode::_place( DbU::Unit x, DbU::Unit y, bool replace ) diff --git a/bora/src/NodeSets.cpp b/bora/src/NodeSets.cpp index faa4a59d..d406c323 100644 --- a/bora/src/NodeSets.cpp +++ b/bora/src/NodeSets.cpp @@ -19,6 +19,7 @@ #include "hurricane/analog/Device.h" #include "hurricane/analog/TransistorFamily.h" #include "hurricane/analog/MultiCapacitor.h" +#include "hurricane/analog/Resistor.h" #include "hurricane/analog/LayoutGenerator.h" #include "crlcore/RoutingGauge.h" @@ -102,7 +103,7 @@ namespace Bora { matrixRange->reset(); do { MatrixParameter* mp = NULL; - if ( (mp = dynamic_cast(mcapacitor->getParameter("Matrix"))) != NULL ) + if ( (mp = dynamic_cast(mcapacitor->getParameter("matrix"))) != NULL ) mp->setMatrix( &matrixRange->getValue() ); layoutGenerator->setDevice( mcapacitor ); @@ -114,7 +115,30 @@ namespace Bora { } while ( matrixRange->isValid() ); } } else { - nodeset->push_back( DBoxSet::create( cell, 0, rg ) ); + ResistorFamily* device = dynamic_cast( cell ); + StepParameterRange* stepRange = dynamic_cast( nodeset->getRange() ); + if (device) { + if (not stepRange) { + throw Error( "NodeSets::create(): Device \"%s\" must be associated with a StepParameterRange argument instead of %s." + , getString(device->getName()).c_str() + , getString(stepRange).c_str() + ); + } + + stepRange->reset(); + do { + device->setBends( stepRange->getValue() ); + + layoutGenerator->setDevice( device ); + layoutGenerator->drawLayout(); + + nodeset->push_back( DBoxSet::create( device, stepRange->getIndex(), rg ) ); + + stepRange->progress(); + } while ( stepRange->isValid() ); + } else { + nodeset->push_back( DBoxSet::create( cell, 0, rg ) ); + } } } @@ -251,11 +275,11 @@ namespace Bora { } - BoxSet* NodeSets::find ( int nfing ) + BoxSet* NodeSets::find ( size_t index ) { size_t i = 0; for ( ; i<_boxSets.size() ; ++i ) { - if (_boxSets[i]->getNFing() == nfing) + if (_boxSets[i]->getIndex() == index) return _boxSets[i]; } diff --git a/bora/src/PyDSlicingNode.cpp b/bora/src/PyDSlicingNode.cpp index eabe3e22..3bb90deb 100644 --- a/bora/src/PyDSlicingNode.cpp +++ b/bora/src/PyDSlicingNode.cpp @@ -96,8 +96,8 @@ extern "C" { } - DirectGetIntAttribute(PyDSlicingNode_getNFing,getNFing,PyDSlicingNode,DSlicingNode) - DirectSetIntAttribute(PyDSlicingNode_setNFing,setNFing,PyDSlicingNode,DSlicingNode) + DirectGetIntAttribute(PyDSlicingNode_getBoxSetIndex,getBoxSetIndex,PyDSlicingNode,DSlicingNode) + DirectSetIntAttribute(PyDSlicingNode_setBoxSetIndex,setBoxSetIndex,PyDSlicingNode,DSlicingNode) // Standart Destroy (Attribute). @@ -105,10 +105,10 @@ extern "C" { // PyDSlicingNode Attribute Method table. PyMethodDef PyDSlicingNode_Methods[] = - { { "create" , (PyCFunction)PyDSlicingNode_create , METH_VARARGS|METH_STATIC + { { "create" , (PyCFunction)PyDSlicingNode_create , METH_VARARGS|METH_STATIC , "Create a new DSlicingNode." } - , { "getNFing" , (PyCFunction)PyDSlicingNode_getNFing , METH_NOARGS , "To be documented." } - , { "setNFing" , (PyCFunction)PyDSlicingNode_setNFing , METH_VARARGS, "To be documented." } + , { "getBoxSetIndex" , (PyCFunction)PyDSlicingNode_getBoxSetIndex, METH_NOARGS , "To be documented." } + , { "setBoxSetIndex" , (PyCFunction)PyDSlicingNode_setBoxSetIndex, METH_VARARGS, "To be documented." } , { NULL, NULL, 0, NULL } /* sentinel */ }; diff --git a/bora/src/SlicingNode.cpp b/bora/src/SlicingNode.cpp index 0959c9a1..caf1d4b8 100644 --- a/bora/src/SlicingNode.cpp +++ b/bora/src/SlicingNode.cpp @@ -812,13 +812,13 @@ namespace Bora { } - void SlicingNode::setNFing ( int ) - { cerr << Error( "SlicingNode::setNFing(): Base class method must never be called." ) << endl; } + void SlicingNode::setBoxSetIndex ( size_t ) + { cerr << Error( "SlicingNode::setBoxSetIndex(): Base class method must never be called." ) << endl; } - int SlicingNode::getNFing () const + size_t SlicingNode::getBoxSetIndex () const { - cerr << Error( "SlicingNode::getNFing(): Base class method must never be called." ) << endl; + cerr << Error( "SlicingNode::getBoxSetIndex(): Base class method must never be called." ) << endl; return 0; } diff --git a/bora/src/bora/DSlicingNode.h b/bora/src/bora/DSlicingNode.h index 0df6a6e3..833981f5 100644 --- a/bora/src/bora/DSlicingNode.h +++ b/bora/src/bora/DSlicingNode.h @@ -49,8 +49,8 @@ namespace Bora { void print () const; DSlicingNode* clone ( unsigned int tr=None ); inline double getDevicesArea () const; - void setNFing ( int ); - int getNFing () const; + void setBoxSetIndex ( size_t ); + size_t getBoxSetIndex () const; inline Instance* getInstance () const; inline void setInstance ( Instance* ); void place ( DbU::Unit x=0, DbU::Unit y=0 ); diff --git a/bora/src/bora/NodeSets.h b/bora/src/bora/NodeSets.h index 4ab5c7fc..c0a32025 100644 --- a/bora/src/bora/NodeSets.h +++ b/bora/src/bora/NodeSets.h @@ -71,7 +71,7 @@ namespace Bora { size_t findIndex ( DbU::Unit height, DbU::Unit width ) const; BoxSet* find ( DbU::Unit height, DbU::Unit width ); BoxSet* find ( BoxSet* boxSet ); - BoxSet* find ( int nfing ); + BoxSet* find ( size_t index ); void print () const; bool compare ( NodeSets nodeSets2, unsigned int flags=NoFlags ) const; void push_back ( BoxSet* boxSet ); diff --git a/bora/src/bora/SlicingNode.h b/bora/src/bora/SlicingNode.h index ed8de98a..df50a2ac 100644 --- a/bora/src/bora/SlicingNode.h +++ b/bora/src/bora/SlicingNode.h @@ -251,8 +251,8 @@ namespace Bora { virtual SlicingNode* clone ( unsigned int tr=None ); virtual double getDevicesArea () const; virtual double getOccupationArea () const; - virtual void setNFing ( int ); - virtual int getNFing () const; + virtual void setBoxSetIndex ( size_t ); + virtual size_t getBoxSetIndex () const; virtual Instance* getInstance () const; virtual void setInstance ( Instance* ); virtual bool checkCellInstances ( Cell* ); diff --git a/crlcore/etc/node180/scn6m_deep_09/devices.py b/crlcore/etc/node180/scn6m_deep_09/devices.py index 1405c70b..e3e4d0a0 100644 --- a/crlcore/etc/node180/scn6m_deep_09/devices.py +++ b/crlcore/etc/node180/scn6m_deep_09/devices.py @@ -124,7 +124,13 @@ addDevice( name = 'SimpleCurrentMirrorBulkUnconnected' addDevice( name = 'MultiCapacitor' #, spice = spiceDir+'MIM_OneCapacitor.spi' #, connectors = ( 'T1', 'B1' ) - , layouts = ( ('Matrix' , 'CapacitorMatrix.py' ), + , layouts = ( ('Matrix', 'CapacitorMatrix.py' ), + ) + ) +addDevice( name = 'Resistor' + #, spice = spiceDir+'MIM_OneCapacitor.spi' + , connectors = ( 'PIN1', 'PIN2' ) + , layouts = ( ('Snake', 'ResistorSnake.py' ), ) ) diff --git a/hurricane/src/analog/CMakeLists.txt b/hurricane/src/analog/CMakeLists.txt index dc335a30..6434b401 100644 --- a/hurricane/src/analog/CMakeLists.txt +++ b/hurricane/src/analog/CMakeLists.txt @@ -13,6 +13,14 @@ ) set( cpps AnalogCellExtension.cpp + Parameter.cpp + CapacitiesParameter.cpp + FormFactorParameter.cpp + ChoiceParameter.cpp + FloatParameter.cpp + MatrixParameter.cpp + MCheckBoxParameter.cpp + StepParameter.cpp BJT.cpp BJTFamily.cpp BJTFamilyNames.cpp @@ -38,6 +46,9 @@ TransistorFamilyNames.cpp TransistorPair.cpp MultiCapacitor.cpp + MetaResistor.cpp + ResistorFamily.cpp + Resistor.cpp ) set( pyCpps PyAnalog.cpp PyCapacitorFamily.cpp @@ -60,12 +71,15 @@ PySimpleCurrentMirror.cpp PySpinBoxParameter.cpp PyStepParameter.cpp + PyFloatParameter.cpp PyTransistor.cpp PyTransistorFamily.cpp PyTransistorPair.cpp PyMatrixParameter.cpp PyCapacitiesParameter.cpp PyMultiCapacitor.cpp + PyResistorFamily.cpp + PyResistor.cpp ) set( includes hurricane/analog/AnalogCellExtension.h hurricane/analog/BJTFamily.h @@ -94,6 +108,7 @@ hurricane/analog/SimpleCurrentMirror.h hurricane/analog/SpinBoxParameter.h hurricane/analog/StepParameter.h + hurricane/analog/FloatParameter.h hurricane/analog/TransistorFamily.h hurricane/analog/TransistorFamilyNames.h hurricane/analog/Transistor.h @@ -102,6 +117,9 @@ hurricane/analog/CapacitiesParameter.h hurricane/analog/MultiCapacitor.h hurricane/analog/Matrix.h + hurricane/analog/MetaResistor.h + hurricane/analog/ResistorFamily.h + hurricane/analog/Resistor.h ) set( pyIncludes hurricane/analog/PyCapacitorFamily.h hurricane/analog/PyCapacitorParameter.h @@ -123,11 +141,14 @@ hurricane/analog/PySimpleCurrentMirror.h hurricane/analog/PySpinBoxParameter.h hurricane/analog/PyStepParameter.h + hurricane/analog/PyFloatParameter.h hurricane/analog/PyTransistorFamily.h hurricane/analog/PyTransistor.h hurricane/analog/PyTransistorPair.h hurricane/analog/PyMatrixParameter.h hurricane/analog/PyCapacitiesParameter.h + hurricane/analog/PyResistorFamily.h + hurricane/analog/PyResistor.h ) set( depLibs viewer diff --git a/hurricane/src/analog/CapacitiesParameter.cpp b/hurricane/src/analog/CapacitiesParameter.cpp new file mode 100644 index 00000000..84a18431 --- /dev/null +++ b/hurricane/src/analog/CapacitiesParameter.cpp @@ -0,0 +1,52 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2009-2019, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | H u r r i c a n e A n a l o g | +// | | +// | Authors : Christophe Alexandre | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Module : "./CapacitiesParameter.cpp" | +// +-----------------------------------------------------------------+ + + +#include "hurricane/analog/CapacitiesParameter.h" + + +namespace Analog { + + using std::string; + + + string CapacitiesParameter::_getTypeName () const + { return "CapacitiesParameter"; } + + + std::string CapacitiesParameter::_getString () const + { + string s = Super::_getString(); + s.insert( s.size()-1, " [" ); + for ( size_t i=0 ; i<_values.size() ; ++i ) { + if (i) s.insert( s.size()-1, " " ); + s.insert( s.size()-1, getString(_values[i]) ); + } + s.insert( s.size()-1, "]" ); + return s; + } + + + Record* CapacitiesParameter::_getRecord () const + { + Record* record = Super::_getRecord(); + record->add( getSlot( "_values", &_values ) ); + return record; + } + + + + +} // Analog namespace. diff --git a/hurricane/src/analog/ChoiceParameter.cpp b/hurricane/src/analog/ChoiceParameter.cpp index b413285d..738f4bae 100644 --- a/hurricane/src/analog/ChoiceParameter.cpp +++ b/hurricane/src/analog/ChoiceParameter.cpp @@ -39,5 +39,26 @@ namespace Analog { return _choices._values[ _value ]; } + + std::string ChoiceParameter::_getTypeName () const + { return "ChoiceParameter"; } + + + std::string ChoiceParameter::_getString () const + { + string s = Super::_getString(); + s.insert( s.size()-1, " "+getString(_value) ); + return s; + } + + + Record* ChoiceParameter::_getRecord () const + { + Record* record = Super::_getRecord(); + record->add( getSlot( "_choices", &_choices ) ); + record->add( getSlot( "_value" , &_value ) ); + return record; + } + } // Analog namespace. diff --git a/hurricane/src/analog/FloatParameter.cpp b/hurricane/src/analog/FloatParameter.cpp new file mode 100644 index 00000000..d9965615 --- /dev/null +++ b/hurricane/src/analog/FloatParameter.cpp @@ -0,0 +1,47 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2009-2019, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | H u r r i c a n e A n a l o g | +// | | +// | Authors : Christophe Alexandre | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Module : "./FloatParameter.cpp" | +// +-----------------------------------------------------------------+ + + +#include "hurricane/analog/FloatParameter.h" + + +namespace Analog { + + using std::string; + + + string FloatParameter::_getTypeName () const + { return "FloatParameter"; } + + + std::string FloatParameter::_getString () const + { + string s = Super::_getString(); + s.insert( s.size()-1, " "+getString(_value) ); + return s; + } + + + Record* FloatParameter::_getRecord () const + { + Record* record = Super::_getRecord(); + record->add( getSlot( "_value", &_value ) ); + return record; + } + + + + +} // Analog namespace. diff --git a/hurricane/src/analog/FormFactorParameter.cpp b/hurricane/src/analog/FormFactorParameter.cpp new file mode 100644 index 00000000..69d51fe3 --- /dev/null +++ b/hurricane/src/analog/FormFactorParameter.cpp @@ -0,0 +1,49 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2009-2019, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | H u r r i c a n e A n a l o g | +// | | +// | Authors : Christophe Alexandre | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Module : "./FormFactorParameter.cpp" | +// +-----------------------------------------------------------------+ + + +#include "hurricane/analog/FormFactorParameter.h" + + +namespace Analog { + + using std::string; + + + string FormFactorParameter::_getTypeName () const + { return "FormFactorParameter"; } + + + std::string FormFactorParameter::_getString () const + { + string s = Super::_getString(); + s.insert( s.size()-1, " "+getString(_value)+" ["+getString(_min)+".."+getString(_max)+"]" ); + return s; + } + + + Record* FormFactorParameter::_getRecord () const + { + Record* record = Super::_getRecord(); + record->add( getSlot( "_min" , &_min ) ); + record->add( getSlot( "_max" , &_max ) ); + record->add( getSlot( "_value", &_value ) ); + return record; + } + + + + +} // Analog namespace. diff --git a/hurricane/src/analog/MCheckBoxParameter.cpp b/hurricane/src/analog/MCheckBoxParameter.cpp new file mode 100644 index 00000000..974751fb --- /dev/null +++ b/hurricane/src/analog/MCheckBoxParameter.cpp @@ -0,0 +1,48 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2009-2019, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | H u r r i c a n e A n a l o g | +// | | +// | Authors : Christophe Alexandre | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Module : "./MCheckBoxParameter.cpp" | +// +-----------------------------------------------------------------+ + + +#include "hurricane/analog/MCheckBoxParameter.h" + + +namespace Analog { + + using std::string; + + + string MCheckBoxParameter::_getTypeName () const + { return "MCheckBoxParameter"; } + + + std::string MCheckBoxParameter::_getString () const + { + string s = Super::_getString(); + s.insert( s.size()-1, " "+getString(_value) ); + return s; + } + + + Record* MCheckBoxParameter::_getRecord () const + { + Record* record = Super::_getRecord(); + record->add( getSlot( "_choices", &_choices ) ); + record->add( getSlot( "_value" , &_value ) ); + return record; + } + + + + +} // Analog namespace. diff --git a/hurricane/src/analog/MatrixParameter.cpp b/hurricane/src/analog/MatrixParameter.cpp new file mode 100644 index 00000000..35f8cb73 --- /dev/null +++ b/hurricane/src/analog/MatrixParameter.cpp @@ -0,0 +1,47 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2009-2019, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | H u r r i c a n e A n a l o g | +// | | +// | Authors : Christophe Alexandre | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Module : "./MatrixParameter.cpp" | +// +-----------------------------------------------------------------+ + + +#include "hurricane/analog/MatrixParameter.h" + + +namespace Analog { + + using std::string; + + + string MatrixParameter::_getTypeName () const + { return "MatrixParameter"; } + + + std::string MatrixParameter::_getString () const + { + string s = Super::_getString(); + s.insert( s.size()-1, " ["+getString(_matrix.rows())+" x "+getString(_matrix.columns())+"]" ); + return s; + } + + + Record* MatrixParameter::_getRecord () const + { + Record* record = Super::_getRecord(); + record->add( getSlot( "_matrix", &_matrix ) ); + return record; + } + + + + +} // Analog namespace. diff --git a/hurricane/src/analog/MetaResistor.cpp b/hurricane/src/analog/MetaResistor.cpp new file mode 100644 index 00000000..32eaf187 --- /dev/null +++ b/hurricane/src/analog/MetaResistor.cpp @@ -0,0 +1,58 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2019-2019, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | H u r r i c a n e A n a l o g | +// | | +// | Authors : Jean-Paul Chaput | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Module : "./MetaResistor.cpp" | +// +-----------------------------------------------------------------+ + + +#include "hurricane/analog/MetaResistor.h" + + +namespace Analog { + + + MetaResistor::MetaResistor ( Library* library, const Name& name ) + : Super(library, name) + , _pin1 (NULL) + , _pin2 (NULL) + , _anonymous(NULL) + , _we (0.0) + , _le (0.0) + , _bends (0) + { } + + + MetaResistor* MetaResistor::create ( Library* library, const Name& name ) + { + MetaResistor* mResistor = new MetaResistor( library, name ); + mResistor->_postCreate(); + + return mResistor; + } + + + void MetaResistor::_postCreate () + { + Super::_postCreate(); + + _pin1 = Net::create(this, "PIN1"); + _pin1->setExternal(true); + _pin2 = Net::create(this, "PIN2"); + _pin2->setExternal(true); + _anonymous = Net::create(this, "Anonymous"); + _anonymous->setAutomatic( true ); + + setTerminal(false); + } + + +} // Analog namespace. diff --git a/hurricane/src/analog/MultiCapacitor.cpp b/hurricane/src/analog/MultiCapacitor.cpp index 5c9b9564..ac494b28 100644 --- a/hurricane/src/analog/MultiCapacitor.cpp +++ b/hurricane/src/analog/MultiCapacitor.cpp @@ -51,7 +51,6 @@ namespace Analog { mc->setTerminal ( true ); UpdateSession::close(); - cerr << "capacities:" << mc->getParameter( "capacities" ) << endl; return mc; } diff --git a/hurricane/src/analog/Parameter.cpp b/hurricane/src/analog/Parameter.cpp new file mode 100644 index 00000000..bbd9b39d --- /dev/null +++ b/hurricane/src/analog/Parameter.cpp @@ -0,0 +1,42 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2009-2019, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | H u r r i c a n e A n a l o g | +// | | +// | Authors : Christophe Alexandre | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Module : "./Parameter.cpp" | +// +-----------------------------------------------------------------+ + + +#include "hurricane/analog/Parameter.h" + + +namespace Analog { + + + Parameter::~Parameter () + { } + + + std::string Parameter::_getString () const + { return "<"+_getTypeName()+" \""+getName()+"\">"; } + + + Record* Parameter::_getRecord () const + { + Record* record = new Record( _getString() ); + record->add( getSlot( "_name" , &_name ) ); + record->add( getSlot( "_index", &_index ) ); + return record; + } + + + + +} // Analog namespace. diff --git a/hurricane/src/analog/PyAnalog.cpp b/hurricane/src/analog/PyAnalog.cpp index 5ba702fb..4781012c 100644 --- a/hurricane/src/analog/PyAnalog.cpp +++ b/hurricane/src/analog/PyAnalog.cpp @@ -31,6 +31,9 @@ #include "hurricane/analog/PyCapacitorFamily.h" #include "hurricane/analog/PyMultiCapacitor.h" +#include "hurricane/analog/PyResistorFamily.h" +#include "hurricane/analog/PyResistor.h" + #include "hurricane/analog/PyMatrix.h" #include "hurricane/analog/PyParameter.h" #include "hurricane/analog/PyChoiceParameter.h" @@ -38,6 +41,7 @@ #include "hurricane/analog/PyMCheckBoxParameter.h" #include "hurricane/analog/PySpinBoxParameter.h" #include "hurricane/analog/PyStepParameter.h" +#include "hurricane/analog/PyFloatParameter.h" #include "hurricane/analog/PyCapacitiesParameter.h" #include "hurricane/analog/PyMatrixParameter.h" #include "hurricane/analog/PyLayoutGenerator.h" @@ -81,6 +85,10 @@ extern "C" { PyLevelShifter_LinkPyType(); PySimpleCurrentMirror_LinkPyType(); PyCascode_LinkPyType(); + PyCapacitorFamily_LinkPyType(); + PyMultiCapacitor_LinkPyType(); + PyResistorFamily_LinkPyType(); + PyResistor_LinkPyType(); PyMatrix_LinkPyType(); PyParameter_LinkPyType(); @@ -89,11 +97,10 @@ extern "C" { PyMCheckBoxParameter_LinkPyType(); PySpinBoxParameter_LinkPyType(); PyStepParameter_LinkPyType(); + PyFloatParameter_LinkPyType(); PyCapacitiesParameter_LinkPyType(); PyMatrixParameter_LinkPyType(); - PyCapacitorFamily_LinkPyType(); PyLayoutGenerator_LinkPyType(); - PyMultiCapacitor_LinkPyType(); PYTYPE_READY( Matrix ) PYTYPE_READY( Parameter ) @@ -114,12 +121,16 @@ extern "C" { PYTYPE_READY_SUB( CapacitorFamily , Device ) PYTYPE_READY_SUB( MultiCapacitor , CapacitorFamily ) + + PYTYPE_READY_SUB( ResistorFamily , Device ) + PYTYPE_READY_SUB( Resistor , ResistorFamily ) PYTYPE_READY_SUB( ChoiceParameter , Parameter ) PYTYPE_READY_SUB( FormFactorParameter , Parameter ) PYTYPE_READY_SUB( MCheckBoxParameter , Parameter ) PYTYPE_READY_SUB( SpinBoxParameter , Parameter ) PYTYPE_READY_SUB( StepParameter , Parameter ) + PYTYPE_READY_SUB( FloatParameter , Parameter ) PYTYPE_READY_SUB( CapacitiesParameter , Parameter ) PYTYPE_READY_SUB( MatrixParameter , Parameter ) @@ -140,6 +151,9 @@ extern "C" { __cs.addType( "cfamily" , &PyTypeCapacitorFamily , "" , false, "device" ); __cs.addType( "mulcapa" , &PyTypeMultiCapacitor , "" , false, "cfamily" ); + __cs.addType( "rfamily" , &PyTypeResistorFamily , "" , false, "device" ); + __cs.addType( "resistor" , &PyTypeResistor , "" , false, "rfamily" ); + __cs.addType( "matrix" , &PyTypeMatrix , "" , false ); __cs.addType( "parameter", &PyTypeParameter , "" , false ); __cs.addType( "choicepar", &PyTypeChoiceParameter , "" , false, "parameter" ); @@ -147,6 +161,7 @@ extern "C" { __cs.addType( "mcboxpar" , &PyTypeMCheckBoxParameter , "" , false, "parameter" ); __cs.addType( "sboxpar" , &PyTypeSpinBoxParameter , "" , false, "parameter" ); __cs.addType( "steppar" , &PyTypeStepParameter , "" , false, "parameter" ); + __cs.addType( "floatpar" , &PyTypeFloatParameter , "" , false, "parameter" ); __cs.addType( "capspar" , &PyTypeCapacitiesParameter , "" , false, "parameter" ); __cs.addType( "matrpar" , &PyTypeMatrixParameter , "" , false, "parameter" ); __cs.addType( "laygen" , &PyTypeLayoutGenerator , "" , false ); @@ -185,9 +200,14 @@ extern "C" { PyModule_AddObject( module, "Cascode" , (PyObject*)&PyTypeCascode ); Py_INCREF( &PyTypeCapacitorFamily ); - PyModule_AddObject( module, "CapacitorFamily" , (PyObject*)&PyTypeCapacitorFamily ); + PyModule_AddObject( module, "CapacitorFamily" , (PyObject*)&PyTypeCapacitorFamily ); Py_INCREF( &PyTypeMultiCapacitor ); - PyModule_AddObject( module, "MultiCapacitor" , (PyObject*)&PyTypeMultiCapacitor ); + PyModule_AddObject( module, "MultiCapacitor" , (PyObject*)&PyTypeMultiCapacitor ); + + Py_INCREF( &PyTypeResistorFamily ); + PyModule_AddObject( module, "ResistorFamily" , (PyObject*)&PyTypeResistorFamily ); + Py_INCREF( &PyTypeResistor ); + PyModule_AddObject( module, "Resistor" , (PyObject*)&PyTypeResistor ); Py_INCREF( &PyTypeMatrix ); PyModule_AddObject( module, "Matrix" , (PyObject*)&PyTypeMatrix ); @@ -202,17 +222,20 @@ extern "C" { Py_INCREF( &PyTypeSpinBoxParameter ); PyModule_AddObject( module, "SpinBoxParameter" , (PyObject*)&PyTypeSpinBoxParameter ); Py_INCREF( &PyTypeStepParameter ); - PyModule_AddObject( module, "CapacitiesParameter", (PyObject*)&PyTypeCapacitiesParameter ); - Py_INCREF( &PyTypeCapacitiesParameter ); - PyModule_AddObject( module, "MatrixParameter" , (PyObject*)&PyTypeMatrixParameter ); - Py_INCREF( &PyTypeMatrixParameter ); PyModule_AddObject( module, "StepParameter" , (PyObject*)&PyTypeStepParameter ); + Py_INCREF( &PyTypeFloatParameter ); + PyModule_AddObject( module, "FloatParameter" , (PyObject*)&PyTypeFloatParameter ); + Py_INCREF( &PyTypeCapacitiesParameter ); + PyModule_AddObject( module, "CapacitiesParameter", (PyObject*)&PyTypeCapacitiesParameter ); + Py_INCREF( &PyTypeMatrixParameter ); + PyModule_AddObject( module, "MatrixParameter" , (PyObject*)&PyTypeMatrixParameter ); Py_INCREF( &PyTypeLayoutGenerator ); PyModule_AddObject( module, "LayoutGenerator" , (PyObject*)&PyTypeLayoutGenerator ); PyDevice_postModuleInit(); PyTransistorFamily_postModuleInit(); PyCapacitorFamily_postModuleInit(); + PyResistorFamily_postModuleInit(); PyParameter_postModuleInit(); PyLayoutGenerator_postModuleInit(); diff --git a/hurricane/src/analog/PyFloatParameter.cpp b/hurricane/src/analog/PyFloatParameter.cpp new file mode 100644 index 00000000..96c51f39 --- /dev/null +++ b/hurricane/src/analog/PyFloatParameter.cpp @@ -0,0 +1,81 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2019-2019, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | H u r r i c a n e A n a l o g | +// | | +// | Author : Jean-Paul Chaput | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Module : "./PyFloatParameter.cpp" | +// +-----------------------------------------------------------------+ + + +#include "hurricane/analog/PyFloatParameter.h" + + +namespace Isobar { + +using namespace Hurricane; +using namespace Analog; + +extern "C" { + + +#undef ACCESS_OBJECT +#undef ACCESS_CLASS +#define ACCESS_OBJECT _baseObject._object +#define ACCESS_CLASS(_pyObject) &(_pyObject->_baseObject) +#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(FloatParameter,stepParameter,function) + +#if defined(__PYTHON_MODULE__) + +// +=================================================================+ +// | "PyFloatParameter" Python Module Code Part | +// +=================================================================+ + + + DirectGetDoubleAttribute(PyFloatParameter_getValue, getValue, PyFloatParameter, FloatParameter) + DirectSetDoubleAttribute(PyFloatParameter_setValue, setValue, PyFloatParameter, FloatParameter) + + + // --------------------------------------------------------------- + // PyFloatParameter Attribute Method table. + + PyMethodDef PyFloatParameter_Methods[] = + { { "getValue" , (PyCFunction)PyFloatParameter_getValue, METH_NOARGS + , "Self explanatory." } + , { "setValue" , (PyCFunction)PyFloatParameter_setValue, METH_VARARGS + , "Self explanatory." } + , { NULL, NULL, 0, NULL } /* sentinel */ + }; + + + // +-------------------------------------------------------------+ + // | "PyFloatParameter" Object Methods | + // +-------------------------------------------------------------+ + + + PythonOnlyDeleteMethod(FloatParameter) + PyTypeObjectLinkPyType(FloatParameter) + + +#else // End of Python Module Code Part. + +// +=================================================================+ +// | "PyFloatParameter" Shared Library Code Part | +// +=================================================================+ + + + LinkCreateMethod(FloatParameter) + PyTypeInheritedObjectDefinitions(FloatParameter, Parameter) + + +#endif // End of Shared Library Code Part. + +} // extern "C". + +} // Isobar namespace. diff --git a/hurricane/src/analog/PyParameter.cpp b/hurricane/src/analog/PyParameter.cpp index 4335ac35..a2ec1103 100644 --- a/hurricane/src/analog/PyParameter.cpp +++ b/hurricane/src/analog/PyParameter.cpp @@ -22,6 +22,7 @@ #include "hurricane/analog/PyMCheckBoxParameter.h" #include "hurricane/analog/PySpinBoxParameter.h" #include "hurricane/analog/PyStepParameter.h" +#include "hurricane/analog/PyFloatParameter.h" namespace Isobar { @@ -120,6 +121,9 @@ extern "C" { StepParameter* stepParameter = dynamic_cast(object); if (stepParameter) return PyStepParameter_Link(stepParameter); + FloatParameter* floatParameter = dynamic_cast(object); + if (floatParameter) return PyFloatParameter_Link(floatParameter); + Py_RETURN_NONE; } diff --git a/hurricane/src/analog/PyResistor.cpp b/hurricane/src/analog/PyResistor.cpp new file mode 100644 index 00000000..42019587 --- /dev/null +++ b/hurricane/src/analog/PyResistor.cpp @@ -0,0 +1,127 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2019-2019, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | H u r r i c a n e A n a l o g | +// | | +// | Author : Jean-Paul Chaput | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Module : "./PyResistor.cpp" | +// +-----------------------------------------------------------------+ + + +#include "hurricane/isobar/PyLibrary.h" +#include "hurricane/analog/PyResistor.h" + + +namespace Isobar { + +using namespace Hurricane; +using namespace Analog; + +extern "C" { + + +#undef ACCESS_OBJECT +#undef ACCESS_CLASS +#define ACCESS_OBJECT _baseObject._baseObject._baseObject._baseObject._object +#define ACCESS_CLASS(_pyObject) &(_pyObject->_baseObject._baseObject._baseObject._baseObject) +#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(Resistor,resistor,function) + +#if defined(__PYTHON_MODULE__) + +// +=================================================================+ +// | "PyResistor" Python Module Code Part | +// +=================================================================+ + + + static PyObject* PyResistor_create ( PyObject*, PyObject* args ) + { + cdebug.log(49) << "PyResistor_create()" << endl; + + Resistor* resistor = NULL; + + HTRY + PyObject* pyLibrary = NULL; + char* name = NULL; + long pyType = 0; + + if (PyArg_ParseTuple( args + , "Osl:Resistor.create" + , &pyLibrary + , &name + , &pyType + )) { + if (not IsPyLibrary(pyLibrary)) { + PyErr_SetString ( ConstructorError, "Resistor.create(): First argument is not of type Library." ); + return NULL; + } + switch ( pyType ) { + case Resistor::LOWRES: + case Resistor::HIRES: break; + default: + PyErr_SetString ( ConstructorError, "Resistor.create(): Type argument is neither LOWRES nor HIRES." ); + return NULL; + } + + resistor = Resistor::create( PYLIBRARY_O(pyLibrary) + , Name(name) + , (Resistor::Type)pyType + ); + } else { + PyErr_SetString ( ConstructorError, "Bad parameters given to Resistor.create()." ); + return NULL; + } + HCATCH + + return PyResistor_Link(resistor); + } + + + // Standart Destroy (Attribute). + DBoDestroyAttribute(PyResistor_destroy, PyResistor) + + //GetNameMethod(Resistor, device) + + + // --------------------------------------------------------------- + // PyResistor Attribute Method table. + + PyMethodDef PyResistor_Methods[] = + { { "create" , (PyCFunction)PyResistor_create , METH_VARARGS|METH_STATIC + , "Create an anlogic device made of one resistor." } + , { "destroy" , (PyCFunction)PyResistor_destroy , METH_NOARGS + , "Destroys associated hurricane object, the python object remains." } + , { NULL, NULL, 0, NULL } /* sentinel */ + }; + + + // +-------------------------------------------------------------+ + // | "PyResistor" Object Methods | + // +-------------------------------------------------------------+ + + + DBoDeleteMethod(Resistor) + PyTypeObjectLinkPyType(Resistor) + + +#else // End of Python Module Code Part. + +// +=================================================================+ +// | "PyResistor" Shared Library Code Part | +// +=================================================================+ + + + DBoLinkCreateMethod(Resistor) + PyTypeInheritedObjectDefinitions(Resistor, ResistorFamily) + + +#endif // End of Shared Library Code Part. + +} // extern "C". + +} // Isobar namespace. diff --git a/hurricane/src/analog/PyResistorFamily.cpp b/hurricane/src/analog/PyResistorFamily.cpp new file mode 100644 index 00000000..26310249 --- /dev/null +++ b/hurricane/src/analog/PyResistorFamily.cpp @@ -0,0 +1,138 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2019-2019, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | H u r r i c a n e A n a l o g | +// | | +// | Author : Jean-Paul Chaput | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Module : "./PyResistorFamily.cpp" | +// +-----------------------------------------------------------------+ + + +#include "hurricane/analog/PyResistorFamily.h" + + +namespace Isobar { + +using namespace Hurricane; +using namespace Analog; + +extern "C" { + + +#undef ACCESS_OBJECT +#undef ACCESS_CLASS +#define ACCESS_OBJECT _baseObject._baseObject._baseObject._object +#define ACCESS_CLASS(_pyObject) &(_pyObject->_baseObject._baseObject._baseObject) +#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(ResistorFamily,family,function) + +#if defined(__PYTHON_MODULE__) + +// +=================================================================+ +// | "PyResistorFamily" Python Module Code Part | +// +=================================================================+ + + + static PyObject* PyResistorFamily_getType ( PyResistorFamily* self ) + { + ResistorFamily::Type type = ResistorFamily::LOWRES; + + HTRY + METHOD_HEAD ( "ResistorFamily.getType()" ) + type = family->getType(); + HCATCH + + return Py_BuildValue( "i", (int)type ); + } + + + DirectGetBoolAttribute (PyResistorFamily_isLOWRES,isLOWRES,PyResistorFamily,ResistorFamily) + DirectGetBoolAttribute (PyResistorFamily_isHIRES ,isHIRES ,PyResistorFamily,ResistorFamily) + DirectGetIntAttribute (PyResistorFamily_getBends,getBends,PyResistorFamily,ResistorFamily) + DirectGetLongAttribute (PyResistorFamily_getW ,getW ,PyResistorFamily,ResistorFamily) + DirectGetLongAttribute (PyResistorFamily_getL ,getL ,PyResistorFamily,ResistorFamily) + + DirectSetIntAttribute (PyResistorFamily_setBends,setBends,PyResistorFamily,ResistorFamily) + + DirectGetDoubleAttribute(PyResistorFamily_getR ,getR ,PyResistorFamily,ResistorFamily) + DirectGetDoubleAttribute(PyResistorFamily_getWE ,getWE ,PyResistorFamily,ResistorFamily) + DirectGetDoubleAttribute(PyResistorFamily_getLE ,getLE ,PyResistorFamily,ResistorFamily) + + DirectSetDoubleAttribute(PyResistorFamily_setR ,setR ,PyResistorFamily,ResistorFamily) + DirectSetDoubleAttribute(PyResistorFamily_setWE ,setWE ,PyResistorFamily,ResistorFamily) + DirectSetDoubleAttribute(PyResistorFamily_setLE ,setLE ,PyResistorFamily,ResistorFamily) + + + // --------------------------------------------------------------- + // PyResistorFamily Attribute Method table. + + PyMethodDef PyResistorFamily_Methods[] = + { { "getType" , (PyCFunction)PyResistorFamily_getType , METH_NOARGS + , "Returns the type of the resistor (as a numric constant)." } + , { "isLOWRES" , (PyCFunction)PyResistorFamily_isLOWRES , METH_NOARGS + , "Returns True if it is a LOWRES resistor." } + , { "isHIRES" , (PyCFunction)PyResistorFamily_isHIRES , METH_NOARGS + , "Returns True if it is a HIRES resistor." } + , { "getBends" , (PyCFunction)PyResistorFamily_getBends , METH_NOARGS + , "Self explanatory." } + , { "getW" , (PyCFunction)PyResistorFamily_getW , METH_NOARGS + , "Resistor effective W in the layout." } + , { "getL" , (PyCFunction)PyResistorFamily_getL , METH_NOARGS + , "Resistor effective L in the layout." } + , { "getR" , (PyCFunction)PyResistorFamily_getR , METH_NOARGS + , "Resistor effective R." } + , { "setBends" , (PyCFunction)PyResistorFamily_setBends , METH_VARARGS + , "Self explanatory." } + , { "getWE" , (PyCFunction)PyResistorFamily_getWE , METH_NOARGS + , "Resistor electrical W (requested)." } + , { "getLE" , (PyCFunction)PyResistorFamily_getLE , METH_NOARGS + , "Resistor electrical L (requested)." } + , { "setWE" , (PyCFunction)PyResistorFamily_setWE , METH_VARARGS + , "Resistor electrical W (requested)." } + , { "setLE" , (PyCFunction)PyResistorFamily_setLE , METH_VARARGS + , "Resistor electrical L (requested)." } + , { "setR" , (PyCFunction)PyResistorFamily_setR , METH_VARARGS + , "Resistor electrical R." } + , { NULL, NULL, 0, NULL } /* sentinel */ + }; + + + // +-------------------------------------------------------------+ + // | "PyResistorFamily" Object Methods | + // +-------------------------------------------------------------+ + + + DBoDeleteMethod(ResistorFamily) + PyTypeObjectLinkPyType(ResistorFamily) + + +#else // End of Python Module Code Part. + +// +=================================================================+ +// | "PyResistorFamily" Shared Library Code Part | +// +=================================================================+ + + + DBoLinkCreateMethod(ResistorFamily) + PyTypeInheritedObjectDefinitions(ResistorFamily, Device) + + + extern void PyResistorFamily_postModuleInit () + { + PyObject* constant; + + LoadObjectConstant(PyTypeResistorFamily.tp_dict,ResistorFamily::LOWRES,"LOWRES"); + LoadObjectConstant(PyTypeResistorFamily.tp_dict,ResistorFamily::HIRES ,"HIRES" ); + } + + +#endif // End of Shared Library Code Part. + +} // extern "C". + +} // Isobar namespace. diff --git a/hurricane/src/analog/Resistor.cpp b/hurricane/src/analog/Resistor.cpp new file mode 100644 index 00000000..de9daff5 --- /dev/null +++ b/hurricane/src/analog/Resistor.cpp @@ -0,0 +1,133 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2019-2019, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | H u r r i c a n e A n a l o g | +// | | +// | Authors : Jean-Paul Chaput | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Module : "./Resistor.cpp" | +// +-----------------------------------------------------------------+ + + +#include +#include +#include "hurricane/Warning.h" +#include "hurricane/UpdateSession.h" +#include "hurricane/analog/MetaResistor.h" +#include "hurricane/analog/Resistor.h" + +namespace Analog { + + + const Hurricane::Name Resistor::_resistorName ( "Resistor" ); + + + Resistor::Resistor ( Library* library, const Name& name, const Type& type ) + : Super(library,name,type) + , _metaResistor(NULL) + { } + + + Resistor* Resistor::create ( Library* library, const Name& name, const Type& type ) + { + preCreate( _resistorName ); + + UpdateSession::open(); + Resistor* tr = new Resistor( library, name, type ); + tr->_postCreate( _resistorName ); + tr->createConnections(); + tr->setTerminal( true ); + UpdateSession::close(); + return tr; + } + + + void Resistor::_postCreate ( const Name& deviceName ) + { + Super::_postCreate( deviceName ); + } + + + void Resistor::createConnections () + { + Net* pin1 = Net::create( this, Name("PIN1") ); + pin1->setExternal(true); + + Net* pin2 = Net::create( this, Name("PIN2") ); + pin2->setExternal(true); + + _metaResistor = MetaResistor::create( getSubDevicesLibrary(), Name("R1") ); + Instance* metaResistorIns = Instance::create( this, Name("R1Instance"), _metaResistor ); + + setReferenceResistor( _metaResistor ); + + Plug* mrPin1Plug = metaResistorIns->getPlug( _metaResistor->getPin1() ); + mrPin1Plug->setNet( pin1 ); + Plug* mrPin2Plug = metaResistorIns->getPlug( _metaResistor->getPin2() ); + mrPin2Plug->setNet( pin2 ); + } + + + Name Resistor::getDeviceName () const + { + return _resistorName; + } + + + unsigned int Resistor::getRestriction ( Hurricane::Net* net ) const + { + Name namePin1 = getNet("PIN1")->getName(); + Name namePin2 = getNet("PIN2")->getName(); + + //unsigned int ok = 0x1; + unsigned int yes = 0x2; + unsigned int west = 0; + unsigned int east = 2; + unsigned int south = 4; + unsigned int north = 6; + unsigned int rule = 0; + + if (net->getName() == namePin1) { + rule = (yes << south) | (yes << east) | (yes << west); + } else { + if (net->getName() == namePin2) { + rule = (yes << north) | (yes << east) | (yes << west); + } else { + cerr << Error( "Resistor::getRestriction(): Resistor device do not have Net named \"%s\"." + , getString(net->getName()).c_str() + ) << endl; + } + } + + return rule; + } + + + bool Resistor::isSame ( Resistor* r ) + { + StepParameter* w1 = dynamic_cast(getParameter("W")); + StepParameter* l1 = dynamic_cast(getParameter("L")); + + StepParameter* w2 = dynamic_cast(r->getParameter("W")); + StepParameter* l2 = dynamic_cast(r->getParameter("L")); + + if (w1->getValue() != w2->getValue()){ + cerr << Warning( "Resistor::isSame(): W are different \"%s\" vs \"%s\"." + , getString(this).c_str(), getString(r).c_str() ); + return false; + } if (l1->getValue() != l2->getValue()){ + cerr << Warning( "Resistor::isSame(): L are different \"%s\" vs \"%s\"." + , getString(this).c_str(), getString(r).c_str() ); + return false; + } + + return true; + } + + +} // Analog namespace. diff --git a/hurricane/src/analog/ResistorFamily.cpp b/hurricane/src/analog/ResistorFamily.cpp new file mode 100644 index 00000000..f985835e --- /dev/null +++ b/hurricane/src/analog/ResistorFamily.cpp @@ -0,0 +1,53 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2019-2019, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | H u r r i c a n e A n a l o g | +// | | +// | Authors : Jean-Paul Chaput | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Module : "./ResistorFamily.cpp" | +// +-----------------------------------------------------------------+ + + +#include "hurricane/DataBase.h" +#include "hurricane/Technology.h" +#include "hurricane/PhysicalRule.h" +#include "hurricane/analog/MetaResistor.h" +#include "hurricane/analog/ResistorFamily.h" + +namespace Analog { + + + ResistorFamily::ResistorFamily ( Library* library, const Name& name, const Type& type ) + : Super (library,name) + , _type (type) + , _referenceResistor(NULL) + , _w (NULL) + , _l (NULL) + , _r (NULL) + , _bends (NULL) + { } + + + void ResistorFamily::_postCreate ( const Name& deviceName ) + { + Super::_postCreate(deviceName); + + DbU::Unit resistorMinL = 0; // techno->getPhysicalRule( "resistorMinL" ).getValue(); + DbU::Unit resistorMaxL = 1000000; // techno->getPhysicalRule( "resistorMaxL" ).getValue(); + DbU::Unit resistorMinW = 0; // techno->getPhysicalRule( "resistorMinW" ).getValue(); + DbU::Unit resistorMaxW = 10000000; // techno->getPhysicalRule( "resistorMaxW" ).getValue(); + + _w = addStepParameter ( "W" , resistorMinW, resistorMaxW, DbU::grid(1) ); + _l = addStepParameter ( "L" , resistorMinL, resistorMaxL, DbU::grid(1) ); + _r = addFloatParameter ( "R" ); + _bends = addFormFactorParameter( "bends", 1, 10 ); + } + + +} // Analog namespace. diff --git a/hurricane/src/analog/StepParameter.cpp b/hurricane/src/analog/StepParameter.cpp new file mode 100644 index 00000000..2c414d87 --- /dev/null +++ b/hurricane/src/analog/StepParameter.cpp @@ -0,0 +1,51 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2009-2019, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | H u r r i c a n e A n a l o g | +// | | +// | Authors : Christophe Alexandre | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Module : "./StepParameter.cpp" | +// +-----------------------------------------------------------------+ + + +#include "hurricane/analog/StepParameter.h" + + +namespace Analog { + + using std::string; + + + string StepParameter::_getTypeName () const + { return "StepParameter"; } + + + std::string StepParameter::_getString () const + { + string s = Super::_getString(); + s.insert( s.size()-1, " "+getString(_value) + +" ["+getString(_min)+".."+getString(_max)+"/"+getString(_step)+"]" ); + return s; + } + + + Record* StepParameter::_getRecord () const + { + Record* record = Super::_getRecord(); + record->add( getSlot( "_min" , &_min ) ); + record->add( getSlot( "_max" , &_max ) ); + record->add( getSlot( "_step" , &_step ) ); + record->add( getSlot( "_value", &_value ) ); + return record; + } + + + + +} // Analog namespace. diff --git a/hurricane/src/analog/hurricane/analog/CapacitiesParameter.h b/hurricane/src/analog/hurricane/analog/CapacitiesParameter.h index 3e2128d9..c1d11a00 100644 --- a/hurricane/src/analog/hurricane/analog/CapacitiesParameter.h +++ b/hurricane/src/analog/hurricane/analog/CapacitiesParameter.h @@ -24,11 +24,16 @@ namespace Analog { class CapacitiesParameter : public Parameter { public: - inline CapacitiesParameter ( std::string id, size_t count ); - inline CapacitiesParameter ( std::string id, const std::vector& ); - inline size_t getCount () const; - inline double getValue ( size_t index ) const; - inline void setValue ( size_t index, double value ); + typedef Parameter Super; + public: + inline CapacitiesParameter ( std::string id, size_t count ); + inline CapacitiesParameter ( std::string id, const std::vector& ); + inline size_t getCount () const; + inline double getValue ( size_t index ) const; + inline void setValue ( size_t index, double value ); + virtual std::string _getTypeName () const; + virtual std::string _getString () const; + virtual Record* _getRecord () const; private: std::vector _values; }; @@ -51,4 +56,7 @@ namespace Analog { } // Analog namespace. + +INSPECTOR_PR_SUPPORT(Analog::CapacitiesParameter); + #endif // ANALOG_CAPACITIES_PARAMETER_H diff --git a/hurricane/src/analog/hurricane/analog/CapacitorParameter.h b/hurricane/src/analog/hurricane/analog/CapacitorParameter.h index 20d06e28..576ddc81 100644 --- a/hurricane/src/analog/hurricane/analog/CapacitorParameter.h +++ b/hurricane/src/analog/hurricane/analog/CapacitorParameter.h @@ -24,10 +24,11 @@ namespace Analog { class CapacitorParameter : public Parameter { public: - inline CapacitorParameter ( std::string id, double value ); - inline double getValue () const; - inline operator double () const; - inline void setValue ( double ); + inline CapacitorParameter ( std::string id, double value ); + inline double getValue () const; + inline operator double () const; + inline void setValue ( double ); + virtual std::string _getTypeName () const { return "CapacitorParameter"; } private: double _value; }; diff --git a/hurricane/src/analog/hurricane/analog/ChoiceParameter.h b/hurricane/src/analog/hurricane/analog/ChoiceParameter.h index 79b8afe7..bf7607a5 100644 --- a/hurricane/src/analog/hurricane/analog/ChoiceParameter.h +++ b/hurricane/src/analog/hurricane/analog/ChoiceParameter.h @@ -25,12 +25,16 @@ namespace Analog { class ChoiceParameter : public Parameter { + public: + typedef Parameter Super; public: inline ChoiceParameter ( std::string id, const Choices& ); - virtual ~ChoiceParameter () { } Choices::Values getChoicesValues () const; std::string getValue () const; void setValue ( const std::string& choice ); + virtual std::string _getTypeName () const; + virtual std::string _getString () const; + virtual Record* _getRecord () const; private: Choices _choices; unsigned _value; @@ -46,4 +50,7 @@ namespace Analog { } // Analog namespace. + +INSPECTOR_PR_SUPPORT(Analog::ChoiceParameter); + #endif // ANALOG_CHOICE_PARAMETER_H diff --git a/hurricane/src/analog/hurricane/analog/Device.h b/hurricane/src/analog/hurricane/analog/Device.h index 71948c3f..4349b3db 100644 --- a/hurricane/src/analog/hurricane/analog/Device.h +++ b/hurricane/src/analog/hurricane/analog/Device.h @@ -19,6 +19,7 @@ #include "hurricane/Cell.h" #include "hurricane/analog/StepParameter.h" +#include "hurricane/analog/FloatParameter.h" #include "hurricane/analog/CapacitorParameter.h" #include "hurricane/analog/ChoiceParameter.h" #include "hurricane/analog/SpinBoxParameter.h" @@ -70,6 +71,7 @@ namespace Analog { inline Hurricane::Library* getSubDevicesLibrary (); inline void addParameter ( Parameter* parameter ); inline StepParameter* addStepParameter ( const std::string name, long min, long max, long step ); + inline FloatParameter* addFloatParameter ( const std::string name, float value=0.0 ); inline CapacitorParameter* addCapacitorParameter ( const std::string name, long value ); inline SpinBoxParameter* addSpinBoxParameter ( const std::string name, long min, long max ); inline FormFactorParameter* addFormFactorParameter ( const std::string name, long min, long max ); @@ -108,6 +110,13 @@ namespace Analog { return stepParameter; } + inline FloatParameter* Device::addFloatParameter ( const std::string name, float value ) + { + FloatParameter* floatParameter = new FloatParameter( name, value ); + addParameter( floatParameter ); + return floatParameter; + } + inline CapacitorParameter* Device::addCapacitorParameter ( const std::string name, long value ) { CapacitorParameter* capacitorParameter = new CapacitorParameter( name,value ); diff --git a/hurricane/src/analog/hurricane/analog/FloatParameter.h b/hurricane/src/analog/hurricane/analog/FloatParameter.h new file mode 100644 index 00000000..682bc46d --- /dev/null +++ b/hurricane/src/analog/hurricane/analog/FloatParameter.h @@ -0,0 +1,51 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2019-2019, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | H u r r i c a n e A n a l o g | +// | | +// | Authors : Jean-Paul Chaput | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./hurricane/analog/FloatParameter.h" | +// +-----------------------------------------------------------------+ + +#ifndef ANALOG_FLOAT_PARAMETER_H +#define ANALOG_FLOAT_PARAMETER_H + +#include "hurricane/analog/Parameter.h" + + +namespace Analog { + + class FloatParameter : public Parameter { + public: + typedef Parameter Super; + public: + inline FloatParameter ( std::string id, float value=0.0 ); + inline float getValue () const; + inline void setValue ( float ); + inline operator long () const; + virtual std::string _getTypeName () const; + virtual std::string _getString () const; + virtual Record* _getRecord () const; + private: + float _value; + }; + + + inline FloatParameter::FloatParameter ( std::string id, float value ): Parameter(id), _value(value) {} + inline float FloatParameter::getValue () const { return _value; } + inline void FloatParameter::setValue ( float value ) { _value = value; } + inline FloatParameter::operator long () const { return getValue(); } + + +} // Analog namespace. + + +INSPECTOR_PR_SUPPORT(Analog::FloatParameter); + +#endif // ANALOG_FLOAT_PARAMETER_H diff --git a/hurricane/src/analog/hurricane/analog/FormFactorParameter.h b/hurricane/src/analog/hurricane/analog/FormFactorParameter.h index baeb5fe6..6cbffc05 100644 --- a/hurricane/src/analog/hurricane/analog/FormFactorParameter.h +++ b/hurricane/src/analog/hurricane/analog/FormFactorParameter.h @@ -24,13 +24,18 @@ namespace Analog { class FormFactorParameter : public Parameter { public: - inline FormFactorParameter ( std::string id, long min, long max); - inline long getMin () const; - inline long getMax () const; - inline long getValue () const; - inline operator long () const ; - inline void setValue ( long ); - inline void setMax ( long ); + typedef Parameter Super; + public: + inline FormFactorParameter ( std::string id, long min, long max); + inline long getMin () const; + inline long getMax () const; + inline long getValue () const; + inline operator long () const ; + inline void setValue ( long ); + inline void setMax ( long ); + virtual std::string _getTypeName () const; + virtual std::string _getString () const; + virtual Record* _getRecord () const; private: long _min; long _max; @@ -55,4 +60,7 @@ namespace Analog { } // Analog namespace. + +INSPECTOR_P_SUPPORT(Analog::FormFactorParameter); + #endif // ANALOG_FORMFACTOR_PARAMETER_H diff --git a/hurricane/src/analog/hurricane/analog/MCheckBoxParameter.h b/hurricane/src/analog/hurricane/analog/MCheckBoxParameter.h index 224b5153..dd23b39b 100644 --- a/hurricane/src/analog/hurricane/analog/MCheckBoxParameter.h +++ b/hurricane/src/analog/hurricane/analog/MCheckBoxParameter.h @@ -29,10 +29,15 @@ namespace Analog { class MCheckBoxParameter : public Parameter { public: - inline MCheckBoxParameter ( std::string id, const Choices& ); - inline Choices::Values getChoicesValues () const; - inline unsigned int getValue () const; - inline void setValue ( unsigned int ); + typedef Parameter Super; + public: + inline MCheckBoxParameter ( std::string id, const Choices& ); + inline Choices::Values getChoicesValues () const; + inline unsigned int getValue () const; + inline void setValue ( unsigned int ); + virtual std::string _getTypeName () const; + virtual std::string _getString () const; + virtual Record* _getRecord () const; private: Choices _choices; unsigned _value; @@ -47,4 +52,7 @@ namespace Analog { } // Analog namespace. + +INSPECTOR_PR_SUPPORT(Analog::MCheckBoxParameter); + #endif // ANALOG_MCHECKBOX_PARAMETER_H diff --git a/hurricane/src/analog/hurricane/analog/Matrix.h b/hurricane/src/analog/hurricane/analog/Matrix.h index ba8f1238..906d4031 100644 --- a/hurricane/src/analog/hurricane/analog/Matrix.h +++ b/hurricane/src/analog/hurricane/analog/Matrix.h @@ -17,8 +17,13 @@ #ifndef ANALOG_MATRIX_H #define ANALOG_MATRIX_H +#include + + namespace Analog { + using std::size_t; + class Matrix { public: diff --git a/hurricane/src/analog/hurricane/analog/MatrixParameter.h b/hurricane/src/analog/hurricane/analog/MatrixParameter.h index 3c402ba1..d8776336 100644 --- a/hurricane/src/analog/hurricane/analog/MatrixParameter.h +++ b/hurricane/src/analog/hurricane/analog/MatrixParameter.h @@ -25,13 +25,18 @@ namespace Analog { class MatrixParameter : public Parameter { public: - inline MatrixParameter ( std::string id, size_t rows=1, size_t columns=1 ); - inline size_t getRows () const; - inline size_t getColumns () const; - inline size_t getValue ( size_t row , size_t column ) const; - inline void setValue ( size_t row , size_t column , size_t value ); - inline void setMatrix ( const Matrix* ); - inline void resize ( size_t rows, size_t columns ); + typedef Parameter Super; + public: + inline MatrixParameter ( std::string id, size_t rows=1, size_t columns=1 ); + inline size_t getRows () const; + inline size_t getColumns () const; + inline size_t getValue ( size_t row , size_t column ) const; + inline void setValue ( size_t row , size_t column , size_t value ); + inline void setMatrix ( const Matrix* ); + inline void resize ( size_t rows, size_t columns ); + virtual std::string _getTypeName () const; + virtual std::string _getString () const; + virtual Record* _getRecord () const; private: Matrix _matrix; }; @@ -52,4 +57,7 @@ namespace Analog { } // Analog namespace. + +INSPECTOR_PR_SUPPORT(Analog::MatrixParameter); + #endif // ANALOG_MATRIX_PARAMETER_H diff --git a/hurricane/src/analog/hurricane/analog/MetaResistor.h b/hurricane/src/analog/hurricane/analog/MetaResistor.h new file mode 100644 index 00000000..48aa7688 --- /dev/null +++ b/hurricane/src/analog/hurricane/analog/MetaResistor.h @@ -0,0 +1,73 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2019-2019, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | H u r r i c a n e A n a l o g | +// | | +// | Authors : Jean-Paul Chaput | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./hurricane/analog/MetaResistor.h" | +// +-----------------------------------------------------------------+ + + +#ifndef ANALOG_METARESISTOR_H +#define ANALOG_METARESISTOR_H + +#include "hurricane/Cell.h" + + +namespace Analog { + + using namespace Hurricane; + + + class MetaResistor : public Cell { + public: + typedef Cell Super; + public: + static MetaResistor* create ( Library* , const Name& ); + inline Net* getSource () const; + inline Net* getPin1 () const; + inline Net* getPin2 () const; + inline float getWE () const; + inline float getLE () const; + inline float getR () const; + inline int getBends () const; + inline void setWE ( float ); + inline void setLE ( float ); + inline void setR ( float ); + inline void setBends ( int ); + protected: + void _postCreate (); + private: + MetaResistor ( Library* , const Name& ); + private: + Net* _pin1; + Net* _pin2; + Net* _anonymous; + float _r; + float _we; + float _le; + int _bends; + }; + + + inline Net* MetaResistor::getPin1 () const { return _pin1; } + inline Net* MetaResistor::getPin2 () const { return _pin2; } + inline float MetaResistor::getWE () const { return _we; } + inline float MetaResistor::getLE () const { return _le; } + inline float MetaResistor::getR () const { return _r; } + inline int MetaResistor::getBends () const { return _bends; } + inline void MetaResistor::setWE ( float we ) { _we = we; } + inline void MetaResistor::setLE ( float le ) { _le = le; } + inline void MetaResistor::setR ( float r ) { _r = r; } + inline void MetaResistor::setBends ( int bends ) { _bends = bends; } + + +} // Analog namespace. + +#endif // ANALOG_METARESISTOR_H diff --git a/hurricane/src/analog/hurricane/analog/MetaTransistor.h b/hurricane/src/analog/hurricane/analog/MetaTransistor.h index 4e56e473..fe63ad2b 100644 --- a/hurricane/src/analog/hurricane/analog/MetaTransistor.h +++ b/hurricane/src/analog/hurricane/analog/MetaTransistor.h @@ -29,46 +29,46 @@ namespace Analog { public: typedef Cell Super; public: - static MetaTransistor* create ( Library* , const Name& ); - inline Net* getSource () const; - inline Net* getDrain () const; - inline Net* getGate () const; - inline Net* getBulk () const; - inline float getWE () const; - inline float getLE () const; - inline float getIDS () const; - inline float getVGS () const; - inline float getVDS () const; - inline float getVBS () const; - inline float getVG () const; - inline float getVD () const; - inline float getVS () const; - inline float getVB () const; - inline float getVEG () const; - inline float getVTH () const; - inline float getWmin () const; - inline float getWmax () const; - inline int getNfing () const; - inline void setM ( unsigned int m ); - inline void setWE ( float we ); - inline void setLE ( float le ); - inline void setIDS ( float ids ); - inline void setVGS ( float vgs ); - inline void setVDS ( float vds ); - inline void setVBS ( float vbs ); - inline void setVG ( float vg ); - inline void setVD ( float vd ); - inline void setVS ( float vs ); - inline void setVB ( float vb ); - inline void setVEG ( float veg ); - inline void setVTH ( float vth ); - inline void setWmin ( float wmin ); - inline void setWmax ( float wmax ); - inline void setNfing ( int nfing ); + static MetaTransistor* create ( Library* , const Name& ); + inline Net* getSource () const; + inline Net* getDrain () const; + inline Net* getGate () const; + inline Net* getBulk () const; + inline float getWE () const; + inline float getLE () const; + inline float getIDS () const; + inline float getVGS () const; + inline float getVDS () const; + inline float getVBS () const; + inline float getVG () const; + inline float getVD () const; + inline float getVS () const; + inline float getVB () const; + inline float getVEG () const; + inline float getVTH () const; + inline float getWmin () const; + inline float getWmax () const; + inline int getNfing () const; + inline void setM ( unsigned int m ); + inline void setWE ( float we ); + inline void setLE ( float le ); + inline void setIDS ( float ids ); + inline void setVGS ( float vgs ); + inline void setVDS ( float vds ); + inline void setVBS ( float vbs ); + inline void setVG ( float vg ); + inline void setVD ( float vd ); + inline void setVS ( float vs ); + inline void setVB ( float vb ); + inline void setVEG ( float veg ); + inline void setVTH ( float vth ); + inline void setWmin ( float wmin ); + inline void setWmax ( float wmax ); + inline void setNfing ( int nfing ); protected: - void _postCreate (); + void _postCreate (); private: - MetaTransistor ( Library* , const Name& ); + MetaTransistor ( Library* , const Name& ); private: Net* _drain; Net* _source; diff --git a/hurricane/src/analog/hurricane/analog/Parameter.h b/hurricane/src/analog/hurricane/analog/Parameter.h index 3b867506..380120da 100644 --- a/hurricane/src/analog/hurricane/analog/Parameter.h +++ b/hurricane/src/analog/hurricane/analog/Parameter.h @@ -18,25 +18,31 @@ #define ANALOG_PARAMETER_H #include +#include "hurricane/Commons.h" namespace Analog { + using Hurricane::Record; + class Parameter { public: friend class Device; enum Type { STEP=0, CHOICE=1, SPIN=2, MCHECK=3, CAPACITOR=4 }; public: - inline const std::string& getName () const; - inline int getIndex (); - inline void setIndex ( int ); - virtual ~Parameter () { } + virtual ~Parameter (); + inline const std::string& getName () const; + inline int getIndex (); + inline void setIndex ( int ); + virtual std::string _getTypeName () const = 0; + virtual std::string _getString () const; + virtual Record* _getRecord () const; protected: - inline Parameter ( const std::string& name ); + inline Parameter ( const std::string& name ); private: - Parameter (); - Parameter ( const Parameter& parameter ); + Parameter (); + Parameter ( const Parameter& parameter ); private: const std::string _name; int _index; @@ -51,4 +57,7 @@ namespace Analog { } // Analog namespace. + +INSPECTOR_P_SUPPORT(Analog::Parameter); + #endif // ANALOG_PARAMETER_H diff --git a/hurricane/src/analog/hurricane/analog/PyFloatParameter.h b/hurricane/src/analog/hurricane/analog/PyFloatParameter.h new file mode 100644 index 00000000..3fb76a2b --- /dev/null +++ b/hurricane/src/analog/hurricane/analog/PyFloatParameter.h @@ -0,0 +1,55 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2019-2019, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | H u r r i c a n e A n a l o g | +// | | +// | Author : Jean-Paul Chaput | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./hurricane/analog/PyFloatParameter.h" | +// +-----------------------------------------------------------------+ + + +#ifndef ANALOG_PY_FLOAT_PARAMETER_H +#define ANALOG_PY_FLOAT_PARAMETER_H + +#include "hurricane/analog/PyParameter.h" +#include "hurricane/analog/FloatParameter.h" + + +namespace Isobar { + +extern "C" { + +// ------------------------------------------------------------------- +// Python Object : "PyFloatParameter". + + typedef struct { + PyParameter _baseObject; + } PyFloatParameter; + + +// ------------------------------------------------------------------- +// Functions & Types exported to "PyHurricane.cpp". + + extern PyTypeObject PyTypeFloatParameter; + extern PyMethodDef PyFloatParameter_Methods[]; + + extern PyObject* PyFloatParameter_Link ( Analog::FloatParameter* object ); + extern void PyFloatParameter_LinkPyType (); + + +#define IsPyFloatParameter(v) ( (v)->ob_type == &PyTypeFloatParameter ) +#define PYFLOATPARAMETER(v) ( (PyFloatParameter*)(v) ) +#define PYFLOATPARAMETER_O(v) ( PYFLOATPARAMETER(v)->_baseObject->_baseObject._object ) + + +} // extern "C". + +} // Isobar namespace. + +#endif // ANALOG_PY_FLOAT_PARAMETER_H diff --git a/hurricane/src/analog/hurricane/analog/PyResistor.h b/hurricane/src/analog/hurricane/analog/PyResistor.h new file mode 100644 index 00000000..592140fc --- /dev/null +++ b/hurricane/src/analog/hurricane/analog/PyResistor.h @@ -0,0 +1,55 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2019-2019, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | H u r r i c a n e A n a l o g | +// | | +// | Author : Jean-Paul Chaput | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./hurricane/analog/PyResistor.h" | +// +-----------------------------------------------------------------+ + + +#ifndef ANALOG_PY_RESISTOR_H +#define ANALOG_PY_RESISTOR_H + +#include "hurricane/analog/PyResistorFamily.h" +#include "hurricane/analog/Resistor.h" + + +namespace Isobar { + +extern "C" { + +// ------------------------------------------------------------------- +// Python Object : "PyResistor". + + typedef struct { + PyResistorFamily _baseObject; + } PyResistor; + + +// ------------------------------------------------------------------- +// Functions & Types exported to "PyHurricane.cpp". + + extern PyTypeObject PyTypeResistor; + extern PyMethodDef PyResistor_Methods[]; + + extern PyObject* PyResistor_Link ( Analog::Resistor* object ); + extern void PyResistor_LinkPyType (); + + +#define IsPyResistor(v) ( (v)->ob_type == &PyTypeResistor ) +#define PYRESISTOR(v) ( (PyResistor*)(v) ) +#define PYRESISTOR_O(v) ( PYRESISTOR(v)->_baseObject->_baseObject._object ) + + +} // extern "C". + +} // Isobar namespace. + +#endif // ANALOG_PY_RESISTOR_H diff --git a/hurricane/src/analog/hurricane/analog/PyResistorFamily.h b/hurricane/src/analog/hurricane/analog/PyResistorFamily.h new file mode 100644 index 00000000..88364881 --- /dev/null +++ b/hurricane/src/analog/hurricane/analog/PyResistorFamily.h @@ -0,0 +1,56 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2019-2019, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | H u r r i c a n e A n a l o g | +// | | +// | Author : Jean-Paul Chaput | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./hurricane/analog/PyResistorFamily.h" | +// +-----------------------------------------------------------------+ + + +#ifndef ANALOG_PY_RESISTOR_FAMILY_H +#define ANALOG_PY_RESISTOR_FAMILY_H + +#include "hurricane/analog/PyDevice.h" +#include "hurricane/analog/ResistorFamily.h" + + +namespace Isobar { + +extern "C" { + +// ------------------------------------------------------------------- +// Python Object : "PyResistorFamily". + + typedef struct { + PyDevice _baseObject; + } PyResistorFamily; + + +// ------------------------------------------------------------------- +// Functions & Types exported to "PyHurricane.cpp". + + extern PyTypeObject PyTypeResistorFamily; + extern PyMethodDef PyResistorFamily_Methods[]; + + extern PyObject* PyResistorFamily_Link ( Analog::ResistorFamily* object ); + extern void PyResistorFamily_LinkPyType (); + extern void PyResistorFamily_postModuleInit (); + + +#define IsPyResistorFamily(v) ( (v)->ob_type == &PyTypeResistorFamily ) +#define PYRESISTORFAMILY(v) ( (PyResistorFamily*)(v) ) +#define PYRESISTORFAMILY_O(v) ( PYRESISTORFAMILY(v)->_baseObject->_baseObject._object ) + + +} // extern "C". + +} // Isobar namespace. + +#endif // ANALOG_PY_RESISTOR_FAMILY_H diff --git a/hurricane/src/analog/hurricane/analog/Resistor.h b/hurricane/src/analog/hurricane/analog/Resistor.h new file mode 100644 index 00000000..593ff841 --- /dev/null +++ b/hurricane/src/analog/hurricane/analog/Resistor.h @@ -0,0 +1,51 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2019-2019, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | H u r r i c a n e A n a l o g | +// | | +// | Authors : Jean-Paul Chaput | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./hurricane/analog/Resistor.h" | +// +-----------------------------------------------------------------+ + + +#ifndef ANALOG_RESISTOR_H +#define ANALOG_RESISTOR_H + +#include "hurricane/analog/ResistorFamily.h" + +namespace Analog { + + + class Resistor : public ResistorFamily { + public: + typedef ResistorFamily Super; + public: + static Resistor* create ( Hurricane::Library* + , const Hurricane::Name& + , const Type& ); + virtual Hurricane::Name getDeviceName () const; + unsigned int getRestriction ( Hurricane::Net* ) const; + bool isSame ( Resistor* ); + + protected: + Resistor ( Hurricane::Library* , const Hurricane::Name& , const Type& ); + virtual void _postCreate ( const Hurricane::Name& deviceName ); + virtual void createConnections (); + private: + static const Hurricane::Name _resistorName; + MetaResistor* _metaResistor; + }; + + +} // Analog namespace. + + +INSPECTOR_P_SUPPORT(Analog::Resistor); + +#endif // ANALOG_RESISTOR_H diff --git a/hurricane/src/analog/hurricane/analog/ResistorFamily.h b/hurricane/src/analog/hurricane/analog/ResistorFamily.h new file mode 100644 index 00000000..c5c32ef2 --- /dev/null +++ b/hurricane/src/analog/hurricane/analog/ResistorFamily.h @@ -0,0 +1,113 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2019-2019, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | H u r r i c a n e A n a l o g | +// | | +// | Authors : Jean-Paul Chaput | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./hurricane/analog/ResistorFamily.h" | +// +-----------------------------------------------------------------+ + + +#ifndef ANALOG_RESISTOR_FAMILY_H +#define ANALOG_RESISTOR_FAMILY_H + +#include "hurricane/DbU.h" +#include "hurricane/analog/Device.h" +#include "hurricane/analog/MetaResistor.h" + +namespace Hurricane { + class Name; + class Library; +} + + +namespace Analog { + + + class ResistorFamily : public Device { + public: + typedef Device Super; + + enum Type { LOWRES=1, HIRES }; + public: + inline MetaResistor* getReferenceResistor (); + inline const MetaResistor* getReferenceResistor () const; + inline const Type& getType () const; + // Geometrical (layout) parameters commons to all resistors. + inline bool isLOWRES () const; + inline bool isHIRES () const; + inline int getBends () const; + inline DbU::Unit getW () const; + inline DbU::Unit getL () const; + inline float getR () const; + inline void setR ( float ); + inline void setBends ( int ); + // Electrical parameters commons to all resistors. + inline float getWE () const; + inline float getLE () const; + inline void setWE ( float ); + inline void setLE ( float ); + protected: + ResistorFamily ( Hurricane::Library* + , const Hurricane::Name& + , const Type& ); + void _postCreate ( const Name& deviceName ); + inline void setReferenceResistor ( MetaResistor* ); + virtual void createConnections () = 0; + private: + inline MetaResistor* _secureGetReferenceResistor (); + inline const MetaResistor* _secureGetReferenceResistor () const; + private: + const Type _type; + MetaResistor* _referenceResistor; + StepParameter* _w; + StepParameter* _l; + FloatParameter* _r; + FormFactorParameter* _bends; + }; + + + inline MetaResistor* ResistorFamily::getReferenceResistor () { return _referenceResistor; } + inline const MetaResistor* ResistorFamily::getReferenceResistor () const { return _referenceResistor; } + inline const ResistorFamily::Type& ResistorFamily::getType () const { return _type; } + inline void ResistorFamily::setReferenceResistor ( MetaResistor* mr ) { _referenceResistor = mr; } + inline bool ResistorFamily::isLOWRES () const { return getType() == LOWRES; } + inline bool ResistorFamily::isHIRES () const { return getType() == HIRES; } + // Mutators. + inline void ResistorFamily::setR ( float r ) { _secureGetReferenceResistor()->setR (r ); _r ->setValue(r ); } + inline void ResistorFamily::setBends ( int bends ) { _secureGetReferenceResistor()->setBends(bends); _bends->setValue(bends); } + inline void ResistorFamily::setWE ( float we ) { _secureGetReferenceResistor()->setWE (we ); } + inline void ResistorFamily::setLE ( float le ) { _secureGetReferenceResistor()->setLE (le ); } + // Accessors. + inline int ResistorFamily::getBends () const { return _secureGetReferenceResistor()->getBends(); } + inline DbU::Unit ResistorFamily::getW () const { return _w->getValue(); } + inline DbU::Unit ResistorFamily::getL () const { return _l->getValue(); } + inline float ResistorFamily::getR () const { return _r->getValue(); } + inline float ResistorFamily::getWE () const { return _secureGetReferenceResistor()->getWE (); } + inline float ResistorFamily::getLE () const { return _secureGetReferenceResistor()->getLE (); } + + inline MetaResistor* ResistorFamily::_secureGetReferenceResistor () + { + if (!_referenceResistor) throw Hurricane::Error("No MetaResistor"); + return _referenceResistor; + } + + inline const MetaResistor* ResistorFamily::_secureGetReferenceResistor () const + { + if (!_referenceResistor) throw Hurricane::Error("No MetaResistor"); + return _referenceResistor; + } + + +} // Analog namespace. + + +INSPECTOR_P_SUPPORT(Analog::ResistorFamily); + +#endif // ANALOG_RESISTOR_FAMILY_H diff --git a/hurricane/src/analog/hurricane/analog/SpinBoxParameter.h b/hurricane/src/analog/hurricane/analog/SpinBoxParameter.h index 37a78232..6ee28d93 100644 --- a/hurricane/src/analog/hurricane/analog/SpinBoxParameter.h +++ b/hurricane/src/analog/hurricane/analog/SpinBoxParameter.h @@ -24,12 +24,13 @@ namespace Analog { class SpinBoxParameter : public Parameter { public: - inline SpinBoxParameter ( std::string id, long min, long max ); - inline long getMin () const; - inline long getMax () const; - inline long getValue () const; - inline operator long () const; - inline void setValue ( long value ); + inline SpinBoxParameter ( std::string id, long min, long max ); + inline long getMin () const; + inline long getMax () const; + inline long getValue () const; + inline operator long () const; + inline void setValue ( long value ); + virtual std::string _getTypeName () const { return "SpinBoxParameter"; } private: long _min; long _max; diff --git a/hurricane/src/analog/hurricane/analog/StepParameter.h b/hurricane/src/analog/hurricane/analog/StepParameter.h index 27a11e98..5fc5e583 100644 --- a/hurricane/src/analog/hurricane/analog/StepParameter.h +++ b/hurricane/src/analog/hurricane/analog/StepParameter.h @@ -23,13 +23,18 @@ namespace Analog { class StepParameter : public Parameter { public: - inline StepParameter ( std::string id, long min, long max, long step ); - inline long getMin () const; - inline long getMax () const; - inline long getStep () const; - inline long getValue () const; - inline operator long () const; - inline void setValue ( long ); + typedef Parameter Super; + public: + inline StepParameter ( std::string id, long min, long max, long step ); + inline long getMin () const; + inline long getMax () const; + inline long getStep () const; + inline long getValue () const; + inline operator long () const; + inline void setValue ( long ); + virtual std::string _getTypeName () const; + virtual std::string _getString () const; + virtual Record* _getRecord () const; private: long _min; long _max; @@ -49,4 +54,7 @@ namespace Analog { } // Analog namespace. + +INSPECTOR_PR_SUPPORT(Analog::StepParameter); + #endif // ANALOG_STEP_PARAMETER_H diff --git a/hurricane/src/analog/hurricane/analog/Transistor.h b/hurricane/src/analog/hurricane/analog/Transistor.h index d23325ea..2fffa6b7 100644 --- a/hurricane/src/analog/hurricane/analog/Transistor.h +++ b/hurricane/src/analog/hurricane/analog/Transistor.h @@ -32,7 +32,7 @@ namespace Analog { , bool bulkConnected ); virtual Hurricane::Name getDeviceName () const; unsigned int getRestriction ( Hurricane::Net* net ) const; - bool isSame (Transistor* ts); + bool isSame ( Transistor* ); protected: Transistor ( Hurricane::Library* , const Hurricane::Name& , const Type& ); diff --git a/hurricane/src/isobar/PyCell.cpp b/hurricane/src/isobar/PyCell.cpp index a2b99a43..8c5e0c39 100644 --- a/hurricane/src/isobar/PyCell.cpp +++ b/hurricane/src/isobar/PyCell.cpp @@ -64,20 +64,25 @@ extern "C" { // --------------------------------------------------------------- // Attribute Method : "PyCell_create ()" - PyObject* PyCell_create ( PyObject*, PyObject *args ) { + PyObject* PyCell_create ( PyObject*, PyObject* args ) + { cdebug_log(20,0) << "PyCell_create()" << endl; - char* name = NULL; + char* name = NULL; PyLibrary* pyLibrary = NULL; - Cell* cell = NULL; + Cell* cell = NULL; HTRY - if (PyArg_ParseTuple(args,"O!s:Cell.create", &PyTypeLibrary, &pyLibrary, &name)) { - cell = Cell::create(PYLIBRARY_O(pyLibrary), Name(name)); - } else { - PyErr_SetString ( ConstructorError, "invalid number of parameters for Cell constructor."); + if (PyArg_ParseTuple(args,"O!s:Cell.create", &PyTypeLibrary, &pyLibrary, &name)) { + cell = Cell::create( PYLIBRARY_O(pyLibrary), Name(name) ); + } else { + string message = "Cell::create(): Invalid number of parameters for Cell constructor, name="; + if (name) message += "\"" + getString(name) + "\"."; + else message += "(NULL)."; + + PyErr_SetString( ConstructorError, message.c_str() ); return NULL; - } + } HCATCH return PyCell_Link(cell); diff --git a/karakaze/python/AnalogDesign.py b/karakaze/python/AnalogDesign.py index 541b865c..1d0e7301 100644 --- a/karakaze/python/AnalogDesign.py +++ b/karakaze/python/AnalogDesign.py @@ -33,6 +33,10 @@ from Analog import LevelShifter from Analog import SimpleCurrentMirror from Analog import CapacitorFamily from Analog import MultiCapacitor +from Analog import CapacitorFamily +from Analog import MultiCapacitor +from Analog import ResistorFamily +from Analog import Resistor from Analog import LayoutGenerator from Analog import Matrix from Bora import ParameterRange @@ -55,6 +59,8 @@ PMOS = Transistor.PMOS PIP = CapacitorFamily.PIP MIM = CapacitorFamily.MIM MOM = CapacitorFamily.MOM +LOWRES = ResistorFamily.LOWRES +HIRES = ResistorFamily.HIRES Center = SlicingNode.AlignCenter Left = SlicingNode.AlignLeft Right = SlicingNode.AlignRight @@ -256,6 +262,7 @@ class AnalogDesign ( object ): specSize = 0 if isderived(dspec[0],TransistorFamily): specSize = 12 elif isderived(dspec[0], CapacitorFamily): specSize = 6 + elif isderived(dspec[0], ResistorFamily): specSize = 5 else: raise Error( 3, [ 'AnalogDesign.doDevices(): \"self.devicesSpecs\" entry [%d], has unsupported device type.' \ % (count) @@ -315,6 +322,15 @@ class AnalogDesign ( object ): raise Error( 3, [ 'AnalogDesign.doDevices(): \"self.devicesSpecs\" entry [%d], field [4] (Cs) should either be *one* float or a *list* of floats.' % count , '%s' % str(dspec) ]) + elif specSize == 5: + if dspec[3] not in [LOWRES, HIRES]: + raise Error( 3, [ 'AnalogDesign.doDevices(): \"self.devicesSpecs\" entry [%d], field [3] (type) must be either LOWRES or HIRES.' % count + , '%s' % str(dspec) ]) + if isinstance(dspec[4],float): pass + else: + raise Error( 3, [ 'AnalogDesign.doDevices(): \"self.devicesSpecs\" entry [%d], field [4] (resistance) must be a float.' % count + , '%s' % str(dspec) ]) + else: raise Error( 3, [ 'AnalogDesign.doDevices(): \"self.devicesSpecs\" entry [%d], spec list do not match any known pattern.' % count , '%s' % str(dspec) ]) @@ -386,19 +402,23 @@ class AnalogDesign ( object ): if dspec[8]: device.setExternalDummy( dspec[8] ) elif isderived(dspec[0],CapacitorFamily): - if isinstance(dspec[4],float): capaCount = 1 - elif isinstance(dspec[4],tuple): capaCount = len(dspec[4]) + if isinstance(dspec[4],float): capaValues = (dspec[4],) + elif isinstance(dspec[4],tuple): capaValues = dspec[4] else: - print type(dspec[4]), dspec[4] - - device = dspec[0].create( self.library, dspec[1], dspec[3], capaCount ) + raise ErrorMessage( 1, 'AnalogDesign.doDevice(): Invalid type for capacities values "%s".' \ + % str(dspec[4]) ) + + device = dspec[0].create( self.library, dspec[1], dspec[3], len(capaValues) ) + device.getParameter( 'Layout Styles' ).setValue( dspec[2] ) + for i in range(len(capaValues)): + device.getParameter( 'capacities' ).setValue( i, capaValues[i] ) + + elif isderived(dspec[0],ResistorFamily): + device = dspec[0].create( self.library, dspec[1], dspec[3] ) device.getParameter( 'Layout Styles' ).setValue ( dspec[2] ) - device.getParameter( 'matrix' ).setMatrix( dspec[5] ) - if isinstance(dspec[4],float): - device.getParameter( 'capacities' ).setValue( 0, dspec[4] ) - else: - for index in range(len(dspec[4])): - device.getParameter( 'capacities' ).setValue( index, dspec[4][index] ) + device.getParameter( 'Resistance' ).setMatrix( dspec[4] ) + else: + raise ErrorMessage( 1, 'AnalogDesign.doDevice(): Unknown/unsupported device "%s".' % str(dspec[0]) ) self.generator.setDevice ( device ) self.generator.drawLayout() @@ -579,10 +599,10 @@ class AnalogDesign ( object ): del self.stack[-1] return - def addDevice ( self, name, align, span=(0, 0, 0), NF=0 ): - node = DSlicingNode.create( name, self.cell, StepParameterRange(span[0], span[1], span[2]), self.rg ) + def addDevice ( self, name, align, parameter, index=0 ): + node = DSlicingNode.create( name, self.cell, parameter, self.rg ) node.setAlignment( align ) - if NF != 0: node.setNFing( NF ) + if index != 0: node.setBoxSetIndex( index ) self.topNode().push_back( node ) trace( 110, '\tSlicingTree.addDevice() %s (parent id:%d)\n' % (str(node),self.topNode().getId()) ) #node.cprint() diff --git a/oroshi/python/CMakeLists.txt b/oroshi/python/CMakeLists.txt index bb6048f5..30b852ad 100644 --- a/oroshi/python/CMakeLists.txt +++ b/oroshi/python/CMakeLists.txt @@ -12,6 +12,7 @@ CapacitorVRTracks.py CapacitorRouted.py MultiCapacitor.py + ResistorSnake.py ) install( FILES ${pythonFiles} DESTINATION ${PYTHON_SITE_PACKAGES}/oroshi ) diff --git a/oroshi/python/MultiCapacitor.py b/oroshi/python/MultiCapacitor.py index 6d9f1619..7d695a51 100644 --- a/oroshi/python/MultiCapacitor.py +++ b/oroshi/python/MultiCapacitor.py @@ -81,7 +81,6 @@ def layout ( device, bbMode ): try: capacities = device.getParameter( 'capacities' ) - print str(device) print 'Capacities = ', capacities capValuesArg = [] diff --git a/oroshi/python/ParamsMatrix.py b/oroshi/python/ParamsMatrix.py index 36df4523..70e01146 100644 --- a/oroshi/python/ParamsMatrix.py +++ b/oroshi/python/ParamsMatrix.py @@ -62,6 +62,12 @@ class ParamsMatrix ( object ): return + def setGlobalResistorParams ( self, boundingBox ): + self.matrix[0][0]['box' ] = boundingBox + self.matrix[0][0]['family' ] = 'Resistor' + return + + def setStacks ( self, stacks ): if not isinstance(stacks,list): print Error( 3, 'ParamsMatrix::setGlobalParams(): argument must be of type.' ) diff --git a/oroshi/python/ResistorSnake.py b/oroshi/python/ResistorSnake.py new file mode 100644 index 00000000..81e09ebc --- /dev/null +++ b/oroshi/python/ResistorSnake.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- + +from Hurricane import DataBase +from Hurricane import UpdateSession +from Hurricane import DbU +from Hurricane import Box +import helpers +import helpers.io +from helpers import trace, u + +helpers.setTraceLevel( 1000 ) + +import Analog +import ParamsMatrix +import oroshi + + +def checkCoherency ( device, bbMode ): + valid = True + message = 'ResistorSnake.checkCoherency():\n' + + techno = DataBase.getDB().getTechnology() + rules = oroshi.getRules() + + bends = device.getParameter( 'bends' ) + if bends is None: + message += ' Missing "bends" parameter on %s' % str(device) + print message + return (False, message) + + if not valid: return (False, message) + + return (True, "") + + +def layout ( device, bbMode ): + + trace( 100, ',+', '\tResistorSnake.layout() called.\n' ) + + paramsMatrix = ParamsMatrix.ParamsMatrix() + + try: + bends = device.getParameter( 'bends' ) + print 'bends = ', bends + + device.setAbutmentBox( Box( u(0.0), u(0.0), u(10.0), u((bends.getValue()+1)*10.0)) ) + + paramsMatrix.setGlobalResistorParams( device.getAbutmentBox() ) + trace( 100, '++' ) + #paramsMatrix.trace() + + except Exception, e: + helpers.io.catch( e ) + + trace( 100, '---' ) + + return paramsMatrix.getMatrix()