Mathworks REAL-TIME WORKSHOP EMBEDDED CODER 5 Reference

Page 1
Real-Time Worksho
Reference
p
®
Embedded Coder™ 5
Page 2
How to Contact The MathWorks
www.mathworks. comp.soft-sys.matlab Newsgroup www.mathworks.com/contact_TS.html T echnical Support
suggest@mathworks.com Product enhancem ent suggestions bugs@mathwo doc@mathworks.com Documentation error reports service@mathworks.com Order status, license renewals, passcodes info@mathwo
com
rks.com
rks.com
Bug reports
Sales, prici
ng, and general information
508-647-7000 (Phone)
508-647-7001 (Fax)
The MathWorks, Inc. 3 Apple Hill Drive Natick, MA 01760-2098
For contact information about worldwide offices, see the MathWorks Web site.
®
Real-Time Workshop
© COPYRIGHT 2006–20 10 by The MathWorks, Inc.
The software described in this document is furnished under a license agreement. The software may be used or copied only under the terms of the license agreement. No part of this manual may be photocopied or reproduced in any form without prior written consent from The MathW orks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation by, for, or through the federal government of the United States. By accepting delivery of the Program or Documentation, the government hereby agrees that this software or documentation qualifies as commercial computer software or commercial computer software documentation as such terms are used or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern theuse,modification,reproduction,release,performance,display,anddisclosureoftheProgramand Documentation by the federal government (or other entity acquiring for or through the federal government) and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the government’s needs or is inconsistent in any respect with federal procurement law, the government agrees to return the Program and Docu mentation, unused, to The MathWorks, Inc.
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand
names may be trademarks or registered trademarks of their respective holders.
Patents
The MathWorks products are protected by one or more U.S. patents. Please see
www.mathworks.com/patents for more information.
Embedded Coder™ Reference
Page 3
Revision History
September 2006 Online only New for Version 4.5 (Release 2006b) March 2007 Online only Revised for Version 4.6 (Release 2007a) September 2007 Online only Revised for Version 5.0 (Release 2007b) March 2008 Online only Revised for Version 5.1 (Release 2008a) October 2008 Online only Revised for Version 5.2 (Release 2008b) March 2009 Online only Revised for Version 5.3 (Release 2009a) September 2009 Online only Revised for Version 5.4 (Release 2009b) March 2010 Online only Revised for Version 5.5 (Release 2010a)
Page 4
Page 5
Function Reference
1
AUTOSAR ......................................... 1-2
AUTOSAR Component Import AUTOSAR Configuration
....................... 1-2
........................... 1-3
Contents
C++ Encapsulation Interface Control
Code Generation Objectives Customization
Code Generation Verification
Function Prototype Control
Model Entry Points
Processor-in-the-Loop
Connectivity Configuration Build Execution Download, Start and Stop Host and Target Communications Host-Side Communications Target-Side Communications
System Target File Callback Interface
Target Function Library Table Creation
............................................ 1-13
................................ 1-12
.............................. 1-13
....................... 1-9
........................ 1-10
......................... 1-13
......................... 1-14
........................ 1-14
................ 1-6
.................. 1-14
.................... 1-14
............... 1-15
............. 1-16
.......... 1-8
v
Page 6
Class Reference
2
AUTOSAR ......................................... 2-1
AUTOSAR Component Import AUTOSAR Configuration
....................... 2-1
........................... 2-1
C++ Encapsulation Interface Control
Code Generation Objectives Customization
Code Generation Verification
Function Prototype Control
....................... 2-2
........................ 2-2
................ 2-2
.......... 2-2
Alphabetical List
3
Block Reference
4
AUTOSAR Client-Server Communication ............ 4-2
vi Contents
Configuration Wizards
Module Packaging
................................. 4-4
............................. 4-3
Page 7
Blocks — Alphabetical List
5
Configuration Parameters
6
Real-Time Workshop Pane: SIL and PIL Verification .. 6-2
Real-Time Workshop: SIL and PIL Verification Tab
Overview Enable portable word sizes Create SIL block Code coverage tool
...................................... 6-4
.......................... 6-5
.................................. 6-7
................................. 6-9
Real-Time Workshop Pane: Code Style
Real-Time Workshop: Code Style Tab Overview Parentheses l ev el Preserve operand order in expression Preserve condition expression in if statement Convert if-elseif-else patterns to switch-case statements Preserve extern keyword in function declaratio ns
Real-Time Workshop Pane: Templates
Real-Time Workshop: Templates Tab Overview Code templates: Source file (*.c) template Code templates: Header file (*.h) template Data templates: Source file (*.c) template Data templates: Header file (*.h) template File customization template Generate an example main program Target operating system
Real-Time Workshop Pane: Code Placement
Real-Time W orkshop: Code Placement Tab Overview Data definition Data definition filename Data declaration Data declaration filename #include file delimiter Module naming
................................. 6-13
......................... 6-29
............................ 6-32
................................... 6-37
............................ 6-39
.................................. 6-41
.......................... 6-43
.............................. 6-44
................................... 6-45
.............. 6-10
................. 6-15
........... 6-16
............... 6-22
.............. 6-25
............. 6-26
.............. 6-27
............. 6-28
.................. 6-30
........ 6-12
.. 6-18
....... 6-20
......... 6-24
......... 6-34
.... 6-36
vii
Page 8
Module name ..................................... 6-47
Signal display level Parameter tune level File packaging format
................................ 6-49
............................... 6-51
.............................. 6-53
Real-Time Workshop Pane: Data Type Replacement
Real-Time Workshop: Data Type Replacement Tab
Overview Replace data type names in the generated code Replacement Name: double Replacement Name: single Replacement Name: int32 Replacement Name: int16 Replacement Name: int8 Replacement Name: uint32 Replacement Name: uint16 Replacement Name: uint8 Replacement Name : boolean Replacement Name: int Replacement Name: uint Replacement Name: char
Real-Time Workshop Pane: Memory Sections
Real-Time W orkshop: Memory Sections Tab Overview Package Refresh package list Initialize/Terminate Execution Constants Inputs/Outputs Internal data Parameters Validation results
...................................... 6-58
......... 6-59
......................... 6-61
.......................... 6-63
.......................... 6-65
.......................... 6-67
........................... 6-69
......................... 6-71
......................... 6-73
.......................... 6-75
........................ 6-77
............................ 6-79
........................... 6-81
........................... 6-83
........ 6-85
......................................... 6-88
............................... 6-90
............................... 6-91
........................................ 6-92
........................................ 6-93
................................... 6-95
..................................... 6-97
...................................... 6-99
................................. 6-101
.. 6-56
... 6-87
viii Contents
Real-Time Workshop Pane: AUTOSAR Code Generation
Options
Real-Time Workshop: AUTOSAR Code Generation Options
Tab Overview Generate XML file from schema version Use AUTOSAR compiler abstraction macros Configure AUTOSAR Interface
......................................... 6-102
.................................. 6-104
............... 6-105
........... 6-105
...................... 6-107
Page 9
Parameter Reference .............................. 6-108
Recommended S ettings Summary Parameter Command-Line Information Summary
.................... 6-108
....... 6-120
Index
ix
Page 10
x Contents
Page 11

Function Reference

AUTOSAR (p. 1-2) Control AUTOSAR component
configuration for import, code generation, and XML file export from Simulink
®
models
1
C++ Encapsulation Interface Control (p. 1-6)
Code Generation Objectives Customization (p. 1-8)
Code Generation Verification (p. 1-9) Compare numerical equivalence
Function Prototype Control (p. 1-10) Control step function prototypes
Model Entry Points (p. 1-12) Access entry points in generated
Processor-in-the-Loop (p. 1-13) Control processor-in-the-loop (PIL)
System Target File Callback Interface (p. 1-15)
Target Function Library Table Creation (p. 1-16)
Control C++ encapsulation interfaces in generated code for ERT-based Simulink models
Control step function prototypes in generated code for ERT-based Simulink models
of simulation and generated code results
in generated code for ERT-based Simulink models
code for ERT-based Simulink models
configuration
Control Real-Time Workshop configuration o p t ions in callbacks for ERT-based custom targets
Create function replacement tables that make up Real-Time Workshop target function libraries (TFLs)
®
Page 12
1 Function Reference

AUTOSAR

AUTOSAR Component Import (p. 1-2)
AUTOSAR Configuration (p. 1-3) Control and validate AUTOSAR
Control import of AUT OSA R components
configuration

AUTOSAR Component Import

arxml.importer
createCalibrationComponentObjects (arxml.importer)
createComponentAsModel (arxml.importer)
createComponentAsSubsystem (arxml.importer)
createOperationAsConfigurableSubsystems (arxml.importer)
getCalibrationComponentNames (arxml.importer)
Construct
Create Simulink calibration objects from AUTOSAR calibration component
Create AUTOSAR atomic software component as Simulink model
Create AUTOSAR atomic software component as Simulink atomic subsystem
Create configurable Simulink subsystem library for client-server operation
Get calibration component names
arxml.importer object
1-2
getComponentNames (arxml.importer)
getDependencies (arxml.importer) Get list of XML dependency files
getFile (arxml.importer) Return XML file name for
setDependencies (arxml.importer) Set XML file dependencies
setFile (arxml.importer) S et XML file name for
Get atomic software component names
arxml.importer object
arxml.importer object
Page 13

AUTOSAR Configuration

addIOConf (RTW.AutosarInterface) Add AUTOSAR I/O configuration to
model
AUTOSAR
attachToModel (RTW.AutosarInterface)
getComponentName (RTW.AutosarInterface)
getDataTypePackageName (RTW.AutosarInterface)
getDefaultConf (RTW.AutosarInterface)
getExecutionPeriod (RTW.AutosarInterface)
getImplementationName (RTW.AutosarInterface)
getInitEventName (RTW.AutosarInterface)
getInitRunnableName (RTW.AutosarInterface)
getInterfacePackageName (RTW.AutosarInterface)
getInternalBehaviorName (RTW.AutosarInterface)
Attach object to mode l
Get XML component name
Get XML data type package name
Get default configuration
Get runnable execution period
Get XML implementation name
Getinitialeventname
Get initial runnable name
Get XM L interface package name
Get XML internal behavior name
RTW.AutosarInterface
getIOAutosarPortName (RTW.AutosarInterface)
getIODataAccessMode (RTW.AutosarInterface)
getIODataElement (RTW.AutosarInterface)
getIOErrorStatusReceiver (RTW.AutosarInterface)
GetI/OAUTOSARportname
Get I/O data access mode
Get I/O data element name
Get receiver port name
1-3
Page 14
1 Function Reference
getIOInterfaceName (RTW.AutosarInterface)
getIOPortNumber (RTW.AutosarInterface)
getIOServiceInterface (RTW.AutosarInterface)
getIOServiceName (RTW.AutosarInterface)
getIOServiceOperation (RTW.AutosarInterface)
getIsServerOperation (RTW.AutosarInterface)
getPeriodicEventName (RTW.AutosarInterface)
getPeriodicRunnableName (RTW.AutosarInterface)
getPortDefaultConf (RTW.AutosarInterface)
getServerInterfaceName (RTW.AutosarInterface)
Get I/O interface name
Get I/O AUTOSAR port number
GetportI/Oserviceinterface
GetportI/Oservicename
GetportI/Oserviceoperation
Determine whether server is specified
Get periodic event name
Get periodic runnable name
Getportdefaultconfiguration
Get name of server interface
1-4
getServerOperationPrototype (RTW.AutosarInterface)
getServerPortName (RTW.AutosarInterface)
getServerType (RTW.AutosarInterface)
RTW.AutosarInterface Construct
runValidation (RTW.AutosarInterface)
setComponentName (RTW.AutosarInterface)
Get server operation prototype
Get server port name
Determine server type
object
Validate object against model
SetXMLcomponentname
RTW.AutosarInterface
RTW.AutosarInterface
Page 15
AUTOSAR
setInitEventName (RTW.AutosarInterface)
setInitRunnableName (RTW.AutosarInterface)
setIOAutosarPortName (RTW.AutosarInterface)
setIODataAccessMode (RTW.AutosarInterface)
setIODataElement (RTW.AutosarInterface)
setIOInterfaceName (RTW.AutosarInterface)
setIsServerOperation (RTW.AutosarInterface)
setPeriodicEventName (RTW.AutosarInterface)
setPeriodicRunnableName (RTW.AutosarInterface)
setServerInterfaceName (RTW.AutosarInterface)
Set initial event name
Set initial runnable name
Set A UTOSAR port name
Set I/O data access mode
Set I/O data element
Set I/O interface name
Indicate that server is specified
Set periodic event name
Set p eriodic runnable name
Set name of server interface
setServerOperationPrototype (RTW.AutosarInterface)
setServerPortName (RTW.AutosarInterface)
setServerType (RTW.AutosarInterface)
syncWithModel (RTW.AutosarInterface)
Specify operation prototype
Set server port name
Specify server type
Synchronize configuration with model
1-5
Page 16
1 Function Reference

C++ Encapsulation Interface Control

attachToModel (RTW.ModelCPPClass)
getArgCategory (RTW.ModelCPPArgsClass)
getArgName (RTW.ModelCPPArgsClass)
getArgPosition (RTW.ModelCPPArgsClass)
getArgQualifier (RTW.ModelCPPArgsClass)
getClassName (RTW.ModelCPPClass)
getDefaultConf (RTW.ModelCPPClass)
Attach model-specific C++ encapsulation interface to loaded ERT-based Simulink model
Get argume nt category for Simulink model port from model-specific C++ encapsulation interface
GetargumentnameforSimulink model port from model-specific C++ encapsulation interface
GetargumentpositionforSimulink model port from model-specific C++ encapsulation interface
Getargumenttypequalifier for Simulink model port from model-specific C++ encapsulation interface
Get class nam e from model-specific C++ encapsulation interface
Get default config u ration information for model-specific C++ encapsulation interface from Simulink model
1-6
getNumArgs (RTW.ModelCPPClass) Get number of step method
arguments from model-specific C++ encapsulation interface
getStepMethodName (RTW.ModelCPPClass)
RTW.configSubsystemBuild Configure C function prototype
Getstepmethodnamefrom model-specific C++ encapsulation interface
or C++ encapsula tio n interface for right-click bui ld of specified subsystem
Page 17
C++ Encapsulation Interface Control
RTW.getEncapsulationInterfaceSpecificationGethandletomodel-specificC++
encapsulation interface control object
RTW.ModelCPPArgsClass Create C++ encapsulation interface
object for configuring model class with I/O arguments style step method
RTW.ModelCPPVoidClass Create C++ encapsulation interface
object for configuring model class with
void-void style step method
runValidation (RTW.ModelCPPArgsClass)
runValidation (RTW.ModelCPPVoidClass)
setArgCategory (RTW.ModelCPPArgsClass)
setArgName (RTW.ModelCPPArgsClass)
setArgPosition (RTW.ModelCPPArgsClass)
setArgQualifier (RTW.ModelCPPArgsClass)
setClassName (RTW.ModelCPPClass)
setStepMethodName (RTW.ModelCPPClass)
Validate model-specific C++ encapsulation interface against Simulink model
Validate model-specific C++ encapsulation interface against Simulink model
Set argume nt category for Simulink model port in model-specific C++ encapsulation interface
Set argument name for Simulink model port in model-specific C++ encapsulation interface
SetargumentpositionforSimulink model port in model-specific C++ encapsulation interface
Setargumenttypequalifier for Simulink model port in model-specific C++ encapsulation interface
Set class name in model-specific C++ encapsulation interface
Setstepmethodnamein model-specific C++ encapsulation interface
1-7
Page 18
1 Function Reference

Code Generation Objectives Customization

addCheck (rtw.codegenObjectives.Objective)
addParam (rtw.codegenObjectives.Objective)
excludeCheck (rtw.codegenObjectives.Objective)
modifyInheritedParam (rtw.codegenObjectives.Objective)
register (rtw.code
removeIn (rtw.cod
removeInheritedParam (rtw.codegenObjectives.Objective)
rtw.codegenObjectives.Objective Create custom code generation
setObjectiveName (rtw.codegenObjectives.Objective)
genObjectives.Objective)
heritedCheck
egenObjectives.Objective)
Add checks
Add parameters
Exclude chec
Modify inherited parameter values
Register o
Remove inherited checks
Remove inherited parameters
objectives
Specify objective name
ks
bjective
1-8
Page 19

Code Generation Verification

addCallback (cgv.CGV) Add callback function
addConfigSet (cgv.CGV) Add configuration set
addInputData (cgv.CGV) Add input data
addPostLoadFiles (cgv.CGV) Add files required by model
compare (cgv.CGV) Compare signal data
configModel (cgv.Config) Determine and change configuration
createToleranceFile (cgv.CG V ) Create file correlating tolerance
displayReport (cgv.Config) Display results of comparing
getOutputData (cgv.CGV) Get output data
getReportData (cgv.Config) Return results of comparing
Code Generation Verification
parameter values
information with signal names
configuration parameter values
configuration parameter values
getSavedSignals (cgv.CGV) Display list of signal names to
command line
plot (cgv.CGV) Create plot for signal or multiple
signals
run (cgv.CGV) Execute CGV object
setOutputDir (cgv.CGV) Specify folder
setOutputFile (cgv.CGV) Specify output data file name
1-9
Page 20
1 Function Reference

Function Prototype Control

addArgConf (RTW.ModelSpecificCPrototype)
attachToModel (RTW.ModelSpecificCPrototype)
getArgCategory (RTW.ModelSpecificCPrototype)
getArgName (RTW.ModelSpecificCPrototype)
getArgPosition (RTW.ModelSpecificCPrototype)
getArgQualifier (RTW.ModelSpecificCPrototype)
getDefaultConf (RTW.ModelSpecificCPrototype)
Add argument configuration information for Simulink model port to model-specific C function prototype
Attach model-specific C function prototype to loaded ERT -bas ed Simulink model
Get argume nt category for Simulink model port from model-specific C function prototype
GetargumentnameforSimulink model port from model-specific C function prototype
GetargumentpositionforSimulink model port from model-specific C function prototype
Getargumenttypequalifier for Simulink model port from model-specific C function prototype
Get default config u ration information for model-specific C function prototype from Simulink model
1-10
getFunctionName (RTW.ModelSpecificCPrototype)
getNumArgs (RTW.ModelSpecificCPrototype)
getPreview (RTW.ModelSpecificCPrototype)
Get function name from model-specific C function prototype
Get number of function arguments from model-specific C function prototype
Get model-specific C function prototype code preview
Page 21
Function Prototype Control
RTW.configSubsystemBuild Configure C function prototype
or C++ encapsula tio n interface for right-click bui ld of specified subsystem
RTW.getFunctionSpecification Get handle to model-specific C
prototype function control object
RTW.ModelSpecificCPrototype Create model-specific C prototype
object
runValidation (RTW.ModelSpecificCPrototype)
setArgCategory (RTW.ModelSpecificCPrototype)
setArgName (RTW.ModelSpecificCPrototype)
setArgPosition (RTW.ModelSpecificCPrototype)
setArgQualifier (RTW.ModelSpecificCPrototype)
setFunctionName (RTW.ModelSpecificCPrototype)
Validate model-specific C function prototype against Simulink model
Set argume nt category for Simulink model port in model-specific C function prototype
Set argument name for Simulink model port in model-specific C function prototype
SetargumentpositionforSimulink model port in model-specific C function prototype
Setargumenttypequalifier for Simulink model port in model-specific C function prototype
Setfunctionnameinmodel-specific C function prototype
1-11
Page 22
1 Function Reference

Model Entry Points

model_initialize Initialization entry point in
model_SetEventsForThisBaseStep Set event flags for multirate,
generated code for ERT-based Simulink model
multitasking operation before calling
model_step for ERT-based Simulink
model — not generated as of Version
5.1 (R2008a)
model_step
model_ter
minate
Step routine entry point in generated code for ERT-based Simulink model
Terminati code for ER
on entry point in generated
T-based Simulink model
1-12
Page 23

Processor-in-the-Loop

Connectivity Configuration (p. 1-13) Define processor-in-the-loop (PIL)
Build (p. 1-13) Configure PIL build process
Processor-in-the-Loop
configuration
Execution Download, Start and Stop (p. 1-14)
Host and Target Communications (p. 1-14)
Host-Side C om m u n i cation s (p. 1-14) Configure host-side communications
Target-Side Communications (p. 1-14)
Control downloading, starting and resetting PIL executable on target hardware
Configure host-target communications
channel and drivers
Configure target-side communications channel and drivers

Connectivity Configuration

rtw.connectivity.ComponentArgs
rtw.connectivity.Config Define connectivity implementation,
rtw.connectivity.ConfigRegistry Register connectivity configuration
Provide parameters to each target connectivity component
comprising builder, launcher, and communicator components
ld
Bui
rtw.connectivity.MakefileBuilder Configure makefile-based build
process
1-13
Page 24
1 Function Reference
Execution Downl
rtw.connectivi
ty.Launcher
Host and Targe
rtIOStreamClose Shut down communications channel
rtIOStreamOpen
rtIOStrea
rtIOStrea
mRecv
mSend
oad, Start and Stop
Control downloading, starting and resetting executable on target hardware
t Communications
with remote processor
Initialize with remote
Receive da
Send data t
communications channel
processor
ta from remote processor
o remote p roce ssor

Host-Side Communications

rtiostream_wrapper Test rtiostream shared library
methods
rtw.connectivity.RtIOStreamHost­Communicator
Configure host-side communications
1-14

Target-Side Communications

rtw.pil.RtIOStreamApplication­Framework
Configure target-side communications
Page 25

System Target File Callback Interface

slConfigUIGetVal Return current value for custom
target configuration option
System Target File Callback Interface
slConfigUISetEnabled
slConfigUISetVal Set value for custom target
Enable or disable custom target configuration option
configuration option
1-15
Page 26
1 Function Reference

Target Function Library Table Creation

addAdditionalHeaderFile Add additional header file to array of
addAdditionalIncludePath Add additional include path to array
addAdditionalLinkObj Add addi t ional link object to array of
addAdditionalLinkObjPath Add additional link object path to
addAdditionalSourceFile Add additional source file to array of
additional header files for TFL table entry
of additional include paths for TFL table entry
additional link objects for TFL table entry
array of additional link object paths for TFL table entry
additional source files for TFL table entry
1-16
addAdditionalSourcePath Add additional source path to array
of additional source paths for TFL table entry
addConceptualArg Add conceptual argument to array of
conceptual arguments for TFL table entry
addEntry
copyConceptualArgsToImplementationCopy conceptual argument
createAndAddConceptualArg Create conceptual argument from
Add table entry to collection of table entries registered in TFL table
specifications to matching implementation arguments for TFL table entry
specified properties an d add to conceptual arguments for TFL table entry
Page 27
Target Function Library Table Creation
createAndAddImplementationArg Create implementation argument
from specified properties and add to implementation arguments for TFL table entry
createAndSetCImplementationReturn Create implementation return
argument from specified properties and add to implementation for TFL table entry
enableCPP Enable C++ support for function
entry in TFL table
getTflArgFromString Create TFL argument based on
specified name and built-in data type
registerCFunctionEntry Create TFL function entry based on
specified p arame ters and register in TFL table
registerCPPFunctionEntry Create TFL C++ function entry
based on specified parameters and register in TFL table
registerCPromotableMacroEntry Create TFL promotable macro
entry based on specified parameters and register in TFL table (for
abs
function replacement only)
setNameSpace Set name space for C++ function
entry in TFL table
setReservedIdentifiers Register specified reserved
identifierstobeassociatedwithTFL table
setTflCFunctionEntryParameters Set specified parameters for function
entry in TFL table
setTflCOperationEntryParameters Set specified parameters for operator
entry in TFL table
1-17
Page 28
1 Function Reference
1-18
Page 29

Class Reference

“AUTOSAR” on page 2-1
“C++ Encapsulation Interface Control” on page 2-2
“Code Generation Objectives Customization” on p age 2-2
“Code Generation Verification” on page 2-2
“Function Prototype Control” on page 2-2

AUTOSAR

2
In this section...
“AUTOSAR Component Import” on page 2-1
“AUTOSAR Configuration” on page 2-1

AUTOSAR Component Import

arxml.importer

AUTOSAR Configuration

RTW.AutosarInterface Control and validate AUTOSAR
Control import of AUT OSA R components
configuration
Page 30
2 Class Reference

C++ Encapsulation Interface Control

RTW.ModelCPPArgsClass Control C++ encapsulation interfaces
for models using I/O arguments style step method
RTW.ModelCPPClass Control C++ encapsulation interfaces
for models
RTW.ModelCPPVoidClass Control C++ encapsulation interfaces
for models using step method

Code Generation Objectives Customization

rtw.codegenObjectives.Objective Customize code generation objectives
void-void style

Code Generation Verification

cgv.CGV Verify numerical equivalence of
cgv.Config Check and modify model

Function Prototype Control

RTW.ModelSpecificCPrototype Describe signatures of functions for
2-2
results
configuration parameter values
model
Page 31

Alphabetical List

3
Page 32
addAdditionalHeaderFile
Purpose Add additional header file to array of additional header files for TFL
table entry
Syntax addAdditionalHeaderFile(hEntry, headerFile)
Arguments hEntry
Handle to a TFL table entry previously returned by instantiating a TF L entry class, such as
hEntry = RTW.TflCOperationEntry.
headerFile
String specifying an additional header file.
Description The addAdditionalHeaderFile function adds a specified additional
header file to the array of additional header files for a TFL table entry.
Example In the following example, the addAdditionalHeaderFile
function is used along with addAdditionalIncludePath,
addAdditionalSourceFile,andaddAdditionalSourcePath to fully
specify additional header and source files for a TFL table entry.
hEntry = RTW.TflCFunctionEntry or
% Path to external header and source files
libdir = fullfile('$(MATLAB_ROOT)','..', '..', 'lib');
op_entry = RTW.TflCOperationEntry;
.
.
.
addAdditionalHeaderFile(op_entry, 'all_additions.h');
addAdditionalIncludePath(op_entry, fullfile(libdir, 'include'));
addAdditionalSourceFile(op_entry, 'all_additions.c');
addAdditionalSourcePath(op_entry, fullfile(libdir, 'src'));
See Also addAdditionalIncludePath, addAdditionalSourceFile,
addAdditionalSourcePath
3-2
Page 33
addAdditionalHeaderFile
“Specifying Build Information for Function Replacements” in the Real-Time Workshop
“Replacing Math Functions and Operators Using Target Function Libraries” in the Real-Time Workshop Embedded Coder documentation
®
Embedded Coder™ documentation
3-3
Page 34
addAdditionalIncludePath
Purpose Add additional include path to array of additional include paths for
TFL table entry
Syntax addAdditionalIncludePath(hEntry, path)
Arguments hEntry
Handle to a TFL table entry previously returned by instantiating a TF L entry class, such as
hEntry = RTW.TflCOperationEntry.
path
String specifying the full path to an additional header file.
Description The addAdditionalIncludePath function adds a specified additional
include path to the array of additional include paths for a TFL table entry.
Example In the following example, the addAdditionalIncludePath
function is used along with addAdditionalHeaderFile,
addAdditionalSourceFile,andaddAdditionalSourcePath to fully
specify additional header and source files for a TFL table entry.
hEntry = RTW.TflCFunctionEntry or
% Path to external header and source files
libdir = fullfile('$(MATLAB_ROOT)','..', '..', 'lib');
op_entry = RTW.TflCOperationEntry;
.
.
.
addAdditionalHeaderFile(op_entry, 'all_additions.h');
addAdditionalIncludePath(op_entry, fullfile(libdir, 'include'));
addAdditionalSourceFile(op_entry, 'all_additions.c');
addAdditionalSourcePath(op_entry, fullfile(libdir, 'src'));
See Also addAdditionalHeaderFile, addAdditionalSourceFile,
addAdditionalSourcePath
3-4
Page 35
addAdditionalIncludePath
“Specifying Build Information for Function Replacements” in the Real-Time Workshop Embedded Coder documentation
“Replacing Math Functions and Operators Using Target Function Libraries” in the Real-Time Workshop Embedded Coder documentation
3-5
Page 36
addAdditionalLinkObj
Purpose Add additional link object to array of additional link objects for TFL
table entry
Syntax addAdditionalLinkObj(hEntry, linkObj)
Arguments hEntry
Handle to a TFL table entry previously returned by instantiating a TF L entry class, such as
hEntry = RTW.TflCOperationEntry.
linkObj
String specifying an additional link object.
Description The addAdditionalLinkObj function adds a specified additional link
object to the array of additional link objects for a TFL table entry.
Example In the following example, the addAdditionalLinkObj function is used
along with link object file for a TFL table entry.
addAdditionalLinkObjPath to fu lly specify an additional
hEntry = RTW.TflCFunctionEntry or
% Path to external object files
libdir = fullfile('$(MATLAB_ROOT)','..', '..', 'lib');
op_entry = RTW.TflCOperationEntry;
...
addAdditionalLinkObj(op_entry, 'addition.o');
addAdditionalLinkObjPath(op_entry, fullfile(libdir, 'bin'));
See Also addAdditionalLinkObjPath
“Specifying Build Information for Function Replacements” in the Real-Time Workshop Embedded Coder documentation
“Replacing Math Functions and Operators Using Target Function Libraries” in the Real-Time Workshop Embedded Coder documentation
3-6
Page 37
addAdditionalLinkObjPath
Purpose Add additional link object path to array of additional link object paths
for TFL table entry
Syntax addAdditionalLinkObjPath(hEntry, path)
Arguments hEntry
Handle to a TFL table entry previously returned by instantiating a TF L entry class, such as
hEntry = RTW.TflCOperationEntry.
path
String specifying the full path to an additional link object.
Description The addAdditionalLinkObjPath function adds a specified additional
link object path to the array of additional link object paths for a TFL table entry.
Example In the following example, the addAdditionalLinkObjPath function is
used along with link object file for a TFL table entry.
addAdditionalLinkObj to fully specify an additional
hEntry = RTW.TflCFunctionEntry or
% Path to external object files
libdir = fullfile('$(MATLAB_ROOT)','..', '..', 'lib');
op_entry = RTW.TflCOperationEntry;
...
addAdditionalLinkObj(op_entry, 'addition.o');
addAdditionalLinkObjPath(op_entry, fullfile(libdir, 'bin'));
See Also addAdditionalLinkObj
“Specifying Build Information for Function Replacements” in the Real-Time Workshop Embedded Coder documentation
“Replacing Math Functions and Operators Using Target Function Libraries” in the Real-Time Workshop Embedded Coder documentation
3-7
Page 38
addAdditionalSourceFile
Purpose Add additional source file to array of additional source files for TFL
table entry
Syntax addAdditionalSourceFile(hEntry, sourceFile)
Arguments hEntry
Handle to a TFL table entry previously returned by instantiating a TF L entry class, such as
hEntry = RTW.TflCOperationEntry.
sourceFile
String specifying an additional source file.
Description The addAdditionalSourceFile function adds a specified additional
source file to the array of additional source files for a TFL table entry.
Example In the following example, the addAdditionalSourceFile
function is used along with addAdditionalHeaderFile,
addAdditionalIncludePath,andaddAdditionalSourcePath to fully
specify additional header and source files for a TFL table entry.
hEntry = RTW.TflCFunctionEntry or
% Path to external header and source files
libdir = fullfile('$(MATLAB_ROOT)','..', '..', 'lib');
op_entry = RTW.TflCOperationEntry;
.
.
.
addAdditionalHeaderFile(op_entry, 'all_additions.h');
addAdditionalIncludePath(op_entry, fullfile(libdir, 'include'));
addAdditionalSourceFile(op_entry, 'all_additions.c');
addAdditionalSourcePath(op_entry, fullfile(libdir, 'src'));
See Also addAdditionalHeaderFile, addAdditionalIncludePath,
addAdditionalSourcePath
3-8
Page 39
addAdditionalSourceFile
“Specifying Build Information for Function Replacements” in the Real-Time Workshop Embedded Coder documentation
“Replacing Math Functions and Operators Using Target Function Libraries” in the Real-Time Workshop Embedded Coder documentation
3-9
Page 40
addAdditionalSourcePath
Purpose Add additional source path to array of additional source paths for TFL
table entry
Syntax addAdditionalSourcePath(hEntry, path)
Arguments hEntry
Handle to a TFL table entry previously returned by instantiating a TF L entry class, such as
hEntry = RTW.TflCOperationEntry.
path
String specifying the full path to an additional source file.
Description The addAdditionalSourcePath function adds a specified additional
source file path to the array of additional source file paths for a TFL table.
Example In the following example, the addAdditionalSourcePath
function is used along with addAdditionalHeaderFile,
addAdditionalIncludePath,andaddAdditionalSourceFile to fully
specify additional header and source files for a TFL table entry.
hEntry = RTW.TflCFunctionEntry or
% Path to external header and source files
libdir = fullfile('$(MATLAB_ROOT)','..', '..', 'lib');
op_entry = RTW.TflCOperationEntry;
.
.
.
addAdditionalHeaderFile(op_entry, 'all_additions.h');
addAdditionalIncludePath(op_entry, fullfile(libdir, 'include'));
addAdditionalSourceFile(op_entry, 'all_additions.c');
addAdditionalSourcePath(op_entry, fullfile(libdir, 'src'));
See Also addAdditionalHeaderFile, addAdditionalIncludePath,
addAdditionalSourceFile
3-10
Page 41
addAdditionalSourcePath
“Specifying Build Information for Function Replacements” in the Real-Time Workshop Embedded Coder documentation
“Replacing Math Functions and Operators Using Target Function Libraries” in the Real-Time Workshop Embedded Coder documentation
3-11
Page 42
RTW.ModelSpecificCPrototype.addArgConf
Purpose Add argument configuration information for Simulink model port to
model-specific C function prototype
Syntax addArgConf(obj, portName, category, argName, qualifier)
Description addArgConf(obj, portName, category, argName, q ualifier)
method adds argument configuration information for a port in your ERT-based Simulink model to a model-specific C function prototype. You specify the name of the model port, the argument category ( or 'Pointer'), the argument name, and the argument type qualifier (for example,
'const').
'Value'
Input Arguments
The order of port in the function prototype, unless you change the order by other means, such as the method.
If a port has an existing argument configuration, subsequent calls to
addArgConf with the same port name overwrite the previous argument
configuration of the port.
obj
portName
category
argName
qualifier
addArgConf calls determines the argument position for the
RTW.ModelSpecificCPrototype.setArgPosition
Handle to a model-specific C prototype function control obje ct previously returned by
RTW.ModelSpecificCPrototype RTW.getFunctionSpecification(modelName)
String specifying the unqualified name of an inport or outport in your Simulink model.
String specifying the argument category, either
String specifying a valid C identifier.
String specifying the argument type qualifier:
'none', 'const', 'const *',or'const * const'
'Value' or 'Pointer'.
.
obj =
or obj =
.
3-12
Page 43
RTW.ModelSpecificCPrototype.addArgConf
Examples In the following example, you use the addArgConf method to add
argument configuration information for ports an ERT-based version of
rtwdemo_counter. After executing these
commands, click the Configure Model Functions button on the Interface pane of the Configuration Parameters dialog box to open the
Model Interface dialog box and confirm that the succeeded.
rtwdemo_counter
set_param(gcs,'SystemTargetFile','ert.tlc')
%% Create a function control object
a=RTW.ModelSpecificCPrototype
%% Add argument configuration information for Input and Output ports
addArgConf(a,'Input','Pointer','inputArg','const *')
addArgConf(a,'Output','Pointer','outputArg','none')
%% Attach the function control object to the model
attachToModel(a,gcs)
Input and Output in
addArgConf commands
Alternatives You can specify the argument config uration information in the Model
Interface dialog box. See “Configuring Model Function Prototypes” in the Real-Time Workshop Embedded Coder documentation.
See Also RTW.ModelSpecificCPrototype.attachToModel
“Controlling Generation of Function Prototypes” — Explains how to configure model function prototypes in generated code
3-13
Page 44
cgv.CGV.addCallback
Purpose Add callback function
Syntax cgvObj.addCallback(CallbackFcn)
Description cgvObj.addCallback(CallbackFcn) is an optional method that adds a
callback function to the object. Before executing the model, for each input data, the object loads the input data (that you added using callback function.
The declaration of th e callback function must receive the following parameters:
CallbackFcn(InputIndex, model_name, componentType, connectivity)
cgvObj isahandletoacgv.CGV object.
addInputData) and then calls the
model_name
arguments that you specified in the the index of the input data that th e callback function executes.
You can specify only one callback for each object.
, componentType, connectivity are identical to the
cgvObj constructor. InputIndex is
How To • “Verifying Numerical Equivalence of Results with Code Generation
Verification API”
• “Using Callback Functions”
3-14
Page 45
rtw.codegenObjectives.Objective.addCheck
Purpose Add checks
Syntax addCheck(obj, checkID)
Description addCheck(obj, checkID) includes the check, checkID,intheCode
Generation Advisor. When a user selects the objective, the Code Generation Advisor includes the check, unless another objective with a higher priority excludes the check.
Input Arguments
obj
checkID
Handle to a code generation objectiv e object previously created.
Unique identifier of the check that you add to the n ew objective.
Examples Add the Identify questionable code instrumentation (data I/O)
check to the objective.
addCheck(obj, 'Identify questionable code instrumentation (data I/O)');
See Also Simulink.ModelAdvisor
How To • “Creating Custom Objectives”
•“AboutIDs”
3-15
Page 46
addConceptualArg
Purpose Add conceptual argument to array of conceptual arguments for TFL
table entry
Syntax addConceptualArg(hEntry, arg)
Arguments hEntry
Handle to a TFL table entry previously returned by instantiating a TF L entry class, such as
hEntry = RTW.TflCOperationEntry.
arg
Argument, such as returned by arg =
getTflArgFromString(name, datatype)
array of conceptual arguments for the TFL table entry.
Description The addConceptualArg function adds a specified conceptual argument
to the array of conceptual arguments for a TFL table entry.
Example In the following example, the addConceptualArg function is used to
add conceptual arguments for the output port and the two input ports for an addition operation.
hEntry = RTW.TflCFunctionEntry or
,tobeaddedtothe
3-16
hLib = RTW.TflTable;
% Create entry for addition of built-in uint8 data type
op_entry = RTW.TflCOperationEntry;
op_entry.setTflCOperationEntryParameters( ...
'Key', 'RTW_OP_ADD', ...
'Priority', 90, ...
'SaturationMode', 'RTW_SATURATE_ON_OVERFLOW', ...
'RoundingMode', 'RTW_ROUND_UNSPECIFIED', ...
'ImplementationName', 'u8_add_u8_u8', ...
'ImplementationHeaderFile', 'u8_add_u8_u8.h', ...
'ImplementationSourceFile', 'u8_add_u8_u8.c' );
arg = hLib.getTflArgFromString('y1','uint8');
arg.IOType = 'RTW_IO_OUTPUT';
Page 47
op_entry.addConceptualArg( arg );
arg = hLib.getTflArgFromString('u1','uint8');
op_entry.addConceptualArg( arg );
arg = hLib.getTflArgFromString('u2','uint8');
op_entry.addConceptualArg( arg );
op_entry.copyConceptualArgsToImplementation();
hLib.addEntry( op_entry );
See Also getTflArgFromString
“Creating Function Replacement Tables” in the Real-Time Workshop Embedded Coder documentation
“Replacing Math Functions and Operators Using Target Function Libraries” in the Real-Time Workshop Embedded Coder documentation
addConceptualArg
3-17
Page 48
cgv.CGV.addConfigSet
Purpose Add configuration set
Syntax cgvObj.addConfigSet(configSet)
cgvObj.addConfigSet('configSetName') cgvObj.addConfigSet('file','configSetFileName') cgvObj.addConfigSet('file','configSetFileName','variable',
'configSetName')
Description cgvObj.addConfigSet(configSet) is an optional method that adds the
configuration set to the object.
cgvObj. configSet is a variable that specifies the configuration set.
cgvObj.addConfigSet('configSetName') is an optional method that
adds the configuration set to the object. specifies the name of the configuration set in the workspace.
cgvObj.addConfigSet('file','configSetFileName') is an
optional method that adds the configuration set to the object.
configSetFileName is a string that specifies thenameofthefilethat
contains only one configuration set.
cgvObj is a handle to a cgv.CGV object.
configSetName is a string that
cgvObj.addConfigSet('file','configSetFileName','variable', 'configSetName')
set to the object. The file contains one or more configuration sets. Specify the name of the configuration set to use.
This method replaces all configuration parameter values in the model with the values from the configuration set that you add. The object applies the configuration set when you call the add only one configuration set for each
is an optional method that adds the configuration
run method. You can
cgv.CGV object.
How To • “Verifying Numerical Equivalence of Results with Code Generation
Verification API”
• “Managing Configuration Sets”
3-18
Page 49
addEntry
Purpose Add table entry to collection of table entries registered in TFL table
Syntax addEntry(hTable, entry)
Arguments hTable
Handle to a TFL table previously returned by hTable =
RTW.TflTable
entry
Handle to a function or operator entry that you have constructed after calling
RTW.TflCOperationEntry
Description The addEntry function adds a function or operator entry that you have
constructed to the collectio n of table entries registered in a TFL table.
Example In the following example, the addEntry function is used to add an
operator entry to a TFL table after the entry is constructed.
.
hEntry = RTW.TflCFunctionEntry or hEntry =
hLib = RTW.TflTable;
% Create an entry for addition of built-in uint8 data type
op_entry = RTW.TflCOperationEntry;
op_entry.setTflCOperationEntryParameters( ...
'Key', 'RTW_OP_ADD', ...
'Priority', 90, ...
'SaturationMode', 'RTW_SATURATE_ON_OVERFLOW', ...
'RoundingMode', 'RTW_ROUND_UNSPECIFIED', ...
'ImplementationName', 'u8_add_u8_u8', ...
'ImplementationHeaderFile', 'u8_add_u8_u8.h', ...
'ImplementationSourceFile', 'u8_add_u8_u8.c' );
arg = hLib.getTflArgFromString('y1','uint8');
arg.IOType = 'RTW_IO_OUTPUT';
op_entry.addConceptualArg( arg );
arg = hLib.getTflArgFromString('u1','uint8');
3-19
Page 50
addEntry
op_entry.addConceptualArg( arg );
arg = hLib.getTflArgFromString('u2','uint8');
op_entry.addConceptualArg( arg );
op_entry.copyConceptualArgsToImplementation();
addEntry(hLib, op_entry);
See Also “Creating Function Replacement Tables” in the Real-Time Workshop
Embedded Coder documentation
“Replacing Math Functions and Operators Using Target Function Libraries” in the Real-Time Workshop Embedded Coder documentation
3-20
Page 51
cgv.CGV.addInputData
Purpose Add input data
Syntax cgvObj.addInputData(InputIndex,'DataFileName')
Description cgvObj.addInputData(InputIndex,'DataFileName') is a method
that adds an input data file to the object.
cgv.CGV object. InputIndex is a u nique numeric identifier to input
data. The input data is used when the model executes. the name of the input file, with or without the input file is in the working folder, the
cgvObj uses the InputIndex to identify the input data associated
The with output data and output data files. callback function to identify the input data that the callback function uses.
Tips • When calling addInputData you can modify configuration parameters
by including their settings in the input file,
addInputData does not qualify that the contents of DataFileName
relate to the inputs of the model. Data that is not used by the model will not throw a warning or error.
cgvObj is a handle to a
DataFileName is
.mat extension. If the
cgvObj does not require the path.
cgvObj passes InputIndex to a
DataFileName.
If you omit calling
Generation Verification runs once using data in the base workspace.
addInputData before executing the model, Code
How To • “Verifying Numerical Equivalence of Results with Code Generation
Verification API”
3-21
Page 52
RTW.AutosarInterface.addIOConf
Purpose Add AUTOSAR I/O configuration to model
Syntax autosarInterfaceObj.addIOConf(SimulinkPort, Dat aAccessMode,
autosarPort, InterfaceName, DataElement)
autosarInterfaceObj.addIOConf(SimulinkErrorStatusPort,
'ErrorStatus', CorrespondingSimulinkReceiverPort)
autosarInterfaceObj.addIOConf(SimulinkBasicSoftwarePort,
'BasicSoftwarePort', ServiceName, ServiceOperation, ServiceInterfacePath)
Description You can designate inports and outports to be data sender/receiver ports,
error status receivers, or access points to AUTOSAR Basic Software using the method
autosarInterfaceObj.addIOConf(SimulinkPort, Dat aAccessMode, autosarPort, InterfaceName, DataElement)
autosarInterfaceObj.addIOConf(SimulinkErrorStatusPort, 'ErrorStatus', CorrespondingSimulinkReceiverPort)
autosarInterfaceObj.addIOConf(SimulinkBasicSoftwarePort, 'BasicSoftwarePort', ServiceName, ServiceOperation, ServiceInterfacePath)
addIOConf:
Input Arguments
3-22
Each call adds an AUTOSAR I/O configuration to autosarInterfaceObj, a model-specific
SimulinkPort
RTW.AutosarInterface object.
Inport/outport name (string)
DataAccessMode
Data access mode of the port. You can designate inports and outports to be data sender/receiver ports by specifying
DataAccessMode to be
one of the following:
Page 53
RTW.AutosarInterface.addIOConf
autosarPort
InterfaceName
DataElement
SimulinkErrorStatusPort
'ErrorStatus'
CorrespondingSimulinkReceiverPort
'ImplicitSend'
'ImplicitReceive'
'ExplicitSend'
'ExplicitReceive'
Use 'Implicit...'where data is buffered by the run-time environment (RTE), or
'Explicit...'
where data is not buffered and hence not deterministic.
AUTOSAR port name (string)
Interfacename(string)
Data element name (string)
The port you choose to receive error status.
The data access mode for ports chosen to be error status receivers.
The port that is listened to for error status. The data access mode for this port must be either
'ImplicitReceive' or 'ExplicitReceive'.
3-23
Page 54
RTW.AutosarInterface.addIOConf
SimulinkBasicSoftwarePort
'BasicSoftwarePort'
ServiceName
ServiceOperation
ServiceInterfacePath
The port that you specify as an access point to AUTOSAR Basic Software.
The data access mode for ports chosen to be access points to AUTOSAR Basic Software.
The service name you specify. Must be a valid AUTOSAR identifier.
The service operation you specify. Must be a valid AUTOSAR identifier.
The service interface you specify. Must be a valid path of the form
AUTOSAR/Service/servicename.
See Also “Using the Configure AUTOSAR Interface Dialog Box” and “Configuring
Ports for Basic S oftware and Error Status Receivers” in the Real-Time Workshop Embedded Coder documentation
3-24
Page 55
rtw.codegenObjectives.Objective.addParam
Purpose Add parameters
Syntax addParam(obj, paramName, value)
Description addParam(obj, paramName, value) adds a parameter to the objective,
and defines the value of the parameter that the Code Generation Advisor verifies in Check model configuration settings against code generation objectives.
Input Arguments
obj
paramName
value
Handle to a code generation objectiv e object previously created.
Parameter that you add to the objective.
Value of the parameter.
Examples Add Inlineparameters to the objective, and specify the parameter
value as
on.
addParam(obj, 'InlineParams', 'on');
See Also get_param
How To • “Creating Custom Objectives”
• “Parameter Command-Line Information Summary”
3-25
Page 56
cgv.CGV.addPostLoadFiles
Purpose Add files required by model
Syntax cgvObj.addPostLoadfiles({FileList})
Description cgvObj.addPostLoadfiles({FileList}) is an optional method that
adds MATLAB
cgv.CGV object. cgvObj executes and loads the files after opening the
model and before running tests. MATLAB and MAT-files in the testing directory that the model requires to run.
®
and MAT-files to the object. cgvObj is a handle to a
FileList is a cell array of names of
How To • “Verifying Numerical Equivalence of Results with Code Generation
Verification API”
• “Using Callback Functions”
3-26
Page 57
arxml.importer class
Purpose Control import of AUTOSAR components
Description You can use methods of the arxml.importer class to import AUTOSAR
components in a controlled manner. For example, you can parse an AUTOSAR software component description file exported by DaVinci System Architect (from Vector Inform ati k Gmbh ), and import the component into a Simulink model for subsequent configuration, code generation, and export to XML.
Construction
Methods
arxml.importer
createCalibrationComponentObjectsCreate Simulink calibration
createComponentAsModel Create AUTOSAR atomic
createComponentAsSubsystem Create AUTOSAR atomic
createOperationAsConfigurableSubsystemsCreate configurable Simulink
getCalibrationComponentNames Get calibration component names
getComponentNames Get atomic software component
getDependencies
getFile
Construct
objects from AUTOSAR calibration component
software component as Simulink model
software component as Simulink atomic subsystem
subsystem library for client-server operation
names
Get list of XML dependency files
ReturnXMLfilenamefor
arxml.importer object
arxml.importer object
3-27
Page 58
arxml.importer class
Copy Semantics
setDependencies
setFile
Handle. To learn how this affects your use of the class, see C opying Objects in the MATLAB Programming Fundamentals documentation.
Set XML file dependencies
Set XML file name for
arxml.importer object
See Also Importing an AUTOSAR Software Component in the Real-Time
Workshop Embedded Coder documentation
3-28
Page 59
arxml.importer
Purpose Construct arxml.importer object
Syntax importer_obj = importer(filename)
Description importer_obj = importer(filename) constructs an arxml.importer
object and parses the atomic software component described in the XML file specified by
Note Only the atomic softw are components described in this XML file can b e imported.
filename.
Input Arguments
Output Arguments
filename
importer_obj
XML file containing description of atomic software component.
Handle to newly createdarxml.importer object.
See Also “Importing an AUTOSAR Software C omponent” in the Real-Time
Workshop Embedded Coder documentation
3-29
Page 60
RTW.AutosarInterface.attachToModel
Purpose Attach RTW.AutosarInterface object to model
Syntax autosarInterfaceObj.attachToModel(modelName)
Description autosarInterfaceObj.attachToModel(modelName) attaches
autosarInterfaceObj,anRTW.AutosarInterface object, to a loaded
Simulink model with an ERT-based target.
Input Arguments
modelName
Name of a loaded Simulink model to which the object is going to be attached (string).
See Also “Modifying and Validating an Existing AUTOSAR Interface” in th e
Real-Time Workshop Embedded Coder documentation
3-30
Page 61
RTW.ModelCPPClass.attachToModel
Purpose Attach model-specific C++ encapsulation interface to loaded ERT-based
Simulink model
Syntax attachToModel(obj, modelName)
Description attachToModel(obj, modelName) attaches a model-specific C++
encapsulation interface to a loaded ERT-ba s ed Simulink model.
Input Arguments
obj
modelName
Handle to a model-specific C++ encapsulation interface control object, such as a handle previously returned by
= RTW.ModelCPPArgsClass RTW.ModelCPPVoidClass
String specifying the name of a loaded ERT-based Simulink mod el to w h ich the objectisgoingtobeattached.
.
obj
or obj =
Alternatives The Configure C++ Encapsulation Interface buttononthe
Interface pane of the Simulink Configuration Parameters dialog box
launches the Configure C++ encapsulation interface dialog box, where you can flexibly control the C++ encapsulation interfaces that are generated for your model. Once you validate and apply your changes, you can generate code based on your C++ encapsulation interface modifications. See “Generating andConfiguringC++Encapsulation Interfaces to Model Code” in the Real-Time Workshop Embedded Coder documentation.
See Also “Configuring C++ Encapsulation Interfaces Programmatically” in the
Real-Time Workshop Embedded Coder documentation
“Sample Script for Configuring the Step Method for a Model Class” in the Real-Time Workshop Embedded Coder documentation
“Controlling Generation of Encapsulated C++ Model Interfaces” in the Real-Time Workshop Embedded Coder documentation
3-31
Page 62
RTW.ModelSpecificCPrototype.attachToModel
Purpose Attach model-specific C function prototype to loaded ERT-based
Simulink model
Syntax attachToModel(obj, modelName)
Description attachToModel(obj, modelName) attaches a model-specific C function
prototype to a loaded ERT-based Simulink model.
Input Arguments
obj
modelName
Handle to a model-specific C prototype function control object previously returned by
obj = RTW.ModelSpecificCPrototype.
String specifying the name of a loaded ERT-based Simulink mod el to w h ich the objectisgoingtobeattached.
Alternatives Click the Configure Model Functions button on the Configuration
Parameters > Real-Time Workshop > Inter fa ce pane for flexible
control over the model function prototypes that are generated for your model. Once you validate and apply your changes, you can generate code based on your function prototype modifications. See “Configuring Model Function Prototypes” in the Real-Time Workshop Embedded Coder documentation.
See Also “Controlling Generation of Function Prototypes” — Explains how to
configure model function prototypes in generated code
3-32
Page 63
cgv.CGV class
Purpose Verify numerical equivalence of results
Description Executes a model in different environments such as, simulation,
Software-In-the-Loop (SIL), or Processor-In-the-Loop (PIL) and stores numerical results. Using the script to verify that the model and the Real-Time Workshop Embedded Coder generated code produce numerically equ i valent results.
cgv.Config and cgv.CGV use many of the same properties. When the cgv.CGV object executes, it uses cgv.Config to verify that the model is
configured correctly for the mode of execution that you specify. If the top model is set to normal simulation m ode, any reference models set to PIL mode will be changed to Accelerator m ode.
Construction cgvObj = cgv.CGV('model_name') creates a handle to a code
generation verification object using the default properties. is the name of the model that you are verifying. Returns a handle to a
cgv.CGV object, cgvObj.
cgvObj = cgv.CGV('model_name','PropertyName','PropertyValue')
constructs the object using options, specified as property name and value pairs. Property names and values are not case sensitive.
cgv.CGV class methods, you can create a
model_name
Properties ComponentType
Define the SIL or PIL approach
If mode of execution is simulation ( either value for results. However, values based on the value of
connectivity is sim), choosing
ComponentType has no effect on simulation
cgv.CGV recommends configuration parameter
ComponentType.
3-33
Page 64
cgv.CGV class
Value
'topmodel' (default) Top-model SIL or PIL
'modelblock'
connectivity
Specify mode of execution
Value
'sim' (default) Mode of execution is Normal
'sil'
'tasking'
Description
simulation and standalone code interface mode.
Model block SIL or PIL simulation and model reference Real-Time W orkshop target code interface mode.
Description
simulation. Recommends changes to a proper subset of the configuration parameters that all PIL targets require.
Mode of execution is SIL. Recommends changes to the configuration parameters that SIL targets require.
Mode of ex ecutio n is PIL using the Embedded IDE Link™ software and Altium
®
TASKING tools configuration. Requires that you specify
'processor'. Recommends
changes to the configuration parameters that PIL targets using the Embedded IDE Link software and Altium TASKING tools require.
3-34
Page 65
cgv.CGV class
Value
'custom'
LogMode
Specify how to save signal data
Value
'SignalLogging' (default) Save signal data to the
'SaveOutput'
Description
Mode of ex ecutio n is PIL with custom connectivity that you provide using the PIL Connectivity API. Recommends changes to the configuration parameters that PIL targets with custom connectivity require.
Description
MATLAB workspace variable during execution.
To save the data, in the Configuration Parameters dialog box, the object uses the Data
Import/Export > Signal logging parameter. In the Signal logging name field,
definethevariablename.
Save signal data to the MATLAB workspace variable during execution.
To save the data, in the Configuration Parameters Dialog box, the object uses the Data
Import/Export > Output parameter. In the Output
3-35
Page 66
cgv.CGV class
Value
processor
Defines the processor type.
processor only when the value of connectivity is tasking.
Use
Value
'ARM'
'TriCore'
'C166'
'8051'
'M16C'
'DSP563xx'
Description
name field, define the variable name.
When you use the Output parametertosavesignaldata, Simulink does not save bus outputs.
Description
ARM®processor
Infineon®TriCore®processor
Infineon®C166®processor
Intel®8051 processor
Renesas®M16C processor
Freescale™ DSP566xx processor
3-36
SaveModel
Specify whether to save the model
Page 67
cgv.CGV class
Value
'off' (default) CGV checks the model
Description
configuration for compatibility with the connectivity target using save the model.
'on'
CGV updates and saves the model with required changes determined by Saves the model in the working folder.
ConfigModel
Specify whether to disable configuration checks
Value
'on' (default) CGV checks the model
Description
configuration for compatibility with the connectivity target using
'off'
Disable a ll use of cgv.Config on the model. Only specify
'off' if you are sure the model
is compatible.
cgv.Config. Does not
cgv.Config.
cgv.Config.
CheckInterface
Specify whether to verify the model outports
3-37
Page 68
cgv.CGV class
Methods
Value
'on' (default) CGV checks the model outports
'off'
addCallback Add callback function
addConfigSet Add configuration set
addInputData
addPostLoadFiles
compare
createToleranceFile
getOutputData Get output data
getSavedSignals Display list of signal names to
Description
for compatibility with CGV. CGV compiles the model first.
Disable verification of model outports. Only specify if you are sure the model outports are compatible with CGV.
Add input data
Add files required by model
Compare signal data
Create file correlating tolerance information with signal names
command line
'off'
Copy Semantics
3-38
plot
run
setOutputDir Specify folder
setOutputFile Specify output data file name
Handle. To learn how handle classes affect copy operations, see Copying Objects in the MATLAB Programming Fundamentals documentation.
Create plot for signal or multiple signals
Execute C GV object
Page 69
cgv.CGV class
Examples The general workflow for testing a model for numerical equivalence
using the
1 Create a cgv.CGV object for each mode of execution and use the
cgv.CGV set up methods to configure the model for each execution.
The set up methods are:
addConfigSet
addInputData
addPostLoadFiles
setOutputDir
setOutputFile
2 Run the model for each mode of execution using cgv.CGV.run.
3 Use the cgv.CGV access methods to get and evaluate the data. The
access methods are:
cgv.CGV classisto:
addCallBack
getOutputData
getSavedSignals
plot
compare
An object should only be run once. After the object is run, the set up methods are no longer used for that object. You then use the access methods for verifying the numerical equivalence of the results.
See Also cgv.Config
How To • “Verifying Numerical Equivalence of Results with Code Generation
Verification API”
• Using Code Generation Verification
3-39
Page 70
cgv.CGV class
• “VerifyingCodeUsingtheSILSimulationMode”
• “Verifying Compiled Object Code with Pro cesso r-in-the-Loop Simulation”
3-40
Page 71
cgv.Config class
Purpose Check and modify model configuration parameter values
Description Creates a handle to a cgv.Config object that supports checking and
optionally modifying models for compatibility with various modes of execution, such as simulation, Software-In-the-Loop (SIL), or Processor-In-the-Loop (PIL).
To execute the model successfully in the mode that you specify, you might need to make additional modifications to the configuration parametervaluesorthemodel.
By default, value that it recommends, but does not save the model. Alternatively, you can specify that
Modify configuration parameter values to the values that
recommends, and save the model. Specify this approach using the
SaveModel property.
List the values that
parameters, but do not modify the configuration parameters or the model. Specify this approach using the
Do not use referenced configuration sets in models that you are modifying using configuration set, update the model with a copy of the configuration set. Use the For more information, see documentation.
If you use the callback function might modify configuration parameter values each time the m odel loads. The callback function might revert changes that
cgv.Config made. When this change occurs, the model might no
longer be set up correctly for SIL or PIL. For more information, see “Using Callback Functions”.
cgv.Config modifies configuration parameter values to the
cgv.Config use one of the follow ing approaches:
cgv.Config
cgv.Config recommends for the configuration
ReportOnly property.
cgv.Config. If the model uses a referenced
Simulink.ConfigSetRef.getRefConfigSet method.
Simulink.ConfigSetRef in the Simu link
cgv.Config on a model that executes a callback function,
Construction cfgObj = cgv.Config('model_name') creates a handle to a
cgv.Config object, cfgObj, using default values for properties.
3-41
Page 72
cgv.Config class
model_name is the name of the model that you are checking and
optionally configuring.
cfgObj = cgv.Config('model_name','PropertyName','PropertyValue')
constructs the object using options, specified as property name and value pairs. Property names and values are not case sensitive.
cgv.Config and cgv.CGV use many of the same properties. When the cgv.CGV object executes, it uses cgv.Config to verify that the model is
configured correctly for the mode of execution that you specify.
Properties ComponentType
Define the SIL or PIL approach
If mode of execution is simulation ( either value for results. However,
ComponentType has no effect on simulation
cgv.Config recommends configuration
parameter values based on the value of
Value
'topmodel' (default) Top-model SIL or PIL
'modelblock'
connectivity
Specify mode of execution
connectivity is sim), choosing
ComponentType.
Description
simulation and standalone code interface mode.
Model block SIL or PIL simulation and model reference Real-Time W orkshop target code interface mode.
3-42
Page 73
cgv.Config class
Value
'sim' (default) Mode ofexecutionis
'sil'
'tasking'
'custom'
Description
simulation. Recommends changes to a proper subset of the configuration parameters that all PIL targets require.
Mode of execution is SIL. Requires that the system target file is set to andthatyoudonotuse your own external target. Recommends changes to the configuration parameters that SIL targets require.
Mode of ex ecutio n is PIL using the Embedded IDE Link software and Altium TASKING tools configuration. Requires that you specify
'processor'. Recommends
changes to the configuration parameters that PIL targets using the Embedded IDE Link software and Altium TASKING tools require.
Mode of ex ecutio n is PIL with custom connectivity that you provide using the PIL Connectivity API. Recommends changes to the configuration parameters that PIL targets with custom connectivity require.
'ert.tlc'
LogMode
3-43
Page 74
cgv.Config class
Specify how to save signal data
Value
'SignalLogging' (default) Save signal data to the
'SaveOutput'
Description
MATLAB workspace variable during execution.
To save the data, in the Configuration Parameters dialog box, the object uses the Data
Import/Export > Signal logging parameter . In the Signal logging name field,
definethevariablename.
Save signal data to the MATLAB workspace variable during execution.
To save the data, in the Configuration Parameters dialog box, the object uses the Data
Import/Export > Output
parameter . In the Output name field, define the variable name.
3-44
processor
Defines the processor type
processor only when the value of connectivity is tasking.
Use
When you use the Output parametertosavesignaldata, Simulink does not save bus outputs.
Page 75
cgv.Config class
Value
'ARM'
'TriCore'
'C166'
'8051'
'M16C'
'DSP563xx'
ReportOnly
Description
ARM processor
Infineon TriCore processor
Infineon C166 processor
Intel 8051 processor
Renesas M16C processor
Freescale DSP566xx processor
Specify whether to create a report
Specify w hether to create a report of the values that recommends for the configuration parameters, without modifying the configuration parameters or the model. If you set to 'on', SaveModel must be 'off'.
Value
'off' (default)
'on'
SaveModel
Description
Do not create a report.
Create a report.
cgv.Config
ReportOnly
Specify whether to save the model
Specify w hether to modify configuration parameter values to the values that set
SaveModel to 'on', ReportOnly must be 'off'.
Value
'off' (default)
'on'
cgv.Config recommends, and save the model. If you
Description
Do not save the model.
Save the model in the working folder.
3-45
Page 76
cgv.Config class
Methods
configModel
Determine and change configuration parameter values
displayReport
Display results of comparing configuration parameter values
getReportData
Return results of comparing configuration parameter values
Copy Semantics
Handle. To learn how handle classes affect copy operations, see Copying Objects in the MATLAB Programming Fundamentals documentation.
Examples Configure the rtwdemo_iec61508 model for top-model SIL. Then view
the changes at the MATLAB Command Window:
% Create a cgv.Config object and configure the model for top-model SIL.
cgvCfg = cgv.Config('rtwdemo_iec61508', 'LogMode', 'SaveOutput', ...
'connectivity', 'sil');
cgvCfg.configModel();
% Display the results of what the cgv.Config object changed.
cgvCfg.displayReport();
% Close the rtwdemo_iec61508 model.
bdclose('rtwdemo_iec61508');
See Also cgv.CGV
Tutorials • “How To Verify a SIL or PIL Configuration”
How To • “Configuring a PIL Simulation”
• “Choosing a PIL Approach”
• “Managing Configuration Sets”
3-46
Page 77
cgv.CGV.compare
Purpose Compare signal data
Syntax [matchNames, matchFigures, mism atch Names,
mismatchFigures] = cgv.CGV.compare(data_set1, data_set2)
[matchNames, matchFigures, mism atch Names,
mismatchFigures] = cgv.CGV.compare(data_set1, data_set2, 'Plot', 'param_value')
[matchNames, matchFigures, mism atch Names,
mismatchFigures] = cgv.CGV.compare(data_set1, data_set2, 'Plot', 'none', 'Signals', signa l_list, 'ToleranceFile', 'file_name.mat')
Description [matchNames, matchFigures, mismatchNames, mismatchFigures]
= cgv.CGV.compare(data_set1, data_set2)
data s ets which have common signal names between both executions. Possible outputs of the names, figure handles to the matched signal names, mismatched signal names, and figure handles to the mismatched signal names. By default,
cgv.CGV.compare looksatallsignalswhichhaveacommonname
betweenbothexecutions.
cgv.CGV.compare function are matched signal
compares data from two
Input Arguments
[matchNames, matchFigures, mism atch Names, mismatchFigures] = cgv.CGV.compare(data_set1, data_set2, 'Plot', 'param_value')
to
param_value.
[matchNames, matchFigures, mism atch Names, mismatchFigures] = cgv.CGV.compare(data_set1, data_set2, 'Plot', 'none', 'Signals', signal_list, 'ToleranceFile', 'f ile_name.mat')
compares only the given signals and produces no plots.
data_set1, data_set2
Output data from a model. After running the model, use the
cgv.CGV.getOutputData function to get the data. The
cgv.CGV.getOutputData function returns a cell array o f all output signal names.
compares all signals and plots the signals according
3-47
Page 78
cgv.CGV.compare
varargin
Variable number of parameter name and value pairs.
varargin Parameters
You can specify the following argument properties for the
cgv.CGV.compare function using parameter name and value argument
pairs. These parameters are optional.
Plot(optional)
Designates which comparison data to plot. The value of this parameter must be one of the following:
'match': plot the comparison of the matched signals from the
two datasets
'mismatch'(default): plot the comparison of the mismatched
signals from the two datasets
'none': donotproduceaplot
Signals(optional)
A cell array of strings, where each string is a signal name in the
dataset.Usecgv.CGV.getSavedSignals to view the list
of available signal names in the
dataset. signal_list can
contain an individual signal or multiple signals. The syntax for an individual signal name is:
signal_list = {'log_data.subsystem_name.Data(:,1)'}
The syntax for multiple signal names is:
3-48
signal_list = {'log_data.block_name.Data(:,1)',...
'log_data.block_name.Data(:,2)',...
'log_data.block_name.Data(:,3)',... 'log_data.block_name.Data(:,4)'};
If a m odel component contains a space or newline character, MATLAB adds parantheses and a single quote to the name of the component. For example, if a section of the signal has a space,
'block name', MATLAB displays the signal name as:
Page 79
cgv.CGV.compare
log_data.('block name').Data(:,1)
To use the signal name as input to a CGV function, 'block name' must have two single quotes. For example:
signal_list = {'log_data.(''block name'').Data(:,1)'}
If Signals is not present, all signals are compared.
Tolerancefile(optional)
Name for the file created by the function. The file contains the signal names and the associated tolerance parameter name and value pair for comparing the data.
cgv.CGV.createToleranceFile
Output Arguments
Depending on the data and the parameters, any of the following output arguments might be empty.
match_names
Cell array of matching signal names.
match_figures
Array of figure handles for matching signals
mismatch_names
Cell array of mismatching signal names
mismatch_figures
Array of figure handles for mismatching signals
How To • “Verifying Numerical Equivalence of Results with Code Generation
Verification API”
3-49
Page 80
cgv.Config.configModel
Purpose Determine and change configuration parameter values
Syntax cfgObj.configModel()
Description cfgObj.configModel() determines the recommended values for
the configuration parameters in the model.
cgv.Config object. The ReportOnly property of the object determines
whether values.
configModel reports or changes the configuration parameter
Tutorials • “How To Verify a SIL or PIL Configuration”
How To • “Configuring a PIL Simulation”
• “Managing Configuration Sets”
cfgObj isahandletoa
3-50
Page 81
copyConceptualArgsToImplementation
Purpose Copy conceptual argument specifications to matching implementation
arguments for TFL table entry
Syntax copyConceptualArgsToImplementation(hEntry)
Arguments hEntry
Handle to a TFL table entry previously returned by instantiating a TF L entry class, such as
hEntry = RTW.TflCOperationEntry.
Description The copyConceptualArgsToImplementation function provides a
quick way to copy conceptual argument specifications to matching implementation arguments. This function can be used when the conceptual arguments and the implementation arguments are the same for a TFL table entry.
Example In the following example, the copyConceptualArgsToImplementation
function is used to copy conceptual argument specifications to matching implementation arguments for an addition operation.
hEntry = RTW.TflCFunctionEntry or
hLib = RTW.TflTable;
% Create an entry for addition of built-in uint8 data type
op_entry = RTW.TflCOperationEntry;
op_entry.setTflCOperationEntryParameters( ...
'Key', 'RTW_OP_ADD', ...
'Priority', 90, ...
'SaturationMode', 'RTW_SATURATE_ON_OVERFLOW', ...
'RoundingMode', 'RTW_ROUND_UNSPECIFIED', ...
'ImplementationName', 'u8_add_u8_u8', ...
'ImplementationHeaderFile', 'u8_add_u8_u8.h', ...
'ImplementationSourceFile', 'u8_add_u8_u8.c' );
arg = hLib.getTflArgFromString('y1','uint8');
arg.IOType = 'RTW_IO_OUTPUT';
op_entry.addConceptualArg( arg );
3-51
Page 82
copyConceptualArgsToImplementation
arg = hLib.getTflArgFromString('u1','uint8');
op_entry.addConceptualArg( arg );
arg = hLib.getTflArgFromString('u2','uint8');
op_entry.addConceptualArg( arg );
op_entry.copyConceptualArgsToImplementation();
hLib.addEntry( op_entry );
See Also “Creating Function Replacement Tables” in the Real-Time Workshop
Embedded Coder documentation
“Replacing Math Functions and Operators Using Target Function Libraries” in the Real-Time Workshop Embedded Coder documentation
3-52
Page 83
createAndAddConceptualArg
Purpose Create conceptual argument from specified properties and add to
conceptual arguments for TFL table entry
Syntax arg = createAndAddConceptualArg(hEntry, argType, varar gin)
Arguments hEntry
Handle to a TFL table entry previously returned by instantiating a TF L entry class, such as
hEntry = RTW.TflCOperationEntry.
argType
String specifying the argument type to create:
'RTW.TflArgNumeric' for numeric or 'RTW.TflArgMatrix' for
matrix.
varargin
Parameter/value pairs for the conceptual argument. See varargin Parameters.
hEntry = RTW.TflCFunctionEntry or
varargin Parameters
The following argument properties can be specified to the
createAndAddConceptualArg function using param eter/value
argument pairs. For example,
createAndAddConceptualArg(..., 'DataTypeMode', 'double', ...);
Name
String specifying the argument name, for example, 'y1' or 'u1'.
IOType
String specifying the I/O type of the argument: 'RTW_IO_INPUT' for input or 'RTW_IO_OUTPUT' for output. The default is
'RTW_IO_INPUT'.
IsSigned
Boolean value that, when set to true, indicates that the argument is signed. The default is
true.
3-53
Page 84
createAndAddConceptualArg
WordLength
Integer specifying the word length, in bits, of the argument. The default is
CheckSlope
Boolean flag that, when set to true for a fixed-point argument, causes TFL replacement request processing to check that the slope value of the argument exactly matches the call-site slope value. The default is
16.
true.
Specify
true if you are matching a specific [slope bias] scaling
combination or a specific binary-point-only sca li n g combination on fixed-point operator inputs and output. Specify
false if you are
matching relative scaling or relative slope and bias values across fixed-point operator inputs and output.
CheckBias
Boolean flag that, when set to true for a fixed-point argument, causes TFL replacement request processing to check that the bias value of the argument exactly matches the call-site bias value. The default is
Specify
true if you are matching a specific [slope bias] scaling
true.
combination or a specific binary-point-only sca li n g combination on fixed-point operator inputs and output. Specify
false if you are
matching relative scaling or relative slope and bias values across fixed-point operator inputs and output.
DataTypeMode
String specifying the d ata type mode of the argument: 'boolean',
'double', 'single', 'Fixed-point: binary point scaling',
or
'Fixed-point: slope and bias scaling'. The default is
'Fixed-point: binary point scaling'.
Note You can specify either DataType (with Scaling)or
DataTypeMode, but do not specify both.
3-54
Page 85
createAndAddConceptualArg
DataType
String specifying the data type of the argument: 'boolean',
'double', 'single',or'Fixed'. The default is 'Fixed'.
Scaling
String specifying the data type scaling of the argument:
'BinaryPoint' for binary-point scaling or 'SlopeBias' for slope
and bias scaling. The default is
Slope
Floating-point value specifying the slope of the argument, for example,
15.0. The default is 1.
If you are matching a specific [slope bias] scaling combination on fixed-point operator inputs and output, specify either this parameteroracombinationofthe
FixedExponent parameters
SlopeAdjustmentFactor
Floating-point value specifying the slope adjustment factor (F) part of the slope,
E
F2
, of the argument. The default is 1.0.
'BinaryPoint'.
SlopeAdjustmentFactor and
If you are matching a specific [slope bias] scaling combination on fixed-point operator inputs and output, specify either the
Slope parameter or a combination of this parameter and the FixedExponent parameter.
FixedExponent
Integer value specifying the fixed exponent (E)partoftheslope,
E
F2
, of the argument. The default is -15.
If you are matching a specific [slope bias] scaling combination on fixed-point operator inputs and output, specify either the
Slope parameter or a combination of this parameter and the SlopeAdjustmentFactor parameter.
Bias
Floating-point value specifying the bias of the argument, for example,
2.0.Thedefaultis0.0.
3-55
Page 86
createAndAddConceptualArg
Specify this parameter if you are matching a specific [slope bias] scaling combination on fix ed-point operator inputs and output.
FractionLength
Integer value specifying the fraction length for the argument, for example,
Specify this parameter if y ou are matching a specific binary-point-only scaling combination on fixed-point operator inputs and output.
BaseType
String specifying the base data type for which a matrix argument is valid, for example,
DimRange
Dimensions for which a matrix argument is valid, for example,
[2 2]. You can also specify a range of dimensions specified in the
format
... DimNMax]
two-dimensional m atrix of size 2x2 or larger.
3.Thedefaultis15.
[Dim1Min Dim2Min ... DimNMin; Dim1Max Dim2Max
. For example, [2 2; inf inf] means any
'double'.
Returns Handle to the created conceptual argument. Specifying the return
argument in the
createAndAddConceptualArg function call is optional.
Description The createAndAddConceptualArg function creates a conceptual
argument from specified properties and adds the argument to the conceptual arguments for a TFL table entry.
Examples In the following example, thecreateAndAddConceptualArg function
is used to specify conceptual output and input arguments for a TFL operator entry.
op_entry = RTW.TflCOperationEntry;
.
.
.
createAndAddConceptualArg(op_entry, 'RTW.TflArgNumeric', ...
3-56
Page 87
createAndAddConceptualArg
'Name', 'y1', ...
'IOType', 'RTW_IO_OUTPUT', ...
'IsSigned', true, ...
'WordLength', 32, ...
'FractionLength', 0);
createAndAddConceptualArg(op_entry, 'RTW.TflArgNumeric',...
'Name', 'u1', ...
'IOType', 'RTW_IO_INPUT',...
'IsSigned', true,...
'WordLength', 32, ...
'FractionLength', 0 );
createAndAddConceptualArg(op_entry, 'RTW.TflArgNumeric',...
'Name', 'u2', ...
'IOType', 'RTW_IO_INPUT',...
'IsSigned', true,...
'WordLength', 32, ...
'FractionLength', 0 );
The following examples show some common type specifications using
createAndAddConceptualArg.
% uint8:
createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ...
'Name', 'u1', ...
'IOType', 'RTW_IO_INPUT', ...
'IsSigned', false, ...
'WordLength', 8, ...
'FractionLength', 0 );
% single:
createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ...
'Name', 'u1', ...
'IOType', 'RTW_IO_INPUT', ...
'DataTypeMode', 'single' );
3-57
Page 88
createAndAddConceptualArg
% double:
createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ...
% boolean:
createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ...
% Fixed-point using binary-point-only scaling:
createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ...
'Name', 'y1', ...
'IOType', 'RTW_IO_OUTPUT', ...
'CheckSlope', true, ...
'CheckBias', true, ...
'DataTypeMode', 'Fixed-point: binary point scaling', ...
'IsSigned', true, ...
'WordLength', 32, ...
'FractionLength', 28);
'Name', 'y1', ...
'IOType', 'RTW_IO_OUTPUT', ...
'DataTypeMode', 'double' );
'Name', 'u1', ...
'IOType', 'RTW_IO_INPUT', ...
'DataTypeMode', 'boolean' );
3-58
% Fixed-point using [slope bias] scaling:
createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ...
'Name', 'y1', ...
'IOType', 'RTW_IO_OUTPUT', ...
'CheckSlope', true, ...
'CheckBias', true, ...
'DataTypeMode', 'Fixed-point: slope and bias scaling', ...
'IsSigned', true, ...
'WordLength', 16, ...
'Slope', 15, ...
'Bias', 2);
For examples of fixed-point arguments that use relative scaling or relative slope/bias values, see “Example: Creating Fixed-Point
Page 89
createAndAddConceptualArg
Operator Entries for Relative Scaling (Multiplication and Division)” an d “Example: Creating Fixed-Point Operator Entries for Equal S lope and Zero Net Bias (Addition and Subtraction)” in the Real-Time Workshop Embedded Coder documentation.
See Also “Creating Function Replacement Tables” in the Real-Time Workshop
Embedded Coder documentation
“Replacing Math Functions and Operators Using Target Function Libraries” in the Real-Time Workshop Embedded Coder documentation
3-59
Page 90
createAndAddImplementationArg
Purpose Create implementation argument from specified properties and add to
implementation arguments for TFL table entry
Syntax arg = createAndAddImplementationArg(hEntry, argTyp e,
varargin)
Arguments hEntry
Handle to a TFL table entry previously returned by instantiating a TF L entry class, such as
hEntry = RTW.TflCOperationEntry.
argType
String specifying the argument type to create:
'RTW.TflArgNumeric' for numeric.
varargin
Parameter/value pairs for the implementation argument. See varargin Parameters.
hEntry = RTW.TflCFunctionEntry or
varargin Parameters
3-60
The following argument properties can be specified to the
createAndAddImplementationArg function using parameter/value
argument pairs. For example,
createAndAddImplementationArg(..., 'DataTypeMode', 'double', ...);
Name
String specifying the argument name, for example, 'u1'.
IOType
String specifying the I/O type of the argument: 'RTW_IO_INPUT' for input.
IsSigned
Boolean value that, when set to true, indicates that the argument is signed. The default is
WordLength
Integer specifying the word length, in bits, of the argument. The default is
16.
true.
Page 91
createAndAddImplementationArg
DataTypeMode
String specifying the d ata type mode of the argument: 'boolean',
'double', 'single', 'Fixed-point: binary point scaling',
or
'Fixed-point: slope and bias scaling'. The default is
'Fixed-point: binary point scaling'.
Note You can specify either DataType (with Scaling)or
DataTypeMode, but do not specify both.
DataType
String specifying the data type of the argument: 'boolean',
'double', 'single',or'Fixed'. The default is 'Fixed'.
Scaling
String specifying the data type scaling of the argument:
'BinaryPoint' for binary-point scaling or 'SlopeBias' for slope
and bias scaling. The default is
'BinaryPoint'.
Slope
Floating-point value specifying the slope of the argument, for example,
15.0. The default is 1.
You can optionally specify either this parameter or a combinatio n of the
SlopeAdjustmentFactor and FixedExponent parameters,
but do not specify both.
SlopeAdjustmentFactor
Floating-point value specifying the slope adjustment factor (F) part of the slope,
You can optionally specify either the combination of this parameter and the
E
F2
, of the argument. The default is 1.0.
Slope parameter or a
FixedExponent parameter,
but do not specify both.
FixedExponent
Integer value specifying the fixed exponent (E)partoftheslope,
E
F2
, of the argument. The default is -15.
3-61
Page 92
createAndAddImplementationArg
You can optionally specify either the Slope parameter or a combination of this parameter and the parameter, but do not specify both.
Bias
Floating-point value specifying the bias of the argument, for example,
FractionLength
Integer value specifying the fraction length of the argument, for example,
Value
Constant value specifying the initial value of the argument. The default is 0.
Use this parameter only to set the value of injected constant input arguments, such as arguments that pass fraction-length values or flag values, in an implementation function signature. Do not use it for standard generated input arguments such as and so on. You can place a constant input argument that uses this parameter at any position in the implementation function signature except as the return argument.
2.0.Thedefaultis0.0.
3.Thedefaultis15.
SlopeAdjustmentFactor
u1, u2,
You can inject constant input arguments into the implementation signature for any TFL table entry, but if the argument values or the number of arguments required depends on compile-time information, you should use custom matching. For more information, see “Refining TFL Matching and Replacement Using Custom TFL Table Entries” in the Real-Time Workshop Embedded Coder documentation.
Returns Handle to the created implementation argument. Specifying the return
argument in the optional.
3-62
createAndAddImplementationArg function call is
Page 93
createAndAddImplementationArg
Description The createAndAddImplementationArg function creates an
implementation argument from specified properties and adds the argument to the implementation arguments for a TFL table entry.
Note Implementation arguments must describe fundamental numeric data types, such as
uint16, uint8,orboolean (not fixed point data types).
Example In the following example, thecreateAndAddImplementationArg
function is used along with the createAndSetCImplementationReturn function to specify the output and input arguments for an operator implementation.
op_entry = RTW.TflCOperationEntry;
.
.
.
createAndSetCImplementationReturn(op_entry, 'RTW.TflArgNumeric', ...
double, single, int32, int16, int8, uint32,
'Name', 'y1', ...
'IOType', 'RTW_IO_OUTPUT', ...
'IsSigned', true, ...
'WordLength', 32, ...
'FractionLength', 0);
createAndAddImplementationArg(op_entry, 'RTW.TflArgNumeric',...
'Name', 'u1', ...
'IOType', 'RTW_IO_INPUT',...
'IsSigned', true,...
'WordLength', 32, ...
'FractionLength', 0 );
createAndAddImplementationArg(op_entry, 'RTW.TflArgNumeric',...
'Name', 'u2', ...
'IOType', 'RTW_IO_INPUT',...
'IsSigned', true,...
3-63
Page 94
createAndAddImplementationArg
'WordLength', 32, ...
'FractionLength', 0 );
The following examples show some common type specifications using
createAndAddImplementationArg.
% uint8:
createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ...
'Name', 'u1', ...
'IOType', 'RTW_IO_INPUT', ...
'IsSigned', false, ...
'WordLength', 8, ...
'FractionLength', 0 );
% single:
createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ...
'Name', 'u1', ...
'IOType', 'RTW_IO_INPUT', ...
'DataTypeMode', 'single' );
% double:
createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ...
% boolean:
createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ...
See Also createAndSetCImplementationReturn
“Creating Function Replacement Tables” in the Real-Time Workshop Embedded Coder documentation
3-64
'Name', 'u1', ...
'IOType', 'RTW_IO_INPUT', ...
'DataTypeMode', 'double' );
'Name', 'u1', ...
'IOType', 'RTW_IO_INPUT', ...
'DataTypeMode', 'boolean' );
Page 95
createAndAddImplementationArg
“Replacing Math Functions and Operators Using Target Function Libraries” in the Real-Time Workshop Embedded Coder documentation
3-65
Page 96
createAndSetCImplementationReturn
Purpose Create implementation return argument from specified properties and
add to implementation for TFL table entry
Syntax arg = createAndSetCImplementationReturn(hEntry, ar gTyp e,
varargin)
Arguments hEntry
Handle to a TFL table entry previously returned by instantiating a TF L entry class, such as
hEntry = RTW.TflCOperationEntry.
argType
String specifying the argument type to create:
'RTW.TflArgNumeric' for numeric.
varargin
Parameter/value pairs for the implementation return argument. See varargin Parameters.
hEntry = RTW.TflCFunctionEntry or
varargin Parameters
3-66
The following argument properties can be specified to the
createAndSetCImplementationReturn function using parameter/value
argument pairs. For example,
createAndSetCImplementationReturn(..., 'DataTypeMode', 'double', ...);
Name
String specifying the argument name, for example, 'y1'.
IOType
String specifying the I/O type of the argument: 'RTW_IO_OUTPUT' for output.
IsSigned
Boolean value that, when set to true, indicates that the argument is signed. The default is
WordLength
Integer specifying the word length, in bits, of the argument. The default is
16.
true.
Page 97
createAndSetCImplementationReturn
DataTypeMode
String specifying the d ata type mode of the argument: 'boolean',
'double', 'single', 'Fixed-point: binary point scaling',
or
'Fixed-point: slope and bias scaling'. The default is
'Fixed-point: binary point scaling'.
Note You can specify either DataType (with Scaling)or
DataTypeMode, but do not specify both.
DataType
String specifying the data type of the argument: 'boolean',
'double', 'single',or'Fixed'. The default is 'Fixed'.
Scaling
String specifying the data type scaling of the argument:
'BinaryPoint' for binary-point scaling or 'SlopeBias' for slope
and bias scaling. The default is
'BinaryPoint'.
Slope
Floating-point value specifying the slope for a fixed-point argument, for example,
15.0. The default is 1.
You can optionally specify either this parameter or a combinatio n of the
SlopeAdjustmentFactor and FixedExponent parameters,
but do not specify both.
SlopeAdjustmentFactor
Floating-point value specifying the slope adjustment factor (F) part of the slope,
You can optionally specify either the combination of this parameter and the
E
F2
, of the argument. The default is 1.0.
Slope parameter or a
FixedExponent parameter,
but do not specify both.
FixedExponent
Integer value specifying the fixed exponent (E)partoftheslope,
E
F2
, of the argument. The default is -15.
3-67
Page 98
createAndSetCImplementationReturn
You can optionally specify either the Slope parameter or a combination of this parameter and the parameter, but do not specify both.
Bias
Floating-point value specifying the bias of the argument, for example,
FractionLength
2.0.Thedefaultis0.0.
Integer value specifying the fraction length of the argument, for example,
3.Thedefaultis15.
Returns Handle to the created implementation return argument. Specifying
the return argument in the function call is optional.
createAndSetCImplementationReturn
Description The createAndSetCImplementationReturn function creates an
implementation return argument from specified properties and adds the argument to the implementation for a TFL table.
SlopeAdjustmentFactor
Note Implementation return arg uments must describe fundamental numeric data types, such as
uint32, uint16, uint8,orboolean (not fixed point data types).
double, single, int32, int16, int8,
Example In the following example, the createAndSetCImplementationReturn
function is used along with the createAndAddImplementationArg function to specify the output and input arguments for an operator implementation.
op_entry = RTW.TflCOperationEntry;
.
.
.
createAndSetCImplementationReturn(op_entry, 'RTW.TflArgNumeric', ...
'Name', 'y1', ...
'IOType', 'RTW_IO_OUTPUT', ...
3-68
Page 99
createAndSetCImplementationReturn
'IsSigned', true, ...
'WordLength', 32, ...
'FractionLength', 0);
createAndAddImplementationArg(op_entry, 'RTW.TflArgNumeric',...
'Name', 'u1', ...
'IOType', 'RTW_IO_INPUT',...
'IsSigned', true,...
'WordLength', 32, ...
'FractionLength', 0 );
createAndAddImplementationArg(op_entry, 'RTW.TflArgNumeric',...
'Name', 'u2', ...
'IOType', 'RTW_IO_INPUT',...
'IsSigned', true,...
'WordLength', 32, ...
'FractionLength', 0 );
The following examples show some common type specifications using
createAndSetCImplementationReturn.
% uint8:
createAndSetCImplementationReturn(hEntry, 'RTW.TflArgNumeric', ...
'Name', 'y1', ...
'IOType', 'RTW_IO_OUTPUT', ...
'IsSigned', false, ...
'WordLength', 8, ...
'FractionLength', 0 );
% single:
createAndSetCImplementationReturn(hEntry, 'RTW.TflArgNumeric', ...
'Name', 'y1', ...
'IOType', 'RTW_IO_OUTPUT', ...
'DataTypeMode', 'single' );
% double:
createAndSetCImplementationReturn(hEntry, 'RTW.TflArgNumeric', ...
3-69
Page 100
createAndSetCImplementationReturn
'Name', 'y1', ...
'IOType', 'RTW_IO_OUTPUT', ...
'DataTypeMode', 'double' );
% boolean:
createAndSetCImplementationReturn(hEntry, 'RTW.TflArgNumeric', ...
'Name', 'y1', ...
'IOType', 'RTW_IO_OUTPUT', ...
'DataTypeMode', 'boolean' );
See Also createAndAddImplementationArg
“Creating Function Replacement Tables” in the Real-Time Workshop Embedded Coder documentation
“Replacing Math Functions and Operators Using Target Function Libraries” in the Real-Time Workshop Embedded Coder documentation
3-70
Loading...