Bitwise Operator
A specified bitwise operation on the input signals.
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.
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) |
Block parameter |
|
Values |
|
By default |
|
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.
Block parameter |
|
Values |
|
By default |
|
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.
Block parameter |
|
Values |
|
By default |
|
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 |
|
Bit clear |
AND |
|
Bit get |
AND |
|
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.
Block parameter |
|
Values |
|
By default |
|