Products & Services Solutions Academia Support User Community Company

Learn more about Real-Time Workshop Embedded Coder   

Using the Code Interface Report to Analyze the Generated Code Interface

Code Interface Report Overview

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

For limitations that apply to code interface reports, see Code Interface Report Limitations

Generating a Code Interface Report

To generate a code interface report for your model, perform the following steps.

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

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

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

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

Navigating Code Interface Report Subsections

To help you navigate code interface descriptions, the code interface report provides collapse/expand tokens and hyperlinks, as follows:

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.

Interpreting the Entry Point Functions Subsection

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.

FieldDescription
Function:Lists the function name. You can click on the function name to go to its declaration in model.c.
PrototypeDisplays the function prototype, including the function return value, name, and arguments.
DescriptionProvides a text description of the function's purpose in the application.
TimingDescribes 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.
ArgumentsIf 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 valueIf 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 fileLists 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.

Interpreting the Inports and Outports Subsections

The Inports and Outports subsections of the code interface report provide the following interface information about each inport and outport in the model.

FieldDescription
Block NameDisplays 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:

  • If the data is defined in the generated code, the field displays the identifier string.

  • If the data is declared but not defined in the generated code — for example, if the data is resolved with an imported storage class — the field displays the identifier string prefixed with the label 'Imported data:'.

  • If the data is neither defined nor declared in the generated code — for example, if the option Generate reusable code is selected for the model — the field displays the string 'Defined externally'.

Data TypeLists the data type of the inport or outport.
DimensionLists 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.

Interpreting the Interface Parameters Subsection

The Interface Parameters subsection of the code interface report provides the following interface information about tunable parameters that are associated with the model.

FieldDescription
Parameter Source

Lists the source of the parameter value, as follows:

  • If the source of the parameter value is a block, the field displays the block name, such as <Root>/Gain2 or <S1>/Lookup1. If you selected the Report pane option Code-to-model for your model, you can click on the Parameter Source value to go to the parameter's location in the model display.

  • If the source of the parameter value is a workspace variable, the field displays the name of the workspace variable prefixed with the label 'Workspace variable:'; for example, Workspace variable: K2.

Code Identifier

Lists the identifier associated with the tunable parameter data in the generated code, as follows:

  • If the data is defined in the generated code, the field displays the identifier string.

  • If the data is declared but not defined in the generated code — for example, if the data is resolved with an imported storage class — the field displays the identifier string prefixed with the label 'Imported data:'.

  • If the data is neither defined nor declared in the generated code — for example, if the option Generate reusable code is selected for the model — the field displays the string 'Defined externally'.

Data TypeLists the data type of the tunable parameter.
DimensionLists 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).

Interpreting the Data Stores Subsection

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.

FieldDescription
Data Store Source

Lists the source of the data store memory, as follows:

  • If the data store is defined using a Data Store Memory block, the field displays the block name, such as <Root>/DS1. If you selected the Report pane option Code-to-model for your model, you can click on the Data Store Source value to go to the data store's location in the model display.

  • If the data store is defined using a Simulink.Signal object, the field displays the name of the Simulink.Signal object prefixed with the label 'Global:'.

Code Identifier

Lists the identifier associated with the data store data in the generated code, as follows:

  • If the data is defined in the generated code, the field displays the identifier string.

  • If the data is declared but not defined in the generated code — for example, if the data is resolved with an imported storage class — the field displays the identifier string prefixed with the label 'Imported data:'.

  • If the data is neither defined nor declared in the generated code — for example, if the option Generate reusable code is selected for the model — the field displays the string 'Defined externally'.

Data TypeLists the data type of the data store.
DimensionLists 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).

Code Interface Report Limitations

The following limitations apply to code interface section of the HTML code generation reports.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS