Products & Services Solutions Academia Support User Community Company

Learn more about Real-Time Workshop   

Tracing Generated Code

About Code Traceability

The Real-Time Workshop code generator produces the HTML code generation report for a model. The report includes the following resources that support code traceability:

Format of Traceability Tags

A traceability tag appears in a comment above the corresponding line of generated code. The format of the tags is <system>/block_name, where

The Real-Time Workshop code generator documents all the tags for a model in the comments section of the generated header file model.h. For example, the following comment appears in the header file for model, foo, that has a subsystem Outer and a nested subsystem Inner:

/* Here is the system hierarchy for this model.
 *
 * <Root> : foo
 * <S1>   : foo/Outer
 * <S2>   : foo/Outer/Inner
 */

Examples of Tagged Code

The following code shows a tag comment adjacent to a line of code. This code is generated from a Gain block at the root level of a source model:

/* Gain: '<Root>/UnDeadGain1' */
rtb_UnDeadGain1_h = dead_gain_U.In1 *
  dead_gain_P.UnDeadGain1_Gain;

The following code shows a tag comment adjacent to a line of code. This code is generated from a Gain block within a subsystem one level below the root level of the source model:

/* Gain Block: <S1>/Gain */
dead_gain_B.temp0 *= (dead_gain_P.s1_Gain_Gain);

Tracing Code To Blocks Using hilite_system

To trace generated code back to the corresponding source system or block in a model:

  1. Open the source model.

  2. In an editor or in the context of an HTML code generation report, open a generated source or header file.

  3. As you review lines of code, note traceability tags that correspond to code of interest. In the model diagram, highlight the block that corresponds to a line of code by entering the hilite_system command with the traceability tag that marks that code. The command changes the color of the outline and label of the corresponding block and fills the block with shading.

    For example, suppose the traceability tag <Root>/x appears in code generated for model foo . In this case, enter the following commands to highlight block x:

    hilite_system('foo/x')
    
    hilite_system('<Root>/x')

    The following figure shows block x highlighted.

    You can also use the hilite_system command to highlight a subsystem. Specify the subsystem using its system name or label. For example, you can highlight subsystem S2, which is labeled bar, using either of the following commands:

    hilite_system('<S2>')
    
    hilite_system('<Root>/bar')

If you have a Real-Time Workshop Embedded Coder license, HTML code generation reports display hyperlinks in "Regarding," "Outport," and other comment lines. In addition, you can trace subsystems and blocks to corresponding generated code. For more information, see About Traceability Extensions in the Real-Time Workshop Embedded Coder documentation.

For more information on using HTML code generation reports for traceability analysis, see Reviewing Generated Code.

Traceability Limitations

In HTML code generation reports, the traceability report sections have the following limitations:

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS