Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Map vector of bits to corresponding vector of integers

Utility Blocks

The Bit to Integer Converter block maps groups of bits in the
input vector to integers in the output vector. *M* defines
how many bits are mapped for each output integer.

For unsigned integers, if *M* is the **Number
of bits per integer**, then the block maps each group of *M* bits
to an integer between 0 and 2^{M}-1. As a
result, the output vector length is 1/*M* times the
input vector length. For signed integers, if *M* is
the **Number of bits per integer** , then the block
maps each group of *M* bits to an integer between
–2^{M-1} and 2^{M-1}-1.

This block accepts a column vector input signal with an integer
multiple equal to the value you specify for **Number of bits
per integer** parameter. The block accepts `double`

, `single`

, `boolean`

, `int8`

, `uint8`

, `int16`

, `uint16`

, `int32`

, `uint32`

and `ufix1`

input
data types.

**Number of bits per integer**The number of input bits that the block maps to each integer of the output. This parameter must be an integer between 1 and 32.

**Input bit order**Defines whether the first bit of the input signal is the most significant bit (MSB) or the least significant bit (LSB). The default selection is MSB.

**After bit packing, treat resulting integer value as**Indicates if the integer value input ranges should be treated as signed or unsigned. The default setting is

`Unsigned`

.### Note

This parameter setting determines which

**Output data type**selections are available.**Output data type**If the input values are unsigned integers, you can choose from the following

**Output data type**options:`Inherit via internal rule`

`Smallest integer`

`Same as input`

`double`

`single`

`int8`

`uint8`

`int16`

`uint16`

`int32`

`uint32`

If the input values are signed integers, you can choose from the following

**Output data type**options:`Inherit via internal rule`

`Smallest integer`

`double`

`single`

`int8`

`int16`

`int32`

The default selection for this parameter is

`Inherit via internal rule`

.When you set the parameter to

`Inherit via internal rule`

, the block determines the output data type based on the input data type.If the input signal is floating-point (either

`double`

or`single`

), the output data type is the same as the input data type.If the input data type is not floating-point, the output data type is determined as if the parameter is set to

`Smallest integer`

.

When you set the parameter to

`Smallest integer`

, the software selects the output data type based on the settings used in the**Hardware Implementation**(Simulink) pane of the Configuration Parameters dialog box.If

`ASIC/FPGA`

is selected, the output data type is the smallest ideal integer or fixed-point data type, based on the setting for the**Number of bits per integer**parameter.For all other selections, the output data type is the smallest available (signed or unsigned) integer word length that is large enough to fit the ideal minimum bit size.

Refer to the example on the Integer to Bit Converter reference page: Fixed-Point Integer To Bit and Bit To Integer Conversion (Audio Scrambling and Descrambling Example)

Was this topic helpful?