Main Content

V-Model for System Development with Simulink Variants

In Model-Based Design workflows, creating multiple design variations for system components are essential to meet different sets of requirements. These requirements can cater to diverse market needs, customer preferences, or geographical features. Throughout the system development life cycle, from requirements to deployment, you may need to switch between these choices. Simulink® variant capabilities allow you to create flexible models with built-in variabilities to more efficiently manage, configure, and reuse your designs. For information on Simulink variants basics, see What Are Variants and When to Use Them.

The V-model is a representation of system development life cycle applying a testing phase for each corresponding developing phase. Simulink Variants provide capabilities at various stages of the development process. The left side of the V-model identifies steps to develop system specifications, develop detailed-design software, and generate application code. The right side of the V-model focuses on the verification and validation of steps cited on the left side, including software and system integration. Depending on your application and its role in the process, you might focus on one or more of the steps called out in the V-model or repeat steps at several stages of the V-model.

These tables list goals that you might have as you apply variations in your model and guides you on how to meet those goals. You can open and run the examples linked below to apply variants and generate code. For a list of models that show variant capabilities in Simulink, see Simulink Variant Examples.

System-Level Design

You can model variations for any component in a system architecture model. A component may have two variant options that represent two alternate structural decompositions. You can also define a mix of behaviors (defined in a Simulink model) and architectures (defined in a System Composer™ architecture model) as variant choices. For more information on System Composer architecture models, see Compose Architecture Visually (System Composer).

GoalCapabilityExample
Add components with alternative structural designs in architecture model.Variant Component (System Composer)Create Variants (System Composer)
Manage systems with variations in structural components.Variant Manager OverviewImport Control Variables to Variant Configuration

Components — Create Models with Structural Variations

Once you understand your modeling requirements, you can begin to identify the varying components of the system. Identifying components and their relationships within a top-level structure help build a potentially complex model systematically. With variant blocks in Simulink you can design multiple design alternatives of a system in a single model. Each design choice is incorporated into the model as a variant choice. You can choose to activate or deactivate the variant choices as per your requirement during simulation. The inactive variant choices appear faded. For more information, see What Are Variants and When to Use Them.

This section covers:

Implement Structural Variabilities for Components

You can implement structural variabilities in all domains, including controls logic, state machines, flow charts, and physical plants by using variant blocks in your model. For more information on variant blocks, see Variant Blocks in Simulink.

GoalCapability Example

Encapsulate variations of a component in a separate in your model. You can encapsulate subsystem (virtual and non-virtual) blocks, model blocks, and subsystem reference blocks to conditionally execute them.

Variant Subsystem, Variant ModelVariant Subsystems
  • Represent all variations of a component at the same level in your model.

  • Represent components with variations in source or destination signals.

Variant Source and Variant Sink
Represent components that have a fixed common structure, but varying input and output interfaces.Variant Subsystem, Variant ModelAdaptive Interface for Variant Subsystems
Represent variations at the same level in your model and toggle between the variant choices using a simple toggle switch mechanism.Manual Variant Source and Manual Variant SinkProvide Variation at Source and Destination of a Signal Using Manual Variant Source and Manual Variant Sink Blocks

Conditionally execute event-driven functions on a model initialize, reset, and terminate events.

Initialize Function, Reset Function, and Terminate FunctionVariant Condition Propagation with Initialize, Reset, and Terminate Blocks

Conditionally execute trigger-driven functions (execution is controlled by external signal).

Enabled Subsystem, Triggered Subsystem, and Enabled and Triggered Subsystem
Using Function-Call Subsystems
Conditionally execute Simulink functions (analogous to a function in procedural programming language).Simulink Function
Merge output signals of conditionally executed Simulink functions.Using Function-Call SubsystemsVariant Function-Call Signals on Variant Subsystem Outport
Encapsulate Simulink models as variant choices and execute them conditionally.Variant Subsystem, Variant ModelModel Reference Variants

Implement variations in real physical components.

Variant Connector (Simscape)
  • Active variant is fixed before the simulation starts and does not change during intermediate stage of simulation.

  • Switch between active variants using strings with minimal data management.

Use label Mode in Variant BlocksSwitch Between Choices Using Labels in Variant Blocks
Create branches in your model that apply only to simulation or only to code generation.Use sim codegen switching Mode in Variant BlocksSwitch Between Choices for Simulation and Code Generation Workflows Without Using Control Variables in Variant Blocks

Propagate Conditions from Variant Blocks Upstream and Downstream

You can expand the variability control to any region of your model by automatically propagating variant conditions from variant blocks to other blocks upstream and downstream. Variant conditions can propagate through signal lines, buses, and function calls to reach blocks in a model affected by variant selection. For more information, see Variant Condition Propagation Overview.

GoalCapabilityExample
Improve accuracy of the model and avoid manual computation of variant conditions to assign to the dependent blocks by propagating the state of the underlying blocks outside of the parent variant block.Variant Subsystem, Variant ModelPropagate Variant Conditions Outside Variant Subsystems
Improve accuracy of the model and avoid manual computation of variant conditions to assign to the dependent blocks by propagating the state of the variant blocks to all its connected blocks. Variant Condition Propagation with Variant Sources and Sinks
Remove variant region completely from model execution when no variant is active.Allow zero active variant controlsPropagate Variant Conditions Outside Variant Subsystems
Stop propagating the state of variants upstream and downstream.Ground and TerminatorControl Variant Condition Propagation
Reduce visual complexity by propagating variant elements in composite signals.

Control Visibility of Variant Regions

You can control the visibility of variant regions by defining the variant control in appropriate workspaces as per your requirement. Limiting the scope helps avoid name conflicts and establish clear ownership of the variant controls between the blocks. It also enables you to use same names for variant controls in different scopes. For more information, see Storage Locations for Variant Control Variables (Operands) in Variant Blocks and Types of Operators in Variant Blocks for Different Activation Times.

GoalCapabilityExample
  • Create custom user interface for variants.

  • Prevent unintended modification of variant controls by encapsulating it behind a mask.

  • Use same names for variant controls in different masks by limiting the scope of controls.

Masking Fundamentals

  • Improve model portability by permanently storing variant controls that is local to the model.

  • Use same names for variant controls in different models by limiting the scope of controls.

Local Data: Model WorkspaceApproaches to Control Active Variant Choice of a Variant Block Using Mask or Model Workspace
Store global variant controls. Create a Simple Variant Model
Set different active variants for multiple instances of custom locked library block.Approaches to Control Active Variant Choice of a Variant Block Using Mask or Model WorkspaceControl Active Choice of Locked Custom Library Variant Subsystem Using Mask Parameter
Define global variant controls for multiple variant regions at different levels of a model.Data Store MemoryVariant Conditions and Data Stores

Variant Controls in Structurally Varying Systems

Each variant choice in your model is associated with a variant control. Variant controls determine which variant choice is active. By changing the value of a variant control, you can switch the active variant choice. You can use different types of variant controls variables while implementing variant regions in your model. For more information, see Types of Variant Control Variables (Operands) in Variant Blocks and Storage Locations for Variant Control Variables (Operands) in Variant Blocks.

GoalCapabilityExample

Rapidly prototype variant controls when you are still building your model.

Scalar variableScalar Variant Control Variables for Rapid Prototyping in Variant Blocks

  • Reuse common variant controls across models.

  • Reduce complexity of variant controls by encapsulating them.

Simulink.VariantSimulink.Variant Objects for Variant Condition Reuse of Variant Blocks

Improve readability by representing variant controls as meaningful names instead of integers.

Simulink Enumerations

Control Variant Activation Times of Structurally Varying Systems

Prior to simulation or code generation, you can check for incompatibilities, such as datatype and dimension mismatches in variants. You can design variants that can be activated in different stages of simulation and code generation workflows. During code generation, you can choose which variabilities to include in the generated code and activate them at different stages based on the requirements and the target platform. You can also check for incompatibilities, such as datatype and dimension mismatches in variants. For more information, see Activate Variant During Different Stages of Simulation and Code Generation Workflow.

Goal CapabilityExample

Retain active variant and remove inactive variant early in the model compilation stage, so that, the variants with incompatible signal attributes coexist in the simulation workflow.

update diagramConsider a scenario where you want to simulate only the active variant. You have installed all the products required to simulate the active variant, but you do not have licenses that are required to simulate inactive variants. In this case, you can use update diagram activation time to remove inactive variants from execution at the beginning of the simulation workflow.
Analyze active and inactive variants for incompatibilities in signal attributes such as dimension and data type prior to the simulation-loop stage.update diagram analyze all choicesActivate Variant During Different Stages of Simulation and Code Generation Workflow
  • Perform iterative simulations and enhance simulation speed without having to recompile the model or terminating the simulation each time you change the active variant.

startup

Components — Create Models with Parameter Value Variations

You may have a set of requirements where the structure of the model remains the same, but the values of the parameters for each requirement are different. You can create a single model with fixed structure and create parameters with a finite set of values where each value corresponds to different requirements. You can then choose to activate or deactivate the variant choices during simulation. For more information on value variations, see Use Variant Parameters to Reuse Block Parameters with Different Values.

This section covers:

Implement Variabilities in Parameter Values

You can implement value variabilities in all domains, including controls logic, state machines, flow charts, and physical plants by using variant parameters in your model.

Variant Controls for Varying Parameter Values

Variant controls are Simulink.VariantControl objects that associates the Value of a variant control with an ActivationTime. Use the variant control objects to determine the active value of a variant parameter during different stages of simulation and code generation workflow. You can specify different types of values for variant control objects while implementing variant regions in your model. For more information, see Storage Locations for Variant Control Variables (Operands) in Variant Parameters and Types of Variant Control Variables (Operands) in Variant Parameters.

GoalCapabilityExample

Rapidly prototype variant controls when you are still building your model.

Numeric valuesNumeric Variant Control Values for Rapid Prototyping of Variant Parameters

  • Reuse common variant controls across models.

  • Reduce complexity of variant controls by encapsulating them.

Simulink.VariantSimulink.Variant Objects for Variant Condition Reuse of Variant Parameters

Improve readability by representing variant controls as meaningful names instead of integers.

Simulink EnumerationsEnumerated Types to Improve Code Readability of Variant Control Variables of Variant Parameters

Improve readability by representing variant parameter values as meaningful names instead of integers.

Simulink EnumerationsImprove Code Readability of Variant Parameters Using Enumerated Types

Control Variant Activation Times of Varying Parameter Values

Prior to simulation or code generation, you can check for incompatibilities, such as datatype and dimension mismatches in variants. You can design variants that can be activated in different stages of simulation and code generation workflows. During code generation, you can choose which variabilities to include in the generated code and activate them at different stages based on the requirements and the target platform. You can also check for incompatibilities, such as datatype and dimension mismatches in variants. For more information, see Activate Variant During Different Stages of Simulation and Code Generation Workflow.

GoalCapabilityExample

Retain active variant and remove inactive variant early in the model compilation stage, so that, the variants with incompatible signal attributes coexist in the simulation workflow.

update diagramChange Active Values and Activation Time of Variant Parameters
Analyze active and inactive variants for incompatibilities in signal attributes such as dimension and data type prior to the simulation-loop stage.update diagram analyze all choices
Perform iterative simulations without having to recompile the model or terminating the simulation each time you change the active variant.startupRun Iterative Simulations Without Recompiling Model for Variant Systems Using Fast Restart

Components — Create Models with Variations in Transition Paths

You can control the transition to multiple design configurations within the Stateflow® charts using variant transitions.

GoalCapabilityExample
Conditionally execute transition path from source object to destination object.Conditions (Stateflow) andCondition Actions (Stateflow)Variant Lamp Design (Stateflow)

Components — Create Models with Variations in Dimensions

You can use symbolic dimensions to simulate various sets of dimension choices without regenerating code for every set. These symbols propagate throughout the model during simulation, and then go into the generated code.

GoalCapabilityExample
Store dimensions in symbols to flexibly switch between variant choices.Allow symbolic dimension specificationGenerate Code for Variant Subsystem with Child Subsystems of Different Output Signal Dimensions (Embedded Coder)
Create parameters with variants having different dimensions. Symbolic Dimensions in Generated Code (Embedded Coder)Compile Code Conditionally for all Values of Variant Parameters with Same and Different Dimensions
Store dimensions of AUTOSAR elements, such as a ports, in symbols to flexibly switch between variation points during code compilation.Variants for Array Sizes (AUTOSAR Blockset)Configure Dimension Variants for AUTOSAR Array Sizes (AUTOSAR Blockset)

Components — Create Models with Variations in AUTOSAR Interfaces

You can enable or disable AUTOSAR interfaces or implementations in the execution path using variation points in AUTOSAR software components. In Simulink, AUTOSAR system constants serve as inputs to control component variation points. Variation points present a choice between two or more variants. For more information, see Model AUTOSAR Variants (AUTOSAR Blockset).

GoalCapabilityExample
Enable or disable AUTOSAR ports and runnables.Variants for Ports and Runnables (AUTOSAR Blockset)Configure Variants for AUTOSAR Ports and Runnables (AUTOSAR Blockset)
Vary implementation of AUTOSAR runnable by specifying variant conditions inside the runnable.Variants for Runnable Implementations (AUTOSAR Blockset)Configure Variants for AUTOSAR Runnable Implementations (AUTOSAR Blockset)
Model AUTOSAR calibration data in combination with different types of variant conditions.Export Variation Points for AUTOSAR Calibration Data (AUTOSAR Blockset)
Import variation points in AUTOSAR software components.Predefined Variants and System Constant Value Sets (AUTOSAR Blockset)Control AUTOSAR Variants with Predefined Value Combinations (AUTOSAR Blockset)

Components — Manage Structural Variations in a Model

Variant Manager enables you to visually trace variations, manage variabilities simultaneously, and prevent invalid variant combinations in a system model or variant transitions in a Stateflow chart. You can also simplify a variant model by automatically reducing it to contain only the selected variants. For more information, see Variant Manager Overview.

GoalCapabilityExample

Visualize a tree view of a variant model hierarchy and edit properties of variant elements.

Model Hierarchy

Create Variant Configurations to represent combinations of variant choices across a model hierarchy.

Variant Manager OverviewCreate and Validate Variant Configurations

Define constraints for variant configurations to prevent invalid variant combinations.

ConstraintsDefine Constraints

Create a variant configuration data object to store, distribute, and reuse variant configurations for a model.

ConfigurationsExport, Save, Refresh, and Load a Variant Configuration Data Object

Validate and apply a variant configuration to a model early in the update diagram stage.

Activate a Variant ConfigurationCreate and Validate Variant Configurations

Automatically generate a reduced model that contains only selected variant configurations from a parent model with many variants.

Reduce Models Containing Variant BlocksReduce a Variant Model for Selected Variant Configuration

Visualize and compare variant configurations to locate and diagnose potential faults or inconsistencies in the configurations.

Analyze Variant Configurations in Models Containing Variant Blocks

Production Code Generation

You can include variabilities in generated code to reuse and configure the code for different stages of development, such as testing different implementations or providing multifunctional code to third parties.

Generate Code for Structurally Varying Systems

You can specify the variabilities of the variant blocks to be included in the generated code. You can also control the appearance, placement, definition, and declaration of variant controls in the generated code.

GoalCapabilityExample
Generate a code that contains active and inactive variants, and enables you to switch between the variants prior to code compile.code compile
Generate an executable that contains active and inactive variants, and enables you to switch between the variants at model startup.startup
Share variant controls among multiple blocks, separate values from their data types and other properties, control the appearance, placement, definition, and declaration of variant controls in the generated code.Simulink.ParameterSimulink.Parameter Type of Variant Control Variables for Code Generation in Variant Blocks

Improve code readability by representing variant controls as meaningful names instead of integers in generated code.

Simulink Enumerations

Generate Code for Varying Parameter Values

You can specify the variabilities of the variant parameters to be included in the generated code. You can also control the appearance, placement, definition, and declaration of variant controls and variant parameters in the generated code. For more information, see Options to Represent Variant Parameters in Generated Code (Embedded Coder).

GoalCapabilityExample
Generate a code that contains all variants and enables you to switch between the variants prior to code compile.code compileCompile Code Conditionally for all Values of Variant Parameters with Same and Different Dimensions
Generate an executable that contains all variants and enables you to switch between the variants at model startup.startupRun Executable for Different Variant Parameter Values Without Recompiling Code
Share variant controls among multiple blocks, separate values from their data types and other properties, control the appearance, placement, definition, and declaration of variant controls in the generated code. Simulink.Parameter Type of Variant Control Variables for Code Generation of Variant Parameters

Improve code readability by representing variant controls as meaningful names instead of integers.

Simulink EnumerationsEnumerated Types to Improve Code Readability of Variant Control Variables of Variant Parameters

Improve code readability by representing variant parameter values as meaningful names instead of integers.

Simulink EnumerationsImprove Code Readability of Variant Parameters Using Enumerated Types

Generate Code for Varying Transition Paths

You can use variant transitions to create Stateflow charts in Simulink models that generate code to be used in a variety of different software situations. Variant transitions allow you to model a full subset of variations within one Stateflow chart so that you can choose which variation you want when you generate code or when you compile the generated code.

GoalCapabilityExample
Generate code that only contains the data members needed to execute the currently selected software configuration.Code Generation Using Variant Transitions (Stateflow)Variant Lamp Design (Stateflow)

Generate Code for Varying Dimensions

You can use symbolic dimensions to simulate various sets of dimension choices without regenerating code for every set. These symbols propagate throughout the model during simulation, and then go into the generated code.

GoalCapabilityExample
Store dimensions in symbols to flexibly switch between variants during code compilation.Allow symbolic dimension specificationGenerate Code for Variant Subsystem with Child Subsystems of Different Output Signal Dimensions (Embedded Coder)
Store dimensions in automatically generated symbols to flexibly switch between variant parameter values during code compilation.Symbolic Dimensions in Generated Code (Embedded Coder)Compile Code Conditionally for all Values of Variant Parameters with Same and Different Dimensions
Store dimensions of AUTOSAR elements, such as a ports, in symbols to flexibly switch between variation points during code compilation.Variants for Array Sizes (AUTOSAR Blockset)Configure Dimension Variants for AUTOSAR Array Sizes (AUTOSAR Blockset)

Unit Tests and Subsystem- Level Tests

You can identify hidden design errors and detect model constructs in variants that result in integer overflow, dead logic, array access violations, and division by zero by generating test cases using Simulink Design Verifier™. For more information, see About Systematic Model Verification Using Simulink Design Verifier (Simulink Design Verifier).

GoalCapability Example
Analyze active variant to detect design errors and requirement violations by generating test cases for debugging.code compileSee SLDV Run workflow in Verify and Validate Variant Models with Code Compile Activation Time

Analyze active and inactive variants to detect design errors and requirement violations by generating test cases for debugging.

startupSee SLDV Run workflow in Verify and Validate Variant Models with Startup Activation Time

System Verification and Validation

You can use Simulink Test™ to execute user-defined tests on only active variant or both active and inactive variants in a model.

GoalCapability Example

Analyze only active variant and re-run the tests to analyze all variants.

code compileSee Simulink Test Manager workflow in Verify and Validate Variant Models with Code Compile Activation Time

Run iterative tests on active and inactive variants without recompiling the model for each variant.

startupSee Simulink Test Manager workflow in Verify and Validate Variant Models with Startup Activation Time

Related Topics