b_asic.data_type¶

B-ASIC Data Type Module.
- class b_asic.data_type.DataType(wl: tuple[int, int], input_wl: tuple[int, int] | None = None, output_wl: tuple[int, int] | None = None, num_repr: NumRepresentation = NumRepresentation.FIXED_POINT, is_signed: bool = True, is_complex: bool = False, quantization_mode: QuantizationMode = QuantizationMode.TRUNCATION, overflow_mode: OverflowMode = OverflowMode.WRAPPING)¶
Data type specification.
All arguments are keyword only.
The number of bits can be specified in two few different ways.
num_repr
int
(int, int)
(1, wl -1), one integer bits, wl bits in total
(integer bits, fractional bits)
N/A
(exponent bits, mantissa bits)
If input_wl or output_wl are not provided, they are assumed to be the same as wl.
- Parameters:
- wlint or (int, int)
Number of bits for data type used in computations.
- input_wlint or (int, int), optional
Number of bits for input data type.
- output_wlint or (int, int), optional
Number of bits for output data type.
- num_repr
NumRepresentation, default:NumRepresentation.FIXED_POINT Type of number representation to use.
- is_signedbool, default: True
If the number representation is signed.
- is_complexbool, default: False
If the number representation is complex-valued.
- quantization_mode
QuantizationMode, default:QuantizationMode.TRUNCATION Type of quantization to use.
- overflow_mode
OverflowMode, default:OverflowMode.WRAPPING Type of overflow to use.
- classmethod from_DataType(other: DataType) Self¶
Create DataType subclass from other subclass.
- Parameters:
- otherDataType
The DataType to base new object on.
- num_repr: NumRepresentation = 1¶
- overflow_mode: OverflowMode = 1¶
- quantization_mode: QuantizationMode = 2¶
- abstract property scalar_type_str: str¶
Scalar type used for computations.
Same as
type_str()when using a real type. The inner type when using a complex type.- Returns:
- str
- class b_asic.data_type.NumRepresentation(value)¶
Type of number representation.
- FIXED_POINT = 1¶
- FLOATING_POINT = 2¶
- class b_asic.data_type.VhdlDataType(wl: tuple[int, int], input_wl: tuple[int, int] | None = None, output_wl: tuple[int, int] | None = None, num_repr: NumRepresentation = NumRepresentation.FIXED_POINT, is_signed: bool = True, is_complex: bool = False, quantization_mode: QuantizationMode = QuantizationMode.TRUNCATION, overflow_mode: OverflowMode = OverflowMode.WRAPPING, vhdl_2008: bool = False)¶
Data type specification for VHDL.
All arguments are keyword only.
The number of bits can be specified in two few different ways.
num_repr
int
(int, int)
(1, wl -1), one integer bits, wl bits in total
(integer bits, fractional bits)
N/A
(exponent bits, mantissa bits)
If input_wl or output_wl are not provided, they are assumed to be the same as wl.
- Parameters:
- wlint or (int, int)
Number of bits for data type used in computations.
- input_wlint or (int, int), optional
Number of bits for input data type.
- output_wlint or (int, int), optional
Number of bits for output data type.
- num_repr
NumRepresentation, default:NumRepresentation.FIXED_POINT Type of number representation to use.
- is_signedbool, default: True
If number representation is signed.
- is_complexbool, default: False
If number representation is complex-valued.
- vhdl_2008bool, default: False
If True, use
fixed_pkgfor fixed-point values andfloat_pkgfor floating-point values.- quantization_mode
QuantizationMode, default:QuantizationMode.TRUNCATION Type of quantization to use.
- overflow_mode
OverflowMode, default:OverflowMode.WRAPPING Type of overflow to use.
- classmethod from_DataType(other: DataType) Self¶
Create DataType subclass from other subclass.
- Parameters:
- otherDataType
The DataType to base new object on.
- num_repr: NumRepresentation = 1¶
- overflow_mode: OverflowMode = 1¶
- quantization_mode: QuantizationMode = 2¶
- property scalar_type_str: str¶
Scalar type used for computations.
Same as
type_str()when using a real type. The inner type when using a complex type.- Returns:
- str