| Contents | Index |
The coder creates and displays an HDL Code Generation Report when you select one or more of the following options:
| GUI option | makehdl Property |
|---|---|
| Generate traceability report | Traceability, 'on' |
| Generate resource utilization report | ResourceReport, 'on' |
| Generate optimization report | OptimizationReport, 'on' |
These options appear in the Code generation report panel of the HDL Code Generation pane of the Configuration Parameters dialog box:

The HDL Code Generation Report is an HTML report that includes a Summary and one or more of the following optional sections:
All reports include a Summary section. The Summary lists information about the model, the DUT, the date of code generation, and top-level coder settings. The Summary also lists any model properties that have non-default values. The following report shows a typical Summary section.

Even a relatively small model can generate hundreds of lines of HDL code. The coder provides the traceability report section to help you navigate more easily between the generated code and your source model. When you enable traceability, the coder creates and displays an HTML code generation report. You can generate reports from the Configuration Parameters dialog box or the command line. A typical traceability report looks something like this:

The traceability report has several subsections:
The Traceability Report lists Traceable Simulink Blocks / Stateflow Objects / MATLAB Functions, providing a complete mapping between model elements and code. The Eliminated / Virtual Blocks section of the report accounts for blocks that are untraceable.
The Generated Source Files table contains hyperlinks that let you view generated HDL code in a MATLAB Web Browser window. This view of the code includes hyperlinks that let you view the blocks or subsystems from which the code was generated. You can click the names of source code files generated from your model to view their contents in a MATLAB Web Browser window. The report supports two types of linkage between the model and generated code:
Code-to-model hyperlinks within the displayed source code let you view the blocks or subsystems from which the code was generated. Click the hyperlinks to view the relevant blocks or subsystems in a Simulink model window.
Model-to-code linkage 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 HDL Code Generation > Navigate to Code.
Note If your model includes blocks that have requirements comments, you can also render the comments as hyperlinked comments within the HTML code generation report. See Requirements Comments and Hyperlinks for more information. |
In the following sections, the mcombo demonstration model illustrates stages in the workflow for generating code generation reports from the Configuration Parameters dialog box and from the command line. The model is available in the demos folder as the following file:
MATLABROOT\toolbox\hdlcoder\hdlcoderdemos\mcombo.mdl
The root-level mcombo model appears as follows:

Simulink HDL Coder supports report generation for models, subsystems, blocks, Stateflow charts, and MATLAB Function blocks. This example uses the combo subsystem, shown in the following figure. The combo subsystem includes a Stateflow chart, a MATLAB Function block, and a subsystem.

To generate a Simulink HDL Coder code generation report from the Configuration Parameters dialog box:
Verify that the model is open.
Open the Configuration Parameters dialog box and navigate to the HDL Code Generation pane.
To enable report generation, select Generate traceability report.
If your model includes blocks that have requirements comments, you can also select Include requirements in block comments in the HDL Code Generation > Global Settings > Coding style pane to render the comments as hyperlinked comments in the HTML code generation report. See Requirements Comments and Hyperlinks for more information.
Verify that Generate HDL for specifies the correct DUT for HDL code generation. You can generate reports for the root-level model or for subsystems, blocks, Stateflow charts, or MATLAB Function blocks.
Click Apply.
The dialog box looks something like this:

Click Generate to initiate code and report generation.
When you select Generate traceability report, the coder generates HTML report files as part of the code generation process. Report file generation is the final phase of that process. As code generation proceeds, the coder displays progress messages. The process completes with messages similar to the following:
### Generating HTML files for traceability in slprj\hdl\mcombo\html directory ... ### HDL Code Generation Complete.
When code generation is complete, the HTML report appears in a new window:

To view the different report sections or view the generated code files, click the hyperlinks in the Contents pane of the report window.
Tip The coder writes the code generation report files to a folder in the hdlsrc\html\ folder of the build folder. The top-level HTML report file is named system_codegen_rpt.html, where system is the name of the model, subsystem, or other component selected for code generation. However, because the coder automatically opens this file after report generation, you do not need to access the HTML files directly. Instead, navigate the report using the links in the top-level window. |
For more information on using the report you generate for tracing, see:
To generate a Simulink HDL Coder code generation report from the command line:
open_system('model_name');
Specify the desired device under test (DUT) for code generation by entering:
gcb = 'path_to_DUT';
You can generate reports for the root-level model or for subsystems, blocks, Stateflow charts, or MATLAB Function blocks. If you do not specify any subsystem, block, Stateflow chart, or MATLAB Function block, the coder generates a report for the top-level model.
Enable the makehdl property Traceability by entering:
makehdl(gcb,'Traceability','on');
When you enable traceability, the coder generates HTML report files as part of the code generation process. Report file generation is the final phase of that process. As code generation proceeds, the coder displays progress messages. The process completes with messages similar to the following:
### Generating HTML files for traceability in slprj\hdl\mcombo\html directory ... ### HDL Code Generation Complete.
When code generation is complete, the HTML report appears in a new window:

To view the different report sections or view the generated code files, click the hyperlinks in the Contents pane of the report window.
Tip The coder writes the code generation report files to a folder in the hdlsrc\html\ folder of the build folder. The top-level HTML report file is named system_codegen_rpt.html, where system is the name of the model, subsystem, or other component selected for code generation. However, because the coder automatically opens this file after report generation, you do not need to access the HTML files directly. Instead, navigate the report using the links in the top-level window. |
For more information on using the report you generate for tracing, see:
If you generate a code generation report for a model, and subsequently make changes to the model, the report might become invalid.
To keep your code generation report current, you should regenerate HDL code and the report after modifying the source model.
If you close and then reopen a model without making any changes, the report remains valid.
To trace from generated code to your model:
Generate code and open an HTML report for the desired DUT (see Generating a Traceability Report from Configuration Parameters or Generating a Traceability Report from the Command Line).
In the left pane of the HTML report window, click the desired file name in the Generated Source Files table to view a source code file.
The following figure shows a view of the source file Gain_Subsystem.vhd.

In the HTML report window, click any of the hyperlinks present to highlight a source block.
For example, in the HTML report shown in the previous figure, you could click the hyperlink for the Gain block (highlighted) to view that block in the model. Clicking the hyperlink locates and displays the corresponding block in the Simulink model window.

Model-to-code traceability lets you select a component at any level of the model, and view all code references to that component in the HTML code generation report. You can select any of the following objects for tracing:
Subsystem
Simulink block
MATLAB Function block
Stateflow chart, or any of the following elements of a Stateflow chart:
State
Transition
Truth table
MATLAB function inside a chart
To trace a model component:
Generate code and open an HTML report for the desired DUT (see Generating a Traceability Report from Configuration Parameters or Generating a Traceability Report from the Command Line).
In the model window, right-click the component and select HDL Code Generation > Navigate to Code.
Selecting Navigate to Code activates the HTML code generation report.
The following figure shows the result of tracing the Stateflow chart within the combo subsystem.

In the right pane of the report, the highlighted tag <S3>/Chart indicates the beginning of the code generated code for the chart.
In the left pane of the report, the total number of highlighted lines of code (in this case, 1) appears next to the source file name combo.vhd.
The left pane of the report also contains Previous and Next buttons. These buttons help you navigate through multiple instances of code generated for a selected component. In this example, there is only one instance, so the buttons are disabled.
The Traceability Report section of the report provides a complete mapping between model elements and code. The Traceability Report summarizes:
Eliminated / virtual blocks: accounts for blocks that are untraceable because they are not included in generated code
Traceable model elements, including:
Traceable Simulink blocks
Traceable Stateflow objects
Traceable MATLAB functions
The following figure shows the beginning of a traceability report generated for the combo subsystem of the mcombo model.

The following limitations apply to Simulink HDL Coder HTML code generation reports:
If a block name in your model contains a single quote ('), code-to-model and model-to-code traceability 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 from 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 the subsystem level, you might be able to trace individual blocks within the subsystem.
When you select Generate resource utilization report, the coder adds a Resource Utilization Report section. The Resource Utilization Report summarizes multipliers, adders/subtractors, and registers consumed by the device under test (DUT). It also includes a detailed report on resources used by each subsystem. The detailed report includes (wherever possible) links back to corresponding blocks in your model.
The Resource Utilization Report is useful for analysis of the effects of optimizations, such as resource sharing and streaming. See Streaming, Resource Sharing, and Delay Balancing) for example reports.
A typical Resource Utilization Report looks something like this:

When you select Generate optimization report, the coder adds an Optimization Report section, with two subsections:
Distributed Pipelining: this subsection shows details of subsystem-level distributed pipelining (if any subsystems have the DistributedPipelining option enabled). Details include comparative listings of registers and flip-flops before and after applying the distributed pipelining transform.
Streaming and Sharing: this subsection shows both summary and detailed information about all subsystems for which sharing or streaming is requested. (See Streaming, Resource Sharing, and Delay Balancing for example reports.)
A typical Distributed Pipelining Report looks something like this:

![]() | Code Generation Reports, HDL Compatibility Checker, Block Support Library, and Code Annotation | Annotating Generated Code with Comments and Requirements | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |