def port_to_pin_helper(ports_list, cell, layerPinRec): """ Draws port shapes for visual help in KLayout. """ # Create the pins, as short paths: # from siepic_tools.config import PIN_LENGTH PIN_LENGTH = 100 dbu = cell.layout().dbu for port in ports_list: if port.name.startswith("el"): pin_length = port.width else: pin_length = PIN_LENGTH * dbu port_position_i = port.position.to_itype(dbu) cell.shapes(layerPinRec).insert( kdb.DPath( [ port.position - 0.5 * pin_length * port.direction, port.position + 0.5 * pin_length * port.direction, ], port.width, ).to_itype(dbu)) cell.shapes(layerPinRec).insert( kdb.Text( port.name, kdb.Trans(kdb.Trans.R0, port_position_i.x, port_position_i.y))).text_size = (2 / dbu)
def trace_rounded_path(cell, layer, rounded_path, width): points = [] for item in rounded_path: points.extend(item.get_points()) dpath = kdb.DPath(points, width, 0, 0) cell.shapes(layer).insert(dpath)
def draw(self, cell, layer): """ Draws this port on cell's layer using klayout.db""" if self.name.startswith("el"): pin_length = self.width else: # port is optical pin_length = max(2, self.width / 10) ex = self.direction # Place a Path around the port pointing towards its exit port_path = kdb.DPath( [ self.position - 0.5 * pin_length * ex, self.position + 0.5 * pin_length * ex, ], self.width, ) cell.shapes(layer).insert(port_path) # Place a small arrow around the tip of the port from zeropdk.layout.geometry import rotate90 ey = rotate90(ex) port_tip = kdb.DSimplePolygon( [ self.position + 0.5 * pin_length * ex, self.position + 0.4 * pin_length * ex + 0.1 * pin_length * ey, self.position + 0.4 * pin_length * ex - 0.1 * pin_length * ey, ] ) cell.shapes(layer).insert(port_tip) # pin_rectangle = rectangle(self.position, self.width, # pin_length, ex, ey) # cell.shapes(layer).insert(pin_rectangle) # Place a text object annotating the name of the port cell.shapes(layer).insert( kdb.DText( self.name, kdb.DTrans(kdb.DTrans.R0, self.position.x, self.position.y), min(pin_length, 20), 0, ) ) return self
def trace_reference_path(cell, layer, points, width): dpath = kdb.DPath(points, width, 0, 0) cell.shapes(layer).insert(dpath)