From 9d8c4bd79960ee1592feb01c2f735607eff220b6 Mon Sep 17 00:00:00 2001 From: Jock Tanner Date: Wed, 18 Mar 2020 08:46:45 +0000 Subject: [PATCH] Parameterize bit width. --- experiments7/doAlu16.py | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/experiments7/doAlu16.py b/experiments7/doAlu16.py index 749343c..032f216 100755 --- a/experiments7/doAlu16.py +++ b/experiments7/doAlu16.py @@ -20,6 +20,7 @@ from plugins import RSavePlugin import symbolic.cmos # do not remove af = CRL.AllianceFramework.get() +BIT_WIDTH = 16 def get_layer(name, layer_cache={}): @@ -135,7 +136,7 @@ def add(**kwargs): UpdateSession.open() cell.setAbutmentBox(ab) - for i in range(16): + for i in range(BIT_WIDTH): x = 20.0 * i + 10.0 y = height pin = Pin.create( @@ -152,7 +153,7 @@ def add(**kwargs): pin.getNet().setExternal(True) NetExternalComponents.setExternal(pin) - for i in range(16): + for i in range(BIT_WIDTH): pin = Pin.create( cell.getNet('o(%d)' % i), 'o(%d).0' % i, @@ -167,7 +168,7 @@ def add(**kwargs): pin.getNet().setExternal(True) NetExternalComponents.setExternal(pin) - for i in range(16): + for i in range(BIT_WIDTH): net = cell.getNet('b(%d)' % i) x = 20.0 * i + 10.0 + 10 y = height - 0 @@ -247,7 +248,7 @@ def sub(**kwargs): UpdateSession.open() cell.setAbutmentBox(ab) - for i in range(16): + for i in range(BIT_WIDTH): x = 20.0 * i + 10.0 y = height pin = Pin.create( @@ -264,7 +265,7 @@ def sub(**kwargs): pin.getNet().setExternal(True) NetExternalComponents.setExternal(pin) - for i in range(16): + for i in range(BIT_WIDTH): pin = Pin.create( cell.getNet('o(%d)' % i), 'o(%d).0' % i, @@ -279,7 +280,7 @@ def sub(**kwargs): pin.getNet().setExternal(True) NetExternalComponents.setExternal(pin) - for i in range(16): + for i in range(BIT_WIDTH): net = cell.getNet('b(%d)' % i) x = 20.0 * i + 10.0 + 10 y = height - 0 @@ -335,25 +336,30 @@ def alu16(**kwargs): UpdateSession.open() cell.setAbutmentBox(ab) - ins = cell.getInstance('subckt_48_add') - ins.setTransformation( + # get instances inside cell + instances = cell.getInstances() + + # find adder instance + add_inst = [x for x in instances if x.getName().endswith('add')][0] + add_inst.setTransformation( Transformation( toDbU(25.0), toDbU(75.0), Transformation.Orientation.ID ) ) - ins.setPlacementStatus(Instance.PlacementStatus.FIXED) + add_inst.setPlacementStatus(Instance.PlacementStatus.FIXED) - ins = cell.getInstance('subckt_49_sub') - ins.setTransformation( + # find subtractor instance + sub_inst = [x for x in instances if x.getName().endswith('sub')][0] + sub_inst.setTransformation( Transformation( toDbU(725.0), toDbU(75.0), Transformation.Orientation.ID ) ) - ins.setPlacementStatus(Instance.PlacementStatus.FIXED) + sub_inst.setPlacementStatus(Instance.PlacementStatus.FIXED) yNorth = cell.getAbutmentBox().getYMax() - for i in range(16): + for i in range(BIT_WIDTH): Pin.create( cell.getNet('a(%d)' % i), 'a(%d).0' % i, @@ -410,19 +416,16 @@ def alu16(**kwargs): # this puts all the remaining cells (little ones) # into this (small) space so that they do not go # "all over the place" around the add and sub - ab2 = Box( l( 400.0 ) - , l( 50.0 ) - , l( 700.0 ) - , l( 500.0 ) ) + ab2 = Box(l(400.0), l(50.0), l(700.0), l(500.0)) - cell.setAbutmentBox( ab2 ) + cell.setAbutmentBox(ab2) etesian = Etesian.EtesianEngine.create(cell) etesian.place() # then route (globally) # this connects up not just in the remaining (little) cells, # it connects *to add and sub and the outside world as well* - cell.setAbutmentBox( ab ) + cell.setAbutmentBox(ab) result = placeAndRoute(cell) -- 2.30.2