MATLAB REAL-TIME WORKSHOP EMBEDDED CODER 5 Reference

Specifications

Brand: MATLAB
Category: Other
Model: REAL-TIME WORKSHOP EMBEDDED CODER 5 (Reference)
File Type: PDF
File Size: —
Pages: 500

Read Online

Read the MATLAB REAL-TIME WORKSHOP EMBEDDED CODER 5 Reference online using the built-in PDF viewer.

Text of the manual

How to Contact The MathWorks

www.mathworks.com Web comp.soft-sys.matlab Newsgroup www.mathworks.com/contact_TS.html Technical Support [email protected] Product enhancement suggestions [email protected] Bug reports [email protected] Documentation error reports [email protected] Order status, license renewals, passcodes [email protected] Sales, pricing, 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® Embedded Coder™ Reference © COPYRIGHT 2006–2010 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 MathWorks, 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 the use, modification, reproduction, release, performance, display, and disclosure of the Program and 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 Documentation, 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.

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)

AUTOSAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-2 AUTOSAR Component Import . . . . . . . . . . . . . . . . . . . . . . . 1-2 AUTOSAR Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 C++ Encapsulation Interface Control . . . . . . . . . . . . . . . . 1-6 Code Generation Objectives Customization . . . . . . . . . . 1-8 Code Generation Verification . . . . . . . . . . . . . . . . . . . . . . . 1-9 Function Prototype Control . . . . . . . . . . . . . . . . . . . . . . . . 1-10 Model Entry Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-12 Processor-in-the-Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13 Connectivity Configuration . . . . . . . . . . . . . . . . . . . . . . . . . 1-13 Build . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13 Execution Download, Start and Stop . . . . . . . . . . . . . . . . . . 1-14 Host and Target Communications . . . . . . . . . . . . . . . . . . . . 1-14 Host-Side Communications . . . . . . . . . . . . . . . . . . . . . . . . . 1-14 Target-Side Communications . . . . . . . . . . . . . . . . . . . . . . . . 1-14 System Target File Callback Interface . . . . . . . . . . . . . . . 1-15 Target Function Library Table Creation . . . . . . . . . . . . . 1-16 v

AUTOSAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-1 AUTOSAR Component Import . . . . . . . . . . . . . . . . . . . . . . . 2-1 AUTOSAR Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1 C++ Encapsulation Interface Control . . . . . . . . . . . . . . . . 2-2 Code Generation Objectives Customization . . . . . . . . . . 2-2 Code Generation Verification . . . . . . . . . . . . . . . . . . . . . . . 2-2 Function Prototype Control . . . . . . . . . . . . . . . . . . . . . . . . 2-2 Alphabetical List 3 Block Reference 4 AUTOSAR Client-Server Communication . . . . . . . . . . . . 4-2 Configuration Wizards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3 Module Packaging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4 vi Contents

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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4 Enable portable word sizes . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5 Create SIL block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-7 Code coverage tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-9 Real-Time Workshop Pane: Code Style . . . . . . . . . . . . . . 6-10 Real-Time Workshop: Code Style Tab Overview . . . . . . . . 6-12 Parentheses level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-13 Preserve operand order in expression . . . . . . . . . . . . . . . . . 6-15 Preserve condition expression in if statement . . . . . . . . . . . 6-16 Convert if-elseif-else patterns to switch-case statements . . 6-18 Preserve extern keyword in function declarations . . . . . . . 6-20 Real-Time Workshop Pane: Templates . . . . . . . . . . . . . . . 6-22 Real-Time Workshop: Templates Tab Overview . . . . . . . . . 6-24 Code templates: Source file (*.c) template . . . . . . . . . . . . . . 6-25 Code templates: Header file (*.h) template . . . . . . . . . . . . . 6-26 Data templates: Source file (*.c) template . . . . . . . . . . . . . . 6-27 Data templates: Header file (*.h) template . . . . . . . . . . . . . 6-28 File customization template . . . . . . . . . . . . . . . . . . . . . . . . . 6-29 Generate an example main program . . . . . . . . . . . . . . . . . . 6-30 Target operating system . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-32 Real-Time Workshop Pane: Code Placement . . . . . . . . . 6-34 Real-Time Workshop: Code Placement Tab Overview . . . . 6-36 Data definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-37 Data definition filename . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-39 Data declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-41 Data declaration filename . . . . . . . . . . . . . . . . . . . . . . . . . . 6-43 #include file delimiter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-44 Module naming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-45 vii

Module name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6-47 Signal display level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-49 Parameter tune level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-51 File packaging format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-53 Real-Time Workshop Pane: Data Type Replacement . . 6-56 Real-Time Workshop: Data Type Replacement Tab Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-58 Replace data type names in the generated code . . . . . . . . . 6-59 Replacement Name: double . . . . . . . . . . . . . . . . . . . . . . . . . 6-61 Replacement Name: single . . . . . . . . . . . . . . . . . . . . . . . . . . 6-63 Replacement Name: int32 . . . . . . . . . . . . . . . . . . . . . . . . . . 6-65 Replacement Name: int16 . . . . . . . . . . . . . . . . . . . . . . . . . . 6-67 Replacement Name: int8 . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-69 Replacement Name: uint32 . . . . . . . . . . . . . . . . . . . . . . . . . 6-71 Replacement Name: uint16 . . . . . . . . . . . . . . . . . . . . . . . . . 6-73 Replacement Name: uint8 . . . . . . . . . . . . . . . . . . . . . . . . . . 6-75 Replacement Name: boolean . . . . . . . . . . . . . . . . . . . . . . . . 6-77 Replacement Name: int . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-79 Replacement Name: uint . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-81 Replacement Name: char . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-83 Real-Time Workshop Pane: Memory Sections . . . . . . . . 6-85 Real-Time Workshop: Memory Sections Tab Overview . . . 6-87 Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-88 Refresh package list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-90 Initialize/Terminate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-91 Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-92 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-93 Inputs/Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-95 Internal data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-97 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-99 Validation results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-101 Real-Time Workshop Pane: AUTOSAR Code Generation Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-102 Real-Time Workshop: AUTOSAR Code Generation Options Tab Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-104 Generate XML file from schema version . . . . . . . . . . . . . . . 6-105 Use AUTOSAR compiler abstraction macros . . . . . . . . . . . 6-105 Configure AUTOSAR Interface . . . . . . . . . . . . . . . . . . . . . . 6-107 viii Contents

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-108

Recommended Settings Summary . . . . . . . . . . . . . . . . . . . . 6-108 Parameter Command-Line Information Summary . . . . . . . 6-120 Index ix

AUTOSAR (p. 1-2)

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

1 Function Reference

AUTOSAR AUTOSAR Component Import (p. 1-2) Control import of AUTOSAR components AUTOSAR Configuration (p. 1-3) Control and validate AUTOSAR configuration AUTOSAR Component Import arxml.importer Construct arxml.importer object createCalibrationComponentObjects (arxml.importer) Create Simulink calibration objects from AUTOSAR calibration component createComponentAsModel (arxml.importer) Create AUTOSAR atomic software component as Simulink model createComponentAsSubsystem (arxml.importer) Create AUTOSAR atomic software component as Simulink atomic subsystem createOperationAsConfigurableSubsystems (arxml.importer) Create configurable Simulink subsystem library for client-server operation getCalibrationComponentNames (arxml.importer) Get calibration component names getComponentNames (arxml.importer) Get atomic software component names getDependencies (arxml.importer) Get list of XML dependency files getFile (arxml.importer) Return XML file name for arxml.importer object setDependencies (arxml.importer) Set XML file dependencies setFile (arxml.importer) Set XML file name for arxml.importer object 1-2

Add AUTOSAR I/O configuration to

model attachToModel (RTW.AutosarInterface) Attach RTW.AutosarInterface object to model getComponentName (RTW.AutosarInterface) Get XML component name getDataTypePackageName (RTW.AutosarInterface) Get XML data type package name getDefaultConf (RTW.AutosarInterface) Get default configuration getExecutionPeriod (RTW.AutosarInterface) Get runnable execution period getImplementationName (RTW.AutosarInterface) Get XML implementation name getInitEventName (RTW.AutosarInterface) Get initial event name getInitRunnableName (RTW.AutosarInterface) Get initial runnable name getInterfacePackageName (RTW.AutosarInterface) Get XML interface package name getInternalBehaviorName (RTW.AutosarInterface) Get XML internal behavior name getIOAutosarPortName (RTW.AutosarInterface) Get I/O AUTOSAR port name getIODataAccessMode (RTW.AutosarInterface) Get I/O data access mode getIODataElement (RTW.AutosarInterface) Get I/O data element name getIOErrorStatusReceiver (RTW.AutosarInterface) Get receiver port name 1-3

1 Function Reference

getIOInterfaceName (RTW.AutosarInterface) Get I/O interface name getIOPortNumber (RTW.AutosarInterface) Get I/O AUTOSAR port number getIOServiceInterface (RTW.AutosarInterface) Get port I/O service interface getIOServiceName (RTW.AutosarInterface) Get port I/O service name getIOServiceOperation (RTW.AutosarInterface) Get port I/O service operation getIsServerOperation (RTW.AutosarInterface) Determine whether server is specified getPeriodicEventName (RTW.AutosarInterface) Get periodic event name getPeriodicRunnableName (RTW.AutosarInterface) Get periodic runnable name getPortDefaultConf (RTW.AutosarInterface) Get port default configuration getServerInterfaceName (RTW.AutosarInterface) Get name of server interface getServerOperationPrototype (RTW.AutosarInterface) Get server operation prototype getServerPortName (RTW.AutosarInterface) Get server port name getServerType (RTW.AutosarInterface) Determine server type RTW.AutosarInterface Construct RTW.AutosarInterface object runValidation (RTW.AutosarInterface) Validate RTW.AutosarInterface object against model setComponentName (RTW.AutosarInterface) Set XML component name 1-4

Set initial event name

setInitRunnableName (RTW.AutosarInterface) Set initial runnable name setIOAutosarPortName (RTW.AutosarInterface) Set AUTOSAR port name setIODataAccessMode (RTW.AutosarInterface) Set I/O data access mode setIODataElement (RTW.AutosarInterface) Set I/O data element setIOInterfaceName (RTW.AutosarInterface) Set I/O interface name setIsServerOperation (RTW.AutosarInterface) Indicate that server is specified setPeriodicEventName (RTW.AutosarInterface) Set periodic event name setPeriodicRunnableName (RTW.AutosarInterface) Set periodic runnable name setServerInterfaceName (RTW.AutosarInterface) Set name of server interface setServerOperationPrototype (RTW.AutosarInterface) Specify operation prototype setServerPortName (RTW.AutosarInterface) Set server port name setServerType (RTW.AutosarInterface) Specify server type syncWithModel (RTW.AutosarInterface) Synchronize configuration with model 1-5

1 Function Reference

C++ Encapsulation Interface Control attachToModel (RTW.ModelCPPClass) Attach model-specific C++ encapsulation interface to loaded ERT-based Simulink model getArgCategory (RTW.ModelCPPArgsClass) Get argument category for Simulink model port from model-specific C++ encapsulation interface getArgName (RTW.ModelCPPArgsClass) Get argument name for Simulink model port from model-specific C++ encapsulation interface getArgPosition (RTW.ModelCPPArgsClass) Get argument position for Simulink model port from model-specific C++ encapsulation interface getArgQualifier (RTW.ModelCPPArgsClass) Get argument type qualifier for Simulink model port from model-specific C++ encapsulation interface getClassName (RTW.ModelCPPClass) Get class name from model-specific C++ encapsulation interface getDefaultConf (RTW.ModelCPPClass) Get default configuration information for model-specific C++ encapsulation interface from Simulink model getNumArgs (RTW.ModelCPPClass) Get number of step method arguments from model-specific C++ encapsulation interface getStepMethodName (RTW.ModelCPPClass) Get step method name from model-specific C++ encapsulation interface RTW.configSubsystemBuild Configure C function prototype or C++ encapsulation interface for right-click build of specified subsystem 1-6

C++ Encapsulation Interface Control

RTW.getEncapsulationInterfaceSpecification Get handle to model-specific C++ 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) Validate model-specific C++ encapsulation interface against Simulink model runValidation (RTW.ModelCPPVoidClass) Validate model-specific C++ encapsulation interface against Simulink model setArgCategory (RTW.ModelCPPArgsClass) Set argument category for Simulink model port in model-specific C++ encapsulation interface setArgName (RTW.ModelCPPArgsClass) Set argument name for Simulink model port in model-specific C++ encapsulation interface setArgPosition (RTW.ModelCPPArgsClass) Set argument position for Simulink model port in model-specific C++ encapsulation interface setArgQualifier (RTW.ModelCPPArgsClass) Set argument type qualifier for Simulink model port in model-specific C++ encapsulation interface setClassName (RTW.ModelCPPClass) Set class name in model-specific C++ encapsulation interface setStepMethodName (RTW.ModelCPPClass) Set step method name in model-specific C++ encapsulation interface 1-7

1 Function Reference

Code Generation Objectives Customization addCheck (rtw.codegenObjectives.Objective) Add checks addParam (rtw.codegenObjectives.Objective) Add parameters excludeCheck (rtw.codegenObjectives.Objective) Exclude checks modifyInheritedParam (rtw.codegenObjectives.Objective) Modify inherited parameter values register (rtw.codegenObjectives.Objective) Register objective removeInheritedCheck (rtw.codegenObjectives.Objective) Remove inherited checks removeInheritedParam (rtw.codegenObjectives.Objective) Remove inherited parameters rtw.codegenObjectives.Objective Create custom code generation objectives setObjectiveName (rtw.codegenObjectives.Objective) Specify objective name 1-8

Code Generation Verification

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 parameter values createToleranceFile (cgv.CGV) Create file correlating tolerance information with signal names displayReport (cgv.Config) Display results of comparing configuration parameter values getOutputData (cgv.CGV) Get output data getReportData (cgv.Config) Return results of comparing 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

1 Function Reference

Function Prototype Control addArgConf (RTW.ModelSpecificCPrototype) Add argument configuration information for Simulink model port to model-specific C function prototype attachToModel (RTW.ModelSpecificCPrototype) Attach model-specific C function prototype to loaded ERT-based Simulink model getArgCategory (RTW.ModelSpecificCPrototype) Get argument category for Simulink model port from model-specific C function prototype getArgName (RTW.ModelSpecificCPrototype) Get argument name for Simulink model port from model-specific C function prototype getArgPosition (RTW.ModelSpecificCPrototype) Get argument position for Simulink model port from model-specific C function prototype getArgQualifier (RTW.ModelSpecificCPrototype) Get argument type qualifier for Simulink model port from model-specific C function prototype getDefaultConf (RTW.ModelSpecificCPrototype) Get default configuration information for model-specific C function prototype from Simulink model getFunctionName (RTW.ModelSpecificCPrototype) Get function name from model-specific C function prototype getNumArgs (RTW.ModelSpecificCPrototype) Get number of function arguments from model-specific C function prototype getPreview (RTW.ModelSpecificCPrototype) Get model-specific C function prototype code preview 1-10

Function Prototype Control

RTW.configSubsystemBuild Configure C function prototype or C++ encapsulation interface for right-click build 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) Validate model-specific C function prototype against Simulink model setArgCategory (RTW.ModelSpecificCPrototype) Set argument category for Simulink model port in model-specific C function prototype setArgName (RTW.ModelSpecificCPrototype) Set argument name for Simulink model port in model-specific C function prototype setArgPosition (RTW.ModelSpecificCPrototype) Set argument position for Simulink model port in model-specific C function prototype setArgQualifier (RTW.ModelSpecificCPrototype) Set argument type qualifier for Simulink model port in model-specific C function prototype setFunctionName (RTW.ModelSpecificCPrototype) Set function name in model-specific C function prototype 1-11

1 Function Reference

Model Entry Points model_initialize Initialization entry point in generated code for ERT-based Simulink model model_SetEventsForThisBaseStep Set event flags for multirate, multitasking operation before calling model_step for ERT-based Simulink model — not generated as of Version 5.1 (R2008a) model_step Step routine entry point in generated code for ERT-based Simulink model model_terminate Termination entry point in generated code for ERT-based Simulink model 1-12

Connectivity Configuration (p. 1-13)

Define processor-in-the-loop (PIL) configuration Build (p. 1-13) Configure PIL build process Execution Download, Start and Stop (p. 1-14) Control downloading, starting and resetting PIL executable on target hardware Host and Target Communications (p. 1-14) Configure host-target communications Host-Side Communications (p. 1-14) Configure host-side communications channel and drivers Target-Side Communications (p. 1-14) Configure target-side communications channel and drivers Connectivity Configuration rtw.connectivity.ComponentArgs Provide parameters to each target connectivity component rtw.connectivity.Config Define connectivity implementation, comprising builder, launcher, and communicator components rtw.connectivity.ConfigRegistry Register connectivity configuration Build rtw.connectivity.MakefileBuilder Configure makefile-based build process 1-13

1 Function Reference

Execution Download, Start and Stop rtw.connectivity.Launcher Control downloading, starting and resetting executable on target hardware Host and Target Communications rtIOStreamClose Shut down communications channel with remote processor rtIOStreamOpen Initialize communications channel with remote processor rtIOStreamRecv Receive data from remote processor rtIOStreamSend Send data to remote processor Host-Side Communications rtiostream_wrapper Test rtiostream shared library methods rtw.connectivity.RtIOStreamHost- Communicator Configure host-side communications Target-Side Communications rtw.pil.RtIOStreamApplication- Framework Configure target-side communications 1-14

System Target File Callback Interface

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

1 Function Reference

Target Function Library Table Creation addAdditionalHeaderFile Add additional header file to array of additional header files for TFL table entry addAdditionalIncludePath Add additional include path to array of additional include paths for TFL table entry addAdditionalLinkObj Add additional link object to array of additional link objects for TFL table entry addAdditionalLinkObjPath Add additional link object path to array of additional link object paths for TFL table entry addAdditionalSourceFile Add additional source file to array of additional source files for TFL table entry 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 Add table entry to collection of table entries registered in TFL table copyConceptualArgsToImplementationCopy conceptual argument specifications to matching implementation arguments for TFL table entry createAndAddConceptualArg Create conceptual argument from specified properties and add to conceptual arguments for TFL table entry 1-16

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 parameters 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 identifiers to be associated with TFL table setTflCFunctionEntryParameters Set specified parameters for function entry in TFL table setTflCOperationEntryParameters Set specified parameters for operator entry in TFL table 1-17

• “AUTOSAR” on page 2-1

• “C++ Encapsulation Interface Control” on page 2-2 • “Code Generation Objectives Customization” on page 2-2 • “Code Generation Verification” on page 2-2 • “Function Prototype Control” on page 2-2 AUTOSAR In this section... “AUTOSAR Component Import” on page 2-1 “AUTOSAR Configuration” on page 2-1 AUTOSAR Component Import arxml.importer Control import of AUTOSAR components AUTOSAR Configuration RTW.AutosarInterface Control and validate AUTOSAR configuration

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 void-void style step method Code Generation Objectives Customization rtw.codegenObjectives.Objective Customize code generation objectives Code Generation Verification cgv.CGV Verify numerical equivalence of results cgv.Config Check and modify model configuration parameter values Function Prototype Control RTW.ModelSpecificCPrototype Describe signatures of functions for model 2-2

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 TFL entry class, such as hEntry = RTW.TflCFunctionEntry or 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, and addAdditionalSourcePath to fully specify additional header and source files for a TFL table entry. % 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

“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-3

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 TFL entry class, such as hEntry = RTW.TflCFunctionEntry or 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, and addAdditionalSourcePath to fully specify additional header and source files for a TFL table entry. % 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

“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

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 TFL entry class, such as hEntry = RTW.TflCFunctionEntry or 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 addAdditionalLinkObjPath to fully specify an additional link object file for a TFL table entry. % 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

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 TFL entry class, such as hEntry = RTW.TflCFunctionEntry or 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 addAdditionalLinkObj to fully specify an additional link object file for a TFL table entry. % 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

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 TFL entry class, such as hEntry = RTW.TflCFunctionEntry or 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, and addAdditionalSourcePath to fully specify additional header and source files for a TFL table entry. % 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

“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

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 TFL entry class, such as hEntry = RTW.TflCFunctionEntry or 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, and addAdditionalSourceFile to fully specify additional header and source files for a TFL table entry. % 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

“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

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, qualifier) 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 ('Value' or 'Pointer'), the argument name, and the argument type qualifier (for example, 'const'). The order of addArgConf calls determines the argument position for the port in the function prototype, unless you change the order by other means, such as the RTW.ModelSpecificCPrototype.setArgPosition 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. Input Arguments obj Handle to a model-specific C prototype function control object previously returned by obj = RTW.ModelSpecificCPrototype or obj = RTW.getFunctionSpecification(modelName). portName String specifying the unqualified name of an inport or outport in your Simulink model. category String specifying the argument category, either 'Value' or 'Pointer'. argName String specifying a valid C identifier. qualifier String specifying the argument type qualifier: 'none', 'const', 'const *', or 'const * const'. 3-12

In the following example, you use the addArgConf method to add

argument configuration information for ports Input and Output in 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 addArgConf commands 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) Alternatives You can specify the argument configuration 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

Add callback function

Syntax cgvObj.addCallback(CallbackFcn) Description cgvObj.addCallback(CallbackFcn) is an optional method that adds a callback function to the object. cgvObj is a handle to a cgv.CGV object. Before executing the model, for each input data, the object loads the input data (that you added using addInputData) and then calls the callback function. The declaration of the callback function must receive the following parameters: CallbackFcn(InputIndex, model_name, componentType, connectivity) model_name, componentType, connectivity are identical to the arguments that you specified in the cgvObj constructor. InputIndex is the index of the input data that the callback function executes. You can specify only one callback for each object. How To • “Verifying Numerical Equivalence of Results with Code Generation Verification API” • “Using Callback Functions” 3-14

addCheck(obj, checkID) includes the check, checkID, in the Code

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 Handle to a code generation objective object previously created. checkID Unique identifier of the check that you add to the new 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” • “About IDs” 3-15

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 TFL entry class, such as hEntry = RTW.TflCFunctionEntry or hEntry = RTW.TflCOperationEntry. arg Argument, such as returned by arg = getTflArgFromString(name, datatype), to be added to the 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. 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'; 3-16

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 3-17

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 is a handle to a cgv.CGV 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. configSetName is a string that 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 the name of the file that contains only one configuration set. cgvObj.addConfigSet('file','configSetFileName','variable', 'configSetName') is an optional method that adds the configuration 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 run method. You can add only one configuration set for each cgv.CGV object. How To • “Verifying Numerical Equivalence of Results with Code Generation Verification API” • “Managing Configuration Sets” 3-18

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 hEntry = RTW.TflCFunctionEntry or hEntry = RTW.TflCOperationEntry Description The addEntry function adds a function or operator entry that you have constructed to the collection 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. 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

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

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. cgvObj is a handle to a cgv.CGV object. InputIndex is a unique numeric identifier to input data. The input data is used when the model executes. DataFileName is the name of the input file, with or without the .mat extension. If the input file is in the working folder, the cgvObj does not require the path. The cgvObj uses the InputIndex to identify the input data associated with output data and output data files. cgvObj passes InputIndex to a 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, DataFileName. • 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. • If you omit calling addInputData before executing the model, Code Generation Verification runs once using data in the base workspace. How To • “Verifying Numerical Equivalence of Results with Code Generation Verification API” 3-21

Add AUTOSAR I/O configuration to model

Syntax autosarInterfaceObj.addIOConf(SimulinkPort, DataAccessMode, 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 addIOConf: autosarInterfaceObj.addIOConf(SimulinkPort, DataAccessMode, autosarPort, InterfaceName, DataElement) autosarInterfaceObj.addIOConf(SimulinkErrorStatusPort, 'ErrorStatus', CorrespondingSimulinkReceiverPort) autosarInterfaceObj.addIOConf(SimulinkBasicSoftwarePort, 'BasicSoftwarePort', ServiceName, ServiceOperation, ServiceInterfacePath) Each call adds an AUTOSAR I/O configuration to autosarInterfaceObj, a model-specific RTW.AutosarInterface object. Input Arguments SimulinkPort 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: 3-22

data is buffered by the

run-time environment (RTE), or 'Explicit...' where data is not buffered and hence not deterministic. autosarPort AUTOSAR port name (string) InterfaceName Interface name (string) DataElement Data element name (string) SimulinkErrorStatusPort The port you choose to receive error status. 'ErrorStatus' The data access mode for ports chosen to be error status receivers. CorrespondingSimulinkReceiverPort The port that is listened to for error status. The data access mode for this port must be either 'ImplicitReceive' or 'ExplicitReceive'. 3-23

The port that you specify

as an access point to AUTOSAR Basic Software. 'BasicSoftwarePort' The data access mode for ports chosen to be access points to AUTOSAR Basic Software. ServiceName The service name you specify. Must be a valid AUTOSAR identifier. ServiceOperation The service operation you specify. Must be a valid AUTOSAR identifier. ServiceInterfacePath 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 Software and Error Status Receivers” in the Real-Time Workshop Embedded Coder documentation 3-24

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 Handle to a code generation objective object previously created. paramName Parameter that you add to the objective. value 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

Add files required by model

Syntax cgvObj.addPostLoadfiles({FileList}) Description cgvObj.addPostLoadfiles({FileList}) is an optional method that adds MATLAB® and MAT-files to the object. cgvObj is a handle to a cgv.CGV object. cgvObj executes and loads the files after opening the model and before running tests. FileList is a cell array of names of MATLAB and MAT-files in the testing directory that the model requires to run. How To • “Verifying Numerical Equivalence of Results with Code Generation Verification API” • “Using Callback Functions” 3-26

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 Informatik Gmbh), and import the component into a Simulink model for subsequent configuration, code generation, and export to XML. Construction arxml.importer Construct arxml.importer object Methods createCalibrationComponentObjectsCreate Simulink calibration objects from AUTOSAR calibration component createComponentAsModel Create AUTOSAR atomic software component as Simulink model createComponentAsSubsystem Create AUTOSAR atomic software component as Simulink atomic subsystem createOperationAsConfigurableSubsystems Create configurable Simulink subsystem library for client-server operation getCalibrationComponentNames Get calibration component names getComponentNames Get atomic software component names getDependencies Get list of XML dependency files getFile Return XML file name for arxml.importer object 3-27

Set XML file dependencies

setFile Set XML file name for arxml.importer object Copy Semantics Handle. To learn how this affects your use of the class, see Copying Objects in the MATLAB Programming Fundamentals documentation. See Also Importing an AUTOSAR Software Component in the Real-Time Workshop Embedded Coder documentation 3-28

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 filename. Note Only the atomic software components described in this XML file can be imported. Input Arguments filename XML file containing description of atomic software component. Output Arguments importer_obj Handle to newly createdarxml.importer object. See Also “Importing an AUTOSAR Software Component” in the Real-Time Workshop Embedded Coder documentation 3-29

Attach RTW.AutosarInterface object to model

Syntax autosarInterfaceObj.attachToModel(modelName) Description autosarInterfaceObj.attachToModel(modelName) attaches autosarInterfaceObj, an RTW.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 the Real-Time Workshop Embedded Coder documentation 3-30

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-based Simulink model. Input Arguments obj Handle to a model-specific C++ encapsulation interface control object, such as a handle previously returned by obj = RTW.ModelCPPArgsClass or obj = RTW.ModelCPPVoidClass. modelName String specifying the name of a loaded ERT-based Simulink model to which the object is going to be attached. Alternatives The Configure C++ Encapsulation Interface button on the 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 and Configuring C++ 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

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 Handle to a model-specific C prototype function control object previously returned by obj = RTW.ModelSpecificCPrototype. modelName String specifying the name of a loaded ERT-based Simulink model to which the object is going to be attached. Alternatives Click the Configure Model Functions button on the Configuration Parameters > Real-Time Workshop > Interface 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

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 cgv.CGV class methods, you can create a script to verify that the model and the Real-Time Workshop Embedded Coder generated code produce numerically equivalent 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 mode, any reference models set to PIL mode will be changed to Accelerator mode. Construction cgvObj = cgv.CGV('model_name') creates a handle to a code generation verification object using the default properties. model_name 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. Properties ComponentType Define the SIL or PIL approach If mode of execution is simulation (connectivity is sim), choosing either value for ComponentType has no effect on simulation results. However, cgv.CGV recommends configuration parameter values based on the value of ComponentType. 3-33

Top-model SIL or PIL

simulation and standalone code interface mode. 'modelblock' Model block SIL or PIL simulation and model reference Real-Time Workshop target code interface mode. connectivity Specify mode of execution Value Description 'sim' (default) Mode of execution is Normal simulation. Recommends changes to a proper subset of the configuration parameters that all PIL targets require. 'sil' Mode of execution is SIL. Recommends changes to the configuration parameters that SIL targets require. 'tasking' Mode of execution 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

Mode of execution 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. LogMode Specify how to save signal data Value Description 'SignalLogging' (default) 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 > Signal logging parameter. In the Signal logging name field, define the variable name. 'SaveOutput' 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

name field, define the variable

name. When you use the Output parameter to save signal data, Simulink does not save bus outputs. processor Defines the processor type. Use processor only when the value of connectivity is tasking. Value Description 'ARM' ARM® processor 'TriCore' Infineon® TriCore® processor 'C166' Infineon® C166® processor '8051' Intel® 8051 processor 'M16C' Renesas® M16C processor 'DSP563xx' Freescale™ DSP566xx processor SaveModel Specify whether to save the model 3-36

CGV checks the model

configuration for compatibility with the connectivity target using cgv.Config. Does not save the model. 'on' CGV updates and saves the model with required changes determined by cgv.Config. Saves the model in the working folder. ConfigModel Specify whether to disable configuration checks Value Description 'on' (default) CGV checks the model configuration for compatibility with the connectivity target using cgv.Config. 'off' Disable all use of cgv.Config on the model. Only specify 'off' if you are sure the model is compatible. CheckInterface Specify whether to verify the model outports 3-37

CGV checks the model outports

for compatibility with CGV. CGV compiles the model first. 'off' Disable verification of model outports. Only specify 'off' if you are sure the model outports are compatible with CGV. Methods addCallback Add callback function addConfigSet Add configuration set addInputData Add input data addPostLoadFiles Add files required by model compare Compare signal data createToleranceFile Create file correlating tolerance information with signal names getOutputData Get output data getSavedSignals Display list of signal names to command line plot Create plot for signal or multiple signals run Execute CGV object setOutputDir Specify folder setOutputFile Specify output data file name Copy Semantics Handle. To learn how handle classes affect copy operations, see Copying Objects in the MATLAB Programming Fundamentals documentation. 3-38

The general workflow for testing a model for numerical equivalence

using the cgv.CGV class is to: 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: • addCallBack • 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: • 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

• “Verifying Code Using the SIL Simulation Mode”

• “Verifying Compiled Object Code with Processor-in-the-Loop Simulation” 3-40

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 parameter values or the model. By default, cgv.Config modifies configuration parameter values to the value that it recommends, but does not save the model. Alternatively, you can specify that cgv.Config use one of the following approaches: • Modify configuration parameter values to the values that cgv.Config recommends, and save the model. Specify this approach using the SaveModel property. • List the values that cgv.Config recommends for the configuration parameters, but do not modify the configuration parameters or the model. Specify this approach using the ReportOnly property. Do not use referenced configuration sets in models that you are modifying using cgv.Config. If the model uses a referenced configuration set, update the model with a copy of the configuration set. Use the Simulink.ConfigSetRef.getRefConfigSet method. For more information, see Simulink.ConfigSetRef in the Simulink documentation. If you use cgv.Config on a model that executes a callback function, the callback function might modify configuration parameter values each time the model 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”. Construction cfgObj = cgv.Config('model_name') creates a handle to a cgv.Config object, cfgObj, using default values for properties. 3-41

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 (connectivity is sim), choosing either value for ComponentType has no effect on simulation results. However, cgv.Config recommends configuration parameter values based on the value of ComponentType. Value Description 'topmodel' (default) Top-model SIL or PIL simulation and standalone code interface mode. 'modelblock' Model block SIL or PIL simulation and model reference Real-Time Workshop target code interface mode. connectivity Specify mode of execution 3-42

Mode of execution is

simulation. Recommends changes to a proper subset of the configuration parameters that all PIL targets require. 'sil' Mode of execution is SIL. Requires that the system target file is set to 'ert.tlc' and that you do not use your own external target. Recommends changes to the configuration parameters that SIL targets require. 'tasking' Mode of execution 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. 'custom' Mode of execution 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. LogMode 3-43

Specify how to save signal data

Value Description 'SignalLogging' (default) 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 > Signal logging parameter . In the Signal logging name field, define the variable name. 'SaveOutput' 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. When you use the Output parameter to save signal data, Simulink does not save bus outputs. processor Defines the processor type Use processor only when the value of connectivity is tasking. 3-44

Infineon TriCore processor

'C166' Infineon C166 processor '8051' Intel 8051 processor 'M16C' Renesas M16C processor 'DSP563xx' Freescale DSP566xx processor ReportOnly Specify whether to create a report Specify whether to create a report of the values that cgv.Config recommends for the configuration parameters, without modifying the configuration parameters or the model. If you set ReportOnly to 'on', SaveModel must be 'off'. Value Description 'off' (default) Do not create a report. 'on' Create a report. SaveModel Specify whether to save the model Specify whether to modify configuration parameter values to the values that cgv.Config recommends, and save the model. If you set SaveModel to 'on', ReportOnly must be 'off'. Value Description 'off' (default) Do not save the model. 'on' Save the model in the working folder. 3-45

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

Compare signal data

Syntax [matchNames, matchFigures, mismatchNames, mismatchFigures] = cgv.CGV.compare(data_set1, data_set2) [matchNames, matchFigures, mismatchNames, mismatchFigures] = cgv.CGV.compare(data_set1, data_set2, 'Plot', 'param_value') [matchNames, matchFigures, mismatchNames, mismatchFigures] = cgv.CGV.compare(data_set1, data_set2, 'Plot', 'none', 'Signals', signal_list, 'ToleranceFile', 'file_name.mat') Description [matchNames, matchFigures, mismatchNames, mismatchFigures] = cgv.CGV.compare(data_set1, data_set2) compares data from two data sets which have common signal names between both executions. Possible outputs of the cgv.CGV.compare function are matched signal names, figure handles to the matched signal names, mismatched signal names, and figure handles to the mismatched signal names. By default, cgv.CGV.compare looks at all signals which have a common name between both executions. [matchNames, matchFigures, mismatchNames, mismatchFigures] = cgv.CGV.compare(data_set1, data_set2, 'Plot', 'param_value') compares all signals and plots the signals according to param_value. [matchNames, matchFigures, mismatchNames, mismatchFigures] = cgv.CGV.compare(data_set1, data_set2, 'Plot', 'none', 'Signals', signal_list, 'ToleranceFile', 'file_name.mat') compares only the given signals and produces no plots. Input Arguments 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 of all output signal names. 3-47

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': do not produce a plot Signals(optional) A cell array of strings, where each string is a signal name in the dataset. Use cgv.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: 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 model 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: 3-48

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 cgv.CGV.createToleranceFile function. The file contains the signal names and the associated tolerance parameter name and value pair for comparing the data. 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

Determine and change configuration parameter values

Syntax cfgObj.configModel() Description cfgObj.configModel() determines the recommended values for the configuration parameters in the model. cfgObj is a handle to a cgv.Config object. The ReportOnly property of the object determines whether configModel reports or changes the configuration parameter values. Tutorials • “How To Verify a SIL or PIL Configuration” How To • “Configuring a PIL Simulation” • “Managing Configuration Sets” 3-50

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 TFL entry class, such as hEntry = RTW.TflCFunctionEntry or 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. 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

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

Create conceptual argument from specified properties and add to

conceptual arguments for TFL table entry Syntax arg = createAndAddConceptualArg(hEntry, argType, varargin) Arguments hEntry Handle to a TFL table entry previously returned by instantiating a TFL entry class, such as hEntry = RTW.TflCFunctionEntry or 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. varargin Parameters The following argument properties can be specified to the createAndAddConceptualArg function using parameter/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

Integer specifying the word length, in bits, of the argument. The

default is 16. 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 true. Specify true if you are matching a specific [slope bias] scaling combination or a specific binary-point-only scaling 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 true. Specify true if you are matching a specific [slope bias] scaling combination or a specific binary-point-only scaling 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 data 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

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. If you are matching a specific [slope bias] scaling combination on fixed-point operator inputs and output, specify either this parameter or a combination of the SlopeAdjustmentFactor and FixedExponent parameters SlopeAdjustmentFactor Floating-point value specifying the slope adjustment factor (F) part of the slope, F2E, of the argument. The default is 1.0. 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) part of the slope, F2E, 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. The default is 0.0. 3-55

Specify this parameter if you are matching a specific [slope bias]

scaling combination on fixed-point operator inputs and output. FractionLength Integer value specifying the fraction length for the argument, for example, 3. The default is 15. Specify this parameter if you 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, 'double'. 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 [Dim1Min Dim2Min ... DimNMin; Dim1Max Dim2Max ... DimNMax]. For example, [2 2; inf inf] means any two-dimensional matrix of size 2x2 or larger. 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

'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

createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ...

'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'DataTypeMode', 'double' ); % boolean: createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'DataTypeMode', 'boolean' ); % 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); % 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 3-58

Operator Entries for Relative Scaling (Multiplication and Division)” and

“Example: Creating Fixed-Point Operator Entries for Equal Slope 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

Create implementation argument from specified properties and add to

implementation arguments for TFL table entry Syntax arg = createAndAddImplementationArg(hEntry, argType, varargin) Arguments hEntry Handle to a TFL table entry previously returned by instantiating a TFL entry class, such as hEntry = RTW.TflCFunctionEntry or 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. varargin Parameters 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 true. WordLength Integer specifying the word length, in bits, of the argument. The default is 16. 3-60

String specifying the data 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 combination 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, F2E, of the argument. The default is 1.0. You can optionally specify either the Slope parameter or a combination of this parameter and the FixedExponent parameter, but do not specify both. FixedExponent Integer value specifying the fixed exponent (E) part of the slope, F2E, of the argument. The default is -15. 3-61

You can optionally specify either the Slope parameter or a

combination of this parameter and the SlopeAdjustmentFactor parameter, but do not specify both. Bias Floating-point value specifying the bias of the argument, for example, 2.0. The default is 0.0. FractionLength Integer value specifying the fraction length of the argument, for example, 3. The default is 15. 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 u1, u2, 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. 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 createAndAddImplementationArg function call is optional. 3-62

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 double, single, int32, int16, int8, uint32, uint16, uint8, or boolean (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', ... '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

'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', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'DataTypeMode', 'double' ); % boolean: createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'DataTypeMode', 'boolean' ); See Also createAndSetCImplementationReturn “Creating Function Replacement Tables” in the Real-Time Workshop Embedded Coder documentation 3-64

“Replacing Math Functions and Operators Using Target Function

Libraries” in the Real-Time Workshop Embedded Coder documentation 3-65

Create implementation return argument from specified properties and

add to implementation for TFL table entry Syntax arg = createAndSetCImplementationReturn(hEntry, argType, varargin) Arguments hEntry Handle to a TFL table entry previously returned by instantiating a TFL entry class, such as hEntry = RTW.TflCFunctionEntry or 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. varargin Parameters 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 true. WordLength Integer specifying the word length, in bits, of the argument. The default is 16. 3-66

String specifying the data 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 combination 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, F2E, of the argument. The default is 1.0. You can optionally specify either the Slope parameter or a combination of this parameter and the FixedExponent parameter, but do not specify both. FixedExponent Integer value specifying the fixed exponent (E) part of the slope, F2E, of the argument. The default is -15. 3-67

You can optionally specify either the Slope parameter or a

combination of this parameter and the SlopeAdjustmentFactor parameter, but do not specify both. Bias Floating-point value specifying the bias of the argument, for example, 2.0. The default is 0.0. FractionLength Integer value specifying the fraction length of the argument, for example, 3. The default is 15. Returns Handle to the created implementation return argument. Specifying the return argument in the createAndSetCImplementationReturn function call is optional. Description The createAndSetCImplementationReturn function creates an implementation return argument from specified properties and adds the argument to the implementation for a TFL table. Note Implementation return arguments must describe fundamental numeric data types, such as double, single, int32, int16, int8, uint32, uint16, uint8, or boolean (not fixed point data types). 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

'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

'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

Other Other Manuals