b_asic.special_operations

Inheritance diagram of b_asic.special_operations

B-ASIC Special Operations Module.

Contains operations with special purposes that may be treated differently from normal operations in an SFG.

class b_asic.special_operations.Compression(factor: int = 2, in0: SignalSourceProvider | None = None, name: str = '', *, phase: int = 0)

Bases: _RateChange

Reduce the sample rate by retaining every factor:th sample.

The output is y[n] = x[factor * n + phase].

Parameters:
factorint, default: 2

Positive integer compression factor.

in0SignalSourceProvider, optional

Input stream.

nameName, optional

Operation name.

phaseint, default: 0

Retained phase, in the range 0 <= phase < factor.

Notes

Simulate graphs containing this operation with Simulation. Use to_single_rate() before scheduling.

classmethod type_name() → TypeName

Get the type name of this graph component.

class b_asic.special_operations.Delay(in0: SignalSourceProvider | None = None, initial_value: int | float | complex | DTypeLike | APyFixed | APyCFixed | APyFloat | APyCFloat = 0, name: str = '')

Bases: AbstractOperation

Unit delay operation.

Represents a delay of one iteration. The initial value is zero unless otherwise specified.

Parameters:
in0SignalSourceProvider, optional

The node to be delayed.

initial_valueNumber, default: 0

Initial value of the delay.

nameName, default “”

Name.

current_output(index: int, delays: Mapping[ResultKey, int | float | complex | DTypeLike | APyFixed | APyCFixed | APyFloat | APyCFloat] | None = None, prefix: str = '') → int | float | complex | DTypeLike | APyFixed | APyCFixed | APyFloat | APyCFloat | None

Get the current output at the given index of this operation, if available.

The delays parameter will be used for lookup. The prefix parameter will be used as a prefix for the key string when looking for delays.

See also

current_outputs, evaluate_output, evaluate_outputs
evaluate(a, data_type, delays=None) → int | float | complex | DTypeLike | APyFixed | APyCFixed | APyFloat | APyCFloat

Evaluate the operation and generate a list of output values.

Parameters:
*inputs

List of input values.

data_typeDataType, optional

Data type to use for quantization during evaluation.

property initial_value: int | float | complex | DTypeLike | APyFixed | APyCFixed | APyFloat | APyCFloat

Get the initial value of this delay.

is_linear = True
classmethod type_name() → TypeName

Get the type name of this graph component.

class b_asic.special_operations.Expansion(factor: int = 2, in0: SignalSourceProvider | None = None, name: str = '', *, phase: int = 0)

Bases: _RateChange

Increase the sample rate by an integer factor using zero insertion.

The output is y[factor * n + phase] = x[n]; all other samples are zero. Filtering, when needed, is represented by separate operations.

Parameters:
factorint, default: 2

Positive integer expansion factor.

in0SignalSourceProvider, optional

Input stream.

nameName, optional

Operation name.

phaseint, default: 0

Nonzero phase, in the range 0 <= phase < factor.

Notes

Simulate graphs containing this operation with Simulation. Use to_single_rate() before scheduling.

classmethod type_name() → TypeName

Get the type name of this graph component.

class b_asic.special_operations.Input(name: str = '')

Bases: AbstractOperation

Input operation.

Represents an input port to an SFG. Its value will be updated on each iteration when simulating the SFG.

Parameters:
nameName, optional

Operation name.

evaluate(data_type=None) → int | float | complex | DTypeLike | APyFixed | APyCFixed | APyFloat | APyCFloat

Evaluate the operation and generate a list of output values.

Parameters:
*inputs

List of input values.

data_typeDataType, optional

Data type to use for quantization during evaluation.

get_input_coordinates() → tuple[tuple[float, float], ...]

Return coordinates for inputs.

These maps to the polygons and are corresponding to a start time of 0 and height 1.

get_output_coordinates() → tuple[tuple[float, float], ...]

Return coordinates for outputs.

These maps to the polygons and are corresponding to a start time of 0 and height 1.

get_plot_coordinates() → tuple[tuple[tuple[float, float], ...], tuple[tuple[float, float], ...]]

Return coordinates for the latency and execution time polygons.

This returns a tuple containing coordinates for the two polygons outlining the latency and execution time of the operation. The polygons are corresponding to a start time of 0 and are of height 1.

is_constant = False
is_linear = True
property latency: int

Get the latency of the operation.

This is the longest time it takes from one of the input ports to one of the output ports.

classmethod type_name() → TypeName

Get the type name of this graph component.

property value: int | float | complex | DTypeLike | APyFixed | APyCFixed | APyFloat | APyCFloat

Get the current value of this input.

class b_asic.special_operations.MemoryRead(address: int = 0, memory_name: str = '', name: str = '', latency: int = 0)

Bases: Input

Read a value from a memory address.

Behaves as an Input with an address and an optional memory name. During simulation, values are supplied through the SFG input mechanism. The address and memory name identify the memory location symbolically.

Parameters:
addressint, default: 0

Read address.

memory_nameName, optional

Memory name. An empty name denotes the default memory.

nameName, optional

Operation name.

latencyint, default: 0

Cycles between presenting the read address and obtaining the value. The operation starts when the address is presented, and its value output has this latency offset.

property address: int

Get the read address.

property latency: int

Get the latency from the read address to the value output.

property memory_name: str

Get the name of the memory to read from.

classmethod type_name() → TypeName

Get the type name of this graph component.

class b_asic.special_operations.MemoryWrite(address: int = 0, in0: SignalSourceProvider | None = None, memory_name: str = '', name: str = '')

Bases: Output

Write a value to a memory address.

Behaves as an Output with an address and an optional memory name. During simulation, values are collected through the SFG output mechanism. The address and memory name identify the memory location symbolically.

Parameters:
addressint, default: 0

Write address.

in0SignalSourceProvider, optional

The signal to write.

memory_nameName, optional

Memory name. An empty name denotes the default memory.

nameName, optional

Operation name.

property address: int

Get the write address.

property memory_name: str

Get the name of the memory to write to.

classmethod type_name() → TypeName

Get the type name of this graph component.

class b_asic.special_operations.Output(in0: SignalSourceProvider | None = None, name: str = '')

Bases: AbstractOperation

Output operation.

Represents an output port to an SFG. The SFG will forward its input to the corresponding output signal destinations.

Parameters:
in0SignalSourceProvider, optional

The signal connected to the Output operation.

nameName, optional

Operation name.

evaluate(_, data_type) → None

Evaluate the operation and generate a list of output values.

Parameters:
*inputs

List of input values.

data_typeDataType, optional

Data type to use for quantization during evaluation.

get_input_coordinates() → tuple[tuple[float, float], ...]

Return coordinates for inputs.

These maps to the polygons and are corresponding to a start time of 0 and height 1.

get_output_coordinates() → tuple[tuple[float, float], ...]

Return coordinates for outputs.

These maps to the polygons and are corresponding to a start time of 0 and height 1.

get_plot_coordinates() → tuple[tuple[tuple[float, float], ...], tuple[tuple[float, float], ...]]

Return coordinates for the latency and execution time polygons.

This returns a tuple containing coordinates for the two polygons outlining the latency and execution time of the operation. The polygons are corresponding to a start time of 0 and are of height 1.

is_linear = True
property latency: int

Get the latency of the operation.

This is the longest time it takes from one of the input ports to one of the output ports.

classmethod type_name() → TypeName

Get the type name of this graph component.