Variant Subsystem, Variant Model
Template subsystem containing Subsystem, Model, or Subsystem Reference blocks as variant choices
- Library:
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: 4-cylinder gas, 6-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 Model blocks as choices is called a Variant Model block. For more information on these blocks, see Create Subsystems, Model, and Subsystem Reference.
Apart from the variant choices, you can include Inport, Outport, and 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, 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.
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, improving the runtime performance of your model.
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.
Ports
During simulation, Simulink disables the inactive ports in a Variant Subsystem block.