bag.layout.core

This module defines some core layout classes

Module Contents

Classes

PyLayInstance

Attributes

T

bag.layout.core.T[source]
class bag.layout.core.PyLayInstance(parent: bag.layout.template.TemplateBase, master: bag.layout.template.TemplateBase, ref: pybag.core.PyLayInstRef)[source]
property name: str[source]
property committed: bool[source]
property nx: int[source]

Number of columns.

Type:

int

property ny: int[source]

Number of rows.

Type:

int

property spx: int[source]

The column pitch.

Type:

int

property spy: int[source]

The row pitch.

Type:

int

property master: bag.layout.template.TemplateBase[source]

The master of this instance.

Type:

TemplateBase

property transformation: pybag.core.Transform[source]

The instance transformation object.

Type:

Transform

property bound_box: pybag.core.BBox[source]

Returns the overall bounding box of this instance.

Type:

BBox

property array_box: pybag.core.BBox[source]

Returns the array box of this instance.

property fill_box: pybag.core.BBox[source]

Returns the fill box of this instance.

get_item_location(row: int = 0, col: int = 0) Tuple[int, int][source]

Returns the location of the given item in the array.

Parameters:
  • row (int) – the item row index. 0 is the bottom-most row.

  • col (int) – the item column index. 0 is the left-most column.

Returns:

  • xo (int) – the item X coordinate.

  • yo (int) – the item Y coordinate.

get_bound_box_of(row: int = 0, col: int = 0) pybag.core.BBox[source]

Returns the bounding box of an instance in this mosaic.

Parameters:
  • row (int) – the item row index. 0 is the bottom-most row.

  • col (int) – the item column index. 0 is the left-most column.

Returns:

bbox – the bounding box.

Return type:

BBox

move_by(dx: int = 0, dy: int = 0) None[source]

Moves this instance by the given amount.

Parameters:
  • dx (int) – the X shift.

  • dy (int) – the Y shift.

transform(xform: pybag.core.Transform) None[source]

Transform the location of this instance.

Parameters:

xform (Transform) – the transformation to apply to this instance.

new_master_with(**kwargs: Any) None[source]

Change the master template of this instance.

This method will get the old master template layout parameters, update the parameter values with the given dictionary, then create a new master template with those parameters and associate it with this instance.

Parameters:

**kwargs (Any) – a dictionary of new parameter values.

transform_master_object(obj: T, row: int = 0, col: int = 0) T[source]

Transforms the given object in instance master w.r.t. this instance’s Transform object.

Parameters:
  • obj (T) – the object to transform. Must have get_transform() method defined.

  • row (int) – the instance row index. Index 0 is the bottom-most row.

  • col (int) – the instance column index. Index 0 is the left-most column.

Returns:

ans – the transformed object.

Return type:

T

get_port(name: str = '', row: int = 0, col: int = 0) bag.layout.routing.base.Port[source]

Returns the port object of the given instance in the array.

Parameters:
  • name (str) – the port terminal name. If empty, check if this instance has only one port, then return it.

  • row (int) – the instance row index. Index 0 is the bottom-most row.

  • col (int) – the instance column index. Index 0 is the left-most column.

Returns:

port – the port object.

Return type:

Port

get_primitive_port(name: str, check_fun: Callable[[int], bool], row: int = 0, col: int = 0) bag.layout.routing.base.Port[source]

Returns the port object of the given instance in the array.

Parameters:
  • name (str) – the port terminal name. If empty, check if this instance has only one port, then return it.

  • check_fun (Callable[[int], bool]) – a function that returns true if a layer is considered “private”.

  • row (int) – the instance row index. Index 0 is the bottom-most row.

  • col (int) – the instance column index. Index 0 is the left-most column.

Returns:

port – the port object.

Return type:

Port

get_pin(name: str = '', row: int = 0, col: int = 0, layer: int = Port.default_layer) Union[bag.layout.routing.base.WireArray, pybag.core.BBox][source]

Returns the first pin with the given name.

This is an efficient method if you know this instance has exactly one pin.

Parameters:
  • name (str) – the port terminal name. If None or empty, check if this instance has only one port, then return it.

  • row (int) – the instance row index. Index 0 is the bottom-most row.

  • col (int) – the instance column index. Index 0 is the left-most column.

  • layer (int) – the pin layer. If negative, check to see if the given port has only one layer. If so then use that layer.

Returns:

pin – the first pin associated with the port of given name.

Return type:

Union[WireArray, BBox]

port_pins_iter(name: str = '', layer: Union[int, str] = Port.default_layer) Iterable[Union[bag.layout.routing.base.WireArray, pybag.core.BBox]][source]

Iterate through all pins of all ports with the given name in this instance array.

Parameters:
  • name (str) – the port terminal name. If None or empty, check if this instance has only one port, then return it.

  • layer (Union[int, str]) – the pin layer ID or primitive pin layer name. If negative, check to see if the given port has only one layer. If so then use that layer.

Yields:

pin (Union[WireArray, BBox]) – the pin as WireArray or bounding box.

get_all_port_pins(name: str = '', layer: Union[int, str] = Port.default_layer) Union[List[bag.layout.routing.base.WireArray], List[pybag.core.BBox]][source]

Returns a list of all pins of all ports with the given name in this instance array.

This method gathers ports from all instances in this array with the given name, then find all pins of those ports on the given layer, then return as list of WireArrays.

Parameters:
  • name (str) – the port terminal name. If None or empty, check if this instance has only one port, then return it.

  • layer (Union[int, str]) – the pin layer ID or primitive pin layer name. If negative, check to see if the given port has only one layer. If so then use that layer.

Returns:

pin_list – the list of pins as WireArrays or bounding boxes.

Return type:

Union[List[WireArray], List[BBox]]

port_names_iter() Iterable[str][source]

Iterates over port names in this instance.

Yields:

port_name (str) – name of a port in this instance.

has_port(port_name: str) bool[source]

Returns True if this instance has the given port.

commit() None[source]