Advice About TLC Tutorials

The fastest and easiest way to understand the Target Language Compiler (TLC) is to run it, paying attention to how TLC scripts transform compiled Simulink® models (model.rtw files) into source code. The tutorials highlight the principal reasons for and techniques of using TLC. The tutorials provide a number of TLC exercises, each one organized as a major section.

The example models, S-functions, and TLC files for the exercises are located in the folder matlabroot/toolbox/rtw/rtwdemos/tlctutorial (open). In this chapter, this folder is referred to as tlctutorial. Each example is located in a separate subfolder within tlctutorial. Within that subfolder, you can find solutions to the problem in a solutions subfolder.


Before you begin the tutorial, copy the entire tlctutorial folder to a local working folder. The files are together, and if you make mistakes or want fresh examples to try again, you can recopy files from the original tlctutorial folder.

Each tutorial exercise is limited in scope, requiring just a small amount of experimentation. The tutorial explains details about TLC that will help customize and optimize code for code generation projects.


You should not customize TLC files in the folder matlabroot/rtw/c/tlc even though the capability exists to do so. Such TLC customizations might not be applied during the code generation process and can lead to unpredictable results.

The tutorials progress in difficulty from basic to more advanced. To get the most out of them, you should be familiar with

  • Working in the MATLAB® environment

  • Building Simulink models

  • Using the code generator to produce code for target systems

  • High-level language concepts (for example, C or Fortran programming)

If you encounter terms in the tutorials that you do not understand, it may be helpful to read Code Generation Concepts to acquaint yourself with the basic goals and methods of TLC programming. Similarly, if you see TLC keywords, built-in functions, or directives that you would like to know more about, see the corresponding topics on Target Language Compiler.

The examples used in the tutorial are:

guideIllustrative record file
timesNAn example C file S-function for multiplying an input by N
tlcdebugAn example using TLC Debugger
wrapperExample TLC file for S-function wrapsfcn.c

Related Topics