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 supports Skill™ PCells defined in the following syntax:
pcDefinePCell (
cellIdentifier
cellParameters
cellBodyDefinition
returnValue
)
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).
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.
There is a prototype Sk2PyCellsLib under the sk2py distribution. Copy this to your HOME directory. This directory contains three files: lib.defs, __init__.py, and test.py. The file __init__.py contains the package definitions for the library. The module test.py 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/Santana.tech pkg:Sk2PyCells \
Sk2PyCellLib $HOME/Sk2PyCellLib
Refer to the Ciranova documentation for details on cngenlib.
Figure 1. sk2py UI showing basic layout of side-by-side views of Skill™ and translated Python.
# file: __init__.py
#
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: __init__.py
#
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.
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/Santana.tech 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.
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 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):
pass
@staticmethod
def who():
# id of the function that object rewrites
@staticmethod
def type():
# the return type of the function call.
@staticmethod
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.
class DbCreateRect(RWIntfc):
def __init__(self):
RWIntfc.__init__(self)
@staticmethod
def who():
return "dbCreateRect"
@staticmethod
def type():
return TV_OBJECT
@staticmethod
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:
def initRWIntfcObjs(frontend):
frontend.regIntfcObj(DdGetObj)
. . .
[1]. http://www.ciranova.com/products/five_reasons.php