Skip to Main Content Skip to Search
Product Documentation

Creating and Using Code Generation Reports

Information Included in Code Generation Reports

The coder creates and displays an HDL Code Generation Report when you select one or more of the following options:

GUI optionmakehdl Property
Generate traceability reportTraceability, 'on'
Generate resource utilization reportResourceReport, 'on'
Generate optimization reportOptimizationReport, '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:

Summary Section

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.

Traceability Report 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:

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.

Generating a Traceability Report from Configuration Parameters

To generate a Simulink HDL Coder code generation report from the Configuration Parameters dialog box:

  1. Verify that the model is open.

  2. Open the Configuration Parameters dialog box and navigate to the HDL Code Generation pane.

  3. 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.

  4. 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.

  5. Click Apply.

    The dialog box looks something like this:

  6. 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:

  7. 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:

Generating a Traceability Report from the Command Line

To generate a Simulink HDL Coder code generation report from the command line:

  1. Open your model by entering:

    open_system('model_name');
    
  2. 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.

  3. 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:

  4. 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:

Keeping the Report Current

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.

Tracing from Code to Model

To trace from generated code to your model:

  1. 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).

  2. 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.

  3. 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.

Tracing from Model to Code

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:

To trace a model component:

  1. 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).

      Tip   If you have not generated code for the model, the coder disables the HDL Code Generation > Navigate to Code menu item.

  2. In the model window, right-click the component and select HDL Code Generation > Navigate to Code.

  3. 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.

Mapping Model Elements to Code Using the Traceability Report

The Traceability Report section of the report provides a complete mapping between model elements and code. The Traceability Report summarizes:

The following figure shows the beginning of a traceability report generated for the combo subsystem of the mcombo model.

Traceability Report Limitations

The following limitations apply to Simulink HDL Coder HTML code generation reports:

Resource Utilization Report Section

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:

Optimization Report Section

When you select Generate optimization report, the coder adds an Optimization Report section, with two subsections:

A typical Distributed Pipelining Report looks something like this:

  


Related Products & Applications

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