V-Model for System Development with Simulink Variants - MATLAB & Simulink (original) (raw)
Simulink® is often used to model systems that represent a product line. The systems in a product line, although based on the same definition, can differ in several aspects. For example, consider a product line of passenger cars where each variant has different set of features. Instead of designing multiple models to represent all possible variants, you can use Simulink variants to model all the variations in a product line in a single model. 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 represents a development process. The model demonstrates the relationship between each phase of the development cycle on the left side and its associated validation phase on the right side. Simulink variants supports the V-model development process by providing variant capabilities from the System Level Model phase, down to Code Generation, and up to the Interaction and Test phase. In the System Level Model and Component phases, you can use variant blocks and variant parameters to capture structural and data variations. You can use the Variant Manager for Simulink to prevent invalid variant combinations and reduce the variant model to contain only the selected variants. The generated code contains the variations defined in the model and the components. In the Test phases, you can use the Simulink Design Verifier™ to generate test cases to identify hidden design errors and use Simulink Test™ to execute user-defined tests. Also, you can use Simulink Coverage™ to get coverage for all variants.
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 Model
- Components — Create Models with Structural Variations
- Components — Create Models with Parameter Value Variations
- Components — Create Models with Variations in Transition Paths
- Components — Create Models with Variations in Dimensions
- Components — Create Models with Variations in AUTOSAR Interfaces
- Components — Manage Structural Variations in a Model
- Generated Code
- Component Tests and System-Level Tests
System-Level Model
You can model variations for any component in a system architecture model. A component may have two or more than two variant options that represent 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 Architectures Visually (System Composer).
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. For more information, see What Are Variants and When to Use Them.
This section covers:
- Implement Structural Variabilities for Components
- Propagate Conditions from Variant Blocks Upstream and Downstream
- Control Visibility of Variant Regions
- Variant Controls in Structurally Varying Systems
- Control Variant Activation Times of Structurally Varying Systems
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.
Goal | Capability | 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 | Implement Variations in Separate Hierarchy Using Variant 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 andVariant Sink | Variant Source and Variant Sink Blocks in Car Wiper Motor Skeleton (Model:slexVariantWiper)Variant Source and Variant Sink Blocks |
Represent components that have a fixed common structure, but varying input and output interfaces. | Variant Subsystem | Adaptive 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 Sink | Provide Variation in Signal Source and Destination 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, andTerminate Function | Conditionally Execute Custom Initialize, Reinitialize, Reset, and Terminate Routines |
Conditionally execute trigger-driven functions (execution is controlled by external signal). | Enabled Subsystem,Triggered Subsystem,Enabled and Triggered Subsystem, and Using Function-Call Subsystems | Propagate Variant Conditions to Control Execution of Conditional Subsystems |
Conditionally execute Simulink functions (analogous to a function in procedural programming language). | Simulink Function | Conditionally Execute Simulink Functions |
Encapsulate Simulink models or subsystem files as variant choices and execute them conditionally. | Variant Subsystem | Propagate Variant Conditions to Enable or Disable Model or Subsystem References in Hierarchy |
Add or remove variant choices without modifying the model. | Variant Assembly Subsystem | Add or Remove Variant Choices of Variant Assembly Component Blocks Using External File (System Composer) |
Implement variations in real physical components. | Variant Connector (Simscape) | Model Variants in a Mechanical System Using Variant Connector Blocks (Simscape)Model Variants in an Electrical Circuit Using Variant Connector Blocks (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 Blocks | Switch 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 Blocks | Switch 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 Propagate Variant Conditions to Define Variant Regions with Variant Blocks.
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.
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.
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.
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
- Variant Controls for Varying Parameter Values
- Control Variant Activation Times of Varying Parameter Values
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.
For code generation capabilities, see Generate Code for Varying Parameter Values.
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, seeStorage Locations for Variant Control Variables (Operands) in Variant Parameters and Types of Variant Control Variables (Operands) in Variant Parameters.
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.
Components — Create Models with Variations in Transition Paths
You can control the transition to multiple design configurations within the Stateflow® charts using variant transitions.
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.
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).
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 for Simulink.
Generated Code
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.
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).
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.
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.
Component Tests and System-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 Use Simulink Design Verifier for Systematic Model Verification (Simulink Design Verifier).
You can further execute user-defined tests on both active and inactive variants in a model by using Simulink Test. If your model has variant configurations defined using Variant Manager for Simulink, you can use the configurations to run tests programmatically for variant paths in the model.