From: Jock Tanner Date: Mon, 16 Mar 2020 19:01:52 +0000 (+0000) Subject: Generalize layer creation/retrieval. X-Git-Tag: partial-core-ls180-gdsii~170 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ee9fbf231885318a148d45d0fa883ce1a8df7b8a;p=soclayout.git Generalize layer creation/retrieval. --- diff --git a/experiments7/doAlu16.py b/experiments7/doAlu16.py index 21bb601..674f7ac 100755 --- a/experiments7/doAlu16.py +++ b/experiments7/doAlu16.py @@ -22,34 +22,18 @@ import symbolic.cmos # do not remove af = CRL.AllianceFramework.get() -def toDbU(l): - return DbU.fromLambda(l) - - -def createVertical(contacts, x, layer, width=None): - def yincrease(lhs, rhs): - return int(lhs.getY() - rhs.getY()) - - contacts.sort(yincrease) +def get_layer(name, layer_cache={}): + """ Creates a new layer or returns it from cache. """ + if name in layer_cache: + return layer_cache[name] - if width is None: width = l(2.0) + layer = DataBase.getDB().getTechnology().getLayer(name) + layer_cache[name] = layer + return layer - for i in range(1, len(contacts)): - 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 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)), - ] - - createVertical(contacts, l(x), layer) - print("slaves", contacts[-1].getSlaveComponents()) - for component in contacts[-1].getSlaveComponents(): - NetExternalComponents.setExternal(component) +def toDbU(l): + return DbU.fromLambda(l) def placeAndRoute(cell): @@ -113,13 +97,13 @@ def add(**kwargs): db = DataBase.getDB() print(db, dir(db)) - METAL2 = DataBase.getDB().getTechnology().getLayer('METAL2') - 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') + METAL2 = get_layer('METAL2') + METAL3 = get_layer('METAL3') + METAL5 = get_layer('METAL5') + BLOCKAGE2 = get_layer('BLOCKAGE2') + BLOCKAGE3 = get_layer('BLOCKAGE3') + BLOCKAGE4 = get_layer('BLOCKAGE4') + BLOCKAGE5 = get_layer('BLOCKAGE5') cell = af.getCell('add', CRL.Catalog.State.Logical) print(cell.getNet('a(0)')) @@ -225,13 +209,13 @@ def sub(**kwargs): db = DataBase.getDB() print(db, dir(db)) - METAL2 = DataBase.getDB().getTechnology().getLayer('METAL2') - 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') + METAL2 = get_layer('METAL2') + METAL3 = get_layer('METAL3') + METAL5 = get_layer('METAL5') + BLOCKAGE2 = get_layer('BLOCKAGE2') + BLOCKAGE3 = get_layer('BLOCKAGE3') + BLOCKAGE4 = get_layer('BLOCKAGE4') + BLOCKAGE5 = get_layer('BLOCKAGE5') cell = af.getCell('sub', CRL.Catalog.State.Logical) print(cell.getNet('a(0)')) @@ -337,8 +321,8 @@ def alu16(**kwargs): db = DataBase.getDB() print(db, dir(db)) - METAL2 = DataBase.getDB().getTechnology().getLayer('METAL2') - METAL3 = DataBase.getDB().getTechnology().getLayer('METAL3') + METAL2 = get_layer('METAL2') + METAL3 = get_layer('METAL3') cell = af.getCell('alu16', CRL.Catalog.State.Logical) if not cell: