Main Content

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, configure the representation of model data elements and entry-point functions for code generation. You configure model data elements and functions by mapping them to code definitions that are predefined by the product or created with the Embedded Coder Dictionary. For data elements, you also have the option of mapping them to code definitions created in packages with the Custom Storage Class Designer.

For an introduction, see C Code Generation Configuration for Model Interface Elements.

Objects

coder.mapping.api.CodeMappingModel data and function interface configuration for C code generation

Functions

expand all

model_initializeGenerated C/C++ entry-point function that contains initialization code for a Simulink model
model_resetGenerated C/C++ entry-point function that contains reset code for a Simulink model
model_stepGenerated C/C++ entry-point function that contains execution code for each step in a Simulink model
model_terminateGenerated C/C++ entry-point function that contains termination code for a Simulink model

Create and Find Code Mappings

coder.mapping.api.getGet code mappings for model
coder.mapping.utils.createCreate code mappings object for configuring data and function interface for C code generation
findGet model elements for the category of model code mappings

Default Configurations

getDataDefaultGet default storage class or storage class property setting for model data category
getFunctionDefaultGet default function customization template or memory section for model functions category
setDataDefaultSet default storage class and storage class property values for model data category
setFunctionDefaultSet default function customization template and memory section for model functions category

Function Configuration

getFunctionGet code configuration from code mappings for model function
setFunctionSet code mapping information for model function

Root-Level Inport and Outport Configuration

getInportGet code configuration from code mappings for root-level inport
getOutportGet code configuration from code mappings for root-level outport
setInportConfigure root-level inports for code generation
setOutportConfigure root-level outport for code generation

Parameter Configuration

getModelParameterGet code configuration from code mappings for model parameters
setModelParameterConfigure model parameter for code generation

Signal, State, and Data Store Configuration

addSignalAdd block output signal to model code mappings
getDataStoreGet code configuration from code mappings for local or shared local data store
getSignalGet code configuration from code mappings for block output signal
getStateGet code configuration from code mappings for block state
removeSignalRemove block output signal from model code mappings
setDataStoreConfigure local or shared local data store for code generation
setSignalConfigure block signal data for code generation
setStateConfigure block states for code generation

Tools

Code Mappings EditorAssociate model elements with code definitions

Topics

Configuration Fundamentals

C Code Generation Configuration for Model Interface Elements

Control the representation of model data elements and functions in generated C code.

Code Definition and Mapping Limitations and Considerations

Restrictions, constraints, and considerations that apply to code definitions and code mappings.

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

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

Manage Multiple Code Mappings for a Model

Design models that are platform-neutral and ready to deploy to different run-time environments.

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.

Migration of Model Data Configurations to Code Mappings

How Simulink® migrates code definitions for models created before release R2020b to code mappings and related information to consider.

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

How to configure memory sections and shared utility function naming rules for models created before release R2018a.

C Data Configuration

Choose Data Configuration Approach

Make decisions about the design data used by your model based on your code generation requirements.

Configure Root-Level Inport Blocks for C Code Generation

Set the storage class and other relevant code generation properties for root-level Inport blocks.

Configure Root-Level Outport Blocks for C Code Generation

Set the storage class and other relevant code generation properties for root-level Outport blocks.

Configure Signal Data for C Code Generation

Set the storage class and other relevant code generation properties for signal data.

Configure Parameters for C Code Generation

Set the storage class and other relevant code generation properties for parameters.

Configure Block States for C Code Generation

Set the storage class and other relevant code generation properties for block states.

Configure Data Stores for C Code Generation

Set the storage class and other relevant code generation properties for data stores.

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.

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.

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

Configure C Code Generation for Model Entry-Point Functions

Learn about generated C entry-point functions, configuration options, and how to interface with them.

Control Data and Function Interface in Generated Code

Control how generated code exchanges data with a calling environment.

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

Generate Modular Function Code for Nonvirtual Subsystems

Generate modular function code for nonvirtual subsystems.

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.

Featured Examples