Map AUTOSAR Adaptive Elements for Code Generation
In Simulink®, you can use the Code Mappings editor and the AUTOSAR Dictionary separately or together to graphically configure an AUTOSAR adaptive software component and map Simulink model elements to AUTOSAR component elements. For more information, see AUTOSAR Component Configuration.
Use the Code Mappings editor to map Simulink model elements to AUTOSAR component elements from a Simulink model perspective. The editor display consists of tabbed tables, including Inports and Outports. Use the tables to select Simulink elements and map them to corresponding AUTOSAR elements. The mappings that you configure are reflected in generated AUTOSAR-compliant C++ code and exported ARXML descriptions.
Simulink to AUTOSAR Mapping Workflow
To map Simulink model elements to AUTOSAR adaptive software component elements:
Open a model for which AUTOSAR system target file
autosar_adaptive.tlc
is selected.Create or open a mapped view of the AUTOSAR model. In the model window, do one of the following:
From the Apps tab, open the AUTOSAR Component Designer app.
Click the perspective control in the lower-right corner and select Code.
If the model has not yet been mapped to an AUTOSAR software component, the AUTOSAR Component Quick Start opens. To configure the model for AUTOSAR component development, work through the quick-start procedure and click Finish. For more information, see Create Mapped AUTOSAR Component with Quick Start.
The model opens in the AUTOSAR Code perspective. This perspective displays the model and directly below the model, the Code Mappings editor.
The Code Mappings editor provides in-canvas access to AUTOSAR mapping information, with batch editing, element filtering, easy navigation to model elements and AUTOSAR properties, and model element traceability.
Navigate the Code Mappings editor tabs to perform these actions:
Map a Simulink inport or outport to an AUTOSAR required or provided port and a service interface event.
Map a Simulink data store to an AUTOSAR persistency provided-required port and a key value interface data element.
Use the Filter contents field (where available) to selectively display some elements, while omitting others, in the current view.
After mapping model elements, click the Validate button to validate the AUTOSAR component configuration. If errors are reported, address them, and then retry validation.
Map Inports and Outports to AUTOSAR Service Ports and Events
The Inports and Outports tabs of the Code Mappings editor support modeling AUTOSAR service interface communication in Simulink. After using the AUTOSAR Dictionary to create AUTOSAR required and provided service ports, service interfaces, and service interface events in your model, open the Code Mappings editor. Use the Inports and Outports tabs to map Simulink root inports and outports to AUTOSAR required and provided service ports and service interface events.
For more information, see Model AUTOSAR Adaptive Service Communication.
The Inports tab of the Code Mappings editor maps each Simulink root inport to an AUTOSAR required port and a service interface event. To map a Simulink inport, select the inport, and then select menu values for an AUTOSAR port and an AUTOSAR event among values listed for the component.
The Outports tab of the Code Mappings editor maps each Simulink root outport to an AUTOSAR provided port and a service interface event. In the Outports tab, you can:
Map a Simulink outport by selecting the outport, and then selecting menu values for an AUTOSAR port and an AUTOSAR event among values listed for the component.
Use the code attribute
AllocateMemory
to configure memory allocation for AUTOSAR adaptive service data. Specify whether to send event data by reference (the default) or byara::com
allocated memory. To send event data byara::com
allocated memory, select the valuetrue
. To send event data by reference, selectfalse
. For more information, see Configure Memory Allocation for AUTOSAR Adaptive Service Data.
Map Data Stores to AUTOSAR Persistent Memory Ports and Data Elements
The Data Stores tab of the Code Mappings editor supports modeling AUTOSAR persistent memory in Simulink. After using the AUTOSAR Dictionary to create AUTOSAR persistency provided-required ports, persistency key value interfaces, and key value interface data elements, open the Code Mappings editor. Use the Data Stores tab to map Simulink data stores to AUTOSAR persistency provided-required ports and key value interface data elements.
For more information, see Model AUTOSAR Adaptive Persistent Memory.
To map a Simulink data store, select a data store in the Data
Stores tab and, in the Mapped To menu,
select Persistency
. By default the data stores are mapped to
Auto
.
To configure the AUTOSAR persistency provided-required port and key value interface data element for the mapped data store, click the icon. A properties dialog box opens. Select menu values for Port and Data Element.
Attribute | Purpose |
---|---|
Port | Select the name of a persistency provided-required port configured in the AUTOSAR Dictionary. |
DataElement | Select the name of a persistency key value interface data element configured in the AUTOSAR Dictionary. |
Related Examples
- Model AUTOSAR Adaptive Service Communication
- Configure Memory Allocation for AUTOSAR Adaptive Service Data
- Model AUTOSAR Adaptive Persistent Memory
- Configure AUTOSAR Adaptive Elements and Properties
- Configure and Map AUTOSAR Component Programmatically