luceda ipkiss教程 66:金属线的钝角转弯

案例分享:金属线的135度转弯:
在这里插入图片描述
所有代码如下:

from si_fab import all as pdk
import ipkiss3.all as i3
from ipkiss.geometry.shape_modifier import __ShapeModifierAutoOpenClosed__
from numpy import sqrt


class ShapeManhattanStub(__ShapeModifierAutoOpenClosed__):
    """
    Will create a 135 degree from a Manhattan shape
    """

    bend_radius = i3.PositiveNumberProperty(default=5.0, doc="bend radius of the routing")

    def define_points(self, pts):
        s = self.original_shape
        s.remove_straight_angles()
        manh90_points = [i3.Coord2(pt) for pt in s.points]

        for idx, pt in enumerate(manh90_points[1:-1]):
            input_vector = pt - manh90_points[idx]
            outut_vector = manh90_points[idx + 2] - pt

            if abs(input_vector.x) < 1e-10:
                input_vector.x = 0
            if abs(input_vector.y) < 1e-10:
                input_vector.y = 0
            if abs(outut_vector.x) < 1e-10:
                outut_vector.x = 0
            if abs(outut_vector.y) < 1e-10:
                outut_vector.y = 0

            if ((input_vector.x * input_vector.y) + (outut_vector.x * outut_vector.y)) != 0:
                raise Exception(
                    "Non manhattan routing given (between input_vector {}, pt {} and outut_vector {})".format(
                        (input_vector.x, input_vector.y),
                        (pt.x, pt.y),
                        (outut_vector.x, outut_vector.y),
                    )
                )

        new_shape = i3.ShapeStub(original_shape=s, stub_width=sqrt(2) * self.bend_radius)
        return new_shape.points


class ConnectElectrical135DegreeCorners(i3.ConnectManhattan):
    stub_side = i3.PositiveNumberProperty(default=25)

    def _connect(self, start_port, end_port, name=None):
        """Connect start_port to end_port using RouteManhattan"""

        if None in (start_port.angle, end_port.angle):
            raise ValueError(
                "The start and/or end port has no angle defined." "Please specify an angle for both ports."
            )

        pcell_props = self._get_pcell_properties(name)
        layout_props = self._get_layout_properties(i3.ElectricalDomain)
        manhattan_props = self._get_manhattan_properties()

        route = ShapeManhattanStub(
            i3.RouteManhattan(
                input_port=start_port,
                output_port=end_port,
                **manhattan_props
            ),
            bend_radius=self.stub_side
        )

        layout_props["shape"] = route

        pcell = i3.ElectricalWire(**pcell_props)
        pcell.Layout(**layout_props)

        return pcell


# Trace templates for the Electrical wires
tt = pdk.M1WireTemplate()
tt.Layout(width=5)

# Define Electrical ports
port1 = i3.ElectricalPort(name="elec1", position=(0.0, 0.0), angle=90.0, trace_template=tt)
port2 = i3.ElectricalPort(name="elec2", position=(100.0, 100.0), angle=-90.0, trace_template=tt)
port3 = i3.ElectricalPort(name="elec3", position=(150.0, 0.0), angle=90.0, trace_template=tt)
port4 = i3.ElectricalPort(name="elec4", position=(250.0, 100.0), angle=-90.0, trace_template=tt)

connectors = i3.Circuit(
    insts={},
    specs=[
        i3.ConnectElectrical(
            port1,
            port2,
            control_points=[i3.H(40)],
            trace_template=tt,
        ),
        ConnectElectrical135DegreeCorners(
            port3,
            port4,
            "manhattan_bend_pt",
            control_points=[i3.H(40)],
            stub_side=20.0,
            trace_template=tt,
        ),
    ],
)
connectors_lo = connectors.Layout()
connectors_lo.visualize()

通过ConnectElectrical135DegreeCorners这个金属布线函数,原来90度转弯的地方都变成了135度转弯!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值