Writing S-Functions | ![]() ![]() |
Ada S-Function Specification
The specification specifies the methods that the Ada S-function uses and implements. The specification must specify that the Ada S-function uses the Simulink
package, which defines data types and functions that the S-function can use to access the internal data structure (SimStruct) that Simulink uses to store information about the S-function (see SimStruct Functions). The specification and body of the Simulink
package reside in the matlabroot
/simulink/ada/interface/
directory.
The specification should also specify each callback method that the S-function implements as an Ada procedure exported to C. The following is an example of an Ada S-function specification that meets these requirements.
-- The Simulink API for Ada S-Function with Simulink; use Simulink; package Times_Two is -- The S_FUNCTION_NAME has to be defined as a constant -- string. -- S_FUNCTION_NAME : constant String := "times_two"; -- Every S-Function is required to have the -- "mdlInitializeSizes" method. -- This method needs to be exported as shown below, with the -- exported name being "mdlInitializeSizes". -- procedure mdlInitializeSizes(S : in SimStruct); pragma Export(C, mdlInitializeSizes, "mdlInitializeSizes"); procedure mdlOutputs(S : in SimStruct; TID : in Integer); pragma Export(C, mdlOutputs, "mdlOutputs"); end Times_Two;
![]() | Ada S-Function Source File Format | Ada S-Function Body | ![]() |