| Contents | Index |
setTflCFunctionEntryParameters(hEntry, varargin)
Handle to a CRL function entry previously returned by hEntry = RTW.TflCFunctionEntry or hEntry = MyCustomFunctionEntry, where MyCustomFunctionEntry is a class derived from RTW.TflCFunctionEntry.
Parameter/value pairs for the function entry. See varargin Parameters.
The following function entry parameters can be specified to the setTflCFunctionEntryParameters function using parameter/value argument pairs. For example,
setTflCFunctionEntryParameters(..., 'Key', 'sqrt', ...);
String specifying the name of the function to be replaced. The name must match one of the functions supported for replacement:
Math Functions
| ||||
| abs | acos | acosh | asin | |
| asinh | atan | atan2 | atanh | |
| ceil | cos | cosh | exactrSqrt | |
| exp | fix | floor | frexp | |
| hypot | ldexp | ln | log | |
| log10 | max | min | mod/fmod | |
| pow | rem | round | rSqrt | |
| saturate | sign | sin | sincos | |
| sinh | sqrt | round | tanh | |
| Memory Utility Functions | ||||
| memcmp | memcpy | memset | memset2zero1 | |
| Nonfinite Support Utility Functions2 | ||||
| getInf | getMinusInf | getNaN | isInf3 | |
| isNaN3 | ||||
| Notes: 1 Some target processors provide optimized memset functions for use when performing a memory set to zero. The CRL API supports replacing memset to zero functions with more efficient target-specific functions. 2 Replacement of nonfinite functions is supported for Simulink code generation (not for Stateflow or MATLAB Coder code generation). 3 Replacement of isInf and isNaN is supported only for complex floating-point inputs. | ||||
String specifying '' or 'RTW.copyFileToBuildDir'. The default is ''. If you specify 'RTW.copyFileToBuildDir', and if this function entry is matched and used, the function RTW.copyFileToBuildDir will be called after code generation to copy additional header, source, or object files that you have specified for this function entry to the build directory. For more information, see Specify Build Information for Code Replacements in the Embedded Coder documentation.
Positive integer specifying the function entry's search priority, 0-100, relative to other entries of the same function name and conceptual argument list within this table. Highest priority is 0, and lowest priority is 100. The default is 100. If the table provides two implementations for a function, the implementation with the higher priority will shadow the one with the lower priority.
Specifies the type of entry: FCN_IMPL_FUNCT for function or FCN_IMPL_MACRO for macro. The default is FCN_IMPL_FUNCT.
String specifying the name of the implementation function, for example, 'sqrt', which can match or differ from the Key name. The default is ''.
String specifying the name of the header file that declares the implementation function, for example, '<math.h>'. The default is ''.
String specifying the full path to the implementation header file. The default is ''.
String specifying the name of the implementation source file. The default is ''.
String specifying the full path to the implementation source file. The default is ''.
Note To supply additional build information for the function entry, you can use CRL table entry functions addAdditionalHeaderFile, addAdditionalIncludePath, addAdditionalLinkObj, addAdditionalLinkObjPath, addAdditionalSourceFile, and addAdditionalSourcePath, and CRL table entry properties AdditionalCompileFlags, AdditionalLinkFlags, and OtherFiles. For more information. see Specify Build Information for Code Replacements. |
Boolean value used to flag the code generator that the implementation function described by this entry should accept expression inputs. The default value is true if ImplType equals FCN_IMPL_FUNCT and false if ImplType equals FCN_IMPL_MACRO.
If the value is true, expression inputs are integrated into the generated code in a form similar to the following:
rtY.Out1 = mySin(rtU.In1 + rtU.In2);
If the value is false, a temporary variable is generated for the expression input, as follows:
real_T rtb_Sum; rtb_Sum = rtU.In1 + rtU.In2; rtY.Out1 = mySin(rtb_Sum);
Boolean value used to flag the code generator that the implementation function described by this entry should not be optimized away. This parameter applies to implementation functions that return void but should not be optimized away, such as a memcpy implementation or an implementation function that accesses global memory values. For those implementation functions only, you must include this parameter and specify the value true. The default is false.
Boolean value used to flag 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 is false (the default), 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. For example, here is an example of code generated with expression folding:
void sw_step(void)
{
if (ssub(sadd(sw_U.In1, sw_U.In2), sw_U.In3) <=
smul(ssub(sw_U.In4, sw_U.In5),sw_U.In6)) {
sw_Y.Out1 = sw_U.In7;
} else {
sw_Y.Out1 = sw_U.In8;
}
}With StoreFcnReturnInLocalVar set to true, the generated code potentially is 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;
}
}String specifying a computation or approximation method, configured for the specified math function, that must be matched in order for function replacement to occur. CRLs support function replacement based on computation or approximation method for the math functions rSqrt, sin, cos, and sincos. The valid arguments for each supported function are:
| Function | Argument | Meaning |
|---|---|---|
| rSqrt | RTW_DEFAULT | Match the default computation method, Exact |
| RTW_NEWTON_RAPHSON | Match the Newton-Raphson computation method | |
| RTW_UNSPECIFIED | Match any computation method | |
| sin cos sincos | RTW_CORDIC | Match the CORDIC approximation method |
| RTW_DEFAULT | Match the default approximation method, None | |
| RTW_UNSPECIFIED | Match any approximation method |
The setTflCFunctionEntryParameters function sets specified parameters for a function entry in a CRL table.
In the following example, the setTflCFunctionEntryParameters function is used to set specified parameters for a CRL function entry for sqrt.
fcn_entry = RTW.TflCFunctionEntry;
fcn_entry.setTflCFunctionEntryParameters( ...
'Key', 'sqrt', ...
'Priority', 100, ...
'ImplementationName', 'sqrt', ...
'ImplementationHeaderFile', '<math.h>' );
Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |