User`s guide

Quick Start Tutorials
3-33
5 The generated code is in the build directory, example_grt_rtw. The file
example_grt_rtw\example.c contains the output computation for the
model. Open this file into the MATLAB editor:
edit example_grt_rtw\example.c
6 In example.c, find the function example_output near the top of the file.
The generated C code consists of procedures that implement the algorithms
defined by your Simulink block diagram. The execution engine calls the
procedures in proper succession as time moves forward. The modules that
implement the execution engine and other capabilities are referred to
collectively as the run-time interface modules. See the Real-Time Workshop
User’s Guide documentation for a complete discussion of how Real-Time
Workshop interfaces and executes application, system-dependent, and
system-independent modules, in each of the two styles of generated code.
In code generated for
example, the generated example_output function
implements the actual algorithm for multiplying a sine wave by a gain. The
example_output function computes the model’s block outputs. The
run-time interface must call
example_output at every time step.
With buffer optimizations turned off,
example_output assigns unique
buffers to each block output. These buffers (
rtB.sin_out, rtB.gain_out)
are members of a global block I/O data structure, called in this code
example_B. and declared as follows:
BlockIO_example example_B;
The data type BlockIO_example is defined in example.h as follows:
typedef struct _BlockIO_example {
real_T sin_out;
real_T gain_out;
} BlockIO_example;
The output code (without comments) accesses fields of this global structure,
as is shown below:
static void example_output(int_T tid)
{
example_B.sin_out = example_P.SineWave_Amp *
sin(example_P.SineWave_Freq * example_M->Timing.t[0] +