createAndAddImplementationArg

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

Description

example

arg = createAndAddImplementationArg(hEntry,argType,varargin) 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 as double, single, int32, int16, int8, uint32, uint16, uint8, boolean, or 'logical' (not fixed-point data types).

Examples

collapse all

This example shows how to use thecreateAndAddImplementationArg function with the createAndSetCImplementationReturn 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 using createAndAddImplementationArg.

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

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

The argType is a character vector or string scalar that specifies the argument type to create. Use 'RTW.TflArgNumeric' for numeric.

Example: 'RTW.TflArgNumeric'

Example: 'Name','u1'

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'Name','u1'

Example: 'Name','u1'

Use 'RTW_IO_INPUT' for input.

Example: 'IOType','RTW_IO_INPUT'

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

Example: 'IsSigned',true

Example: 'WordLength',16

You can specify either DataType (with Scaling) 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 and FixedExponent 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 the FixedExponent 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 the SlopeAdjustmentFactor parameter, but do not specify both.

Example: 'FixedExponent',0

Example: 'Bias',0.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 as u1u2. 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

Output Arguments

collapse all

Specifying the return argument in the createAndAddImplementationArg function call is optional.

Introduced in R2007b