| Contents | Index |
• Model Architecture and Design
• Data, Function, and File Definition
• Structure Parameters and Generated Code
About Structure Parameters and Generated Code
Tunable Parameter Storage Classes
Linear Block Parameter Tunability
Configuration Parameter Quick Reference Diagram
Generated Code for Parameter Data Types
• Signals
Signals with Auto Storage Class
Interface Signals to External Code
Symbolic Naming Conventions for Signals in Generated Code
Summary of Signal Storage Class Options
• States
• Entry Point Functions and Scheduling
Generate Code and Executables from Subsystems
Nonvirtual Subsystem Code Generation Options
About Code Generation for Referenced Models
Generate Code for Referenced Models
Project Folder Structure for Model Reference Targets
Simulink Coder Model Referencing Requirements
Storage Classes for Signals Used with Model Blocks
Inherited Sample Time for Referenced Models
Customize Library File Suffix, Including the File Type Extension
Simulink Coder Model Referencing Limitations
Reusable Code and Referenced Models
Generate Reusable Code from Stateflow Charts
Generate Reusable Code for Subsystems Containing S-Function Blocks
Open the Model Configuration for Code Generation
Configure a Model from the MATLAB Command Line
About The Code Generation Objectives
Configuring The Code Generation Objectives Using The Code Generation Advisor
About Targets and Code Formats
Backwards Compatibility of Code Formats
Template Makefiles and Make Options
Describing the Emulation and Embedded Targets
Describing Embedded Hardware Characteristics
Describing Emulation Hardware Characteristics
Selecting and Viewing Code Replacement Libraries
Configuring Generated Identifiers
Header Dependencies When Interfacing Legacy/Custom Code with Generated Code
Dependencies of the Generated Code
Specify Include Paths in Simulink Coder Generated Source Files
Folders Used During the Build Process
Internal Data Storage for Complex Number Arrays
Controlling Shared Utility Code Placement
rtwtypes.h and Shared Utility Code
Incremental Shared Utility Code Generation and Compilation
Shared Fixed-Point Utility Functions
Share User-Defined Data Types Across Models
View the Code Generation Report
Set Report Name, Location, and Format
General Rapid Simulation Workflow
Identify Rapid Simulation Requirements
Configure Inport Blocks to Provide Rapid Simulation Source Data
Configure and Build a Model for Rapid Simulation
Set Up Rapid Simulation Input Data
Program Scripts for Batch and Monte Carlo Simulations
Rapid Simulation Target Limitations
Create an S-Function Block from a Subsystem
Tunable Parameters in Generated S-Functions
System Target File and Template Makefiles
Checksums and the S-Function Target
About Real-Time Rapid Prototyping
Goals of Real-Time Rapid Prototyping
Refine Component Code With Real-Time Rapid Prototyping
Set Up and Run HIL Simulations
Types of External Code Integration
Integrate External MATLAB Code
Integrate External C or C++ Code
Integration Considerations for Reusable Algorithmic Components
Generate Inlined S-Function Files for Code Generation Support
Apply Model Code Style Settings to Legacy Functions
Address Dependencies on Files in Different Locations
Deploy Generated S-Functions for Simulation and Code Generation
Example: Using a Custom Code Block
Preventing User Source Code from Being Deleted from Build Folders
Write Fully Inlined S-Functions
Write Fully Inlined S-Functions with the mdlRTW Routine
Guidelines for Writing Inlined S-Functions
Write S-Functions That Support Expression Folding
Write S-Functions That Specify Port Scope and Reusability
Write S-Functions That Specify Sample Time Inheritance Rules
Write S-Functions That Support Code Reuse
Write S-Functions for Multirate Multitasking Environments
Troubleshoot Compiler Configurations
Build a Generic Real-Time Program
Control Regeneration of Top Model Code
Reduce Build Time for Referenced Models
Relocate Code to Another Development Environment
How an Executable Program Is Built From a Model
Log Data from a Generated Program
Compare Numerical Results of a Simulation and a Generated Program
Data Interchange Using the C API
Remove Code That Wraps Out-of-Range Values
Specify the Location of Precompiled Libraries
Control the Location of Model Reference Libraries
Control the Suffix Applied to Library File Names
Program a Post Code Generation Command
Define a Post Code Generation Command
About Configuring Generated Code with TLC
Assigning Target Language Compiler Variables
Set Target Language Compiler Options
Conventions for Using the STF_make_rtw Hook File
STF_make_rtw_hook.m Function Prototype and Arguments
Applications for STF_make_rtw_hook.m
Use STF_make_rtw_hook.m for Your Build Procedure
Register Build Process Hook Functions Using sl_customization.m
Variables Available for sl_customization.m Hook Functions
Example Build Process Customization Using sl_customization.m
Types of External Code Integration
Integrate External MATLAB Code
Integrate External C or C++ Code
Integration Considerations for Reusable Algorithmic Components
Generate Inlined S-Function Files for Code Generation Support
Apply Model Code Style Settings to Legacy Functions
Address Dependencies on Files in Different Locations
Deploy Generated S-Functions for Simulation and Code Generation
Example: Using a Custom Code Block
Preventing User Source Code from Being Deleted from Build Folders
Write Fully Inlined S-Functions
Write Fully Inlined S-Functions with the mdlRTW Routine
Guidelines for Writing Inlined S-Functions
Write S-Functions That Support Expression Folding
Write S-Functions That Specify Port Scope and Reusability
Write S-Functions That Specify Sample Time Inheritance Rules
Write S-Functions That Support Code Reuse
Write S-Functions for Multirate Multitasking Environments
ASAP2 File Structure on the MATLAB Path
Customize the Contents of the ASAP2 File
Use GROUP and SUBGROUP Hierarchies to Organize Signals and Parameters
Customize Computation Method Names
Suppress Computation Methods for FIX_AXIS
External Mode Communications Overview
Implement a Custom Transport Layer
Recommended Features for Embedded Targets
Key Folders Under the Target Root (mytarget)
Key Files in the Target Folder (mytarget/mytarget)
Additional Folders and Files for Externally Developed Targets
Target Development and the Build Process
System Target File Naming and Location Conventions
Define and Display Custom Target Options
Tips and Techniques for Customizing Your STF
Create a Custom Target Configuration
Structure of the Template Makefile
Customize and Create Template Makefiles
Support Compiler Optimization Level Control
Support firstTime Argument Control
Support C Function Prototype Control
Support C++ Encapsulation Interface Control
• Desktop IDEs and Desktop Targets
Support for Third Party Products
Automation of IDE Tasks and Processes
Using Makefiles to Generate and Build Software
Making an XMakefile Configuration Operational
Working with Microsoft Visual Studio
Example: Creating a New XMakefile Configuration
XMakefile User Configuration Dialog Box
Running Your PIL Application to Perform Simulation and Verification
Installing Eclipse IDE for C/C++ Developers
Verifying the GNU Tool Chain on Linux
Installing the GNU Tool Chain on Windows
GDB Stops on Each Semaphore Post
Eclipse Message: "Can't find a source file"
Eclipse Message: "Cannot access memory at address"
Some Versions of Eclipse CDT Do Not Catch GCC Errors
Running Target Applications on Multicore Processors
Running Multirate, Multitasking Executables on the Linux Desktop
Avoiding Lock-Up in Free-Running, Multirate, Multitasking Models
Target Language Compiler Overview
Overview of the Code Generation Process
Modifying and Diversifying Code Generation
How TLC Determines S-Function Inlining Status
A Look at Inlined and Noninlined S-Function Code
Search Algorithm for Locating TLC Files
Availability for Inlining and Noninlining
Fully Inlined S-Function Example
Wrapper Inlined S-Function Example
Learning About the Structure of Record Files
Learning About the Anatomy of a TLC Script
Learning About Noninlined Code Generation
Understand Why You Use TLC to Inline S-Functions
Creating an Inlined S-Function
Changing the Loop Rolling Threshold
Learning More About TLC Loop Rolling
Generating and Running Code from the Model
Start the Debugger and Use Its Commands
Fixing the Bug and Verifying the Fix
Opening the Model and Generating Code
Understanding Why You Might Wrap
Generating Code Without a Wrapper
Generating Code Using a Wrapper
Simulink Coder Matrix Parameters
Accessing Data Object Information via TLC
Controlling the Data Reference Threshold
Avoiding Data Reference Expansion
Caution Against Directly Accessing Record Fields
Exception to Using the Library Functions
Object-Oriented Facility for Generating Target Code
Asserts, Errors, Warnings, and Debug Messages
Function-Based or Wrapped Code Generation
Begin Identifiers with Uppercase Letters
Begin Global Variable Assignments with Uppercase Letters
Begin Local Variable Assignments with Lowercase Letters
Begin Functions Declared in block.tlc Files with Fcn
Do Not Hard-Code Variables Defined in commonsetup.tlc
Conditional Inclusion in Library Files
BlockInstanceSetup(block, system)
InitializeConditions(block, system)
LibBlockInputSignal(portIdx, ucv, lcv, sigIdx)
LibBlockInputSignalAddr(portIdx, ucv, lcv, sigIdx)
LibBlockInputSignalAliasedThruDataTypeName(portIdx, reim)
LibBlockInputSignalConnected(portIdx)
LibBlockInputSignalDataTypeId(portIdx)
LibBlockInputSignalDataTypeName(portIdx, reim)
LibBlockInputSignalDimensions(portIdx)
LibBlockInputSignalIsComplex(portIdx)
LibBlockInputSignalIsFrameData(portIdx)
LibBlockInputSignalLocalSampleTimeIndex(portIdx)
LibBlockInputSignalNumDimensions(portIdx)
LibBlockInputSignalOffsetTime(portIdx)
LibBlockInputSignalSampleTime(portIdx)
LibBlockInputSignalSampleTimeIndex(portIdx)
LibBlockInputSignalWidth(portIdx)
LibBlockOutputPortIndexMode(block, pidx)
LibBlockOutputSignal(portIdx, ucv, lcv, sigIdx)
LibBlockOutputSignalAddr(portIdx, ucv, lcv, sigIdx)
LibBlockOutputSignalAliasedThruDataTypeName(portIdx, reim)
LibBlockOutputSignalBeingMerged(portIdx)
LibBlockOutputSignalConnected(portIdx)
LibBlockOutputSignalDataTypeId(portIdx)
LibBlockOutputSignalDataTypeName(portIdx, reim)
LibBlockOutputSignalDimensions(portIdx)
LibBlockOutputSignalIsComplex(portldx)
LibBlockOutputSignalIsFrameData(portIdx)
LibBlockOutputSignalLocalSampleTimeIndex(portIdx)
LibBlockOutputSignalNumDimensions(portIdx)
LibBlockOutputSignalOffsetTime(portIdx)
LibBlockOutputSignalSampleTime(portIdx)
LibBlockOutputSignalSampleTimeIndex(portIdx)
LibBlockOutputSignalWidth(portIdx)
LibBlockMatrixParameterAddr(param, rucv, rlcv, ridx, cucv, clcv, cidx)
LibBlockMatrixParameterBaseAddr(param)
LibBlockParamSetting(bType, psType)
LibBlockParameter(param, ucv, lcv, sigIdx)
LibBlockParameterAddr(param, ucv, lcv, idx)
LibBlockParameterBaseAddr(param)
LibBlockParameterDataTypeId(param)
LibBlockParameterDataTypeName(param, reim)
LibBlockParameterDimensions(param)
LibBlockParameterIsComplex(param)
LibBlockParameterString(param)
LibBlockParameterValue(param, elIdx)
LibBlockContinuousStateDerivative(ucv, lcv, idx)
LibBlockContStateDisabled(ucv, lcv, idx)
LibBlockDWork(dwork, ucv, lcv, idx)
LibBlockDWorkAddr(dwork, ucv, lcv, idx)
LibBlockDWorkDataTypeId(dwork)
LibBlockDWorkDataTypeName(dwork, reim)
LibBlockDWorkStorageClass(dwork)
LibBlockDWorkStorageTypeQualifier(dwork)
LibBlockDWorkUsedAsDiscreteState(dwork)
LibBlockDiscreteState(ucv, lcv, idx)
LibBlockIWork(definediwork, ucv, lcv, idx)
LibBlockNonSampledZC(ucv, lcv, NSZCIdx)
LibBlockPWork(definedpwork, ucv, lcv, idx)
LibBlockRWork(definedrwork, ucv, lcv, idx)
LibBlockZCSignalValue(ucv, lcv, zcsIdx, zcElIdx)
LibBlockReportFatalError(block, errorstring)
LibBlockReportWarning(block, warnstring)
LibGetFormattedBlockPath(block)
LibAddToCommonIncludes(incFileName)
LibCacheFunctionPrototype(buffer)
LibCallSetEventForThisBaseStep(buffername)
LibCreateSourceFile(type, creator, name)
LibGetSourceFileCustomSection(file, attrib)
LibGetSourceFileFromIdx(fileIdx)
LibMdlRegCustomCode(buffer, location)
LibMdlStartCustomCode(buffer, location)
LibMdlTerminateCustomCode(buffer, location)
LibSetSourceFileCodeTemplate(opFile, name)
LibSetSourceFileCustomSection(file, attrib, value)
LibSetSourceFileOutputDirectory(opFile, name)
LibSetSourceFileSection(fileH, section, value)
LibSystemDerivativeCustomCode(system, buffer, location)
LibSystemDisableCustomCode(system, buffer, location)
LibSystemEnableCustomCode(system, buffer, location)
LibSystemInitializeCustomCode(system, buffer, location)
LibSystemOutputCustomCode(system, buffer, location)
LibSystemUpdateCustomCode(system, buffer, location)
LibWriteModelInput(tid, rollThreshold)
LibWriteModelOutput(tid, rollThreshold)
LibAsyncTaskAccessTimeInFcn(tid, fcnType)
LibGetClockTickDataTypeId(tid)
LibGetElapseTimeCounter(system)
LibGetElapseTimeCounterDTypeId(system)
LibGetElapseTimeResolution(system)
LibGetGlobalTIDFromLocalSFcnTID(sfcnTID)
LibGetNumSFcnSampleTimes(block)
LibGetSampleTimePeriodAndOffset(tid, idx)
LibIsSFcnSpecialSampleHit(sfcnSTI, sfcnTID)
LibNumAsynchronousSampleTimes()
LibNumSynchronousSampleTimes()
LibPortBasedSampleTimeBlockIsTriggered(block)
LibSetVarNextHitTime(block, tNext)
LibBlockExecuteFcnDisable(block, callIdx)
LibBlockExecuteFcnEnable(block, callIdx)
LibBlockInputSignalAliasedThruDataTypeId(idx)
LibBlockOutputSignalAliasedThruDataTypeId(idx)
LibGenConstVectWithInit(data, typeId, varId)
LibGetBlockAttribute(block, attr)
LibGetCallerClockTickCounter(sfcnBlock)
LibGetCallerClockTickCounterHigh(sfcnBlock)
LibGetDataTypeComplexNameFromId(id)
LibGetDataTypeIdAliasedThruToFromId(id)
LibGetDataTypeIdAliasedToFromId(id)
LibGetDataTypeIdResolvesToFromId(id)
LibGetDataTypeSLSizeFromId(id)
LibGetDataTypeStorageIdFromId(id)
LibGetFcnCallBlock(sfcnblock,callIdx)
LibManageAsyncCounter(sfcnBlock, callIdx)
LibNeedAsyncCounter(sfcnBlock, callIdx)
LibSetAsyncClockTicks(sfcnBlock, callIdx, buf1, buf2)
LibSetAsyncCounter(sfcnBlock, callIdx, buf)
LibSetAsyncCounterHigh(sfcnBlock, callIdx, buf)
LibTIDInSystem(system, fcnType)
LibBlockInputSignalBufferDstPort(portIdx)
LibBlockInputSignalStorageClass(portIdx, sigIdx)
LibBlockInputSignalStorageTypeQualifier(portIdx, sigIdx)
LibBlockOutputSignalIsGlobal(portIdx)
LibBlockOutputSignalIsInBlockIO(portIdx)
LibBlockOutputSignalIsValidLValue(portIdx)
LibBlockOutputSignalStorageClass(portIdx)
LibBlockOutputSignalStorageTypeQualifier(portIdx)
LibBlockSrcSignalBlock(portIdx, sigIdx)
LibBlockSrcSignalIsDiscrete(portIdx, sigIdx)
LibBlockSrcSignalIsGlobalAndModifiable(portIdx, sigIdx)
LibBlockSrcSignalIsInvariant(portIdx, sigIdx)
LibGetModelReferenceUserData(modelName)
LibIsModelReferenceRTWTarget()
LibIsModelReferenceSimTarget()
• Blocks
| On this page… |
|---|
About Structure Parameters and Generated Code |
Structure parameters provide a way to improve generated code to use structures rather multiple separate variables. You also have the option of configuring the appearance of a structure parameter in generated code.
For more information about structure parameters, seeUsing Structure Parameters in the Simulink documentation. For an example of how to convert a model that uses unstructured workspace variables to a model that uses structure parameters, see sldemo_applyVarStruct.
By default, structure parameters do not appear in generated code. Structure parameters include numeric variables and the code generator inlines numeric values.
To make structure type definition appear in generated code for a structure parameter,
Create a Simulink.Parameter object.
Define the object value to be the parameter structure.
Define the object storage class to be a value other than Auto.
The code generator places a structure type definition or the tunable parameter structure in model_types.h. By default, the code generator identifies the type with a nondescriptive, automatically generated name, such as struct_z98c0D2qc4btL.
For information on how to control the naming of the type, see Control the Name of a Structure Parameter Type. For an example, see sldemo_applyVarStruct
To control the naming of a structure parameter type, by using a Simulink.Bus object to specify the data type of the Simulink.Parameter object.
Use Simulink.Bus.createObject to create a bus object with the same shape as the parameter structure. For example:
busInfo=Simulink.Bus.createObject(ControlParam.Value);
Assign the bus object name to the data type property of the parameter object.
ParamType=eval(busInfo.busName); ControlParam.DataType='Bus: ParamType';
Only Simulink.Parameter can accept the bus object name as a data type.
For an example, see sldemo_applyVarStruct
![]() | Enumerations | Parameters | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |


