This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Verify Generated Code with Multiple Test Benches

You can generate code with multiple test benches from your subsystem. For the generated code to have multiple test benches, the input to your subsystem must consist of multiple signal groups.

To generate multiple test benches for your subsystem:

  1. Provide multiple signal groups as inputs by using a Signal Builder block with multiple signal groups (Simulink).

    Instead of manually entering a Signal Builder block and creating multiple signal groups, you can use Simulink® Design Verifier™ to create a test harness model from the subsystem. In the test harness model, a Signal Builder block with one or more signal groups provides input to the subsystem. You can use this Signal Builder block to provide inputs to your subsystem. However, if your model is complex, Simulink Design Verifier can create large number of signal groups. See Troubleshooting: Test Data Exceeds Target Data Size.

    To create your Signal Builder block with Simulink Design Verifier:

    1. Right-click the subsystem and select Design Verifier > Generate Tests for Subsystem.

    2. In the Simulink Design Verifier Results Summary window, select Create harness model.

    3. Open the Inputs block in the test harness model. The Inputs block is a Signal Builder block that can have one or more signal groups.

      In the Signal Builder window, make sure that more than one signal group is available in the Active Group drop-down list.

    4. Copy the Signal Builder block from the test harness model and use this block to provide inputs to your original subsystem.

  2. Specify that test benches must be generated for the subsystem.

    1. Right-click your subsystem and select PLC Code > Options.

    2. Select Generate Testbench for Subsystem.

  3. Right-click the subsystem and select PLC Code > Generate, Import and Verify Code for Subsystem.

    In your target IDE, you can see multiple test benches. Each test bench corresponds to a signal group.

Troubleshooting: Test Data Exceeds Target Data Size

If the test data from the multiple signal groups exceeds the maximum data size on your target, you can encounter compilation errors. If you encounter compilation errors when generating multiple test benches, try one of the following:

  • Reduce the number of signal groups in the Signal Builder block and regenerate the test benches.

  • Increase the simulation step size for the subsystem.

Related Topics