Target Language Compiler    

Using a Wrapper S-Function Inlined with TLC

When to Consider?

Assume that the file wrapfcn.c contains an existing function called wrapfcn. In this case, you have the source code, however, making the correct changes for compilation, you could also link against an existing library if the source code is not available. For example, suppose you had an existing object file compiled for a TI DSP, or, for some other processor where Simulink does not run. You could write a dummy C S-function and use a TLC wrapper that would provide a call to the external function, for which you do not have its source code. For instance, this could be the case if you had a library for an FFT algorithm optimized for your target processor. You would also make appropriate changes to a template makefile, or, somehow provide a means of linking against the library. Now that you understand why you might want to do this, let's look at an example.

Objective: Learn about wrapper S-functions and how to create an inlined wrapper S-function using TLC.

The purpose of a wrapper S-function is to enable a user to pull in an existing C or Ada function without fully rewriting it in the context of a Simulink S-function. Basically, you write a simplified S-function that merely calls the existing, external function.

The only requirement for the dummy C coded S-function is to make sure that it uses the correct number of inputs and outputs. Other than that, the S-function does not need to provide correct computations, unless we find it necessary to use these computations to obtain correct simulation results in Simulink - prior to generating real-time code.


 Code Coverage for Debugging TLC Files Exercise