b_asic.data_type

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

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 dontcare_str: str

Don’t care value for signals of this data type.

Returns:
str
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
abstract property init_val: str

Initial value for signals of this data type.

Returns:
str
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
abstract property input_type_str: str

Type used for input.

Returns:
str
input_wl: tuple[int, int] | None = None
is_complex: bool = False
is_signed: bool = True
property low: int

Index of least significant bit.

Returns:
int
num_repr: NumRepresentation = 1
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
abstract property output_type_str: str

Type used for output.

Returns:
str
output_wl: tuple[int, int] | None = None
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
abstract property type_str: str

Type used for computations.

Returns:
str
wl: tuple[int, int]
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)

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 number representation is signed.

is_complexbool, default: False

If number representation is complex-valued.

vhdl_2008bool, default: False

If True, use fixed_pkg for fixed-point values and float_pkg for floating-point values.

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 dontcare_str: str

Don’t care value for signals of this data type.

Returns:
str
classmethod from_DataType(other: DataType) Self

Create DataType subclass from other subclass.

Parameters:
otherDataType

The DataType to base new object on.

get_input_port_declaration(entity_name: str) list[str]
get_input_port_mapping(entity_name: str) list[str]
get_output_port_declaration(entity_name: str) list[str]
get_output_port_mapping(entity_name: str) list[str]
property high: int

Index of most significant bit.

Returns:
int
property init_val: str

Initial value for signals of this data type.

Returns:
str
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 input_type_str: str

Type used for input.

Returns:
str
input_wl: tuple[int, int] | None = None
is_complex: bool = False
is_signed: bool = True
property low: int

Index of least significant bit.

Returns:
int
num_repr: NumRepresentation = 1
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
property output_type_str: str

Type used for output.

Returns:
str
output_wl: tuple[int, int] | None = None
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
property type_str: str

Type used for computations.

Returns:
str
vhdl_2008: bool = False
wl: tuple[int, int]