b_asic.port

Inheritance diagram of b_asic.port

B-ASIC Port Module.

Contains classes for managing the ports of operations.

class b_asic.port.AbstractPort(operation: Operation, index: int, latency_offset: int | None = None)

Bases: Port

Generic abstract port base class.

Concrete ports should normally derive from this to get the default behavior.

property index: int

Return the index of the port.

property latency_offset: int | None

Get the latency_offset of the port.

property name

Return a name of the port.

This name consists of graph_id of the related operation and the port number.

property operation: Operation

Return the connected operation.

class b_asic.port.InputPort(operation: Operation, index: int)

Bases: AbstractPort

Input port.

May have one or zero signals connected to it.

add_signal(signal: Signal) None

Connect this port to the entered signal.

If the entered signal is not connected to this port then connect the entered signal to the port as well.

Parameters:
signalSignal

Signal to add.

clear() None

Remove all connected signals from the Port.

connect(src: SignalSourceProvider, name: str = '') Signal

Connect the provided signal source to this input port by creating a new signal.

Returns the new signal.

property connected_source: OutputPort | None

Get the output port that is currently connected to this input port.

Return None if it is unconnected.

delay(number: int) InputPort

Insert number amount of delay elements before the input port.

Returns the input port of the first delay element in the chain.

remove_signal(signal: Signal) None

Remove the signal that was entered from the Ports signals.

If the entered signal still is connected to this port then disconnect the entered signal from the port as well.

Parameters:
signalSignal

Signal to remove.

property signal_count: int

Return the number of connected signals.

property signals: Sequence[Signal]

Return all connected signals.

class b_asic.port.OutputPort(operation: Operation, index: int)

Bases: AbstractPort, SignalSourceProvider

Output port.

May have zero or more signals connected to it.

add_signal(signal: Signal) None

Connect this port to the entered signal.

If the entered signal is not connected to this port then connect the entered signal to the port as well.

Parameters:
signalSignal

Signal to add.

clear() None

Remove all connected signals from the Port.

remove_signal(signal: Signal) None

Remove the signal that was entered from the Ports signals.

If the entered signal still is connected to this port then disconnect the entered signal from the port as well.

Parameters:
signalSignal

Signal to remove.

property signal_count: int

Return the number of connected signals.

property signals: Sequence[Signal]

Return all connected signals.

property source: OutputPort

Get the main source port provided by this object.

class b_asic.port.Port

Bases: ABC

Port interface.

Ports serve as connection points for connecting signals between operations. They also store information about the latency of the corresponding calculations of the operation.

Aside from connected signals, each port also provides a reference to the parent operation that “owns” it as well as the operation’s port index at which the port resides.

abstract add_signal(signal: Signal) None

Connect this port to the entered signal.

If the entered signal is not connected to this port then connect the entered signal to the port as well.

Parameters:
signalSignal

Signal to add.

abstract clear() None

Remove all connected signals from the Port.

abstract property index: int

Return the index of the port.

abstract property latency_offset: int | None

Get the latency_offset of the port.

abstract property name: str

Return a name of the port.

This name consists of graph_id of the related operation and the port number.

abstract property operation: Operation

Return the connected operation.

abstract remove_signal(signal: Signal) None

Remove the signal that was entered from the Ports signals.

If the entered signal still is connected to this port then disconnect the entered signal from the port as well.

Parameters:
signalSignal

Signal to remove.

abstract property signal_count: int

Return the number of connected signals.

abstract property signals: Sequence[Signal]

Return all connected signals.

class b_asic.port.SignalSourceProvider

Bases: ABC

Signal source provider interface.

Signal source providers give access to a single output port that can be used to connect signals from.

abstract property source: OutputPort

Get the main source port provided by this object.