Main Content

Package and Share Protected Models

When you protect a model, you can automatically create and package the following contents in a project archive (.mlproj) for easy sharing:

  • Protected model file (.slxp)

  • Harness model file

  • MAT-file with base workspace definitions

  • Data dictionary pruned to relevant definitions

  • Other supporting files

In the Create Protected Model dialog box, set Contents to Protected model (.slxp) and dependencies in a project.

Note

Before sharing the project, check whether the project contains the necessary supporting files. If supporting files are missing, simulating or generating code for the related harness model can help identify them. Add the missing dependencies to the project and update the harness model as needed.

Alternatively, you can use one of these options to deliver the protected model package:

  • Create a project archive to share a project that contains the protected model file and supporting files. For more information, see Create a Project from a Model and Share Projects.

  • Provide the protected model file and supporting files as separate files.

  • Combine the files into a ZIP or other container file.

  • Provide the files in some other standard or proprietary format specified by the receiver.

Whichever approach you use to deliver a protected model, include information on how to retrieve the original files.

Harness Model

You can create a harness model when you create your protected model. The harness model contains a Model block that references the protected model. A third-party can use the Model block to reference your protected model. The harness model is set up for simulation of the protected model.

MAT-File with Base Workspace Definitions

Referenced models can use object definitions or tunable parameters that are defined in the MATLAB® base workspace. These variables are not saved with the model. When you protect a model, you must obtain the definitions of required base workspace entities and ship them with the model.

For example, if the model uses the following base workspace variables, they must be saved to a MAT-file:

  • Global tunable parameter

  • Global data store

  • The following objects used by a signal that connects to a root-level model Inport or Outport:

    • Simulink.Signal

    • Simulink.Bus

    • Simulink.Alias

    • Simulink.NumericType that is an alias

To determine the required base workspace definitions and save them to a MAT-file, see Explore Protected Model Capabilities. Before executing the protected model as a part of a third-party model, the receiver of the protected model must load the MAT-file.

Simulink Data Dictionary

Referenced models can use data definitions from a data dictionary, which are not saved with the model. When you protect a model that uses a data dictionary, package and ship the data dictionary with the protected model.

Protected Model File Contents

A protected model file (.slxp) consists of the derived files that support the options that you selected when you created the protected model. The derived files are unpacked when you or a third-party use the protected model in simulation. You do not need to package these derived files with the protected model.

If you created a protected model for simulation only and the referencing model is in Normal mode, after simulation, the model_msp.mexext file is placed in the build folder. The derived files that are unpacked depends on the support that you enabled when creating the protected model.

Protected Model Derived Files

Supported FunctionalityDerived Files
Created a protected model for simulation only and the referencing model is in Normal modeThe model_msp.mexext file is placed in the build folder. If the model uses a noninlined S-function directly or indirectly, the S-function MEX-files are placed in the build folder.
Created protected model for simulation only and referencing model is in Accelerator or Rapid Accelerator mode.

In addition to the preceding files in the build folder, these files are unpacked in the slprj/sim/ folder:

  • slprj/sim/model/*.h

  • slprj/sim/model/modellib.a (or modellib.lib)

  • slprj/sim/model/tmwinternal/*

  • slprj/sim/_sharedutils/*

For the protected model report, these additional files are unpacked (but not in the build folder):

  • slprj/sim/model/html/*

  • slprj/sim/model/buildinfo.mat

Created protected model with code generation support.

These files are unpacked in the slprj folder after building your model (in addition to the preceding files):

  • slprj/sim/model/*.h

  • slprj/sim/model/modellib.a (or modellib.lib)

  • slprj/sim/model/tmwinternal/*

  • slprj/sim/_sharedutils/*

  • slprj/target/model/*.h

  • slprj/target/model/model_rtwlib.a (or model_rtwlib.lib)

  • slprj/target/model/buildinfo.mat

  • slprj/target/model/codeinfo.mat

  • slprj/target/_sharedutils/*

  • slprj/target/model/tmwinternal/*

Specified a Top model code interface (requires Embedded Coder® license) and enabled code generation support when creating protected model.

These files are unpacked in the slprj folder after building your model (in addition to the preceding files):

  • slprj/sim/model/*.h

  • slprj/sim/model/modellib.a (or modellib.lib)

  • slprj/sim/model/tmwinternal/*

  • slprj/sim/_sharedutils/*

  • model_target_rtw/*.h

  • model_target_rtw/*.objExt

  • model_target_rtw/buildinfo.mat

  • model_target_rtw/codeinfo.mat

  • slprj/target/_sharedutils/*

  • slprj/target/model/tmwinternal/*

For the protected model report, after building your model these files are unpacked (in addition to the preceding files):

  • slprj/target/model/html/*

  • slprj/target/model/buildinfo.mat

  • slprj/target/_sharedutils/html/*

Created protected model with HDL code generation support (requires HDL Coder™ license).

The files are unpacked in the hdlsrc folder:

  • hdlsrc/model/model.vhd(or model.v if you specified Verilog as the Target language).

  • hdlsrc/model/Subsystem.vhd(or Subsystem.v if you specified Verilog as the Target language of the model that you protected. The additional HDL files depend on how hierarchically the referenced model was designed).

  • hdlsrc/model/model_pkg.vhd (This file is not generated if you specified Verilog as the Target language of the model that you protected).

  • hdlsrc/model/model_report.html

  • hdlsrc/model/gm_model.slxp (This is a generated protected model).

Note

The slprj/sim/model/* files are deleted after they are used.

Related Topics