Documentation

Choose a SIL or PIL Approach

Consider a top model that consists of componentsA,B,C, andD:

  • AandBare existing components for which code has previously been generated and tested.

  • C, a referenced model, andD, a subsystem, are new components.

With software-in-the-loop (SIL) and processor-in-the-loop (PIL) simulations, you can use the following approaches to numerical equivalence testing:

For some forms of testing, you require a test harness model. The test harness model:

  • Generates test vectors or stimulus inputs that feed the block under test.

  • Makes it possible for you to observe or capture output from the block.

The following example shows a simple test harness model.

The block under test is aModelblock. TheSine Waveblock generates the input for theModelblock. Through theScopeblock, you can observe the output from theModelblock. For information about creating and using test harnesses, see:

测试顶级模特的代码

To test code generated from the top-model components together (A,B,C, andD), you can use top-model SIL/PIL or Model block SIL/PIL.

  • Top-model SIL/PIL:

    1. Create test vectors or stimulus inputs in theMATLAB workspace(Simulink).

    2. Run the top model in normal, SIL, and PIL simulation modes. The software loads the test vectors or stimulus inputs from the MATLAB®workspace.

    3. For each simulation mode, observe or capture outputs.

    4. Verify numerical equivalence by comparing normal outputs against SIL and PIL outputs.

  • Modelblock SIL/PIL:

    1. Create aModelblock that contains the top-model components.

    2. Insert theModelblock in a simulation model, for example, your test harness model.

    3. Run simulations, switching theModelblock between normal, SIL, and PIL modes. For the SIL and PIL simulation modes, set theCode interfaceModelblock parameter toTop model.

    4. Verify numerical equivalence by comparing normal outputs against SIL and PIL outputs.

Test Referenced Model Code

To test code generated from the componentCas part of a model reference hierarchy, use theModelblock SIL/PIL approach:

  • Insert the Model blockC我n a simulation model, for example, your test harness model.

  • Run simulations, switching theModelblock between normal, SIL, and PIL modes. For the SIL and PIL simulation modes, set theCode interfaceModelblock parameter to模型reference.

  • Verify numerical equivalence by comparing normal outputs against SIL and PIL outputs.

Test Subsystem Code

To test code generated from the subsystemD, use the SIL or PIL block approach:

  1. Insert the subsystem in a simulation model, for example, your test harness model.

  2. Run a normal mode simulation, capturing the outputs.

  3. Create a SIL or PIL block from the subsystem.

  4. In the model, replace the subsystem with the SIL or PIL block.

  5. Run a simulation of the model, capturing the outputs.

  6. Verify numerical equivalence by comparing normal mode subsystem outputs against SIL or PIL block outputs.

Summary

Simulation Type Component From Which Code Is Generated Steps Generated Code Interface Test Signal Source
Top-model SIL/PIL Top model

In SIL/PIL Manager:

  1. SelectSIL/PIL Simulation Onlymode.

  2. InSystem Under Test, selectTop model.

Standalone MATLAB workspace(Simulink)
Modelblock SIL/PIL 模型referenced byModelblock

  1. In SIL/PIL Manager:

    1. SelectSIL/PIL Simulation Onlymode.

    2. InSystem Under Test, selectModel blocks in SIL/PIL mode.

  2. InModelblocks, setSimulation modetoSoftware-in-the-loop (SIL)orProcessor-in-the-loop (PIL).

Determined byModelblock parameterCode interface: standalone or model reference. Simulation model, for example, test harness model
SIL or PIL block Subsystem Manual block substitution Standalone Simulation model, for example, test harness model.

Related Topics