b_asic.data_type

Inheritance diagram of 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)

FIXED_POINT

(1, wl -1), one integer bits, wl bits in total

(integer bits, fractional bits)

FLOATING_POINT

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_reprNumRepresentation, 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_modeQuantizationMode, default: QuantizationMode.TRUNCATION

Type of quantization to use.

overflow_modeOverflowMode, default: OverflowMode.WRAPPING

Type of overflow to use.

property bits: int

Number of bits used for computations.

Returns:
int
property exp_bits: int

Number of exponent bits. Only valid for floating-point types.

Returns:
int
property frac_bits: int

Number of fractional bits. Only valid for fixed-point types.

Returns:
int
classmethod from_DataType(other: DataType) Self

Create DataType subclass from other subclass.

Parameters:
otherDataType

The DataType to base new object on.

property high: int

Index of most significant bit.

Returns:
int
property input_bits: int

Number of bits used for input.

Returns:
int
property input_high: int

Index of most significant bit for input.

Returns:
int
property int_bits: int

Number of integer bits. Only valid for fixed-point types.

Returns:
int
property low: int

Index of least significant bit.

Returns:
int
property man_bits: int

Number of mantissa bits. Only valid for floating-point types.

Returns:
int
property output_bits: int

Number of bits used for output.

Returns:
int
property output_high: int

Index of most significant bit for output.

Returns:
int
class b_asic.data_type.NumRepresentation(*values)

Type of number representation.

FIXED_POINT = 1
FLOATING_POINT = 2