| Real-Time Workshop® Embedded Coder™ | ![]() |
| On this page… |
|---|
Generating an HTML Code Generation Report Using Code-to-Model Traceability Using Model-to-Code Traceability Using the Model-to-Code Navigation Dialog Box to Load Existing Trace Information |
The Real-Time Workshop® Embedded Coder™ code generation report is an enhanced version of the HTML code generation report normally generated by the Real-Time Workshop® build process. The report consists of several sections:
The Generated Source Files section of the Contents pane contains a table of source code files generated from your model. You can view the source code in a MATLAB® Web browser window.
If you selected the traceability option Code-to-model, hyperlinks within the displayed source code let you view the blocks or subsystems from which the code was generated. Click on the hyperlinks to view the relevant blocks or subsystems in a Simulink® model window.
If you selected the traceability option Model-to-code, traceability support lets you view the generated code for any block in the model. To highlight a block's generated code in the HTML report, right-click the block and select Real-Time Workshop > Navigate to Code.
The Summary section lists version and date information, TLC options used in code generation, and Simulink model settings. The Configuration Settings at the Time of Code Generation link opens a noneditable view of the Configuration Parameters dialog that shows all of the settings at the time of code generation.
The Traceability Report section lists eliminated and virtual blocks versus Simulink blocks, Stateflow® objects, and Embedded MATLAB™ scripts, helping to provide a complete mapping between your model and your generated code.
The Subsystem Report section contains information on nonvirtual subsystems in the model.
To generate a code generation report,
Open the Configuration Parameters dialog box or Model Explorer and navigate to the Real-Time Workshop > Report pane.
Select Create code generation report. By default, Launch report automatically and Code-to-model also are selected, and Model-to-code is cleared, as shown in the figure below.
You can select or clear any of these options as desired.

Generate code from your model or subsystem (for example, for a model, by clicking Build on the Real-Time Workshop pane of the Configuration Parameters dialog box).
The Real-Time Workshop build process writes the code generation report files in the html subdirectory of the build directory. The top-level HTML report file is named model_codegen_rpt.html or subsystem_codegen_rpt.html.
If you selected Launch report automatically, the Real-Time Workshop build process automatically opens a MATLAB Web browser window and displays the code generation report.
If you did not select Launch report automatically, you can open the code generation report (model_codegen_rpt.html or subsystem_codegen_rpt.html) manually into a MATLAB Web browser window, or into another Web browser.
If you selected Code-to-model, hyperlinks to blocks in the generating model are created in the report files. When you view the report files in a MATLAB Web browser, clicking on these hyperlinks displays and highlights the referenced blocks in the model. For more information, see Using Code-to-Model Traceability.
If you selected Model-to-code, model-to-code highlighting support is included in the generated HTML report. To highlight the generated code for a block in your Simulink model, right-click the block and select Real-Time Workshop > Navigate to Code. This selection highlights the generated code for the block in the HTML code generation report. For more information, see Using Model-to-Code Traceability and Viewing the Traceability Report.
Notes
|
To use Code-to-model,
Open an ERT-based model and go to the Real-Time Workshop + Report pane of the Configuration Parameters dialog box. Select the option Create Code Generation report. By default, Launch report automatically and Code-to-model also are selected.

Build your model. This will launch an HTML code generation report.
In the HTML report window, click any of the hyperlinks present to highlight the source block. For example, in the HTML report shown below for the demo model rtwdemo_hyperlinks, you could click the first UnitDelay hyperlink in the generated code for the model step function.

Making this selection highlights the corresponding source block in the Simulink model window.

See also the demo rtwdemo_hyperlinks, which walks you through using Code-to-model .
To use Model-to-code,
Open an ERT-based model and go to the Real-Time Workshop > Report pane of the Configuration Parameters dialog box. Select the options Create Code Generation report, Launch report automatically, and Model-to-code. (Selecting Model-to-code also enables the Configure button, which you can use to open the Model-to-code dialog box; see Using the Model-to-Code Navigation Dialog Box to Load Existing Trace Information.)

Build your model. This launches an HTML code generation report.
In the model window, right-click any block. In the right-click menu, select Real-Time Workshop > Navigate to Code.
This selection highlights the generated code for the block in the HTML code generation report. The total number of highlighted lines is displayed next to each source file name in the left panel of the HTML report. Previous and Next buttons help you navigate through the highlighted lines.

See also the demo rtwdemo_hyperlinks, which walks you through using Model-to-code.
Note If you later close and reopen your model, you may find that you cannot use right-click/Real-Time Workshop > Navigate to Code to trace a block's code, because Navigate to Code is greyed out. This means that a build directory for your model cannot be found in the current working directory. To address this you can do any of the following:
|
To open the Model-to-code navigation dialog box, click the Configure button on the Real-Time Workshop > Report pane of the Configuration Parameters dialog box. You can use this dialog box to reconnect your model with a previously-generated build directory, including trace information for model-to-code highlighting.

If you find that you cannot use right-click Real-Time Workshop > Navigate to Code to trace a block's code, because Navigate to Code is greyed out, it means that a build directory for your model cannot be found in the current working directory. To fix this without having to reset the current working directory or rebuild the model,
Click the Configure button to launch the Model-to-code navigation dialog box.
In the dialog box, click the Browse button, browse to the build directory for your model, and select the directory. The build directory path should be displayed in the Build directory field of the dialog box, as shown in the example above.
Click Apply or OK. This loads trace information from the earlier build into your Simulink session, provided that you selected Model-to-code for the build.
Now you can now successfully use right-click Real-Time Workshop > Navigate to Code to trace a block's code.
When you select the Model-to-code parameter discussed in the previous section, the generated HTML report contains a traceability report. The traceability report contains sections that allow you to account for Eliminated / Virtual Blocks versus Traceable Simulink Blocks, providing a complete mapping between blocks and code.

See the demo rtwdemo_hyperlinks, which walks you through using the traceability report.
The following limitations apply to the traceability features of HTML code generation reports.
If a block name in your model contains a single quote ('), code-to-model and model-to-code are disabled for that block.
If an asterisk (*) in a block name in your model causes a name-mangling ambiguity relative to other names in the model, code-to-model highlighting and model-to-code highlighting are disabled for that block. This is most likely to occur if an asterisk precedes or follows a slash (/) in a block name or appears at the end of a block name.
If a block name in your model contains the character ÿ (char(255)), code-to-model highlighting and model-to-code highlighting are disabled for that block.
Some types of subsystems are not traceable using Model-to-code at the subsystem block level:
Virtual subsystems
Masked subsystems
Nonvirtual subsystems for which code has been optimized away
If you cannot trace a subsystem at subsystem level, you may be able to trace individual blocks within the subsystem.
![]() | Tips for Optimizing the Generated Code | Automatic S-Function Wrapper Generation | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |