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:
_RealValuedOperationAbsolute value operation.
Gives the absolute value of its input.
\[y = |x|\]- Parameters:
- in0
SignalSourceProvider, optional The signal to compute the absolute value of.
- name
Name, 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.
- in0
- 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:
AbstractOperationTwo-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, in1
SignalSourceProvider, optional The two signals to add or subtract.
- name
Name, 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
- 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_type
DataType, optional Data type to use for quantization during evaluation.
- is_linear = True¶
- 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:
AbstractOperationBinary 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, in1
SignalSourceProvider, optional The two signals to add.
- name
Name, 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.
- in0, in1
See also
- 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_type
DataType, optional Data type to use for quantization during evaluation.
- is_linear = True¶
- 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:
AbstractOperationTwo-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, in1
SignalSourceProvider, optional The two signals to compare.
- name
Name, 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).
- in0, in1
- 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_type
DataType, optional Data type to use for quantization during evaluation.
- 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:
AbstractOperationComplex conjugate operation.
Gives the complex conjugate of its input.
\[y = x^*\]- Parameters:
- in0
SignalSourceProvider, optional The signal to compute the complex conjugate of.
- name
Name, 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).
- in0
- class b_asic.core_operations.Constant(value: int | float | complex | DTypeLike | APyFixed | APyCFixed | APyFloat | APyCFloat = 0, name: str = '')¶
Bases:
AbstractOperationConstant 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.
- name
Name, 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_type
DataType, 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.
See also
- 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.
See also
- 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¶
- 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:
AbstractOperationConstant 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.
- in0
SignalSourceProvider, optional The signal to multiply.
- name
Name, 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
- 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_type
DataType, optional Data type to use for quantization during evaluation.
- is_linear = True¶
- 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:
_RealValuedOperationBinary division operation.
Gives the result of dividing the first input by the second one.
\[y = \frac{x_0}{x_1}\]- Parameters:
- in0, in1
SignalSourceProvider, optional The two signals to divide.
- name
Name, 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.
- in0, in1
See also
- 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:
AbstractOperationImaginary multiplication operation.
Gives the result of multiplying its input by the imaginary unit.
\[y = x_0 \times j\]- Parameters:
- in0
SignalSourceProvider, optional The signal to multiply with the imaginary unit.
- name
Name, 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).
- in0
- 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_type
DataType, optional Data type to use for quantization during evaluation.
- is_linear = True¶
- 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:
AbstractOperationArithmetic 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.
- in0
SignalSourceProvider, optional The signal to shift left.
- name
Name, 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
- 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_type
DataType, optional Data type to use for quantization during evaluation.
- is_linear = True¶
- 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:
AbstractOperationMultiply-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, in2
SignalSourceProvider, optional The three signals to determine the multiply-add operation of.
- name
Name, 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.
- in0, in1, in2
See also
- 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_type
DataType, optional Data type to use for quantization during evaluation.
- 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.
- 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- 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_type
DataType, optional Data type to use for quantization during evaluation.
- 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.
- 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:
AbstractOperationBinary max operation.
Gives the maximum value of two inputs.
\[y = \max\{x_0 , x_1\}\]Note
Only real-valued numbers are supported.
- Parameters:
- in0, in1
SignalSourceProvider, optional The two signals to determine the min of.
- name
Name, 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).
- in0, in1
See also
- 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_type
DataType, optional Data type to use for quantization during evaluation.
- is_swappable = True¶
- 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:
AbstractOperationBinary min operation.
Gives the minimum value of two inputs.
\[y = \min\{x_0 , x_1\}\]Note
Only real-valued numbers are supported.
- Parameters:
- in0, in1
SignalSourceProvider, optional The two signals to determine the min of.
- name
Name, 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).
- in0, in1
See also
- 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_type
DataType, optional Data type to use for quantization during evaluation.
- is_swappable = True¶
- 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:
AbstractOperationBinary multiplication operation.
Gives the result of multiplying two inputs.
\[y = x_0 \times x_1\]- Parameters:
- in0, in1
SignalSourceProvider, optional The two signals to multiply.
- name
Name, 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).
- in0, in1
See also
- 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_type
DataType, optional Data type to use for quantization during evaluation.
- is_swappable = True¶
- 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:
AbstractOperationNegation operation.
Gives the result of negating its input.
\[y = -x\]- Parameters:
- in0
SignalSourceProvider, optional The signal to negate.
- name
Name, 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).
- in0
- 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_type
DataType, optional Data type to use for quantization during evaluation.
- is_linear = True¶
- is_swappable = True¶
- 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:
_RealValuedOperationReciprocal operation.
Gives the reciprocal of its input.
\[y = \frac{1}{x}\]- Parameters:
- in0
SignalSourceProvider, optional The signal to compute the reciprocal of.
- name
Name, 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.
- in0
See also
- 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:
_RealValuedOperationReciprocal square root operation.
Gives the reciprocal of the square root of its input.
\[y = \frac{1}{\sqrt{x}}\]- Parameters:
- in0
SignalSourceProvider, optional The signal to compute the reciprocal square root of.
- name
Name, 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.
- in0
See also
- 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:
AbstractOperationArithmetic 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.
- in0
SignalSourceProvider, optional The signal to shift right.
- name
Name, 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_type
DataType, optional Data type to use for quantization during evaluation.
- is_linear = True¶
- 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:
AbstractOperationArithmetic 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.
- in0
SignalSourceProvider, optional The signal to shift.
- name
Name, 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
- 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_type
DataType, optional Data type to use for quantization during evaluation.
- is_linear = True¶
- 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:
_RealValuedOperationSquare root operation.
Gives the square root of its input.
\[y = \sqrt{x}\]- Parameters:
- in0
SignalSourceProvider, optional The signal to compute the square root of.
- name
Name, 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.
- in0
See also
- 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:
AbstractOperationBinary 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, in1
SignalSourceProvider, optional The two signals to subtract.
- name
Name, 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.
- in0, in1
See also
- 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_type
DataType, optional Data type to use for quantization during evaluation.
- is_linear = True¶