| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Real-Time Workshop |
| Contents | Index |
| Learn more about Real-Time Workshop |
| On this page… |
|---|
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:
Code element hyperlinks (indicated with underlining) that you can use to trace through and toggle between generated source and header files.
Tags in code comments that identify blocks from which lines of code are generated.
A traceability tag appears in a comment above the corresponding line of generated code. The format of the tags is <system>/block_name, where
system is one of the following:
The string Root
A unique system number assigned by the Simulink engine
block_name is the name of the source block
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 */
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);
To trace generated code back to the corresponding source system or block in a model:
Open the source model.
In an editor or in the context of an HTML code generation report, open a generated source or header file.
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.
In HTML code generation reports, the traceability report sections have the following limitations:
Under the following conditions, code-to-model traceability is disabled for a block if the block name contains:
A single quote (').
An asterisk (*), that causes a name-mangling ambiguity relative to other names in the model. This name-mangling ambiguity occurs if in a block name or at the end of a block name, an asterisk precedes or follows a slash (/).
The character ÿ (char(255)).
After building a model, if you move the .mdl file to a different directory, traceability might not work.
![]() | About Generated Code Verification | Profiling Code Performance | ![]() |

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 |