Main Content

Reports for Code Generation

The code generator software produces an HTML code generation report so that you can view and analyze the generated code. When you build your model, the code generation process produces an HTML file that is displayed in an HTML browser or in the Model Explorer. For an example, see Generate Code Generation Report.

If you have Simulink® Report Generator™, you can document your code generation project in multiple formats, including HTML, PDF, RTF, Microsoft® Word, and XML. For an example of how to create a Microsoft Word report, see Document Generated Code with Simulink Report Generator.

HTML Code Generation Report Content

The code generation report includes:

  • The Summary section that contains model and code information, including Author, Tasking Mode, System Target File, Hardware Device Type, and code generation objectives information. The Configuration settings at the time of code generation link opens a noneditable view of the Configuration Parameters dialog box. The dialog box shows the Simulink model settings at the time of code generation, including TLC options.

  • The Subsystem Report section that contains information on nonvirtual subsystems in the model.

  • The Code Interface Report section that provides information about the generated code interface, including model entry-point functions and input/output data. For more information, see Analyze Generated Data Code Interface Report.

  • In the Code section on the Contents pane, you can click the names of source code files generated from your model to view their contents.

HTML Code Generation Report Location

The default location for the code generation report files is in the html subfolder of the build folder, model_target_rtw/html/. target is the name of the System target file specified on the Code Generation pane. The default name for the top-level HTML report file is index.html. For more information on the location of the build folder, see Manage Build Process Folders.

HTML Code Generation Report for Referenced Models

To generate a code generation report for a top model and code generation reports for each referenced model, you need to specify the Create code generation report on the Code Generation > Report pane for the top model and each referenced model. You can open the code generation report of a referenced model in one of two ways:

  • From the top-model code generation report, you can access the referenced model code generation report by clicking the name of the top model above the generated code. In the drop-down list of the model reference hierarchy, click the referenced model. To navigate back to the top model code generation report, use the Back button at the top of the left navigation pane or use the model reference hierarchy context menu.

  • In the referenced model diagram window, on the C Code tab, click Open Report.

For more information, see Generate Code for Model Reference Hierarchy.

HTML Code Generation Report Extensions

If you have Embedded Coder®, the code generator enhances the HTML code generation report. Configure your model to include these sections in the report:

  • The Traceability Report section enables you to account for Eliminated / Virtual Blocks that are untraceable versus the listed Traceable Simulink Blocks / Stateflow Objects / MATLAB Scripts. This section provides a complete mapping between model elements and code. For more information, see Customize Traceability Reports (Embedded Coder).

  • The Static Code Metrics Report section provides generated code statistics. Metrics are estimated from static analysis of the generated code. To generate a static code metrics report without generating a code generation report, use the function (Embedded Coder). For more information, see Static Code Metrics (Embedded Coder).

  • The Code Replacements Report section enables you to account for code replacement library (CRL) functions that were used during code generation, providing a mapping between each replacement instance and the Simulink block that triggered the replacement. For more information, see Analyze Code Replacements in Generated Code (Embedded Coder).

  • The Coder Assumptions section provides a list of:

    • Code generation assumptions for your target hardware that you can check.

    • Expected results for the assumption checks.

    For more information, see Check Code Generation Assumptions (Embedded Coder).

  • The model web view displays an interactive model diagram within the code generation report and supports traceability between the source code and the model. You can then share your model and generated code outside of the MATLAB environment. For more information, see Generate Web View of Model in Code Generation Report (Embedded Coder).

On the Contents pane, in the Generated Files section, 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:

  • If you enable code-to-model traceability, hyperlinks within the displayed source code navigate to the blocks or subsystems from which the code is generated. For more information, see Code-to-Model Traceability (Embedded Coder).

  • If you enable model-to-code traceability, you can navigate to the generated code for a block in the model. For more information, see Model-to-Code Traceability (Embedded Coder).

  • If you set the Code coverage tool parameter on the Code Generation > Verification pane, you can view the code coverage data and annotations. For more information, see Configure Code Coverage with Third-Party Tools (Embedded Coder).

  • If you select the Generate static code metrics check box on the Code Generation > Report pane, you can view code metrics information and navigate to code definitions and declarations in the generated code. For more information, see View Static Code Metrics and Definitions Within the Generated Code (Embedded Coder).


To view the contents of your generated code and navigate between model and code, you can also use the Code view in the Code perspective. In the perspective, click the Code tab in the bottom-right corner.

Related Topics