b_asic.signal

B-ASIC Signal Module.

Contains the class for representing the connections between operations.

class b_asic.signal.Signal(source: OutputPort | Signal | Operation | None = None, destination: InputPort | Signal | Operation | None = None, bits: int | None = None, name: str = '')

Bases: AbstractGraphComponent

A connection between two ports.

Note

If a Signal is provided as source or destination, the connected port is used. Hence, if the argument signal is later changed, it will not affect the current Signal.

Parameters:
sourceOutputPort, Signal, or Operation, optional

OutputPort, Signal, or Operation to connect as source to the signal.

destinationInputPort, Signal, or Operation, optional

InputPort, Signal, or Operation to connect as destination to the signal.

bitsint, optional

The word length of the signal.

nameName, default: “”

The signal name.

property bits: int | None

Get the number of bits that this operation using this signal as an input should quantize received values to. None = unlimited.

dangling() bool

Return True if the signal is missing either a source or a destination.

property destination: InputPort | None

Return the destination InputPort of the signal.

property destination_operation: Operation | None

Return the destination Operation of the signal.

property is_constant: bool

Return True if the value of the signal (source) is constant.

property neighbors: Iterable[GraphComponent]

Return a list of the (up to) two operations connected to this signal.

remove_destination() None

Disconnect the destination InputPort of the signal.

remove_source() None

Disconnect the source OutputPort of the signal.

If the source port still is connected to this signal then also disconnect the source port.

set_destination(destination: InputPort | Signal | Operation) None

Connect to the entered destination InputPort.

Also, disconnect the previous destination InputPort of the signal and connect the entered destination port to the signal if it has not already been connected.

Parameters:
destinationInputPort, Signal, or Operation

InputPort, Signal, or Operation to connect as destination to the signal. If Signal, it will connect to the destination of the signal, so later on changing the destination of the argument Signal will not affect this Signal. If Operation, it must have a single input, otherwise a TypeError is raised.

set_source(source: OutputPort | Signal | Operation) None

Connect to the entered source OutputPort.

Also, disconnect the previous source OutputPort of the signal and connect the entered source port to the signal if it has not already been connected.

Parameters:
sourceOutputPort, Signal, or Operation

OutputPort, Signal, or Operation to connect as source to the signal. If Signal, it will connect to the source of the signal, so later on changing the source of the argument Signal will not affect this Signal. If Operation, it must have a single output, otherwise a TypeError is raised. That output is used to extract the OutputPort.

property source: OutputPort | None

Return the source OutputPort of the signal.

property source_operation: Operation | None

Return the source Operation of the signal.

classmethod type_name() TypeName

Get the type name of this graph component.