Integer to Bit Converter - Map vector of integers to vector of bits

Library

Utility Blocks

Description

The Integer to Bit Converter block maps each integer or fixed-point value in the input vector to a group of bits in the output vector.

The block maps each integer value (or stored integer when a fixed point input is used) to a group of M bits, using the selection for the Output bit order to determine the most significant bit. The resulting output vector length is M times the input vector length.

For integer-valued inputs, if M is the Number of bits per integer and Treat input values as is set to Unsigned, then the input values must be between 0 and 2M-1. If M is the Number of bits per integer and Treat input values as is set to Signed, then the block maps each group of M bits to an integer between –2M-1 and 2M-1-1.

This block is single-rate and single-channel. The input can be either a scalar or a frame-based column vector. The output is always a column vector with a length equal to Number of bit per integer times larger than the input signal length.

A simulation-only runtime input value check is performed. If any input value is outside of the Number of bit per integer value range, the block will issue an error.

The block can accept the data types int8, uint8, int16, uint16, int32, uint32, single, double, and fixed point.

Dialog Box

Number of bits per integer

The number of bits the block uses to represent each integer of the input. This parameter must be an integer between 1 and 32.

Treat input values as

Indicate if the integer value input ranges should be treated as signed or unsigned. The default setting is Unsigned.

Output bit order

Define whether the first bit of the output signal is the most significant bit (MSB) or the least significant bit (LSB). The default selection is MSB first.

Output data type

You can choose 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 block selects the output data type based on settings used in the Hardware Implementation pane of the Configuration Parameters dialog box.

Examples

If the input is [7; 13], the value for the Number of bits per integer parameter is 4, and the Output bit order is MSB first, then the output is [0; 1; 1; 1; 1; 1; 0; 1]. The first group of four bits (0, 1, 1, 1) represents 7 and the second group of four bits (1, 1, 0, 1) represents 13. Notice that the output length is four times the input length.

Pair Block

bi2de , bin2dec

See Also

de2bi and dec2bin

  


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