Skip to content

Commit

Permalink
Allow placing mask name labels on chips during mask export
Browse files Browse the repository at this point in the history
This commit makes it possible to add mask name labels to each chip as overlay during mask export, instead of coding the label inside the chip cell. To use this feature, set name_mask="_3" in the chip to add a 4-character placeholder, and set add_mask_name_to_chips=True in MaskSet to enable the label overlay.
  • Loading branch information
caspar-iqm committed Apr 15, 2024
1 parent 744024c commit 9db4255
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
22 changes: 18 additions & 4 deletions klayout_package/python/kqcircuits/masks/mask_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,13 @@ def insert_chips(self):
for params in self.graphical_representation_inputs:
self._add_chip_graphical_representation_layer(*params)

def insert_chip_copy_labels(self, labels_cell, layers):
def insert_chip_copy_labels(self, labels_cell, layers, mask_name_for_chip=None):
"""Inserts chip copy labels to all chips in this mask layout and its submasks
Args:
labels_cell: Cell to which the labels are inserted
layers: list of layer names (without face_ids) where the labels are produced
mask_name_for_chip: mask name to place on each chip, or None (default) to not add mask names to the chip.
"""

# find labels_cell for this mask and each submask
Expand Down Expand Up @@ -401,7 +402,8 @@ def insert_chip_copy_labels(self, labels_cell, layers):
# update position label into chips_dict
chips_dict[(x, y)] = (chip_name, _, bbox, dtrans, position_label, mask_layout)
used_position_labels.add(position_label)
bbox_x1 = bbox.left if (bool(dtrans.is_mirror()) ^ bool(self.mirror_labels)) else bbox.right
total_mirror_label = bool(dtrans.is_mirror()) ^ bool(self.mirror_labels)
bbox_x1, bbox_x2 = (bbox.left, bbox.right) if total_mirror_label else (bbox.right, bbox.left)
produce_label(
labels_cell_2,
position_label,
Expand All @@ -413,9 +415,21 @@ def insert_chip_copy_labels(self, labels_cell, layers):
mask_layout.face()["ground_grid_avoidance"],
mirror=self.mirror_labels,
)
bbox_x2 = bbox.right if dtrans.is_mirror() else bbox.left
if mask_name_for_chip is not None:
produce_label(
labels_cell_2,
mask_name_for_chip,
dtrans * (pya.DPoint(bbox_x2, bbox.top)),
LabelOrigin.TOPLEFT,
mask_layout.dice_width,
mask_layout.text_margin,
[mask_layout.face()[layer] for layer in layers],
mask_layout.face()["ground_grid_avoidance"],
mirror=self.mirror_labels,
)
bbox_xr = bbox.right if dtrans.is_mirror() else bbox.left
self.graphical_representation_inputs.append(
(chip_name, dtrans * (pya.DPoint(bbox_x2, bbox.bottom)), position_label, bbox.width(), labels_cell_2)
(chip_name, dtrans * (pya.DPoint(bbox_xr, bbox.bottom)), position_label, bbox.width(), labels_cell_2)
)

chip_box = pya.DBox(dtrans * bbox)
Expand Down
7 changes: 6 additions & 1 deletion klayout_package/python/kqcircuits/masks/mask_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def __init__(
export_drc=False,
mask_export_layers=None,
export_path=TMP_PATH,
add_mask_name_to_chips=False,
):

self._time = {"INIT": perf_counter(), "ADD_CHIPS": 0, "BUILD": 0, "EXPORT": 0, "END": 0}
Expand All @@ -95,6 +96,7 @@ def __init__(
self.mask_layouts = []
self.mask_export_layers = mask_export_layers if mask_export_layers is not None else []
self.used_chips = {}
self.add_mask_name_to_chips = add_mask_name_to_chips
self._extra_params = {}
self._mask_set_dir = Path(export_path) / f"{name}_v{version}"

Expand Down Expand Up @@ -327,12 +329,15 @@ def build(self, remove_guiding_shapes=True):
self.mask_layouts = submask_layouts + [ml for ml in self.mask_layouts if ml not in mask_layouts_to_remove]

# add chip copy labels for every mask layout
mask_name_for_chip = self.name if self.add_mask_name_to_chips else None
for mask_layout in tqdm(self.mask_layouts, desc="Adding chip copy labels", bar_format=default_bar_format):

labels_cell = mask_layout.layout.create_cell("ChipLabels")
mask_layout.top_cell.insert(pya.DCellInstArray(labels_cell.cell_index(), pya.DTrans(pya.DVector(0, 0))))
if mask_layout not in submask_layouts:
chips_dict = mask_layout.insert_chip_copy_labels(labels_cell, chip_copy_label_layers)
chips_dict = mask_layout.insert_chip_copy_labels(
labels_cell, chip_copy_label_layers, mask_name_for_chip
)
mask_layout.overwrite_chips_by_position_label(chips_dict)
# remove "$1" or similar unnecessary postfix from cell name
mask_layout.top_cell.name = f"{mask_layout.name}"
Expand Down

0 comments on commit 9db4255

Please sign in to comment.