createAndAddImplementationArg - Create implementation argument from specified properties and add to

        implementation arguments for code replacement table entry - MATLAB ([original](https://www.mathworks.com/help/ecoder/ref/createandaddimplementationarg.html)) ([raw](?raw))

Create implementation argument from specified properties and add to implementation arguments for code replacement table entry

Syntax

Description

[arg](#d126e20976) = createAndAddImplementationArg([hEntry](#d126e20390),[argType](#mw%5F7e6025cb-04e8-447f-ae80-23ba9e951f5c),Name=[Name](#mw%5Fa82fa84c-eef2-4f3c-b4ae-558071c33de7),[varargin](#d126e20521)) creates an implementation argument from specified properties and adds the argument to the implementation arguments for a code replacement table entry.

Implementation arguments must describe fundamental numeric data types, such asdouble, single, int32,int16, int8, uint32,uint16, uint8, boolean, or 'logical' (not fixed-point data types).

example

Examples

collapse all

This example shows how to use thecreateAndAddImplementationArg function with thecreateAndSetCImplementationReturn function to specify the output and input arguments for an operator implementation.

op_entry = RTW.TflCOperationEntry; % . % . % . createAndSetCImplementationReturn(op_entry, 'RTW.TflArgNumeric', ... 'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'IsSigned', true, ... 'WordLength', 32, ... 'FractionLength', 0);

createAndAddImplementationArg(op_entry, 'RTW.TflArgNumeric',... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT',... 'IsSigned', true,... 'WordLength', 32, ... 'FractionLength', 0 );

createAndAddImplementationArg(op_entry, 'RTW.TflArgNumeric',... 'Name', 'u2', ... 'IOType', 'RTW_IO_INPUT',... 'IsSigned', true,... 'WordLength', 32, ... 'FractionLength', 0 );

These examples show some common type specifications usingcreateAndAddImplementationArg.

hEntry = RTW.TflCOperationEntry; % . % . % . % uint8: createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'Type', 'uint8');

% single: createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'Type', 'single' );

% double: createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'Type', 'double' );

% boolean: createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'Type', 'boolean' );

% complex: createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'Type', 'cint16' );

% matrix of complex integers: createAndAddImplementationArg(hEntry, 'RTW.TflArgMatrix', ... 'Name', 'mat_in1', ... 'IOType', 'RTW_IO_INPUT', ... 'BaseType', 'cint8', ... 'DimRange', [2 1; Inf Inf]);

These examples show how to specify types by using several properties of the data type.

hEntry = RTW.TflCOperationEntry; % . % . % . % uint8: createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'IsSigned', false, ... 'WordLength', 8, ... 'FractionLength', 0 );

% single: createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'DataTypeMode', 'single' );

% double: createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'DataTypeMode', 'double' );

% boolean: createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'DataTypeMode', 'boolean' );

This example shows how to add an input argument that is a numeric constant to the implementation function. The actual value of the constant is set during code generation.

hEntry = RTW.TflCOperationEntry; % . % . % . createAndAddImplementationArg(hEntry, 'RTW.TflArgNumericConstant', ... 'Name', 'fl_in1', ... 'IOType', 'RTW_IO_INPUT', ... 'IsSigned', false, ... 'WordLength', 32, ... 'FractionLength', 0, ... 'Value', 0);

This example shows how to create an input argument that is a two-dimensional matrix of size 2-by-1 or larger and has base typeuint8.

hEntry = RTW.TflCOperationEntry; % . % . % . createAndAddImplementationArg(hEntry, 'RTW.TflArgMatrix', ... 'Name', 'mat_in1', ... 'IOType', 'RTW_IO_INPUT', ... 'DimRange', [2 1; Inf Inf], ... 'BaseType', 'uint8');

This example shows how to create an implementation argument that is a structure with elements bus1 andbus2.

hEnt = RTW.TflEntry; myStruct.Identifier = 'myBus'; elem1.Identifier = 'bus1'; elem1.Type= 'int32'; elem2.Identifier = 'bus2'; elem2.Type = 'double'; myStruct.Elements = [elem1, elem2]; hEnt.createAndAddImplementationArg('RTW.TflArgStruct','Name','u1','StructData',myStruct);

Input Arguments

collapse all

The hEntry is a handle to a code replacement table entry previously returned by instantiating a code replacement entry class, such as _`hEntry`_ = RTW.TflCFunctionEntry or_`hEntry`_ = RTW.TflCOperationEntry.

Example: op_entry

Argument type to create, specified as a character vector or string scalar. Specify one of these types of arguments.

Name of the argument to create, specified as a character vector or string scalar. You may specify:

Example: 'Name','y1'

Example: 'Name','u1'

Example: 'IOType','RTW_IO_INPUT'

Name-Value Arguments

collapse all

Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'IOType','RTW_IO_INPUT'

Use 'RTW_IO_INPUT' for input.

Example: 'IOType','RTW_IO_INPUT'

Data type of the argument, specified as a character vector or string scalar. You can specify built-in MATLAB data types such asuint8, boolean,double, and others. You can also specify data types that you create by using the fixdt function, such as fixdt(1,16,2). When you specify theType, you do not need to specify other properties of the type, such as the signedness or word length.

Example: 'Type','uint8'

Example: 'Type','fixdt(1,16,2)'

Boolean value that, when set to true, indicates that the argument is signed.

Example: 'IsSigned',true

You can specify either DataType (withScaling) or DataTypeMode, but do not specify both.

Example: 'DataTypeMode','Fixed-point: binary point scaling'

Example: 'DataType','Fixed'

Use 'BinaryPoint' for binary-point scaling or'SlopeBias' for slope and bias scaling.

Example: 'Scaling','BinaryPoint'

You can optionally specify either this parameter or a combination of the SlopeAdjustmentFactor andFixedExponent parameters, but do not specify both.

Example: 'Slope',1.0

You can optionally specify either the Slope parameter or a combination of this parameter and theFixedExponent parameter, but do not specify both.

Example: 'SlopeAdjustmentFactor',1.0

You can optionally specify either the Slope parameter or a combination of this parameter and theSlopeAdjustmentFactor parameter, but do not specify both.

Example: 'FixedExponent',0

Example: 'FractionLength',0

Use this parameter only to set the value of injected constant input arguments, such as arguments that pass fraction-length values or flag values, in an implementation function signature. Do not use it for standard generated input arguments, such asu1 u2. You can supply a constant input argument that uses this parameter anywhere in the implementation function signature, except as the return argument.

You can inject constant input arguments into the implementation signature for code replacement table entries. If the argument values or the number of arguments required depends on compile-time information, you can use custom matching. For more information, see Customize Match and Replacement Process.

Example: 'Value',0

Elements of the structure for a structure argument, specified as a structure in which each field identifies an element of the structure.

Example: 'StructElements',elements

Output Arguments

collapse all

Specifying the return argument in thecreateAndAddImplementationArg function call is optional.

Version History

Introduced in R2007b

expand all

You can now specify pre-defined data types for the argument by using theType argument. Specify built-in MATLAB data types or fixed-point data types. When you use the Type argument, you do not need to specify other properties of the data type such asIsSigned or WordLength.