Verify AUTOSAR Adaptive Software Component Code With SIL
R2026bTo 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:
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.
If you are not working in a Linux® environment, set configuration parameter Enable portable word sizes (Embedded Coder) to
truefor the software architecture and the AUTOSAR Adaptive software component.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)");
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.
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");
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.

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)");
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.

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");
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.

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.
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 toTop 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");
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.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.

For more information about verifying AUTOSAR code with SIL simulations, see Verify AUTOSAR Code with SIL and PIL Simulations.
See Also
Adaptive Component | SIL/PIL Manager (Embedded Coder)