Configure AUTOSAR Per-Instance Memory
To model AUTOSAR per-instance memory (PIM) for AUTOSAR applications, you import per-instance memory definitions from ARXML files or create per-instance memory content in Simulink®. For information about the high-level PIM workflow, see Per-Instance Memory.
AUTOSAR typed per-instance memory (ArTypedPerInstanceMemory
) defines an AUTOSAR typed memory block that is available for each instance of an AUTOSAR software component. In the AUTOSAR run-time environment, calibration tools can access arTypedPerInstanceMemory
blocks for calibration and measurement.
To model AUTOSAR PIM, you can use Simulink block signals, discrete states, or data stores in your model.
Configure Block Signals and States as AUTOSAR Typed Per-Instance Memory
To generate arTypedPerInstanceMemory
blocks for Simulink block signal and discrete state data in your AUTOSAR model, open the Code Mappings editor and select the Signals/States tab. Select signals and states and map them to arTypedPerInstanceMemory
. For example:
Open an AUTOSAR model that contains signals or states for which you want to generate
arTypedPerInstanceMemory
blocks. This example uses modelautosar_swc_counter
.In the AUTOSAR Code perspective, open the Code Mappings editor and select the Signals/States tab. In the list of available signals, select
sum_out
. Selecting a signal highlights the signal in the model diagram. In the Mapped To drop-down list, selectArTypedPerInstanceMemory
. To view and modify AUTOSAR attributes for the per-instance memory, click the icon. For more information about signal code and calibration attributes, see Map Block Signals and States to AUTOSAR Variables. If you are mapping signals and states in a submodel referenced by a component, see Map Submodel Signals and States to AUTOSAR Variables.In the Signals/States tab, from the list of available states, select state
X
. In the Mapped To drop-down list, selectArTypedPerInstanceMemory
. To view and modify AUTOSAR attributes for the per-instance memory, click the icon.
When you generate code:
Exported ARXML files contain
AR-TYPED-PER-INSTANCE-MEMORYS
descriptions for signals and states that you configured asArTypedPerInstanceMemory
.Generated C code contains
Rte_Pim_*
API calls for signal and state variables.
For referenced models within an AUTOSAR component model, Embedded Coder® maps internal signals and states for model reference code generation. Internal signals and states map to AUTOSAR ArTypedPerInstanceMemory
for multi-instance model reference or to AUTOSAR StaticMemory
for single-instance model reference.
Configure Data Stores as AUTOSAR Typed Per-Instance Memory
To generate arTypedPerInstanceMemory
blocks for Simulink data store memory blocks in your AUTOSAR model, open the Code Mappings editor and select the Data Stores tab. Select data stores and map them to arTypedPerInstanceMemory
. For example:
Open an AUTOSAR model that contains data stores that you want to generate
arTypedPerInstanceMemory
blocks for. This example uses modelautosar_bsw_sensor1
.In the AUTOSAR Code perspective, open the Code Mappings editor and select the Data Stores tab. In the list of available data stores, select data store
LowSetPoint
. Selecting a data store highlights the data store memory block in the model diagram. In the Mapped To drop-down list, selectArTypedPerInstanceMemory
. To view and modify AUTOSAR attributes for the per-instance memory, click the icon. For more information about data store code and calibration attributes, see Map Data Stores to AUTOSAR Variables. If you are mapping data stores in a submodel referenced by a component, see Map Submodel Data Stores to AUTOSAR Variables.
When you generate code:
Exported ARXML files contain
AR-TYPED-PER-INSTANCE-MEMORYS
descriptions for data stores that you configured asArTypedPerInstanceMemory
.Generated C code contains
Rte_Pim_*
API calls for data store variables.
When you build your model, the XML files that are generated define an exclusive area for each Data Store Memory block that references per-instance memory. Every runnable that accesses per-instance memory runs inside the corresponding exclusive area. If multiple AUTOSAR runnables have access to the same Data Store Memory block, the exported AUTOSAR specification enforces data consistency by using an AUTOSAR exclusive area. With this specification, the runnables have mutually exclusive access to the per-instance memory global data, which prevents data corruption.
In the AUTOSAR attributes of the per-instance memory, if you select needsNVRAMAccess, a SERVICE-NEEDS
entry is declared in XML files. The entry indicates that the per-instance memory is a RAM mirror block and requires service from the NvM
manager module. For more information about modeling software component access to AUTOSAR nonvolatile memory, see Model AUTOSAR Nonvolatile Memory.
Configure Data Stores to Preserve State Information at Startup and Shutdown
To facilitate bottom-up and round-trip workflows, you can configure NVRAM block state data to be read out at startup and written away at shutdown by configuring the NVBlockNeeds properties RestoreAtStart
and StoreAtShutdown
. To set these properties, you must configure your model data stores as ArTypedPerInstanceMemory
and set the property needsNVRAMAccess
as true
.
To set these parameters interactively, you can use the Code Mappings editor by selecting the pencil icon , or by using theNvBlockNeeds section of the Property Inspector:
To configure these parameters programmatically, you can configure the mapping object by using the getDataStore
function:
mappingObj = autosar.api.getSimulinkMapping(modelName); mappingObj.mapDataStore(dsmBlockPath, 'ArTypedPerInstanceMemory', ... 'NeedsNVRAMAccess', 'true', ... 'RestoreAtStart', 'true', ... 'StoreAtShutdown', 'true');
See Also
getDataStore
| getSignal
| getState
| mapDataStore
| mapSignal
| mapState
| Data Store Memory
Related Examples
- Map Block Signals and States to AUTOSAR Variables
- Map Submodel Signals and States to AUTOSAR Variables
- Map Data Stores to AUTOSAR Variables
- Map Submodel Data Stores to AUTOSAR Variables
- Model AUTOSAR Component Behavior