Level-1 Versus Level-2 S-Functions

There are two main strategies to executing Fortran code from the Simulink® software. One is from a Level-1 Fortran-MEX (F-MEX) S-function, the other is from a Level-2 gateway S-function written in C. Each has its advantages and both can be incorporated into code generated by the Simulink Coder™ product. If you have Simulink Coder, to have complete code generation with the software, you must inline the Fortran S-function. For more information, see Inlining S-Functions.

The original S-function interface was called the Level-1 API. As the Simulink product grew, the S-function API was rearchitected into the more extensible Level-2 API. This allows S-functions to have all the capabilities of a full Simulink model (except automatic algebraic loop identification and solving).

    Note:   The Level-1 API supports creation of S-functions having only continuous sample time. If you want to create a Fortran S-function with a discrete sample time, you must use the Level-2 API.

For more information, see:

Was this topic helpful?