Engee documentation

Switch

Switches the output between the first and third inputs based on the value of the second input.

blockType: Switch

Path in the library:

/Basic/Signal Routing/Switch

Description

Block Switch skips the signal from the first or third input, depending on the value of the signal at the second input. The first and third inputs are input signals, the second input is the control input. The condition under which the block passes the signal from the first input to the output is set by the parameters Criteria for passing first input and Threshold.

Ports

Output

# OUT_1 — The output signal
scalar | vector

Details

An output signal received from either the first or second input signal, depending on the value of the control signal.

Data types

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

Complex numbers support

Yes

Input

# IN_1 — the first input signal
scalar | vector

Details

The first of the two input signals. The unit transmits either one or the other input signal to the output based on the value of the control signal. The condition under which the block passes the signal from the first input to the output is set by the parameters Criteria for passing first input and Threshold.

Data types

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

Complex numbers support

Yes

# IN_2 — control signal
scalar | vector

Details

The control signal that the unit uses to determine which input should be sent to the output. If the control signal satisfies the conditions specified in the parameter Criteria for passing first input, then the block transmits the first input signal. Otherwise, the unit transmits a second input signal.

Data types

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

Complex numbers support

Yes

# IN_3 — the second input signal
scalar | vector

Details

The second of the two input signals. The unit transmits either one or the other input signal to the output based on the value of the control signal. The condition under which the block passes the signal from the first input to the output is set by the parameters Criteria for passing first input and Threshold.

Data types

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

Complex numbers support

Yes

Parameters

Main

# Criteria for passing first input — the criterion for choosing the transmission of the first input signal
u2 >= Threshold | u2 > Threshold | u2 ~= 0

Details

Select the condition under which the block will send the first input signal to the output. If the control input IN_2 satisfies the conditions specified in the parameter Criteria for passing first input, the block will transmit the first input signal In_1. Otherwise, the block transmits the second input signal IN_3. Options to choose from:

  • u2 >= Threshold — the control input is greater than or equal to the threshold value;

  • u2 > Threshold — the control input is greater than the threshold value;

  • u2 ~= 0 — the control input is non-zero.

Hint

If the control input is a Boolean signal, use one of the following combinations of condition and threshold value:

  • u2 >= Threshold, where the threshold value is 1;

  • u2 > Threshold, where the threshold value is 0;

  • u2 ~= 0.

Otherwise, the block Switch ignores threshold values and uses a Boolean value to route the signal. With the value 1 the block transmits the first input, and when the value 0 – the third entrance.

Values

u2 >= Threshold | u2 > Threshold | u2 ~= 0

Default value

u2 > Threshold

Program usage name

Criteria

Tunable

No

Evaluatable

No

# Threshold — the threshold value used in the criterion
Scalar / array of real numbers

Details

The threshold value used in the parameter Criteria for passing first input, which determines which input the block transmits to the output.

Dependencies

To use this parameter, set for the parameter Criteria for passing first input meaning u2 >= Threshold or u2 > Threshold.

Default value

0.0

Program usage name

Threshold

Tunable

Yes

Evaluatable

Yes

Signal Attributes

# Require all data inputs to have the same data type — all input data must have the same type.
Logical

Details

Check this box so that all input data has the same data type.

Default value

false (switched off)

Program usage name

InputSameDT

Tunable

No

Evaluatable

No

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

Details

Specify the type of output data.

The type can be inherited or specified directly.

Values

Inherit: auto | Same as first input | Float64 | Float32 | Float16 | Int8 | UInt8 | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 | Int128 | UInt128 | Bool | 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:

  • 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 be saturated 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.

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

Verilog code generation: Yes