Create implementation argument from specified properties and add to implementation arguments for code replacement table entry
creates an implementation argument from specified properties and adds the argument
to the implementation arguments for a code replacement table entry.arg
= createAndAddImplementationArg(hEntry
,argType
,varargin
)
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).
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' );
hEntry
— Handle to a code replacement table entryThe hEntry
is a handle to a code replacement
table entry previously returned by instantiating a code replacement entry
class, such as
or
hEntry
=
RTW.TflCFunctionEntry
.hEntry
=
RTW.TflCOperationEntry
Example: op_entry
argType
— Specifies the argument type to create'RTW.TflArgNumeric'
| character vector | string scalarThe argType
is a character vector or string
scalar that specifies the argument type to create. Use
'RTW.TflArgNumeric'
for numeric.
Example: 'RTW.TflArgNumeric'
varargin
— Name-value pairs that specify the implementation argumentExample: 'Name','u1'
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
.
'Name','u1'
'Name'
— Specifies the argument nameExample: 'Name','u1'
'IOType'
— Specifies the I/O type of the argument'RTW_IO_INPUT'
| character vector | string scalarUse 'RTW_IO_INPUT'
for input.
Example: 'IOType','RTW_IO_INPUT'
'IsSigned'
— Indicates whether the argument is signedtrue
(default) | false
Boolean value that, when set to true
, indicates
that the argument is signed.
Example: 'IsSigned',true
'WordLength'
— Specifies the word length, in bits, of the argument16
(default) | integer valueExample: 'WordLength',16
'DataTypeMode'
— Specifies the data type mode of the argument'Fixed-point: binary point
scaling'
(default) | 'Fixed-point: slope and bias scaling'
| 'boolean'
| 'double'
| 'single'
You can specify either DataType
(with
Scaling
) or DataTypeMode
, but
do not specify both.
Example: 'DataTypeMode','Fixed-point: binary point
scaling'
'DataType'
— Specifies the data type of the argument'Fixed'
(default) | 'boolean'
| 'double'
| 'single'
Example: 'DataType','Fixed'
'Scaling'
— Specifies the data type scaling of the argument'BinaryPoint'
(default) | 'SlopeBias'
Use 'BinaryPoint'
for binary-point scaling or
'SlopeBias'
for slope and bias scaling.
Example: 'Scaling','BinaryPoint'
'Slope'
— Specifies the slope of the argument1.0
(default) | floating-point valueYou can optionally specify either this parameter or a combination of
the SlopeAdjustmentFactor
and
FixedExponent
parameters, but do not specify
both.
Example: 'Slope',1.0
'SlopeAdjustmentFactor'
— Specifies the slope adjustment factor (F
) part of the slope,
F
2E
,
of the argument1.0
(default) | floating-point valueYou 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
'FixedExponent'
— Specifies the fixed exponent (E
) part of the slope, F
2E
,
of the argument-15
(default) | integer valueYou 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
'Bias'
— Specifies the bias of the argument0.0
(default) | floating-point valueExample: 'Bias',0.0
'FractionLength'
— Specifies the fraction length of the argument15
(default) | integer valueExample: 'FractionLength',0
'Value'
— Specifies the initial value of the argument0
(default) | constant valueUse 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
u1
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
arg
— Handle to the created implementation argumentSpecifying the return argument in the
createAndAddImplementationArg
function call is
optional.