Engee documentation

Bit to Integer Converter

Maps a vector of bits to the corresponding vector of integers.

bit to integer converter

Description

The Bit to Integer Converter block maps groups of bits in the input vector to integers in the output vector.

The number is specified by the parameter Number of bits per integer(M) :

  • For unsigned integers, the block maps each group of M bits to an integer in the range [0, (2M - 1)]. As a result, the length of the output vector is times smaller than the length of the input vector.

  • For signed integers, the block maps each group of M bits to an integer in the range [(-2M-1), (2M-1 - 1)].

Ports

Input

In - input signal
bit scalar | bit vector-column

Input signal, as a scalar or vector-column of bits with a length multiple of the value specified in the Number of bits per Integer(M) parameter. Input data must be bits with values 0 or 1.

Data types: Int8, Int16, Int32, UInt8, UInt16, UInt32, Float32, Float64, Bool.

Output

Out - output signal
integer | vector-column of integers

Output signal returned as an integer or vector-column of integers. The After bit packing, treat resulting integer values as parameter specifies whether the output integers are interpreted as unsigned or signed.

  • When the input bits are treated as unsigned, each output integer is in the range [0, (2M- 1)].

  • When the input bits are treated as signed, each output integer is in the range [(-2M-1 ), (2M-1 - 1)].

Parameters

Number of bits per integer(M) - number of bits per integer (M)
3.0 (by default) | an integer in the range [1, 32]

The number of input bits mapped to each integer input as an integer in the value range [1, 32].

Usage in program code

Block parameter

nbits

Values

an integer in the range [1, 32]

By default

3.0

Input bit order - input bit order
MSB first (by default) | LSB first

Determine whether the first bit of the input signal is a high bit (MSB) or a low bit (LSB).

Usage in program code

Block parameter

bitOrder

Values

MSB first | LSB first

By default

MSB first

After bit packing, treat resulting integer values as - treat output values as numbers with or without sign
Unsigned (by default) | Signed

Specify whether the output values should be treated as signed (Signed) or unsigned (Unsigned) numbers.

Usage in program code

Block parameter

SignedOutputValues

Values

Unsigned | Signed

By default

Unsigned

Output data type - output data type
Float16 | Same as input | Float64 | Float32 | Int8 | Int16 | Int32 | UInt8 | UInt16 | UInt32

The available values of Output data type change depending on the desired characterisation of the output data.

If the output integers are `Signed', you can select one of the following output data type options:

  • Float32.

  • Float64

  • Int8

  • Int16

  • `Int32

If the output integers are Unsigned, in addition to the above options are added:

  • Same as input.

  • Float32

  • Float64

  • Int8

  • `Int16

  • `Int32

  • `UInt16

  • `UInt32

Additional options

C code generation: Yes