| Real-Time Workshop User's Guide | ![]() |
Models with S-Functions
Real-Time Workshop Ada Coder does not currently support non-inlined S-functions. For Real-Time Workshop code generation purposes, you can create a wrapper S-function that calls an Ada S-function.
It is possible, however, to generate Ada code for models with inlined Ada or C S-functions. To do so, you must create a TLC file that incorporates the algorithm from your S-function.
The following example shows how to write a TLC file to inline a simple Ada S-function. For more information on writing TLC files, see the Target Language Compiler Reference Guide.
Create model times2 using these blocks:
timestwo Ada S-function (provided in the matlabroot/toolbox/simulink/blocks/tlc_ada directory) with no parameters set (i.e., leave the Parameters field blank)Your model should look like this picture.

The times2 model contains a simple S-function, called timestwo, that takes the input sine wave signal and doubles its amplitude. The TLC file corresponding to the S-function is shown below.
%% Copyright (c) 1990-2000 by The MathWorks, Inc. %% %% Abstract: %% TLC file for timestwo.c used in Real-Time Workshop %% S-Function test. %implements "timestwo" "Ada" %% Function: Outputs ========================================================== %function Outputs(block, system) Output -- %<Type> Block: %<Name> -- Multiply input by two %<LibBlockOutputSignal(0, "", "", 0)> := ... %<LibBlockInputSignal(0, "", "", 0) > * 2.0; %endfunction %% [EOF] timestwo.tlc
The key line in this TLC file is the assignment of two times the LibBlockInputSignal to the LibBlockOutputSignal. This line directs the Target Language Compiler to place the algorithm directly into the generated Ada code.
This TLC file is located inmatlabroot/toolbox/simulink/blocks/tlc_ada/timestwo.tlc.
Generating the Ada Code
The build process is similar to the case where your model does not contain any S-functions. The only additional requirement for generating Ada code for models containing S-functions is to provide a TLC file with the same name as the S-function. Otherwise, the build procedure is exactly the same.
| Getting Started | Configuring the Template Makefile | ![]() |