Writing S-Functions | ![]() ![]() |
Building an Ada S-Function
To use your Ada S-function with Simulink, you must build a MATLAB executable (MEX) file from the Ada source code for the S-function. Use the MATLAB mex
command to perform this step.
The mex
syntax for building an Ada S-function MEX file is
where SFCN.ads
is the name of the S-function's package specification.
For example, to build the timestwo
S-function example that comes with Simulink, enter the command
Ada Compiler Requirements
To build a MEX file from Ada source code, using the mex
tool, you must have previously installed a copy of version 3.12 (or higher) of the GNAT Ada95 compiler on your system. You can obtain the latest Solaris, Windows, and GNU-Linux versions of the compiler at the GNAT ftp site (ftp://cs.nyu.edu/pub/gnat
). Make sure that the compiler executable is in MATLAB's command path so that the mex
tool can find it.
The GNAT Ada95 compiler package used to include gnatdll.exe
, a tool for building DLLs on Windows. This tool, which is required to build Ada MEX files on Windows, now comes as part of a separate gnatwin
package containing Windows-specific files. If you want to build Ada S-functions on a Windows system, you must download and install the gnatwin
package as well as the GNAT Ada95 compiler.
![]() | Writing Callback Methods in Ada | Example of an Ada S-Function | ![]() |