案例分享:金属线的135度转弯:
所有代码如下:
from si_fab import all as pdk
import ipkiss3.all as i3
from ipkiss.geometry.shape_modifier import __ShapeModifierAutoOpenClosed__
from numpy import sqrtclass 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_shapes.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] - ptif abs(input_vector.x) < 1e-10:input_vector.x = 0if abs(input_vector.y) < 1e-10:input_vector.y = 0if abs(outut_vector.x) < 1e-10:outut_vector.x = 0if abs(outut_vector.y) < 1e-10:outut_vector.y = 0if ((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.pointsclass 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"] = routepcell = 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度转弯!