Documentation

Bit Unpacking

Deconstruct data frames

Library

Simulink® Real-Time™ Library for Utilities

Description

This block is used to extract data frames. Its input port is typically connected to an output port of a Receive block or Digital Input block.

The block has one input port, which represents the data frame entity from which the signals are extracted and leaving the block at its output ports. The number of output ports and the data type of each output port depend on the settings in the block dialog box.

Block Parameters

Bit Patterns

Specify bit patterns. The data type must be a MATLAB® cell array vector. The number of elements in the cell array define the number of input ports shown by this block instance. The cell array elements must be of type double array and define the position of each bit of the incoming value (data typed input port) in the outgoing double value (data frame). From a data type perspective, the block behaves like a Sink block. The Input port (packed) data types specify the data type of the input port.

Input port (packed) data types

From the list, select an input port (packed) data type.

  • double

  • single

  • int8

  • uint8

  • int16

  • uint16

  • int32

  • uint32

  • boolean

Input port (packed) dimension

Specify the dimensions of the input port (packed). Enter this as a vector. Specify the size of the port using a format compatible with the MATLAB size command.

Output port (unpacked) data types (cell array)

The output ports (packed) can be of arbitrary data type. The number of elements in the cell array define the number of output ports shown by this block instance. The data types can be

  • double

  • single

  • int8

  • uint8

  • int16

  • uint16

  • int32

  • uint32

  • boolean

Output port (unpacked) dimension (cell array)

Specify the dimensions of each output port (unpacked). Enter this as a cell array of vector sizes.

Sign extend

Select this check box to enable sign extension. If you select this check box and unpack the data frame into a signed type (int8, int16, or int32), the block performs sign extension. For example, if the bit pattern is [0:4], and the data type is int8, you are extracting 5 bits into an 8-bit wide signed type. In this case, bits 5, 6, and 7 are the same as bit 4, resulting in sign extension. This functionality enables you to pack and unpack negative numbers without losing precision.

Was this topic helpful?