Main Content

Test Protected Models

To test a protected model that you created, compare the simulation results of the protected model to the output of the original model. As you supply the protected model from the original model, both the original and the protected model might exist on the MATLAB® path.

In the parent model, if the Model block Model name parameter names the model without providing a suffix, the protected model takes precedence over the unprotected model. To override this default when testing the output, in the Model block Model name parameter, specify the file name with the extension of the unprotected model, .slx.

To compare the unprotected and protected versions of a Model block, you can use the Simulation Data Inspector. This example uses hdlcoder_protected_model_parent_harness and the protected model, hdlcoder_referenced_model_gain.slxp, which you created in Create Protected Models to Conceal Contents and Generate HDL Code.

  1. If it is not already open, open the model hdlcoder_protected_model_parent_harness.

    open_system('hdlcoder_protected_model_parent_harness')
  2. Make sure that the Model block in the hdlcoder_protected_model_parent_harness/DUT/mynested subsystem is referencing the original model hdlcoder_referenced_model_gain.slx and not the protected model.

  3. Enable logging for the output signals of the Model block. Right-click the output signals and select Log Selected Signals.

  4. Simulate the model and click the Simulation Data Inspector. In the Simulation Data Inspector, select the signals that you logged to see the simulation results. Save this simulation run with a name such as original_model_run.

  5. Now, in the Block Parameters dialog box for the Model block, change the Model name to hdlcoder_referenced_model_gain.slxp.

    A badge icon appears on the Model block indicating that you are referencing the protected model. If you haven't already created the protected model, follow the steps mentioned in Create Protected Models to Conceal Contents and Generate HDL Code.

  6. Simulate the model, which now refers to the protected model. When the simulation is complete, a new run appears in the Simulation Data Inspector. Save this run as protected_model_run.

  7. In the Simulation Data Inspector, click the Compare tab. From the Baseline and Compare To lists, select the original_model_run and the protected_model_run. To compare the runs, click Compare Runs.

This figure displays the comparison between the Baseline and Compare To lists. You see that the simulation results match.

See Also

Functions

Related Topics