kqcircuits.util.instance_hierarchy_helpers

class kqcircuits.util.instance_hierarchy_helpers.InstanceHierarchy(instance: Instance, trans: DCplxTrans, parent_instances: List[Instance], top_cell: Cell)[source]

Bases: object

Data structure holding the instance hierarchy of a single cell instance

instance: Instance
trans: DCplxTrans
parent_instances: List[Instance]
top_cell: Cell
kqcircuits.util.instance_hierarchy_helpers.get_cell_instance_hierarchy(layout: Layout, cell_index: int) List[InstanceHierarchy][source]

Find all instances of a cell and their transforms (DCplxTrans) in the global coordinate system. Resolves the full cell hierarchy.

Parameters:
  • layout – Layout object

  • cell_index – Cell index of the cell to find instances of

Returns: list of InstanceHierarchy structrures describing the cell hierarchy of each instance

kqcircuits.util.instance_hierarchy_helpers.formatted_cell_instance_hierarchy(inst_data: InstanceHierarchy) str[source]

Create formatted list showing the instance hierarchy of all instances of a cell, including the global transformation of the instance and the instance names along the hierarchy if they are defined.

Parameters:
  • layout – Layout object

  • cell_index – Cell index of the cell to find instances of

Returns: formatted string (multiple lines)

kqcircuits.util.instance_hierarchy_helpers.transform_top_cell(transform: DCplxTrans | DTrans, layout: Layout, cell: None | Cell = None) None[source]

Apply transformation to a top cell. Useful for chips.

An alternative to layout.transform, but it preserves transformation hierarchy of instances. KLayout’s layout.transform function tends to make transformation displacement to be arbitrary, and compensate for it by shifting polygons within instances. transform_top_cell will make sure that polygons won’t shift in relation to its instance’s origin within instance hierarchy.

Parameters:
  • transform – Transformation to apply

  • layout – Layout where the top cell is. Will contain changed geometry after this call.

  • cell – Optional, to specify which top cell to transform within layout.

../_images/kqcircuits.util.instance_hierarchy_helpers.png