Main Content

Simulink Cache Files for Incremental Code Generation

Share the generated code for various target types between team members inside an organization by using Simulink® cache files. When you generate code from a Simulink model hierarchy, each referenced model has an associated Simulink cache file. These files have an .slxc file extension. The cache files contain artifacts from the build that can reduce the time required for successive model simulation and code generation. Simulink cache files are generated when you simulate models in accelerator or rapid accelerator mode or generate code for models. For more information, see Share Simulink Cache Files for Faster Simulation.

Contents of Simulink Cache Files

At the end of a build, the code generator packages the artifacts and generated code for the model hierarchy in the Simulink cache files. The cached artifacts include:

  • Shared utilities

  • All files under the slprj\system_target_file\model_name

  • model_name_rtw_system_target_file folder for the top model

  • Any binaries generated for the top model

You cannot modify the contents of the Simulink cache files. If you update the build artifacts inside the slprj folder, the Simulink cache file picks up these updates during the next build cycle.

Share Code Generation Artifacts

If you are involved in team development of large models that reference other models, use Simulink cache files to synchronize builds and share generated code artifacts to enhance incremental code generation. You can leverage Simulink cache files to avoid unnecessary code generation.

For example, assume that you collaborate with your team members by using a source control system and your models are built every night in a continuous integration system.

  1. Open your model. For example, rtwdemo_mdlreftop.

  2. Build the model. On the C Code tab, click Build.

    Observe the Simulink cache files generated for all referenced models. The rtwdemo_mdlrefbot model is a referenced model in rtwdemo_mdlreftop.

    Simulink stores cache files in the folder specified by the Simulation cache folder preference.

    To see all supported configurations, double-click the cache file. The Simulink cache report contains information related to each release, platform, and list of packaged targets.

    Alternatively, to get the contents of the Simulink cache file in a MATLAB® table, use the slxcinfo function.

  3. Submit your models to the source control system. The continuous integration system builds the models overnight and updates the existing Simulink cache files.

    Note

    Because Simulink cache files are derived files, do not submit them to source control. If you share Simulink cache files by storing them in a source control system, you cannot diff or merge different versions of these files.

  4. Assume your team member made some changes to the model and submitted the changes to the source control system. When you want to work with the model hierarchy, fetch these files:

    • Design files (model and associated files) from the source control system.

    • Simulink cache files from the continuous integration system.

  5. Make your changes to the model.

  6. Build the model. The code generator extracts code generation artifacts stored in the Simulink cache files from the overnight build and avoids unnecessary rebuilds and code regeneration.

    The time to build the model and generate code is less than the first time that you built the model.

    Note

    To unpack the simulation and code generation targets from the Simulink cache files without updating, simulating, or generating code for the model hierarchy, use the slxcunpack function.

  7. Submit your updated model files to the source control system.

See Also

|

Related Examples

More About

External Websites