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 onlyNew for Version 4.5 (Release 2006b)
March 2007Online onlyRevised for Version 4.6 (Release 2007a)
September 2007 Online onlyRevised for Version 5.0 (Release 2007b)
March 2008Online onlyRevised for Version 5.1 (Release 2008a)
October 2008Online onlyRevised for Version 5.2 (Release 2008b)
March 2009Online onlyRevised for Version 5.3 (Release 2009a)
September 2009 Online onlyRevised for Version 5.4 (Release 2009b)
March 2010Online onlyRevised for Version 5.5 (Release 2010a)
AUTOSAR Client-Server Communication ............4-2
viContents
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
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
%% Attach the function control object to the model
attachToModel(a,gcs)
Input and Output in
addArgConf commands
AlternativesYou 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 AlsoRTW.ModelSpecificCPrototype.attachToModel
“Controlling Generation of Function Prototypes” — Explains how to
configure model function prototypes in generated code
3-13
Page 44
cgv.CGV.addCallback
PurposeAdd callback function
SyntaxcgvObj.addCallback(CallbackFcn)
DescriptioncgvObj.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:
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
PurposeAdd checks
SyntaxaddCheck(obj, checkID)
DescriptionaddCheck(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.
ExamplesAdd the Identify questionable code instrumentation (data I/O)
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
PurposeAdd table entry to collection of table entries registered in TFL table
SyntaxaddEntry(hTable, entry)
ArgumentshTable
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
DescriptionThe addEntry function adds a function or operator entry that you have
constructed to the collectio n of table entries registered in a TFL table.
ExampleIn 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
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
PurposeAdd parameters
SyntaxaddParam(obj, paramName, value)
DescriptionaddParam(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 againstcode 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.
ExamplesAdd Inlineparameters to the objective, and specify the parameter
value as
on.
addParam(obj, 'InlineParams', 'on');
See Alsoget_param
How To• “Creating Custom Objectives”
• “Parameter Command-Line Information Summary”
3-25
Page 56
cgv.CGV.addPostLoadFiles
PurposeAdd files required by model
SyntaxcgvObj.addPostLoadfiles({FileList})
DescriptioncgvObj.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
PurposeControl import of AUTOSAR components
DescriptionYou 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.
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
PurposeAttach model-specific C++ encapsulation interface to loaded ERT-based
Simulink model
SyntaxattachToModel(obj, modelName)
DescriptionattachToModel(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 =
AlternativesThe 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
PurposeAttach model-specific C function prototype to loaded ERT-based
Simulink model
SyntaxattachToModel(obj, modelName)
DescriptionattachToModel(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.
AlternativesClick 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
PurposeVerify numerical equivalence of results
DescriptionExecutes 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.
ConstructioncgvObj = 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
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
PropertiesComponentType
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'
addCallbackAdd callback function
addConfigSetAdd configuration set
addInputData
addPostLoadFiles
compare
createToleranceFile
getOutputDataGet output data
getSavedSignalsDisplay 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
setOutputDirSpecify folder
setOutputFileSpecify 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
ExamplesThe 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 Alsocgv.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
PurposeCheck and modify model configuration parameter values
DescriptionCreates 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,
ConstructioncfgObj = 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
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.
PropertiesComponentType
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.
ExamplesConfigure 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.
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,
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:
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
PurposeDetermine and change configuration parameter values
SyntaxcfgObj.configModel()
DescriptioncfgObj.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
PurposeCopy conceptual argument specifications to matching implementation
arguments for TFL table entry
SyntaxcopyConceptualArgsToImplementation(hEntry)
ArgumentshEntry
Handle to a TFL table entry previously returned by instantiating
a TF L entry class, such as
hEntry = RTW.TflCOperationEntry.
DescriptionThe 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.
ExampleIn 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
PurposeCreate conceptual argument from specified properties and add to
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'.
ReturnsHandle to the created conceptual argument. Specifying the return
argument in the
createAndAddConceptualArg function call is optional.
DescriptionThe createAndAddConceptualArg function creates a conceptual
argument from specified properties and adds the argument to the
conceptual arguments for a TFL table entry.
ExamplesIn the following example, thecreateAndAddConceptualArg function
is used to specify conceptual output and input arguments for a TFL
operator entry.
'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
PurposeCreate implementation argument from specified properties and add to
implementation arguments for TFL table entry
Syntaxarg = createAndAddImplementationArg(hEntry, argTyp e,
varargin)
ArgumentshEntry
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
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.
ReturnsHandle to the created implementation argument. Specifying the return
argument in the
optional.
3-62
createAndAddImplementationArg function call is
Page 93
createAndAddImplementationArg
DescriptionThe 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).
ExampleIn the following example, thecreateAndAddImplementationArg
function is used along with the createAndSetCImplementationReturn
function to specify the output and input arguments for an operator
implementation.