Add inflate blockages and remove pins from blockages.

This commit is contained in:
Matt Guthaus 2018-09-05 11:06:17 -07:00
parent 93b24d8c85
commit b1c63a6c62
2 changed files with 50 additions and 25 deletions

View File

@ -1,5 +1,5 @@
import debug import debug
from tech import GDS from tech import GDS, drc
from vector import vector from vector import vector
from tech import layer from tech import layer
@ -40,6 +40,21 @@ class pin_layout:
else: else:
return False return False
def inflate(self, spacing=None):
"""
Inflate the rectangle by the spacing (or other rule)
and return the new rectangle.
"""
if not spacing:
spacing = drc["{0}_to_{0}".format(self.layer)]
(ll,ur) = self.rect
spacing = vector(spacing, spacing)
newll = ll - spacing
newur = ur + spacing
return (newll, newur)
def overlaps(self, other): def overlaps(self, other):
""" Check if a shape overlaps with a rectangle """ """ Check if a shape overlaps with a rectangle """
(ll,ur) = self.rect (ll,ur) = self.rect

View File

@ -90,19 +90,19 @@ class router:
def find_pin(self,pin): def find_pin(self,pin_name):
""" """
Finds the pin shapes and converts to tracks. Finds the pin shapes and converts to tracks.
Pin can either be a label or a location,layer pair: [[x,y],layer]. Pin can either be a label or a location,layer pair: [[x,y],layer].
""" """
label_list=self.layout.getPinShapeByLabel(str(pin)) shape_list=self.layout.getPinShapeByLabel(str(pin_name))
pin_list = [] pin_list = []
for label in label_list: for shape in shape_list:
(name,layer,boundary)=label (name,layer,boundary)=shape
rect = [vector(boundary[0],boundary[1]),vector(boundary[2],boundary[3])] rect = [vector(boundary[0],boundary[1]),vector(boundary[2],boundary[3])]
# this is a list because other cells/designs may have must-connect pins pin = pin_layout(pin_name, rect, layer)
pin_list.append(pin_layout(pin, rect, layer)) pin_list.append(pin)
debug.check(len(pin_list)>0,"Did not find any pin shapes for {0}.".format(str(pin))) debug.check(len(pin_list)>0,"Did not find any pin shapes for {0}.".format(str(pin)))
@ -208,22 +208,30 @@ class router:
def add_blockages(self): def add_blockages(self):
""" Add the blockages except the pin shapes """ """ Add the blockages except the pin shapes. Also remove the pin shapes from the blockages list. """
# Skip pin shapes # Join all the pin shapes into one big list
all_pins = [x[0] for x in list(self.pins.values())] all_pins = [item for sublist in list(self.pins.values()) for item in sublist]
# Do an n^2 check to see if any shapes are the same, otherwise add them
# FIXME: Make faster, but number of pins won't be *that* large
real_blockages = []
for blockage in self.blockages: for blockage in self.blockages:
for pin in all_pins: for pin in all_pins:
# If the blockage overlaps the pin and is on the same layer, # If the blockage overlaps the pin and is on the same layer,
# it must be connected, so skip it. # it must be connected, so skip it.
if blockage==pin: if blockage==pin:
debug.info(1,"Skipping blockage for pin {}".format(str(pin))) debug.info(1,"Removing blockage for pin {}".format(str(pin)))
break break
else: else:
debug.info(2,"Adding blockage {}".format(str(blockage))) debug.info(2,"Adding blockage {}".format(str(blockage)))
[ll,ur]=self.convert_blockage_to_tracks(blockage.rect) # Inflate the blockage by spacing rule
[ll,ur]=self.convert_blockage_to_tracks(blockage.inflate())
zlayer = self.get_zindex(blockage.layer_num) zlayer = self.get_zindex(blockage.layer_num)
self.rg.add_blockage_shape(ll,ur,zlayer) self.rg.add_blockage_shape(ll,ur,zlayer)
real_blockages.append(blockage)
# Remember the filtered blockages
self.blockages = real_blockages
def get_blockages(self, layer_num): def get_blockages(self, layer_num):
@ -262,15 +270,15 @@ class router:
old_ur = ur old_ur = ur
ll=ll.scale(self.track_factor) ll=ll.scale(self.track_factor)
ur=ur.scale(self.track_factor) ur=ur.scale(self.track_factor)
if ll[0]<45 and ll[0]>35 and ll[1]<5 and ll[1]>-5: # We can round since we are using inflated shapes
print(ll,ur) # and the track points are at the center
ll = ll.floor() ll = ll.round()
ur = ur.ceil() ur = ur.round()
if ll[0]<45 and ll[0]>35 and ll[1]<5 and ll[1]>-5: # if ll[0]<45 and ll[0]>35 and ll[1]<5 and ll[1]>-5:
debug.info(0,"Converting [ {0} , {1} ]".format(old_ll,old_ur)) # debug.info(0,"Converting [ {0} , {1} ]".format(old_ll,old_ur))
debug.info(0,"Converted [ {0} , {1} ]".format(ll,ur)) # debug.info(0,"Converted [ {0} , {1} ]".format(ll,ur))
pin=self.convert_track_to_shape(ll) # pin=self.convert_track_to_shape(ll)
debug.info(0,"Pin {}".format(pin)) # debug.info(0,"Pin {}".format(pin))
return [ll,ur] return [ll,ur]
def convert_pin_to_tracks(self, pin): def convert_pin_to_tracks(self, pin):
@ -464,10 +472,12 @@ class router:
zoom=0.05) zoom=0.05)
for blockage in self.blockages: for blockage in self.blockages:
# Display the inflated blockage
(ll,ur) = blockage.inflate()
self.cell.add_rect(layer="blockage", self.cell.add_rect(layer="blockage",
offset=blockage.ll(), offset=ll,
width=blockage.width(), width=ur.x-ll.x,
height=blockage.height()) height=ur.y-ll.y)
# FIXME: This should be replaced with vector.snap_to_grid at some point # FIXME: This should be replaced with vector.snap_to_grid at some point