Writing S-Functions | ![]() ![]() |
Syntax
Arguments
S
SimStruct representing an S-Function block.
Description
Use in mdlInitializeSizes
to specify S-function options (see following). The options must be joined using the OR
operator. For example:
S-Function Options
An S-function can specify the following options, using ssSetOptions
:
SS_OPTION_EXCEPTION_FREE_CODE
mexErrMsgTxt
, mxCalloc
, or any other routines that can throw an exception when called, you can set this option for improved performance.
SS_OPTION_RUNTIME_EXCEPTION_FREE_CODE
SS_OPTION_EXCEPTION_FREE_CODE
except it only applies to the run-time routines mdlGetTimeOfNextVarHit, mdlOutputs, mdlUpdate, and mdlDerivatives.
SS_OPTION_DISCRETE_VALUED_OUTPUT
SS_OPTION_PLACE_ASAP
SS_OPTION_ALLOW_INPUT_SCALAR_EXPANSION
SS_OPTION_DISALLOW_CONSTANT_SAMPLE_TIME
SS_OPTION_ASYNCHRONOUS
SS_OPTION_ASYNCHRONOUS
option is ignored. Use this option when driving function-call subsystems to attached to interrupt service routines.
SS_OPTION_ASYNC_RATE_TRANSITION
SS_OPTION_ASYNC_RATE_TRANSITION
in symstruc.h for more information.
SS_OPTION_PORT_SAMPLE_TIMES_ASSIGNED
ssSetNumSampleTimes > 1
) to specify the rate at which each input and output port is running. The simulation engine needs this information when checking for illegal rate transitions.
SS_OPTION_SFUNCTION_INLINED_FOR_RTW
.tlc
file for your S-function and do not have an mdlRTW method. Setting this option has no effect if you have an mdlRTW
method.
SS_OPTION_ALLOW_PARTIAL_DIMENSIONS_CALL
SS_OPTION_FORCE_NONINLINED_FCNCALL
SS_OPTION_USE_TLC_WITH_ACCELERATOR
mex
version of the S-function even though a TLC file for the S-function exists. This option should not be set for device driver blocks (A/D) or when there is an incompatibility between running the mex Start/InitializeConditions
functions together with the TLC Outputs/Update/Derivatives
.
SS_OPTION_SIM_VIEWING_DEVICE
SimViewingDevice
. As long as it meets the other requirements for this type of block (no states, no outputs, etc.), it is considered to be an external mode block (it show up in the external mode GUI and no code is generated for it). During an external mode simulation, this block is run on the host only.
SS_OPTION_CALL_TERMINATE_ON_EXIT
UserData
. Setting this option guarantees that the mdlTerminate function is called if mdlInitializeSizes is called. This means that mdlTerminate
is called:
Note that it does not matter if the simulation fails and at what stage the simulation fails. Therefore, if the mdlSetWorkWidths
of some block errors out, the model's other blocks have a chance to free the memory during a call to mdlTerminate
.
If this option is not set, mdlTerminate
is called only if at least one of the blocks has had its mdlStart
called.
SS_OPTION_REQ_INPUT_SAMPLE_TIME_MATCH
generates an error if this option is set. If the block (or input port) sample time is inherited, no error is generated.
SS_OPTION_WORKS_WITH_CODE_REUSE
SS_OPTION_ALLOW_CONSTANT_PORT_SAMPLE_TIME
SS_OPTION_ALLOW_PORT_BASED_SAMPLE_TIME_IN_TRIGSS
Languages
![]() | ssSetOffsetTime | ssSetOutputPortComplexSignal | ![]() |