Byte Reversal

Reverse little-endian data for big-endian processor

  • Library:
  • Simulink Support Package for Arduino Hardware/Utilities

    Embedded Coder Support Package for STMicroelectronics Discovery Boards/Utilities

    Simulink Coder Support Package for STMicroelectronics Nucleo Boards/Utilities

Description

The Byte Reversal block changes the order of the bytes in the input data. Use this block when your process communicates between processors that use different endianness. For example, use this block for communication between Intel® processors that are little-endian and others that are big-endian. Processors compatible with the Intel 80x86 processors and Texas Instruments™ processors are little-endian. In this case, insert a Byte Reversal block before the Byte Pack block and another Byte Reversal block just after the Byte Unpack block.

Using the parameter of this block, you specify the number of block inputs.

Ports

Input

expand all

Number of input ports specified in the Number of inputs parameter. The block can have 1 to N input ports.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean

Output

expand all

Output ports from 1 to N as specified in the Number of inputs parameter. The number of output ports adjusts to match the number of input ports.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean

Parameters

expand all

The number of input ports and output ports adjusts to match the value specified in this parameter.

When you use more than one input port, each input port maps to the matching output port. Data entering input port 1 leaves through output port 1, and so on. Reversing the bytes does not change the data type.

Example

Suppose that you are sending a signal. The signals have the following attributes:

Constant valueTypeByte structure
-234int161111 1111 0001 0110
234uint160000 0000 1110 1010
234uint320000 0000 0000 0000 0000 0000 1110 1010
  1. Set the number of inputs to 3.

    The block creates three input and three output ports.

  2. Connect the signals to the Byte Reversal block.

The following model shows byte reversal. In the first signal, with value -234, the low-order byte 0001 0110 is swapped with the high-order byte 1111 1111. Therefore, the signal outputs to 0001 0110 1111 1111.

Introduced in R2016b