User`s guide

Open Architecture of the Real-Time Workshop
1-19
Language Compiler Reference Guide, which contains detailed descriptions of
the contents of
model.rtw files.
Basic Features of example.c
Using the example.rtw file and target files, the Target Language Compiler
creates C code that you can use in stand-alone or real-time applications. The
generated C code consists of procedures that must be called by your target’s
execution engine.
These procedures consist of the algorithms defined by your Simulink block
diagram. The execution engine executes the procedures as time moves forward.
In addition to executing the generated procedures, your target may provide
capabilities such as data logging. The modules that implement the execution
engine and other capabilities are referred to collectively as the run-time
interface modules.
For our example, the generated
MdlOutputs function, which is where the actual
algorithm (multiplying a sine wave by a gain) occurs, is shown below.
void MdlOutputs(int_T tid)
{
/* local block i/o variables */
real_T rtb_temp0;
/* Sin Block: <Root>/Sine Wave */
rtb_temp0 = rtP.Sine_Wave_Amp *
sin(rtP.Sine_Wave_Freq * ssGetT(rtS) + rtP.Sine_Wave_Phase);
/* Gain Block: <Root>/Gain */
rtb_temp0 *= rtP.Gain_Gain;
/* Outport Block: <Root>/Out1 */
rtY.Out1 = rtb_temp0;
}
MdlOutputs
must be called at every time step by the run-time interface. This
example demonstrates the efficiency of generated Real-Time Workshop code.
The code in
MdlOutputs reuses rtb_temp0, a temporary buffer, rather than