MT Pack Bits VI
Packs data to an unsigned or signed integer array. You can specify the order in which the bits are packed into the integer array either as MSB First or LSB First. You can also specify the integer format to be Signed or Unsigned using the integer format parameter.
This VI packs MN-sized binary data of the form b i={0,1}, i=0…MN–1 to an unsigned or signed integer array a n n=0…N–1 of size N, where M denotes the number of bits per integer.
input bit stream specifies the binary bit stream b i={0,1}, i=0…MN–1 to be packed into integers. The default is empty. |
|||||||
bits per integer specifies the number of binary data values that are packed into an integer. If you choose Unsigned for the integer format, the maximum value is 31. If you choose Signed, the maximum value is 32. The default is 1. |
|||||||
packed bit order specifies the order in which the binary data stream has been packed into integers.
|
|||||||
integer format specifies the input integer format.
|
|||||||
reset ? specifies how the VI 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 VI. When reset? is set to FALSE, these buffered bits are prepended to the input bit stream during the next iteration. The default is TRUE. |
|||||||
error in (no error) can accept error information wired from previously called VIs. Use this information to decide if any functionality should be bypassed in the event of errors from other VIs. Right-click the front panel error in control and select Explain Error or Explain Warning from the shortcut menu for more information about the error.
|
|||||||
output integers returns the output integer stream a n n=0…N–1 corresponding to the packed bits. |
|||||||
error out passes error or warning information out of a VI to be used by other VIs. Right-click the front panel error out indicator and select Explain Error or Explain Warning from the shortcut menu for more information about the error.
|
Details
The relationship between the output integers array and the input bit stream for the Unsigned integer format is given by the following equations:
(packed bit order set to MSB First)
(packed bit order set to LSB First)
If the integer format is set 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 VI is continuable, meaning that you can call it for multiple iterations inside a loop with reset? set to FALSE. In this case, the VI 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. |