Main Content

Analyze Generated Service 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 services. 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 data interface configuration for the generated code, the code interface report includes information about data and functions, as described in Analyze Generated Data Code Interface.

For code configured with service interfaces, the code interface report includes the following subsections:

  • Introduction — a high-level description of how the code interface is generated to work with services provided by the target platform software.

  • Execution — interface information about each model execution entry-point function, including model_initialize, model_step, and (if applicable) model_reset and model_terminate.

  • Services — interface information about platform services that the generated code uses, including data transfer and timer services.

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.

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 [Hide] and [Show] buttons that allow you to collapse or expand that section.

  • The code interface report provides several forms of hyperlink navigation. For example:

    • 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 arrow buttons above the Content section in the upper-left corner of the report.

Interpreting the Execution Subsection

The Execution 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.
Sample timeIf the function is called periodically, sample time describes the time interval. If the function is not called periodically, no sample time is shown.
ArgumentsIf the function has arguments, displays the number, name, data type, and Simulink® description for each argument.
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.
Header fileThe name of the header file for the function.

For each execution function, the report shows interface information for the receiver, sender, and timer services for the function. The report provides this information about each service.

FieldDescription
PrototypeDisplays the function prototype for calling the service, including the function return value, name, and arguments.
Data communication methodIndicates how the service accesses data. The options are outside execution, during execution, or direct access.
Header fileThe name of the header file that contains the service interface prototypes.

For example, here is the Execution subsection for the model Guideline_DataTransfer.

Execution section of the code interface report.

Interpreting the Services Section

The Services section of the code interface report provides this interface information about each service in the generated code.

FieldDescription
Service:Lists the service name.
PrototypeDisplays the service prototype, including the service return value, name, and arguments.
Data communication methodIndicates how the service accesses data. The options are outside execution, during execution, or direct access.
Receiving functionName of the function for receiving data.
Sending functionName of the function for sending data.
Header fileLists the name of the header file that contains the service interface prototypes.

For example, here is the Services section for the model Guideline_DataTransfer.

Services section of the interface report for the Guideline_DataTransfer model. One table shows interface information for the data transfer service.

Code Interface Report Limitations

The following 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 the following ways:

    • The storage class property Type is set to FlatStructure. For example, 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, 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 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 to Imported or Instance-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 link to built-in data types rather than their specified replacement data types.