Engee documentation

Extract Bits

Outputs a sample of consecutive bits from the input signal.

extract bits

Description

The Extract Bits block allows you to output a selection of consecutive bits from a stored integer value of the input signal. Use the Bits to extract parameter to define the method of selecting the output bits.

The values to be selected in the Bits to extract parameter:

  • Upper half - output half of the input bits containing the upper bit.

  • Lower half - output half of the input bits containing the least significant bit.

  • Range starting with the most significant bit - output a certain number of high bits of the input signal, the number of bits is set in the Number of bits parameter.

  • Range ending with least significant bit - outputs a certain number of low significant bits of the input signal, the number of bits is set in the Number of bits parameter.

  • Range of bits - when selecting this value it is necessary to specify the range of consecutive bits of the input signal for output. The range of values is specified in the Bit indices parameter in [start, end] format, and the input bit indices are labelled sequentially, starting from 0 for the least significant bit.

Ports

Input

Port_1 - input signal
scalar | vector | matrix | N-dimensional array

An input signal specified as a scalar, vector, matrix, or N-dimensional array. Floating point input data passes through the block unchanged. Input data of Bool type is treated as data of UInt8 type.

It is difficult to perform bit operations on signed integers. You can avoid difficulties by converting the data type of the input signals to unsigned integers.

Data types: Float16, Float32, Float64, Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128, Bool, Fixed.

Output

Port_1 - extracted bits
scalar | vector | matrix | N-dimensional array

A sequential sample of extracted bits, specified as a scalar, vector, matrix, or N-dimensional array. Floating point input data passes through the block unchanged.

Data types: Float16, Float32, Float64, Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128, Bool, Fixed.

Parameters

Bits to extract - method of extracting bits
Upper half (by default) | Lower half | Range starting with most significant bit | Range ending with least significant bit | Range of bits

Select the method of extracting bits from the input signal.

Consider an input signal that is represented in binary by 110111001:

  • If Upper half is selected to output half of the input bits containing the high bit, the output will be 11011 in binary.

  • If Lower half is selected to output half of the input bits containing the least significant bit, the output will be 11001 in binary.

  • If Range starting with most significant bit is selected - output a certain number of high bits of the input signal, and the number of bits in the Number of bits parameter is set to 3, the output will be 110 in binary.

  • If Range ending with least significant bit is selected - output a certain number of least significant bits of the input signal, and the number of bits in the Number of bits parameter is set to 8, the output will be 10111001 in binary.

  • If Range of bits is selected and the number of [4, 7] adjacent bits of the input signal to be output in the Bit indices parameter is specified, the output will be 1011 in binary.

Usage in program code

Block parameter

bitsToExtract

Value

Upper half | Lower half | Range starting with most significant bit | Range ending with least significant bit | Range of bits

* By default*

Upper half

Number of bits - number of bits to output
8 (by default) | positive integer

Select the number of bits to output from the input signal. Signed integers must have at least two bits. Unsigned integers can have no more than one bit.

Dependencies

To use this parameter, set the Bits to extract parameter to Range starting with most significant bit or Range ending with least significant bit.

Usage in program code

Block parameter

numBits

Value

positive integer

* By default*

8

Bit indices - serial bit range for output
[0, 7] (by default) | sequential range

Specify the input bit range for output in [start, end] format. Indices are assigned to the input bits starting from 0 in the least significant bit.

Dependencies

To use this parameter, set the Bits to extract parameter to Range of bits.

Usage in program code

Block parameter

bitIdxRange

Value

sequential range

By default

[0, 7]

Output scaling mode - output scaling mode
Preserve fixed-point scaling (by default) | `Treat bit field as an integer `

Select the scaling mode to be used for output bit selection:

  • Preserve fixed-point scaling - fixed-point scaling of input data is used to determine the output scaling during data type conversion.

  • Treat bit field as an integer - fixed-point scaling of input data is ignored and only the stored integer is used to calculate the output data type.

Usage in program code

Block parameter

outScalingMode

Value

Preserve fixed-point scaling | Treat bit field as an integer

By default

Preserve fixed-point scaling