Verify AUTOSAR Code with SIL and PIL Simulations
R2026bAs part of developing AUTOSAR software, you can carry out code verification of AUTOSAR software components by using software-in-the-loop (SIL) and processor-in-the-loop (PIL) simulations. Use SIL simulation for verification of generated source code on your development computer and PIL simulation for verification of object code on your production target hardware. For more information, see Choose a SIL or PIL Approach (Embedded Coder).
Through behavioral and structural comparisons, code verification demonstrates the equivalence between a component model and its generated code. By running SIL and PIL simulations you can:
Test numerical equivalence between your component model and generated code by comparing normal mode simulation results against SIL or PIL simulation results.
Show the absence of unintended functionality by comparing model coverage against code coverage or performing a traceability analysis.
Configure SIL and PIL simulations to generate code coverage metrics.
Generate reports that provide bidirectional traceability between model objects and generated code.
For software component models configured for the AUTOSAR Adaptive Platform, you run SIL and PIL simulations by using software architecture models or architecture test harnesses:
If you have System Composer™, create an AUTOSAR software architecture configured for the AUTOSAR Adaptive Platform and use Adaptive Component blocks with Code interface set to
Top modelto run SIL simulations.If you have System Composer and Simulink® Test™, create an architecture test harness for your AUTOSAR Adaptive software component to run SIL simulations.
For more information, see Verify AUTOSAR Adaptive Software Component Code With SIL.
In Simulink, you can run unit-level tests of Model blocks contained in AUTOSAR Adaptive software component models if all of these conditions are met:
The Model block has Code interface set to
Model Reference.The Model block does not reference a model configured as an AUTOSAR software component.
The Model block does not reference a protected model.
For models configured for the AUTOSAR Classic Platform, you run SIL and PIL simulations by configuring either the top model or Model blocks.
You test AUTOSAR software component models that are configured for AUTOSAR system target file
autosar.tlcby using the SIL/PIL Manager (Embedded Coder) and setting System Under Test toTop modeland SIL/PIL Mode toSoftware-in-the-Loop (SIL)orProcessor-in-the-Loop (PIL). Alternatively, you can reference the AUTOSAR software component model by using a Model block in a test harness model.You use Model block SIL or PIL simulation for unit-level testing of a Model block that references an AUTOSAR software subcomponent model configured for AUTOSAR system target file
autosar.tlc. On the Model block, set Simulation mode toSoftware-in-the-Loop (SIL)orProcessor-in-the-Loop (PIL)and Code interface toModel reference. In this case, before you run a simulation, you must build the parent component to generate the AUTOSAR Runtime Environment (RTE) header files. If you do not build the parent component, the SIL or PIL simulation fails. For models configured for the AUTOSAR Classic Platform, you can build the subcomponent model by using the functionslbuildand specify"ModelReferenceCoderTarget". For example,For an example of a mapped AUTOSAR subcomponent referenced from an AUTOSAR software component, see Configure Subcomponent Data for AUTOSAR Calibration and Measurement.slbuild("autosar_subcomponent","ModelReferenceCoderTarget");
For composition-level testing of multiple AUTOSAR software components, reference the component models in a composition, architecture model, or test harness model. In the Model block for each component under test, set Simulation mode to
Software-in-the-Loop (SIL)orProcessor-in-the-Loop (PIL), and set Code interface toTop model.
For more information, see Simulation with Top Model (Embedded Coder) and Simulation with Model Blocks (Embedded Coder).
If you have Simulink Test software, you can use test harnesses to:
Perform composition-level testing of AUTOSAR software components. For more information, see Testing AUTOSAR Compositions (Simulink Test).
Perform unit-level testing of atomic subsystems in AUTOSAR software components. For more information, see Unit Test Atomic Subsystem Code with SIL/PIL Manager (Embedded Coder).
Run SIL simulations on AUTOSAR Adaptive software component models. For more information, see Verify AUTOSAR Adaptive Software Component Code With SIL.
See Also
Topics
- AUTOSAR Classic Component Code Generation Files
- SIL and PIL Simulations (Embedded Coder)
- Choose a SIL or PIL Approach (Embedded Coder)
- Simulation with Top Model (Embedded Coder)
- Simulation with Model Blocks (Embedded Coder)
- Testing AUTOSAR Compositions (Simulink Test)
- Unit Test Atomic Subsystem Code with SIL/PIL Manager (Embedded Coder)
- Limitations and Tips