Add get_tx_insts and expand add_enclosure

This commit is contained in:
mrg 2020-06-24 11:54:36 -07:00
parent 93d65e84e1
commit 4bc3df8931
1 changed files with 57 additions and 18 deletions

View File

@ -269,6 +269,23 @@ class layout():
width, width,
end.y - start.y) end.y - start.y)
def get_tx_insts(self, tx_type=None):
"""
Return a list of the instances of given tx type.
"""
tx_list = []
for i in self.insts:
try:
if tx_type and i.mod.tx_type == tx_type:
tx_list.append(i)
elif not tx_type:
if i.mod.tx_type == "nmos" or i.mod.tx_type == "pmos":
tx_list.append(i)
except AttributeError:
pass
return tx_list
def get_pin(self, text): def get_pin(self, text):
""" """
Return the pin or list of pins Return the pin or list of pins
@ -1301,26 +1318,48 @@ class layout():
height=ur.y - ll.y, height=ur.y - ll.y,
width=ur.x - ll.x) width=ur.x - ll.x)
def add_enclosure(self, insts, layer="nwell"): def add_enclosure(self, insts, layer="nwell", extend=0, leftx=None, rightx=None, topy=None, boty=None):
""" Add a layer that surrounds the given instances. Useful """
Add a layer that surrounds the given instances. Useful
for creating wells, for example. Doesn't check for minimum widths or for creating wells, for example. Doesn't check for minimum widths or
spacings.""" spacings. Extra arg can force a dimension to one side left/right top/bot.
"""
xmin = insts[0].lx() if leftx != None:
ymin = insts[0].by() xmin = leftx
xmax = insts[0].rx() else:
ymax = insts[0].uy() xmin = insts[0].lx()
for inst in insts: for inst in insts:
xmin = min(xmin, inst.lx()) xmin = min(xmin, inst.lx())
ymin = min(ymin, inst.by()) xmin = xmin - extend
xmax = max(xmax, inst.rx()) if boty != None:
ymax = max(ymax, inst.uy()) ymin = boty
else:
self.add_rect(layer=layer, ymin = insts[0].by()
offset=vector(xmin, ymin), for inst in insts:
width=xmax - xmin, ymin = min(ymin, inst.by())
height=ymax - ymin) ymin = ymin - extend
if rightx != None:
xmax = rightx
else:
xmax = insts[0].rx()
for inst in insts:
xmax = max(xmax, inst.rx())
xmax = xmax + extend
if topy != None:
ymax = topy
else:
ymax = insts[0].uy()
for inst in insts:
ymax = max(ymax, inst.uy())
ymax = ymax + extend
rect = self.add_rect(layer=layer,
offset=vector(xmin, ymin),
width=xmax - xmin,
height=ymax - ymin)
return rect
def copy_power_pins(self, inst, name): def copy_power_pins(self, inst, name):
""" """
This will copy a power pin if it is on the lowest power_grid layer. This will copy a power pin if it is on the lowest power_grid layer.
@ -1337,7 +1376,7 @@ class layout():
else: else:
self.add_power_pin(name, pin.center(), start_layer=pin.layer) self.add_power_pin(name, pin.center(), start_layer=pin.layer)
def add_power_pin(self, name, loc, size=[1, 1], directions=None, start_layer="m1"): def add_power_pin(self, name, loc, size=[1, 1], directions=None, start_layer="m1"):
""" """
Add a single power pin from the lowest power_grid layer down to M1 (or li) at Add a single power pin from the lowest power_grid layer down to M1 (or li) at