2023-06-04 17:46:59 +02:00
|
|
|
# See LICENSE for licensing information.
|
|
|
|
|
#
|
|
|
|
|
# Copyright (c) 2016-2023 Regents of the University of California, Santa Cruz
|
|
|
|
|
# All rights reserved.
|
|
|
|
|
#
|
|
|
|
|
from openram.base.pin_layout import pin_layout
|
2023-06-06 04:33:45 +02:00
|
|
|
from openram.base.vector import vector
|
|
|
|
|
from openram.tech import drc
|
2023-07-22 23:07:27 +02:00
|
|
|
from .graph_utils import snap
|
2023-06-04 17:46:59 +02:00
|
|
|
|
|
|
|
|
|
2023-07-13 21:07:55 +02:00
|
|
|
class graph_shape(pin_layout):
|
2023-06-04 17:46:59 +02:00
|
|
|
"""
|
|
|
|
|
This class inherits the pin_layout class to change some of its behavior for
|
2023-07-13 21:07:55 +02:00
|
|
|
the graph router.
|
2023-06-04 17:46:59 +02:00
|
|
|
"""
|
|
|
|
|
|
2023-07-25 19:26:23 +02:00
|
|
|
def __init__(self, name, rect, layer_name_pp, core=None):
|
2023-06-04 17:46:59 +02:00
|
|
|
|
|
|
|
|
pin_layout.__init__(self, name, rect, layer_name_pp)
|
|
|
|
|
|
2023-07-21 18:55:36 +02:00
|
|
|
# Snap the shape to the grid here
|
|
|
|
|
ll, ur = self.rect
|
2023-07-22 23:07:27 +02:00
|
|
|
self.rect = [snap(ll), snap(ur)]
|
2023-07-25 19:26:23 +02:00
|
|
|
# Core is the original shape from which this shape is inflated
|
|
|
|
|
self.core = core
|
2023-06-04 17:46:59 +02:00
|
|
|
|
2023-06-29 05:55:49 +02:00
|
|
|
|
2023-07-22 23:07:27 +02:00
|
|
|
def center(self):
|
|
|
|
|
""" Override the default `center` behavior. """
|
|
|
|
|
|
|
|
|
|
return snap(super().center())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def height(self):
|
|
|
|
|
""" Override the default `height` behavior. """
|
|
|
|
|
|
|
|
|
|
return snap(super().height())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def width(self):
|
|
|
|
|
""" Override the default `width` behavior. """
|
|
|
|
|
|
|
|
|
|
return snap(super().width())
|
|
|
|
|
|
|
|
|
|
|
2023-07-25 19:26:23 +02:00
|
|
|
def get_core(self):
|
2023-07-21 17:26:54 +02:00
|
|
|
"""
|
2023-07-25 19:26:23 +02:00
|
|
|
Return `self` if `self.core` is None. Otherwise, return `self.core`.
|
2023-07-21 17:26:54 +02:00
|
|
|
"""
|
|
|
|
|
|
2023-07-25 19:26:23 +02:00
|
|
|
if self.core is None:
|
2023-07-21 17:26:54 +02:00
|
|
|
return self
|
2023-07-25 19:26:23 +02:00
|
|
|
return self.core
|
2023-07-21 17:26:54 +02:00
|
|
|
|
|
|
|
|
|
2023-07-24 06:09:15 +02:00
|
|
|
def inflated_pin(self, spacing=None, multiple=0.5, extra_spacing=0):
|
2023-06-04 17:46:59 +02:00
|
|
|
""" Override the default inflated_pin behavior. """
|
|
|
|
|
|
2023-06-15 20:08:13 +02:00
|
|
|
ll, ur = self.inflate(spacing, multiple)
|
|
|
|
|
extra = vector([extra_spacing] * 2)
|
|
|
|
|
newll = ll - extra
|
|
|
|
|
newur = ur + extra
|
2023-06-06 04:33:45 +02:00
|
|
|
inflated_area = (newll, newur)
|
2023-07-24 06:09:15 +02:00
|
|
|
return graph_shape(self.name, inflated_area, self.layer, self)
|
2023-06-04 17:46:59 +02:00
|
|
|
|
|
|
|
|
|
2023-07-26 03:40:07 +02:00
|
|
|
def multiply(self, scale):
|
|
|
|
|
""" Multiply the width and height with the scale value. """
|
|
|
|
|
|
|
|
|
|
width = (self.width() * (scale - 1)) / 2
|
|
|
|
|
height = (self.height() * (scale - 1)) / 2
|
|
|
|
|
ll, ur = self.rect
|
|
|
|
|
newll = vector(ll.x - width, ll.y - height)
|
|
|
|
|
newur = vector(ur.x + width, ur.y + height)
|
|
|
|
|
self.rect = [snap(newll), snap(newur)]
|
|
|
|
|
|
|
|
|
|
|
2023-06-04 17:46:59 +02:00
|
|
|
def aligns(self, other):
|
|
|
|
|
""" Return if the other shape aligns with this shape. """
|
|
|
|
|
|
|
|
|
|
# Shapes must overlap to be able to align
|
|
|
|
|
if not self.overlaps(other):
|
|
|
|
|
return False
|
|
|
|
|
ll, ur = self.rect
|
|
|
|
|
oll, our = other.rect
|
|
|
|
|
if ll.x == oll.x and ur.x == our.x:
|
|
|
|
|
return True
|
|
|
|
|
if ll.y == oll.y and ur.y == our.y:
|
|
|
|
|
return True
|
|
|
|
|
return False
|