Data and Function Configuration

Map model data elements and functions to model-independent code definitions

To comply with code standards and guidelines, integrate generated code with external code, and address memory requirements, you can control the declarations and definitions of functions, variables, and data types in generated code. For example, you can use these graphical and programming interfaces to map model data elements and functions to model-independent code definitions:

  • In the Code Mappings editor or by using an API, configure default C code generation for categories of model data and functions.

  • In the Code Mappings editor, override configurations for individual C functions.

  • In the Model Data Editor code view, override configurations for individual model data elements.

Functions

expand all

model_initializeInitialization entry-point function in generated code for Simulink model
model_stepStep routine entry point in generated code for Simulink model
model_terminateTermination entry point in generated code for Simulink model
coder.mapping.createCreate C code mapping environment for model
coder.mapping.defaults.allowedPropertiesReturn properties for model default mapping category
coder.mapping.defaults.allowedValuesReturn value of property for model default mapping category
coder.mapping.defaults.dataCategoriesReturn default mapping categories for model data
coder.mapping.defaults.functionCategoriesReturn default mapping categories for model functions
coder.mapping.defaults.getReturn value of property for model default mapping category
coder.mapping.defaults.setSet value for property of model default mapping category
RTW.configSubsystemBuildConfigure C function prototype or C++ class interface for right-click build of specified subsystem
RTW.getFunctionSpecificationGet handle to model-specific C prototype function control object
RTW.ModelSpecificCPrototypeCreate model-specific C prototype object
RTW.configSubsystemBuildConfigure C function prototype or C++ class interface for right-click build of specified subsystem
RTW.getClassInterfaceSpecificationGet handle to model-specific C++ class interface control object
RTW.ModelCPPArgsClassCreate C++ class interface object for configuring model class with I/O arguments style step method
RTW.ModelCPPDefaultClassCreate C++ class interface object for configuring model class with default model step method

Tools

Code Mappings EditorAssociate model data elements and entry-point functions with code definitions

Topics

Data and Function Configuration Basics

Environment for Configuring Model Data and Functions for Code Generation

Configure model data and functions for code generation.

Configure Code Generation for Model Entry-Point Functions

Learn about generated entry-point functions and ways to control their interfaces and whether the functions are reusable and reside in specific areas of memory.

Configure Default C Code Generation for Categories of Model Data and Functions

Apply default code generation configurations for categories of model data and functions across a model.

Configure Generated Code According to Interface Control Document Interactively

Configure code generation settings for a model according to specifications from an interface control document.

Migrate Memory Section and Shared Utility Settings from Configuration Parameters to Code Mappings Editor

When you open the Code perspective in a model created before release R2018a, learn how to manage the migration of memory section and shared utility settings.

C Data Configuration

Choose Storage Class for Controlling Data Representation in Generated Code

Choose a storage class to apply to data elements in a model, such as signals, states, and block parameters.

Configure Data Interface by Applying Storage Classes

Configure data elements in a model, such as block parameters and signal lines, so that corresponding variables appear in generated code.

Apply Storage Classes to Individual Signal, State, and Parameter Data Elements

Control data representation in the generated code by applying storage classes directly, which overrides the default storage classes that you specify in the Code Mapping Editor.

Apply Built-In and Customized Storage Classes to Data Elements

Customize data representation in the generated code by applying storage classes to individual data items.

Control Placement of Global Data Definitions and Declarations in Generated Files

Modularize the generated code and establish clear ownership of global data by controlling the file placement of each declaration and definition.

Protect Global Data with const and volatile Type Qualifiers

Prevent data corruption and improve code safety by applying C type qualifiers const and volatile to global data in generated code.

Finely Control Data Representation by Writing TLC Code for a Storage Class

For advanced control of data representation in the generated code, create custom storage classes by writing TLC code.

C Function Configuration

Customize Generated C Function Interfaces

Learn ways that you can configure generated C function interfaces and about customization limitations.

Configure Default C Code Generation for Categories of Model Data and Functions

Apply default code generation configurations for categories of model data and functions across a model.

Override Default Naming for Individual C Entry-Point Functions

Explicitly customize the name individual entry-point functions.

Override Default C Step Function Interface

Explicitly configure step function name and arguments.

Customize Entry-Point Function Interfaces for Simulink Function and Function Caller Blocks

Customize entry-point function names and step function arguments for Simulink Function and Function Caller blocks.

Control Data and Function Interface in Generated Code

Control how generated code exchanges data with a calling environment.

Rapid Prototyping Model Functions

Generate rapid prototyping code.

C++ Class Interface Configuration

Control Generation of C++ Class Interfaces

Produce C++ class interfaces in code generated for a model.

Generate C++ Class Interface to Model or Subsystem Code

Generate a C++ class interface to code generated from a model or subsystem.

Generate Code for String Blocks by using the Standard C++ String Library

Generate C++ code for Simulink string blocks.

Nonvirtual Subsystems

Generate Modular Function Code for Nonvirtual Subsystems

Generate modular function code for nonvirtual subsystems.

Featured Examples