bag.layout.routing.base
This module provides basic routing classes.
Module Contents
Classes
A class that represents locations of track(s) on the routing grid. |
|
An array of wires on the routing grid. |
|
A layout port. |
|
A class that makes it easy to compute track locations. |
Attributes
- class bag.layout.routing.base.TrackID(layer_id: int, track_idx: bag.typing.TrackType, width: int = 1, num: int = 1, pitch: bag.typing.TrackType = 0, grid: Optional[bag.layout.routing.grid.RoutingGrid] = None)[source]
Bases:
pybag.core.PyTrackID
A class that represents locations of track(s) on the routing grid.
- Parameters:
layer_id (int) – the layer ID.
track_idx (TrackType) – the smallest middle track index in the array. Multiples of 0.5
width (int) – width of one track in number of tracks.
num (int) – number of tracks in this array.
pitch (TrackType) – pitch between adjacent tracks, in number of track pitches.
grid (Optional[RoutingGrid]) – the routing grid associated with this TrackID object.
- property base_index: bag.util.math.HalfInt[source]
the base index.
- Type:
- property pitch: bag.util.math.HalfInt[source]
the track pitch.
- Type:
- property grid: Optional[bag.layout.routing.grid.RoutingGrid][source]
the routing grid of this TrackID object.
- Type:
Optional[RoutingGrid]
- __iter__() Iterator[bag.util.math.HalfInt] [source]
Iterate over all middle track indices in this TrackID.
- copy_with(grid: bag.layout.routing.grid.RoutingGrid) TrackID [source]
- class bag.layout.routing.base.WireArray(track_id: TrackID, lower: int, upper: int)[source]
An array of wires on the routing grid.
- Parameters:
- classmethod list_to_warr(warr_list: Sequence[WireArray]) WireArray [source]
Convert a list of WireArrays to a single WireArray.
this method assumes all WireArrays have the same layer, width, and lower/upper coordinates. Overlapping WireArrays will be compacted.
- classmethod single_warr_iter(warr: Union[WireArray, Sequence[WireArray]]) Iterable[WireArray] [source]
Iterate through single wires in the given WireArray or WireArray list.
- classmethod wire_grp_iter(warr: Union[WireArray, Sequence[WireArray]]) Iterable[WireArray] [source]
Iterate through WireArrays in the given WireArray or WireArray list.
- class bag.layout.routing.base.Port(term_name: str, pin_dict: Dict[Union[int, str], Union[List[WireArray], List[pybag.core.BBox]]], label: str, hidden: bool)[source]
A layout port.
a port is a group of pins that represent the same net. The pins can be on different layers.
- Parameters:
True if this is a hidden port.
- Type:
- get_single_layer() Union[int, str] [source]
Returns the layer of this port if it only has a single layer.
- get_pins(layer: Union[int, str] = -1000) Union[List[WireArray], List[pybag.core.BBox]] [source]
Returns the pin geometries on the given layer.
- get_bounding_box(layer: Union[int, str] = -1000) pybag.core.BBox [source]
Calculate the overall bounding box of this port on the given layer.
- class bag.layout.routing.base.TrackManager(grid: bag.layout.routing.grid.RoutingGrid, tr_widths: WDictType, tr_spaces: SpDictType, **kwargs: Any)[source]
A class that makes it easy to compute track locations.
This class provides many helper methods for computing track locations and spacing when each track could have variable width. All methods in this class accepts a “track_type”, which is either a string in the track dictionary or an integer representing the track width.
- Parameters:
grid (RoutingGrid) – the RoutingGrid object.
tr_widths (WDictType) – dictionary from wire types to its width on each layer.
tr_spaces (SpDictType) – dictionary from wire types to its spaces on each layer.
**kwargs (Any) – additional options.
- property grid: bag.layout.routing.grid.RoutingGrid[source]
- property tr_widths: bag.util.immutable.ImmutableSortedDict[str, bag.util.immutable.ImmutableSortedDict[int, int]][source]
- property tr_spaces: bag.util.immutable.ImmutableSortedDict[Tuple[str, str], bag.util.immutable.ImmutableSortedDict[int, bag.typing.TrackType]][source]
- classmethod _get_space_from_tuple(layer_id: int, ntup: Tuple[str, str], sp_dict: Optional[SpDictType]) Optional[bag.typing.TrackType] [source]
- get_sep(layer_id: int, type_tuple: Tuple[Union[str, int], Union[str, int]], **kwargs: Any) bag.util.math.HalfInt [source]
Returns the track separation.
- Parameters:
- Returns:
tr_sp – the track spacing
- Return type:
TrackType
- get_next_track(layer_id: int, cur_idx: bag.typing.TrackType, cur_type: Union[str, int], next_type: Union[str, int], up: Union[bool, int] = True, **kwargs: Any) bag.util.math.HalfInt [source]
Compute the track location of a wire next to a given one.
- Parameters:
- Returns:
next_int – the next track index.
- Return type:
- get_num_wires_between(layer_id: int, bot_wire: str, bot_idx: bag.util.math.HalfInt, top_wire: str, top_idx: bag.util.math.HalfInt, fill_wire: str) int [source]
- place_wires(layer_id: int, type_list: Sequence[Union[str, int]], align_track: Optional[bag.util.math.HalfInt] = None, align_idx: int = 0, center_coord: Optional[int] = None, **kwargs: Any) Tuple[bag.util.math.HalfInt, List[bag.util.math.HalfInt]] [source]
Place the given wires next to each other.
- Parameters:
layer_id (int) – the layer of the tracks.
align_track (Optional[HalfInt]) – If not None, will make sure the the track at location align_idx has this value.
align_idx (Optional[int]) – the align wire index.
center_coord (Optional[int]) – If not None, will try to center the wires around this coordinate. align_track takes precedence over center_coord.
**kwargs (Any) – optional parameters for get_num_space_tracks() method of RoutingGrid.
- Returns:
num_tracks (HalfInt) – number of tracks used.
locations (List[HalfInt]) – the center track index of each wire.
- classmethod _get_align_delta(tot_ntr: bag.typing.TrackType, num_used: bag.typing.TrackType, alignment: int) bag.util.math.HalfInt [source]
- align_wires(layer_id: int, type_list: Sequence[Union[str, int]], tot_ntr: bag.typing.TrackType, alignment: int = 0, start_idx: bag.typing.TrackType = 0, **kwargs: Any) List[bag.util.math.HalfInt] [source]
Place the given wires in the given space with the specified alignment.
- Parameters:
layer_id (int) – the layer of the tracks.
tot_ntr (TrackType) – total available space in number of tracks.
alignment (int) – 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.
start_idx (TrackType) – the starting track index.
**kwargs (Any) – optional parameters for place_wires().
- Returns:
locations – the center track index of each wire.
- Return type:
List[HalfInt]
- get_next_track_obj(warr_tid_obj: Union[TrackID, WireArray], cur_type: Union[str, int], next_type: Union[str, int], count_rel_tracks: int = 1, **kwargs) TrackID [source]
Computes next TrackID relative the WireArray or TrackID object, given wire types
- Parameters:
warr_tid_obj (Union[TrackID, WireArray]) – the wire array or track id object used as the reference
cur_type (Union[str, int]) – the wire type of current reference warr/tid
next_type (Union[str, int]) – the wire type of the returned tid
count_rel_tracks (int) – the number of spacings to skip +1 means the immediate next track id -1 means immediate previous track id, +2 means the one after the next track id, etc. if |count_rel_tracks| > 1, the skipped distance is space(cur_type, next_type) + (|count_rel_tracks| - 1) * space(next_type, next_type)
- Returns:
track_id – the TrackID object of the next track id
- Return type:
- get_shield_tracks(layer_id: int, tidx_lo: bag.util.math.HalfInt, tidx_hi: bag.util.math.HalfInt, wtype_lo: Union[str, int], wtype_hi: Union[str, int]) List[TrackID] [source]
Fill the given space with shielding tracks
Try to fill with the widest metal allowed in the PDK Respect DRC spacing rules relative to lower and higher wires Currently this method just returns a bunch of width 1 wires.
- Parameters:
- Returns:
idx_list – list of TrackIDs
- Return type:
List[TrackID]
- spread_wires(layer_id: int, type_list: Sequence[Union[str, int]], lower: bag.util.math.HalfInt, upper: bag.util.math.HalfInt, sp_type: Tuple[str, str], alignment: int = 0, max_iter: int = 1000) List[bag.util.math.HalfInt] [source]
Spread out the given wires in the given space.
This method tries to spread out wires by increasing the space around the given wire/combination of wires.
- Parameters:
layer_id (int) – the layer of the tracks.
lower (HalfInt) – the lower bound track index, inclusive.
upper (HalfInt) – the upper bound track index, inclusive.
alignment (int) – 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.
max_iter (int) – maximum number of iterations.
- Returns:
locations – the center track index of each wire.
- Return type:
List[HalfInt]