Main Content

Embedded and Generic Real-Time Resources

Extending Embedded and Generic Real-Time System Target Files

Simulink® Coder™ and Embedded Coder® use system target files (STFs) to generate code for interfacing with specific real-time operating systems. The Target Language Compiler (TLC) uses STFs and various other target files to convert a model into generated code. In addition to including STFs for ready-to-run configurations, Simulink Coder and Embedded Coder allow you to extend STFs to support third-party and custom target hardware. For more information on TLC files and STFs, including a list of available STFs, see Configure a System Target File (Simulink Coder) and Target Language Compiler Basics (Simulink Coder).

Generic real-time (GRT) is a Simulink Coder STF that you can use when you generate code from a Simscape™ model for hardware-in-the-loop (HIL) simulation. To generate code for HIL simulation, you must configure your Simscape model to use a fixed step, local solver. To learn about Simscape solver configurations that support HIL simulation, see Solvers for Real-Time Simulation.

Embedded real-time (ERT) is an Embedded Coder STF for deploying production-quality code for real-time execution of the algorithm for your Simulink controller. Do not deploy code that you generate from a Simscape model to production platforms. Simscape models contain constructs that are not compatible with performance-related Embedded Coder Model Advisor checks, such as “Check for blocks not recommended for C/C++ production code deployment”. For more information, see Embedded Coder Model Advisor Checks for Standards, Guidelines, and Code Efficiency (Embedded Coder).

To extend ERT or GRT system target files and create hardware-specific, standalone applications, use the toolchain build process approach. The toolchain approach generates optimized makefiles and supports custom toolchains. For information, see Customize System Target Files (Simulink Coder) and Support Toolchain Approach with Custom Target (Simulink Coder).

Third-party vendors supply additional system target files for the Simulink Coder product. For more information about third-party products, see the MathWorks Connections Program Web page: https://www.mathworks.com/products/connections.

Precompiled Static Libraries

Simscape and its add-on products provide static libraries precompiled for compilers supported by Simulink Coder software. For details on supported compilers, see Supported and Compatible Compilers. For all other compilers, the static libraries needed by code generated from Simscape models are compiled once per model during the code generation build process.

To save time during the build process, precompile new or updated S-function libraries (MEX-files) for a model by using the MATLAB® language function rtw_precompile_libs (Simulink Coder). You can also use the rtw_precompile_libs function to recompile a precompiled S-function library. Recompiling a precompiled library allows you to customize compiler settings for various platforms or environments. For details on using rtw_precompile_libs, see Precompile S-Function Libraries (Simulink Coder).

Typically, a target machine places cross-compiled versions of the precompiled libraries in a default location as specified in an rtwmakecfg.m file. The default file suffix and file extension used by the Simulink Coder code generator to name precompiled libraries during the build process are:

  • On Windows® systems, model_rtwlib.lib

  • On UNIX® or Linux® systems, model_rtwlib.a

You can control the file destination, location, suffix, and extension by customizing the system target file (STF) for your target hardware. For more information, see Control Library Location and Naming During Build (Simulink Coder) and Use rtwmakecfg.m API to Customize Generated Makefiles (Simulink Coder).

See Also

(Simulink Coder)

Related Topics

Related Topics