2012-11-16 06:48:38 -06:00
|
|
|
|
|
|
|
// -*- C++ -*-
|
|
|
|
//
|
|
|
|
// This file is part of the Coriolis Project.
|
|
|
|
// Copyright (C) Laboratoire LIP6 - Departement ASIM
|
|
|
|
// Universite Pierre et Marie Curie
|
|
|
|
//
|
|
|
|
// Main contributors :
|
|
|
|
// Christophe Alexandre <Christophe.Alexandre@lip6.fr>
|
|
|
|
// Sophie Belloeil <Sophie.Belloeil@lip6.fr>
|
|
|
|
// Hugo Clément <Hugo.Clement@lip6.fr>
|
|
|
|
// Jean-Paul Chaput <Jean-Paul.Chaput@lip6.fr>
|
|
|
|
// Damien Dupuis <Damien.Dupuis@lip6.fr>
|
|
|
|
// Christian Masson <Christian.Masson@lip6.fr>
|
|
|
|
// Marek Sroka <Marek.Sroka@lip6.fr>
|
|
|
|
//
|
|
|
|
// The Coriolis Project is free software; you can redistribute it
|
|
|
|
// and/or modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation; either version 2 of
|
|
|
|
// the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// The Coriolis Project is distributed in the hope that it will be
|
|
|
|
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
|
|
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with the Coriolis Project; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
// USA
|
|
|
|
//
|
|
|
|
// License-Tag
|
|
|
|
// Authors-Tag
|
|
|
|
//
|
|
|
|
// +-----------------------------------------------------------------+
|
2008-03-06 10:46:43 -06:00
|
|
|
// | C O R I O L I S |
|
|
|
|
// | I s o b a r - Hurricane / Python Interface |
|
|
|
|
// | |
|
|
|
|
// | Author : Damien DUPUIS |
|
|
|
|
// | E-mail : Damien.Dupuis@asim.lip6.fr |
|
|
|
|
// | =============================================================== |
|
2012-11-16 06:48:38 -06:00
|
|
|
// | C++ Module : "./PyTechnology.cpp" |
|
|
|
|
// +-----------------------------------------------------------------+
|
|
|
|
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-05-21 17:46:29 -05:00
|
|
|
#include "hurricane/isobar/PyDataBase.h"
|
|
|
|
#include "hurricane/isobar/PyTechnology.h"
|
2012-11-16 06:48:38 -06:00
|
|
|
#include "hurricane/isobar/PyLayer.h"
|
|
|
|
#include "hurricane/isobar/PyLayerMask.h"
|
|
|
|
#include "hurricane/isobar/PyBasicLayer.h"
|
|
|
|
#include "hurricane/isobar/PyRegularLayer.h"
|
|
|
|
#include "hurricane/isobar/PyViaLayer.h"
|
|
|
|
#include "hurricane/isobar/PyLayerCollection.h"
|
|
|
|
#include "hurricane/isobar/PyBasicLayerCollection.h"
|
|
|
|
#include "hurricane/isobar/PyRegularLayerCollection.h"
|
|
|
|
#include "hurricane/isobar/PyViaLayerCollection.h"
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
namespace Isobar {
|
|
|
|
|
2008-03-28 04:48:47 -05:00
|
|
|
using namespace Hurricane;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
|
|
|
|
#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(Technology,techno,function)
|
|
|
|
|
|
|
|
|
2012-11-16 06:48:38 -06:00
|
|
|
// +=================================================================+
|
2008-03-06 10:46:43 -06:00
|
|
|
// | "PyTechnology" Python Module Code Part |
|
2012-11-16 06:48:38 -06:00
|
|
|
// +=================================================================+
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
#if defined(__PYTHON_MODULE__)
|
|
|
|
|
|
|
|
|
2012-11-16 06:48:38 -06:00
|
|
|
// +-------------------------------------------------------------+
|
2008-03-06 10:46:43 -06:00
|
|
|
// | "PyTechnology" Attribute Methods |
|
2012-11-16 06:48:38 -06:00
|
|
|
// +-------------------------------------------------------------+
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
2012-11-16 06:48:38 -06:00
|
|
|
static PyObject* PyTechnology_create ( PyTechnology*, PyObject* args )
|
|
|
|
{
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(20,0) << "Technology.create()" << endl;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2012-11-16 06:48:38 -06:00
|
|
|
Technology* technology = NULL;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
HTRY
|
2012-11-16 06:48:38 -06:00
|
|
|
PyDataBase* pyDb = NULL;
|
|
|
|
char* name = NULL;
|
|
|
|
if (PyArg_ParseTuple(args,"Os:Technology.create", &pyDb, &name)) {
|
|
|
|
if (not IsPyDataBase(pyDb) ) {
|
|
|
|
PyErr_SetString(ConstructorError,"Technology.create(): First parameter is not a DataBase.");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
technology = Technology::create( PYDATABASE_O(pyDb), Name(name) );
|
|
|
|
} else {
|
|
|
|
PyErr_SetString(ConstructorError, "Technology.create(): Bad parameter(s) number or type.");
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-03-06 10:46:43 -06:00
|
|
|
HCATCH
|
2012-11-16 06:48:38 -06:00
|
|
|
|
|
|
|
return PyTechnology_Link(technology);
|
2008-03-06 10:46:43 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-16 06:48:38 -06:00
|
|
|
static PyObject* PyTechnology_getDataBase ( PyTechnology* self )
|
|
|
|
{
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(20,0) << "PyTechnology_getDataBase()" << endl;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2012-11-16 06:48:38 -06:00
|
|
|
DataBase* db = NULL;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
HTRY
|
2012-11-16 06:48:38 -06:00
|
|
|
METHOD_HEAD("Technology.getDataBase()")
|
|
|
|
db = techno->getDataBase();
|
2008-03-06 10:46:43 -06:00
|
|
|
HCATCH
|
|
|
|
|
2012-11-16 06:48:38 -06:00
|
|
|
if (db == NULL) Py_RETURN_NONE;
|
|
|
|
return PyDataBase_Link(db);
|
2008-03-06 10:46:43 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-16 06:48:38 -06:00
|
|
|
static PyObject* PyTechnology_getLayer ( PyTechnology *self, PyObject* args )
|
|
|
|
{
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(20,0) << "Technology.getLayer()" << endl;
|
2012-11-16 06:48:38 -06:00
|
|
|
|
2008-12-10 12:37:32 -06:00
|
|
|
METHOD_HEAD("Technology.getLayer()")
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
Layer* layer = NULL;
|
|
|
|
|
|
|
|
HTRY
|
2012-11-16 06:48:38 -06:00
|
|
|
PyObject* arg0 = NULL;
|
|
|
|
PyObject* arg1 = NULL;
|
|
|
|
if (PyArg_ParseTuple(args,"O|OO:Technology.getLayer", &arg0, &arg1)) {
|
|
|
|
if (PyString_Check(arg0)) {
|
|
|
|
layer = techno->getLayer(Name(PyString_AsString(arg0)));
|
|
|
|
} else if (IsPyLayerMask(arg0)) {
|
|
|
|
bool useWorking = (arg1 != NULL) ? PyObject_IsTrue(arg1) : true;
|
|
|
|
layer = techno->getLayer(PYLAYERMASK_O(arg0), useWorking);
|
|
|
|
} else {
|
2008-12-10 12:37:32 -06:00
|
|
|
PyErr_SetString(ConstructorError, "invalid number of parameters for getLayer.");
|
|
|
|
return NULL;
|
2012-11-16 06:48:38 -06:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
PyErr_SetString(ConstructorError, "Hurricane.getLayer(): Bad parameter(s) type.");
|
|
|
|
return NULL;
|
2008-12-10 12:37:32 -06:00
|
|
|
}
|
2008-03-06 10:46:43 -06:00
|
|
|
HCATCH
|
2008-12-10 12:37:32 -06:00
|
|
|
|
Complete replacement of the Chip placement Python scripts.
Finally get rid of the demonic code from Wu Yifei...
* New: In Isobar, added encapsulation of Interval (don't know how have
forgotten it for so long).
* Change: In Isobar, In PyLayer, new PyLink_LayerDerived() function to
create/link the C++ object to the correct derived class and not the
base one (PyLayer) which then prevent to use the specialized methods.
Must replace PyLink_Layer() througout all the code.
* Change: In Isobar, in PyPoint the "setX()" & "setY()" methods where
still capitalized.
* Change: In Isobar, in PyQuery, complete the exportation of the C++
interface. remove the code belonging to a more "boost" way of
building the Python interface (will do that in a far future).
* New: In CRL Core, In PyAllianceFramework, export isPad() method.
* Change: In Unicorn, in unicornInit.py, protect the loading of each
single plugin by a "try" / "except" clause to the failing of one
plugins do not stop the loading of the next one.
Pass the same dictionnary argument to unicornHook() as for
ScripMain(), this is more uniform this way.
* New: In Cumulus, complete replacement of the chip placement scripts
from Wu Yifei (at last!). The clock-tree integration is still to
be done.
________________________________________________________________________
2014-07-21 06:18:34 -05:00
|
|
|
return PyLayer_LinkDerived(layer);
|
2008-03-06 10:46:43 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-16 06:48:38 -06:00
|
|
|
static PyObject* PyTechnology_getBasicLayers ( PyTechnology* self, PyObject* args )
|
|
|
|
{
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(20,0) << "PyTechnology_getBasicLayers()" << endl;
|
2012-11-16 06:48:38 -06:00
|
|
|
|
|
|
|
PyBasicLayerCollection* pyObjects = NULL;
|
|
|
|
|
|
|
|
HTRY
|
|
|
|
METHOD_HEAD("Technology.getBasicLayers()")
|
|
|
|
|
|
|
|
PyObject* pyMask = NULL;
|
|
|
|
BasicLayers* objects = NULL;
|
|
|
|
|
|
|
|
if (PyArg_ParseTuple( args, "O:Technology.getBasicLayers()", &pyMask)) {
|
|
|
|
if (not IsPyLayerMask(pyMask)) {
|
|
|
|
PyErr_SetString ( ConstructorError
|
|
|
|
, "Technology.getBasicLayers(): First argument is not of Layer.Mask type." );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
PyErr_SetString ( ConstructorError
|
|
|
|
, "Invalid number of parameters passed to Technology.getBasicLayers()." );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pyMask != NULL)
|
|
|
|
objects = new BasicLayers(techno->getBasicLayers(PYLAYERMASK_O(pyMask)));
|
|
|
|
else
|
|
|
|
objects = new BasicLayers(techno->getBasicLayers());
|
|
|
|
|
|
|
|
pyObjects = PyObject_NEW(PyBasicLayerCollection,&PyTypeBasicLayerCollection);
|
|
|
|
if (pyObjects == NULL) return NULL;
|
|
|
|
pyObjects->_object = objects;
|
|
|
|
HCATCH
|
|
|
|
|
|
|
|
return (PyObject*)pyObjects;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static PyObject* PyTechnology_setWorkingLayer ( PyTechnology *self, PyObject* args ) {
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(20,0) << "Technology.setWorkingLayer()" << endl;
|
2012-11-16 06:48:38 -06:00
|
|
|
|
|
|
|
METHOD_HEAD("Technology.setWorkingLayer()")
|
|
|
|
|
|
|
|
bool rvalue = false;
|
|
|
|
|
|
|
|
HTRY
|
|
|
|
PyObject* arg0 = NULL;
|
|
|
|
if (PyArg_ParseTuple(args,"O:Technology.setWorkingLayer", &arg0)) {
|
|
|
|
if (PyString_Check(arg0)) {
|
|
|
|
rvalue = techno->setWorkingLayer(Name(PyString_AsString(arg0)));
|
|
|
|
} else if (IsPyLayer(arg0)) {
|
|
|
|
rvalue = techno->setWorkingLayer(PYLAYER_O(arg0));
|
|
|
|
} else {
|
|
|
|
PyErr_SetString(ConstructorError, "Hurricane.setWorkingLayer(): Invalid number of parameters.");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
PyErr_SetString(ConstructorError, "Hurricane.setWorkingLayer(): Bad parameter type.");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
HCATCH
|
|
|
|
|
|
|
|
if (rvalue) Py_RETURN_TRUE;
|
|
|
|
Py_RETURN_FALSE;
|
|
|
|
}
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
// Standart Accessors (Attributes).
|
2012-11-16 06:48:38 -06:00
|
|
|
GetNameMethod (Technology,techno)
|
|
|
|
SetNameMethod (Technology,techno)
|
|
|
|
predicateFromLayer (isMetal ,PyTechnology,Technology)
|
|
|
|
accessorAnyLayerFromName (getBasicLayer ,PyTechnology,Technology,BasicLayer )
|
|
|
|
accessorAnyLayerFromName (getRegularLayer ,PyTechnology,Technology,RegularLayer)
|
|
|
|
accessorAnyLayerFromName (getViaLayer ,PyTechnology,Technology,ViaLayer )
|
|
|
|
accessorCollectionFromVoid (getLayers ,PyTechnology,Technology,Layer )
|
|
|
|
accessorCollectionFromVoid (getRegularLayers,PyTechnology,Technology,RegularLayer)
|
|
|
|
accessorCollectionFromVoid (getViaLayers ,PyTechnology,Technology,ViaLayer )
|
|
|
|
accessorLayerFromLayerOptBool(getMetalAbove ,PyTechnology,Technology)
|
|
|
|
accessorLayerFromLayerOptBool(getMetalBelow ,PyTechnology,Technology)
|
|
|
|
accessorLayerFromLayerOptBool(getCutAbove ,PyTechnology,Technology)
|
|
|
|
accessorLayerFromLayerOptBool(getCutBelow ,PyTechnology,Technology)
|
|
|
|
accessorLayerFromLayerLayer (getViaBetween ,PyTechnology,Technology)
|
|
|
|
accessorLayerFromInt (getNthMetal ,PyTechnology,Technology)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
// Standard destroy (Attribute).
|
|
|
|
DBoDestroyAttribute(PyTechnology_destroy, PyTechnology)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
|
|
|
// PyTechnology Attribute Method table.
|
|
|
|
|
|
|
|
PyMethodDef PyTechnology_Methods[] =
|
2012-11-16 06:48:38 -06:00
|
|
|
{ { "create" , (PyCFunction)PyTechnology_create , METH_VARARGS|METH_STATIC
|
|
|
|
, "Create the Technology object." }
|
|
|
|
, { "isMetal" , (PyCFunction)PyTechnology_isMetal , METH_VARARGS
|
|
|
|
, "Tells if the given layer is of metal kind (Material)." }
|
|
|
|
, { "getDataBase" , (PyCFunction)PyTechnology_getDataBase , METH_NOARGS
|
|
|
|
, "Returns the associated DataBase." }
|
|
|
|
, { "getName" , (PyCFunction)PyTechnology_getName , METH_NOARGS
|
|
|
|
, "Returns the name of the technology." }
|
|
|
|
, { "getLayer" , (PyCFunction)PyTechnology_getLayer , METH_VARARGS
|
|
|
|
, "Returns the layer named name." }
|
|
|
|
, { "getBasicLayer" , (PyCFunction)PyTechnology_getBasicLayer , METH_VARARGS
|
|
|
|
, "Returns the BasicLayer named name." }
|
|
|
|
, { "getRegularLayer" , (PyCFunction)PyTechnology_getRegularLayer , METH_VARARGS
|
|
|
|
, "Returns the RegularLayer named name." }
|
|
|
|
, { "getViaLayer" , (PyCFunction)PyTechnology_getViaLayer , METH_VARARGS
|
|
|
|
, "Returns the ViaLayer named name." }
|
|
|
|
, { "getLayers" , (PyCFunction)PyTechnology_getLayers , METH_NOARGS
|
|
|
|
, "Returns the collection of all Layers." }
|
|
|
|
, { "getBasicLayers" , (PyCFunction)PyTechnology_getBasicLayers , METH_VARARGS
|
|
|
|
, "Returns the collection of all BasicLayers." }
|
|
|
|
, { "getRegularLayers" , (PyCFunction)PyTechnology_getRegularLayers, METH_NOARGS
|
|
|
|
, "Returns the collection of all RegularLayers." }
|
|
|
|
, { "getViaLayers" , (PyCFunction)PyTechnology_getViaLayers , METH_NOARGS
|
|
|
|
, "Returns the collection of all BasicLayers." }
|
|
|
|
, { "getMetalAbove" , (PyCFunction)PyTechnology_getMetalAbove , METH_VARARGS
|
|
|
|
, "Returns the metal layer immediatly above this one." }
|
|
|
|
, { "getMetalBelow" , (PyCFunction)PyTechnology_getMetalBelow , METH_VARARGS
|
|
|
|
, "Returns the metal layer immediatly below this one." }
|
|
|
|
, { "getCutAbove" , (PyCFunction)PyTechnology_getCutAbove , METH_VARARGS
|
|
|
|
, "Returns the cut layer immediatly above this one." }
|
|
|
|
, { "getCutBelow" , (PyCFunction)PyTechnology_getCutBelow , METH_VARARGS
|
|
|
|
, "Returns the cut layer immediatly below." }
|
|
|
|
, { "getViaBetween" , (PyCFunction)PyTechnology_getViaBetween , METH_VARARGS
|
|
|
|
, "Returns the VIA between those two layers (must be adjacent)." }
|
|
|
|
, { "getNthMetal" , (PyCFunction)PyTechnology_getNthMetal , METH_VARARGS
|
|
|
|
, "Returns Nth metal (zero is nearest substrate)." }
|
|
|
|
, { "setName" , (PyCFunction)PyTechnology_setName , METH_VARARGS
|
|
|
|
, "Allows to change the technology name." }
|
|
|
|
, { "setWorkingLayer" , (PyCFunction)PyTechnology_setWorkingLayer , METH_VARARGS
|
|
|
|
, "Mark a Layer as the working one (by name or by Layer)." }
|
|
|
|
, { "destroy" , (PyCFunction)PyTechnology_destroy , METH_NOARGS
|
|
|
|
, "Destroy associated hurricane object The python object remains." }
|
|
|
|
, {NULL, NULL, 0, NULL} /* sentinel */
|
2008-03-06 10:46:43 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
DBoDeleteMethod(Technology)
|
|
|
|
PyTypeObjectLinkPyType(Technology)
|
|
|
|
|
2012-11-16 06:48:38 -06:00
|
|
|
|
2008-03-06 10:46:43 -06:00
|
|
|
#else // End of Python Module Code Part.
|
|
|
|
|
|
|
|
|
2012-11-16 06:48:38 -06:00
|
|
|
// +=================================================================+
|
2008-03-06 10:46:43 -06:00
|
|
|
// | "PyTechnology" Shared Library Code Part |
|
2012-11-16 06:48:38 -06:00
|
|
|
// +=================================================================+
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
// Link/Creation Method.
|
2008-10-12 08:37:33 -05:00
|
|
|
DBoLinkCreateMethod(Technology)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
|
|
|
// PyTechnology Object Definitions.
|
2012-11-16 06:48:38 -06:00
|
|
|
|
2008-10-12 08:37:33 -05:00
|
|
|
PyTypeObjectDefinitions(Technology)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
#endif // End of Shared Library Code Part.
|
|
|
|
|
2012-11-16 06:48:38 -06:00
|
|
|
} // extern "C".
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2012-11-16 06:48:38 -06:00
|
|
|
} // Isobar namespace.
|
2008-03-06 10:46:43 -06:00
|
|
|
|