From ebc4a0cdbf1823f4cb298e01210183ec29a03bdb Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Sat, 27 Aug 2016 16:02:22 +0200 Subject: [PATCH] Complete Python support. * New: In PyAnabatic, export the various Engine constants. * Change: In Katana, in TrackElement and derived classes, add a getSegment() method for easier access to the underlying Hurricane segment. * New: In PyKatanaEngine, export the loadGlobalRouting method which was missing (for use by Unicorn/cgt). --- anabatic/src/PyAnabatic.cpp | 9 +++++++++ katana/src/KatanaEngine.cpp | 2 +- katana/src/PyKatanaEngine.cpp | 28 +++++++++++++++++++++++++++ katana/src/TrackFixedSegment.cpp | 1 + katana/src/TrackSegment.cpp | 1 + katana/src/katana/TrackElement.h | 1 + katana/src/katana/TrackFixedSegment.h | 3 ++- katana/src/katana/TrackSegment.h | 1 + 8 files changed, 44 insertions(+), 2 deletions(-) diff --git a/anabatic/src/PyAnabatic.cpp b/anabatic/src/PyAnabatic.cpp index ecd8ee3e..e05ec4d2 100644 --- a/anabatic/src/PyAnabatic.cpp +++ b/anabatic/src/PyAnabatic.cpp @@ -82,6 +82,15 @@ extern "C" { PyModule_AddObject( module, "AnabaticEngine", (PyObject*)&PyTypeAnabaticEngine ); Py_INCREF( &PyTypeGraphicAnabaticEngine ); PyModule_AddObject( module, "GraphicAnabaticEngine", (PyObject*)&PyTypeGraphicAnabaticEngine ); + + PyObject* dictionnary = PyModule_GetDict(module); + PyObject* constant; + + LoadObjectConstant( dictionnary,EngineLoadGrByNet ,"EngineLoadGrByNet" ); + LoadObjectConstant( dictionnary,EngineLoadGrByGCell ,"EngineLoadGrByGCell" ); + LoadObjectConstant( dictionnary,EngineLayerAssignByLength,"EngineLayerAssignByLength" ); + LoadObjectConstant( dictionnary,EngineLayerAssignByTrunk ,"EngineLayerAssignByTrunk" ); + LoadObjectConstant( dictionnary,EngineNoNetLayerAssign ,"EngineNoNetLayerAssign" ); } diff --git a/katana/src/KatanaEngine.cpp b/katana/src/KatanaEngine.cpp index 7b4035cc..d047e37f 100644 --- a/katana/src/KatanaEngine.cpp +++ b/katana/src/KatanaEngine.cpp @@ -284,7 +284,7 @@ namespace Katana { continue; } - Segment* segment = element->base()->base(); + Segment* segment = element->getSegment(); Flags side = Flags::EastSide; DbU::Unit axis = segment->getY(); if (track->getDirection() == Flags::Vertical) { diff --git a/katana/src/PyKatanaEngine.cpp b/katana/src/PyKatanaEngine.cpp index ce573e44..e1022747 100644 --- a/katana/src/PyKatanaEngine.cpp +++ b/katana/src/PyKatanaEngine.cpp @@ -173,6 +173,32 @@ extern "C" { } + PyObject* PyKatanaEngine_loadGlobalRouting ( PyKatanaEngine* self, PyObject* args ) + { + cdebug_log(40,0) << "PyKatanaEngine_loadGlobalRouting()" << endl; + + HTRY + METHOD_HEAD("KatanaEngine.loadGlobalRouting()") + unsigned int flags = 0; + if (PyArg_ParseTuple(args,"I:KatanaEngine.loadGlobalRouting", &flags)) { + if (katana->getViewer()) { + if (ExceptionWidget::catchAllWrapper( std::bind(&KatanaEngine::loadGlobalRouting,katana,flags) )) { + PyErr_SetString( HurricaneError, "KatanaEngine::loadGlobalrouting() has thrown an exception (C++)." ); + return NULL; + } + } else { + katana->loadGlobalRouting(flags); + } + } else { + PyErr_SetString(ConstructorError, "KatanaEngine.loadGlobalRouting(): Invalid number/bad type of parameter."); + return NULL; + } + HCATCH + + Py_RETURN_NONE; + } + + PyObject* PyKatanaEngine_layerAssign ( PyKatanaEngine* self, PyObject* args ) { cdebug_log(40,0) << "PyKatanaEngine_layerAssign()" << endl; @@ -265,6 +291,8 @@ extern "C" { , "Returns True if the detailed routing has been successful." } , { "runGlobalRouter" , (PyCFunction)PyKatanaEngine_runGlobalRouter , METH_VARARGS , "Run the global router (Knik)." } + , { "loadGlobalRouting" , (PyCFunction)PyKatanaEngine_loadGlobalRouting , METH_VARARGS + , "Load global routing into the detailed router." } , { "layerAssign" , (PyCFunction)PyKatanaEngine_layerAssign , METH_VARARGS , "Run the layer assigment stage." } , { "runNegociatePreRouted", (PyCFunction)PyKatanaEngine_runNegociatePreRouted, METH_NOARGS diff --git a/katana/src/TrackFixedSegment.cpp b/katana/src/TrackFixedSegment.cpp index dc5336f6..99946ef2 100644 --- a/katana/src/TrackFixedSegment.cpp +++ b/katana/src/TrackFixedSegment.cpp @@ -131,6 +131,7 @@ namespace Katana { AutoSegment* TrackFixedSegment::base () const { return NULL; } + Segment* TrackFixedSegment::getSegment () const { return _segment; } DbU::Unit TrackFixedSegment::getAxis () const { return getTrack()->getAxis(); } bool TrackFixedSegment::isHorizontal () const { return getTrack()->isHorizontal(); } bool TrackFixedSegment::isVertical () const { return getTrack()->isVertical(); } diff --git a/katana/src/TrackSegment.cpp b/katana/src/TrackSegment.cpp index cf70ebad..3265cf83 100644 --- a/katana/src/TrackSegment.cpp +++ b/katana/src/TrackSegment.cpp @@ -145,6 +145,7 @@ namespace Katana { // Formerly Inline Functions. // Wrappeds. AutoSegment* TrackSegment::base () const { return _base; } + Segment* TrackSegment::getSegment () const { return _base->base(); } bool TrackSegment::isFixed () const { return _base->isFixed(); } bool TrackSegment::isHorizontal () const { return _base->isHorizontal(); } bool TrackSegment::isVertical () const { return _base->isVertical(); } diff --git a/katana/src/katana/TrackElement.h b/katana/src/katana/TrackElement.h index 23de250a..0fb05005 100644 --- a/katana/src/katana/TrackElement.h +++ b/katana/src/katana/TrackElement.h @@ -89,6 +89,7 @@ namespace Katana { public: void destroy (); virtual AutoSegment* base () const; + virtual Segment* getSegment () const = 0; // Wrapped AutoSegment Functions (when applicable). virtual bool isFixed () const; virtual bool isHorizontal () const = 0; diff --git a/katana/src/katana/TrackFixedSegment.h b/katana/src/katana/TrackFixedSegment.h index 5212dd5f..3af7060b 100644 --- a/katana/src/katana/TrackFixedSegment.h +++ b/katana/src/katana/TrackFixedSegment.h @@ -10,7 +10,7 @@ // | Author : Jean-Paul CHAPUT | // | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | =============================================================== | -// | C++ Header : "./katana/TrackFixedSegment.h" | +// | C++ Header : "./katana/TrackFixedSegment.h" | // +-----------------------------------------------------------------+ @@ -41,6 +41,7 @@ namespace Katana { static TrackElement* create ( Katana::Track* track , Segment* segment ); public: virtual AutoSegment* base () const; + virtual Segment* getSegment () const; virtual bool isHorizontal () const; virtual bool isVertical () const; virtual bool isFixed () const; diff --git a/katana/src/katana/TrackSegment.h b/katana/src/katana/TrackSegment.h index 5d224cf8..8ff4886b 100644 --- a/katana/src/katana/TrackSegment.h +++ b/katana/src/katana/TrackSegment.h @@ -56,6 +56,7 @@ namespace Katana { public: // Wrapped AutoSegment Functions (when applicable). virtual AutoSegment* base () const; + virtual Segment* getSegment () const; virtual bool isFixed () const; virtual bool isHorizontal () const; virtual bool isVertical () const;