Main Content

Configure AUTOSAR Data Types

The AUTOSAR standard defines an approach to AUTOSAR data types in which base data types are mapped to implementation data types and application data types. Application and implementation data types separate application-level physical attributes, such as real-world range of values, data structure, and physical semantics, from implementation-level attributes, such as stored-integer minimum and maximum and specification of a primitive-type (integer, Boolean, real, and so on). For information about modeling data types, see Model AUTOSAR Data Types.

The software supports AUTOSAR data types in Simulink® originated and round-trip workflows:

  • For AUTOSAR components originated in Simulink, the software generates AUTOSAR application, implementation, and base types to preserve the information contained within Simulink data types.

  • For round-trip workflows involving AUTOSAR components originated outside MATLAB®, the ARXML importer and exporter preserve data type information and mapping for each imported AUTOSAR data type.

For AUTOSAR data types originated in Simulink, you can control some aspects of data type export. For example, you can control when application data types are generated, or specify the AUTOSAR package and short name exported for AUTOSAR data type mapping sets.

Control Application Data Type Generation

For AUTOSAR data types created in Simulink, by default, the software generates application base types only for fixed-point data types and enumerated date types with storage types. If you want to override the default behavior for generating application types, you can configure the ARXML exporter to generate an application type, along with the implementation type and base type, for each exported AUTOSAR data type. Use the XML options parameter ImplementationDataType Reference (XMLOptions property ImplementationDataTypeReference), for which you can specify the following values:

  • Allowed (default) — Allow direct reference of implementation types in the generated ARXML code. If an application data type is not strictly required to describe an AUTOSAR data type, use an implementation data type reference.

  • NotAllowed — Do not allow direct reference of implementation data types in the generated ARXML code. Generate an application data type for each AUTOSAR data type.

To set the ImplementationDataTypeReference property in the MATLAB Command Window, use an AUTOSAR property set function call similar to the following:

hModel = 'autosar_swc_expfcns';

To set the ImplementationDataTypeReference property in the AUTOSAR Dictionary, select XML Options. Select a value for parameter ImplementationDataType Reference. Click Apply.

Configure DataTypeMappingSet Package and Name

For AUTOSAR software components created in Simulink, you can control the AUTOSAR package and short name exported for AUTOSAR data type mapping sets. To configure the data type mapping set package for export, set the XMLOptions property DataTypeMappingPackage using the AUTOSAR Dictionary or the AUTOSAR property set function.

hModel = 'autosar_swc_expfcns';

The exported ARXML code uses the specified package. The default mapping set short-name is the component name ASWC prefixed to DataTypeMappingsSet.


You can specify a short name for a data type mapping set using the AUTOSAR property function addPackageableElement. The following example specifies a custom data type mapping set package and name using MATLAB commands.

% Add a new data type mapping set
modelName = 'autosar_swc_expfcns';
propObj = autosar.api.getAUTOSARProperties(modelName);
newMappingSetPath = '/myPkg/mySubpkg/MyMappingSets';
newMappingSetName = 'MappingSetName';
newMappingSet = [newMappingSetPath '/' newMappingSetName];

% Configure the component behavior to use the new data type mapping set
swc = get(propObj,'XmlOptions','ComponentQualifiedName');
ib = get(propObj,swc,'Behavior','PathType','FullyQualified');

% Force generation of application data types

% Build

The exported ARXML code uses the specified package and name, as shown below.


Initialize Data with ApplicationValueSpecification

To initialize AUTOSAR data objects typed by application data type, the AUTOSAR standard (R4.1 or later) requires AUTOSAR application value specifications (ApplicationValueSpecifications). Embedded Coder® provides the following support:

  • The ARXML importer uses ApplicationValueSpecifications found in imported ARXML files to initialize the corresponding data objects in the Simulink model.

  • Code generation exports ARXML code that uses ApplicationValueSpecifications to specify initial values for AUTOSAR data.

For AUTOSAR parameters typed by implementation data type, code generation exports ARXML code that uses NumericalValueSpecifications and (for enumerated types) TextValueSpecifications to specify initial values. If initial values for parameters specify multiple values, generated code uses ArrayValueSpecifications.

Related Examples

More About