createCRLEntry - Create code replacement table entry from conceptual and implementation argument

        string specifications - MATLAB ([original](https://www.mathworks.com/help/ecoder/ref/createcrlentry.html)) ([raw](?raw))

Create code replacement table entry from conceptual and implementation argument string specifications

Syntax

Description

[tableEntry](#buofwbt-1-tableEntry) = createCRLEntry([crTable](#buofwbt-1-crTable),[conceptualSpecification](#buofwbt-1-conceptualSpecification),[implementationSpecification](#buofwbt-1-implementationSpecification)) returns a code replacement table entry. The entry maps a conceptual representation of a function or operator to an implementation representation. TheconceptualSpecification argument is a character vector or string scalar that defines the name and conceptual arguments, familiar to the code generator, for the function or operator to replace. TheimplementationSpecification argument is a character vector or string scalar that defines the name and C/C++ implementation arguments for the replacement function.

This function does not support:

In the syntax specifications, place a space before and after an operator symbol. For example, use double u1 + double u2 instead of double u1+double u2. Also, asterisk (*), tilde (~), and semicolon (;) have the following meaning.

Symbol Meaning
* Following a supported data type, such asint32*, pass by reference (pointer). If the conceptual arguments are not scalar, in the implementation specification, pass them by reference.As part of a fixed-point data type definition, such as fixdt(1,32,*), wildcard.
~ Based on the position of the symbol, slopes or bias must be the same across data types.
; Separates dimension ranges. For example, [1 10; 1 100] specifies a vector with length from 10 through 100.

The following table shows syntax for the conceptual and implementation specifications based on:

Type of Replacement Conceptual Syntax Implementation Syntax
Function Code Replacement Syntax
Typical double y1 = sin(double u1) double y1 = mySin(double u1)
Derive implementation argument data types from conceptual specification double y1 = sin(double u1) y1 = mySin(u1)
Derive implementation arguments and data types from conceptual specification double y1 = sin(double u1) mySin
Change data type single y1 = sin(single u1) double y1 = mySin(double u1)
Reorder arguments double y1 = atan2(double u1, double u2) y1 = myAtan(u2, u1)
Specify column vector arguments double y1 = sin(double u1[10]) double y1 = mySin(double* u1)
Specify column vector arguments and dimension range double y1[1 100; 1 100] = sin(double u1[1 100; 1 100]) mySin(double* u1, double* y1)
Remap return value as output argument double y1 = sin(double u1) mySin(double u1, double* y1)
Specify fixed-point data types fixdt(1,16,3) y1 = sin(fixdt(1,16,3) u1) int16 y1 = mySin(int16 u1)
Specify fixed-point data types and setCheckSlope to false,CheckBias to true, andBias to 0 fixdt(1,16,*) y1 = sin(fixdt(1,16,*) u1) int16 y1 = mySin(int16 u1)
Specify fixed-point data types and setSlopesMustBeTheSame totrue, CheckSlope tofalse, CheckBias totrue, and Bias to 0 fixdt(1,16,~) y1 = sin(fixdt(1,16,~) u1) int16 y1 = mySin(int16 u1)
Specify fixed-point data types and setSlopesMustBeTheSame totrue,BiasMustBeTheSame totrue, CheckSlope tofalse, and CheckBias to false fixdt(1,16,~,~) y1 = sin(fixdt(1,16,~,~) u1) int16 y1 = mySin(int16 u1)
Specify multiple output arguments [double y1 double y2] = foo(double u1, double u2) double y1 = myFoo(double u1, double u2, double* y2)
Operator Code Replacement Syntax
Typical int16 y1 = int16 u1 + int16 u2 int16 y1 = myAdd(int16 u1, int16 u2)
Specify fixed-point data types fixdt(1,16,3) y1 = fixdt(1,16,3) u1 + fixdt(1,16,3) u2 int16 y1 = myAdd(int16 u1, int16 u2)
Specify fixed-point data types and setCheckSlope to false,CheckBias to true, andBias to 0 fixdt(1,16,*) y1 = fixdt(1,16,*) u1 + fixdt(1,16,*) u2 int16 y1 = myAdd(int16 u1, int16 u2)
Specify fixed-point data types, wildcard, slopes must be the same, and zero bias fixdt(1,16,~,0) y1 = fixdt(1,16,~,0) u1 + fixdt(1,16,~,0) u2 int16 y1 = myAdd(int16 u1, int16 u2)
Typecast int16 y1 = int8 u1 int16 y1 = myCast(int8 u1)
Shift int16 y1 = int16 u1 << int16 u2 int16 y1 = int16 u1 >> int16 u2 int16 y1 = int16 u1 .>> int16 u2 int16 y1 = myShiftLeft(int16 u1, int16 u2) int16 y1 = myShiftRightArithmetic(int16 u1, int16 u2) int16 y1 = myShiftRightLogical(int16 u1, int16 u2)
Specify relational operator bool y1 = int16 u1 < int16 u2 bool y1 = myLessThan(int6 u1, int16 u2)
Specify multiplication and division int32 y1 = int32 u1 * in32 u2 / in32 u3 int32 y1 = myMultDiv(int32 u1, int32 u2, int32 u3)
Specify matrix multiplication double y1[10][10] = double u1[10][10] * double u2[10][10] myMult(double* u1, double* u2, double* y1)
Specify element-wise matrix multiplication double y1[10][10] = double u1[10][10] .* double u2[10][10] myMult(double* u1, double* u2, double* y1)
Specify matrix multiplication with transpose of an input argument double y1[10][10] = double u1[10][10]' * double u2[10][10] myMult(double* u1, double* u2, double* y1)
Specify matrix multiplication with Hermitian of an input argument cdouble y1[10][10] = cdouble u1[10][10]' * cdouble u2[10][10] cdouble y1[10][10] = cdouble u1[10][10] * cdouble u2[10][10]' myMult(cdouble* u1, cdouble* u2, cdouble* y1)
Specify left matrix division double y1[10][10] = double u1[10][10] \ double u2[10][10] myLeftDiv(double* u1, double* u2, double* y1)
Specify right matrix division double y1[10][10] = double u1[10][10] / double u2[10][10] myRightDiv(double* u1, double* u2, double* y1)

example

Examples

collapse all

Create a table definition file that contains a function definition.

function crTable = crl_table_sinfcn()

Within the function body, create the code replacement table.

Create a table entry for the sin function.

tableEntry = createCRLEntry(crTable, ... 'double y1 = sin(double u1)', ... 'double y1 = mySin(double u1)');

Set entry parameters for the sin function. To generate the replacement code, specify that the code generator use the header and source files mySin.h andmySin.c.

setTflCFunctionEntryParameters(tableEntry, ... 'ImplementationHeaderFile', 'mySin.h', ... 'ImplementationSourceFile', 'mySin.c');

Add the entry to the table.

addEntry(crTable, tableEntry);

Create a table definition file that contains a function definition.

function crTable = crl_table_addfcn()

Within the function body, create the code replacement table.

Create a table entry for the addition operator.

tableEntry = createCRLEntry(crTable, ... 'int16 y1 = int16 u1 + int16 u2', ... 'int16 y1 = myAdd(int16 u1, int16 u2)');

Set entry parameters such that the entry specifies a cast-after-sum addition. To generate the replacement code, specify that the code generator use the header and source files myAdd.h andmyAdd.c.

setTflCOperationEntryParameters(tableEntry, ... 'EntryInfoAlgorithm', 'RTW_CAST_AFTER_OP', ... 'ImplementationHeaderFile', 'myAdd.h', ... 'ImplementationSourceFile', 'myAdd.c'));

Add the entry to the table.

addEntry(crTable, tableEntry);

Create a table definition file that contains a function definition.

function crTable = crl_table_intaddfcn()

Within the function body, create the code replacement table.

Create a table entry for a signed fixed-point addition operation requiring the same slope across types.

tableEntry = createCRLEntry(crTable, ... 'fixdt(1,16,,0) y1 = fixdt(1,16,,0) u1 + fixdt(1,16,~,0) u2', ... 'int16 y1 = myAdd(int16 u1, int16 u2)');

Set entry parameters. Set algorithm parameters for a cast-after-sum addition and saturation and rounding modes. To generate the replacement code, specify that the code generator use the header and source filesmyIntAdd.h and myIntAdd.c.

setTflCOperationtionEntryParameters(tableEntry, ... 'EntryInfoAlgorithm', 'RTW_CAST_AFTER_OP', ... 'SaturationMode', 'RTW_SATURATE_ON_OVERFLOW', ... 'RoundingMode', 'RTW_ROUND_SIMPLEST', ... 'ImplementationHeaderFile', 'myIntAdd.h', ... 'ImplementationSourceFile', 'myIntAdd.c');

Add the entry to the table.

addEntry(crTable, tableEntry);

Create a table definition file that contains a function definition.

function crTable = crl_table_sinfcn()

Within the function body, create the code replacement table.

Create a table entry for a sin function, where the implementation arguments are the same as the conceptual arguments.

tableEntry = createCRLEntry(crTable, ... 'double y1 = sin(double u1)', ... 'y1 = mySin(u1)');

Set entry parameters. To generate the replacement code, specify that the code generator use the header and source files mySin.h and mySin.c.

setTflCFunctionEntryParameters(tableEntry, ... 'ImplementationHeaderFile', 'mySin.h', ... 'ImplementationSourceFile', 'mySin.c');

Add the entry to the table.

addEntry(crTable, tableEntry);

Input Arguments

collapse all

Table that stores one or more code replacement entries, each representing a potential replacement for a function or operator. Each entry maps a conceptual representation of a function or operator to an implementation representation and priority.

Representation of the name or symbol and conceptual input and output arguments for a function or operator that the software replaces, specified as a character vector or string scalar. Conceptual arguments observe naming conventions ('y1', 'u1', 'u2', ...) and data types familiar to the code generator. Use the syntax table in Description to determine the syntax to use for your conceptual argument specification.

Example: 'double y1 = sin(double u1)'

Example: 'int16 y1 = int16 u1 + int16 u2'

Representation of the name and implementation input and output arguments for a C or C++ replacement function, specified as a character vector or string scalar. Implementation arguments observe C/C++ name and data type specifications. Use the syntax table in Description to determine the syntax for your implementation argument specification.

Example: 'double y1 = my_sin(double u1)'

Example: 'int16 y1 = myAdd(int16 u1, int16 u2)'

Output Arguments

collapse all

Code replacement table entry that represents a potential code replacement for a function or operator, returned as an object. Maps the conceptual representation of a function or operator,conceptualSpecification, to the C/C++ implementation representation,implementationSpecification.

Version History

Introduced in R2015a