Processor-in-the-Loop Simulation
A processor-in-the-loop (PIL) simulation cross-compiles generated source code, and then downloads and runs object code on your target hardware. By comparing normal and PIL simulation results, you can test the numerical equivalence of your model and the generated code. During a PIL simulation, you can collect code coverage and execution-time metrics for the generated code.
A PIL simulation requires a connectivity configuration.
Apps
| SIL/PIL Manager | Verify generated code | 
Namespaces
| target | Manage target hardware and build tool information | 
Classes
Objects
Functions
Topics
- SIL and PIL SimulationsAn overview of software-in-the-loop (SIL) and processor-in-the-loop simulations (PIL). 
- Choose a SIL or PIL ApproachTest code generated from top models, referenced models, or subsystems. 
- Create PIL Target Connectivity Configuration for SimulinkCustomize PIL simulation for your target environment. 
- Host-Target Communication for Simulink PIL SimulationUse the rtiostreamAPI for communication between your development computer and target hardware during a PIL simulation.
- Specify Hardware Timer for SimulinkSpecify a hardware timer using the Code Replacement Tool. 
- Set Up PIL Connectivity by Using Target FrameworkProvide PIL connectivity between Simulink® and the target hardware. 
- Custom Toolchain Directives Required for Code Coverage and Execution ProfilingSpecify compiler directives for building PIL application that supports code coverage analysis and execution profiling. 
- Configure and Run PIL SimulationSet up and run top-model PIL, Model block PIL, and PIL block simulations. 
- Unit Test Subsystem Code with SIL/PIL ManagerPerform unit testing on atomic subsystem by using SIL/PIL Manager. 
- SIL/PIL Manager Verification WorkflowA simplified workflow for verifying generated code. 
- PIL Simulation SequenceHow a PIL simulation proceeds. 
- Simulation Mode Override Behavior in Model Reference HierarchyHow the simulation mode of the top model or parent model determines the simulation behavior of a model hierarchy. 
- Field-Oriented Control of Permanent Magnet Synchronous MachineSimulate motor control system, generate controller code, and use PIL simulation to test numerical equivalence and profile code execution times. 
- Security for PIL SimulationsSecurity measures for PIL simulations. 
- SIL and PIL LimitationsModeling and code generation features that are not supported or partially supported by SIL and PIL simulations. 
Troubleshooting
Debug Generated Code During SIL or PIL Simulation
Use a debugger to understand the behavior of generated code.
View SIL and PIL Files in Code Generation Report
Produce a code generation report and static code metrics that cover SIL and PIL files.
Verification of Code Generation Assumptions
The SIL or PIL simulation checks code generation assumptions.

