| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Real-Time Workshop |
| Contents | Index |
| Learn more about Real-Time Workshop |
If possible, use one of the following mechanisms to automate block creation:
Legacy Code Tool (see Integrating Existing C Functions into Simulink Models with the Legacy Code Tool in the Simulink documentation)
S-Function Builder block (see the block description)
If you create a block from an S-function, rather than as a masked subsystem of built-in Simulink blocks, inline the S-function, using a Target Language Compiler (TLC) file. The easiest way to inline external code is to use the Legacy Code Tool. For more information, see Inlining S-Functions with TLC in the Target Language Compiler documentation and the following Simulink topics:
If you create a block for a model for which generated code is intended for production deployment, avoid:
Accessing absolute time values. If a block depends on absolute time and the time value reaches the largest value that can be represented by the data type used by the timer to store time, the timer overflows and the logged time or block output is no longer correct. For more information, seeUsing Timers.
Avoid using continuous sample times. Although you can generate code for blocks that use continuous time (for example, if you specify a fixed-step ODE solver), the execution performance and stability of code generated from models that do not use continuous sample times is much better. For more information, see Using Discrete and Continuous Time.
If possible, avoid creating multirate S-function blocks. Such blocks have complex data handling requirements when you use them in a multitasking solver mode. For more information, see Creating Multitasking-Safe, Multirate, Port-Based Sample Time S-Functions.
![]() | Block Set Support for Code Generation | Scheduling Considerations | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |