Processor-in-the-Loop Execution with the MATLAB Coder App
Use processor-in-the-loop (PIL) execution to verify the numerical behavior of cross-compiled object code with reference to your original MATLAB® functions.
Before you run a PIL execution, you must define a target connectivity configuration. In Processor-in-the-Loop Execution from Command Line, steps 1 and 2 of the example PIL Execution of Code Generated for a Kalman Estimator show how you can set up and register a connectivity configuration for PIL execution on your development computer.
To open the MATLAB Coder™ app, on the MATLAB Toolstrip Apps tab, under Code Generation, click the app icon.
To open your project, click , and then click
Open existing project
. Select the project. For example,kalman_filter.prj
.On the Generate Code page, click the Generate arrow .
In the Generate dialog box:
Set Build type to
Static Library
orDynamic Library
.In the Output file name field, use the default value. For example,
kalman01
.Clear the Generate code only check box.
From the Hardware Board drop-down list, select
None - Select device below
.In the Device fields, specify vendor and type. These settings must match the target hardware settings in the
rtwTargetInfo.m
file of your target connectivity configuration. For host-based PIL, select settings that match your host computer. For example:For a Windows® 64-bit system, set Device vendor to
Intel
and Device type tox86-64 (Windows64)
. In addition, set Enable long long toYes
.For a Linux® 64-bit system, set Device vendor to
Intel
and Device type tox86-64 (Linux 64)
.For a Mac OS X system, set Device vendor to
Intel
and Device type tox86-64 (Mac OS X)
.
You do not have to specify the Toolchain setting. By default, the MATLAB Coder app locates an installed toolchain.
To generate the C or C++ code, click Generate.
Click Verify Code.
In the command field, specify the test file that calls the original MATLAB functions, for example,
test01_ui.m
.To start the PIL execution, click Run Generated Code.
The MATLAB Coder app:
Generates a standalone library, for example,
codegen\lib\kalman01
.Generates PIL interface code, for example,
codegen\lib\kalman01\pil
.Runs the test file, replacing calls to the MATLAB function with calls to the generated code in the library.
Displays messages from the PIL execution in the Test Output tab.
Verify that the results from the PIL execution match the results from the original MATLAB functions.
To terminate the PIL execution process, click Stop PIL Verification. Alternatively, on the Test Output tab, click the link that follows
To terminate execution
.
Note
On a Windows operating system, the Windows Firewall can potentially block a SIL or PIL execution. To allow the execution, use the Windows Security Alert dialog box. For example, in Windows 7, click Allow access.
Related Examples
- Generate C Code by Using the MATLAB Coder App
- Processor-in-the-Loop Execution from Command Line
- Generate Execution Time Profile
- Generate Stack Usage Profile