b_asic.data_type¶

B-ASIC Data Type Module.
- class b_asic.data_type.DataType(wl: int | tuple[int, int], input_wl: int | tuple[int, int] | None = None, output_wl: int | 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: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:TRUNCATION Type of quantization to use.
- overflow_mode
OverflowMode, default:WRAPPING Type of overflow to use.
- property bits: int¶
Number of bits used for computations.
- Returns:
- int
Total number of bits used for computations.
- property exp_bits: int¶
Number of exponent bits. Only valid for floating-point types.
- Returns:
- int
Number of exponent bits in the floating-point representation.
- property frac_bits: int¶
Number of fractional bits. Only valid for fixed-point types.
- Returns:
- int
Number of fractional bits in the fixed-point representation.
- classmethod from_DataType(other: DataType) Self¶
Create DataType subclass from other subclass.
- Parameters:
- other
DataType The DataType to base new object on.
- other
- property high: int¶
Index of most significant bit.
- Returns:
- int
Zero-based index of the most significant computation bit.
- property input_bits: int¶
Number of bits used for input.
- Returns:
- int
Total number of bits used for input values.
- property input_high: int¶
Index of most significant bit for input.
- Returns:
- int
Zero-based index of the most significant input bit.
- property int_bits: int¶
Number of integer bits. Only valid for fixed-point types.
- Returns:
- int
Number of integer bits in the fixed-point representation.
- property low: int¶
Index of least significant bit.
- Returns:
- int
Zero-based index of the least significant bit, always 0.
- property man_bits: int¶
Number of mantissa bits. Only valid for floating-point types.
- Returns:
- int
Number of mantissa bits in the floating-point representation.
- class b_asic.data_type.NumRepresentation(*values)¶
Type of number representation.
- FIXED_POINT = 1¶
- FLOATING_POINT = 2¶
Internal VHDL data type¶
- class b_asic.data_type._VhdlDataType(wl: int | tuple[int, int], input_wl: int | tuple[int, int] | None = None, output_wl: int | 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)¶
Internal VHDL-specific data type.
Created by
VhdlPrinterfrom aDataType. ExtendsDataTypewith VHDL string representations and index conventions.- Parameters:
- vhdl_2008bool, default: False
If True, use
fixed_pkgfor fixed-point values andfloat_pkgfor floating-point values.