Contenu principal

Verify AUTOSAR Adaptive Software Component Code With SIL

R2026b

To verify generated algorithmic C++ code for AUTOSAR Adaptive software components, you use software-in-the-loop (SIL) simulations. For more information about SIL simulations, see SIL and PIL Simulations (Embedded Coder).

To verify that the algorithm code generated for software components in an AUTOSAR Adaptive software architecture is consistent with the algorithm you modeled in Simulink®,use this general workflow:

  1. Link the software component whose code you want to verify to an Adaptive Component block in an AUTOSAR Adaptive software architecture model (requires System Composer™).

    For more information on linking models to Adaptive Component blocks, see Define AUTOSAR Component Behavior by Creating or Linking Models.

  2. If you are not working in a Linux® environment, set configuration parameter Enable portable word sizes (Embedded Coder) to true for the software architecture and the AUTOSAR Adaptive software component.

  3. Set Simulation mode for the Adaptive Component to Software-in-the-loop (SIL).

    Alternatively, you can set the Simulation mode programmatically.

    set_param("AUTOSARArch/SWC","SimulationMode","software-in-the-loop (sil)");

  4. From the top-level of the AUTOSAR Adaptive software architecture, open the SIL/PIL Manager (Embedded Coder). From the SIL/PIL tab, click Run Verification in the Simulink toolstrip.

  5. In the Mode section of the toolstrip, select Automated Verification. The software automatically runs a SIL simulation. When the SIL simulation finishes, the Simulation Data Inspector opens and displays the results.

Run SIL Simulation for AUTOSAR Adaptive Components in AUTOSAR Software Architecture

This example shows how to configure an AUTOSAR Adaptive software architecture and its referenced components for software-in-the-loop (SIL) simulation to verify the generated C++ code for each AUTOSAR Adaptive software component in the architecture.

Open example architecture model adaptive_BrakeControlSystem.

openExample("adaptive_BrakeControlSystem");

AUTOSAR Adaptive software architecture model showing Sensors composition, Controller, Actuator, and Speedometer components with connected ports.

Open the SIL/PIL Manager (Embedded Coder) app. On the Apps tab of the Simulink Toolstrip, click SIL/PIL Manager. Click the down arrow on the Settings button to view options for SIL parameters and simulation settings. Click Portable Word Sizes in the SIL/PIL Settings section.

adaptive_BrakeControlSystem open to the SIL/PIL tab. The SIL/PIL Settings are displayed and Portable Word Sizes is selected.

Configure each software component for SIL simulations by setting block parameter Simulation mode to Software-in-the-loop (SIL) and check that Code interface is set to Top model.

Alternatively, programmatically configure each software component model for SIL simulation. First run these commands to set the simulation mode as a SIL simulation.

set_param("adaptive_BrakeControlSystem/Actuator",SimulationMode="software-in-the-loop (sil)");
set_param("adaptive_BrakeControlSystem/Speedometer",SimulationMode="software-in-the-loop (sil)");
set_param("adaptive_BrakeControlSystem/Controller",SimulationMode="software-in-the-loop (sil)");
set_param("adaptive_BrakeControlSystem/Sensors/Sensor_left",SimulationMode="software-in-the-loop (sil)");
set_param("adaptive_BrakeControlSystem/Sensors/Sensor_right",SimulationMode="software-in-the-loop (sil)");
Then set the code interface as Top model because the SIL simulation is for an AUTOSAR Adaptive software component, not a referenced model.
set_param("adaptive_BrakeControlSystem/Actuator",CodeInterface="Top model");
set_param("adaptive_BrakeControlSystem/Speedometer",CodeInterface="Top model");
set_param("adaptive_BrakeControlSystem/Controller",CodeInterface="Top model");
set_param("adaptive_BrakeControlSystem/Sensors/Sensor_left",CodeInterface="Top model");
set_param("adaptive_BrakeControlSystem/Sensors/Sensor_right",CodeInterface="Top model");

Run the SIL simulation. From the SIL/PIL tab, click Run Verification on the Simulink Toolstrip.

When the SIL simulation finishes, the Simulation Data Inspector opens and displays the results.

Simulation Data Inspector with results displayed for SIL simulation of adaptive_BrakeControlSystem

Run SIL Simulation for AUTOSAR Adaptive Component in Architecture Test Harness

This example shows how to create an architecture test harness from an AUTOSAR Adaptive software component model (requires System Composer and Simulink Test™). Use an architecture test harness to verify generated AUTOSAR Adaptive component C++ code by using software-in-the-loop (SIL) simulations.

Open example AUTOSAR Adaptive software component model autosar_LaneGuidance.

openExample("autosar_LaneGuidance");

Top level view of autosar_LaneGuidance in the AUTOSAR software component perspective. LeftSensor, RightSensor, HazardIndicator ports are visible on the software component boundary.

Open the Simulink Test Manager (Simulink Test) app. On the Simulink Toolstrip, on the Apps tab, click Simulink Test. Create an architecture test harness by clicking Add Test Harness. The Create Test Harness dialog box opens. Accept the default values by clicking OK. An architecture test harness for the model opens. The architecture test harness creates mock software components for software components ports of the component under test.

autosar_LaneGuidance architecture test harness.

To prepare the component under test in the architecture test harness for SIL simulation, configure the component under test as a top model, log the outputs of the system, designate them as test points, and enable portable word sizes. Open the SIL/PIL Manager (Embedded Coder) app. On the toolstrip Apps tab, click SIL/PIL Manager.

  1. Configure the component under test for SIL simulation by setting block parameter Simulation mode to Software-in-the-loop (SIL) and check that Code interface is set to Top model.

    Alternatively, you can programmatically set the Simulation mode and Code Interface properties by entering these commands in the MATLAB® Command Window:

    set_param("autosar_LaneGuidance_Harness1/autosar_LaneGuidance",SimulationMode="software-in-the-loop (sil)");
    set_param("autosar_LaneGuidance_Harness1/autosar_LaneGuidance",CodeInterface="Top model");

  2. Log the outputs of the system and designate them as test points. In the architecture test harness, navigate to the component under test autosar_LaneGuidance, open the Property Inspector, select the output signals in the model canvas, and in the Property Inspector, select Log signal data and Test Point in the Logging and accessibility section.

  3. If you are not on a Linux machine, enable portable word sizes. On the SIL/PIL tab of the toolstrip, click the down arrow on the Settings button and select Portable Word Sizes.

Click Run Verification on the SIL/PIL tab of the Simulink Toolstrip. When the SIL simulation finishes, the Simulation Data Inspector opens and displays the results.

Simulation Data Inspector with results displayed for SIL simulation of autosar_LaneGuidance

For more information about verifying AUTOSAR code with SIL simulations, see Verify AUTOSAR Code with SIL and PIL Simulations.

See Also

| (Embedded Coder)

Topics