Share Simulink Cache Files for Faster Simulation - MATLAB & Simulink (original) (raw)

Simulink® cache files contain build artifacts that can speed up simulation and code generation. To generate these build artifacts and automatically package them in Simulink cache files, perform one of these actions:

The second time that you perform any of these actions, Simulink builds only the out-of-date files as long as the ****Rebuild** configuration parameter is set to If changes detected (default) or If changes in known dependencies detected. With fewer files to build, the actions complete faster.

Note

While you can avoid all referenced model rebuilds by setting the**Rebuild configuration parameter toNever, using this setting can produce invalid simulation results.

Team members and continuous integration (CI) systems can generate Simulink cache files for models that you use. To reduce the time it takes when you build those models for the first time, you can copy the corresponding Simulink cache files to your local folder specified by the ****Simulation cache folder** preference. Simulink extracts any Simulink cache file contents that differ from the contents on disk. If Simulink generates or updates the build artifacts on disk, it locally updates the corresponding Simulink cache files.

You can identify a Simulink cache file by its .slxc extension. Its file name matches the name of the corresponding model.

Simulink cache files can contain multiple types of build artifacts, including:

Simulink cache files accumulate build artifacts for multiple platforms and Simulink releases.

To learn what a specific Simulink cache file contains, open the report by double-clicking the file.

Simulink cache report

Alternatively, to get the contents of the Simulink cache file in a MATLAB® table, use the slxcinfo function. For example, suppose you have a Simulink cache file for a model named CounterAlgorithm.

slxcinfo("CounterAlgorithm.slxc")

ans =

3×5 table

      Model           Release     Platform                     Target                               Compiler           
__________________    ________    ________    ________________________________________    _____________________________

"CounterAlgorithm"    "R2025a"    "all"       "Variable usage information"                ""                           
"CounterAlgorithm"    "R2025a"    "win64"     "Model reference simulation target"         "MinGW64 Compiler (C) v8.1.0"
"CounterAlgorithm"    "R2025a"    "win64"     "grt | Model reference | Model specific"    "MinGW64 Compiler (C) v8.1.0"

You can reuse build artifacts that support the platform, compiler, and release that you use. Some build artifacts do not require a compiler. Suppose you use a Windows® machine, a MinGW® compiler, and the R2025a Simulink release. From the Simulink cache file for CounterAlgorithm, you can reuse the simulation and code generation targets under R2025a : win64 and the variable usage information under R2025a : all platforms. A team member that uses a Linux® machine and R2025a can reuse only the variable usage information underR2025a : all platforms.

A Simulink cache file accumulates build artifacts for the release in which it was created and later releases. Suppose you create a Simulink cache file in R2025a. You would not be able to use that Simulink cache file in R2024b.

While most teams can benefit from using Simulink cache files, a development environment with these features is best suited for using Simulink cache files.

In this development environment, you interact with files in the source control system and build archive.

Workflow with source control system, CI system, and build archive. The CI system pulls design changes from the source control system and archives Simulink cache files in the build archive.

To reduce the amount of time that you spend updating simulation targets, follow these steps.

  1. Pull the latest version of all design files from the source control system.
  2. Copy the latest version of all Simulink cache files from the build archive and place them in your**Simulation cache folder.
  3. Open the top model and simulate it.
    Simulink extracts the required build artifacts from the Simulink cache files. The simulation completes without rebuilding any models as long as the models have not changed since the most recent build completed by the CI system.
    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.
  4. Change a model and simulate the model hierarchy again.
    Simulink rebuilds the necessary models and updates the local copy of the corresponding Simulink cache file.
  5. Commit the updated model to the source control system. You do not commit the Simulink cache file, which is a derived file.

When you create a project from a top model, the project includes the corresponding Simulink cache files for the model and its referenced models.

To view Simulink cache file dependencies in a model hierarchy, in the MATLAB Toolstrip, on the Project tab, in theTools gallery, click Dependency Analyzer.

Dependency Analyzer results for sldemo_mdlref_depgraph, including Simulink cache files

For more information, see Perform Impact Analysis with a Project.

See Also

slxcinfo | slxcunpack

Topics

External Websites