| Real-Time Workshop® Embedded Coder™ | ![]() |
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. In the report,
The Summary section lists version and date information. The Configuration Settings at the Time of Code Generation link opens a noneditable view of the Configuration Parameters dialog that shows the Simulink model settings, including TLC options, at the time of code generation.
The Subsystem Report section contains information on nonvirtual subsystems in the model.
The Code Interface Report section provides information about the generated code interface, including model entry point functions and input/output data.
The Traceability Report section allows you to account for Eliminated / Virtual Blocks that are untraceable, versus the listed Traceable Simulink Blocks / Stateflow Objects / Embedded MATLAB Scripts, providing a complete mapping between model elements and code.
In the Generated Source Files section of the Contents pane, you can click the names of source code files generated from your model to view their contents in a MATLAB Web browser window. In the displayed source code,
Global variable instances are hyperlinked to their definitions.
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, you can 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.
To generate a Real-Time Workshop Embedded Coder code generation report,
With your ERT-based model open, open the Configuration Parameters dialog box or Model Explorer and navigate to the Real-Time Workshop > Report pane.
Select Create code generation report if it is not already selected. 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 Using the Traceability Report to Completely Map Model Elements to Code.
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 if it is not already selected. By default, Launch report automatically and Code-to-model also are selected.

Build or generate code for 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.

Clicking the UnitDelay hyperlink 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, if they are not already selected.
Selecting Model-to-code enables the Configure button, which you can use to open the Model-to-code navigation dialog box; see Using the Model-to-Code Navigation Dialog Box to Load Existing Trace Information. Selecting Model-to-code also enables and selects content options for generating a Traceability Report, described in Using the Traceability Report to Completely Map Model Elements to Code.

Build or generate code for 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.
Selecting Navigate to Code highlights the generated code for the block in the HTML code generation report and takes you to the first instance. The total number of highlighted lines is displayed next to each source file name in the left panel of the HTML report. To navigate through multiple instances of highlighted lines, use the Previous and Next buttons.
The report below shows the result of tracing the Unit Delay block in the demo model rtwdemo_hyperlinks.

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 Create code generation report option for an ERT-based model, a Code Interface Report section is automatically included in the generated HTML report. The Code Interface Report section provides documentation of the generated code interface, including model entry point functions and interface data, for consumers of the generated code. The information in the report can help facilitate code review and code integration.
The code interface report includes the following subsections
Entry Point Functions — interface information about each model entry point function, including model_initialize, model_step, and (if applicable) model_terminate
Inports and Outports — interface information about each model inport and outport
Interface Parameters — interface information about tunable parameters that are associated with the model
Data Stores — interface information about global data stores and data stores with non-auto storage that are associated with the model
For limitations that apply to code interface reports, see Code Interface Report Limitations
Note This section uses the following demo models for illustration purposes:
|
To generate a code interface report for your model, perform the following steps.
Open your model, go to the Real-Time Workshop pane of the Configuration Parameters dialog box, and select ert.tlc or an ERT-based System target file, if one is not already selected.
Go to the Real-Time Workshop > Report pane of the Configuration Parameters dialog box and select the option Create code generation report, if it is not already selected. The rtwdemo_basicsc, rtwdemo_mrmtbb, and rtwdemo_fcnprotoctrl demo models used in this section select every Report pane option by default, but selecting Create code generation report alone is sufficient to generate a Code Interface Report section in the HTML report.
Alternatively, you can programmatically select the option by issuing the following MATLAB command:
set_param(bdroot, 'GenerateReport', 'on')
If the Report pane option Code-to-model is selected, the generated report will contain hyperlinks to the model. You should leave this value selected unless you plan to use the report outside the MATLAB environment.
Build the model. If you selected the Report pane option Launch report automatically, the code generation report opens automatically after the build process completes. (Otherwise, you can launch it manually from within the model build directory.)
To display the code interface report for your model, go to the Contents pane of the HTML report and click the Code Interface Report link. For example, here is the generated code interface report for the demo model rtwdemo_basicsc (with the ExportedGlobal Storage Class button selected in the demo model window).

For help navigating the content of the code interface report subsections, see Navigating Code Interface Report Subsections. For help interpreting the content of the code interface report subsections, see the sections beginning with Interpreting the Entry Point Functions Subsection.
To help you navigate code interface descriptions, the code interface report provides collapse/expand tokens and hyperlinks, as follows:
For any lengthy subsection, the report provides [-] and [+] symbols that allow you to collapse or expand that section. In the example in the previous section, the symbols are provided for the Inports and Interface Parameters sections.
Several forms of hyperlink navigation are provided in the code interface report. For example,
The Table of Contents located at the top of the code interface report provides links to each subsection.
You can click on each function name to go to its declaration in model.c.
You can click on each function's header file name to go to the header file source listing.
If you selected the Report pane option Code-to-model for your model, you can click on hyperlinks for any of the following to go to the corresponding location in the model display:
Function argument
Function return value
Inport
Outport
Interface parameter (if the parameter source is a block)
Data store (if the data store source is a Data Store Memory block)
For general backward and forward navigation within the HTML code generation report, use the Back and Forward buttons above the Contents section in the upper left corner of the report.
The Entry Point Functions subsection of the code interface report provides the following interface information about each model entry point function, including model_initialize, model_step, and (if applicable) model_terminate.
| Field | Description |
|---|---|
| Function: | Lists the function name. You can click on the function name to go to its declaration in model.c. |
| Prototype | Displays the function prototype, including the function return value, name, and arguments. |
| Description | Provides a text description of the function's purpose in the application. |
| Timing | Describes the timing characteristics of the function, such as how many times the function is called, or if it is called periodically, at what time interval. For a multirate timing example, see the rtwdemo_mrmtbb report excerpt below. |
| Arguments | If the function has arguments, displays the number, name, data type, and Simulink description for each argument. If you selected the Report pane option Code-to-model for your model, you can click the hyperlink in the description to go to the block corresponding to the argument in the model display. For argument examples, see the rtwdemo_fcnprotoctrl report excerpt below. |
| Return value | If the function has a return value, displays the return value data type and Simulink description. If you selected the Report pane option Code-to-model for your model, you can click the hyperlink in the description to go to the block corresponding to the return value in the model display. For a return value example, see the rtwdemo_fcnprotoctrl report excerpt below. |
| Header file | Lists the name of the header file for the function. You can click on the header file name to go to the header file source listing. |
For example, here is the Entry Point Functions subsection for the demo model rtwdemo_basicsc.

To illustrate how timing information might be listed for a multirate model, here are the Entry Point Functions and Inports subsections for the demo model rtwdemo_mrmtbb. This multirate, discrete-time, multitasking model contains Inport blocks 1 and 2, which specify 1-second and 2-second sample times, respectively. The sample times are constrained to the specified times by the Periodic sample time constraint option on the Solver pane of the Configuration Parameters dialog box.

To illustrate how function arguments and return values are displayed in the report, here is the Entry Point Functions description of the model step function for the demo model rtwdemo_fcnprotoctrl.

The Inports and Outports subsections of the code interface report provide the following interface information about each inport and outport in the model.
| Field | Description |
|---|---|
| Block Name | Displays the Simulink block name of the inport or outport. If you selected the Report pane option Code-to-model for your model, you can click on each inport or outport Block Name value to go to its location in the model display. |
| Code Identifier | Lists the identifier associated with the inport or outport data in the generated code, as follows:
|
| Data Type | Lists the data type of the inport or outport. |
| Dimension | Lists the dimensions of the inport or outport (for example, 1 or [4, 5]). |
For example, here are the Inports and Outports subsections for the demo model rtwdemo_basicsc.

The Interface Parameters subsection of the code interface report provides the following interface information about tunable parameters that are associated with the model.
| Field | Description |
|---|---|
| Parameter Source | Lists the source of the parameter value, as follows:
|
| Code Identifier | Lists the identifier associated with the tunable parameter data in the generated code, as follows:
|
| Data Type | Lists the data type of the tunable parameter. |
| Dimension | Lists the dimensions of the tunable parameter (for example, 1 or [4, 5, 6]). |
For example, here is the Interface Parameters subsection for the demo model rtwdemo_basicsc (with the ExportedGlobal Storage Class button selected in the demo model window).

The Data Stores subsection of the code interface report provides the following interface information about global data stores and data stores with non-auto storage that are associated with the model.
| Field | Description |
|---|---|
| Data Store Source | Lists the source of the data store memory, as follows:
|
| Code Identifier | Lists the identifier associated with the data store data in the generated code, as follows:
|
| Data Type | Lists the data type of the data store. |
| Dimension | Lists the dimensions of the data store (for example, 1 or [1, 2]). |
For example, here is the Data Stores subsection for the demo model rtwdemo_basicsc (with the ExportedGlobal Storage Class button selected in the demo model window).

When you select the Model-to-code traceability option discussed in Using Model-to-Code Traceability, the generated HTML report includes a Traceability Report section. The content of the generated traceability report is determined by your selections among the following options on the Real-Time Workshop > Report pane of the Configuration Parameters dialog box.

The traceability report allows you to account for Eliminated / virtual blocks that are untraceable, versus the listed Traceable Simulink blocks, Traceable Stateflow objects, and Traceable Embedded MATLAB functions, providing a complete mapping between model elements and code.
The display below shows the beginning of the traceability report generated by selecting all four traceability content options for the demo model rtwdemo_hyperlinks.

For the full report, see the demo rtwdemo_hyperlinks, which walks you through using the traceability report, and be sure to select all four traceability content options.
The following limitations apply to Real-Time Workshop Embedded Coder 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.
The code interface report does not support the GRT interface with an ERT target or the C++ (Encapsulated) language option. For these configurations, the code interface report will not be generated and will not appear in the HTML code generation report Contents pane.
The code interface report supports data resolved with most custom storage classes (CSCs), except when the CSC properties are set in any of the following ways:
The CSC property Type is set to FlatStructure. For example, the BitField and Struct CSCs in the Simulink package have Type set to FlatStructure and are not supported by the code interface report.
The CSC property Type is set to Other. For example, the GetSet CSC in the Simulink package has Type set to Other and is not supported by the code interface report.
The CSC property Data access is set to Pointer, indicating that imported symbols are declared as pointer variables rather than simple variables. This property is accessible only when the CSC property Data scope is set to Imported or Instance-specific.
In these cases, the report displays empty Data Type and Dimension fields.
For outports, the code interface report cannot describe the associated memory (data type and dimensions) if the memory is optimized. In these cases, the report displays empty Data Type and Dimension fields.
The code interface report does not support data type replacement using the Real-Time Workshop > Data Type Replacement pane of the Configuration Parameters dialog box. The data types listed in the report will link to built-in data types rather than their specified replacement data types.
![]() | Tips for Optimizing the Generated Code | Automatic S-Function Wrapper Generation | ![]() |
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |