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:

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.

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 in
matlabroot/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