Real-Time Workshop    

General Code Generation Options

The general code generation options are common to all target configurations. These options are organized into two groups, selected from the Category menu, as shown in Figure 2-3 and Figure 2-4.

Figure 2-3: General Code Generation Options

Figure 2-4: General Code Generation Options (cont.)

Show Eliminated Statements Option

If this option is selected, statements that were eliminated as the result of optimizations (such as parameter inlining) appear as comments in the generated code. The default is not to include eliminated statements.

Loop Rolling Threshold Field

The loop rolling threshold determines when a wide signal or parameter should be wrapped into a for-loop and when it should be generated as a separate statement for each element of the signal. The default threshold value is 5.

For example, consider the model below

:

The gain parameter of the Gain block is the vector myGainVec.

Assume that the loop rolling threshold value is set to the default, 5.

If myGainVec is declared as

an array of 10 elements, rtP.Gain_Gain[] is declared within the Parameters data structure, rtP. The size of the gain array exceeds the loop rolling threshold. Therefore the code generated for the Gain block iterates over the array in a for loop, as shown in the following code fragment:

If myGainVec is declared as

an array of three elements, rtP.Gain_Gain[] is declared within the Parameters data structure, rtP. The size of the gain array is below the loop rolling threshold. The generated code consists of inline references to each element of the array, as in the code fragment below.

See the Target Language Compiler Reference Guide for more information on loop rolling.

Verbose Builds Option

If this option is selected, the MATLAB command window displays progress information during code generation; compiler output is also made visible.

Generate HTML Report Option

If this option is selected, Real-Time Workshop produces a code generation report in HTML format and automatically opens it for viewing in the MATLAB Help browser. The contents of the report vary from one target to another, but all reports contain the following code generation details:

The Real-Time Workshop Embedded Coder code generation report produces additional information, such as suggestions for code generation options, to help you optimize what is output. For further information see the Real-Time Workshop Embedded Coder documentation.

Inline Invariant Signals Option

An invariant signal is a block output signal that does not change during Simulink simulation. For example, the signal S3 in this block diagram is an invariant signal.

Given the model above, if both Inline parameters and Inline invariant signals are selected, Real-Time Workshop inlines the invariant signal S3 in the generated code.

Note that an invariant signal is not the same as an invariant constant. (See the Using Simulink manual for information on invariant constants.) In the above example, the two constants (1 and 2) and the gain value of 3 are invariant constants. To inline these invariant constants, select Inline parameters.

Local Block Outputs Option

When this option is selected, block signals will be declared locally in functions instead of being declared globally (when possible).

For further information on the use of the Local block outputs option, see Signals: Storage, Optimization, and Interfacing. Also go through Tutorial 4: A First Look at Generated Code of the Getting Started guide if you have not done so already.

Force Generation of Parameter Comments Option

The Force generation of parameter comments option controls the generation of comments in the model parameter structure declaration in model_prm.h. Parameter comments indicate parameter variable names and the names of source blocks.

When this option is off (the default), parameter comments are generated if less than 1000 parameters are declared. This reduces the size of the generated file for models with a large number of parameters.

When this option is on, parameter comments are generated regardless of the number of parameters.

General Code Generation Options (cont.)

Buffer Reuse Option

When the Buffer reuse option is on (the default) Real-Time Workshop reuses signal memory whenever possible. When Buffer reuse is off, signals are stored in unique locations.

Note that the Buffer reuse option is enabled only when the Signal storage reuse option on the Advanced pane of the Simulation Parameters dialog box is selected.

See Signals: Storage, Optimization, and Interfacing for further information (including generated code example) on Buffer reuse and other signal storage options.

Expression Folding Options

Expression folding is a code optimization technique that can dramatically improve the efficiency of generated code by minimizing the computation of intermediate results and the use of temporary buffers or variables.

Expression folding is enabled by default. We strongly recommended that you use this option. See Expression Folding for full details on this feature and related options that you can control from the General code generation options (cont.) pane.


  Target Configuration Options General Code Appearance Options