Engee documentation

Gain

Multiplies the input signal by a constant.

blockType: Gain

Path in the library:

/Basic/Math Operations/Gain

Description

The Gain unit multiplies the value of the input signal by a constant value (gain). The input signal and gain can be scalar, vector or matrix.

The gain is specified by the parameters Gain. The parameter Multiplication allows you to specify element-by-element or matrix multiplication. For matrix multiplication, this parameters also allows you to specify the order of multipliers.

When calculating the output signal, the Gain block uses the following rules:

  • If the input signal type is of the real type and the gain is complex, the output signal type will be complex.

  • If the input signal type is different from the gain type, Engee attempts to perform a conversion of the gain type to the input signal type. If such a conversion is not possible, the calculation will be stopped and an error message will be displayed. This situation may occur, for example, if the input signal is an unsigned integer (Uint8) and the parameter Gain is set to a negative number.

Ports

Input

# IN_1 — input signal
scalar | vector | matrix

Details

Block Gain supports both real and complex scalar, vector or matrix input signals. If the block input signal Gain is real and the gain is complex, the output signal will be complex.

Data types

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

Complex numbers support

Yes

Output

# OUT_1 — input signal multiplied by the amplification factor
scalar | vector | matrix

Details

The input signal multiplied by the gain. If the block input signal Gain is real and the gain is complex, the output signal will be complex.

Data types

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

Complex numbers support

Yes

Parameters

Main

# Gain — the coefficient to multiply the input signal by
Scalar / array of real and/or complex numbers

Details

Sets the coefficient by which the input signal should be multiplied. The gain can be a real or complex scalar, vector, or matrix of any type, except logical.

Default value

1.0

Program usage name

Gain

Tunable

Yes

Evaluatable

Yes

# Multiplication — multiplication mode
Element-wise(K.*u) | Matrix(K*u) | Matrix(u*K)

Details

Specify one of these multiplication modes.:

  • Element-wise(K.*u) — each element of the input signal is multiplied by each element of the gain. If necessary, the block performs extensions so that the input data and the gain have the same dimensions.

  • Matrix(K*u) — The input data and the gain are multiplied by a matrix using the input data as the second operand.

  • Matrix(u*K) — The input data and the gain are multiplied by a matrix using the input data as the first operand.

Values

Element-wise(K.*u) | Matrix(K*u) | Matrix(u*K)

Default value

Element-wise(K.*u)

Program usage name

Multiplication

Tunable

No

Evaluatable

No

Signal Attributes

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

Details

Sets the type of output data.

Values

Inherit: auto | Same as 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 type of fixed-point output.

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

# 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:

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

  • Floor — 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.

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

Parameter Attributes

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

Details

Sets the data type of the parameter.

Values

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

Default value

Inherit: auto

Program usage name

ParamDataTypeStr

Tunable

No

Evaluatable

No

# Parameter fixed-point type — fixed-point parameter data type
Data type

Details

Specify the data type of the fixed-point parameter.

Dependencies

To use this parameter, set for the parameter Parameter data type meaning Fixed-point.

Default value

fixdt(1, 16, 0)

Program usage name

ParamDataTypeStrFixed

Tunable

No

Evaluatable

Yes

Additional options

C code generation: Yes

Verilog generation: Yes

Examples