Analyze the Generated Code Interface
Code Interface Report Overview
When you select the Create code generation report option, 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_reset
andmodel_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.
For illustration purposes, this section uses the following models:
rtwdemo_configinterface
(with the ExportedGlobal Storage Class button selected in the model window) for examples of report subsectionsrtwdemo_mrmtbb
for examples of timing informationrtwdemo_fcnprotoctrl
for examples of function argument and return value information
Generating a Code Interface Report
To generate a code interface report for your model:
Open the Configuration Parameters dialog box.
On the Code Generation > Report pane, select Create code generation report. The
rtwdemo_configinterface
,rtwdemo_mrmtbb
, andrtwdemo_fcnprotoctrl
models used in this section select multiple other Report pane options by default.Alternatively, you can programmatically select the option by issuing the following MATLAB® command:
set_param(bdroot, 'GenerateReport', 'on')
If your model uses an ERT-based target, you can select the Code-to-model parameter. In this case, the generated report contains hyperlinks to the model.
Build the model. On the C Code tab, click Open Report.
To display the code interface report for your model, on the Contents pane of the HTML report, click the Code Interface Report link. For example, here is the generated code interface report for the model
rtwdemo_configinterface
(with the ExportedGlobal Storage Class button selected in the model window).
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 a large 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 each function name to go to its definition in
.model
.cYou can click each function's header file name to go to the header file source listing.
If you selected the Code-to-model parameter for your model, to go to the corresponding location in the model display, you can click hyperlinks for any of the following:
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 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_reset
and model_terminate
.
Field | Description |
---|---|
Function: | Lists the function name. You can click the function name to go to its definition in . |
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, and at what time interval. For a multirate timing example, see the following rtwdemo_mrmtbb report excerpt. |
Arguments | If the function has arguments, displays the number, name, data type, and Simulink® description for each argument. If you select the Code-to-model parameter 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, this field displays the return value data type and Simulink description. If you selected the Code-to-model parameter 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 following rtwdemo_fcnprotoctrl report excerpt. |
Header file | Lists the name of the header file for the function. You can click the header file name to go to the header file source listing. |
For example, here is the Entry-Point Functions subsection for the model rtwdemo_configinterface
.
To illustrate how timing information might be listed for a multirate model, here are the Entry-Point Functions and Inports subsections for the 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 function description of the model step function for 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.
Field | Description |
---|---|
Block Name | Displays the Simulink block name of the inport or outport. If you selected the Code-to-model parameter 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. |
Scaling | For fixed-point entries, lists the data type and fraction length using Simulink fixed-point data type notation. Note You must have a Fixed-Point Designer™ license to see fixed-point scaling information in the report. For more information on how scaling is represented in the table, see Fixed-Point Data Type and Scaling Notation (Fixed-Point Designer). |
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 model rtwdemo_configinterface
.
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.
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. |
Scaling | For fixed-point entries, lists the data type and fraction length using Simulink fixed-point data type notation. Note You must have a Fixed-Point Designer license to see fixed-point scaling information in the report. For more information on how scaling is represented in the table, see Fixed-Point Data Type and Scaling Notation (Fixed-Point Designer). |
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 model rtwdemo_configinterface
(with the ExportedGlobal Storage Class button selected in the 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.
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. |
Scaling | For fixed-point entries, lists the data type and fraction length using Simulink fixed-point data type notation. Note You must have a Fixed-Point Designer license to see fixed-point scaling information in the report. For more information on how scaling is represented in the table, see Fixed-Point Data Type and Scaling Notation (Fixed-Point Designer). |
Dimension | Lists the dimensions of the data store (for example, 1 or [1, 2] ). |
For example, here is the Data Stores subsection for the model rtwdemo_configinterface
(with the ExportedGlobal Storage Class button selected in the model window).
Code Interface Report Limitations
The following limitations apply to the code interface section of the HTML code generation reports.
The code interface report does not support the GRT interface with an ERT target or C++ class code interface packaging. For these configurations, the code interface report is not generated and does not appear in the HTML code generation report Contents pane.
The code interface report supports data resolved with most storage classes, except when the storage class properties are set in any of the following ways:
The storage class property Type is set to
FlatStructure
. For example, theBitField
andStruct
storage classes in the Simulink package have Type set toFlatStructure
.The storage class property Type is set to
Other
. For example, theGetSet
storage class in the Simulink package has Type set toOther
.The storage class 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 storage class property Data scope is set toImported
orInstance-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 Code Generation > 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.