b_asic.core_operations

Inheritance diagram of b_asic.core_operations

B-ASIC Core Operations Module.

Contains some of the most commonly used mathematical operations.

class b_asic.core_operations.Absolute(in0: SignalSourceProvider | None = None, name: str = '', latency: int | None = None, latency_offsets: dict[str, int] | None = None, execution_time: int | None = None, real_valued: bool | None = None)

Bases: _RealValuedOperation

Absolute value operation.

Gives the absolute value of its input.

\[y = |x|\]
Parameters:
in0SignalSourceProvider, optional

The signal to compute the absolute value of.

nameName, optional

Operation name.

latencyint, optional

Operation latency (delay from input to output in time units).

latency_offsetsdict[str, int], optional

Used if input arrives later than when the operator starts, e.g., {"in0": 1} which corresponds to in0 arriving one time unit after the operator starts. If not provided and latency is provided, set to zero.

execution_timeint, optional

Operation execution time (time units before operator can be reused).

real_valuedbool or None, default: None

Use only real input parts and assume a real result.

evaluate(a, 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.

classmethod type_name() → TypeName

Get the type name of this graph component.

class b_asic.core_operations.AddSub(is_add: bool = True, in0: SignalSourceProvider | None = None, in1: SignalSourceProvider | None = None, name: str = '', latency: int | None = None, latency_offsets: dict[str, int] | None = None, execution_time: int | None = None, mul_j: bool = False, out0_scale: int = 0, in0_scale: int = 0, in1_scale: int = 0)

Bases: AbstractOperation

Two-input addition or subtraction operation.

Gives the result of adding or subtracting two inputs.

\[\begin{split}y = \begin{cases} (2^{-s_0} x_0 + 2^{-s_1} x_1) 2^{-s_y},& \text{is_add} = \text{True}\\ (2^{-s_0} x_0 - 2^{-s_1} x_1) 2^{-s_y},& \text{is_add} = \text{False} \end{cases}\end{split}\]

This is used to later map additions and subtractions to the same operator.

Parameters:
is_addbool, default: True

If True, the operation is an addition, if False, a subtraction.

in0, in1SignalSourceProvider, optional

The two signals to add or subtract.

nameName, optional

Operation name.

latencyint, optional

Operation latency (delay from input to output in time units).

latency_offsetsdict[str, int], optional

Used if inputs have different arrival times, e.g., {"in0": 0, "in1": 1} which corresponds to in1 arriving one time unit later than in0. If not provided and latency is provided, set to zero if not explicitly provided. So the previous example can be written as {"in1": 1} only.

execution_timeint, optional

Operation execution time (time units before operator can be reused).

mul_jbool, default: False

If True, in1 is multiplied by j before the addition/subtraction.

out0_scaleint, default: 0

Right-shift amount applied to the output result.

in0_scale, in1_scaleint, default: 0

Right-shift amounts applied independently to the inputs before arithmetic.

See also

Addition, Subtraction
evaluate(a, b, 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.

property in0_scale: int

Get the right-shift amount applied to the first input.

property in1_scale: int

Get the right-shift amount applied to the second input.

property is_add: bool

Get if operation is an addition.

is_linear = True
property is_swappable: bool

Return True if the inputs (and outputs) to the operation can be swapped.

Swapping require that the operation retains the same function, but it is allowed to modify values to do so.

property mul_j: bool

Get if in1 is multiplied by j before the addition/subtraction.

property out0_scale: int

Get the right-shift amount applied to the output.

classmethod type_name() → TypeName

Get the type name of this graph component.

class b_asic.core_operations.Addition(in0: SignalSourceProvider | None = None, in1: SignalSourceProvider | None = None, name: str = '', latency: int | None = None, latency_offsets: dict[str, int] | None = None, execution_time: int | None = None, mul_j: bool = False, out0_scale: int = 0, in0_scale: int = 0, in1_scale: int = 0)

Bases: AbstractOperation

Binary addition operation.

Gives the result of adding two inputs.

\[y = (2^{-s_0} x_0 + 2^{-s_1} x_1) 2^{-s_y}\]
Parameters:
in0, in1SignalSourceProvider, optional

The two signals to add.

nameName, optional

Operation name.

latencyint, optional

Operation latency (delay from input to output in time units).

latency_offsetsdict[str, int], optional

Used if inputs have different arrival times, e.g., {"in0": 0, "in1": 1} which corresponds to in1 arriving one time unit later than in0. If not provided and latency is provided, set to zero if not explicitly provided. So the previous example can be written as {"in1": 1} only.

execution_timeint, optional

Operation execution time (time units before operator can be reused).

mul_jbool, default: False

If True, in1 is multiplied by j before the addition.

out0_scaleint, default: 0

Right-shift amount applied to the output result.

in0_scale, in1_scaleint, default: 0

Right-shift amounts applied independently to the inputs before addition.

See also

AddSub
evaluate(a, b, 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.

property in0_scale: int

Get the right-shift amount applied to the first input.

property in1_scale: int

Get the right-shift amount applied to the second input.

is_linear = True
property is_swappable: bool

Return True if the inputs (and outputs) to the operation can be swapped.

Swapping require that the operation retains the same function, but it is allowed to modify values to do so.

property mul_j: bool

Get if in1 is multiplied by j before the addition.

property out0_scale: int

Get the right-shift amount applied to the output.

classmethod type_name() → TypeName

Get the type name of this graph component.

class b_asic.core_operations.Comparator(in0: SignalSourceProvider | None = None, in1: SignalSourceProvider | None = None, name: str = '', latency: int | None = None, latency_offsets: dict[str, int] | None = None, execution_time: int | None = None)

Bases: AbstractOperation

Two-input compare-and-exchange operation.

Outputs the smaller input at output 0 and the larger input at output 1.

\[\begin{split}y_0 & = \min\{x_0 , x_1\}\\ y_1 & = \max\{x_0 , x_1\}\end{split}\]

Note

Only real-valued numbers are supported.

Parameters:
in0, in1SignalSourceProvider, optional

The two signals to compare.

nameName, optional

Operation name.

latencyint, optional

Operation latency (delay from input to output in time units).

latency_offsetsdict[str, int], optional

Used if inputs have different arrival times or if the inputs should arrive after the operator has started. For example, {"in0": 0, "in1": 1} which corresponds to in1 arriving one time unit later than in0 and one time unit later than the operator starts. If not provided and latency is provided, set to zero. Hence, the previous example can be written as {"in1": 1} only.

execution_timeint, optional

Operation execution time (time units before operator can be reused).

See also

Min, Max
evaluate(a, b, data_type=None) → tuple[int | float | complex | DTypeLike | APyFixed | APyCFixed | APyFloat | APyCFloat, 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.

classmethod type_name() → TypeName

Get the type name of this graph component.

class b_asic.core_operations.ComplexConjugate(in0: SignalSourceProvider | None = None, name: str = '', latency: int | None = None, latency_offsets: dict[str, int] | None = None, execution_time: int | None = None)

Bases: AbstractOperation

Complex conjugate operation.

Gives the complex conjugate of its input.

\[y = x^*\]
Parameters:
in0SignalSourceProvider, optional

The signal to compute the complex conjugate of.

nameName, optional

Operation name.

latencyint, optional

Operation latency (delay from input to output in time units).

latency_offsetsdict[str, int], optional

Used if input arrives later than when the operator starts, e.g., {"in0": 1} which corresponds to in0 arriving one time unit after the operator starts. If not provided and latency is provided, set to zero.

execution_timeint, optional

Operation execution time (time units before operator can be reused).

evaluate(a, 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.

classmethod type_name() → TypeName

Get the type name of this graph component.

class b_asic.core_operations.Constant(value: int | float | complex | DTypeLike | APyFixed | APyCFixed | APyFloat | APyCFloat = 0, name: str = '')

Bases: AbstractOperation

Constant value operation.

Gives a specified value that remains constant for every iteration.

\[y = \text{value}\]
Parameters:
valueNumber, default: 0

The constant value. APyTypes scalars preserve their format in finite wordlength simulation and become Python numbers in ordinary simulation. For other values, the fixed-point wordlength is inferred independently of the simulation data type.

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 = True
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 constant value of this operation.

class b_asic.core_operations.ConstantMultiplication(value: int | float | complex | DTypeLike | APyFixed | APyCFixed | APyFloat | APyCFloat = 0, in0: SignalSourceProvider | None = None, name: str = '', latency: int | None = None, latency_offsets: dict[str, int] | None = None, execution_time: int | None = None)

Bases: AbstractOperation

Constant multiplication operation.

Gives the result of multiplying its input by a specified value.

\[y = x_0 \times \text{value}\]
Parameters:
valueint

Value to multiply with.

in0SignalSourceProvider, optional

The signal to multiply.

nameName, optional

Operation name.

latencyint, optional

Operation latency (delay from input to output in time units).

latency_offsetsdict[str, int], optional

Used if input arrives later than when the operator starts, e.g., {"in0": 1} which corresponds to in0 arriving one time unit after the operator starts. If not provided and latency is provided, set to zero.

execution_timeint, optional

Operation execution time (time units before operator can be reused).

See also

Multiplication
evaluate(a, 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.

is_linear = True
classmethod type_name() → TypeName

Get the type name of this graph component.

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

Get the constant value of this operation.

class b_asic.core_operations.Division(in0: SignalSourceProvider | None = None, in1: SignalSourceProvider | None = None, name: str = '', latency: int | None = None, latency_offsets: dict[str, int] | None = None, execution_time: int | None = None, real_valued: bool | None = None)

Bases: _RealValuedOperation

Binary division operation.

Gives the result of dividing the first input by the second one.

\[y = \frac{x_0}{x_1}\]
Parameters:
in0, in1SignalSourceProvider, optional

The two signals to divide.

nameName, optional

Operation name.

latencyint, optional

Operation latency (delay from input to output in time units).

latency_offsetsdict[str, int], optional

Used if inputs have different arrival times or if the inputs should arrive after the operator has started. For example, {"in0": 0, "in1": 1} which corresponds to in1 arriving one time unit later than in0 and one time unit later than the operator starts. If not provided and latency is provided, set to zero. Hence, the previous example can be written as {"in1": 1} only.

execution_timeint, optional

Operation execution time (time units before operator can be reused).

real_valuedbool or None, default: None

Use only real input parts and assume a real result.

See also

Reciprocal
evaluate(a, b, 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.

property is_linear: bool

Return True if the operation is linear.

classmethod type_name() → TypeName

Get the type name of this graph component.

class b_asic.core_operations.ImaginaryMultiplication(in0: SignalSourceProvider | None = None, name: str = '', latency: int | None = None, latency_offsets: dict[str, int] | None = None, execution_time: int | None = None)

Bases: AbstractOperation

Imaginary multiplication operation.

Gives the result of multiplying its input by the imaginary unit.

\[y = x_0 \times j\]
Parameters:
in0SignalSourceProvider, optional

The signal to multiply with the imaginary unit.

nameName, optional

Operation name.

latencyint, optional

Operation latency (delay from input to output in time units).

latency_offsetsdict[str, int], optional

Used if input arrives later than when the operator starts, e.g., {"in0": 1} which corresponds to in0 arriving one time unit after the operator starts. If not provided and latency is provided, set to zero.

execution_timeint, optional

Operation execution time (time units before operator can be reused).

evaluate(a, 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.

is_linear = True
classmethod type_name() → TypeName

Get the type name of this graph component.

class b_asic.core_operations.LeftShift(value: int = 0, in0: SignalSourceProvider | None = None, name: str = '', latency: int | None = None, latency_offsets: dict[str, int] | None = None, execution_time: int | None = None)

Bases: AbstractOperation

Arithmetic left-shift operation.

Shifts the input to the left assuming a fixed-point representation, so a multiplication by a power of two.

\[y = x \ll \text{value} = 2^{\text{value}}x \text{ where value} \geq 0\]
Parameters:
valueint

Number of bits to shift left.

in0SignalSourceProvider, optional

The signal to shift left.

nameName, optional

Operation name.

latencyint, optional

Operation latency (delay from input to output in time units).

latency_offsetsdict[str, int], optional

Used if input arrives later than when the operator starts, e.g., {"in0": 1} which corresponds to in0 arriving one time unit after the operator starts. If not provided and latency is provided, set to zero.

execution_timeint, optional

Operation execution time (time units before operator can be reused).

See also

RightShift
Shift
evaluate(a, 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.

is_linear = True
classmethod type_name() → TypeName

Get the type name of this graph component.

property value: int

Get the constant value of this operation.

class b_asic.core_operations.MAD(in0: SignalSourceProvider | None = None, in1: SignalSourceProvider | None = None, in2: SignalSourceProvider | None = None, name: str = '', latency: int | None = None, latency_offsets: dict[str, int] | None = None, execution_time: int | None = None, do_add: bool = True)

Bases: AbstractOperation

Multiply-add operation.

Gives the result of multiplying the first input by the second input and then adding the third input.

\[y = x_0 \times x_1 + x_2\]
Parameters:
in0, in1, in2SignalSourceProvider, optional

The three signals to determine the multiply-add operation of.

nameName, optional

Operation name.

latencyint, optional

Operation latency (delay from input to output in time units).

latency_offsetsdict[str, int], optional

Used if inputs have different arrival times or if the inputs should arrive after the operator has started. For example, {"in0": 0, "in1": 0, "in2": 2} which corresponds to in2, i.e., the term to be added, arriving two time units later than in0 and in1. If not provided and latency is provided, set to zero. Hence, the previous example can be written as {"in2": 2} only.

execution_timeint, optional

Operation execution time (time units before operator can be reused).

do_addbool, default: True

Whether to add in2 to the product of in0 and in1. If False, in2 is ignored.

property do_add: bool

Get whether the input to in2 is used when computing.

evaluate(a, b, c, 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.

property is_linear: bool

Return True if the operation is linear.

is_swappable = True
swap_io(force: bool = False) → None

Swap inputs (and outputs) of operation.

Parameters:
forcebool, optional

If True, force the swapping even if is_swappable() is False.

Errors if :meth:`is_swappable` is False.
classmethod type_name() → TypeName

Get the type name of this graph component.

class b_asic.core_operations.MADS(is_add: bool | None = True, in0: SignalSourceProvider | None = None, in1: SignalSourceProvider | None = None, in2: SignalSourceProvider | None = None, name: str = '', latency: int | None = None, latency_offsets: dict[str, int] | None = None, execution_time: int | None = None, do_addsub: bool = True)

Bases: AbstractOperation

property do_addsub: bool

Get whether the input to in0 is used when computing.

evaluate(a, b, c, 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.

property is_add: bool

Get whether to add or subtract with the product.

property is_linear: bool

Return True if the operation is linear.

is_swappable = True
swap_io(force: bool = False) → None

Swap inputs (and outputs) of operation.

Parameters:
forcebool, optional

If True, force the swapping even if is_swappable() is False.

Errors if :meth:`is_swappable` is False.
classmethod type_name() → TypeName

Get the type name of this graph component.

class b_asic.core_operations.Max(in0: SignalSourceProvider | None = None, in1: SignalSourceProvider | None = None, name: str = '', latency: int | None = None, latency_offsets: dict[str, int] | None = None, execution_time: int | None = None)

Bases: AbstractOperation

Binary max operation.

Gives the maximum value of two inputs.

\[y = \max\{x_0 , x_1\}\]

Note

Only real-valued numbers are supported.

Parameters:
in0, in1SignalSourceProvider, optional

The two signals to determine the min of.

nameName, optional

Operation name.

latencyint, optional

Operation latency (delay from input to output in time units).

latency_offsetsdict[str, int], optional

Used if inputs have different arrival times or if the inputs should arrive after the operator has started. For example, {"in0": 0, "in1": 1} which corresponds to in1 arriving one time unit later than in0 and one time unit later than the operator starts. If not provided and latency is provided, set to zero. Hence, the previous example can be written as {"in1": 1} only.

execution_timeint, optional

Operation execution time (time units before operator can be reused).

See also

Min
evaluate(a, b, 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.

is_swappable = True
classmethod type_name() → TypeName

Get the type name of this graph component.

class b_asic.core_operations.Min(in0: SignalSourceProvider | None = None, in1: SignalSourceProvider | None = None, name: str = '', latency: int | None = None, latency_offsets: dict[str, int] | None = None, execution_time: int | None = None)

Bases: AbstractOperation

Binary min operation.

Gives the minimum value of two inputs.

\[y = \min\{x_0 , x_1\}\]

Note

Only real-valued numbers are supported.

Parameters:
in0, in1SignalSourceProvider, optional

The two signals to determine the min of.

nameName, optional

Operation name.

latencyint, optional

Operation latency (delay from input to output in time units).

latency_offsetsdict[str, int], optional

Used if inputs have different arrival times or if the inputs should arrive after the operator has started. For example, {"in0": 0, "in1": 1} which corresponds to in1 arriving one time unit later than in0 and one time unit later than the operator starts. If not provided and latency is provided, set to zero. Hence, the previous example can be written as {"in1": 1} only.

execution_timeint, optional

Operation execution time (time units before operator can be reused).

See also

Max
evaluate(a, b, 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.

is_swappable = True
classmethod type_name() → TypeName

Get the type name of this graph component.

class b_asic.core_operations.Multiplication(in0: SignalSourceProvider | None = None, in1: SignalSourceProvider | None = None, name: str = '', latency: int | None = None, latency_offsets: dict[str, int] | None = None, execution_time: int | None = None)

Bases: AbstractOperation

Binary multiplication operation.

Gives the result of multiplying two inputs.

\[y = x_0 \times x_1\]
Parameters:
in0, in1SignalSourceProvider, optional

The two signals to multiply.

nameName, optional

Operation name.

latencyint, optional

Operation latency (delay from input to output in time units).

latency_offsetsdict[str, int], optional

Used if inputs have different arrival times or if the inputs should arrive after the operator has started. For example, {"in0": 0, "in1": 1} which corresponds to in1 arriving one time unit later than in0 and one time unit later than the operator starts. If not provided and latency is provided, set to zero. Hence, the previous example can be written as {"in1": 1} only.

execution_timeint, optional

Operation execution time (time units before operator can be reused).

evaluate(a, b, 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.

property is_linear: bool

Return True if the operation is linear.

is_swappable = True
classmethod type_name() → TypeName

Get the type name of this graph component.

class b_asic.core_operations.Negation(in0: SignalSourceProvider | None = None, name: str = '', latency: int | None = None, latency_offsets: dict[str, int] | None = None, execution_time: int | None = None)

Bases: AbstractOperation

Negation operation.

Gives the result of negating its input.

\[y = -x\]
Parameters:
in0SignalSourceProvider, optional

The signal to negate.

nameName, optional

Operation name.

latencyint, optional

Operation latency (delay from input to output in time units).

latency_offsetsdict[str, int], optional

Used if input arrives later than when the operator starts, e.g., {"in0": 1} which corresponds to in0 arriving one time unit after the operator starts. If not provided and latency is provided, set to zero.

execution_timeint, optional

Operation execution time (time units before operator can be reused).

evaluate(a, 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.

is_linear = True
is_swappable = True
classmethod type_name() → TypeName

Get the type name of this graph component.

class b_asic.core_operations.Reciprocal(in0: SignalSourceProvider | None = None, name: str = '', latency: int | None = None, latency_offsets: dict[str, int] | None = None, execution_time: int | None = None, real_valued: bool | None = None)

Bases: _RealValuedOperation

Reciprocal operation.

Gives the reciprocal of its input.

\[y = \frac{1}{x}\]
Parameters:
in0SignalSourceProvider, optional

The signal to compute the reciprocal of.

nameName, optional

Operation name.

latencyint, optional

Operation latency (delay from input to output in time units).

latency_offsetsdict[str, int], optional

Used if input arrives later than when the operator starts, e.g., {"in0": 1} which corresponds to in0 arriving one time unit after the operator starts. If not provided and latency is provided, set to zero.

execution_timeint, optional

Operation execution time (time units before operator can be reused).

real_valuedbool or None, default: None

Use only real input parts and assume a real result.

See also

Division
evaluate(a, 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.

classmethod type_name() → TypeName

Get the type name of this graph component.

class b_asic.core_operations.ReciprocalSquareRoot(in0: SignalSourceProvider | None = None, name: str = '', latency: int | None = None, latency_offsets: dict[str, int] | None = None, execution_time: int | None = None, real_valued: bool | None = None)

Bases: _RealValuedOperation

Reciprocal square root operation.

Gives the reciprocal of the square root of its input.

\[y = \frac{1}{\sqrt{x}}\]
Parameters:
in0SignalSourceProvider, optional

The signal to compute the reciprocal square root of.

nameName, optional

Operation name.

latencyint, optional

Operation latency (delay from input to output in time units).

latency_offsetsdict[str, int], optional

Used if input arrives later than when the operator starts, e.g., {"in0": 1} which corresponds to in0 arriving one time unit after the operator starts. If not provided and latency is provided, set to zero.

execution_timeint, optional

Operation execution time (time units before operator can be reused).

real_valuedbool or None, default: None

Whether to use only the real part of a complex input. If False or None, use the full complex value. Real inputs are evaluated directly. When True, the real input part must be nonnegative.

evaluate(a, 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.

classmethod type_name() → TypeName

Get the type name of this graph component.

class b_asic.core_operations.RightShift(value: int = 0, in0: SignalSourceProvider | None = None, name: str = '', latency: int | None = None, latency_offsets: dict[str, int] | None = None, execution_time: int | None = None)

Bases: AbstractOperation

Arithmetic right-shift operation.

Shifts the input to the right assuming a fixed-point representation, so a multiplication by a power of two.

\[y = x \gg \text{value} = 2^{-\text{value}}x \text{ where value} \geq 0\]
Parameters:
valueint

Number of bits to shift right.

in0SignalSourceProvider, optional

The signal to shift right.

nameName, optional

Operation name.

latencyint, optional

Operation latency (delay from input to output in time units).

latency_offsetsdict[str, int], optional

Used if input arrives later than when the operator starts, e.g., {"in0": 1} which corresponds to in0 arriving one time unit after the operator starts. If not provided and latency is provided, set to zero.

execution_timeint, optional

Operation execution time (time units before operator can be reused).

See also

LeftShift
Shift
evaluate(a, 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.

is_linear = True
classmethod type_name() → TypeName

Get the type name of this graph component.

property value: int

Get the constant value of this operation.

class b_asic.core_operations.Shift(value: int = 0, in0: SignalSourceProvider | None = None, name: str = '', latency: int | None = None, latency_offsets: dict[str, int] | None = None, execution_time: int | None = None)

Bases: AbstractOperation

Arithmetic shift operation.

Shifts the input to the left or right assuming a fixed-point representation, so a multiplication by a power of two. By definition a positive value is a shift to the left.

\[y = x \ll \text{value} = 2^{\text{value}}x\]
Parameters:
valueint

Number of bits to shift. Positive value shifts to the left.

in0SignalSourceProvider, optional

The signal to shift.

nameName, optional

Operation name.

latencyint, optional

Operation latency (delay from input to output in time units).

latency_offsetsdict[str, int], optional

Used if input arrives later than when the operator starts, e.g., {"in0": 1} which corresponds to in0 arriving one time unit after the operator starts. If not provided and latency is provided, set to zero.

execution_timeint, optional

Operation execution time (time units before operator can be reused).

evaluate(a, 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.

is_linear = True
classmethod type_name() → TypeName

Get the type name of this graph component.

property value: int

Get the constant value of this operation.

class b_asic.core_operations.SquareRoot(in0: SignalSourceProvider | None = None, name: str = '', latency: int | None = None, latency_offsets: dict[str, int] | None = None, execution_time: int | None = None, real_valued: bool | None = None)

Bases: _RealValuedOperation

Square root operation.

Gives the square root of its input.

\[y = \sqrt{x}\]
Parameters:
in0SignalSourceProvider, optional

The signal to compute the square root of.

nameName, optional

Operation name.

latencyint, optional

Operation latency (delay from input to output in time units).

latency_offsetsdict[str, int], optional

Used if input arrives later than when the operator starts, e.g., {"in0": 1} which corresponds to in0 arriving one time unit after the operator starts. If not provided and latency is provided, set to zero.

execution_timeint, optional

Operation execution time (time units before operator can be reused).

real_valuedbool or None, default: None

Use only the real input part, which must be nonnegative.

evaluate(a, 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.

classmethod type_name() → TypeName

Get the type name of this graph component.

class b_asic.core_operations.Subtraction(in0: SignalSourceProvider | None = None, in1: SignalSourceProvider | None = None, name: str = '', latency: int | None = None, latency_offsets: dict[str, int] | None = None, execution_time: int | None = None, mul_j: bool = False, out0_scale: int = 0, in0_scale: int = 0, in1_scale: int = 0)

Bases: AbstractOperation

Binary subtraction operation.

Gives the result of subtracting the second input from the first one.

\[y = (2^{-s_0} x_0 - 2^{-s_1} x_1) 2^{-s_y}\]
Parameters:
in0, in1SignalSourceProvider, optional

The two signals to subtract.

nameName, optional

Operation name.

latencyint, optional

Operation latency (delay from input to output in time units).

latency_offsetsdict[str, int], optional

Used if inputs have different arrival times, e.g., {"in0": 0, "in1": 1} which corresponds to in1 arriving one time unit later than in0. If not provided and latency is provided, set to zero if not explicitly provided. So the previous example can be written as {"in1": 1} only.

execution_timeint, optional

Operation execution time (time units before operator can be reused).

mul_jbool, default: False

If True, in1 is multiplied by j before the subtraction.

out0_scaleint, default: 0

Right-shift amount applied to the output result.

in0_scale, in1_scaleint, default: 0

Right-shift amounts applied independently to the inputs before subtraction.

See also

AddSub
evaluate(a, b, 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.

property in0_scale: int

Get the right-shift amount applied to the first input.

property in1_scale: int

Get the right-shift amount applied to the second input.

is_linear = True
property mul_j: bool

Get if in1 is multiplied by j before the subtraction.

property out0_scale: int

Get the right-shift amount applied to the output.

classmethod type_name() → TypeName

Get the type name of this graph component.