Bit to Integer Converter

Map vector of bits to corresponding vector of integers

Library

Utility Blocks

Description

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

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 2M-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 –2M-1 and 2M-1-1.

If the input signal is a sample-based input, then it must be a vector whose length equals the value for the Number of bits per integer parameter. If the input is frame-based, then it must be a column vector whose length is an integer multiple of Number of bits per integer.

The block can accept input data types double, single, boolean, int8, uint8, int16, uint16, int32, uint32 and ufix1.

Dialog Box

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.

Output data type

If the input values are unsigned integers, you can choose from the following Output data type options:

If the input values are signed integers, you can choose from the following Output data type options:

The default selection for this parameter is Inherit via internal rule.

When the parameter is set to Inherit via internal rule, the block determines the output data type based on the input data type.

When the parameter is set to Smallest integer, the software selects the output data type based on the settings used in the Hardware Implementation pane of the Configuration Parameters dialog box.

Examples

If the input is [0; 1; 1; 1; 1; 1; 0; 1] when the value entered for the Number of bits per integer parameter is 4, the Input bit order is MSB, and After bit packing, treat resulting integer value as is Unsigned, then the output is [7; 13]. The block maps the first group of four bits (0, 1, 1, 1) to 7 and the second group of four bits (1, 1, 0, 1) to 13. Notice that the output length is one-fourth of the input length.

See Also

bi2de , bin2dec

Pair Block

Integer to Bit Converter

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS