bag.layout.template
This module defines layout template classes.
Module Contents
Classes
A database of all templates. |
|
The base template class. |
Functions
|
|
|
|
|
Attributes
- class bag.layout.template.TemplateDB(routing_grid: bag.layout.routing.grid.RoutingGrid, lib_name: str, log_file: str, prj: Optional[bag.core.BagProject] = None, name_prefix: str = '', name_suffix: str = '', log_level: pybag.enum.LogLevel = LogLevel.DEBUG)[source]
Bases:
bag.util.cache.MasterDB
A database of all templates.
This class is a subclass of MasterDB that defines some extra properties/function aliases to make creating layouts easier.
- Parameters:
routing_grid (RoutingGrid) – the default RoutingGrid object.
lib_name (str) – the cadence library to put all generated templates in.
log_file (str) – the log file path.
prj (Optional[BagProject]) – the BagProject instance.
name_prefix (str) – generated layout name prefix.
name_suffix (str) – generated layout name suffix.
log_level (LogLevel) – the logging level.
- property grid: bag.layout.routing.grid.RoutingGrid[source]
The global RoutingGrid instance.
- Type:
- property tech_info: bag.layout.tech.TechInfo[source]
the TechInfo object.
- Type:
- new_template(temp_cls: Type[TemplateType], params: Optional[Mapping[str, Any]] = None, **kwargs: Any) TemplateType [source]
Alias for new_master() for backwards compatibility.
- instantiate_layout(template: TemplateBase, top_cell_name: str = '', output: pybag.enum.DesignOutput = DesignOutput.LAYOUT, **kwargs: Any) None [source]
Alias for instantiate_master(), with default output type of LAYOUT.
- batch_layout(info_list: Sequence[Tuple[TemplateBase, str]], output: pybag.enum.DesignOutput = DesignOutput.LAYOUT, **kwargs: Any) None [source]
Alias for batch_output(), with default output type of LAYOUT.
- bag.layout.template.get_cap_via_extensions(info: bag.layout.data.MOMCapInfo, grid: bag.layout.routing.grid.RoutingGrid, bot_layer: int, top_layer: int) Dict[int, int] [source]
- class bag.layout.template.TemplateBase(temp_db: TemplateDB, params: bag.util.immutable.Param, log_file: str, log_level: pybag.enum.LogLevel = LogLevel.DEBUG, **kwargs: Any)[source]
Bases:
bag.util.cache.DesignMaster
The base template class.
- Parameters:
temp_db (TemplateDB) – the template database.
params (Param) – the parameter values.
log_file (str) – the log file path.
log_level (LogLevel) – the logging level.
**kwargs (Any) –
dictionary of the following optional parameters:
- gridRoutingGrid
the routing grid to use for this template.
- property blackbox_gds: List[pathlib.Path][source]
- property sch_params: Optional[bag.util.immutable.Param][source]
The schematic parameters dictionary.
- Type:
Optional[Dict[str, Any]]
- property template_db: TemplateDB[source]
The template database object
- Type:
- property grid: bag.layout.routing.grid.RoutingGrid[source]
The RoutingGrid object
- Type:
- property array_box: Optional[pybag.core.BBox][source]
The array/abutment bounding box of this template.
- Type:
Optional[BBox]
- property fill_box: Optional[pybag.core.BBox][source]
The dummy fill bounding box of this template.
- Type:
Optional[BBox]
- property size: Optional[bag.typing.SizeType][source]
The size of this template, in (layer, nx_blk, ny_blk) format.
- Type:
Optional[SizeType]
- property bound_box: Optional[pybag.core.BBox][source]
Returns the template BBox. None if size not set yet.
- Type:
Optional[BBox]
- property layout_cellview: pybag.core.PyLayCellView[source]
The internal layout object.
- Type:
PyLayCellView
- property edge_info: Optional[bag.layout.data.TemplateEdgeInfo][source]
Returns a dictionary of hidden parameter values.
hidden parameters are parameters are invisible to the user and only used and computed internally.
- Returns:
hidden_params – dictionary of hidden parameter values.
- Return type:
Dict[str, Any]
- classmethod get_schematic_class() Optional[Type[bag.design.module.Module]] [source]
- abstract draw_layout() None [source]
Draw the layout of this template.
Override this method to create the layout.
WARNING: you should never call this method yourself.
- get_schematic_class_inst() Optional[Type[bag.design.module.Module]] [source]
- get_master_basename() str [source]
Returns the base name to use for this instance.
- Returns:
basename – the base name for this instance.
- Return type:
- get_layout_basename() str [source]
Returns the base name for this template.
- Returns:
base_name – the base name of this template.
- Return type:
- get_content(output_type: pybag.enum.DesignOutput, rename_dict: Dict[str, str], name_prefix: str, name_suffix: str, shell: bool, exact_cell_names: Set[str], supply_wrap_mode: pybag.enum.SupplyWrapMode) Tuple[str, Any] [source]
Returns the content of this master instance.
- Parameters:
output_type (DesignOutput) – the output type.
name_prefix (str) – the name prefix.
name_suffix (str) – the name suffix.
shell (bool) – True if we’re just producing a shell content (i.e. just top level block).
exact_cell_names (Set[str]) – set of cell names to keep exact (don’t add prefix and suffix)
supply_wrap_mode (SupplyWrapMode) – the netlisting supply wrap mode.
- Returns:
cell_name (str) – the master cell name.
content (Any) – the master content data structure.
- get_margin(top_layer: int, edge_dir: pybag.enum.Direction2D, half_blk_x: bool = True, half_blk_y: bool = True) int [source]
- get_rect_bbox(lay_purp: Tuple[str, str]) pybag.core.BBox [source]
Returns the overall bounding box of all rectangles on the given layer.
Note: currently this does not check primitive instances or vias.
- new_template_with(**kwargs: Any) TemplateBase [source]
Create a new template with the given parameters.
This method will update the parameter values with the given dictionary, then create a new template with those parameters and return it.
- Parameters:
**kwargs (Any) – a dictionary of new parameter values.
- Returns:
new_temp – A new layout master object.
- Return type:
- set_size_from_bound_box(top_layer_id: int, bbox: pybag.core.BBox, *, round_up: bool = False, half_blk_x: bool = True, half_blk_y: bool = True)[source]
Compute the size from overall bounding box.
- Parameters:
top_layer_id (int) – the top level routing layer ID that array box is calculated with.
bbox (BBox) – the overall bounding box
round_up (bool) – True to round up bounding box if not quantized properly
half_blk_x (bool) – True to allow half-block widths.
half_blk_y (bool) – True to allow half-block heights.
- set_size_from_array_box(top_layer_id: int) None [source]
Automatically compute the size from array_box.
Assumes the array box is exactly in the center of the template.
- Parameters:
top_layer_id (int) – the top level routing layer ID that array box is calculated with.
- get_pin_name(name: str) str [source]
Get the actual name of the given pin from the renaming dictionary.
Given a pin name, If this Template has a parameter called ‘rename_dict’, return the actual pin name from the renaming dictionary.
- get_port(name: str = '') bag.layout.routing.base.Port [source]
Returns the port object with the given name.
- port_names_iter() Iterable[str] [source]
Iterates over port names in this template.
- Yields:
port_name (str) – name of a port in this template.
- new_template(temp_cls: Type[TemplateType], *, params: Optional[Mapping[str, Any]] = None, show_pins: bool = False, grid: Optional[bag.layout.routing.grid.RoutingGrid] = None) TemplateType [source]
Create a new template.
- Parameters:
temp_cls (Type[TemplateType]) – the template class to instantiate.
params (Optional[Mapping[str, Any]]) – the parameter dictionary.
show_pins (bool) – True to pass show_pins in the generated template, if params does not already have show_pins.
grid (Optional[RoutingGrid]) – routing grid for this cell.
- Returns:
template – the new template instance.
- Return type:
TemplateType
- add_instance(master: TemplateBase, *, inst_name: str = '', xform: Optional[pybag.core.Transform] = None, nx: int = 1, ny: int = 1, spx: int = 0, spy: int = 0, commit: bool = True) bag.layout.core.PyLayInstance [source]
Adds a new (arrayed) instance to layout.
- Parameters:
master (TemplateBase) – the master template object.
inst_name (Optional[str]) – instance name. If None or an instance with this name already exists, a generated unique name is used.
xform (Optional[Transform]) – the transformation object.
nx (int) – number of columns. Must be positive integer.
ny (int) – number of rows. Must be positive integer.
spx (CoordType) – column pitch. Used for arraying given instance.
spy (CoordType) – row pitch. Used for arraying given instance.
commit (bool) – True to commit the object immediately.
- Returns:
inst – the added instance.
- Return type:
- add_instance_primitive(lib_name: str, cell_name: str, *, xform: Optional[pybag.core.Transform] = None, view_name: str = 'layout', inst_name: str = '', nx: int = 1, ny: int = 1, spx: int = 0, spy: int = 0, params: Optional[Dict[str, Any]] = None, commit: bool = True, **kwargs: Any) pybag.core.PyLayInstRef [source]
Adds a new (arrayed) primitive instance to layout.
- Parameters:
lib_name (str) – instance library name.
cell_name (str) – instance cell name.
xform (Optional[Transform]) – the transformation object.
view_name (str) – instance view name. Defaults to ‘layout’.
inst_name (Optional[str]) – instance name. If None or an instance with this name already exists, a generated unique name is used.
nx (int) – number of columns. Must be positive integer.
ny (int) – number of rows. Must be positive integer.
spx (CoordType) – column pitch. Used for arraying given instance.
spy (CoordType) – row pitch. Used for arraying given instance.
params (Optional[Dict[str, Any]]) – the parameter dictionary. Used for adding pcell instance.
commit (bool) – True to commit the object immediately.
**kwargs (Any) – additional arguments. Usually implementation specific.
- Returns:
ref – A reference to the primitive instance.
- Return type:
PyLayInstRef
- is_horizontal(layer: str) bool [source]
Returns True if the given layer has no direction or is horizontal.
- add_rect(lay_purp: Tuple[str, str], bbox: pybag.core.BBox, commit: bool = True) pybag.core.PyRect [source]
Add a new rectangle.
- add_rect_array(lay_purp: Tuple[str, str], bbox: pybag.core.BBox, nx: int = 1, ny: int = 1, spx: int = 0, spy: int = 0) None [source]
Add a new rectangle array.
- add_bbox_array(lay_purp: Tuple[str, str], barr: pybag.core.BBoxArray) None [source]
Add a new rectangle array.
- add_res_metal(layer_id: int, bbox: pybag.core.BBox) None [source]
Add a new metal resistor.
- Parameters:
layer_id (int) – the metal layer ID.
bbox (BBox) – the resistor bounding box.
- add_path(lay_purp: Tuple[str, str], width: int, points: List[bag.typing.PointType], start_style: pybag.enum.PathStyle, *, join_style: pybag.enum.PathStyle = PathStyle.round, stop_style: Optional[pybag.enum.PathStyle] = None, commit: bool = True) pybag.core.PyPath [source]
Add a new path.
- Parameters:
width (int) – the path width.
points (List[PointType]) – points defining this path.
start_style (PathStyle) – the path beginning style.
join_style (PathStyle) – path style for the joints.
stop_style (Optional[PathStyle]) – the path ending style. Defaults to start style.
commit (bool) – True to commit the object immediately.
- Returns:
path – the added path object.
- Return type:
PyPath
- add_path45_bus(lay_purp: Tuple[str, str], points: List[bag.typing.PointType], widths: List[int], spaces: List[int], start_style: pybag.enum.PathStyle, *, join_style: pybag.enum.PathStyle = PathStyle.round, stop_style: Optional[pybag.enum.PathStyle] = None, commit: bool = True) pybag.core.PyPath [source]
Add a path bus that only contains 45 degree turns.
- Parameters:
points (List[PointType]) – points defining this path.
widths (List[int]) – width of each path in the bus.
spaces (List[int]) – space between each path.
start_style (PathStyle) – the path beginning style.
join_style (PathStyle) – path style for the joints.
stop_style (Optional[PathStyle]) – the path ending style. Defaults to start style.
commit (bool) – True to commit the object immediately.
- Returns:
path – the added path object.
- Return type:
PyPath
- add_polygon(lay_purp: Tuple[str, str], points: List[bag.typing.PointType], commit: bool = True) pybag.core.PyPolygon [source]
Add a new polygon.
- add_blockage(layer: str, blk_type: pybag.enum.BlockageType, points: List[bag.typing.PointType], commit: bool = True) pybag.core.PyBlockage [source]
Add a new blockage object.
- add_boundary(bnd_type: pybag.enum.BoundaryType, points: List[bag.typing.PointType], commit: bool = True) pybag.core.PyBoundary [source]
Add a new boundary.
- add_cell_boundary(bbox: pybag.core.BBox) None [source]
Adds cell boundary in this template.
By default, this method is called when finalizing a template (although the process implementation may override this behavior) to set the cell boundary, which is generally used for DRC or P&R purposes.
This method can only be called once from the template. All calls after the first one will be ignored. Therefore, if you need to set the cell boundary to be something other than the template’s bounding box, you can call this in the draw_layout() method.
- Parameters:
bbox (BBox) – the cell boundary bounding box.
- reexport(port: bag.layout.routing.base.Port, *, net_name: str = '', label: str = '', show: Optional[bool] = None, hide: Optional[bool] = None, connect: bool = False) None [source]
Re-export the given port object.
Add all geometries in the given port as pins with optional new name and label.
- Parameters:
port (Port) – the Port object to re-export.
net_name (str) – the new net name. If not given, use the port’s current net name.
label (str) – the label. If not given, use net_name.
show (Optional[bool]) – True to draw the pin in layout. If None, use self.show_pins
hide (Optional[bool]) – if given, it overrides the hide flag of the port, otherwise the default is used.
connect (bool) – True to enable connection by name.
- add_pin_primitive(net_name: str, layer: str, bbox: pybag.core.BBox, *, label: str = '', show: Optional[bool] = None, hide: bool = False, connect: bool = False)[source]
Add a primitive pin to the layout.
- Parameters:
net_name (str) – the net name associated with the pin.
layer (str) – the pin layer name.
bbox (BBox) – the pin bounding box.
label (str) – the label of this pin. If None or empty, defaults to be the net_name. this argument is used if you need the label to be different than net name for LVS purposes. For example, unconnected pins usually need a colon after the name to indicate that LVS should short those pins together.
show (Optional[bool]) – True to draw the pin in layout. If None, use self.show_pins
hide (bool) – True to add a hidden pin.
connect (bool) – True to enable connection by name.
- add_label(label: str, lay_purp: Tuple[str, str], bbox: pybag.core.BBox) None [source]
Adds a label to the layout.
This is mainly used to add voltage text labels.
- add_pin(net_name: str, wire_arr_list: Union[bag.layout.routing.base.WireArray, List[bag.layout.routing.base.WireArray]], *, label: str = '', show: Optional[bool] = None, mode: pybag.enum.PinMode = PinMode.ALL, hide: bool = False, connect: bool = False) None [source]
Add new pin to the layout.
If one or more pins with the same net name already exists, they’ll be grouped under the same port.
- Parameters:
net_name (str) – the net name associated with the pin.
wire_arr_list (Union[WireArray, List[WireArray]]) – WireArrays representing the pin geometry.
label (str) – the label of this pin. If None or empty, defaults to be the net_name. this argument is used if you need the label to be different than net name for LVS purposes. For example, unconnected pins usually need a colon after the name to indicate that LVS should short those pins together.
show (Optional[bool]) – if True, draw the pin in layout. If None, use self.show_pins
mode (PinMode) – location of the pin relative to the WireArray.
hide (bool) – True if this is a hidden pin.
connect (bool) – True to enable connection by name.
- add_via(bbox: pybag.core.BBox, bot_lay_purp: Tuple[str, str], top_lay_purp: Tuple[str, str], bot_dir: pybag.enum.Orient2D, *, extend: bool = True, top_dir: Optional[pybag.enum.Orient2D] = None, add_layers: bool = False, commit: bool = True) pybag.core.PyVia [source]
Adds an arrayed via object to the layout.
- Parameters:
bbox (BBox) – the via bounding box, not including extensions.
bot_lay_purp (Tuple[str. str]) – the bottom layer/purpose pair.
top_lay_purp (Tuple[str, str]) – the top layer/purpose pair.
bot_dir (Orient2D) – the bottom layer extension direction.
extend (bool) – True if via extension can be drawn outside of the box.
top_dir (Optional[Orient2D]) – top layer extension direction. Defaults to be perpendicular to bottom layer direction.
add_layers (bool) – True to add metal rectangles on top and bottom layers.
commit (bool) – True to commit via immediately.
- Returns:
via – the new via object.
- Return type:
PyVia
- add_via_arr(barr: pybag.core.BBoxArray, bot_lay_purp: Tuple[str, str], top_lay_purp: Tuple[str, str], bot_dir: pybag.enum.Orient2D, *, extend: bool = True, top_dir: Optional[pybag.enum.Orient2D] = None, add_layers: bool = False) Dict[str, Any] [source]
Adds an arrayed via object to the layout.
- Parameters:
barr (BBoxArray) – the BBoxArray representing the via bounding boxes, not including extensions.
bot_lay_purp (Tuple[str. str]) – the bottom layer/purpose pair.
top_lay_purp (Tuple[str, str]) – the top layer/purpose pair.
bot_dir (Orient2D) – the bottom layer extension direction.
extend (bool) – True if via extension can be drawn outside of the box.
top_dir (Optional[Orient2D]) – top layer extension direction. Defaults to be perpendicular to bottom layer direction.
add_layers (bool) – True to add metal rectangles on top and bottom layers.
- Returns:
via_info – the via information dictionary.
- Return type:
Dict[str, Any]
- add_via_primitive(via_type: str, xform: pybag.core.Transform, cut_width: int, cut_height: int, *, num_rows: int = 1, num_cols: int = 1, sp_rows: int = 0, sp_cols: int = 0, enc1: Tuple[int, int, int, int] = (0, 0, 0, 0), enc2: Tuple[int, int, int, int] = (0, 0, 0, 0), nx: int = 1, ny: int = 1, spx: int = 0, spy: int = 0, priority: int = 1) None [source]
Adds via(s) by specifying all parameters.
- Parameters:
via_type (str) – the via type name.
xform (Transform) – the transformation object.
cut_width (CoordType) – via cut width. This is used to create rectangle via.
cut_height (CoordType) – via cut height. This is used to create rectangle via.
num_rows (int) – number of via cut rows.
num_cols (int) – number of via cut columns.
sp_rows (CoordType) – spacing between via cut rows.
sp_cols (CoordType) – spacing between via cut columns.
enc1 (Optional[List[CoordType]]) – a list of left, right, top, and bottom enclosure values on bottom layer. Defaults to all 0.
enc2 (Optional[List[CoordType]]) – a list of left, right, top, and bottom enclosure values on top layer. Defaults to all 0.
nx (int) – number of columns.
ny (int) – number of rows.
spx (int) – column pitch.
spy (int) – row pitch.
priority (int) – via priority, defaults to 1
- add_via_on_grid(tid1: bag.layout.routing.base.TrackID, tid2: bag.layout.routing.base.TrackID, *, extend: bool = True) Tuple[Tuple[int, int], Tuple[int, int]] [source]
Add a via on the routing grid.
- extend_wires(warr_list: Union[bag.layout.routing.base.WireArray, List[Optional[bag.layout.routing.base.WireArray]]], *, lower: Optional[int] = None, upper: Optional[int] = None, min_len_mode: Optional[int] = None) List[Optional[bag.layout.routing.base.WireArray]] [source]
Extend the given wires to the given coordinates.
- Parameters:
warr_list (Union[WireArray, List[Optional[WireArray]]]) – the wires to extend.
lower (Optional[int]) – the wire lower coordinate.
upper (Optional[int]) – the wire upper coordinate.
min_len_mode (Optional[int]) – If not None, will extend track so it satisfy minimum length requirement. Use -1 to extend lower bound, 1 to extend upper bound, 0 to extend both equally.
- Returns:
warr_list – list of added wire arrays. If any elements in warr_list were None, they will be None in the return.
- Return type:
List[Optional[WireArray]]
- add_wires(layer_id: int, track_idx: bag.typing.TrackType, lower: int, upper: int, *, width: int = 1, num: int = 1, pitch: bag.typing.TrackType = 1) bag.layout.routing.base.WireArray [source]
Add the given wire(s) to this layout.
- Parameters:
- Returns:
warr – the added WireArray object.
- Return type:
- add_matched_wire(warr: bag.layout.routing.base.WireArray, coord: int, layer_id: int) bag.layout.routing.base.WireArray [source]
Adds a wire (without any via), matched to a provided wire array. The mirroring takes place with respect to a coordinate and the track direction on the layer of the coordinate
- Parameters:
- Returns:
warr – the added WireArray object.
- Return type:
- connect_to_tracks_with_dummy_wires(wire_arr_list: Union[bag.layout.routing.base.WireArray, List[bag.layout.routing.base.WireArray]], track_id: bag.layout.routing.base.TrackID, ref_coord: int, ref_layer_id: int, *, wire_lower: Optional[int] = None, wire_upper: Optional[int] = None, track_lower: Optional[int] = None, track_upper: Optional[int] = None, min_len_mode: pybag.enum.MinLenMode = None, ret_wire_list: Optional[List[bag.layout.routing.base.WireArray]] = None, debug: bool = False) Optional[bag.layout.routing.base.WireArray] [source]
- Implements connect_to_tracks but with matched wires drawn simultaneously
Parameters
- track_idTrackID
TrackID that specifies the track(s) to connect the given wires to.
- ref_coord: int
the coordinate which is used for mirroring
- ref_layer_id: int
the layer_id of the coordinate. this argument is used to figure out the axis around which things should be mirrored
- wire_lowerOptional[CoordType]
if given, extend wire(s) to this lower coordinate.
- wire_upperOptional[CoordType]
if given, extend wire(s) to this upper coordinate.
- track_lowerOptional[CoordType]
if given, extend track(s) to this lower coordinate.
- track_upperOptional[CoordType]
if given, extend track(s) to this upper coordinate.
- min_len_modeMinLenMode
the minimum length extension mode.
- ret_wire_listOptional[List[WireArray]]
If not none, extended wires that are created will be appended to this list.
- debugbool
True to print debug messages.
- Returns:
wire_arr – WireArray representing the tracks created.
- Return type:
Optional[WireArray]
- connect_wire_to_coord(wire: bag.layout.routing.base.WireArray, layer_id: int, coord: int, min_len_mode: pybag.enum.MinLenMode = MinLenMode.NONE, round_mode: pybag.enum.RoundMode = RoundMode.NONE) bag.layout.routing.base.WireArray [source]
Connects a given wire to a wire on the next/previous layer aligned with a given coordinate.
- Parameters:
wire (WireArray) – wire object to be connected.
layer_id (int) – the wire layer ID.
coord (CoordType) – the coordinate to be used for alignment.
min_len_mode (MinLenMode) – the minimum length extension mode used in connect_to_tracks.
round_mode (RoundMode) – the rounding mode used in coord_to_track conversion.
- Returns:
warr – the added WireArray object.
- Return type:
- add_res_metal_warr(layer_id: int, track_idx: bag.typing.TrackType, lower: int, upper: int, **kwargs: Any) bag.util.immutable.Param [source]
Add metal resistor as WireArray to this layout.
- Parameters:
layer_id (int) – the wire layer ID.
track_idx (TrackType) – the smallest wire track index.
lower (CoordType) – the wire lower coordinate.
upper (CoordType) – the wire upper coordinate.
**kwargs – optional arguments to add_wires()
- Returns:
sch_params – the metal resistor schematic parameters dictionary.
- Return type:
Dict[str, Any]
- add_mom_cap(cap_box: pybag.core.BBox, bot_layer: int, num_layer: int, *, port_widths: Optional[Mapping[int, int]] = None, port_plow: Optional[Mapping[int, bool]] = None, array: bool = False, cap_wires_list: Optional[List[Tuple[Tuple[str, str], Tuple[str, str], pybag.core.BBoxArray, pybag.core.BBoxArray]]] = None, cap_type: str = 'standard') Dict[int, Tuple[List[bag.layout.routing.base.WireArray], List[bag.layout.routing.base.WireArray]]] [source]
Draw mom cap in the defined bounding box.
- _add_mom_cap_connect_cap_to_port(cap_dir: pybag.enum.Direction, cap_lp: Tuple[str, str], barr: pybag.core.BBoxArray, ports: List[bag.layout.routing.base.WireArray]) None [source]
- _add_mom_cap_connect_ports(bot_ports: List[bag.layout.routing.base.WireArray], top_ports: List[bag.layout.routing.base.WireArray]) None [source]
- reserve_tracks(layer_id: int, track_idx: bag.typing.TrackType, *, width: int = 1, num: int = 1, pitch: int = 0) None [source]
Reserve the given routing tracks so that power fill will not fill these tracks.
Note: the size of this template should be set before calling this method.
- get_available_tracks(layer_id: int, tid_lo: bag.typing.TrackType, tid_hi: bag.typing.TrackType, lower: int, upper: int, width: int = 1, sep: bag.util.math.HalfInt = HalfInt(1), include_last: bool = False, sep_margin: Optional[bag.util.math.HalfInt] = None, uniform_grid: bool = False) List[bag.util.math.HalfInt] [source]
Returns a list of available tracks between the given bounds.
- Parameters:
layer_id (int) – the layer ID.
tid_lo (TrackType) – the lower track index, inclusive.
tid_hi (TrackType) – the upper track index, exclusive by default.
lower (int) – the lower wire coordinate.
upper (int) – the upper wire coordinate.
width (int) – the track width.
sep (HalfInt) – the track separation
include_last (bool) – True to make “upper” inclusive.
sep_margin (Optional[HalfInt]) – the margin between available tracks and surrounding wires, in number of tracks.
uniform_grid (bool) – True to get available tracks on a uniform grid; False to get densely packed available tracks
- Returns:
tidx_list – list of available tracks.
- Return type:
List[HalfInt]
- connect_wires(wire_arr_list: Union[bag.layout.routing.base.WireArray, List[bag.layout.routing.base.WireArray]], *, lower: Optional[int] = None, upper: Optional[int] = None, debug: bool = False) List[bag.layout.routing.base.WireArray] [source]
Connect all given WireArrays together.
all WireArrays must be on the same layer.
- Parameters:
wire_arr_list (Union[WireArr, List[WireArr]]) – WireArrays to connect together.
lower (Optional[CoordType]) – if given, extend connection wires to this lower coordinate.
upper (Optional[CoordType]) – if given, extend connection wires to this upper coordinate.
debug (bool) – True to print debug messages.
- Returns:
conn_list – list of connection wires created.
- Return type:
List[WireArray]
- connect_bbox_to_tracks(layer_dir: pybag.enum.Direction, lay_purp: Tuple[str, str], box_arr: Union[pybag.core.BBox, pybag.core.BBoxArray], track_id: bag.layout.routing.base.TrackID, *, track_lower: Optional[int] = None, track_upper: Optional[int] = None, min_len_mode: pybag.enum.MinLenMode = MinLenMode.NONE, wire_lower: Optional[int] = None, wire_upper: Optional[int] = None, ret_bnds: Optional[List[int]] = None) bag.layout.routing.base.WireArray [source]
Connect the given primitive wire to given tracks.
- Parameters:
layer_dir (Direction) – the primitive wire layer direction relative to the given tracks. LOWER if the wires are below tracks, UPPER if the wires are above tracks.
lay_purp (Tuple[str, str]) – the primitive wire layer/purpose name.
box_arr (Union[BBox, BBoxArray]) – bounding box of the wire(s) to connect to tracks.
track_id (TrackID) – TrackID that specifies the track(s) to connect the given wires to.
track_lower (Optional[int]) – if given, extend track(s) to this lower coordinate.
track_upper (Optional[int]) – if given, extend track(s) to this upper coordinate.
min_len_mode (MinLenMode) – The minimum length extension mode.
wire_lower (Optional[int]) – if given, extend wire(s) to this lower coordinate.
wire_upper (Optional[int]) – if given, extend wire(s) to this upper coordinate.
ret_bnds (Optional[List[int]]) – if given, return the bounds on the bounding box layer.
- Returns:
wire_arr – WireArray representing the tracks created.
- Return type:
- connect_bbox_to_track_wires(layer_dir: pybag.enum.Direction, lay_purp: Tuple[str, str], box_arr: Union[pybag.core.BBox, pybag.core.BBoxArray], track_wires: Union[bag.layout.routing.base.WireArray, List[bag.layout.routing.base.WireArray]], *, min_len_mode: pybag.enum.MinLenMode = MinLenMode.NONE, ret_bnds: Optional[List[int]] = None) Union[Optional[bag.layout.routing.base.WireArray], List[Optional[bag.layout.routing.base.WireArray]]] [source]
- connect_bbox_to_differential_tracks(p_lay_dir: pybag.enum.Direction, n_lay_dir: pybag.enum.Direction, p_lay_purp: Tuple[str, str], n_lay_purp: Tuple[str, str], pbox: Union[pybag.core.BBox, pybag.core.BBoxArray], nbox: Union[pybag.core.BBox, pybag.core.BBoxArray], tr_layer_id: int, ptr_idx: bag.typing.TrackType, ntr_idx: bag.typing.TrackType, *, width: int = 1, track_lower: Optional[int] = None, track_upper: Optional[int] = None, min_len_mode: pybag.enum.MinLenMode = MinLenMode.NONE) DiffWarrType [source]
Connect the given differential primitive wires to two tracks symmetrically.
This method makes sure the connections are symmetric and have identical parasitics.
- Parameters:
p_lay_dir (Direction) – positive signal layer direction.
n_lay_dir (Direction) – negative signal layer direction.
p_lay_purp (Tuple[str, str]) – positive signal layer/purpose pair.
n_lay_purp (Tuple[str, str]) – negative signal layer/purpose pair.
pbox (Union[BBox, BBoxArray]) – positive signal wires to connect.
nbox (Union[BBox, BBoxArray]) – negative signal wires to connect.
tr_layer_id (int) – track layer ID.
ptr_idx (TrackType) – positive track index.
ntr_idx (TrackType) – negative track index.
width (int) – track width in number of tracks.
track_lower (Optional[int]) – if given, extend track(s) to this lower coordinate.
track_upper (Optional[int]) – if given, extend track(s) to this upper coordinate.
min_len_mode (MinLenMode) – the minimum length extension mode.
- Returns:
p_track (Optional[WireArray]) – the positive track.
n_track (Optional[WireArray]) – the negative track.
- fix_track_min_length(tr_layer_id: int, width: int, track_lower: int, track_upper: int, min_len_mode: pybag.enum.MinLenMode) Tuple[int, int] [source]
- connect_bbox_to_matching_tracks(lay_dir_list: List[pybag.enum.Direction], lay_purp_list: List[Tuple[str, str]], box_arr_list: List[Union[pybag.core.BBox, pybag.core.BBoxArray]], tr_layer_id: int, tr_idx_list: List[bag.typing.TrackType], *, width: int = 1, track_lower: Optional[int] = None, track_upper: Optional[int] = None, min_len_mode: pybag.enum.MinLenMode = MinLenMode.NONE) List[Optional[bag.layout.routing.base.WireArray]] [source]
Connect the given primitive wire to given tracks.
- Parameters:
lay_dir_list (List[Direction]) – the primitive wire layer direction list.
lay_purp_list (List[Tuple[str, str]]) – the primitive wire layer/purpose list.
box_arr_list (List[Union[BBox, BBoxArray]]) – bounding box of the wire(s) to connect to tracks.
tr_layer_id (int) – track layer ID.
tr_idx_list (List[TrackType]) – list of track indices.
width (int) – track width in number of tracks.
track_lower (Optional[int]) – if given, extend track(s) to this lower coordinate.
track_upper (Optional[int]) – if given, extend track(s) to this upper coordinate.
min_len_mode (MinLenMode) – the minimum length extension mode.
- Returns:
wire_arr – WireArrays representing the tracks created.
- Return type:
List[Optional[WireArray]]
- connect_to_tracks(wire_arr_list: Union[bag.layout.routing.base.WireArray, List[bag.layout.routing.base.WireArray]], track_id: bag.layout.routing.base.TrackID, *, wire_lower: Optional[int] = None, wire_upper: Optional[int] = None, track_lower: Optional[int] = None, track_upper: Optional[int] = None, min_len_mode: pybag.enum.MinLenMode = None, ret_wire_list: Optional[List[bag.layout.routing.base.WireArray]] = None, debug: bool = False) Optional[bag.layout.routing.base.WireArray] [source]
Connect all given WireArrays to the given track(s).
All given wires should be on adjacent layers of the track.
- Parameters:
wire_arr_list (Union[WireArray, List[WireArray]]) – list of WireArrays to connect to track.
track_id (TrackID) – TrackID that specifies the track(s) to connect the given wires to.
wire_lower (Optional[CoordType]) – if given, extend wire(s) to this lower coordinate.
wire_upper (Optional[CoordType]) – if given, extend wire(s) to this upper coordinate.
track_lower (Optional[CoordType]) – if given, extend track(s) to this lower coordinate.
track_upper (Optional[CoordType]) – if given, extend track(s) to this upper coordinate.
min_len_mode (MinLenMode) – the minimum length extension mode.
ret_wire_list (Optional[List[WireArray]]) – If not none, extended wires that are created will be appended to this list.
debug (bool) – True to print debug messages.
- Returns:
wire_arr – WireArray representing the tracks created.
- Return type:
Optional[WireArray]
- _connect_to_tracks_helper(warr_list: List[bag.layout.routing.base.WireArray], track_id: bag.layout.routing.base.TrackID, wire_lower: Optional[int], wire_upper: Optional[int], track_lower: int, track_upper: int, ret_wire_list: Optional[List[bag.layout.routing.base.WireArray]], idx: int, debug: bool) Tuple[Optional[int], Optional[int]] [source]
- connect_to_track_wires(wire_arr_list: Union[bag.layout.routing.base.WireArray, List[bag.layout.routing.base.WireArray]], track_wires: Union[bag.layout.routing.base.WireArray, List[bag.layout.routing.base.WireArray]], *, min_len_mode: Optional[pybag.enum.MinLenMode] = None, ret_wire_list: Optional[List[bag.layout.routing.base.WireArray]] = None, debug: bool = False) Union[Optional[bag.layout.routing.base.WireArray], List[Optional[bag.layout.routing.base.WireArray]]] [source]
Connect all given WireArrays to the given WireArrays on adjacent layer.
- Parameters:
wire_arr_list (Union[WireArray, List[WireArray]]) – list of WireArrays to connect to track.
track_wires (Union[WireArray, List[WireArray]]) – list of tracks as WireArrays.
min_len_mode (MinLenMode) – the minimum length extension mode.
ret_wire_list (Optional[List[WireArray]]) – If not none, extended wires that are created will be appended to this list.
debug (bool) – True to print debug messages.
- Returns:
wire_arr – WireArrays representing the tracks created. None if nothing to do.
- Return type:
- connect_differential_tracks(pwarr_list: Union[bag.layout.routing.base.WireArray, List[bag.layout.routing.base.WireArray]], nwarr_list: Union[bag.layout.routing.base.WireArray, List[bag.layout.routing.base.WireArray]], tr_layer_id: int, ptr_idx: bag.typing.TrackType, ntr_idx: bag.typing.TrackType, *, width: int = 1, track_lower: Optional[int] = None, track_upper: Optional[int] = None) Tuple[Optional[bag.layout.routing.base.WireArray], Optional[bag.layout.routing.base.WireArray]] [source]
Connect the given differential wires to two tracks symmetrically.
This method makes sure the connections are symmetric and have identical parasitics.
- Parameters:
pwarr_list (Union[WireArray, List[WireArray]]) – positive signal wires to connect.
nwarr_list (Union[WireArray, List[WireArray]]) – negative signal wires to connect.
tr_layer_id (int) – track layer ID.
ptr_idx (TrackType) – positive track index.
ntr_idx (TrackType) – negative track index.
width (int) – track width in number of tracks.
track_lower (Optional[int]) – if given, extend track(s) to this lower coordinate.
track_upper (Optional[int]) – if given, extend track(s) to this upper coordinate.
- Returns:
p_track (Optional[WireArray]) – the positive track.
n_track (Optional[WireArray]) – the negative track.
- connect_differential_wires(pin_warrs: Union[bag.layout.routing.base.WireArray, List[bag.layout.routing.base.WireArray]], nin_warrs: Union[bag.layout.routing.base.WireArray, List[bag.layout.routing.base.WireArray]], pout_warr: bag.layout.routing.base.WireArray, nout_warr: bag.layout.routing.base.WireArray, *, track_lower: Optional[int] = None, track_upper: Optional[int] = None) Tuple[Optional[bag.layout.routing.base.WireArray], Optional[bag.layout.routing.base.WireArray]] [source]
Connect the given differential wires to two WireArrays symmetrically.
This method makes sure the connections are symmetric and have identical parasitics.
- Parameters:
pin_warrs (Union[WireArray, List[WireArray]]) – positive signal wires to connect.
nin_warrs (Union[WireArray, List[WireArray]]) – negative signal wires to connect.
pout_warr (WireArray) – positive track wires.
nout_warr (WireArray) – negative track wires.
track_lower (Optional[int]) – if given, extend track(s) to this lower coordinate.
track_upper (Optional[int]) – if given, extend track(s) to this upper coordinate.
- Returns:
p_track (Optional[WireArray]) – the positive track.
n_track (Optional[WireArray]) – the negative track.
- connect_matching_tracks(warr_list_list: List[Union[bag.layout.routing.base.WireArray, List[bag.layout.routing.base.WireArray]]], tr_layer_id: int, tr_idx_list: List[bag.typing.TrackType], *, width: int = 1, track_lower: Optional[int] = None, track_upper: Optional[int] = None, min_len_mode: pybag.enum.MinLenMode = MinLenMode.NONE) List[Optional[bag.layout.routing.base.WireArray]] [source]
Connect wires to tracks with optimal matching.
This method connects the wires to tracks in a way that minimizes the parasitic mismatches.
- Parameters:
warr_list_list (List[Union[WireArray, List[WireArray]]]) – list of signal wires to connect.
tr_layer_id (int) – track layer ID.
tr_idx_list (List[TrackType]) – list of track indices.
width (int) – track width in number of tracks.
track_lower (Optional[int]) – if given, extend track(s) to this lower coordinate.
track_upper (Optional[int]) – if given, extend track(s) to this upper coordinate.
min_len_mode (MinLenMode) – the minimum length extension mode.
- Returns:
track_list – list of created tracks.
- Return type:
List[WireArray]
- draw_vias_on_intersections(bot_warr_list: Union[bag.layout.routing.base.WireArray, List[bag.layout.routing.base.WireArray]], top_warr_list: Union[bag.layout.routing.base.WireArray, List[bag.layout.routing.base.WireArray]]) None [source]
Draw vias on all intersections of the two given wire groups.
- mark_bbox_used(layer_id: int, bbox: pybag.core.BBox) None [source]
Marks the given bounding-box region as used in this Template.
- do_max_space_fill(layer_id: int, bound_box: Optional[pybag.core.BBox] = None, fill_boundary: bool = True) None [source]
Draw density fill on the given layer.
- do_device_fill(fill_cls: Type[TemplateBase], **kwargs: Any) None [source]
Fill empty region with device fills.
- do_power_fill(layer_id: int, tr_manager: bag.layout.routing.base.TrackManager, vdd_warrs: Optional[Union[bag.layout.routing.base.WireArray, List[bag.layout.routing.base.WireArray]]] = None, vss_warrs: Optional[Union[bag.layout.routing.base.WireArray, List[bag.layout.routing.base.WireArray]]] = None, bound_box: Optional[pybag.core.BBox] = None, x_margin: int = 0, y_margin: int = 0, sup_type: str = 'both', flip: bool = False, uniform_grid: bool = False) Tuple[List[bag.layout.routing.base.WireArray], List[bag.layout.routing.base.WireArray]] [source]
Draw power fill on the given layer. Wrapper around do_multi_power_fill method that only returns the VDD and VSS wires.
- Parameters:
layer_id (int) – the layer ID on which to draw power fill.
tr_manager (TrackManager) – the TrackManager object.
sup_list (List[Union[WireArray, List[WireArray]]]) – a list of supply wires to draw power fill for.
bound_box (Optional[BBox]) – bound box over which to draw the power fill
x_margin (int) – keepout margin on the x-axis. Fill is centered within margin.
y_margin (int) – keepout margin on the y-axis. Fill is centered within margin.
uniform_grid (bool) – draw power fill on a common grid instead of dense packing.
flip (bool) – true to reverse order of power fill. Default (False) is {VDD, VSS}.
- Returns:
Tuple of VDD and VSS wires. If only one supply was specified, the other will be an empty list.
- Return type:
- do_multi_power_fill(layer_id: int, tr_manager: bag.layout.routing.base.TrackManager, sup_list: List[Union[bag.layout.routing.base.WireArray, List[bag.layout.routing.base.WireArray]]], bound_box: Optional[pybag.core.BBox] = None, x_margin: int = 0, y_margin: int = 0, flip: bool = False, uniform_grid: bool = False) List[List[bag.layout.routing.base.WireArray]] [source]
Draw power fill on the given layer. Accepts as many different supply nets as provided.
- Parameters:
layer_id (int) – the layer ID on which to draw power fill.
tr_manager (TrackManager) – the TrackManager object.
sup_list (List[Union[WireArray, List[WireArray]]]) – a list of supply wires to draw power fill for.
bound_box (Optional[BBox]) – bound box over which to draw the power fill
x_margin (int) – keepout margin on the x-axis. Fill is centered within margin.
y_margin (int) – keepout margin on the y-axis. Fill is centered within margin.
uniform_grid (bool) – draw power fill on a common grid instead of dense packing.
flip (bool) – true to reverse order of power fill. Default is False.
- Returns:
List of the wire arrays for each supply in sup_list, given in the same order as sup_list.
- Return type:
List[List[WireArray]]
- get_lef_options(options: Dict[str, Any], config: Mapping[str, Any]) None [source]
Populate the LEF options dictionary.
- find_track_width(layer_id: int, width: int) int [source]
Find the track width corresponding to the physical width
- connect_via_stack(tr_manager: bag.layout.routing.base.TrackManager, warr: bag.layout.routing.base.WireArray, top_layer: int, w_type: str = 'sig', alignment_p: int = 0, alignment_o: int = 0, mlm_dict: Optional[Mapping[int, pybag.enum.MinLenMode]] = None, ret_warr_dict: Optional[Mapping[int, bag.layout.routing.base.WireArray]] = None, coord_list_p_override: Optional[Sequence[int]] = None, coord_list_o_override: Optional[Sequence[int]] = None, alternate_o: bool = False) bag.layout.routing.base.WireArray [source]
Helper method to draw via stack and connections upto top layer, assuming connections can be on grid. Should work regardless of direction of top layer and bot layer.
This method supports equally spaced WireArrays only. Needs modification for non uniformly spaced WireArrays.
- Parameters:
tr_manager (TrackManager) – the track manager for this layout generator
warr (WireArray) – The bot_layer wire array that has to via up
top_layer (int) – The top_layer upto which stacked via has to go
w_type (str) – The wire type, for querying widths from track manager
alignment_p (int) – alignment for wire arrays which are parallel to bot_layer warr If alignment == -1, will “left adjust” the wires (left is the lower index direction). If alignment == 0, will center the wires in the middle. If alignment == 1, will “right adjust” the wires.
alignment_o (int) – alignment for wire arrays which are orthogonal to bot_layer warr
mlm_dict (Optional[Mapping[int, MinLenMode]]) – Dictionary of MinLenMode for every metal layer. Uses MinLenMode.MIDDLE by default
ret_warr_dict (Optional[Mapping[int, WireArray]]) – If provided, this dictionary will contain all the WireArrays created during via stacking
coord_list_p_override (Optional[Sequence[int]]) – List of co-ordinates for WireArrays parallel to bot_layer wire, assumed to be equally spaced
coord_list_o_override (Optional[Sequence[int]]) – List of co-ordinates for WireArrays orthogonal to bot_layer wire, assumed to be equally spaced
alternate_o (bool) – If coord_o_list is computed (i.e. coord_o_list_override is not used) then every other track is skipped for via spacing. Using alternate_o, we can choose which set of tracks is used and which is skipped. This is useful to avoid line end spacing issues when two adjacent wires require via stacks.
- Returns:
top_warr – The top_layer warr after via stacking all the way up
- Return type:
- bag.layout.template._update_device_fill_area(lookup: pybag.core.RTree, ed: bag.util.immutable.Param, inst_box: pybag.core.BBox, inst_edges: bag.layout.data.TemplateEdgeInfo, sp_box: pybag.core.BBox, sp_edges: Optional[bag.layout.data.TemplateEdgeInfo]) None [source]
- bag.layout.template._fill_merge(sq_list: List[Tuple[pybag.core.BBox, Tuple[bag.util.immutable.Param, bag.util.immutable.Param, bag.util.immutable.Param, bag.util.immutable.Param]]], istart: int, merge_two: bool) Tuple[pybag.core.BBox, Tuple[bag.util.immutable.Param, bag.util.immutable.Param, bag.util.immutable.Param, bag.util.immutable.Param]] [source]