Engee documentation

Bitwise Operator

A specified bitwise operation on the input signals.

bitwise operator

Description

The Bitwise Operator block performs a specified bitwise operation on one or more operands. Unlike the logical operations of the block Logical Operator, bitwise operations treat operands as a vector of bits rather than as a single value.

The block icon changes depending on the operation selected in the Operator parameter.

The number of input ports of the block is specified by the Number of input ports parameter.

Limitations of block operations

The Bitwise Operator block does not support shift operations. Use the Shift Arithmetic block for shift operations.

Ports

Input

Port_N - input signal
scalar | vector | matrix

Input signal as a scalar or vector.

The number of input ports of the block is set by the parameter Number of input ports.

  • The NOT operator accepts only one input, which can be a scalar or vector. If the input is a vector, the output is a vector of the same size containing the results of the specified logical operation on the elements of the input vector.

  • For a single input vector, the block applies the operation (except the NOT operator) to all elements of the vector.

  • For two or more inputs, the block performs the operation between all inputs. If the input parameters are vectors, the block performs the operation between the corresponding elements of the vectors, thus forming an output vector of the same size.

Data types: Integer.

Output

Port_1 - output signal
scalar | vector | matrix

Output signal. Its type must accurately represent zero. Data types satisfying this condition include integer data types with and without sign.

The size of the block output depends on the number of input parameters, the size of the vector, and the operator you choose. If no bitmask is specified, the output is a scalar, otherwise a vector.

Data types: Integer.

Parameters

Operator - bitwise logical operator
AND (by default) | OR | NOR | NAND | XOR | NOT

Bitwise logical operator for block operands. The following bitwise operations are available:

Bitwise operation Description

AND

true if all corresponding bits are true

OR

true if at least one of the corresponding bits is true

NAND

true if at least one of the corresponding bits is false

NOR

true if there are no corresponding bits true

XOR

true if there is an odd number of matching bits true

NOT

true if the input is false (available for one input only)

Usage in program code

Block parameter

logicop

Values

AND | OR | NOR | NAND | XOR | NOT

By default

AND

Use bit mask - checkbox for using a bit mask
On (By default) | Off

Select the checkbox to use bit mask.

Checking this box causes the Number of input ports parameter to be disabled.

Unchecking the box causes the Bit Mask parameter to be disabled.

Usage in program code

Block parameter

UseBitMask

Values

off | on

By default

enabled

Number of input ports - number of input signals
1 (by default) | `Number of input ports* - number of input signals

Number of inputs. There can be more than one input port.

Dependencies

Unchecking Use bit mask enables Number of input ports and disables Bit Mask.

Usage in program code

Block parameter

NumInputPorts

Values

integer

By default

1

Bit Mask - bit mask for communication with a single input
0b11011001 (By default)

Set the bit mask for communication with a single input. This parameter reads values as hexadecimal values.

You can use the bitmask to set, count, or clear (zero) an input bit.

To perform…​ Set the Operator parameter to…​ And create a bit mask with…​

Bit set

OR

1 for each corresponding input bit that you want to set to 1

Bit clear

AND

0 for each corresponding input bit you want to set to 0

Bit get

AND

1 for each corresponding input bit you want to get

Suppose you want to set the fourth bit of an 8-bit input vector. The bit mask will be 00010000, which you can specify as 2^4 for the Bit Mask parameter. To clear a bit, use the bit mask 11101111, which you can specify as 27+26+25+23+22+21+2^0 for the Bit Mask parameter.

Usage in program code

Block parameter

BitMask

Values

integer

By default

0b11011001

Additional options

C code generation: Yes