Model AUTOSAR Variants
AUTOSAR software components use variants to enable or disable AUTOSAR interfaces or implementations in the execution path, based on defined conditions. Variation points in a component present a choice between two or more variants. Components can:
Enable or disable an AUTOSAR port or runnable.
Vary the implementation of an AUTOSAR runnable.
Vary the array size of an AUTOSAR port.
Specify predefined variants and system constant value sets for controlling variants in the component.
In Simulink®, you can:
Import and export AUTOSAR ports and runnables with variants.
Model AUTOSAR variants.
To enable or disable an AUTOSAR port or runnable, use Variant Sink and Variant Source blocks.
To vary the implementation of an AUTOSAR runnable, use Variant Subsystem, Variant Model, Variant Assembly Subsystem blocks.
To vary the array size of an AUTOSAR port, use Simulink symbolic dimensions.
Resolve modeled variants by using predefined variants and system constant value sets imported from ARXML files.
AUTOSAR system constants serve as inputs to control component variation points. To model
system constants, use AUTOSAR.Parameter
data objects.
Variants for Ports and Runnables
AUTOSAR software components can use VariationPoint
elements to enable
or disable AUTOSAR elements, such as ports and runnables, based on defined conditions. In
Simulink, you can:
Import AUTOSAR ports and runnables with variation points.
The ARXML importer creates the required model elements, including Variant Sink and Variant Source blocks to propagate variant conditions and
AUTOSAR.Parameter
data objects to represent system constants with condition values.Model AUTOSAR elements with variation points.
To define variant condition logic and propagate variant conditions, use Variant Sink and Variant Source blocks.
To model AUTOSAR system constants and define condition values, use
AUTOSAR.Parameter
data objects with storage classSystemConstant
.
Run validation on the AUTOSAR configuration. The validation software verifies that variant conditions on Simulink blocks match the designed behavior from the imported ARXML files.
Export AUTOSAR ports and runnables with variation points.
For more information, see Configure Variants for AUTOSAR Elements.
Variants for Runnable Implementations
To vary the implementation of an AUTOSAR runnable, AUTOSAR software components can specify variant condition logic inside a runnable. In Simulink, to model variant condition logic inside a runnable:
Use Variant Subsystem, Variant Model, Variant Assembly Subsystem blocks to define variant implementations and their associated variant condition logic.
Use
AUTOSAR.Parameter
data objects to model AUTOSAR system constants and define condition values.
For more information, see Configure Variants for AUTOSAR Runnable Implementations.
Variants for Array Sizes
AUTOSAR software components can flexibly specify the dimensions of an AUTOSAR element, such as a port, by using a symbolic reference to a system constant. The system constant defines the array size of the port data type. The code generator supports models that include AUTOSAR elements with variant (symbolic) array sizes.
In Simulink, you can:
Import AUTOSAR elements with variant array sizes.
The ARXML importer creates the required model elements, including
AUTOSAR.Parameter
data objects with storage classSystemConstant
, to represent the array size values.Each block that represents an AUTOSAR element with variant array sizes references
AUTOSAR.Parameter
data objects to define its dimensions.
Model AUTOSAR elements with variant array sizes.
Create blocks that represent AUTOSAR elements.
To represent array size values, add
AUTOSAR.Parameter
data objects with storage classSystemConstant
.To specify an array size for an AUTOSAR element, reference an
AUTOSAR.Parameter
data object.
Modify array size values in system constants between model simulations, without regenerating code for simulation.
Generate C code and ARXML files with symbols corresponding to variant array sizes.
For more information, see Configure Dimension Variants for AUTOSAR Array Sizes.
Predefined Variants and System Constant Value Sets
To define the values that control variation points in an AUTOSAR software component, components use the following AUTOSAR elements:
SwSystemconst
— Defines a system constant that serves as an input to control a variation point.SwSystemconstantValueSet
— Specifies a set of system constant values.PredefinedVariant
— Describes a combination of system constant values, among potentially multiple valid combinations, to apply to an AUTOSAR software component.
Suppose that you have an ARXML specification of an AUTOSAR software component. If the
ARXML files also define a PredefinedVariant
or
SwSystemconstantValueSet
s for controlling variation points in the
component, you can resolve the variation points at model creation time. Specify a
PredefinedVariant
or SwSystemconstantValueSet
s with
which the importer can initialize SwSystemconst
data.
After model creation, you can run simulations and generate code based on the combination of variation point input values that you specified.
In Simulink, using the AUTOSAR property function
createSystemConstants
, you can redefine the
SwSystemconst
data that controls variation points without recreating
the model. You can run simulations and generate code based on the revised combination of
variation point input values.
Building the model exports previously imported PredefinedVariant
s and
SwSystemconstantValueSet
s to ARXML files.
For more information, see Control AUTOSAR Variants with Predefined Value Combinations.
Related Examples
- Configure Variants for AUTOSAR Elements
- Configure Variants for AUTOSAR Runnable Implementations
- Configure Dimension Variants for AUTOSAR Array Sizes
- Control AUTOSAR Variants with Predefined Value Combinations