Documentation

Variant Subsystem, Variant Model

Template subsystem containing Subsystem blocks as variant choices

  • Library:
  • Simulink / Ports & Subsystems

Description

The Variant Subsystem and Variant Subsystem blocks each can have one active choice for simulation. The Variant Subsystem block is a template preconfigured to contain two Subsystem blocks to use as variant systems. The Variant Model block is a template preconfigured to contain two Model blocks to use as variant systems. The Variant Subsystem and Variant Model blocks (variant system container blocks) can containa mixture of Subsystem and Model blocks as variant systems. The variant system container blocks can also include Inport, Outport, and Connection Port blocks. There are no drawn connections inside the variant system container blocks.

Each variant system is associated with a variant control that is created in the base workspace. The variant control determines which variant system is active. The variant control can be a condition expression, a Simulink.Variant object specifying a condition expression, or a default variant. The variant control that evaluates to true determines the active variant.

When you select the Specify output when source is unconnected option in the Outport block that is in a variant subsystem container block, you can specify a nonground value as its output. Specify the data type in the Signal Attributes section of the Outport block dialog box.

Note

If you need to use variant systems that are conditionally executed models (models with control ports), then use a Model block as a container for variant models. Otherwise, use a Subsystem Variant or Model Variant block to contain variant systems. Support for using a Model block to contain model variants will be removed in a future release.

For new models, use a Model block for model variants only if you need to use variants that are conditionally executed models (referenced models with control ports). Using a Model block for variant models is supported for backward compatibility. However, support for using a Model block to contain model variants will be removed in a future release. For an example of a model that uses a Variant Subsystem block as a container for variant models, see Model Reference Variants.

Ports

During simulation, Simulink® disables the inactive ports in a variant subsystem container block.

Input

expand all

Each Subsystem or Model block contained within a variant subsystem represents one variant system. If the inport names on a variant system are a subset of the inport names used by the variant subsystem container block, then variant system blocks can have different numbers of inports than the variant subsystem container block has.

Output

expand all

Each Subsystem or Model block contained within a variant subsystem represents one variant system. If the outport names on a variant system are a subset of the outport names used by the variant subsystem container block, then variant system blocks can have different numbers of outports than the variant subsystem container block has.

Parameters

expand all

The table has a row for each variant system contained in the variant subsystem. If there are no variant systems, the table is empty.

You can use buttons to the left of the Variant choices table to modify the elements in the table.

To...Click...
Create and add a new subsystem choice: Place a new subsystem variant choice in the table and create a Subsystem block in the variant subsystem container block diagram.
Create and add a new model variant choice: Place a new model variant choice in the table and create a Model block in the variant subsystem container block.
Create/Edit selected variant object: Create a Simulink.Variant object in the base workspace and open the Simulink.Variant object parameter dialog box to specify the variant Condition.
Open selected variant choice block: Open the subsystem block diagram for the selected row in the Variant choices table.
Refresh dialog information from Variant Subsystem contents: Update the Variant choices table according to the variant system and values of the variant control in the base workspace.

This read-only field is based on the variant system name. To add a subsystem variant choice, click . To add a model variant choice, click .

To enter a variant name, double-click a Variant control cell in a new row and type in the variant control expression.

Programmatic Use

Structure field: Represented by the read-only variant.Name field in the Variant parameter structure
Type: character vector
Value: Variant control that is associated with the variant choice
Default: ''

This read-only field is based on the condition for the associated variant control in the base workspace. Create or change a variant condition in the Simulink.Variant parameter dialog box or in the base workspace.

To choose the active variant based on the evaluation of the variant conditions, use the default (off) . To choose the active variant based on the value specified in the Variant parameter, select the Override variant conditions and use following variant parameter.

For Override variant conditions and use following variant option, the variant control need not be a Boolean condition expression or a Simulink.Variant object. Variant controls that start with a % symbol are ignored.

When you select this option, the variant badge indicates the change.

Dependencies

This parameter enables the Variant parameter.

Programmatic Use

Parameter: OverrideUsingVariant
Type: character vector
Value: '' if no overriding variant is specified
Default: ''

If you select Override variant conditions and use following variant, specify the name of the variant to use. The variant name must be valid MATLAB® identifier.

For Override variant conditions and use following variant option, the variant control need not be a boolean condition expression, or a Simulink.Variant object. Variant controls that start with a % symbol are ignored.

Tip

You can use the Variant drop-down list to see a list of variant controls that are specified in the variant choice section.

Dependencies

To enable this parameter, select the Override variant conditions and use the following variant parameter.

Programmatic Use

Parameter: OverrideUsingVariant
Type: character vector
Value: character vector specifying the variant control expression
Default: ''

To simulate a model (containing a variant system) without an active variant choice, select the Allow zero active variant controls option. When you select this option and there is no active variant choice, Simulink disables all the blocks connected to the input and output stream of variant subsystem container block. The disabled blocks are ignored from update diagram or simulation.

If you do not select this option, Simulink generates an error when there is no active variant choice.

Dependencies

  • No (default) option of variant is selected

  • Override variant conditions and use following variant is cleared ('off')

Programmatic Use

Parameter: AllowZeroVariantControls
Type: character vector
Value: 'off' 'on'
Default: 'off'

When generating code for an ERT target, this parameter determines whether variant choices are enclosed within C preprocessor conditional statements (#if).

When you select this option, Simulink analyzes all variant choices during an update diagram or simulation. This analysis provides early validation of the code generation readiness of all variant choices.

When you select this option, the variant badge indicates the change.

Dependencies

  • The check box is available for generating only ERT targets.

  • Override variant conditions and use following variant is cleared ('off').

Programmatic Use

Parameter: GeneratePreprocessorConditionals
Type: character vector
Value: 'off' 'on'
Default: 'off'

When you select this option, Simulink propagates the variant conditions outside of the variant subsystem container block to determine which components of the model are active during simulation.

When you select this option, the variant badge indicates the change.

Programmatic Use

Parameter: PropagateVariantConditions
Type: character vector
Value: 'off' 'on'
Default: 'off'

Block Characteristics

Data Types

double[a] | single[a] | Boolean[a] | base integer[a] | fixed point[a] | enumerated[a] | bus[a]

Multidimensional Signals

Yes[a]

Variable-Size Signals

Yes[a]

[a] 

Actual data type or capability support depends on block implementation.

Extended Capabilities

HDL Code Generation
Generate Verilog and VHDL code for FPGA and ASIC designs using HDL Coder™.

Introduced in R2010b

Was this topic helpful?