Engee documentation

Add

Performs addition or subtraction of input signals.

Add

add

Sum of Elements

sum of elements

Description

Block Add performs addition or subtraction of input signals. This block can add or subtract scalar, vector or matrix signals. It can also sum the elements of the signal.

The block operations are specified using the parameters List of Signs. Available operations and symbols:

  • Addition ( +).

  • Subtraction ( -).

  • The number of + and - symbols is equal to the number of input ports of the unit.

    For example, if you specify for the parameters List of Signs value +-+, the block will have three input ports. The block subtracts the second (middle) input signal from the first (top) and then adds the third (bottom).

  • If only addition is performed, a numeric value equal to the number of inputs can be set.

Calculating the output value

Calculation of the output value for a block Add depends on the number of block inputs and the sign of the input ports:

If the block And…​ Formula for calculating the output value…​ Where…​

One input port

Input port sign +

y = e[0]+e[1]+e[2]…​+ e[m]

e[i] is the i`th element of the input `u

Input port sign -

y = 0.0-e[0]-e[1]-e[2]…​-e[m]

Two or more input ports

All characters of the input port are -

y = 0.0-u[0]-u[1]-u[2]…​-u[n]

u[i] is the input to the `i`th input port

The k-th input port is the first port with the + sign

y = u[k]-u[0]-u[1]-u[2]-u[k-1] (+/-) u[k+1]…​ (+/-) u[n]

Ports

Output

# OUT_1 — output signal
scalar | vector | matrix

Details

An output signal resulting from addition and/or subtraction operations. The output signal has the same size as the input signals.

Data types

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

Complex numbers support

Yes

Input

# In_1 — first input signal
scalar | vector | matrix

Details

Input signal for an addition or subtraction operation. If there is only one input signal, the addition or subtraction is performed for all its elements.

Data types

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

Complex numbers support

Yes

# In_n — nth input signal of the operand
scalar | vector | matrix

Details

n-th input signal for operations. The number of input signals corresponds to the number of characters in the parameters List of Signs. The block applies operations to the input data in the specified order.

All non-scalar input data must have the same dimensions. Scalar input data is expanded to have the same dimensions as other input data.

Data types

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

Complex numbers support

Yes

Parameters

Main

# List of Signs — operations performed on input data

Details

Enter the addition and subtraction operations performed on input data. An input port is created for each operation.

Addition is the operation by default. The operations are performed in the order specified.

For a single vector input, + or − adds or subtracts elements across all dimensions.

If only addition is performed, you can specify a numeric value equal to the number of inputs.

Default value

Program usage name

Inputs

Tunable

No

Evaluatable

Yes

Accumulator settings

# Accumulator data type — drive data type
Inherit: auto | Same as first input | Float64 | Float32 | Float16 | Int8 | UInt8 | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 | Int128 | UInt128 | Fixed-point

Details

Select the data type for the drive.

Values

Inherit: auto | Same as first input | Float64 | Float32 | Float16 | Int8 | UInt8 | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 | Int128 | UInt128 | Fixed-point

Default value

Inherit: auto

Program usage name

AccumDataTypeStr

Tunable

No

Evaluatable

No

# Accumulator fixed-point type — fixed-point data type for the drive
Data type

Details

Specify the fixed-point data type for the drive.

Dependencies

To use this parameter, set the parameters to Accumulator data type value Fixed-point.

Default value

fixdt(1, 16, 0)

Program usage name

AccumDataTypeStrFixed

Tunable

No

Evaluatable

Yes

Output settings

# Output data type — output data type
Inherit: auto | Same as accumulator | Same as first input | Float64 | Float32 | Float16 | Int8 | UInt8 | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 | Int128 | UInt128 | Fixed-point

Details

Select the type for the output data.

Values

Inherit: auto | Same as accumulator | Same as first input | Float64 | Float32 | Float16 | Int8 | UInt8 | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 | Int128 | UInt128 | Fixed-point

Default value

Inherit: auto

Program usage name

OutDataTypeStr

Tunable

No

Evaluatable

No

# Output fixed-point type — fixed-point output data type
Data type

Details

Specify the fixed point data type for the output data.

Dependencies

To use this parameter, set parameter Output data type value Fixed-point.

Default value

fixdt(1, 16, 0)

Program usage name

OutDataTypeStrFixed

Tunable

No

Evaluatable

Yes

Main

# Integer rounding mode — rounding mode for fixed-point operations
Ceiling | Convergent | Floor | Nearest | Round | Zero

Details

Select the rounding mode for fixed-point operations. You can select:

  • Floor - rounds both positive and negative numbers downwards (towards negative infinity).

  • Ceiling - rounds both positive and negative numbers upwards (towards positive infinity).

  • Convergent - rounds the number to the nearest representable value. If the fractional part of a number ends in 5, the number is rounded to the nearest even integer.

  • Nearest - rounds the number to the nearest representable value. If the fractional part of the number ends in 5, the number is rounded upwards (towards positive infinity).

  • Round - rounds the number to the nearest representable value. If the fractional part of a number ends in 5, positive numbers are rounded upwards (towards positive infinity) and negative numbers are rounded downwards (towards negative infinity).

  • Zero - rounds the number towards zero.

The block parameters are always rounded to the nearest representable value.

Values

Ceiling | Convergent | Floor | Nearest | Round | Zero

Default value

Floor

Program usage name

RndMeth

Tunable

No

Evaluatable

No

# Saturate on integer overflow — overflow action method
Logical

Details

When checked, saturation is applied to all internal block operations, not just the output or result.

Action Reasons for taking this action What happens when overflows Example

Check this box.

Overflows are possible in your model and you need explicit saturation protection in the generated code.

Overflows are saturated to the minimum or maximum value that this data type can represent.

An overflow associated with a signed 8-bit integer may saturate to -128 or 127.

Do not select this check box.

You want to optimise the efficiency of the generated code.
You want to avoid over-specifying how the block handles out-of-range signals.

Overflows are wrapped in an appropriate value that can be represented by a data type.

The number 130 does not fit into a signed 8-bit integer and is collapsed into -126

Default value

false (switched off)

Program usage name

SaturateOnIntegerOverflow

Tunable

No

Evaluatable

No

Additional options

C code generation: Yes