Verify AUTOSAR Code with SIL and PIL Simulations
As 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. 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.
SIL and PIL simulations are not supported for software component models configured for the
AUTOSAR Adaptive Platform. You can run Model block SIL simulations with
Code interface set to Model Reference for
unit-level testing of Model blocks in an AUTOSAR software component model
configured for system target file set to autosar_adaptive.tlc. In this
case, the Model block under test can not reference a model mapped to an AUTOSAR
software component.
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 Subsystem Code with SIL/PIL Manager (Embedded Coder).
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 Subsystem Code with SIL/PIL Manager (Embedded Coder)
- Limitations and Tips