主要内容

setTflCOperationEntryParameters

Set specified parameters for operator entry in code replacement table

描述

example

setTflCOperationEntryParameters(hEntry,varargin)sets specified parameters for an operator entry in a code replacement table.

例子

collapse all

此示例显示了如何使用setTflCOperationEntryParametersfunction to set parameters for a code replacement operator entry foruint8addition that matches a cast-after-sum algorithm.

op_entry=环球套票。TflCOperationEntry; op_entry.setTflCOperationEntryParameters(。。。'Key','rtw_op_add',。。。'EntryInfoAlgorithm','rtw_cast_after_op',。。。'优先', 90,。。。'SaturationMode','rtw_saturate_unspecified',。。。“圆形模式”, {'rtw_round_unspecified'},,。。。'ImplementationName','U8_ADD_U8_U8',。。。'ImplementationHeaderFile','u8_add_u8_u8.h',。。。“实施程序”,'u8_add_u8_u8.c');

此示例显示了如何使用setTflCOperationEntryParametersfunction to set parameters for a code replacement operator entry for fixed-pointINT16division. The table entry specifies a net scaling between the operator inputs and output to map a range of slope and bias values to a replacement operation.

op_entry = rtw.tflcoperationEntrygenerator_netslope;op_entry.settflcoperationEntryParameters(。。。'Key','RTW_OP_DIV',。。。'优先', 90,。。。'SaturationMode','RTW_WRAP_ON_OVERFLOW',。。。“圆形模式”, {'RTW_ROUND_CEILING'},,。。。'NetSlopeAdjustmentFactor', 1.0,。。。“ netfixedepponent”,0.0,。。。'ImplementationName','s16_div_s16_s16',。。。'ImplementationHeaderFile','s16_div_s16_s16.h',。。。“实施程序”,'s16_div_s16_s16.c');

此示例显示了如何使用setTflCOperationEntryParametersfunction to set parameters for a code replacement operator entry for fixed-pointUINT16addition that matches a cast-after-sum algorithm. The parameters 'SlopesMustBeTheSame' and 'MustHaveZeroNetBias' must be set totrueto specify equal slope and zero net bias across operator inputs and output. This maps relative slope and bias values (rather than a specific slope and bias combination) to a replacement operation.

op_entry= rtw.tflcoperationentrygergenerator;op_entry.settflcoperationEntryParameters(。。。'Key','rtw_op_add',。。。'EntryInfoAlgorithm','rtw_cast_after_op',。。。'优先', 90,。。。'SaturationMode','RTW_WRAP_ON_OVERFLOW',。。。“圆形模式”, {'rtw_round_unspecified'},,。。。'SlopesMustBeTheSame', 真的,。。。“ musthavezeronetbias”, 真的,。。。'ImplementationName','u16_add_sameslopezerobias',。。。'ImplementationHeaderFile','u16_add_sameslopezerobias.h',。。。“实施程序”,'u16_add_SameSlopeZeroBias.c');

Input Arguments

collapse all

ThehEntryis a handle to a code replacement table entry previously returned by one of the class instantiations in the table.

Class Instantiation 金宝app

hEntry=环球套票。TflCOperationEntry;

Supports operator replacement.

hEntry= rtw.tflcoperationentrygergenerator;

为定点加法和减法提供参数rtw.tflcoperationentry(SlopesMustBeTheSameandmusthavezeronetbias).

hEntry=环球套票。TflCOperationEntryGenerator_NetSlope;

Provides net slope parameters for fixed-point multiplication and division that are not available inrtw.tflcoperationentry(NetSlopeAdjustmentFactorandNetFixedExponent).

hEntry=环球套票。TflBlasEntryGenerator;

Supports replacement of nonscalar operators with MathWorks BLAS functions.

hEntry= rtw.tflcblasentrygenerator;

金宝app支持用ANSI替换非施法运营商®/ISO®c Blas功能。

hEntry=MyCustomOperationEntry;

(在哪里MyCustomOperationEntry是从rtw.tflcoperationentry)

金宝app使用自定义代码替换表条目支持操作员替换。

如果要指定SlopesMustBeTheSameormusthavezeronetbias对于您的操作员条目,请使用hEntry=环球套票。TflCOperationEntryGeneratorrather thanhEntry=环球套票。TflCOperationEntry。If you want to useNetSlopeAdjustmentFactorandNetFixedExponent, instantiate your table entry by usinghEntry=环球套票。TflCOperationEntryGenerator_NetSlope

例子:op_entry

例子:'Key','RTW_OP_ADD'

Name-Value Pair Arguments

Specify optional comma-separated pairs ofName,Value参数。Nameis the argument name andValueis the corresponding value.Namemust appear inside quotes. You can specify several name and value pair arguments in any order asNAME1,Value1,...,Namen,Valuen

例子:'Key','RTW_OP_ADD'

TheAcceptExprInputvalue flags the code generator that the implementation function described by this entry accepts expression inputs. The default value istrueifsmand类型equalsFCN_IMPL_FUNCTandfalseifsmand类型equalsFCN_IMPL_MACRO

If the value istrue, expression inputs are integrated into the generated code in a form similar to this form:

rtY.Out1 = myAdd(rtU.In1, rtU.In2 * rtU.In3);

If the value isfalse, a temporary variable is generated for the expression input:

real_T temp; temp = rtU.In2 * rtU.In3; rtY.Out1 = myAdd(rtU.In1, temp);

例子:'AcceptExprInput',true

TheAdditionalHeaderFilesvalue specifies additional header files for a code replacement table entry. The character vectors or string array can include tokens. For example, in the token$ mytoken $,mytoken是将MATLAB中定义为字符向量或字符串标量的变量®workspace or as a MATLAB function in the search path that returns a character vector.

例子:'AdditionalHeaderFiles',{}

TheAdditionalIncludePathsvalue specifies the full path of additional include paths for a code replacement entry. The character vectors or string array can include tokens. For example, in the token$ mytoken $,mytoken是MATLAB工作区中的字符向量或字符串标量定义的变量,或在返回字符向量的搜索路径中的MATLAB函数。

例子:'AdditionalIncludePaths',{}

TheAdditionalLinkObjsvalue specifies additional link objects for a code replacement table entry. The character vectors or string array can include tokens. For example, in the token$ mytoken $,mytoken是MATLAB工作区中的字符向量或字符串标量定义的变量,或在返回字符向量的搜索路径中的MATLAB函数。

例子:'AddaflAllInkObjs',{}

TheAdditionalLinkObjsPathsvalue specifies the full path of additional link object paths for a code replacement entry. The character vectors or string array can include tokens. For example, in the token$ mytoken $,mytoken是MATLAB工作区中的字符向量或字符串标量定义的变量,或在返回字符向量的搜索路径中的MATLAB函数。

例子:'AdditionalLinkObjsPaths',{}

TheAdditionalSourceFilesvalue specifies additional source files for a code replacement table entry. The character vectors or string array can include tokens. For example, in the token$ mytoken $,mytoken是MATLAB工作区中的字符向量或字符串标量定义的变量,或在返回字符向量的搜索路径中的MATLAB函数。

例子:“ AffealSourceFiles”,{}

TheAdusalsSourcePathvalue specifies the full path of additional source paths for a code replacement entry. The character vectors or string array can include tokens. For example, in the token$ mytoken $,mytoken是MATLAB工作区中的字符向量或字符串标量定义的变量,或在返回字符向量的搜索路径中的MATLAB函数。

例子:“ AdusalSourcePath”,{}

TheAdditionalCompileFlagsvalue specifies additional flags required to compile the source files defined for a code replacement table entry.

例子:'AdditionalCompileFlags',{}

TheAdditionalLinkFlagsvalue specifies additional flags required to link the compiled files for a code replacement table entry.

例子:“添加allinkflags”,{}

The允许ShapeGnosticMatchvalue enables code replacement match based on total number of elements rather than specific matrix shape for matrices that are contiguously allocated in memory. For more information, seeAllow Shape Agnostic Match

例子:“允许ShapeGnosticMatch”,false

Thearraylayoutvalue specifies the order of array elements in memory supported by the replacement implementation. By default, the replacement implementation supports column-major data layout. ForROW-MAJOR, the replacement implementation supports row-major data layout. ForCOLUMN_AND_ROW,替换实现支持列 - 塔和行数据布局。金宝app

例子:'arraylayout','ROW_MAJOR'

TheEntryInfoAlgorithm值指定了指定的数学函数的算法,必须匹配操作员替换的算法。代码更换库支持基于数学操作算法的替换金宝appRTW_OP_ADDandRTW_OP_MINUS。Valid arguments for the supported operations are listed in the table. The arguments have the same meaning for both operations.

争论 意义

RTW_CAST_BEFORE_OP

Before performing the operation, type cast input values to the output data type. If the output type cannot exactly represent the input values, losses can occur as a result of the cast to the output type. Additional loss can occur when the result of the operation is cast to the final output type.

RTW_CAST_AFTER_OP

Compute the ideal result of the operation of inputs. Then, type cast the result to the output data type. Loss occurs during the type cast. This algorithm behaves similarly to the C language except when the signedness of the operands does not match. For example, when you add a signed long operation to an unsigned long operand, standard C language rules convert the signed long operand to an unsigned long operand. The result is a value that is not ideal.

例子:'entryinfoalgorithm','rtw_cast_after_op'

TheGenCallbackspecifies a callback that follows code generation. If you specify'RTW.copyFileToBuildDir', and if this operation entry is matched and used, the code generator calls functionRTW.copyFileToBuildDirafter code generation. This callback function copies additional header, source, or object files that you have specified for this entry to the build folder.

例子:'gencallback','RTW.copyFileToBuildDir'

The实施Headerfilevalue specifies the name of the header file that declares the implementation function. The character vector or string scalar can include tokens. For example, in the token$ mytoken $,mytoken是MATLAB工作区中的字符向量或字符串标量定义的变量,或在返回字符向量的搜索路径中的MATLAB函数。

例子:“实现headerfile”,'s32_mul.h'

TheImplementationHeaderPathvalue specifies the full path to the implementation header file. The character vector or string scalar can include tokens. For example, in the token$ mytoken $,mytoken是MATLAB工作区中的字符向量或字符串标量定义的变量,或在返回字符向量的搜索路径中的MATLAB函数。

例子:'ImplementationHeaderPath', fullfile('$MATLAB_ROOT', 'crl')

TheImplementationNamevalue specifies the name of the implementation function, which can match or differ from theKeyname.

例子:'ImplementationName','s32_mul_s32_s32_sat'

TheImplementationSourceFilevalue specifies the name of the implementation source file. The character vector or string scalar can include tokens. For example, in the token$ mytoken $,mytoken是MATLAB工作区中的字符向量或字符串标量定义的变量,或在返回字符向量的搜索路径中的MATLAB函数。

例子:'enasemationsourcefile','s32_mul.c'

TheImplementationSourcePathvalue specifies the full path to the implementation source file. The character vector or string scalar can include tokens. For example, in the token$ mytoken $,mytoken是MATLAB工作区中的字符向量或字符串标量定义的变量,或在返回字符向量的搜索路径中的MATLAB函数。

例子:'ImplementationSourcePath', fullfile('$MATLAB_ROOT', 'crl')

Thesmand类型value specifies the type of table entry. UseFCN_IMPL_FUNCT用于功能或FCN_IMPL_MACROfor macro.

例子:','FCN_IMPL_FUNCT'

TheKeyvalue specifies the key for the operator to replace. The key must match an operator key listed inCode You Can Replace from MATLAB CodeorCode You Can Replace From Simulink Models

例子:'Key','RTW_OP_ADD'

Themusthavezeronetbias值指定是否替换匹配要求es that the net bias for conceptual arguments of Add/Minus entries is zero. For the Add/Minus of fixed-point operator inputs and output this parameter must be set totrue。通过使用hEntry=环球套票。TflCOperationEntryGeneratorrather thanhEntry=环球套票。TflCOperationEntry

用于mul/div/muldiv/shift/cast条目​​:

  • 代码生成器忽略了此参数的值。

  • MUL/DIV/MULDIV/SHIFT/CAST条目的概念参数的偏差必须为零,以进行替换匹配。

例子:“ musthavezeronetbias”,true

TheNetSlopeAdjustmentFactorvalue specifies the fixed exponent (E) part of the net slope (F2E, for example, -3.0) for fixed-point conceptual arguments required for a replacement match to occur for Mul/Div/MulDiv/Shift/Cast entries. Instantiate an entry by usinghEntry=环球套票。TflCOperationEntryGenerator_NetSloperather thanhEntry=环球套票。TflCOperationEntry

用于添加/减去条目:

  • 代码生成器忽略了此参数的值。

  • The slope adjustment factor part of the net slope of the conceptual arguments for Add/Minus entries must be zero for a replacement match to occur.

例子:“ netfixedepponent”, -3.0

TheNetSlopeAdjustmentFactorvalue specifies the slope adjustment part of the net slope (F2E, for example, 1.0) for fixed-point conceptual arguments required for a replacement match to occur for Mul/Div/MulDiv/Shift/Cast entries. Instantiate an entry by usinghEntry=环球套票。TflCOperationEntryGenerator_NetSloperather thanhEntry=环球套票。TflCOperationEntry

用于添加/减去条目:

  • 代码生成器忽略了此参数的值。

  • The slope adjustment factor part of the net slope of the conceptual arguments for Add/Minus entries must be zero for a replacement match to occur.

例子:“ NetSlopeadJustmentFactor”,1.5

The优先value specifies the search priority of the operation entry, relative to other entries of the same operation name and conceptual argument list within this table. Highest priority is 0, and lowest priority is 100. If the table provides two implementations for an operation, the implementation with the higher priority shadows the one with the lower priority.

例子:'优先',100

TheRoundingModes值指定实现功能支持的一个或多个圆形模式。金宝app

例子:'roundingmodes',{'rtw_round_unspecified'}

The饱和模式value specifies the saturation mode supported by the implementation function.

例子:'饱和模式','rtw_saturate_unspecified'

The副作用value flags the code generator not to optimize away the implementation function described by this entry. This parameter applies to implementation functions that returnvoidbut are not to be optimized away, such as amemcpyimplementation or an implementation function that accesses global memory values. For those implementation functions only, you must include this parameter and specify the valuetrue

例子:'副作用',false

TheSlopesMustBeTheSame值指定是否替换匹配要求es that the slope is the same for conceptual arguments of Mul/Div/MulDiv/Shift/Cast entries. Instantiate the entry by usinghEntry=环球套票。TflCOperationEntryGeneratorrather thanhEntry=环球套票。TflCOperationEntry

用于添加/减去条目:

  • 代码生成器忽略了此参数的值。

  • 此参数必须设置为true。When set totrue, the slopes of the conceptual arguments are equal for a replacement match to occur.

例子:'SlopesMustBeTheSame',true

TheStoreFcnReturnInLocalVarvalue flags the code generator that the return value of the implementation function described by this entry must be stored in a local variable regardless of other expression folding settings. If the value isfalse, other expression folding settings determine whether the return value is folded. Storing function returns in a local variable can increase the clarity of generated code. This example shows code generated with expression folding:

void sw_step(void){if(ssub(sadd(sw_u.in1,sw_u.in2),sw_u.in3),sw_u.in3)<= smul(ssub(sw_u.in4,sw_u.in5),sw_u.in6,sw_u.in6)){sw_y.out1 = sw_y.out1 =sw_u.in7;} else {sw_y.out1 = sw_u.in8;}}}

WithStoreFcnReturnInLocalVarset totrue, the generated code is potentially easier to understand and debug:

void sw_step(void){real32_t rtb_switch;real32_t hoistedexpr;...... rtb_switch = sadd(sw_u.in1,sw_u.in2);rtb_switch = ssub(rtb_switch,sw_u.in3);HOISTEDEXPR = ssub(sw_u.in4,sw_u.in5);HOISTEDEXPR = SMUL(HOISTEDEXPR,SW_U.IN6);if(rtb_switch <= hoistedexpr){sw_y.out1 = sw_u.in7;} else {sw_y.out1 = sw_u.in8;}}}

例子:'StoreFcnReturnInLocalVar',false

Introduced in R2007b