Engee documentation

Logical Operator

Performs the specified logical operation on the input signals.

blockType: Logic

Path in the library:

/Basic/Logic and Bit Operations/Logical Operator

Description

Block Logical Operator performs a specified logical operation for one or more operands. The input value is interpreted as true (1) if it is not equal to zero, and false (0) if it is equal to zero.

A specific logical operation can be selected in the block settings using the parameter Operator.

The table shows the supported logical operations.:

Operation Description

AND

true if all the inputs are false

OR

true if there is at least one input true

NAND

true if there is at least one input false

NOR

true when there is no input data in the value true

XOR

true if there are an odd number of inputs true

NXOR

true if there are an even number of inputs true

NOT

true If the input is false

The block icon changes depending on which option is selected. Operator a logical operation. The number of input ports is set in the parameter Number of input ports.

The output size depends on the size of the input vector and the selected operator.:

  • If the block has more than one input, the dimension of the remaining ports is expanded to the maximum possible using broadcast operations. For example, if the input signals have dimensions 4 on 1, 1 on 5 and 1 on 1, then using broadcast , the output will be an array of the size 4 on 5. This process automatically expands arrays by dimensions equal to one in order to match the dimensions of the input data for calculations.

    Broadcast is the process of automatically reducing arrays to compatible sizes for performing operations. Broadcast works according to the rules of "distribution" in dimensions equal to one: if the arrays have mismatched sizes, but at least one of the dimensions is equal to 1, then the operation is performed, while the array is expanded in the corresponding dimension.

    The dimension of scalar input signals increases to the dimension of non-scalar input signals, which is also achieved using the broadcast operation. If a block has several inputs, and one of them is scalar, broadcast automatically expands it to the same dimension as the rest of the input data.

    If the block has more than one input, the output has the same dimensions as the inputs, and each output element is the result of applying the specified logical operation to the corresponding input elements. For example, if an operation is specified AND, and the input data are arrays 2 on 2, the output will be an array 2 on 2, the upper -left element of which is the result of the application AND to the upper-left elements of the input data, and so on.

  • For one input vector, the block applies an operation (except the operator NOT) to all elements of the vector. The output in this case is always a scalar.

  • Operator NOT accepts only one input, which can be a scalar or a vector. If the input is a vector, the output is a vector of the same size containing the logical complements of the elements of the input vector.

Ports

Output

# OUT_1 — The output signal
scalar | vector | the matrix

Details

The output signal consists of zeros and ones, with the same dimensions as the input.

Data types

Bool

Complex numbers support

Yes

Input

# IN_1 — the first input signal
scalar | vector | the matrix

Details

The first input signal. A scalar, vector, or matrix.

Data types

Float16, Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Bool

Complex numbers support

Yes

# IN_2 — the second input signal
scalar | vector | the matrix

Details

The second input signal. A scalar, vector, or matrix.

Data types

Float16, Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Bool

Complex numbers support

Yes

Parameters

Main

# Operator — The logical operator
AND | OR | NAND | NOR | XOR | NXOR | NOT

Details

Select the logical operator that will be applied to the input signals of the block:

  • ANDtrue if all the inputs are false.

  • ORtrue if there is at least one input true.

  • NANDtrue if there is at least one input false.

  • NORtrue when there is no input data in the value true.

  • XORtrue if there are an odd number of inputs true.

  • NXORtrue if there are an even number of inputs true.

  • NOTtrue If the input is false.

Values

AND | OR | NAND | NOR | XOR | NXOR | NOT

Default value

AND

Program usage name

Operator

Tunable

No

Evaluatable

No

# Number of input ports — number of inputs
Int64 integer

Details

Set the number of input ports of the block as a positive integer.

Dependencies

To use this parameter, set for the parameter Operator any value other than NOT.

Default value

2

Program usage name

Inputs

Tunable

No

Evaluatable

Yes

Additional options

C code generation: Yes

Verilog code generation: Yes