kqcircuits.masks.mask_set

class kqcircuits.masks.mask_set.MaskSet(view=None, name='MaskSet', version=1, with_grid=False, export_drc=False, mask_export_layers=None, export_path=PosixPath('/__w/KQCircuits/KQCircuits/tmp'))[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_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().

Chips are created in parallel in separate processes but the user may choose to use a -d switch on the command line for debugging with a single process. It is also possible to manually limit the number of concurrently used CPUs for resource management purposes with the -c 4 switch (to 4 in this example).

Example

mask = MaskSet(…) mask.add_mask_layout(…) mask.add_mask_layout(…) mask.add_chip(…) 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

export_path

The folder for mask files will be generated under this. TMP_PATH by default.

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

add_multi_face_mask_layout(face_ids, chips_map=None, extra_face_params=None, mask_layout_type=<class 'kqcircuits.masks.mask_layout.MaskLayout'>, **kwargs)[source]

Create a multi face mask layout, which can be used to make masks with matching chip maps on multiple faces.

A MaskLayout is created of each face in face_ids. By default, the individual mask layouts all have identical parameters, but parameters can be overwritten for a single face id through extra_face_params.

By default, bbox_face_ids is set to face_ids for all mask layouts.

Parameters
  • face_ids – list of face ids to include

  • chips_map – Chips map to use, or None to use an empty chips map.

  • extra_face_params – a dictionary of {face_id: extra_kwargs}, where extra_kwargs is a dictionary of keyword arguments to apply only to the mask layout for face_id.

  • mask_layout_type – optional subclass of MaskLayout to use

  • kwargs – any keyword arguments are passed to all containing mask layouts.

Returns: a MultiFaceMaskLayout instance

add_chip(chips, variant_name=None, cpus=None, **parameters)[source]

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

Note the complex polymorphism used here: chips is either a single chip class or a list of (chip, variant, parameters) tuples. In the latter case the rest of the arguments (except cpus) are ignored. Also, chips (or the individual chip part of tuples) may be a simple file name to load a static .oas file instead.

The chip’s parameters dictionary may also contain an alt_netlists dictionary to specify alternative ways of generating netlists. See export_cell_netlist() or the quick_demo.py mask for further information.

Parameters
  • chip – A chip class. Or a list of tuples, like [(QualityFactor, "QDG", parameters),...], parameters are optional.

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

  • cpus – Number of parallel processes to use for chip generation. By default uses os.cpu_count() or the number of chips, whichever is smaller.

  • **parameters – Any parameters passed to the a single chip PCell.

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()[source]

Exports designs, bitmaps and documentation of this mask set.

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

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