PIL Simulation Sequence - MATLAB & Simulink (original) (raw)
A processor-in-the-loop (PIL) simulation cross-compiles production source code, and then downloads and runs object code on your target hardware. The connectivity configuration that you create controls the way code is compiled and executed on the target. This table describes the sequence of stages in a PIL simulation.
Stage | Description | |
---|---|---|
1 | Start | For top-model PIL, on the Simulink® Editor toolbar, you select theProcessor-in-the-Loop (PIL) mode, and then click the Run button. ForModel block PIL, you set theSimulation mode parameter of theModel block toProcessor-in-the-loop (PIL), and then run a simulation of the harness model that contains theModel block.For the PIL block, you run a simulation of the harness model that contains the PIL block. |
2 | Validate target connectivity | The software verifies that a target connectivity configuration is registered for PIL. Otherwise, the software produces an error. |
3 | Generate production source code and build object code for target | The generated source code is identical to the code that is produced when you run the slbuild command. For top-model PIL or Model block PIL with block parameter Code interface set to Top model, the generated code is identical to the code produced when you runslbuild('model').For Model block PIL with block parameter Code interface set to Model reference, the generated code is identical to the code produced when you runslbuild('model','ModelReferenceCoderTarget').The software builds object code for the target by using the template makefile or toolchain that you specify. |
4 | Create instances of PIL API components | The software instantiates your rtw.connectivity.Config class, which creates instances of rtw.connectivity.MakefileBuilder, rtw.connectivity.Launcher, rtw.pil.RtIOStreamApplicationFramework, andrtw.connectivity.RtIOStreamHostCommunicator. |
5 | Generate PIL files | The generated PIL files are in the pil folder. At the end of the simulation, use the code generation report to view the files. |
6 | Build target application | The software: Uses your instance of rtw.connectivity.MakefileBuilder to build the target application.Compiles the PIL interface file,xil_interface.c, and other PIL files into the target executable file. On a Windows® system, for example, this file is called_modelName_.exe. The object code, including the executable file, is in the pil folder.If configured, produces the code generation report. |
7 | Start target application | The software usesrtw.connectivity.Launcher to start the application on the target. |
8 | Simulink engine interacts with PIL S-function | The Simulink engine interacts with the PIL S-function in the same way that it interacts with a C S-function.From the host-side, the PIL S-function communicates with the target executable code through rtIOStream commands. On the target side, xil_interface executes generated code. |
9 | Stop target application | The software usesrtw.connectivity.Launcher to stop the application on the target. |
10 | End PIL simulation | For top-model PIL, at the end of the simulation, the software destroys the rtw.connectivity.Config instance.ForModel block PIL and PIL block, the block creates and owns the rtw.connectivity.Config instance, which is not destroyed at the end of the simulation. You can rerun the simulation, which now does not require the creation of another rtw.connectivity.Config instance. If you want to destroy the instance, close the parent model. |
See Also
rtw.connectivity.Config | rtw.connectivity.MakefileBuilder | rtw.connectivity.Launcher | rtw.pil.RtIOStreamApplicationFramework | rtw.connectivity.RtIOStreamHostCommunicator