Main Content

piltest

Verify custom target connectivity configuration for Simulink PIL simulation

Description

piltest(config) runs a suite of tests that verify your custom processor-in-the-loop (PIL) target connectivity configuration. In the tests, the function runs various normal, software-in-the-loop (SIL), and PIL simulations. The function compares results and produces errors if it detects differences between simulation modes. For the PIL simulations, the function extracts these parameters from config:

  • SystemTargetFile

  • TargetHWDeviceType

  • Toolchain

In the current working folder, the function creates the piltest folder, which contains subfolders with test results.

piltest(config,'ConfigParams',additionalParameterList) extracts additional parameters from config for the PIL simulation.

example

piltest(config,'TestPoint',testName) runs a specific test from the test suite.

Examples

collapse all

This example uses piltest to verify a target connectivity configuration for PIL simulations on your development computer.

Create a target connectivity implementation in your current working folder.

% Make a local copy of the connectivity classes.
src_dir = ...
    fullfile(matlabroot,'toolbox','coder','simulinkcoder',...
             '+coder','+mypil');
if exist(fullfile('.','+mypil'),'dir')
    rmdir('+mypil','s')
end
mkdir +mypil
copyfile(fullfile(src_dir,'Launcher.m'), '+mypil');
copyfile(fullfile(src_dir,'TargetApplicationFramework.m'), '+mypil');
copyfile(fullfile(src_dir,'ConnectivityConfig.m'), '+mypil');

% Make the copied files writable.
fileattrib(fullfile('+mypil', '*'),'+w');

% Update the package name to reflect the new location of the files.
coder.mypil.Utils.UpdateClassName(...
    './+mypil/ConnectivityConfig.m',...
    'coder.mypil',...
    'mypil');

Register a target connectivity configuration using an sl_customization.m file. This example uses a supplied file.

sl_customization_path = fullfile(matlabroot,...
    'toolbox',...
    'rtw',...
    'rtwdemos',...
    'pil_demo');
addpath(sl_customization_path);
sl_refresh_customizations;

Open the model and specify the PIL simulation mode.

openExample('ecoder/SILPILVerificationExample', ...
             supportingFile='SILTopModel.slx')
set_param('SILTopModel','SimulationMode',...
          'processor-in-the-loop (pil)');

Specify the manufacturer and test hardware type. For example, PIL simulation on a 64-bit Windows® development computer requires:

set_param('SILTopModel','TargetHWDeviceType',...
          'Intel->x86-64 (Windows64)');
set_param('SILTopModel','TargetLongLongMode',true);

Run piltest.

piltest('SILTopModel', 'ConfigParam', {'ProdLongLongMode'} )

Input Arguments

collapse all

A configuration set, configuration set reference, or Simulink® model.

Extract additional parameters from config for PIL simulation.

  • 'verifyPILBlock' — For normal mode results, run a simulation of a Simulink model with a subsystem. For PIL results, replace the subsystem with a PIL block and rerun the simulation. The function compares normal and PIL mode results. If the function detects differences, it produces an error.

  • 'verifyModelBlock' — For normal mode results, run simulations of a Simulink model with a Model block in normal mode.

    For PIL mode results, run simulation loops with the Model block in PIL mode. The function varies these settings:

    • Model block parameter Code interface — Set to Top model (standalone code interface) or Model reference.

    • Configuration Parameters > Code Generation > Language — Set to C or C++. For the C++ case, the function sets Code Generation > Interface > Code interface packaging to C++ class.

    The function compares normal and PIL mode results. If the function detects differences, it produces an error.

  • 'verifyTopModel' — Run simulations of a Simulink top-model in normal and PIL modes. The function compares normal and PIL mode results. If the function detects differences, it produces an error.

  • 'verifyExecutionOnTarget' — Run simulations of a Simulink model with a Model block in normal and PIL modes. For each mode, the Model block uses standalone and model reference code interfaces. For PIL mode, the function introduces a deliberate mismatch. The function compares normal and PIL mode results. If it does not detect the deliberate mismatch, it produces an error.

  • 'verifyTopModelSILPILSwitching' — For a Simulink top model:

    • Verify that production code is not regenerated when the function switches between SIL and PIL simulation modes. The function compares timestamps of the production code in each mode.

    • Compares results from SIL and PIL mode simulations to results from a normal mode simulation.

    If the function detects differences in timestamps or simulation results, it produces an error.

  • 'verifyModelBlockSILPILSwitching' — For a Simulink Model block:

    • Verify that production code is not regenerated when the Model block simulation mode switches between SIL and PIL modes. The function compares timestamps of the production code in each mode.

    • Run simulation loops with the Model block in SIL and PIL modes. The function varies the Code interface Model block parameter, setting this parameter to Top model or Model reference. The function compares results from SIL and PIL mode simulations to results from a normal mode simulation.

    If the function detects differences in timestamps or simulation results, it produces an error.

  • 'all' — Run all tests from the test suite.

Version History

Introduced in R2016b