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.