From d4c14d7d19967e0b770900342e8b146e2ee26faf Mon Sep 17 00:00:00 2001 From: mrg Date: Wed, 23 Feb 2022 14:06:19 -0800 Subject: [PATCH] Add horizontal pin helper function --- compiler/base/hierarchy_layout.py | 33 +++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/compiler/base/hierarchy_layout.py b/compiler/base/hierarchy_layout.py index c30408c7..d65fe17d 100644 --- a/compiler/base/hierarchy_layout.py +++ b/compiler/base/hierarchy_layout.py @@ -422,6 +422,35 @@ class layout(): for pin_name in self.pin_map.keys(): self.copy_layout_pin(instance, pin_name, prefix + pin_name) + def route_horizontal_pin(self, name): + """ + Route together all of the pins of a given name that horizontally align. + """ + bins = {} + + for i in range(len(self.local_insts)): + inst = self.local_insts[i] + for pin in inst.get_pins(name): + try: + bins[pin.cy()].append(pin) + except KeyError: + bins[pin.cy()] = [pin] + + for y, v in bins.items(): + left_x = min([x.lx() for x in v]) + right_x = max([x.rx() for x in v]) + + last_via = None + for pin in v: + last_via = self.add_via_stack_center(from_layer=pin.layer, + to_layer=self.supply_stack[0], + offset=pin.center()) + + self.add_layout_pin_segment_center(text=name, + layer=self.supply_stack[0], + start=vector(left_x, y), + end=vector(right_x, y)) + def add_layout_pin_segment_center(self, text, layer, start, end, width=None): """ Creates a path like pin with center-line convention @@ -450,8 +479,8 @@ class layout(): return self.add_layout_pin(text=text, layer=layer, offset=ll_offset, - width=bbox_width, - height=bbox_height) + width=max(bbox_width, layer_width), + height=max(bbox_height, layer_width)) def add_layout_pin_rect_center(self, text, layer, offset, width=None, height=None): """ Creates a path like pin with center-line convention """