Show numerical equivalence between MATLAB® code and generated code

Use software-in-the-loop (SIL) and processor-in-the-loop (PIL) execution to check the numerical behavior of the code that you generate from MATLAB functions. A software-in-the-loop (SIL) execution compiles generated source code and executes the code as a separate process on your development computer. A PIL execution, which requires a target connectivity configuration, cross-compiles generated source code, and then downloads and runs object code on your target hardware. You can verify the numerical behavior by comparing the results from the SIL or PIL execution against the results from the original MATLAB functions.

You can generate traceable code, which helps you to check the absence of unintended functionality, understand how the generated code implements your algorithm, and evaluate the quality of the generated code.


expand all

rtw.connectivity.ComponentArgsProvide parameters for each target connectivity component
rtw.connectivity.ConfigDefine connectivity implementation that comprises builder, launcher, and communicator components
rtw.connectivity.ConfigRegistryRegister connectivity configuration
rtw.connectivity.LauncherControl downloading, starting, and resetting of a target application
rtw.connectivity.MakefileBuilderConfigure toolchain-based build process
rtw.connectivity.RtIOStreamHostCommunicatorConfigure development computer communications with target processor
rtw.pil.RtIOStreamApplicationFrameworkConfigure target-side communications
coder.EmbeddedCodeConfigConfiguration parameters for C/C++ code generation from MATLAB code with Embedded Coder


expand all

coder.hardwareCreate hardware board configuration object for C/C++ code generation from MATLAB code
rtIOStreamCloseShut down communications channel
rtIOStreamOpenInitialize communications channel
rtIOStreamRecvReceive data through communication channel
rtIOStreamSendSend data through communication channel
rtiostreamtestTest custom rtiostream interface implementation
rtiostream_wrapperTest rtiostream shared library functions in MATLAB
piltestVerify custom target connectivity configuration for MATLAB PIL execution


SIL and PIL Testing

Code Verification Through Software-in-the-Loop and Processor-in-the-Loop Execution

A workflow that uses SIL and PIL execution to verify the numerical behavior of generated MATLAB code.

Software-in-the-Loop Execution with the MATLAB Coder App

Use the MATLAB Coder app to verify the numerical behavior of generated C/C++ code.

Software-in-the-Loop Execution From Command Line

Use MATLAB commands to verify the numerical behavior of generated C/C++ code.

Debug Generated Code During SIL Execution

Use a debugger to understand the behavior of generated code.

Create PIL Target Connectivity Configuration for MATLAB

Customize PIL execution for your target environment.

Host-Target Communication for MATLAB PIL Execution

Use the rtiostream API for communication between your development computer and target during PIL execution.

Specify Hardware Timer

Specify a hardware timer using the Code Replacement Tool.

Custom Toolchain Directives Required for Code Execution Profiling

Specify compiler directives for building PIL application that supports code execution profiling.

Processor-in-the-Loop Execution with the MATLAB Coder App

Use the MATLAB Coder app to verify the numerical behavior of cross-compiled object code.

Processor-in-the-Loop Execution From Command Line

Use MATLAB commands to verify the numerical behavior of cross-compiled object code.

PIL Execution with ARM Cortex-A at the Command Line

This example shows how to set up a PIL execution to verify generated code at the command line.

PIL Execution with ARM Cortex-A by Using the MATLAB Coder App

PIL Execution with App.

Verification of Code Generation Assumptions

PIL execution checks Hardware tab settings.

Speed Up SIL/PIL Execution by Disabling Constant Input Checking and Global Data Synchronization

Configure code generation parameters to turn off constant input checking or global data synchronization for SIL or PIL executions.

SIL/PIL Execution Support and Limitations

SIL and PIL execution support for code generation features.

Code Tracing

Interactively Trace Between MATLAB Code and Generated C/C++ Code

Visualize the mapping between the MATLAB code and the generated C/C++ code.

Include Comments in Generated C/C++ Code

Include MATLAB source code as comments in the generated code. Include function help text and function signature in function banner.

Polyspace Verification

Polyspace Verification of C/C++ Code Generated by MATLAB Coder

Check for run-time errors or defects in generated C/C++ code.

Report Generation

Highlight Potential Data Type Issues in a Report

Highlight MATLAB code that results in double-precision, single-precision, or expensive fixed-point operations.

Find Potential Data Type Issues in Generated Code

Highlight potential data type issues in report.