The Simulink Model Explorer provides a single user interface in Simulink to configure all code generation settings. From the Model Explorer you can:
The Code Generation Advisor checks your model and code generation settings, and then offers advice on how to improve your configuration based on your needs. Once you have identified the optimal settings for your project, you can save them as a configuration set to reuse with other models.
Simulink Coder uses system target files to translate your models into source code and executables. Target files specify the environment on which your generated code will run. Simulink Coder includes target files for several ready-to-run configurations, and supports third-party and custom targets as well. Built-in targets include:
Generic Real-Time Target — Generates code for interactive tuning of model parameters, logs and displays real time simulation results, and allocates data statically for efficient real-time execution
Generic Real-Time Malloc Target — Uses dynamic memory allocation in the generated code, enabling you to include multiple instances of your model or multiple models in one executable
Rapid Simulation Target (RSim) — Provides a fast, flexible test platform for performing batch or Monte Carlo simulation studies using fixed-step or variable-step solvers, and lets you save data for each run to unique output files
You can extend these targets to create customized run-time interfaces and device driver files, which enables you to target your specific environment and access Simulink Coder execution and debug capabilities in it.
Simulink Coder offers built-in support for compilation and execution of generated code with popular desktop environments, including:
You can generate and deploy optimized C and C++ code in real-time embedded systems using Embedded Coder.
Simulink Coder enables you to define and control how the model data appears in the generated code. You can also manage your data by:
Simulink Coder generates code from data stored in your Simulink diagram or in a data dictionary accessed via the Simulink Model Explorer. By employing different data dictionary sets, you can redeploy code from a single model to multiple targets.
Simulink Coder also supports the Simulink product family, including fixed-point modeling, physical modeling, signal processing and communications modeling, and rapid prototyping and hardware-in the-loop (HIL) testing products.
Simulink Coder provides user-selectable options to facilitate execution of generated code in desktop and simulation environments. These options include:
Simulink Coder provides a complete framework for executing the generated code in real time and incorporating it into your execution environment. It generates single-rate or multirate code based on the periodic sample times you specify in the model.
Code can be deployed with or without an RTOS, and in single-tasking, multitasking, or asynchronous mode.
In single-tasking mode, a simple scheduler invokes the generated code in a single thread of execution, preventing preemption between rates.
In multitasking mode, a deterministic, rate-monotonic scheduler invokes the generated code, enabling preemption between rates. In a bare-board environment, you preempt the code with nested interrupts. In an RTOS environment, you use task priorities and task preemption.
In asynchronous mode, nonperiodic or asynchronous rates are specified using Simulink S-functions. Simulink Coder translates these rates into the code necessary for your execution environment. You model and generate code for events, such as hardware interrupts, and trigger subsystems as independent tasks. You can use the included asynchronous block library as a template for creating a library appropriate for other environments.
Simulink and Simulink Coder provide a complete set of target-independent capabilities for real-time deployment. These include:
You can customize the generated code and its run-time environment by incorporating custom legacy C, Fortran, Ada, and C++ code for simulation and code generation. Customization tools in Simulink Coder include a Target Language Compiler (TLC), custom code blocks, template makefiles, build process APIs, and S-Function Builder. Using the Legacy Code Tool, you can rapidly integrate existing C and C++ functions into your Simulink models, which is particularly useful for integrating discrete-time code typically used in embedded systems.
Simulink Coder helps you optimize your algorithm’s performance and improve code execution behavior by enabling you to interact with and analyze the generated executable.
Simulink Coder lets you monitor and tune block signals and parameters using the following data interfaces:
Host-based ASAP2 data exchange file — Lets you use the ASAP2 standard data description for data measurement, calibration, and diagnostic systems outside MATLAB and Simulink
Simulink External mode — Lets you download new parameter values and upload signal values to view in Simulink or to record in the MATLAB workspace. (Opening a dialog box for a source block causes Simulink to pause. While Simulink is paused, you can edit the parameter values. You must close the dialog box to have the changes take effect and allow Simulink to continue.)