Real-Time Workshop    

How Do I...

If you need specific details about how to use Real-Time Workshop, scan the topics and descriptions below to locate documentation relevant to your development tasks and interests. You can also search the index to find information not included in this list.

Operate the Real-Time Workshop User Interface

You control most aspects of code generation through the Real-Time Workshop tab of the Simulation Parameters dialog, and the dialogs descending from it. See The Real-Time Workshop User Interface for full descriptions of the options at your disposal.

Select Targets and Customize Compilation

Setting up targets for code generation is simple with the Target File Browser, described in Selecting a Target Configuration. Look there also for information on configuring compilers (Choosing and Configuring Your Compiler) and modifying makefiles (Template Makefiles and Make Options). For details on working with specific targets, see The S-Function Target, Real-Time Workshop Rapid Simulation Target, Targeting Tornado for Real-Time Applications, Appendix C, "Targeting DOS for Real-Time Applications, and the Real-Time Workshop Embedded Coder documentation.

Generate Single- and Multitasking Code

Real-Time Workshop fully supports singletasking and multitasking code generation. See See "Program Architecture and See "Models with Multiple Sample Rates for a complete description.

Customize Generated Code

Real-Time Workshop supports customization of the generated code.

The principle approach to customizing generated code is to modify Target Language Compiler (TLC) files. The Target Language Compiler is an interpreted language that translates Simulink models into C code. Using the Target Language Compiler, you can direct the code generation process.

There are two TLC files, hookslib.tlc and cachelib.tlc, that contain functions you can use to customize Real-Time Workshop generated code. See the Target Language Compiler documentation for details on these TLC files. See also the source code, located in matlabroot/rtw/c/tlc/lib/cachelib.tlc and matlabroot/rtw/c/tlc/mw/hookslib.tlc.

Optimize Generated Code

The default code generation settings are generic for flexible rapid prototyping systems. The penalty for this flexibility is code that is less than optimal. There are several optimization techniques that you can use to minimize the source code size and memory usage once you have a model that meets your requirements.

See Code Generation and the Build Process and Optimizing the Model for Code Generation for details on code optimization techniques available for all target configurations.

The Real-Time Workshop Embedded Coder documentation contains information about optimization specifically for embedded code.

Make Subsystem Code Reuseable

If your models contain multiple references to the same atomic subsystem, you can ask Real-Time Workshop to generate a single reentrant function to represent the subsystem, rather than inlining it or generating multiple functions that all do the same thing. Building Subsystems tells how to do this, and describes model characteristics that can limit or prevent subsystem reuse.

Validate Generated Code

Using Real-Time Workshop data logging features, you can create an executable that runs on your workstation and creates a data file. You can then compare the results of your program with the results of running an equivalent Simulink simulation.

For more information on how to validate Real-Time Workshop generated code, see Workspace I/O Options and Data Logging. See also Tutorial 2: Data Logging and Tutorial 3: Code Validation of the Real-Time Workshop Getting Started Guide.

Incorporate Generated Code into Larger Systems

If your Real-Time Workshop generated code is intended to function within an existing code base (for example, if you want to use the generated code as a plug-in function), you should use Real-Time Workshop Embedded Coder. The Real-Time Workshop Embedded Coder documentation describes the entry points and header files you will need to interface your code to Real-Time Workshop Embedded Coder generated code.

Incorporate Existing Code into Generated Code

To interface your hand-written code with Real-Time Workshop generated code, you can use an S-function wrapper. See the Simulink Writing S-Functions documentation and the Target Language Compiler documentation for more information.

Create and Communicate with Device Drivers

S-functions provide a flexible method for communicating with device drivers. See Targeting Real-Time Systems for a description of how to build device drivers. Also, for a complete discussion of S-functions, see the Simulink Writing S-Functions documentation.

Trace Code back to Blocks

Real-Time Workshop includes special tags throughout the generated code that make it easy to trace generated code back to your Simulink model. See Tracing Generated Code Back to Your Simulink Model of the Getting Started Guide for more information about this feature.

Automate Builds

Using Real-Time Workshop, you can generate code with the push of a button. The automatic build procedure, initiated by a single mouse click, generates code, a makefile, and optionally compiles (or cross-compiles) and downloads a program. See Automatic Program Building of the Getting Started guide for an overview, and Code Generation and the Build Process for complete details.

Tune Parameters During Execution

Parameter tuning enables you to change block parameters while a generated program runs, thus avoiding recompiling the generated code. Real-Time Workshop supports parameter tuning in four different environments:

See also Interface with Signals and Parameters.

Monitor Signals and Log Data

There are several ways to monitor signals and data in Real-Time Workshop:

Interface with Signals and Parameters

You can interface signals and parameters in your model to hand-written code by specifying the storage declarations of signals and parameters. For more information, see

Learn from Sample Implementations

Real-Time Workshop provides sample implementations that illustrate the development of real-time programs under DOS and Tornado, as well as generic real-time programs under Windows and UNIX.

These sample implementations are located in the following directories:


  Where to Find Help Code Generation and the Build Process