| Contents | Index |
setTflCOperationEntryParameters(hEntry, varargin)
Handle to a CRL table entry previously returned by one of the following class instantiations:
| hEntry = RTW.TflCOperationEntry; | Supports operator replacement, described in Map Scalar Operators to Target-Specific Implementations and Map Nonscalar Operators to Target-Specific Implementations |
| hEntry = RTW.TflCOperationEntryGenerator; | Provides relative scaling factor (RSF) fixed-point parameters, described in Map Fixed-Point Operators to Target-Specific Implementations, that are not available in RTW.TflCOperationEntry |
| hEntry = RTW.TflCOperationEntryGenerator_NetSlope; | Provides net slope parameters, described in Map Fixed-Point Operators to Target-Specific Implementations, that are not available in RTW.TflCOperationEntry |
| hEntry = RTW.TflBlasEntryGenerator; | Supports replacement of nonscalar operators with MathWorks BLAS functions, described in Map Nonscalar Operators to Target-Specific Implementations |
| hEntry = RTW.TflCBlasEntryGenerator; | Supports replacement of nonscalar operators with ANSI/ISO C BLAS functions, described in Map Nonscalar Operators to Target-Specific Implementations |
| hEntry = MyCustomOperationEntry; (where MyCustomOperationEntry is a class derived from RTW.TflCOperationEntry) | Supports operator replacement using custom CRL table entries, described in Refine CRL Matching and Replacement Using Custom CRL Table Entries |
Note If you want to specify any of the parameters SlopesMustBeTheSame, MustHaveZeroNetBias, RelativeScalingFactorF, or RelativeScalingFactorE for your operator entry, instantiate your table entry using hEntry = RTW.TflCOperationEntryGenerator rather than hEntry = RTW.TflCOperationEntry. If you want to use NetSlopeAdjustmentFactor and NetFixedExponent, instantiate your table entry using hEntry = RTW.TflCOperationEntryGenerator_NetSlope. |
Parameter/value pairs for the operator entry. See varargin Parameters.
The following operator entry parameters can be specified to the setTflCOperationEntryParameters function using parameter/value argument pairs. For example,
setTflCOperationEntryParameters(..., 'Key', 'RTW_OP_ADD', ...);
String specifying the operator to be replaced, among the operators supported for replacement:
| Operator | Key |
|---|---|
| Addition (+) | RTW_OP_ADD |
| Subtraction (-) | RTW_OP_MINUS |
| Multiplication (*) | RTW_OP_MUL |
| Division (/) | RTW_OP_DIV |
| Data type conversion (cast) | RTW_OP_CAST |
| Shift left (<<) | RTW_OP_SL |
| Shift right (>>) | RTW_OP_SRA (arithmetic)1 RTW_OP_SRL (logical) |
| Element-wise matrix multiplication (.*) | RTW_OP_ELEM_MUL2 |
| Matrix right division (/) | RTW_OP_RDIV3 |
| Matrix left division (\) | RTW_OP_LDIV3 |
| Matrix inversion (inv) | RTW_OP_INV3 |
| Complex conjugation | RTW_OP_CONJUGATE |
| Transposition (.') | RTW_OP_TRANS |
| Hermitian (complex conjugate) transposition (') | RTW_OP_HERMITIAN |
| Multiplication with transposition | RTW_OP_TRMUL |
| Multiplication with Hermitian transposition | RTW_OP_HMMUL |
| Notes: 1 CRLs that provide arithmetic shift right implementations should also provide logical shift right implementations, because some arithmetic shift rights are converted to logical shift rights during code generation. 2 For scalar multiplication, use RTW_OP_MUL. 3 Matrix division and inversion are supported for Simulink code generation (not for Stateflow or MATLAB Coder code generation). | |
The default is 'RTW_OP_ADD'.
String specifying '' or 'RTW.copyFileToBuildDir'. The default is ''. If you specify 'RTW.copyFileToBuildDir', and if this operator 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 operator entry to the build directory. For more information, see Specify Build Information for Code Replacements in the Embedded Coder documentation.
Positive integer specifying the operator entry's search priority, 0-100, relative to other entries of the same operator 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 an operator, the implementation with the higher priority will shadow the one with the lower priority.
String specifying the rounding mode supported by the implementation function: 'RTW_ROUND_FLOOR', 'RTW_ROUND_CEILING', 'RTW_ROUND_ZERO', 'RTW_ROUND_NEAREST', 'RTW_ROUND_NEAREST_ML', 'RTW_ROUND_SIMPLEST', 'RTW_ROUND_CONV', or 'RTW_ROUND_UNSPECIFIED'. The default is 'RTW_ROUND_UNSPECIFIED'.
String specifying the saturation mode supported by the implementation function: 'RTW_SATURATE_ON_OVERFLOW', 'RTW_WRAP_ON_OVERFLOW', or 'RTW_SATURATE_UNSPECIFIED'. The default is 'RTW_SATURATE_UNSPECIFIED'.
Boolean flag that, when set to true, indicates that CRL replacement request processing must check that the slopes on all arguments (input and output) are equal. The default is false.
This parameter and MustHaveZeroNetBias can be used for fixed-point addition and subtraction replacement. Set both parameters to true to disregard specific slope and bias values and map relative slope and bias values to a replacement function.
To use this parameter, you must instantiate your table entry using hEntry = RTW.TflCOperationEntryGenerator rather than hEntry = RTW.TflCOperationEntry.
Boolean flag that, when set to true, indicates that CRL replacement request processing must check that the net bias on all arguments is zero. The default is false.
This parameter and SlopesMustBeTheSame can be used for fixed-point addition and subtraction replacement. Set both parameters to true to disregard specific slope and bias values and map relative slope and bias values to a replacement function.
To use this parameter, you must instantiate your table entry using hEntry = RTW.TflCOperationEntryGenerator rather than hEntry = RTW.TflCOperationEntry.
Floating-point value specifying the slope adjustment factor (F) part of the relative scaling factor, F2E, for relative scaling CRL entries. The default is 1.0.
This parameter and RelativeScalingFactorE can be used for fixed-point multiplication and division replacement. Specify both parameters to map a range of slope and bias values to a replacement function.
To use this parameter, you must instantiate your table entry using hEntry = RTW.TflCOperationEntryGenerator rather than hEntry = RTW.TflCOperationEntry.
Floating-point value specifying the fixed exponent (E) part of the relative scaling factor, F2E, for relative scaling CRL entries. For example, -3.0. The default is 0.
This parameter and RelativeScalingFactorF can be used for fixed-point multiplication and division replacement. Specify both parameters to map a range of slope and bias values to a replacement function.
To use this parameter, you must instantiate your table entry using hEntry = RTW.TflCOperationEntryGenerator rather than hEntry = RTW.TflCOperationEntry.
Boolean value specifying that the operator entry is a relative scaling factor (RSF) entry. Specify true if the values of RelativeScalingFactorF and RelativeScalingFactorE equal their defaults, 1.0 and 0, but the entry nonetheless should be interpreted by the code generation process as an RSF entry.
Floating-point value specifying the slope adjustment factor (F) part of the net slope, F2E, for net slope CRL entries. The default is 1.0.
This parameter and NetFixedExponent can be used for fixed-point multiplication and division replacement. Specify both parameters to map a range of slope and bias values to a replacement function.
To use this parameter, you must instantiate your table entry using hEntry = RTW.TflCOperationEntryGenerator_NetSlope rather than hEntry = RTW.TflCOperationEntry.
Floating-point value specifying the fixed exponent (E) part of the net slope, F2E, for net slope CRL entries. For example, -3.0. The default is 0.
This parameter and NetSlopeAdjustmentFactor can be used for fixed-point multiplication and division replacement. Specify both parameters to map a range of slope and bias values to a replacement function.
To use this parameter, you must instantiate your table entry using hEntry = RTW.TflCOperationEntryGenerator_NetSlope rather than hEntry = RTW.TflCOperationEntry.
String specifying the name of the implementation function, for example, 's8_add_s8_s8'. The default is ''.
String specifying the name of the header file that declares the implementation function, for example, 's8_add_s8_s8.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, for example, 's8_add_s8_s8.c'. The default is ''.
String specifying the full path to the implementation source file. The default is ''.
Note To supply additional build information for the operator 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. If the value is true (the default), expression inputs are integrated into the generated code in a form similar to the following:
rtY.Out1 = u8_add_u8_u8(u8_add_u8_u8(rtU.In1, rtU.In2), rtU.In3);
If the value is false, a temporary variable is generated for the expression input, as follows:
uint8_T tempVar; tempVar = u8_add_u8_u8(rtU.In1, rtU.In2); rtY.Out1 = u8_add_u8_u8(tempVar, rtU.In3);
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 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;
}
}The setTflCOperationEntryParameters function sets specified parameters for an operator entry in a CRL table.
In the following example, the setTflCOperationEntryParameters function is used to set parameters for a CRL operator entry for uint8 addition.
op_entry = RTW.TflCOperationEntry;
op_entry.setTflCOperationEntryParameters( ...
'Key', 'RTW_OP_ADD', ...
'Priority', 90, ...
'SaturationMode', 'RTW_SATURATE_UNSPECIFIED', ...
'RoundingMode', 'RTW_ROUND_UNSPECIFIED', ...
'ImplementationName', 'u8_add_u8_u8', ...
'ImplementationHeaderFile', 'u8_add_u8_u8.h', ...
'ImplementationSourceFile', 'u8_add_u8_u8.c' );In the following example, the setTflCOperationEntryParameters function is used to set parameters for a CRL operator entry for fixed-point int16 division. The table entry specifies a relative scaling between the operator inputs and output in order to map a range of slope and bias values to a replacement function.
op_entry = RTW.TflCOperationEntryGenerator;
op_entry.setTflCOperationEntryParameters( ...
'Key', 'RTW_OP_DIV', ...
'Priority', 90, ...
'SaturationMode', 'RTW_WRAP_ON_OVERFLOW', ...
'RoundingMode', 'RTW_ROUND_CEILING', ...
'RelativeScalingFactorF', 1.0, ...
'RelativeScalingFactorE', -3.0, ...
'ImplementationName', 's16_div_s16_s16_rsf0p125', ...
'ImplementationHeaderFile', 's16_div_s16_s16_rsf0p125.h', ...
'ImplementationSourceFile', 's16_div_s16_s16_rsf0p125.c' );In the following example, the setTflCOperationEntryParameters function is used to set parameters for a CRL operator entry for fixed-point uint16 addition. The table entry specifies equal slope and zero net bias across operator inputs and output in order to map relative slope and bias values (rather than a specific slope and bias combination) to a replacement function.
op_entry = RTW.TflCOperationEntryGenerator;
op_entry.setTflCOperationEntryParameters( ...
'Key', 'RTW_OP_ADD', ...
'Priority', 90, ...
'SaturationMode', 'RTW_WRAP_ON_OVERFLOW', ...
'RoundingMode', 'RTW_ROUND_UNSPECIFIED', ...
'SlopesMustBeTheSame', true, ...
'MustHaveZeroNetBias', true, ...
'ImplementationName', 'u16_add_SameSlopeZeroBias', ...
'ImplementationHeaderFile', 'u16_add_SameSlopeZeroBias.h', ...
'ImplementationSourceFile', 'u16_add_SameSlopeZeroBias.c' );
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 |