port¶
Port class hierarchy for FPGA fabric.
This module contains the port class hierarchy for representing different types of ports in the FPGA fabric:
Port: Base class for all port types
TilePort: Port on a tile with side and termination information
BelPort: Port on a BEL (Basic Element of Logic)
SlicedPort: A sliced portion of another port
SharedPort: A port shared between multiple BELs
ConfigPort: A configuration port with features
Attributes¶
Classes¶
A port on a BEL (Basic Element of Logic). |
|
A configuration port with features. |
|
Base class for all port types. |
|
A port shared between multiple BELs. |
|
A port that represents a slice of another port. |
|
TilePort represents a port on a tile with a side and termination status. |
Module Contents¶
BelPort¶
- class BelPort(name, io_direction, width, prefix='', external=False, control=False, is_clock=False, is_global=False, net='')[source]¶
Bases:
PortA port on a BEL (Basic Element of Logic).
- Parameters:
name (str) – The name of the port.
io_direction (IO) – The I/O direction (INPUT, OUTPUT, INOUT).
width (int) – The bit width of the port.
prefix (str) – Prefix added to the port name. Defaults to “”.
external (bool) – Whether the port is exposed externally. Defaults to False.
control (bool) – Whether the port is a control signal. Defaults to False.
is_clock (bool) – Whether the port carries a clock. Defaults to False.
is_global (bool) – Whether the port is driven by a fabric-wide signal. Defaults to False.
net (str) – The net the port belongs to. Defaults to “”, the global net.
Properties¶
Methods¶
ConfigPort¶
- class ConfigPort(name, io_direction, width, features=None, feature_type=FeatureType.ENUMERATE)[source]¶
Bases:
PortA configuration port with features.
- Parameters:
name (str) – The name of the port.
io_direction (IO) – The I/O direction (INPUT, OUTPUT, INOUT).
width (int) – The bit width of the port.
features (list[FeatureValue] | None) – List of features associated with this port. Defaults to None, which resolves to an empty list.
feature_type (FeatureType) – The type of feature encoding. Defaults to FeatureType.ENUMERATE.
Properties¶
- property feature_type: FeatureType[source]¶
The type of feature encoding.
- property features: list[FeatureValue][source]¶
The list of features associated with this port.
Methods¶
Port¶
- class Port(name, io_direction, width, is_clock=False, is_global=False, net='')[source]¶
Base class for all port types.
- Parameters:
name (str) – The name of the port.
io_direction (IO) – The I/O direction (INPUT, OUTPUT, INOUT).
width (int) – The bit width of the port.
is_clock (bool) – Whether the port carries a clock. Defaults to False.
is_global (bool) – Whether the port is driven by a fabric-wide signal, such as the global user clock, rather than a locally generated one. Defaults to False.
net (str) – The net the port belongs to. Defaults to “”, the global net.
- Raises:
ValueError – If the width is not greater than 0.
TypeError – If io_direction is not an instance of IO, if name is not a string, or if is_clock or is_global is not a bool.
Properties¶
Methods¶
SlicedPort¶
- class SlicedPort(original_port, high, low)[source]¶
Bases:
PortA port that represents a slice of another port.
The range is written
high downto low, following VHDL: both endpoints are inclusive 0-based indices into the original port’s own expansion, andhighselects the most significant bit.expand()still lists bits least significant first, matchingPort.expand().- Parameters:
- Raises:
ValueError – If
lowis negative, ifhighis belowlow, or ifhighfalls outside the original port’s width.
Properties¶
Methods¶
TilePort¶
- class TilePort(name, io_direction, width, side_of_tile, term=False, tile=None, wire_direction=None, source_name='', x_offset=0, y_offset=0, destination_name='', wire_count=1)[source]¶
Bases:
PortTilePort represents a port on a tile with a side and termination status.
It is an immutable and comparable class. When sorting a list of TilePort instances, the order is determined first by the side of the tile in order of [north, east, south, west] then by the IO type in the order of [output, input, inout].
- Parameters:
name (str) – The name of the port.
io_direction (IO) – The I/O direction (INPUT, OUTPUT, INOUT).
width (int) – The bit width of the port.
side_of_tile (Side) – The side of the tile where the port is located.
term (bool) – Indicates if the port is a termination port. Defaults to False.
tile (Tile | None) – The tile this port belongs to. Set once at construction and read-only thereafter. Defaults to None, leaving the port unattached.
wire_direction (Direction | None) – The wire direction (for backward compatibility with legacy Port). Defaults to None, which resolves to Direction.JUMP.
source_name (str) – The source name of the wire connection. Defaults to “”.
x_offset (int) – The X-offset for wire routing. Defaults to 0.
y_offset (int) – The Y-offset for wire routing. Defaults to 0.
destination_name (str) – The destination name of the wire connection. Defaults to “”.
wire_count (int) – The number of wires. Defaults to 1.
Properties¶
Methods¶
- expand_port_info(mode='SwitchMatrix') tuple[list[str], list[str]][source]¶
Expand the port information to the individual bit signal.
If ‘Indexed’ is in the mode, then brackets are added to the signal name.
- Parameters:
mode (str, optional) – Mode for expansion. Defaults to “SwitchMatrix”. Possible modes are ‘all’, ‘allIndexed’, ‘Top’, ‘TopIndexed’, ‘AutoTop’, ‘AutoTopIndexed’, ‘SwitchMatrix’, ‘SwitchMatrixIndexed’, ‘AutoSwitchMatrix’, ‘AutoSwitchMatrixIndexed’
- Returns:
A tuple of two lists. The first list contains the source names of the ports and the second list contains the destination names of the ports.
- expand_port_info_by_name(indexed=False, prefix='', escape=False) list[str][source]¶
Expand port information to individual wire names.
Generates a list of individual wire names for this port, accounting for wire count and offset calculations. For termination ports (NULL), the wire count is multiplied by the Manhattan distance.
- Parameters:
indexed (bool, optional) – If True, wire names use bracket notation (e.g.,
port[0]). If False, wire names use simple concatenation (e.g.,port0). Defaults to False.prefix (str, optional) – A prefix to prepend to the port name, by default “”.
escape (bool, optional) – If True, escape special characters in the port names (e.g., for regex), by default False.
- Returns:
List of individual wire names for this port.
- expand_port_info_by_name_top(indexed=False, prefix='', escape=False) list[str][source]¶
Expand port information for top-level connections.
Similar to expand_port_info_by_name but specifically for top-level tile connections. The start index is calculated differently to handle the top slice of wires for routing fabric connections.
- Parameters:
indexed (bool, optional) – If True, wire names use bracket notation (e.g.,
port[0]). If False, wire names use simple concatenation (e.g.,port0). Defaults to False.prefix (str, optional) – A prefix to prepend to the port name, by default “”.
escape (bool, optional) – If True, escape special characters in the port names (e.g., for regex), by default False.
- Returns:
List of individual wire names for top-level connections.