Fix style, imports, stale code.
authorJock Tanner <tanner.of.kha@gmail.com>
Fri, 13 Mar 2020 14:47:29 +0000 (14:47 +0000)
committerJock Tanner <tanner.of.kha@gmail.com>
Fri, 13 Mar 2020 14:47:29 +0000 (14:47 +0000)
experiments7/doAlu16.py

index 395b6579ebbb44bc0a5f56ccf9956ae54c078a54..513632343b1b249b9f71c3ad4b6f57c78c6669a9 100755 (executable)
@@ -1,42 +1,26 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
-
+from __future__ import print_function
 import sys
-import re
-import traceback
-import os.path
-import optparse
-import Cfg
-import Hurricane
-from Hurricane import DbU
-from Hurricane import DataBase
-from Hurricane import UpdateSession
-from Hurricane import Breakpoint
-from Hurricane import Box
-from Hurricane import Transformation
-from Hurricane import Instance
-from Hurricane import Net
-from Hurricane import Contact
-from Hurricane import Vertical
-from Hurricane import Pad
-from Hurricane import Pin
-from Hurricane import NetExternalComponents
-import Viewer
+
+import Anabatic
 import CRL
+import Cfg
 import Etesian
-import Anabatic
 import Katana
-import Unicorn
-from helpers import l, u, n
 import clocktree.ClockTree
-import plugins.RSavePlugin
-import plugins.ClockTreePlugin
-import symbolic.cmos
+from Hurricane import (
+    DbU, DataBase, UpdateSession, Box, Transformation, Instance,
+    Contact, Vertical, Pad, Pin, NetExternalComponents,
+)
+from helpers import l, showPythonTrace
+from plugins import ClockTreePlugin, RSavePlugin
 
 af = CRL.AllianceFramework.get()
 
 
-def toDbU(l): return DbU.fromLambda(l)
+def toDbU(l):
+    return DbU.fromLambda(l)
 
 
 def createVertical(contacts, x, layer, width=None):
@@ -48,33 +32,19 @@ def createVertical(contacts, x, layer, width=None):
     if width is None: width = l(2.0)
 
     for i in range(1, len(contacts)):
-        print "create vert", contacts[i - 1], contacts[i], layer, x, width
+        print("create vert", contacts[i - 1], contacts[i], layer, x, width)
         v = Vertical.create(contacts[i - 1], contacts[i], layer, x, width)
-        print "v", v
-
-
-def createHorizontal(contactPaths, y, layer, width=None):
-    def xincrease(lhs, rhs):
-        return int(lhs.getX() - rhs.getX())
-
-    contacts = contactPaths
-
-    if width is None: width = toDbU(2.0)
-
-    contacts.sort(xincrease)
-
-    for i in range(1, len(contacts)):
-        Horizontal.create(contacts[i - 1], contacts[i], layer, y, width)
+        print("v", v)
 
 
 def build_downtrace(net, layer, x, y, y1):
-    contacts = \
-        [Contact.create(net, layer, l(x), l(y), l(2.0), l(2.0))
-            , Contact.create(net, layer, l(x), l(y1), l(2.0), l(2.0))
-         ]
+    contacts = [
+        Contact.create(net, layer, l(x), l(y), l(2.0), l(2.0)),
+        Contact.create(net, layer, l(x), l(y1), l(2.0), l(2.0)),
+    ]
 
     createVertical(contacts, l(x), layer)
-    print "slaves", contacts[-1].getSlaveComponents()
+    print("slaves", contacts[-1].getSlaveComponents())
     for component in contacts[-1].getSlaveComponents():
         NetExternalComponents.setExternal(component)
 
@@ -101,10 +71,12 @@ def coriolisSetup():
 
     cellsTop = '~/alliance-check-toolkit/cells'
     env = af.getEnvironment()
-    env.addSYSTEM_LIBRARY(library=cellsTop + '/nsxlib',
-                          mode=CRL.Environment.Prepend)
-    env.addSYSTEM_LIBRARY(library=cellsTop + '/mpxlib',
-                          mode=CRL.Environment.Prepend)
+    env.addSYSTEM_LIBRARY(
+        library=cellsTop + '/nsxlib', mode=CRL.Environment.Prepend
+    )
+    env.addSYSTEM_LIBRARY(
+        library=cellsTop + '/mpxlib', mode=CRL.Environment.Prepend
+    )
 
     Cfg.getParamBool('misc.catchCore').setBool(False)
     Cfg.getParamBool('misc.info').setBool(False)
@@ -113,8 +85,6 @@ def coriolisSetup():
     Cfg.getParamBool('misc.logMode').setBool(True)
     Cfg.getParamBool('misc.verboseLevel1').setBool(True)
     Cfg.getParamBool('misc.verboseLevel2').setBool(True)
-    # Cfg.getParamInt       ( 'misc.minTraceLevel'          ).setInt       ( 111     )
-    # Cfg.getParamInt       ( 'misc.maxTraceLevel'          ).setInt       ( 112     )
     Cfg.getParamEnumerate('etesian.effort').setInt(2)
     Cfg.getParamPercentage('etesian.spaceMargin').setPercentage(20.0)
     Cfg.getParamPercentage('etesian.aspectRatio').setPercentage(100.0)
@@ -126,7 +96,6 @@ def coriolisSetup():
     Cfg.getParamInt('katana.eventsLimit').setInt(1000000)
     Cfg.getParamInt('katana.hTracksReservedLocal').setInt(7)
     Cfg.getParamInt('katana.vTracksReservedLocal').setInt(6)
-    # Cfg.getParamInt       ( 'clockTree.minimumSide'       ).setInt       ( l(1000) )
 
     env = af.getEnvironment()
     env.setCLOCK('^clk$|m_clock')
@@ -136,404 +105,344 @@ def coriolisSetup():
     Cfg.Configuration.popDefaultPriority()
 
 
-# -------------------------------------------------------------------------------
-# add()
-
-def add(**kw):
-    editor = None
-    if kw.has_key('editor') and kw['editor']:
-        editor = kw['editor']
+def add(**kwargs):
+    editor = kwargs.get('editor', None)
 
     db = DataBase.getDB()
-    print db, dir(db)
-    METAL2 = DataBase.getDB().getTechnology().getLayer('METAL2')
+    print(db, dir(db))
     METAL3 = DataBase.getDB().getTechnology().getLayer('METAL3')
-    METAL5 = DataBase.getDB().getTechnology().getLayer('METAL5')
     BLOCKAGE2 = DataBase.getDB().getTechnology().getLayer('BLOCKAGE2')
     BLOCKAGE3 = DataBase.getDB().getTechnology().getLayer('BLOCKAGE3')
     BLOCKAGE4 = DataBase.getDB().getTechnology().getLayer('BLOCKAGE4')
-    BLOCKAGE5 = DataBase.getDB().getTechnology().getLayer('BLOCKAGE5')
 
     cell = af.getCell('add', CRL.Catalog.State.Logical)
-    print cell.getNet('a(0)')
+    print(cell.getNet('a(0)'))
 
     if not cell:
-        print '[ERROR] Unable to load cell "add.vst", aborting .'
+        print('[ERROR] Unable to load cell "add.vst", aborting .')
         return False
 
-    kw['cell'] = cell
+    kwargs['cell'] = cell
 
     width = 350.0
     height = 400.0
 
-    ab = Box(l(0.0)
-             , l(0.0)
-             , l(width)
-             , l(height))
+    ab = Box(l(0.0), l(0.0), l(width), l(height))
 
     cellGauge = af.getCellGauge()
-    spaceMargin = (Cfg.getParamPercentage(
-        'etesian.spaceMargin').asPercentage() + 5) / 100.0
-    aspectRatio = Cfg.getParamPercentage(
-        'etesian.aspectRatio').asPercentage() / 100.0
-    clocktree.ClockTree.computeAbutmentBox(cell, spaceMargin, aspectRatio,
-                                           cellGauge)
+    margin_as_percentage = Cfg.getParamPercentage(
+        'etesian.spaceMargin'
+    ).asPercentage()
+    spaceMargin = (margin_as_percentage + 5) / 100.0
+    aspectRatio = margin_as_percentage / 100.0
+    clocktree.ClockTree.computeAbutmentBox(
+        cell, spaceMargin, aspectRatio, cellGauge,
+    )
     ab2 = cell.getAbutmentBox()
-    print "box", ab, ab.getHeight(), ab.getWidth()
-    print "calc box", ab2, ab2.getHeight(), ab2.getWidth()
-
-    # height = ab.getHeight()
-    # width = ab.getWidth()
+    print("box", ab, ab.getHeight(), ab.getWidth())
+    print("calc box", ab2, ab2.getHeight(), ab2.getWidth())
 
     UpdateSession.open()
     cell.setAbutmentBox(ab)
 
     for i in range(16):
-        if True:
-            x = 20.0 * i + 10.0
-            y = height
-            pin = Pin.create(cell.getNet('a(%d)' % i)
-                             , 'a(%d).0' % i
-                             , Pin.Direction.NORTH
-                             , Pin.PlacementStatus.FIXED
-                             , METAL3
-                             , l(x), l(y - 0)  # Position.
-                             , l(2.0), l(2.0)  # Size.
-                             )
-            pin.getNet().setExternal(True)
-            NetExternalComponents.setExternal(pin)
+        x = 20.0 * i + 10.0
+        y = height
+        pin = Pin.create(
+            cell.getNet('a(%d)' % i),
+            'a(%d).0' % i,
+            Pin.Direction.NORTH,
+            Pin.PlacementStatus.FIXED,
+            METAL3,
+            l(x),
+            l(y - 0),  # Position.
+            l(2.0), l(2.0),  # Size.
+        )
+        pin.getNet().setExternal(True)
+        NetExternalComponents.setExternal(pin)
+
     for i in range(16):
-        if True:
-            pin = Pin.create(cell.getNet('o(%d)' % i)
-                             , 'o(%d).0' % i
-                             , Pin.Direction.SOUTH
-                             , Pin.PlacementStatus.FIXED
-                             , METAL3
-                             , l(10.0 * i + 100.0), l(0)  # Position.
-                             , l(2.0), l(2.0)  # Size.
-                             )
-            pin.getNet().setExternal(True)
-            NetExternalComponents.setExternal(pin)
+        pin = Pin.create(
+            cell.getNet('o(%d)' % i),
+            'o(%d).0' % i,
+            Pin.Direction.SOUTH,
+            Pin.PlacementStatus.FIXED,
+            METAL3,
+            l(10.0 * i + 100.0),
+            l(0),  # Position.
+            l(2.0),
+            l(2.0),  # Size.
+        )
+        pin.getNet().setExternal(True)
+        NetExternalComponents.setExternal(pin)
 
     for i in range(16):
-        if True:
-            net = cell.getNet('b(%d)' % i)
-            x = 20.0 * i + 10.0 + 10
-            y = height - 0
-            # build_downtrace(net, METAL3, x, y+11, y)
-            # continue
-            pin = Pin.create(net
-                             , 'b(%d).0' % i
-                             , Pin.Direction.NORTH
-                             , Pin.PlacementStatus.FIXED
-                             , METAL3
-                             , l(x), l(y - 0)  # Position.
-                             , l(2.0), l(2.0)  # Size.
-                             )
-            pin.getNet().setExternal(True)
-            NetExternalComponents.setExternal(pin)
-    if False:
-        pin = Pin.create(cell.getNet('rst')
-                         , 'p_reset.0'
-                         , Pin.Direction.WEST
-                         , Pin.PlacementStatus.FIXED
-                         , METAL2
-                         , l(0.0)
-                         , l(140.0)
-                         , l(2.0)
-                         , l(2.0)
-                         )
+        net = cell.getNet('b(%d)' % i)
+        x = 20.0 * i + 10.0 + 10
+        y = height - 0
+        pin = Pin.create(
+            net,
+            'b(%d).0' % i,
+            Pin.Direction.NORTH,
+            Pin.PlacementStatus.FIXED,
+            METAL3,
+            l(x),
+            l(y - 0),  # Position.
+            l(2.0),
+            l(2.0),  # Size.
+        )
         pin.getNet().setExternal(True)
         NetExternalComponents.setExternal(pin)
 
     UpdateSession.close()
 
-    if True:
-        if editor: editor.setCell(cell)
-
-        placeAndRoute(cell)
+    if editor:
+        editor.setCell(cell)
 
-        UpdateSession.open()
-        blockageNet = cell.getNet('blockagenet')
+    placeAndRoute(cell)
 
-        ab = cell.getAbutmentBox()
-        ab.inflate(toDbU(-5.0))
-        Pad.create(net, BLOCKAGE2, ab)
-        Pad.create(net, BLOCKAGE3, ab)
-        Pad.create(net, BLOCKAGE4, ab)
-        # Pad.create( net, BLOCKAGE5, ab )
-        UpdateSession.close()
-
-    if False:
-        UpdateSession.open()
-        cell.setAbutmentBox(ab)
-        for i in range(16):
-            if True:
-                net = cell.getNet('b(%d)' % i)
-                x = 20.0 * i + 10.0 + 10
-                y = height - 10
-                build_downtrace(net, METAL2, x, y, y + 10)
-        UpdateSession.close()
+    UpdateSession.open()
 
-    # af.saveCell( cell, CRL.Catalog.State.Views )
-    plugins.RSavePlugin.ScriptMain(**kw)
+    ab = cell.getAbutmentBox()
+    ab.inflate(toDbU(-5.0))
+    Pad.create(net, BLOCKAGE2, ab)  # do we really want to use net b(15)?
+    Pad.create(net, BLOCKAGE3, ab)
+    Pad.create(net, BLOCKAGE4, ab)
+    UpdateSession.close()
 
+    RSavePlugin.ScriptMain(**kwargs)
 
-# -------------------------------------------------------------------------------
-# sub
 
-def sub(**kw):
-    editor = None
-    if kw.has_key('editor') and kw['editor']:
-        editor = kw['editor']
+def sub(**kwargs):
+    editor = kwargs.get('editor', None)
 
     db = DataBase.getDB()
-    print db, dir(db)
-    METAL2 = DataBase.getDB().getTechnology().getLayer('METAL2')
+    print(db, dir(db))
     METAL3 = DataBase.getDB().getTechnology().getLayer('METAL3')
-    METAL5 = DataBase.getDB().getTechnology().getLayer('METAL5')
     BLOCKAGE2 = DataBase.getDB().getTechnology().getLayer('BLOCKAGE2')
     BLOCKAGE3 = DataBase.getDB().getTechnology().getLayer('BLOCKAGE3')
     BLOCKAGE4 = DataBase.getDB().getTechnology().getLayer('BLOCKAGE4')
-    BLOCKAGE5 = DataBase.getDB().getTechnology().getLayer('BLOCKAGE5')
 
     cell = af.getCell('sub', CRL.Catalog.State.Logical)
-    print cell.getNet('a(0)')
+    print(cell.getNet('a(0)'))
 
     if not cell:
-        print '[ERROR] Unable to load cell "alu16.vst", aborting .'
+        print('[ERROR] Unable to load cell "alu16.vst", aborting .')
         return False
-    kw['cell'] = cell
+
+    kwargs['cell'] = cell
 
     width = 350.0
     height = 400.0
 
-    ab = Box(l(0.0)
-             , l(0.0)
-             , l(width)
-             , l(height))
+    ab = Box(l(0.0), l(0.0), l(width), l(height))
 
     cellGauge = af.getCellGauge()
-    spaceMargin = (Cfg.getParamPercentage(
-        'etesian.spaceMargin').asPercentage() + 5) / 100.0
-    aspectRatio = Cfg.getParamPercentage(
-        'etesian.aspectRatio').asPercentage() / 100.0
-    clocktree.ClockTree.computeAbutmentBox(cell, spaceMargin, aspectRatio,
-                                           cellGauge)
+    margin_as_percentage = Cfg.getParamPercentage(
+        'etesian.spaceMargin'
+    ).asPercentage()
+    spaceMargin = (margin_as_percentage + 5) / 100.0
+    aspectRatio = margin_as_percentage / 100.0
+    clocktree.ClockTree.computeAbutmentBox(
+        cell, spaceMargin, aspectRatio, cellGauge,
+    )
     ab2 = cell.getAbutmentBox()
-    print "box", ab, ab.getHeight(), ab.getWidth()
-    print "calc box", ab2, ab2.getHeight(), ab2.getWidth()
-
-    # height = ab.getHeight()
-    # width = ab.getWidth()
+    print("box", ab, ab.getHeight(), ab.getWidth())
+    print("calc box", ab2, ab2.getHeight(), ab2.getWidth())
 
     UpdateSession.open()
     cell.setAbutmentBox(ab)
 
     for i in range(16):
-        if True:
-            x = 20.0 * i + 10.0
-            y = height
-            pin = Pin.create(cell.getNet('a(%d)' % i)
-                             , 'a(%d).0' % i
-                             , Pin.Direction.NORTH
-                             , Pin.PlacementStatus.FIXED
-                             , METAL3
-                             , l(x), l(y - 0)  # Position.
-                             , l(2.0), l(2.0)  # Size.
-                             )
-            pin.getNet().setExternal(True)
-            NetExternalComponents.setExternal(pin)
+        x = 20.0 * i + 10.0
+        y = height
+        pin = Pin.create(
+            cell.getNet('a(%d)' % i),
+            'a(%d).0' % i,
+            Pin.Direction.NORTH,
+            Pin.PlacementStatus.FIXED,
+            METAL3,
+            l(x),
+            l(y - 0),  # Position.
+            l(2.0),
+            l(2.0),  # Size.
+        )
+        pin.getNet().setExternal(True)
+        NetExternalComponents.setExternal(pin)
 
     for i in range(16):
-        if True:
-            pin = Pin.create(cell.getNet('o(%d)' % i)
-                             , 'o(%d).0' % i
-                             , Pin.Direction.SOUTH
-                             , Pin.PlacementStatus.FIXED
-                             , METAL3
-                             , l(10.0 * i + 100.0), l(0)  # Position.
-                             , l(2.0), l(2.0)  # Size.
-                             )
-            pin.getNet().setExternal(True)
-            NetExternalComponents.setExternal(pin)
+        pin = Pin.create(
+            cell.getNet('o(%d)' % i),
+            'o(%d).0' % i,
+            Pin.Direction.SOUTH,
+            Pin.PlacementStatus.FIXED,
+            METAL3,
+            l(10.0 * i + 100.0),
+            l(0),  # Position.
+            l(2.0),
+            l(2.0),  # Size.
+        )
+        pin.getNet().setExternal(True)
+        NetExternalComponents.setExternal(pin)
 
     for i in range(16):
-        if True:
-            net = cell.getNet('b(%d)' % i)
-            x = 20.0 * i + 10.0 + 10
-            y = height - 0
-            # build_downtrace(net, METAL3, x, y+11, y)
-            # continue
-            pin = Pin.create(net
-                             , 'b(%d).0' % i
-                             , Pin.Direction.NORTH
-                             , Pin.PlacementStatus.FIXED
-                             , METAL3
-                             , l(x), l(y)  # Position.
-                             , l(2.0), l(2.0)  # Size.
-                             )
-            pin.getNet().setExternal(True)
-            NetExternalComponents.setExternal(pin)
-
-    if False:
-        pin = Pin.create(cell.getNet('rst')
-                         , 'p_reset.0'
-                         , Pin.Direction.WEST
-                         , Pin.PlacementStatus.FIXED
-                         , METAL2
-                         , l(0.0)
-                         , l(140.0)
-                         , l(2.0)
-                         , l(2.0)
-                         )
+        net = cell.getNet('b(%d)' % i)
+        x = 20.0 * i + 10.0 + 10
+        y = height - 0
+        pin = Pin.create(
+            net,
+            'b(%d).0' % i,
+            Pin.Direction.NORTH,
+            Pin.PlacementStatus.FIXED,
+            METAL3,
+            l(x),
+            l(y),  # Position.
+            l(2.0),
+            l(2.0),  # Size.
+        )
         pin.getNet().setExternal(True)
         NetExternalComponents.setExternal(pin)
-    UpdateSession.close()
-
-    if True:
-        if editor: editor.setCell(cell)
 
-        placeAndRoute(cell)
+    UpdateSession.close()
 
-        UpdateSession.open()
-        blockageNet = cell.getNet('blockagenet')
+    if editor:
+        editor.setCell(cell)
 
-        ab = cell.getAbutmentBox()
-        ab.inflate(toDbU(-5.0))
-        Pad.create(net, BLOCKAGE2, ab)
-        Pad.create(net, BLOCKAGE3, ab)
-        Pad.create(net, BLOCKAGE4, ab)
-        # Pad.create( net, BLOCKAGE5, ab )
-        UpdateSession.close()
+    placeAndRoute(cell)
 
-    if False:
-        UpdateSession.open()
-        cell.setAbutmentBox(ab)
-        for i in range(16):
-            if True:
-                net = cell.getNet('b(%d)' % i)
-                x = 20.0 * i + 10.0 + 10
-                y = height - 10
-                build_downtrace(net, METAL2, x, y, y + 10)
-        UpdateSession.close()
+    UpdateSession.open()
 
-    # af.saveCell( cell, CRL.Catalog.State.Views )
-    plugins.RSavePlugin.ScriptMain(**kw)
+    ab = cell.getAbutmentBox()
+    ab.inflate(toDbU(-5.0))
+    Pad.create(net, BLOCKAGE2, ab)  # do we really want to use net b(15)?
+    Pad.create(net, BLOCKAGE3, ab)
+    Pad.create(net, BLOCKAGE4, ab)
+    UpdateSession.close()
 
+    RSavePlugin.ScriptMain(**kwargs)
 
-# -------------------------------------------------------------------------------
-# alu16()
 
-def alu16(**kw):
+def alu16(**kwargs):
     editor = None
-    if kw.has_key('editor') and kw['editor']:
-        editor = kw['editor']
+    if kwargs.has_key('editor') and kwargs['editor']:
+        editor = kwargs['editor']
 
     db = DataBase.getDB()
-    print db, dir(db)
+    print(db, dir(db))
     METAL2 = DataBase.getDB().getTechnology().getLayer('METAL2')
     METAL3 = DataBase.getDB().getTechnology().getLayer('METAL3')
 
-    cell = af.getCell('add', CRL.Catalog.State.Views)
-    cell = af.getCell('sub', CRL.Catalog.State.Views)
     cell = af.getCell('alu16', CRL.Catalog.State.Logical)
     if not cell:
-        print '[ERROR] Unable to load cell "alu16.vst", aborting .'
+        print('[ERROR] Unable to load cell "alu16.vst", aborting .')
         return False
-    kw['cell'] = cell
+    kwargs['cell'] = cell
 
-    ab = Box(l(0.0)
-             , l(0.0)
-             , l(1050.0)
-             , l(700.0))
+    ab = Box(l(0.0), l(0.0), l(1050.0), l(700.0))
 
     UpdateSession.open()
     cell.setAbutmentBox(ab)
 
     ins = cell.getInstance('subckt_48_add')
-    ins.setTransformation(Transformation(toDbU(100.0), toDbU(150.0),
-                                         Transformation.Orientation.ID))
+    ins.setTransformation(
+        Transformation(
+            toDbU(100.0), toDbU(150.0), Transformation.Orientation.ID
+        )
+    )
     ins.setPlacementStatus(Instance.PlacementStatus.FIXED)
 
     ins = cell.getInstance('subckt_49_sub')
-    ins.setTransformation(Transformation(toDbU(600.0), toDbU(150.0),
-                                         Transformation.Orientation.ID))
+    ins.setTransformation(
+        Transformation(
+            toDbU(600.0), toDbU(150.0), Transformation.Orientation.ID
+        )
+    )
     ins.setPlacementStatus(Instance.PlacementStatus.FIXED)
 
     yNorth = cell.getAbutmentBox().getYMax()
 
     for i in range(16):
-        Pin.create(cell.getNet('a(%d)' % i)
-                   , 'a(%d).0' % i
-                   , Pin.Direction.SOUTH
-                   , Pin.PlacementStatus.FIXED
-                   , METAL3
-                   , l(60.0 * i + 50.0), l(0.0)  # Position.
-                   , l(2.0), l(2.0)  # Size.
-                   )
-        Pin.create(cell.getNet('b(%d)' % i)
-                   , 'b(%d).0' % i
-                   , Pin.Direction.SOUTH
-                   , Pin.PlacementStatus.FIXED
-                   , METAL3
-                   , l(60.0 * i + 80.0), l(0.0)  # Position.
-                   , l(2.0), l(2.0)  # Size.
-                   )
-        Pin.create(cell.getNet('o(%d)' % i)
-                   , 'o(%d).0' % i
-                   , Pin.Direction.NORTH
-                   , Pin.PlacementStatus.FIXED
-                   , METAL3
-                   , l(60.0 * i + 50.0), yNorth  # Position.
-                   , l(2.0), l(2.0)  # Size.
-                   )
-
-    Pin.create(cell.getNet('rst')
-               , 'rst.0'
-               , Pin.Direction.WEST
-               , Pin.PlacementStatus.FIXED
-               , METAL2
-               , l(0.0)
-               , l(140.0)
-               , l(2.0)
-               , l(2.0)
-               )
+        Pin.create(
+            cell.getNet('a(%d)' % i),
+            'a(%d).0' % i,
+            Pin.Direction.SOUTH,
+            Pin.PlacementStatus.FIXED,
+            METAL3,
+            l(60.0 * i + 50.0),
+            l(0.0),  # Position.
+            l(2.0),
+            l(2.0),  # Size.
+        )
+        Pin.create(
+            cell.getNet('b(%d)' % i),
+            'b(%d).0' % i,
+            Pin.Direction.SOUTH,
+            Pin.PlacementStatus.FIXED,
+            METAL3,
+            l(60.0 * i + 80.0),
+            l(0.0),  # Position.
+            l(2.0),
+            l(2.0),  # Size.
+        )
+        Pin.create(
+            cell.getNet('o(%d)' % i),
+            'o(%d).0' % i,
+            Pin.Direction.NORTH,
+            Pin.PlacementStatus.FIXED,
+            METAL3,
+            l(60.0 * i + 50.0),
+            yNorth,  # Position.
+            l(2.0),
+            l(2.0),  # Size.
+        )
+
+    Pin.create(
+        cell.getNet('rst'),
+        'rst.0',
+        Pin.Direction.WEST,
+        Pin.PlacementStatus.FIXED,
+        METAL2,
+        l(0.0),
+        l(140.0),
+        l(2.0),
+        l(2.0),
+    )
     UpdateSession.close()
 
-    if editor: editor.setCell(cell)
+    if editor:
+        editor.setCell(cell)
 
-    print "editor", editor, dir(editor)
+    print("editor", editor, dir(editor))
 
-    success = placeAndRoute(cell)
+    result = placeAndRoute(cell)
 
     af.saveCell(cell, CRL.Catalog.State.Views)
-    plugins.RSavePlugin.ScriptMain(**kw)
+    RSavePlugin.ScriptMain(**kwargs)
 
-    return success
+    return result
 
 
-def ScriptMain(**kw):
+def ScriptMain(**kwargs):
     coriolisSetup()
-    add(**kw)
-    sub(**kw)
-    success = alu16(**kw)
-    return success
+    add(**kwargs)
+    sub(**kwargs)
+    return alu16(**kwargs)
 
 
 if __name__ == '__main__':
     try:
-        kw = {}
-        success = ScriptMain(**kw)
+        kwargs = {}
+        success = ScriptMain(**kwargs)
         shellSuccess = 0
-        if not success: shellSuccess = 1
+        if not success:
+            shellSuccess = 1
+
     except ImportError, e:
         showPythonTrace(__file__, e, False)
         sys.exit(1)
+
     except Exception, e:
         showPythonTrace(__file__, e)
         sys.exit(2)
 
     sys.exit(shellSuccess)
-
-