Sk2Py 0.2


The Sk2py program is designed to assist the conversion of Skill™ based PCells into the Python language based PyCells [1].  Sk2Py recognizes typical Skill™ extensions used in PCell development and translates them to the appropriate PyCell calls.   Sk2py assumes syntactically-correct Skill™ for input, and produces syntactically-correct Python code as output.  Sk2Py provides a re-writer interface object API to allow for user-extensible additions for Skill™ to Python translation of non-standard Skill™ calls.   

The Sk2Py tool is designed primarily as an aid in the Skill™ to Python translation process.  Not all Skill™ PCell constructs are supported or even directly translatable into Python as the parameterized cells methodologies are not entirely equivalent in functionality and scope.   As such, the Sk2Py tool is configured for interactive use (load/edit/compile).

This manual briefly discusses installation and provides an introductory overview of the usage of sk2py tool.  

Sk2Py Requirements

Scope of Translation Support

Sk2py supports Skill™ PCells defined in the following syntax:

pcDefinePCell (







The cellIdentifier is a list containing the library database ID, cell name, view name, and view type.  The cellParameters construct is a list of input parameters and their default values. The cellBodyDefinition creates the cell geometries.  Local variables must be enclosed within a let() statement.  The returnValue is the return value for the pcDefinePCell (typically t, or true).

Known Limitations

Installation and Usage

The sk2py interface is setup to allow load/edit/compile of Skill™ to Python PyCells.  The left side is an editor for the loaded Skill™ code, the right side for generated Python code, and the bottom is a message logging window.  The following steps outline the installation and usage of sk2py.

  1. Install both Python ( and wxPython (  Make sure a binary install of wxPython corresponds to the version of Python you have installed.
  2. Unpack  This will unzip into a directory named sk2py.
  3. On Unix, Sk2Py supports compilation of generated PyCells to allow a load->translate->edit->compile interactive methodology (only Python static syntax checking is supported on Windows at this time).  If you will not be doing compilations of the translated output, you can skip the following step.
  4. To support the compilation of PyCells on Unix, Sk2Py makes the following assumptions[1] regarding the setup:

There is a prototype Sk2PyCellsLib under the sk2py distribution.  Copy this to your HOME directory.  This directory contains three files:  lib.defs,, and  The file contains the package definitions for the library.  The module is provided as an example of how toYou will need to edit this and add additional definitions as you do you migrate each Skill™ PCell.  

First, you will then need to create the Open Access library by doing the following:

%> cngenlib –-create –-techfile \

  $HOME/Sk2PyTechLib/ pkg:Sk2PyCells \

Sk2PyCellLib $HOME/Sk2PyCellLib


Refer to the Ciranova documentation for details on cngenlib.

  1. If all the installations were done properly, the file associations for Python should be set up such that you can:
  2. If successful, the sk2py UI should appear (Figure 1 below).  You can load a Skill™ PCell via File->Open.  The sk2py distribution comes with PCells from the NCSU standard library distribution (under directory NCSUpcells).  Opening a Skill™ PCell will load it into the left-hand side editor. The file can be edited, saved, and/or saved as a new file.  You can then do an automatic migration to Python by clicking “Gen PyCell”. 

Figure 1.  sk2py UI showing basic layout of side-by-side views of  Skill™ and translated Python.


  1. The generated Python PyCell can also edited, saved and/or saved as a different file.  You can check the syntax of the PyCell by clicking on “Compile PyCell” (again, on Windows, this only invokes the Python compiler which provides simple syntax checking).    To utilize the compilation in Sk2Py, you must do the following:


#  file:


from test import *


def definePcells(lib):

     lib.definePcell(test, “test”)


Given the module being migrated is called nmos (from “class nmos(DloGen)” in the PyCell), you would edit the file to be the following:


#  file:


from test import *

from nmos import *


def definePcells(lib):

     lib.definePcell(test, “test”)

     lib.definePcell(nmos, “nmos”)


You can now click on “Compile PyCell” to recompile the OpenAccess library and check for errors (Figure 2).

Figure 2.  Compiling the translated PCell to check for errors.


  1. Typically the translation is not complete and requires manual intervention.   Primarily, this is due to a combination of unsupported constructs and/or incompatibilities between the APIs.  Also, runtime errors will also be evident as the technology files may be incompatible.

However, with the side-by-side view, you can edit the Skill™ PCell, migrate and re-compile.  You can also custom edit the PyCell prior to compilation.  This particular example illustrated how you should be able to translate the bulk of the code relatively easy.   Once you pass compilation tests within Sk2Py, you can view the cells in the Ciranova viewer by:

%> cngenlib –-create –-view –-techfile \

  $HOME/Sk2PyTechLib/ pkg:Sk2PyCells \

Sk2PyCellLib $HOME/Sk2PyCellLib

The viewer will create views for all your modules within your Sk2PyCellLib using the default arguments (Figure 3).  You can use the viewer to test for additional combinations of parameters.   This should provide a good starting point for additional debugging and module refinement.

Figure 3.  Ciranova viewer showing the results of automatic translation of Skill™ PCell to Python PyCell.






Extending Sk2Py Through the Rewriter API

The Sk2Py API allows custom translation of both supported and unsupported Skill™ functions.  The process involves two steps including 1) creating a Python class derived from class RWIntfc and implementing the required methods, and 2) registering the class with the translator interface of Sk2Py.    The rewriter classes are accessible from the Sk2Py UI via File->Rewriter.  File->Rewriter displays an editor interface for the rewriter classes (Figure 2).   The following will describe the rewriter API and illustrate an example of its use.

NOTE:  Because Python generates scopes lexically (by indentation), Python is very strict about usage of tabs vs. spaces.  Make sure you are consistent in the usage of any files you edit, or you will have compile errors.  Currently checking is minimal through the Rewriter API.  If you have a debugger IDE for Python, that would be the recommended route to extend the API as issues of white space are better dealt with.


Figure 4.  Rewriter editor for mapping Skill™  PCell to Python PyCell system calls.

Rewriter class

Rewriter classes allow the front end to translate system calls in Skill™ for PCells to Python syntax for PyCells.  The class methods are all static as no instances of these classes are actually created.  The static methods themselves provide the necessary functionality.  The RWIntfc base class is[3]:

class RWIntfc:

    def __init__(self):




    def who():

        # id of the function that object rewrites



   def type():

       # the return type of the function call.



   def strrep(args):

       # return a string representation of the

       # Python system call


The steps are illustrated below for the Skill™ dbCreateRect system call.  We will define a class that provides the interface to rewrite into Python PyCells.

  1. Open the rewriter editor.  File->Rewriter
  2. Define the Python re-writer object that translates the Skill™ call into the corresponding Python call for PyCells:

class DbCreateRect(RWIntfc):

    def __init__(self):




    def who():

        return "dbCreateRect"



    def type():

        return TV_OBJECT



    def strrep(args):

        rep = "Rect("

        argcnt = len(args)

        if argcnt != 3:

           rep += ")"

           return rep


        s1 = args[1].strrep()

        rep += "Layer(" + s1 + "),"

        s2 = args[2].strrep()

        rep += s2 + ")"

        return rep


Note the following:

    1. The class DbCreateRect is derived from the class RWIntfc
    2. The static class method “who()” only returns a string representations of the Skill™ system call.
    3. The return type of the system call in Skill™ is returned by the “type()” method.  In general, Skill™ system calls return type of TV_OBJECT.  There are other return types, such as TV_REAL, TV_STRING, etc.
    4. The static class method “strrep()” returns a string representation of the Python representation of the system call.  The argument “args” that is passed to the method is a tree representation of the arguments of the corresponding Skill™ system call.        
    5. Note that the “strrep()” method can check the number and type of arguments to determine how to re-write the Skill™.
  1. Register the Skill™ function name and Python re-writing object with the Sk2Py front end parser.  This is done at the end of the rewriter file.

def initRWIntfcObjs(frontend):


    . . .

  1. Click “OK” on the rewriter editor to close and compile the rewriter objects.  Any errors during compilation will appear in the logging window.









[1] These assumptions are expected to be removed in later releases.

[2] Refer to the Ciranova documentation for further details.

[3] There is one additional method, not shown, for the Python pretty printer interface.  It is omitted for brevity.