Main Content

Simulate AUTOSAR Adaptive Software Component and Optionally Generate Code (Requires Embedded Coder)

After you configure the AUTOSAR adaptive software component model for use in the Simulink® environment, simulate model my_autosar_LaneGuidance, which you configured in Configure Elements of AUTOSAR Adaptive Software Component for Simulink Modeling Environment.

  1. If not already open, open your configured version of model my_autosar_LaneGuidance.

  2. In the Simulink Coder™ Editor, click the Simulate button .

If you have access to Simulink Coder and Embedded Coder® software, you can build an AUTOSAR adaptive model. When you build an AUTOSAR adaptive model, the code generator produces C++ code that complies with the AUTOSAR standard for the Adaptive Platform and ARXML descriptions.

  1. If not already open, open your configured version of model my_autosar_LaneGuidance.

  2. Initiate code generation by pressing Ctrl+B. The code generator produces C++ code and ARXML files. The generated code complies with the AUTOSAR standard so that you can schedule the code with the AUTOSAR run-time environment.

    The code generator also produces and displays a code generation report.

  3. In the code generation report, review the generated code. In your current MATLAB® folder, the my_autosar_LaneGuidance_autosar_adaptive folder contains the primary files listed in this table.

    Generated Code Files

    FilesDescription
    my_autosar_LaneGuidance.cppContains entry points for the code that implements the model algorithm. This file includes the rate scheduling code.
    my_autosar_LaneGuidance.hDeclares model data structures and a public interface to the model entry points and data structures.
    my_autosar_LaneGuidance.arxml
    my_autosar_LaneGuidance_ExecutionManifest.arxml
    my_autosar_LaneGuidance_ServiceInstanceManifest.arxml
    The main ARXML file contains elements and objects that represent AUTOSAR software components, ports, interfaces, data types, and packages. The manifest files provide deployment-related and service-configuration information. You integrate ARXML files into an AUTOSAR run-time environment. You can import ARXML files into the Simulink environment by using the AUTOSAR ARXML importer tool.
    main.cppProvide a framework for running adaptive software component service code.

    By default, AUTOSAR Blockset code generation uses platform types directly in the generated code. If needed for support of legacy implementations, you can use the Data Type Replacement configuration parameter to specify that the code generator define platform types through an intermediate layer in terms of type definitions in the Simulink data type header file rtwtypes.h. (since R2023b)

    Before R2023b: AUTOSAR Blockset code generation created and required the support file rtwtypes.h.

  4. Open and review the Code Interface Report. This information is captured in the ARXML files. The run-time environment generator uses the ARXML descriptions to interface the code into an AUTOSAR run-time environment.

    Entry-point functions

    • Initialization entry-point function — void my_autosar_LaneGuidanceModelClass::initialize(). At startup, call this function once.

    • Output entry-point function — void my_autosar_LaneGuidanceModelClass::step(). Call this function periodically, every 0.1 seconds.

    • Termination entry-point function — void my_autosar_LaneGuidanceModelClass::terminate(). At shutdown, call this function once.

    Input ports:

    • Block leftLaneDistance — Require port, interface: sender-receiver of type real-T of 1 dimension

    • Block leftTurnIndicator — Require port, interface: sender-receiver of type real-T of 1 dimension

    • Block rightLaneDistance — Require port, interface: sender-receiver of type real-T of 1 dimension

    • Block rightTurnIndicator — Require port, interface: sender-receiver of type real-T of 1 dimension

    • Block leftCarInBlindSpot — Require port, interface: sender-receiver of type real-T of 1 dimension

    • Block rightCarInBlindSpot — Require port, interface: sender-receiver of type real-T of 1 dimension

    Output ports:

    • Block leftHazardIndicator — Port defined externally of type real-T of 1 dimension

    • Block rightHazardIndicator — Port defined externally of type real-T of 1 dimension

  5. Check whether the configuration changes that you made appear in the generated code by using the Code panel in the Code perspective. To open the Code panel, on the AUTOSAR tab, click View Code. The Code panel opens to the right of the model.

    With file my_autosar_LaneGuidance.cpp selected, in the search field, type company (one of the namespace values that you defined for the service interfaces). The Code view highlights instances of company, showing how the namespace symbols are applied in the code.

  6. Use the Code perspective Code panel to explore other aspects of the generated code. For example, if you select file my_autosar_LaneGuidance.cpp, and then click in the search field, a list of links to code elements appear. Use the links to quickly navigate to key areas of the generated code.

Related Topics