Main Content

Analyze Generated Data Code Interface

When you generate a code generation report, you can include a code interface report, which documents the generated code interface including model entry-point functions and interface data. The code interface information helps you to review the generated code and integrate it with other code. The information in the report depends on the type of code interface configuration that you use. For models that use service interface code configuration, the code interface report also includes information about services, as described in Analyze Generated Service Code Interface Report (Embedded Coder).

For code configured with data interfaces, 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 and model_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.

To generate a code interface report, select the configuration parameters Create code generation report and Code Interface Report, as described in Generate Code Generation Report. For limitations that apply to code interface reports, see Code Interface Report Limitations.

To open the example models used in this topic, use the openExample command:

openExample('ConfigurationInterface');

Navigating Code Interface Report Subsections

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

  • For a large subsection, the report provides [-] and [+] symbols that allow you to collapse or expand that section.

  • The code interface report provides several forms of hyperlink navigation. 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.c.

    • You can click the header file name for each function to go to the header file source listing.

    • If you selected the configuration parameter Code-to-model, to go to the corresponding location in the model display, you can click hyperlinks for these constructs:

      • Function argument

      • Function return value

      • Variable representing an inport

      • Variable representing an outport

      • Interface parameter (if the parameter source is a block)

      • Variable representing a 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.

FieldDescription
FunctionThe function name. You can click the function name to go to its definition in model.c.
PrototypeDisplays the function prototype, including the function return value, name, and arguments.
DescriptionProvides a text description of the purpose of the function 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, and at what time interval. For a multirate timing example, see the following MultirateMultitaskingBareBoard report excerpt.
ArgumentsIf the function has arguments, displays the number, name, data type, and Simulink® description for each argument. For argument examples, see the report excerpt below.
Return valueIf 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 report excerpt.
Header fileThe name of the header file for the function. You can click the header file name to go to the header file source listing.

To illustrate how timing information might be listed for a multirate model, here are the Entry-Point Functions and Inports subsections for the model MultirateMultitaskingBareBoard. 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.

Entry-point functions section of the code interface report. There is one table of information for the initialize function and each of two step functions.

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 a model.

Table of information for the step function.

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

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

  • 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 text prefixed with the label 'Imported data:'.

  • If the data is neither defined nor declared in the generated code — for example, if model configuration parameter Code interface packaging is set to Reusable function — the field displays the text 'Defined externally'.

Data TypeLists 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).

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 model ConfigurationInterface.

One table of information for the Inports and one table for the Outports of the model ConfigurationInterface. The tables have columns for the block name, code identifiers, data type, and dimension of each port.

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 Code-to-model parameter for your model, you can click 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.

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

  • 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 text prefixed with the label 'Imported data:'.

  • If the data is neither defined nor declared in the generated code — for example, if model configuration parameter Code interface packaging is set to Reusable function — the field displays the text 'Defined externally'.

Data TypeLists 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).

DimensionLists the dimensions of the tunable parameter (for example, 1 or [4, 5, 6]).

For example, here is the Interface Parameters subsection for the model ConfigurationInterface.

Table of interface parameters. The table has columns for the parameter source, code identifier, data type, and dimension for each interface parameter.

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 Code-to-model parameter 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.

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

  • 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 text prefixed with the label 'Imported data:'.

  • If the data is neither defined nor declared in the generated code — for example, if model configuration parameter Code interface packaging is set to Reusable function — the field displays the text 'Defined externally'.

Data TypeLists 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).

DimensionLists the dimensions of the data store (for example, 1 or [1, 2]).

For example, here is the Data Stores subsection for the model ConfigurationInterface.

Table of data stores. The table has columns for the data store source, code identifier, data type, and dimension of each data store.

Code Interface Report Limitations

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

  • The code interface report supports data resolved with most storage classes, except when the storage class properties are set in one of these ways:

    • The storage class property Type is set to FlatStructure. For example, when the BitField and Struct storage classes in the Simulink package have Type set to FlatStructure.

    • The storage class property Type is set to Other. For example, when the GetSet storage class in the Simulink package has Type set to Other.

    • The storage class property Data access is set to Pointer, indicating that the code declares imported symbols as pointer variables rather than simple variables. This property is accessible only when the storage class property Data scope is set to Imported or Instance-specific.

    In these cases, the report displays empty Data Type and Dimension fields.

  • For outports, if you optimize memory, the code interface report cannot describe the associated memory (data type and dimensions). 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 in the report link to built-in data types rather than their specified replacement data types.

Related Topics