Variant Subsystem, Variant Model, Variant Assembly Subsystem
Template subsystem containing Subsystem, Model, or Subsystem Reference blocks as variant choices
Libraries:
Simulink /
Ports & Subsystems
HDL Coder /
Ports & Subsystems
Description
The Variant Subsystem block enables you to include multiple implementations of a component in a separate hierarchy.
For example, suppose you want to simulate a model that represents a vehicle with three possible engine configurations: 2-cylinder gas, 4-cylinder gas, and 8-cylinder gas. You could implement each engine model as a separate subsystem inside the Variant Subsystem and then switch between the subsystems based on the Types of Variant Control Modes in Variant Blocks you select. For more information, see Introduction to Variant Controls.
Note
Only one implementation of a Variant Subsystem is active during simulation.
The Variant Subsystem block is a template preconfigured to contain two or more blocks to use as Variant choices. These choices represent multiple implementations of a system. Only one child block is active during model execution. The active child block is referred to as the active variant.
Each variant choice inside the Variant Subsystem block is associated with a Variant control mode and a Variant activation time. The variant control mode determines how to select the active variant. The variant activation time determines a time to activate the choices and to decide whether to include only the active choice or both active and inactive choices in the generated code.
A Variant Subsystem block can contain a mixture of Subsystem blocks, Model blocks, or Subsystem Reference blocks as variant choices. A Variant Subsystem block with only Model blocks as choices is called a Variant Model block. For more information, see Implement Variations in Separate Hierarchy Using Variant Subsystems. A Variant Subsystem block with Model or Subsystem Reference blocks as choices that can added or removed only from external files and not within the block is called a Variant Assembly Subsystem block.
Apart from the variant choices, you can include Inport, control port (Enable, Trigger, Reset, and Function-Call), Outport, or Connection Port (Simscape) blocks inside a Variant Subsystem block. There are no drawn connections between the blocks that are inside the Variant Subsystem blocks. Simulink® automatically wires the active variant to the Inport and Outport blocks of the Variant Subsystem during model compilation. The blocks representing variant choices can have input and output ports that differ in number from the input and output ports in the parent Variant Subsystem block. For more information, see Map Inports and Outports of Variant Choices in Variant Subsystem.
Using Variant Subsystem block allows you to:
Mix Subsystem, Model, and Subsystem Reference blocks as variant choices.
Model components that do not have similar interface. You can have different numbers of inports and outports for multiple variant choices inside a Variant Subsystem. However, the conditions listed in Map Inports and Outports of Variant Choices in Variant Subsystem must be met.
Establish a hierarchical block diagram, where the Variant Subsystem block is on one layer and the variant choices are on another layer.
Keeps functionally related blocks together.
Reduce the complexity of your model.
During model compilation, Simulink eliminates inactive blocks throughout the model, depending on the variant activation time you select.
The color and icon of the variant badge on the block icon changes depending on the values of the Variant activation time, Variant control mode, and Propagate conditions outside of variant subsystem parameters set on the block. For more information, see Variant Badges.
Variant Assembly Subsystem
A Variant Assembly Subsystem block enables you to add or remove its variant choices from external sources without modifying the model. A Variant Assembly Subsystem block can contain Model blocks, Subsystem Reference blocks, or both as its variant choices. You specify the source of variant choices in the block parameter dialog box once and then modify the source to add or remove the variant choices from the block. Unlike Variant Subsystem, you cannot manage the variant choices from inside the Variant Assembly Subsystem block. For more information, see Add or Remove Variant Choices of Variant Assembly Subsystem Blocks Using External Files.
Note
To convert a Variant Subsystem block to a Variant Assembly Subsystem block, follow the steps in Convert Variant Subsystem to Variant Assembly Subsystem.
Examples
Ports
During simulation, Simulink disables the inactive ports in a Variant Subsystem block.
Input
Output
Map Inports and Outports of Variant Choices in Variant Subsystem
A Variant Subsystem block allows you to use a combination of Subsystem, Model, or Subsystem Reference blocks as variant choices. The inputs that the Variant Subsystem block receives from upstream model components map to the input and output ports of the variant choices.
The blocks that represent variant choices can have input and output ports that differ in number from the input and output ports in the parent Variant Subsystem block. However, the following conditions must be met:
The variant choices must have same set of inports as the Variant Subsystem container block or it must be a subset of ports on the container block.
The variant choices must have same set of outports as the Variant Subsystem container block or it must be a subset of ports on the container block.
If the Variant Subsystem container block has control ports:
The type of control port blocks in all the variant choices must be same as the Variant Subsystem block. For example, you cannot use Enabled Subsystem and Function-Call Subsystem blocks as choices within a Variant Subsystem block.
The control port on the Variant Subsystem block and the corresponding control ports on its variant choices must have the same name. For example, if the name of the control port on the Variant Subsystem is
fcn
, then the name of the corresponding control ports on all its variant choices must also befcn
.
Parameters
Block Characteristics
Extended Capabilities
Version History
Introduced in R2010b