Skip to content

Commit

Permalink
generalize protect_opposite_face
Browse files Browse the repository at this point in the history
  • Loading branch information
caspar-iqm committed Oct 18, 2023
1 parent 6fba642 commit e35b22f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def build(self):
self.cell.shapes(self.get_layer("base_metal_addition", 1)).insert(shape)

# Add ground grid avoidance to second face
self.add_protection(shape.enlarged(self.margin, self.margin), 1, 0)
self.add_protection(shape.enlarged(self.margin, self.margin), 1)

# Flip-chip bump
if self.include_bumps:
Expand Down
15 changes: 11 additions & 4 deletions klayout_package/python/kqcircuits/elements/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ class Element(pya.PCellDeclarationHelper):
face_ids = Param(pdt.TypeList, "Chip face IDs list", ["1t1", "2b1", "1b1", "2t1"])
display_name = Param(pdt.TypeString, "Name displayed in GUI (empty for default)", "")
protect_opposite_face = Param(pdt.TypeBoolean, "Add opposite face protection too", False)
opposing_face_id_groups = Param(pdt.TypeList, "Opposing face ID groups (list of lists)", [["1t1", "2b1"]],
hidden=True)

def __init__(self):
""
Expand Down Expand Up @@ -518,18 +520,23 @@ def raise_error_on_cell(self, error_msg, position=pya.DPoint()):
self.insert_cell(error_text_cell, pya.DTrans(position - text_center))
raise ValueError(error_msg)

def add_protection(self, shape, face_id=0, opposite_face_id=1):
def add_protection(self, shape, face_id=0):
"""Add ground grid protection shape
Args:
shape: The shape (Region, DPolygon, etc.) to add to ground_grid_avoidance layer
face_id: primary face index of ground_grid_avoidance layer, default=0
opposite_face_id: opposite face index, will be used if protect_opposite_face is True, default=1
"""

self.cell.shapes(self.get_layer("ground_grid_avoidance", face_id)).insert(shape)
if self.protect_opposite_face and len(self.face_ids) > opposite_face_id:
self.cell.shapes(self.get_layer("ground_grid_avoidance", opposite_face_id)).insert(shape)
if self.protect_opposite_face:
for group in self.opposing_face_id_groups:
if self.face_ids[face_id] in group:
for other_face_id in group:
if other_face_id != self.face_ids[face_id] and other_face_id in self.face_ids:
self.cell.shapes(self.get_layer("ground_grid_avoidance",
self.face_ids.index(other_face_id))).insert(shape)
break

def sync_parameters(self, abc):
"""Syncronise the calling class' parameters with a JSON representation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def produce_shape(face, a, b, rotation, trace_rotation):
dtrans = pya.DCplxTrans(1, rotation, False, 0, 0)
itrans = dtrans.to_itrans(self.layout.dbu)
self.cell.shapes(self.get_layer("base_metal_gap_wo_grid", face)).insert(region.transformed(itrans))
self.add_protection(avoid_region.transformed(itrans), face, 0)
self.add_protection(avoid_region.transformed(itrans), face)
self.add_port("{}_port".format(self.face_ids[face]),
dtrans * pya.DPoint(-bumps_length/2, 0) + trace_dtrans * dtrans * pya.DVector(-w/2, 0),
trace_dtrans * dtrans * pya.DVector(-1, 0), face)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def _fix_waveguide_end(self, points, current_length):
curve_trans = pya.DCplxTrans(1, degrees(alpha1) - v1.vprod_sign(v2)*90, v1.vprod_sign(v2) < 0,
corner_pos)
self.insert_cell(curve_cell, curve_trans)
WaveguideCoplanarCurved.produce_curve_termination(self, curve_alpha, self.term2, curve_trans, *fids)
WaveguideCoplanarCurved.produce_curve_termination(self, curve_alpha, self.term2, curve_trans, fids[0])
return True

# set last point to correct position based on length
Expand Down Expand Up @@ -398,7 +398,7 @@ def insert_wg_with_connector(segment, distance):
else:
self.insert_cell(WaveguideCoplanar, path=points[:segment + 1] + [b_pos], term2=0)
if segment + 2 == len(points) and s_len - conn_len - distance < 1e-3:
WaveguideCoplanar.produce_end_termination(self, b_pos, t_pos, term2, face_index=1, opp_face_index=0)
WaveguideCoplanar.produce_end_termination(self, b_pos, t_pos, term2, face_index=1)
else:
self.insert_cell(WaveguideCoplanar, path=[t_pos] + points[segment + 1:],
term1=0, term2=term2, face_ids=self.face_ids[1::-1])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def get_corner_data(point1, point2, point3, r):
return v1, v2, alpha1, alpha2, corner_pos

@staticmethod
def produce_end_termination(elem, point_1, point_2, term_len, face_index=0, opp_face_index=1):
def produce_end_termination(elem, point_1, point_2, term_len, face_index=0):
"""Produces termination for a waveguide.
The termination consists of a rectangular polygon in the metal gap layer, and grid avoidance around it.
Expand All @@ -173,7 +173,6 @@ def produce_end_termination(elem, point_1, point_2, term_len, face_index=0, opp_
point_2: DPoint after which termination is produced
term_len (double): termination length, assumed positive
face_index (int): face index of the face in elem where the termination is created
opp_face_index (int): face index of the opposite face
"""
a = elem.a
b = elem.b
Expand All @@ -192,7 +191,7 @@ def produce_end_termination(elem, point_1, point_2, term_len, face_index=0, opp_
term_len += elem.margin
poly2 = pya.DPolygon([u*(a/2 + b + elem.margin), u*(a/2 + b + elem.margin) + v*term_len,
u*(-a/2 - b - elem.margin) + v*term_len, u*(-a/2 - b - elem.margin)])
elem.add_protection(poly2.transform(shift_start), face_index, opp_face_index)
elem.add_protection(poly2.transform(shift_start), face_index)

@staticmethod
def is_continuous(waveguide_cell, annotation_layer, tolerance):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def create_curve_arcs(elem, angle):
annotation

@staticmethod
def produce_curve_termination(elem, angle, term_len, trans, face_index=0, opp_face_index=1):
def produce_curve_termination(elem, angle, term_len, trans, face_index=0):
"""Produces termination for a curved waveguide.
The termination consists of a rectangular polygon in the metal gap layer, and grid avoidance around it.
Expand All @@ -128,7 +128,6 @@ def produce_curve_termination(elem, angle, term_len, trans, face_index=0, opp_fa
term_len (double): termination length, assumed positive
trans (DTrans): transformation applied to the termination
face_index (int): face index of the face in elem where the termination is created
opp_face_index (int): face index of the opposite face
"""
left_inner_arc, left_outer_arc, right_inner_arc, right_outer_arc, left_protection_arc, right_protection_arc,\
_ = WaveguideCoplanarCurved.create_curve_arcs(elem, angle)
Expand Down Expand Up @@ -156,4 +155,4 @@ def produce_curve_termination(elem, angle, term_len, trans, face_index=0, opp_fa
right_protection_arc[0] + (term_len + elem.margin)*term_dir,
right_protection_arc[0],
]
elem.add_protection(trans * pya.DPolygon(protection_pts), face_index, opp_face_index)
elem.add_protection(trans * pya.DPolygon(protection_pts), face_index)

0 comments on commit e35b22f

Please sign in to comment.