Main Content

V-Model for System Development with金宝appVariants

金宝app®通常用于模型系统,代表公关oduct 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, seeWhat 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 theSimulink Design Verifier™to generate test cases to identify hidden design errors and useSimulink Test™to execute user-defined tests. Also, you can useSimulink 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, seeSimulink Variant Examples.

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, seeCompose Architectures Visually(System Composer).

Goal Capability Example
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 for Simulink Create and Activate Variant Configurations

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, seeWhat 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, seeVariant 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, Variant Model 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 SourceandVariant Sink
Represent components that have a fixed common structure, but varying input and output interfaces. Variant Subsystem, Variant Model 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 SourceandManual Variant Sink Provide 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, andTerminate Function Variant Condition Propagation with Initialize, Reset, and Terminate Blocks

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

Enabled Subsystem,Triggered Subsystem, andEnabled and Triggered Subsystem
Using Function-Call Subsystems
Conditionally execute Simulink functions (analogous to a function in procedural programming language). 金宝app仿真软件的功能
Merge output signals of conditionally executed Simulink functions. Using Function-Call Subsystems Variant Function-Call Signals on Variant Subsystem Outport
Encapsulate Simulink models as variant choices and execute them conditionally. Variant Subsystem, Variant Model Model Reference Variants
Add or remove variant choices without modifying the model. Variant Assembly Subsystem Add or Remove Variant Choices of Variant Assembly Subsystem Blocks Using External Files

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 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, seeVariant Condition Propagation Overview.

Goal Capability Example
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 Model Propagate 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 controls Propagate Variant Conditions Outside Variant Subsystems
Stop propagating the state of variants upstream and downstream. GroundandTerminator Control 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, seeStorage Locations for Variant Control Variables (Operands) in Variant BlocksandTypes of Operators in Variant Blocks for Different Activation Times.

Goal Capability Example
  • 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 Workspace Approaches 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 Workspace Control 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 Memory Variant Conditions and Data Stores(Model)

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, seeTypes of Variant Control Variables (Operands) in Variant BlocksandStorage Locations for Variant Control Variables (Operands) in Variant Blocks.

Goal Capability Example
Switch variant choices in related blocks and parameters coherently. Simulink.VariantControl Simulink.VariantControl Variables for Coherent Switching of Choices in Variant Blocks

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

标量变量 Scalar Variant Control Variables for Rapid Prototyping in Variant Blocks

Reduce complexity of variant controls by encapsulating them.

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

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

Simulink Enumerations

Improve readability by grouping related variant controls in a structure.

struct Structures to Group Related Variant Control Variables of 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, seeActivate Variant During Different Stages of Simulation and Code Generation Workflow.

Goal Capability Example

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 diagram Consider 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 useupdate diagramactivation 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 choices Activate 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, seeUse 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 areSimulink.VariantControlobjects that associates theValue的控制的一个变体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 ParametersandTypes of Variant Control Variables (Operands) in Variant Parameters.

Goal Capability Example

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

Numeric values Numeric Variant Control Values for Rapid Prototyping of Variant Parameters

  • Reuse common variant controls across models.

  • Reduce complexity of variant controls by encapsulating them.

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

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

Simulink Enumerations Enumerated 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 Enumerations Improve 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, seeActivate Variant During Different Stages of Simulation and Code Generation Workflow.

Goal Capability Example

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 diagram Change 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. startup Run 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.

Goal Capability Example
Conditionally execute transition path from source object to destination object. Conditions(Stateflow)andCondition Actions(Stateflow) Create Variant Configurations in Stateflow Charts(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.

Goal Capability Example
存储在符号维度灵活切换选择ween variant choices. Allow symbolic dimension specification Generate 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

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, seeModel AUTOSAR Variants(AUTOSAR Blockset).

Goal Capability Example
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)
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)
Flexibly switch between AUTOSAR components after the code is compiled and deployed on an electronic control unit (ECU). Configure Postbuild Variant Conditions for AUTOSAR Software Components(AUTOSAR Blockset)
Flexibly switch between value combinations for AUTOSAR elements prior to code compile, or after the code is compiled and deployed on an ECU. Configure Variant Parameter Values for AUTOSAR Elements(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, seeVariant Manager for Simulink.

Goal Capability Example

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

Manage Variant Elements

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

Variant Manager for Simulink Create and Activate Variant Configurations

Define constraints for variant configurations to prevent invalid variant combinations.

Constraints on Variant Configurations Define Constraints for Variant Configurations

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

Variant Configuration Data Object Save and Reuse Variant Configurations Using Variant Configuration Data Object

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

Activate a Variant Configuration Create and Activate Variant Configurations

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

Reduce Variant Models Using Variant Reducer Reduce Model Containing Variant Blocks

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

Analyze Variant Configurations in Models Containing Variant Blocks

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

您可以指定b变种的可变性locks to be included in the generated code. You can also control the appearance, placement, definition, and declaration of variant controls in the generated code.

Goal Capability Example
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.Parameter Simulink.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, seeOptions to Represent Variant Parameters in Generated Code(Embedded Coder).

Goal Capability Example
Generate a code that contains all variants and enables you to switch between the variants prior to code compile. code compile Compile 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. startup Run 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 Enumerations Enumerated 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 Enumerations Improve 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.

Goal Capability Example
Generate code that only contains the data members needed to execute the currently selected software configuration. Generate C or C++ Code from Stateflow Blocks(Stateflow) Create Variant Configurations in Stateflow Charts(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.

Goal Capability Example
存储在符号维度灵活切换选择ween variants during code compilation. Allow symbolic dimension specification Generate 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)

Component Tests and System-Level Tests

您可以识别隐藏的设计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 usingSimulink Design Verifier. For more information, seeAbout Systematic Model Verification Using Simulink Design Verifier(Simulink Design Verifier).

You can further execute user-defined tests on both active and inactive variants in a model by usingSimulink Test.

Goal Capability Example
Analyze active variant to detect design errors and requirement violations by generating test cases for debugging. code compile SeeSLDV Runworkflow inVerify 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.

startup SeeSLDV Runworkflow inVerify and Validate Variant Models with Startup Activation Time

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

code compile SeeSimulink Test Managerworkflow inVerify and Validate Variant Models with Code Compile Activation Time

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

startup SeeSimulink Test Managerworkflow inVerify and Validate Variant Models with Startup Activation Time

Related Topics