Real-Time Workshop    

Choosing a Code Format for Your Application

Your choice of code format is the most important code generation option. The code format specifies the overall framework of the generated code and determines its style.

When you choose a target, you implicitly choose a code format. Typically, the system target file will specify the code format by assigning the TLC variable CodeFormat. The following example is from ert.tlc.

If the system target file does not assign CodeFormat, the default is RealTime (as in grt.tlc).

If you are developing a custom target, you must consider which code format is best for your application and assign CodeFormat accordingly.

Choose the real-time or real-time malloc code format for rapid prototyping. If your application does not have significant restrictions in code size, memory usage, or stack usage, you may want to continue using the generic real-time (GRT) target throughout development. The real-time format is the most comprehensive code format and supports almost all the built-in blocks. It is also capable of executing in "hard real time" (however, if the hard execution time constraints are not satisfied, a catastrophic system failure occurs). For further information on satisfying time constraints in both singletasking and multitasking environments, see Models with Multiple Sample Rates.

If your application demands that you limit source code size, memory usage, or maintain a simple call structure, then you should choose the Real-Time Workshop Embedded Coder target, which uses the embedded C format.

Finally, you should choose the S-function format if you are not concerned about RAM and ROM usage and want to:

Table 3-1 summarizes the various options available for each Real-Time Workshop code format/target, noting exceptions below.

Table 3-1: Features Supported by Real-Time Workshop Targets and Code Formats  
Feature
GRT
Real-
time malloc

RTW Embedded Coder
DOS
Torn-
ado

S-
Func

RSIM
RT
Win

xPC
TI
DSP

MPC 555

Static mem. allocation
X

X
X
X
X

X
X
X
X
Dynamic mem. allocation

X


X
X
X




Continuous time
X
X

X
X
X
X
X
X


C MEX S-functions
(noninlined)
X
X

X
X
X
X
X
X


Any S-function (inlined)
X
X
X
X
X
X
X
X
X
X
X
Minimize RAM / ROM usage


X







X
Supports external mode
X
X
X

X

X
X
X


Intended for rapid prototyping
X
X

X
X


X
X
X

Production code


X





X
X
X3
Batch parameter tuning and Monte Carlo methods






X




Executes in hard real time
X 1
X 1
X 1
X
X


X
X
X
X2
Non real-time executable included
X
X
X



X



X
Multiple instances of a model (no Stateflow blocks in model)

X



X




X
Supports variable-step solvers





X
X




1The default GRT, GRT malloc, and ERT rt_main files emulate execution of hard real time, and when explicitly connected to a real-time clock execute in hard real-time.
2Except MPC555 (processor-in-the-loop) and MPC555 (algorithm export) targets
3Exccept MPC555 (algorithm export) targets

  Introduction Real-Time Code Format