| Real-Time Workshop® | ![]() |
| On this page… |
|---|
Run-Time Parameters and S-Function Compatibility Diagnostics Goto and From Block Limitations |
If you set the S-function upgrades needed option on the Diagnostics > Compatibility pane of the Configuration Parameters dialog box to warning or error, the Real-Time Workshop® software reports that an upgrade is needed for any S-function you create with the Generate S-function feature. This is because the S-function target does not register run-time parameters. Run-time parameters are only supported for inlined S-Functions and the generated S-Function supports features that prevent it from being inlined (for example, it can call or contain other noninlined S-functions).
You can work around this limitation by setting the S-function upgrades needed option to none. Alternatively, if you have a Real-Time Workshop® Embedded Coder™ license, select the Use Embedded Coder option on the Generate S-function for Subsystem dialog box and generate an ERT S-function. In this case, you do not receive the upgrade messages. However, you cannot include ERT S-functions inside other generated S-functions recursively.
When using the S-function target, the Real-Time Workshop code generator restricts I/O to correspond to the root model's Inport and Outport blocks (or the Inport and Outport blocks of the Subsystem block from which the S-function target was generated). No code is generated for Goto or From blocks.
To work around this restriction, create your model and subsystem with the required Inport and Outport blocks, instead of using Goto and From blocks to pass data between the root model and subsystem. In the model that incorporates the generated S-function, you would then add needed Goto and From blocks.
Example Before Work Around
Root model with a From block and subsystem, Subsystem1

Subsystem1 with a Goto block, which has global visibility and passes its input to the From block in the root model

Subsystem1 replaced with an S-function generated with the S-Function target — a warning results when you run the model because the generated S-function does not implement the Goto block

Example After Work Around
An Outport block replaces the GoTo block in Subsystem1. When you plug the generated S-function into the root model, its output connects directly to the To Workspace block.

The following limitations apply to building and regenerating S-function targets:
You cannot build models that contain Model blocks using the Real-Time Workshop S-function target. This also means that you cannot build a subsystem module by right-clicking (or by using Tools > Real-Time Workshop > Build subsystem) if the subsystem contains Model blocks. This restriction applies only to GRT S-functions, not to ERT S-functions.
If you modify the model that generated an S-Function block, the Real-Time Workshop build process does not automatically rebuild models containing the generated S-Function block. This is in contrast to the practice of automatically rebuilding models referenced by Model blocks when they are modified (depending on the Model Reference Rebuild options configuration setting).
Handwritten S-functions without corresponding TLC files must contain exception-free code. For more information on exception-free code, see Exception Free Code in the Simulink® Writing S-Functions documentation.
The S-function format does not support the following built-in blocks:
MATLAB Fcn block
S-Function blocks containing any of the following:
M-file S-functions (unless you supply a TLC file for C code generation)
Fortran S-functions (unless you supply a TLC file for C code generation)
C/C++ MEX S-functions that call into the MATLAB® environment
Scope block
To Workspace block
![]() | Checksums and the S-Function Target | Running Rapid Simulations | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |