Allow contains to contain copy. Add connectors when pin doesn't overlap grids.

This commit is contained in:
Matt Guthaus 2018-10-30 17:41:29 -07:00
parent 7099ee76e9
commit fc45242ccb
4 changed files with 20 additions and 26 deletions

View File

@ -120,10 +120,14 @@ class pin_layout:
def contains(self, other):
""" Check if a shape contains another rectangle """
# If it is the same shape entirely, it is contained!
if self == other:
return True
# Can only overlap on the same layer
if self.layer != other.layer:
return False
(ll,ur) = self.rect
(oll,our) = other.rect

View File

@ -187,18 +187,17 @@ class pin_group:
return p
def find_smallest_connector(self, enclosure_list):
def find_smallest_connector(self, pin_list, shape_list):
"""
Compute all of the connectors between non-overlapping pins and enclosures.
Compute all of the connectors between the overlapping pins and enclosure shape list..
Return the smallest.
"""
smallest = None
for pin_list in self.pins:
for pin in pin_list:
for enclosure in enclosure_list:
new_enclosure = self.compute_connector(pin, enclosure)
if smallest == None or new_enclosure.area()<smallest.area():
smallest = new_enclosure
for pin in pin_list:
for enclosure in shape_list:
new_enclosure = self.compute_connector(pin, enclosure)
if smallest == None or new_enclosure.area()<smallest.area():
smallest = new_enclosure
return smallest
@ -316,22 +315,13 @@ class pin_group:
# Compute the enclosure pin_layout list of the set of tracks
self.enclosures = self.compute_enclosures()
# A single set of connected pins is easy, so use the optimized set
# if len(self.pins)==1:
# enclosure_list = self.enclosures
# smallest = self.find_smallest_overlapping(self.pins[0],enclosure_list)
# if smallest:
# self.enclosures=[smallest]
# Save the list of all grids
#self.all_grids = self.grids.copy()
# Now, make sure each pin touches an enclosure. If not, add a connector.
for pin_list in self.pins:
if not self.overlap_any_shape(pin_list, self.enclosures):
connector = self.find_smallest_connector(pin_list, self.enclosures)
debug.check(connector!=None, "Could not find a connector for {} with {}".format(pin_list, self.enclosures))
self.enclosures.append(connector)
# Remove the grids that are not covered by the enclosures
# FIXME: We could probably just store what grids each enclosure overlaps when
# it was created.
#for enclosure in self.enclosures:
# enclosure_in_tracks=router.convert_pin_to_tracks(self.name, enclosure)
# self.grids.difference_update(enclosure_in_tracks)
debug.info(3,"Computed enclosure(s) {0}\n {1}\n {2}\n {3}".format(self.name,
self.pins,

View File

@ -197,7 +197,7 @@ class router(router_tech):
combined = pin_group(pin_name, [], self)
combined.combine_pins(pg1, pg2)
debug.info(2,"Combining {0} {1} {2}:".format(pin_name, index1, index2))
debug.info(2, " {0}\n {1}".format(pg1.pins, pg2.pins))
debug.info(2, "\n {0}\n {1}".format(pg1.pins, pg2.pins))
debug.info(2," --> {0}\n {1}".format(combined.pins,combined.grids))
remove_indices.update([index1,index2])
pin_groups.append(combined)

View File

@ -91,7 +91,7 @@ class supply_router(router):
self.route_simple_overlaps(vdd_name)
self.route_simple_overlaps(gnd_name)
self.write_debug_gds("debug_simple_route.gds",stop_program=False)
#self.write_debug_gds("debug_simple_route.gds",stop_program=False)
# Route the supply pins to the supply rails
# Route vdd first since we want it to be shorter