Model AUTOSAR Classic Component and Elements in Simulink
AUTOSAR Blockset allows you to create an AUTOSAR classic software component from a Simulink® model and generate AUTOSAR-compliant C code for testing in Simulink or integrate into the AUTOSAR run-time environment.
You can create an AUTOSAR classic software component from a Simulink model in these ways:
Create an AUTOSAR software component from an existing Simulink model. For more information, see Create AUTOSAR Software Component in Simulink.
Import an AUTOSAR software component or composition from AUTOSAR XML (ARXML) files into a Simulink model. For more information, see Import AUTOSAR XML Descriptions Into Simulink.
Simulink to AUTOSAR Mapping
When you create an AUTOSAR software component from a Simulink model, Simulink converts its model elements to AUTOSAR elements. This table shows the mapping between Simulink modeling elements and their corresponding AUTOSAR elements.
Simulink Element | AUTOSAR Element |
---|---|
Entry-point function | Runnable |
Input port | Data-Read-Access or Inter-Runnable Variable |
Output port | Data-Write-Access or Inter-Runnable Variable |
State or signal line | Per-instance memory |
Model parameter | Constant memory or Shared parameter |
Model parameter argument | Port parameter or Per instance parameter |
Data store | Per instance memory |
Function caller | Client port and Operation |
Rate-Transition block | Inter-Runnable Variable |
Create AUTOSAR Software Component
Create an AUTOSAR classic software component from a Simulink model by performing these tasks.
Configure AUTOSAR Classic Platform
You can configure Simulink model to an AUTOSAR Classic Platform in two ways.
Open the Simulink model and set the System target file to
autosar.tlc
in Code Generation section of the model configuration parameters. Save the model and run the command:autosar.api.create(<modelName>,'default');
Open the Simulink model and click the AUTOSAR Component Designer app from the Apps tab.
Choose Component Type
After configuring the AUTOSAR Classic Platform, you can choose a component type from the AUTOSAR component quick start window. AUTOSAR software components are reusable building blocks of the AUTOSAR software. An AUTOSAR software component connects to an AUTOSAR run-time environment (RTE) to communicate with other AUTOSAR software components and software in the Basic Software (BSW) layer of the AUTOSAR software architecture. In Simulink, you represent AUTOSAR software components with Simulink model components such as model blocks referenced from a composition model.
AUTOSAR Blockset enables you to define these software component types.
Component Type | Description |
---|---|
Application | Implements a part of the software application, and can use all AUTOSAR communication mechanisms and services. |
Sensor-actuator | Provides the AUTOSAR signal representing the physical value of a sensor or actuator. |
Complex device driver | Models a function outside of the normal AUTOSAR BSW stack for complex or resource-critical sensor evaluation or actuator control. |
ECU abstraction | Contains references to the corresponding hardware elements and provides access to the specific I/O capabilities of the ECU. |
Service proxy | Acts as a proxy to provide access to internal services for one or more remote ECUs. |
Define Ports and Interfaces
An AUTOSAR component communicates through its ports with other AUTOSAR software components or BSW services. A port sends information to, or receives information from, its communication partners. Each port owned by the component maps to a communication interface, based on functional requirements of the component.
Ports enable software components to communicate with each other. AUTOSAR uses these types of ports.
Required port — Used when a software component receives or expects data from other entities.
Provided port — Used when a software component transmits or provides a service to other entities.
A port interface specifies the elements or operations that a port provides or requires.
To configure AUTOSAR communication for a component port, create an AUTOSAR interface and map the port to the interface, and then map Simulink elements, such as root inport or outport blocks, to the AUTOSAR port, as required by the type of interface. AUTOSAR Blockset enables you to define these interface types.
Interface Type | Description |
---|---|
Sender-receiver interface | A sender-receiver interface uses sender and receiver ports to exchange data in one direction between a software component and other software components or with BSW modules. A sender port is a provided port that writes data to one or more receivers. A receiver port is a required port that reads data from one or more senders. The
sender-receiver Interface defines
|
Mode-switch interface | A mode-switch interface notifies a software component of a mode. You cannot connect ports with a mode-switch interface across ECU boundaries. |
Client-server interface | A client-server interface defines the operations that are made available by the server and used by the client. A server port provides operations that can be invoked by one or more clients. The server waits for incoming communication requests from a client, performs the requested service, and dispatches a response to the request. A client port is a required port invoking the operations of one compatible server port. The client initiates the communication, requesting that the server perform a service, and transferring a parameter set if necessary. A call to an operation of a client-server interface can be either synchronous or asynchronous communication. In both cases, the client awaits a response from the server. |
Nonvolatile data interface | A nonvolatile data interface must belong to a nonvolatile Block software component. |
Parameter interface | A parameter interface enables parameter software components to access constant data, fixed data, or calibration data. The sensor and the receiver ports connected to parameter interface must be located on the same ECU, as the parameter software component type represents only memory containing the calibration parameter. |
Trigger interface | A software component can use a trigger interface to trigger another software component if there is no data to be exchanged, or if the trigger must have a fast response time. |
For more information, see Configure AUTOSAR Ports.
After you define the ports and interfaces, the Simulink model represents an AUTOSAR component. You can add AUTOSAR-specific elements such as:
Runnables — The RTE can activate a runnable through one or more
RTEEvents
. The RTE can communicate with other components by using the ports of its software component. For more information, see Configure AUTOSAR Runnables.Inter-runnable variables — Runnables inside an instance of a software component can exchange data by defining a
VariableDataPrototype
as an inter-runnable variable. You cannot access inter-runnable variables from outside their software component internal behavior. For more information, see Configure AUTOSAR Inter-Runnable Variables.
Configure AUTOSAR Elements and Properties
In Simulink, you can use the AUTOSAR Dictionary and the Code Mappings Editor separately or together to graphically configure an AUTOSAR software component and map Simulink model elements to AUTOSAR component elements. For more information, see AUTOSAR Component Configuration.
Using a tree format, the AUTOSAR Dictionary displays a mapped AUTOSAR component and its elements, communication interfaces, CompuMethods, SwAddrMethods, and XML options. Use the tree to select AUTOSAR elements and configure their properties. The exported ARXML descriptions, and potentially generated AUTOSAR-compliant C code, reflect the properties that you modify. For more information, see Configure AUTOSAR Elements and Properties.
Configure and Generate AUTOSAR Code
You can generate AUTOSAR-compliant C code and export ARXML descriptions from the AUTOSAR software component model.
Use Embedded Coder® to build the AUTOSAR software component model. Building a classic software component model generates C code and exports ARXML descriptions that comply with AUTOSAR Classic Platform specifications.
You can also configure AUTOSAR code generation to generate the C code and ARXML descriptions according to a specific AUTOSAR schema version, specify XML options sources, AUTOSAR package paths and platform types, and modify default AUTOSAR code generation options. For more information about schema version, see Generate XML file for schema version (Embedded Coder).
To configure AUTOSAR code generation parameters, in the Simulink model Configuration Parameters dialog, select Code Generation > AUTOSAR Code Generation Options.
To configure AUTOSAR XML export options, use the AUTOSAR Dictionary or the
autosar.api.getAUTOSARProperties
function.
For more information about configuring AUTOSAR Code Generation, see AUTOSAR XML Options Settings, autosar.api.getAUTOSARProperties
, and Configure AUTOSAR Code Generation.
See Create and Configure AUTOSAR Software Component for an example of creating an AUTOSAR classic software component, generating C code, and ARXML descriptions.
See Also
autosar.api.create
| autosar.api.getAUTOSARProperties
Related Examples
- Develop AUTOSAR Software Component Model
- Create and Configure AUTOSAR Software Component
- Create and Configure AUTOSAR Adaptive Software Component