Writing S-Functions    
ssSetInputPortReusable

Specify whether where memory allocated to port is reusable.

Syntax

Arguments

S
   SimStruct representing an S-Function block or a Simulink model.

port
   Index of the input port whose reusability is being set.

isReusable
   Value specifying whether port is reusable.

Description

Use in mdlInitializeSizes (after ssSetNumInputPorts) to specify whether the input port memory buffer can be reused by other signals in the model. This macro can take one of two values:

In Simulink, reusable signals share the same memory space. When this macro is turned on, the input port signal to the S-function can be reused by other signals in the model. This reuse results in less memory use during Simulink simulation and more efficiency in the Real-Time Workshop generated code.

You must use caution when using this macro; you can safely turn it on only if the S-function reads its input port signal in its mdlOutputs routine and does not access this input port signal until the next call to mdlOutputs.

When an S-function's input port signal is reused, other signals in the model overwrite it prior to the execution of mdlUpdate, mdlDerivatives, or other run-time S-function routines. For example, if the S-function reads the input port signal in its mdlUpdate routine, or reads the input port signal in the mdlOutputs routine and expects this value to be persistent until the execution of its mdlUpdate routine, turning this attribute on is incorrect and leads to erroneous results.

The default setting, off, is safe. It prevents any reuse of the S-function input port signals, which means that the inport port signals have the same values in any run-time S-function routine during a single execution of the simulation loop.

Note that this is a suggestion and not a requirement for the Simulink engine. If Simulink cannot resolve buffer reuse in local memory, it resets value=0 and places the input port signals into global memory.

Languages

C

See Also

ssSetNumInputPorts, ssSetInputPortOverwritable, ssSetOutputPortReusable


  ssSetInputPortRequiredContiguous ssSetInputPortSampleTime