Skip to Main Content Skip to Search
Product Documentation

setTflCFunctionEntryParameters - Set specified parameters for function entry in CRL table

Syntax

setTflCFunctionEntryParameters(hEntry, varargin)

Arguments

hEntry

Handle to a CRL function entry previously returned by hEntry = RTW.TflCFunctionEntry or hEntry = MyCustomFunctionEntry, where MyCustomFunctionEntry is a class derived from RTW.TflCFunctionEntry.

varargin

Parameter/value pairs for the function entry. See varargin Parameters.

varargin Parameters

The following function entry parameters can be specified to the setTflCFunctionEntryParameters function using parameter/value argument pairs. For example,

setTflCFunctionEntryParameters(..., 'Key', 'sqrt', ...);
Key

String specifying the name of the function to be replaced. The name must match one of the functions supported for replacement:

Math Functions

absacosacoshasin
asinhatanatan2atanh
ceilcoscoshexactrSqrt
expfixfloorfrexp
hypotldexplnlog
log10maxminmod/fmod
powremroundrSqrt
saturatesignsinsincos
sinhsqrtroundtanh
Memory Utility Functions
memcmpmemcpymemsetmemset2zero1
Nonfinite Support Utility Functions2
getInfgetMinusInfgetNaNisInf3
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.

GenCallback

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.

Priority

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.

ImplType

Specifies the type of entry: FCN_IMPL_FUNCT for function or FCN_IMPL_MACRO for macro. The default is FCN_IMPL_FUNCT.

ImplementationName

String specifying the name of the implementation function, for example, 'sqrt', which can match or differ from the Key name. The default is ''.

ImplementationHeaderFile

String specifying the name of the header file that declares the implementation function, for example, '<math.h>'. The default is ''.

ImplementationHeaderPath

String specifying the full path to the implementation header file. The default is ''.

ImplementationSourceFile

String specifying the name of the implementation source file. The default is ''.

ImplementationSourcePath

String specifying the full path to the implementation source file. The default is ''.

AcceptExprInput

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);
SideEffects

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.

StoreFcnReturnInLocalVar

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;  
    }
}
EntryInfoAlgorithm

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:

FunctionArgumentMeaning
rSqrtRTW_DEFAULTMatch the default computation method, Exact
RTW_NEWTON_RAPHSONMatch the Newton-Raphson computation method
RTW_UNSPECIFIEDMatch any computation method
sin
cos
sincos
RTW_CORDICMatch the CORDIC approximation method
RTW_DEFAULTMatch the default approximation method, None
RTW_UNSPECIFIEDMatch any approximation method

Description

The setTflCFunctionEntryParameters function sets specified parameters for a function entry in a CRL table.

Examples

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>' );

How To

  


Related Products & Applications

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