| 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 |
The Real-Time Workshop code reuse feature generates code for a subsystem in the form of a single function that is invoked wherever the subsystem occurs in the model (see Creating Subsystems). If a subsystem contains S-functions, the S-functions must be compatible with the code reuse feature. Otherwise, the code generator might not generate reusable code from the subsystem or might generate incorrect code.
If you want your S-function to support the subsystem code reuse feature, you must ensure that the S-function meets the following requirements:
The S-function must be inlined.
Code generated from the S-function must not use static variables.
The S-function must initialize its pointer work vector in mdlStart and not before.
The S-function must not be a sink that logs data to the workspace.
The S-function must register its parameters as run-time parameters in mdlSetWorkWidths. (It must not use ssWriteRTWParameters in its mdlRTW function for this purpose.)
The S-function must not be a device driver.
In addition to meeting the preceding requirements, your S-function must set the SS_OPTION_WORKS_WITH_CODE_REUSE flag (see the description of ssSetOptions in the Simulink Writing S-Function documentation). This flag assures the code generator that your S-function meets the requirements for subsystem code reuse.
![]() | Writing S-Functions That Specify Sample Time Inheritance Rules | Writing S-Functions for Multirate Multitasking Environments | ![]() |

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 |