| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Real-Time Workshop Embedded Coder |
| Contents | Index |
| Learn more about Real-Time Workshop Embedded Coder |
| On this page… |
|---|
What Is a PIL Connectivity Configuration? Overview of the Target Connectivity API Creating a Connectivity API Implementation |
You can use PIL connectivity configurations and the target connectivity API to customize PIL to work with any target environment.
Use a connectivity configuration to define:
A configuration name
A connectivity API implementation
Settings that define the set of Simulink models that the configuration is compatible with, for example, the set of models that have a particular system target file, template makefile, and hardware implementation.
You can use the API to integrate third party tools for:
Building the PIL application; an executable for the target hardware)
Downloading and running the executable
Communicating with the executable
A particular connectivity configuration name is associated with a single connectivity API implementation. Many different connectivity configurations can coexist and be available for use with PIL simulations. You register each connectivity configuration to Simulink by creating an sl_customization.m file and placing it on the MATLAB path.
To run a PIL simulation, the software must first determine which of the available connectivity configurations to use. The software looks for a connectivity configuration that is compatible with the model under test. If the software finds multiple or no compatible connectivity configurations, you see an error message describing how to resolve the problem.
You can use any of the following connectivity configuration options:
Default host-based connectivity configuration
The target environment is the host machine. See Using PIL Mode for Software-in-the-Loop (SIL) Verification
Custom connectivity configuration
The target environment is a different processor.
See:
The following diagram shows what functions the Target Connectivity API components perform:
Configuring the build process
Controlling communication between Simulink and the target
Downloading, starting, and stopping the application on the target

The communications part of the target connectivity API builds upon the rtiostream API, described in this section.
You can use the rtiostream API to implement a communication channel to enable exchange of data between different processes. This communication channel is required to enable processor-in-the-loop (PIL) on a new target.
PIL requires a host-target communications channel. This communications channel comprises separate driver code running on each of the host and target. The rtiostream API defines the signature of both target-side and host-side functions that must be implemented by this driver code.
The API is independent of the physical layer that sends the data. Possible physical layers include RS232, Ethernet, or Controller Area Network (CAN).
A full rtiostream implementation requires both host-side and target-side drivers. Real-Time Workshop software includes host-side drivers for the default TCP/IP implementation (all platforms) as well as a Windows only version for serial communications. To use the TCP/IP rtiostream communications channel, you must provide, or obtain from a third party, target-specific TCP/IP device drivers. You must also do this if you require serial communications. For other communication channels and platforms, there is no default implementation provided by Real-Time Workshop software. You must provide both the host-side and the target-side drivers.
The rtiostream API comprises the following functions:
You can use rtiostream_wrapper to test the rtiostream shared library methods from M-code.
To see how the rtiostream functions fit into the workflow of creating a connectivity implementation, see the next section, Creating a Connectivity API Implementation.
To create a target connectivity API implementation, you must create a subclass of rtw.connectivity.Config.
You must instantiate rtw.connectivity.MakefileBuilder. This class configures the build process.
You must create a subclass of rtw.connectivity.Launcher. This class downloads and executes the application using a third-party tool.
Configure your rtiostream communications implementation:
On the target-side, integrate the driver code implementing rtiostream functions directly into the Real-Time Workshop build process, by creating a subclass of rtw.pil.RtIOStreamApplicationFramework.
On the host-side, compile the driver code into a shared library. You load and initialize this shared library by instantiating (or optionally, customizing) rtw.connectivity.RtIOStreamHostCommunicator.
For all the classes, methods, and functions in the Target Connectivity API, see the following reference section: Processor-in-the-Loop in the Real-Time Workshop Embedded Coder Function Reference.
Register the new connectivity API implementation to Simulink as a connectivity configuration, by creating or adding to an sl_customization.m file. By doing this, you also define the set of Simulink models that the new connectivity configuration is compatible with.
For details, see rtw.connectivity.ConfigRegistry in the Real-Time Workshop Embedded Coder Function Reference.
For step-by-step examples, see the following demos:
This M-file demo shows you how to create a custom PIL implementation using the target connectivity APIs. You can examine the code that configures the build process to support PIL, a tool to use for downloading and execution, and a communication channel between host and target. Follow the steps to activate a full host-based PIL configuration.
This M-file demo shows you how to implement a communication channel for use with the Real-Time Workshop Embedded Coder product and your own target support package. This communication channel enables exchange of data between different processes. PIL simulation requires this because it requires exchange of data between the Simulink software running on your host machine and deployed code executing on target hardware.
The rtiostream interface provides a generic communication channel that you can implement in the form of target connectivity drivers for a range of connection types. The demo shows how to configure your own target-side driver for TCP/IP, to operate with the default host-side TCP/IP driver. The default TCP/IP communications allow high bandwidth communication between host and target, suitable for transferring data such as video.
The demo also shows how to implement custom target connectivity drivers, for example, using serial, CAN, or USB for both host and target sides of the communication channel.
![]() | Configuring a PIL Simulation | PIL Simulation Support and Limitations | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |