<< DLATCH Integer_pal INTMUL >>

Scilab Help >> Xcos > palettes > Integer_pal > EXTRACTBITS

EXTRACTBITS

Bits Extraction

Block Screenshot

Contents

Description

For an integer input this block outputs a contiguous selection of bits. The operation can be summarized by this expression:

Output = Input ∧ Mask

i.e. a bitwise AND between Input and Mask an integer of the same length as input with the bits to extract set to 1 and the other bits set to 0. Bits to Extract parameter defines the method by which the user selects the output bits as summarized by the following table with index 0, as that of the least significant bit :

Bits to Extract Output Number of Bits or Index of Bit
Upper Half Half of the input that contain the most significant bit Ignored
Lower Half Half of the input that contain the least significant bit Ignored
Range from MSB Number of Bits or Index of Bit bits of the input that contain the most significant bit (MSB) Number of bits to extract.
Range to LSB Number of Bits or Index of Bit bits of the input that contain the least significant bit (LSB) Number of bits to extract.
Range of bits Range of bits of the input between the indexes of the bits Start and End of Number of Bits or Index of Bit parameter. Vector with the format [Start, End] where start the first bit index and end the last bit index.

The output value depends also on the forth parameter Treat Bit Field as an Integer :

Data types

The block supports the following types :

Parameters

Default properties

Example

In the following table, we present the results obtained for the number 215 according to several combinations of the parameters.

Input Bits to Extract Number of Bits or Index of Bit Treat Bit Field as an Integer Output
11010111 (215) Upper Half Ignored no 01100000 (208)
11010111 (215) Upper Half Ignored yes 00001101 (13)
11010111 (215) Lower Half Ignored no 00000111 (7)
11010111 (215) Lower Half Ignored yes 00000111 (7)
11010111 (215) Range starting with MSB 6 no 11010100 (212)
11010111 (215) Range starting with MSB 6 yes 00110101 (53)
11010111 (215) Range starting with LSB 6 no 00010111 (23)
11010111 (215) Range starting with LSB 6 yes 00010111 (23)
11010111 (215) Range of bits [ 2, 5 ] no 00010100 (20)
11010111 (215) Range of bits [ 2, 5 ] yes 00000101 (5)
11010111 (-41) Upper half Ignored no 11010000 (-48)
11010111 (-48) Upper half Ignored yes 11111101 (-3)

In the following diagram, two decimal digit numbers are coded on an only byte. The diagram decode the input to obtain two separate digits.

Interfacing function

Computational function

See also


Report an issue
<< DLATCH Integer_pal INTMUL >>