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:
objectData 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
InstanceHierarchystructrures describing the cell hierarchy of each instance
- kqcircuits.util.instance_hierarchy_helpers.get_instance_marker_polygons(instance: Instance, trans: DCplxTrans | None = None, marker_shape_layer: str = 'ground_grid_avoidance') List[DPolygon][source]
Return ground-grid silhouette polygons for an instance in top-cell coordinates.
- Parameters:
instance – Instance whose geometry should be highlighted.
trans – Optional instance transform in top-cell coordinates. Defaults to
instance.dcplx_trans.marker_shape_layer – Name of the layer to use for marker shapes. Defaults to
"ground_grid_avoidance".
Returns: DPolygons from the instance’s primary face marker layer.
- 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_cellwill 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.