Main Content

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 measurement and calibration.

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:

  1. Open an AUTOSAR model that contains signals or states that you want to generate arTypedPerInstanceMemory blocks for. This example uses model autosar_swc_counter.

  2. 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 and displays the signal attributes in the Property Inspector. Use the Property Inspector to modify the signal attributes. In the Mapped To drop-down list, select ArTypedPerInstanceMemory. For more information about signal code and calibration attributes, see Map Block Signals and States to AUTOSAR Variables.

  3. In the Signals/States tab, from the list of available states, select state X. Use the Property Inspector to modify the state attributes. In the Mapped To drop-down list, select ArTypedPerInstanceMemory.

When you generate code:

  • Exported ARXML files contain AR-TYPED-PER-INSTANCE-MEMORYS descriptions for signals and states that you configured as ArTypedPerInstanceMemory.

  • 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:

  1. Open an AUTOSAR model that contains data stores that you want to generate arTypedPerInstanceMemory blocks for. This example uses model autosar_bsw_sensor1.

  2. 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 and displays the data store attributes in the Property Inspector. Use the Property Inspector to modify the data store attributes. In the Mapped To drop-down list, select ArTypedPerInstanceMemory. For more information about data store code and calibration attributes, see Map 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 as ArTypedPerInstanceMemory.

  • 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.

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.

See Also

| | | | | |

Related Examples

More About