Engee documentation

Add

Performs addition or subtraction of input signals.

blockType: Sum

Add

Path in the library:

/Basic/Math Operations/Add

Sum of Elements

Path in the library:

/Basic/Math Operations/Sum of Elements

Description

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

Block operations are set using the parameter List of Signs. Available operations and symbols:

  • Addition (+).

  • Subtraction ().

  • The number of characters + and is equal to the number of input ports of the block.

    For example, if you specify for the parameter List of Signs The value is −, the block will have three input ports. The block subtracts the second (middle) input signal from the first (upper) one, and then adds the third (lower) one.

  • If only addition is performed, then you can set a numeric value equal to the number of input data.

Calculating the output value

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

If the block has I…​ The 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 input port signs are

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

u[i] — input to the i-th input port

The kth input port is the first port with a + 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

The output signal obtained as a result of 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, Int128,UInt8, UInt16, UInt32, UInt64, UInt128, Bool, Fixed-point

Complex numbers support

Yes

Input

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

Details

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

Data types

Float16, Float32, Float64, Int8, Int16, Int32, Int64, Int128,UInt8, UInt16, UInt32, UInt64, UInt128, Bool, Fixed-point

Complex numbers support

Yes

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

Details

the nth input signal for operations. The number of input signals corresponds to the number of characters in the parameter 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 inputs are expanded to have the same dimensions as other inputs.

Data types

Float16, Float32, Float64, Int8, Int16, Int32, Int64, Int128,UInt8, UInt16, UInt32, UInt64, UInt128, Bool, Fixed-point

Complex numbers support

Yes

Parameters

Main

# List of Signs — operations performed on input data

Details

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

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

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

If only addition is performed, then you can set a numeric value equal to the number of input data.

Default value

Program usage name

Inputs

Tunable

No

Evaluatable

Yes

# Apply over — applying a function to specified measurements
All dimensions | Specified dimension

Details

Specify how to use the function:

  • All dimensions — Apply the function to all input values for all measurements.

    For example, if in the parameter List of Signs the value is set to +, and for the parameter Apply over — value All dimensions, then the block returns the sum of all input values across all dimensions. If the input is a two-dimensional matrix [1 2 3; 4 5 6], then the output will be `21'.

  • Specified dimension — apply the function to all input values for the specified measurement.

Dependencies

To use this parameter, set for the parameter List of Signs just one sign.

Values

All dimensions | Specified dimension

Default value

All dimensions

Program usage name

CollapseMode

Tunable

No

Evaluatable

No

# Dimension — the dimension that will be used for summation
Integer

Details

Specify the dimension for which the summation will be performed as a positive integer.

Let’s assume that — a 2 by 3 matrix:

  • if for the parameter Dimension if the value is set to 1, then the resulting sum is :

  • if for the parameter Dimension if the value is set to `2', then the resulting sum is :

For example, if in the parameter List of Signs the value + is set for the parameter Apply over — value Specified dimension, and for the parameter Dimension — the value is 2', then the block returns the sum of all input values of each row. If the input is a two-dimensional matrix `[1 2 3; 4 5 6], then the output will be `[6; 15]'.

If the specified dimension is greater than the dimension of the input data, an error message appears.

Dependencies

To use this parameter, set for the parameter Apply over meaning Specified dimension.

Default value

1

Program usage name

CollapseDim

Tunable

No

Evaluatable

Yes

Accumulator settings

# Accumulator data type — storage 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 for the parameter Accumulator data type meaning Fixed-point.

Default value

fixdt(1, 16, 0)

Program usage name

AccumDataTypeStrFixed

Tunable

No

Evaluatable

Yes

Output settings

# Output data type — type of output data
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 — the type of fixed-point output
Data type

Details

Specify the fixed-point data type for the output data.

Dependencies

To use this parameter, set for the parameter Output data type meaning 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 choose:

  • Floor — rounds down both positive and negative numbers (towards negative infinity).

  • Ceiling — rounds up both positive and negative numbers (towards positive infinity).

  • Convergent — rounds the number to the nearest representable value. If the fractional part of the 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 up (towards positive infinity).

  • Round — rounds the number to the nearest integer.

  • 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 — method of action in case of overflow
Logical

Details

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

Action Reasons for making this decision What happens when there is an overflow Example

Check this box.

Overflow is possible in your model, and you need explicit protection against saturation in the generated code.

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

Overflow associated with a signed 8-bit integer can saturate to -128 or `127'.

Do not check this box.

You want to optimize the efficiency of the generated code.
You want to avoid over-clarifying how the block handles signals that are out of range.

Overflows are wrapped into an appropriate value, which can be represented by a data type.

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

Default value

false (switched off)

Program usage name

SaturateOnIntegerOverflow

Tunable

No

Evaluatable

No

Additional options

C code generation: Yes

Verilog generation: Yes

Examples