Main Content

How Simscape Code Generation Differs from Simulink

In general, using the code generated from Simscape™ models is similar to using code generated from regular Simulink® models. However, there are certain differences.

Simscape and Simulink Code Generated Separately

Simulink Coder™ software generates code from the Simscape blocks separately from the Simulink blocks in your model. The generated Simscape code does not pass through model.rtw or the Target Language Compiler. All the code generated from a single model resides in the same directory, however.

Compiler and Processor Architecture Requirements

To generate and execute Simscape code, you must have a compiler and a processor that support:

  • 64-bit precision floating-point arithmetic defined by IEEE® Standard for Floating-Point Arithmetic (IEEE 754)

  • 32-bit integer size

For details on supported compiler versions, see

https://www.mathworks.com/support/compilers/current_release

Precompiled Libraries Provided for Selected Compilers

Simscape software and its add-on products provide static runtime libraries precompiled for compilers supported by Simulink Coder software. For details, see

https://www.mathworks.com/support/compilers/current_release

For all other compilers, the static runtime libraries needed by code generated from Simscape models are compiled once per model during the code generation build process.

Tunable Parameters Not Supported

A tunable parameter is a Simulink run-time parameter that you can change while the simulation is running. Simscape blocks do not support tunable parameters in either simulations or generated code. However, Simscape run-time parameters, which are parameters you can modify at run time, but not during simulation, are available. For more information, see Run-Time Parameters.

Simscape Run-Time Parameter Inlining Override of Global Exceptions

If you choose to enable parameter inlining for code generated from a Simscape model, the software inlines all its run-time parameters. If you choose to make some of the global Simscape block parameters exceptions to inlining, the exceptions are ignored. You can change global tunable parameters only by regenerating code from the model.