kqcircuits.masks.mask_set

class kqcircuits.masks.mask_set.MaskSet(layout=None, name='MaskSet', version=1, with_grid=False, export_drc=False, mask_export_layers=None, debug=False)[source]

Bases: object

Class representing a set of masks for different chip faces.

A mask set consists of one or more MaskLayouts, each of which is for a certain face.

To create a mask, add mask layouts to the mask set using add_mask_layout() and add chips to these mask layouts using add_chips() or add_chip(). These functions also export some files for each chip. Then call build() to create the cell hierarchy of the entire mask, and finally export mask files by calling export().

Example

mask = MaskSet(…) mask.add_mask_layout(…) mask.add_mask_layout(…) mask.add_chips(…) mask.build() mask.export(…)

layout

pya.Layout of this mask set

name

Name of the mask set

version

Version of the mask set

with_grid

Boolean determining if ground grid is generated

export_drc

Boolean determining if DRC report is exported

chips_map_legend

Dictionary where keys are chip names, values are chip cells

mask_layouts

list of MaskLayout objects in this mask set

mask_export_layers

list of names of the layers which are exported for each MaskLayout

used_chips

similar to chips_map_legend, but only includes chips which are actually used in mask layouts

add_mask_layout(chips_map, face_id='1t1', mask_layout_type=<class 'kqcircuits.masks.mask_layout.MaskLayout'>, **kwargs)[source]

Creates a mask layout from chips_map and adds it to self.mask_layouts.

Parameters
  • chips_map – List of lists (2D-array) of strings, each string is a chip name (or — for no chip)

  • face_id – face_id of the mask layout

  • mask_layout_type – type of the mask layout (MaskLayout or a child class of it)

  • kwargs – keyword arguments passed to the mask layout

Returns

the created mask layout

load_cell_from_file(file_name)[source]

Load GDS or OASIS cell from file.

Load a cell (usually a chip) from the specified file.

Parameters

file_name – name of the file (with path) to be loaded

Returns

the loaded cell

add_chips(chips, threads=None)[source]

Adds a list of chips with parameters to self.chips_map_legend and exports the files for each chip.

Parameters
  • chips – List of tuples that add_chip uses. Parameters are optional. For example, (QualityFactor, "QDG", parameters).

  • threads – Number of parallel threads to use for generation. By default uses os.cpu_count() threads. Uses subprocesses and consequently a lot of memory.

Warning

It is advised to lower the thread number if your system has a lot of CPU cores but not a lot of memory. The same applies for exporting large and complex geometry.

add_chip(chip, variant_name, **kwargs)[source]

Adds a chip with the given name and parameters to self.chips_map_legend and exports chip files.

Parameters
  • chip – the chip type class (for PCell chip), or a chip cell (for manually designed chip)

  • variant_name – name for specific variant, the same as in the mask layout

  • **kwargs – any parameters passed to the chip PCell

variant_definition(chip_class, variant_name, **kwargs)[source]

Returns chip variant definition with default mask specific parameters.

Parameters
  • chip_class – the chip type class

  • variant_name – name for specific variant, the same as in the mask layout

  • **kwargs – any parameters passed to the chip PCell

Returns

dictionary compatible with mask map structure

build(remove_guiding_shapes=True)[source]

Builds the mask set.

Creates cells for the mask based on self.mask_layouts and self.chips_map_legend. Optionally removes guiding shapes from the layout. Populates self.used_chips with the chips used in the mask layouts.

Parameters

remove_guiding_shapes (Boolean) – determines if the guiding shapes are removed

export(path, view=None)[source]

Exports designs, bitmaps and documentation of this mask set.

Assumes that self.build() has been called before.

Parameters
  • path – path where the folder for this mask set is created

  • view – KLayout view object

static chips_map_from_box_map(box_map, mask_map)[source]

Returns the chips_map created from box_map and mask_map.

Given NxN box map and MxM mask_map, creates chips_map of size MNxMN. So each element of mask map is “replaced” by a box in the box map. Assumes that box_map and mask_map are square.

Parameters
  • box_map – dictionary where keys are strings identifying the box type, and values are 2D arrays (lists of lists) where each element is a string identifying the chip type

  • mask_map – 2D array (list of lists), where each element is a string identifying the box type

../_images/kqcircuits.masks.mask_set.png