Data and Function Interfaces
Map model data elements and functions to code definitions
To comply with code standards and guidelines and configure the representation of model data elements and entry-point functions for code generation, map model data elements and functions to predefined code definitions.
For an introduction, see C Data Code Interface Configuration for Model Interface Elements.
Tools
Code Mappings Editor | Associate model elements with code interface definitions (Since R2020b) |
Objects
coder.mapping.api.CodeMapping | Model data and function interface configuration for C code generation (Since R2020b) |
Functions
Topics
Configuration Fundamentals
- C Data Code Interface Configuration for Model Interface Elements
Control the representation of model data elements and functions in generated C code by using a data code interface configuration. - Generate C++ Class Interface to Model or Subsystem Code
Generate a C++ class interface to code generated from a model or subsystem. - Code Definition and Mapping Limitations and Considerations
Restrictions, constraints, and considerations that apply to code definitions and code mappings. - Manage Multiple Code Mappings for a Model
Design models that are platform-neutral and ready to deploy to different run-time environments. - How Generated Code Exchanges Data with an Environment
The generated code exchanges signal, state, and parameter data with the calling environment through a data interface. - Exchange Data Between External Calling Code and Generated Code
When you export the generated code into your external code, exchange signal, state, and parameter data. - Generate Code That Matches Appearance of External Code
Configure how the code generator applies identifiers (symbols), comments, code styles, code format, and organization. - 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.
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. - Design Data Interface by Configuring Inport and Outport Blocks
Customize the data interface of a model to enable integration of the generated code with your own code and to improve code traceability and readability.
Function Configuration
- Configure Generated C Function Interface 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. - Rapid Prototyping Model Functions
Generate rapid prototyping code.
Data Access and Initialization
- Create Tunable Calibration Parameter in the Generated Code
In the generated code, create tunable parameter data that you can access during rapid prototyping and calibration. - Reuse Parameter Data in Different Data Type Contexts
Reuse parameter data by creating aSimulink.Parameter
object or numeric MATLAB® variable that you can use in different data type contexts. - Limitations for Block Parameter Tunability in Generated Code
Limitations can prevent a block parameter from appearing in the generated code as tunable, which means you cannot interact with the parameter value after compiling the code. - Access Signal, State, and Parameter Data During Execution
As you iteratively develop a model, capture output signal and state data that model execution generates. Tune parameter values during execution to observe results on the outputs. - Switch Between Sets of Parameter Values During Simulation and Code Execution
Switch between independent sets of values for the same block parameters by storing the sets in an array of structures. - Preserve Variables in Generated Code
As you iteratively develop a model, you can tune block parameter values during simulation or execution of generated code to observe the results on signal and state values. - Configure Packaging of Parameter Arguments in Generated Code
Customize the implementation of parameter arguments in generated code. - Control Signal and State Initialization in the Generated Code
Generate code that enables you to store tunable initial conditions in memory, for example, for modeling a system that shuts down and restarts. - Initialization of Signal, State, and Parameter Data in the Generated Code
To match the numerics of a simulation in Simulink, the generated code assigns initial values to global data, especially for block states and parameters. - Code Generation of Parameter Objects With Expression Values
When you set the value of a parameter object (such asSimulink.Parameter
) to an expression, the generated code can preserve the expression.