Visualize Variant Implementations in a Single Layer
Simulink® provides two blocks that you can use to propagate conditions throughout the model and visualize all possible implementations of variant choices in a model. These blocks are called Variant Source and Variant Sink.
When you compile the model, Simulink determines which variant control evaluates to
Simulink then deactivates blocks that are not tied to the variant control being
true and visualizes the active connections.
How Variant Sources and Sinks Work
The Variant Source block has one or more input ports and one output port. You can define variant choices as blocks that are connected to the input port so that, at most, one choice is active. The active choice is connected directly to the output port of the Variant Source and the inactive choices are eliminated during simulation.
The Variant Sink block has one input port and one or more output ports. You can define variant choices as blocks that are connected to the output port so that, at most, one choice is active. The active choice is connected directly to the input port of the Variant Sink, and the inactive choices are eliminated during simulation.
Connect one or more blocks to the input port of the Variant Source block or the output port of the Variant Sink block. Then, you define variant controls for each variant choice entering the Variant Source block and exiting the Variant Sink block. For more information, see Variant Condition Propagation with Variant Sources and Sinks.
Advantages of Using Variant Sources and Sinks
Using Variant Source and Variant Sink blocks in Model-Based Design provides these advantages:
The blocks enable the propagation of variant conditions throughout the model and allow you to visualize variant choices in a single layer of your model.
By visualizing all possible implementations of variant choices, you can improve the readability of your model.
During model compilation, Simulink eliminates inactive blocks throughout the model, improving the runtime performance of your model.
Variant sources and sinks provide variant component interfaces that you can use to quickly model variant choices.
Limitations of Using Variant Sources and Sinks
Variant Source and Variant Sink blocks work with time-based, function-call, or action signals. You cannot use SimEvents®, Simscape™ Multibody™, or other non-time-based signals with these blocks.
The code generation variant report does not contain Variant Source and Variant Sink blocks.