generate code that has multiple test benches
you can generate code that has 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:
provide multiple signal groups as inputs by using a block that has multiple .
use simulink® design verifier™ to create a test harness model from the subsystem. in the test harness model, a signal editor block that has one or more signal groups provides input to the subsystem. use this signal editor block to provide inputs to your subsystem. if your model is complex, simulink design verifier can create a large number of signal groups. see troubleshooting: test data exceeds target data size.
to create your signal editor block:
right-click the subsystem and select design verifier > generate tests for subsystem.
in the simulink design verifier results summary window, select create harness model.
open the inputs block in the test harness model. the inputs block is a signal editor block that can have one or more signal groups.
in the signal editor window, make sure that more than one signal group is available in the active scenario drop-down list.
copy the signal editor block from the test harness mode. use this block to provide inputs to your original subsystem.
generate test benches for the subsystem:
open the plc coder app. click plc code tab > settings > plc code generation.
select the generate testbench for subsystem option.
open your model and open the plc coder app. click settings, and then select verify code in ide.
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 editor block and regenerate the test benches.
increase the simulation step size for the subsystem.
limitations
when you are switching between signal groups, the model simulation time must remain the same for the entire simulation. do not change the model simulation time.