Engee documentation

Multiport Switch

Selects the output signal based on the control signal.

blockType: MultiPortSwitch

Multiport Switch

Path in the library:

/Basic/Signal Routing/Multiport Switch

Index Vector

Path in the library:

/Basic/Signal Routing/Index Vector

Description

Block Multiport Switch determines which of the several inputs to the block passes to the output, depending on the value of the signal at the first input. The first input is called the control input, and the rest are data inputs. The value of the control input determines which input data is passed to the output.

The table below shows how the unit interprets the control signal and determines which input signal will be transmitted to the output.

Control input

Rounding up

Configuring Data Port numbering

Block behavior during simulation

Indexing for selecting data entry

Out-of-range condition

Integer value

No

Zero-based contiguous

Numbering from scratch

The signal at the control input is less 0 or more than the number of data inputs minus one.

One-based contiguous

Numbering from one

The signal at the control input is less 1 or more than the number of data inputs.

Specify indices

Custom numbering

The signal at the control input does not correspond to any data input number.

Non-integer value

The block truncates the value to an integer by rounding towards zero.

Zero-based contiguous

Numbering from scratch

The rounded value of the input signal is less 0 or more than the number of data entries minus one.

One-based contiguous

Numbering from one

The rounded value of the input signal is less 1 or more than the number of data entries.

Specify indices

Custom numbering

The rounded value of the input signal does not correspond to any data input number.

Multiport Switch, configured as a block Index Vector

Index Vector it is a special configuration of the block Multiport Switch in which only one data input is set, and the control input is counted from zero. The block output is an element of the input vector, the index of which corresponds to the control input. For example, if the input vector is [18 15 17 10], and the control input is 3, then the element of the vector with the number 3 (starting from zero), equal to 10, becomes the value of the output signal.

To use the block Index Vector, set for the parameter Number of data ports meaning 1, and for the parameter Data port order meaning Zero-based contiguous.

How does the unit handle out-of-range control input

If the control signal is an integer and its value is less than typemax(Int), then it is assumed to be out of the acceptable range if it does not match any data input number. If the control signal is not an integer, then its value is assumed to be outside the acceptable range if the rounded value does not correspond to any data port index. In both cases, the behavior of the block depends on the settings. Data port for default case and Diagnostic for default case.

If the value of the control signal is greater than typemax(Int) the block converts the input value to an integer.

Modeling behavior

The following behavior applies only to the simulation of the model.

Data port for default case

Diagnostic for default case

No

Error

Last data port

The last data input is used and no warnings or errors appear.

An error message appears and the simulation stops.

Additional data port

An additional data input with a label is used. * and there are no warnings or errors.

An error message appears and the simulation stops.

Behavior during code generation

The following behavior applies to code generation from the model.

Data port for default case

Diagnostic for default case

No

Error

Last data port

The last data input is used.

The last data input is used.

Additional data port

An additional data input with a label is used. *.

An additional data input with a label is used. *.

Rules governing the behavior of the block

The number of data inputs is set by the parameter Number of data ports.

  • If you ask Number of data ports an equal 1, then the block behaves like a block Selector, not how Multiport Switch.

  • If you ask Number of data ports more 1, then the block behaves like Multiport Switch. The output of the block represents the input signal, the number of which corresponds to the value of the control input. If at least one of the input signals is a vector, the output of the block is a vector. In this case, the block expands any scalar input parameters to vectors.

  • If all the input signals are scalar, the output signal is also scalar.

Assumptions and limitations

  1. If the input signals of the block are buses, then their structure on different ports (names, types, and dimensions) must completely match. To ensure that the output bus has the same structure, regardless of which input bus the unit chooses, it is forbidden to mix buses with ordinary signals.

  2. For working with tires, the parameter value is Number of data ports It should be at least 2.

  3. For buses, the control signal must be a scalar.

Read more about the types of tires. Custom tire types.

Ports

Entrance

# IN_1 — control signal

+ scalar | vector | the matrix

Details

A control signal that determines which of the input signals passes to the output.

Data types

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

Support for complex numbers

Yes

# 1 is the first input signal

+ scalar | vector | the matrix | the tire

Details

The first data input is in the form of a scalar, vector, matrix, array, or bus.

  • If all the input signals are scalars, then the output signal is also a scalar.

  • If at least one of the input signals is a vector, the output of the block is a vector. In this case, the block extends any scalar input signals to vectors.

Dependencies

For working with tires, the parameter value is Number of data ports it must be ≥ 2.

Data types

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

Support for complex numbers

Yes

# 2 is the second input signal

+ scalar | vector | the matrix | the tire

Details

The second data input is in the form of a scalar, vector, matrix, array, or bus.

  • If all the input signals are scalars, then the output signal is also a scalar.

  • If at least one of the input signals is a vector, the output of the block is a vector. In this case, the block extends any scalar input signals to vectors.

Dependencies

For working with tires, the parameter value is Number of data ports it should be ≥ 2.

Data types

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

Support for complex numbers

Yes

# * — data input for out-of-range control signal value

+ scalar | vector | the matrix | the tire

Details

An input data port for an out-of-range control signal value in the form of a scalar, vector, matrix, array, or bus.

All signals on the data inputs can have any data type that Engee supports.

Dependencies

To create an additional input port for the out-of-range control signal value, set the parameter Data port for default case meaning Additional data port. When you set for the parameter Data port for default case meaning Last data port, the block uses the last data port for output when the value of the control signal does not match any data port indexes.

For working with tires, the parameter value is Number of data ports it must be ≥ 2.

Data types

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

Support for complex numbers

Yes

Parameters

BaseSettings

# Data port order — type of data port numbering
Zero-based contiguous | One-based contiguous | Specify indices

Details

Sets the type of numbering of data ports.

  • Zero-based contiguous — The unit starts counting the input ports from zero. This is the default value for the Index Vector block.

  • One-based contiguous — The unit starts counting the input ports from one. This is the default value for the block Multiport Switch.

  • Specify indices — the block uses an arbitrary numbering of data ports.

Dependencies

  • Choice Zero-based contiguous or One-based contiguous includes the parameter Number of data ports.

  • Choice Specify indices includes the parameter Data port indices (e.g. [1,[2,3]]).

Values

Zero-based contiguous | One-based contiguous | Specify indices

Default value

Program usage name

DataPortOrder

Tunable

No

Evaluatable

No

# Number of data ports — number of data entry ports
Int64 integer

Details

Sets the number of data ports. The total number of input ports is the number you specify, plus one for the control signal input port and plus one more if you set for Data port for default case meaning Additional data port.

Dependencies

To use this parameter, set for the parameter Data port order meaning Zero-based contiguous or One-based contiguous.

Default value

Program usage name

Inputs

Tunable

No

Evaluatable

Yes

# Data port indices (e.g. [1,[2,3]]) — array of indexes for data ports

Details

Sets an array of indexes of data inputs. The block icon will change to match the data port indexes you specified.

Dependencies

To use this parameter, set for the parameter Data port order meaning Specify indices.

Default value

[1, 2, 3]

Program usage name

DataPortIndices

Tunable

Yes

Evaluatable

Yes

# Data port for default case — input port in case the control signal value is out of range
Last data port | Additional data port

Details

Determines whether to use the last data port in case the control signal value is out of range or to use an additional port. An asterisk (*) next to the port name indicates the port that the block uses when the value of the control input does not match any data port index.

  • Last data port — the block uses the last data port for output when the value of the control signal does not match any index of the data port.

  • Additional data port — the block uses an additional data port for output when the value of the control signal does not correspond to any index of the data port.

If you set this parameter to Additional data port and Number of data ports If the value is 3, then the number of input ports in the block will be 5. The first input is the control port, the next three inputs are the data ports, and the fifth input is the default port in case the control signal value is out of range.
Values

Last data port | Additional data port

Default value

Last data port

Program usage name

DataPortForDefault

Tunable

No

Evaluatable

No

# Diagnostic for default case — diagnostic action
None | Error

Details

Defines the diagnostic action to be taken if the control port value does not match any of the data port indexes. Options include:

  • None — the system is not taking any action.

  • Error — the simulation stops and an error is displayed. In this case Data port for default case It is used only for code generation, not modeling.

Values

None | Error

Default value

Error

Program usage name

DiagnosticForDefault

Tunable

No

Evaluatable

No

Output settings

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

Details

Specify the type of output data. You can ask:

  • Data type inheritance Inherit: auto.

  • An embedded data type, for example, Float32.

  • Fixed point data type Fixed-point.

Values

Inherit: auto | Same as first data 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 type
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

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

# Require all data port 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

Additional options

C code generation: Yes