# MT Pack Bits (G Dataflow)

Packs data to an unsigned or signed integer array.

This node packs MN-sized binary data of the form b i = {0,1}, to an unsigned or signed integer array a_n,

where

• i = 0…MN-1, and M denotes the number of bits per integer
• n = 0…N-1, and N denotes the size of the array

## input bit stream

The binary bit stream to be packed into integers.

The binary bit stream must be in the form b i = {0,1}

where

• i = 0…MN-1, and M denotes the number of bits per integer
• n = 0…N-1, and N denotes the size of the array

Default: empty

## bits per integer

Number of binary data values that are packed into an integer.

If you set the integer format parameter to Unsigned, the maximum value is 31. If you set the integer format parameter to Signed, the maximum value is 32.

Default: 1

## packed bit order

The order in which the binary data stream is packed into integers.

Name Description
MSB first

Data is packed with the most significant bit (MSB) first.

LSB first

Data is packed with the least significant bit (LSB) first.

Default: MSB first

## integer format

Input integer format.

Name Description
Unsigned

The entire number is packed as a positive integer.

Signed

The most significant bit (MSB) determines the sign of the input integer.

Default: Unsigned

## error in

Error conditions that occur before this node runs. The node responds to this input according to standard error behavior.

Default: no error

## reset ?

A Boolean that determines how the node handles buffered data. When the length of the input bit stream is not a multiple of the bits per integer value, the leftover bits are buffered inside the node. When you set reset? to FALSE, these buffered bits are prepended to the input bit stream during the next iteration.

Default: TRUE

## output integers

The output integer stream a n n = 0…N-1, corresponding to the packed bits.

## error out

Error information. The node produces this output according to standard error behavior.

## Relationship between Output Integers and Input Bit Stream

The relationship between the output integers array and the input bit stream for the unsigned integer format is given by the following equations:

${a}_{n}=\underset{j=0}{\overset{M-1}{\sum }}{b}_{Mn+j}{2}^{\left(M-1\right)-j},\text{\hspace{0.17em}}n=0...N-1$(packed bit order set to MSB First)

${a}_{n}=\underset{j=0}{\overset{M-1}{\sum }}{b}_{Mn+j}{2}^{j},\text{\hspace{0.17em}}n=0...N-1$(packed bit order set to LSB First)

If you set the integer format to Signed, then the MSB at the bit position N-1 is used to determine the sign of the output integer. The sign is positive if MSB is 0 and negative if MSB is 1. For example, if you set the integer format to Unsigned and bits per integer as 3, and packed bit order as MSB first, the bits [1 0 0] are mapped to the integer 4. If packed bit order is specified as LSB first, the bits are mapped to the integer 1. If the integer format is set to Signed and packed bit order is MSB first, the bits [1 0 0 ] are packed to integer -4 because the MSB is 1 in this case. If packed bit order is set to LSB first, the bits are mapped to integer 1, because MSB is 0 in this case.

Note

This node is continuable, that is, you can call it for multiple iterations inside a loop with reset? set to FALSE. In this case, the node buffers the leftover bits whenever the length of the input bit stream is not a multiple of the specified bits per integer. These leftover bits are prepended to the beginning of the input bit stream during the next iteration, provided reset? is set to FALSE.

Where This Node Can Run:

Desktop OS: Windows

FPGA: Not supported