Compare System Target File Support Across Products - MATLAB & Simulink (original) (raw)

When you select a system target file (such as grt.tlc), the selection defines the run-time environment and the code generation features. Identify the system target file features that match your code generation workflow goals.

The code generator uses the system target file to produce code intended for execution on certain target hardware or on a certain operating system. The system target file invokes other run-time environment-specific files. For more information on configuring model code generation parameters for target hardware, see Configure Run-Time Environment Options.

Different types of system target files support a selection of generated code features. In the system target file, the value of the CodeFormat TLC variable and corresponding rtwgensettings.DerivedFrom field value identify the system target file type and generated code features. These selections apply your code generation control decisions at several points in the code generation process. Your selections include whether and how the model build generates:

For custom system target file development, the CodeFormat value differs among code generation targets:

This example shows how the value for the CodeFormat TLC variable and corresponding rtwgensettings.DerivedFrom field value are set inert.tlc.

%assign CodeFormat = "Embedded-C"

/% BEGIN_RTW_OPTIONS rtwgensettings.DerivedFrom = 'ert.tlc'; END_RTW_OPTIONS %/

Note

Use the value for the CodeFormat TLC variable with its correspondingrtwgensettings.DerivedFrom field value to generate code for the model. If you do not select a value explicitly, the default values apply. For thertwgensettings.DerivedFrom field, use 'ert.tlc' or'grt.tlc'. For more information, see System Target File Structure.

For a description of the optimized call interface generated by default for the GRT and ERT system target files, see Configure Generated C Function Interface for Model Entry-Point Functions.

Code generation with the GRT and ERT system target files uses the real-time model data structure (rtModel). This structure encapsulates model-specific information in a much more compact form than the simulation structure, SimStruct. Many efficient features of generated code depend on generation of rtModel rather than SimStruct, including:

For a description of the rtModeldata structure, see Real-Time Model Data Structure.

Compare Product System Target Files

You can select from a range of system target files by using the System Target File Browser. This selection lets you experiment with configuration options and save your model with different configurations.

You cannot build or generate code for non-GRT system target files, unless you have the required software on your system. For example, you require Embedded Coder® for ERT system target files, Simulink® Desktop Real-Time™ for SLDRT system target files, and so on.

Selecting a system target file for your model selects either the toolchain approach or the template makefile approach for build process control. For more information about these approaches, see Approaches for Building Code Generated from Simulink Models.

System Target Files Available from System Target File Browser

Note

To create and build a Visual C++ Solution (.sln) file with Debug configuration, in theToolchain field, specify a CMake toolchain, for example, Microsoft Visual Studio Project 2019 | CMake (64-bit Windows) or Microsoft Visual Studio Project 2017 | CMake (64-bit Windows). For more information about CMake toolchains, see Configure CMake Build Process.

Compare Code Styles and STF Support

The code generator produces two styles of code. One code style is suitable for rapid prototyping (and simulation by using code generation). The other style is suitable for embedded applications. This table maps system target files to corresponding code styles.

Code Styles Listed by System Target File

System Target File Code Style Purpose
Embedded Coder embedded real-time (ERT) Embedded A starting point for embedded application development of C/C++ generated code.
Simulink Coder™ generic real-time (GRT) Rapid prototyping A starting point for creating a rapid prototyping target hardware that does not use real-time operating system tasking primitives and for verifying the generated C/C++ code on your desktop computer.
Rapid simulation (RSim) Rapid prototyping Provides non-real-time simulation on your desktop computer and a high-speed or batch simulation tool.
S-function Rapid prototyping Creates a C MEX S-function for simulation within another Simulink model.
Simulink Desktop Real-Time Rapid prototyping Runs a model in real time at interrupt level while your desktop computer runs Microsoft® Windows® in the background.
Simulink Real-Time Rapid prototyping Runs a model in real time on a desktop computer running the Simulink Real-Time kernel.

Third-party vendors supply additional system target files to support code generation for their products. For more information about third-party products, see the vendor website or the MathWorks® Connections program web page: https://www.mathworks.com/products/connections.

Compare Generated Code Features by Product

The code generation process for real-time system target files (such as GRT) provides many embedded code optimizations. Selecting an ERT-based system target file offers more extensive features than GRT. The system target file selection determines the available features for the code generation product. As you select the code generation target that matches your development process, use this table to compare code generation features available with Simulink Coder and features available with Embedded Coder.

Compare Code Generation Features for Simulink Coder Versus Embedded Coder

Feature Simulink Coder Embedded Coder
rtModel data structure Full rtModel structure generatedGRT variable declaration:rtModel_ model model_M_; rtModel is optimized for the modelOptional suppression of error status field and data logging fieldsERT variable declaration:RT_MODEL_ model model_M_;
Custom storage classes (CSCs) Code generation ignores CSCs. Objects are assigned a CSC default toAuto storage class. Code generation with CSCs is supported
HTML code generation report Basic HTML code generation report Enhanced report with additional detail and hyperlinks to the model
Symbol formatting Symbols (for signals, parameters, and so on) are generated in accordance with hard-coded default Detailed control over generated symbols
User-defined maximum identifier length for generated symbols Supported Supported
Generation of terminate function Generated Option to suppress the terminate function
Combined output/update function Separate output/update functions are generated Option to generate combined output/update function
Optimized data initialization Not available Options to suppress generation of unnecessary initialization code for zero-valued memory, I/O ports, and so on
Comments generation Basic options to include or suppress comment generation Options to include Simulink block descriptions, Stateflow® object descriptions, and Simulink data object descriptions in comments
Module Packaging Features (MPF) Not supported Extensive code customization features See Manage Replacement of Simulink Data Types in Generated Code and MPT Data Object Properties.
System target file-optimized data types header file Requires full tmwtypes.h header file Generates optimized rtwtypes.h header file, including definitions required by the system target file
User-defined types User-defined types default to base types in code generation User-defined data type aliases are supported in code generation
Rate grouping Not supported Supported
Auto-generation of main program module Not supported. Static main program module is provided. Automated and customizable generation of main program module is supported (static main program also available)
Reusable (multi-instance) code generation Option to generate reusable code with dynamic memory allocation Option to generate reusable code with static or dynamic memory allocation
Software constraint options Support for floating-point, complex, and nonfinite numbers is enabled Options to enable or disable support for floating-point, complex, and nonfinite numbers
Application life span Defaults to inf User-specified. Determines most efficient word size for integer timers
ANSI®-C/C++ code generation Supported Supported
ISO®-C/C++ code generation Supported Supported
GNU®-C/C++ code generation Supported Supported
Generate scalar inlined parameters as #DEFINE statements Not supported Supported
MAT-file variable name modifier Supported Supported
Data exchange: C API, ASAP2, external mode Supported Supported

Compare Generated Code Features by STF

The code generator supports a selection of generated code features for different types of system target files. In each system target file, the value of theCodeFormat TLC variable identifies the set of features.

This table summarizes how different system target files support applications.

Application System Target File (STF)
Fixed- or variable-step acceleration RSIM, S-Function, Model Reference
Fixed-step real-time deployment GRT, ERT, Simulink Real-Time, Simulink Desktop Real-Time, ...

This table summarizes the various options available for each System target file selection, with the exceptions noted.

Features Supported in Code Generated for System Target Files (STF)

| | System Target Files (STF)1 | | | | | | | | | | ---------------------------------------------- | ------- | ------- | --------------- | ----------- | -------- | --------- | ------------- | ----- | | Feature | grt.tlc | ert.tlc | ert_shrlib.tlc | rtwsfcn.tlc | rsim.tlc | sldrt.tlc | speedgoat.tlc | Other | | Static memory allocation | X | X | | X | X | X | | | | Dynamic memory allocation | X4, 5 | X4, 5 | X | X | X | | | | | Continuous time | X | X | X | X | X | X | | | | C/C++ MEX S-functions (noninlined) | X | X | X | X | X | X | | | | S-function (inlined) | X | X | X | X | X | X | X | | | Minimize RAM/ROM usage | X | X2 | X | | | | | | | Supports external mode | X | X | X | X | X | | | | | Rapid prototyping | X | X | X | X | | | | | | Production code | X | X2 | X3 | | | | | | | Batch parameter tuning and Monte Carlo methods | X | X | | | | | | | | System-level Simulator | X | | | | | | | | | Executes in hard real time | X3 | X3 | X | X | X5 | | | | | Non-real-time executable included | X | X | X | | | | | | | Multiple instances of model | X4, 5 | X4, 5 | X4 | X4, 5 | X4, 5 | | | | | Supports variable-step solvers | X | X | | | | | | | | Supports SIL/PIL6 | X | X | X | | | | | |

Notes

  1. System Target Files:
    • grt.tlc — Generic real-time target
    • ert.tlc — Embedded real-time target
    • ert_shrlib.tlc — Embedded real-time target shared library
    • rtwsfcn.tlc (To be removed) — S-function target
    • rsim.tlc — Rapid simulation target
    • sldrt.tlc — Simulink Desktop Real-Time target
    • speedgoat.tlc — Simulink Real-Time target
    • Other — The Simulink Coder embedded real-time capabilities support other system target files
  2. Does not apply to GRT-based system target files. Applies to only ERT-based system target files.
  3. The default GRT and ERT rt_main files emulate execution of hard real time. When explicitly connected to a real-time clock, they execute in hard real time.
  4. You can generate code for multiple instances of a Stateflow chart or subsystem containing a chart, except when the chart contains exported graphical functions.
  5. In the Configuration Parameters dialog box, for the Code interface packaging field, select Reusable function.
  6. Requires an Embedded Coder license.

See Also

Topics