Create conceptual argument from specified properties and add to conceptual arguments for code replacement table entry
This example shows how to use
thecreateAndAddConceptualArg
function to specify
conceptual output and input arguments for a code replacement operator
entry.
For examples of fixed-point arguments that use relative scaling or relative slope/bias values, see Net Slope Scaling Code Replacement and Equal Slope and Zero Net Bias Code Replacement.
op_entry = RTW.TflCOperationEntry; . . . createAndAddConceptualArg(op_entry, 'RTW.TflArgNumeric', ... 'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'IsSigned', true, ... 'WordLength', 32, ... 'FractionLength', 0); createAndAddConceptualArg(op_entry, 'RTW.TflArgNumeric',... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT',... 'IsSigned', true,... 'WordLength', 32, ... 'FractionLength', 0 ); createAndAddConceptualArg(op_entry, 'RTW.TflArgNumeric',... 'Name', 'u2', ... 'IOType', 'RTW_IO_INPUT',... 'IsSigned', true,... 'WordLength', 32, ... 'FractionLength', 0 );
These examples show some common type specifications using
createAndAddConceptualArg
.
hEntry = RTW.TflCOperationEntry; . . . % uint8: createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'IsSigned', false, ... 'WordLength', 8, ... 'FractionLength', 0 ); % single: createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'DataTypeMode', 'single' ); % double: createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'DataTypeMode', 'double' ); % boolean: createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'DataTypeMode', 'boolean' ); % Fixed-point using binary-point-only scaling: createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'CheckSlope', true, ... 'CheckBias', true, ... 'DataTypeMode', 'Fixed-point: binary point scaling', ... 'IsSigned', true, ... 'WordLength', 32, ... 'FractionLength', 28); % Fixed-point using [slope bias] scaling: createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'CheckSlope', true, ... 'CheckBias', true, ... 'DataTypeMode', 'Fixed-point: slope and bias scaling', ... 'IsSigned', true, ... 'WordLength', 16, ... 'Slope', 15, ... 'Bias', 2);
hEntry
— Handle to a code replacement table entry The hEntry
is a handle to a code replacement
table entry previously returned by instantiating a code replacement table
entry class, such as
or
hEntry
=
RTW.TflCFunctionEntry
.hEntry
=
RTW.TflCOperationEntry
Example: op_entry
argType
— Specifies the argument type to create'RTW.TflArgNumeric'
| 'RTW.TflArgMatrix'
The argType
is a character vector or string
scalar that specifies the argument type to create. Use
'RTW.TflArgNumeric'
for numeric or
'RTW.TflArgMatrix'
for matrix.
Example: 'RTW.TflArgNumeric'
varargin
— Name-value pair arguments that specify the conceptual argumentExample: 'Name','y1'
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','y1'
'Name'
— Specifies the argument nameExample: 'Name','y1'
'IOType'
— Specifies the I/O type of the argument'RTW_IO_INPUT'
(default) | 'RTW_IO_OUTPUT'
Use value 'RTW_IO_INPUT'
for input or value
'RTW_IO_OUTPUT'
.
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) | integerInteger specifying the word length, in bits, of the argument. The
default is 16
.
Example: 'WordLength',16
'CheckSlope'
— Selects whether to check that the slope value of the argument exactly matches the call-site slope valuetrue
(default) | false
Boolean flag that, when set to true
for a
fixed-point argument, causes code replacement request processing to
check that the slope value of the argument exactly matches the call-site
slope value.
Specify true
if you are matching a specific [slope
bias] scaling combination or a specific binary-point-only scaling
combination on fixed-point operator inputs and output. Specify
false
if you are matching relative scaling or
relative slope and bias values across fixed-point operator inputs and
output.
Example: 'CheckSlope',true
'CheckBias'
— Selects whether to check that the bias value of the argument exactly matches the call-site bias valuetrue
(default) | false
Boolean flag that, when set to true
for a
fixed-point argument, causes code replacement request processing to
check that the bias value of the argument exactly matches the call-site
bias value.
Specify true
if you are matching a specific [slope
bias] scaling combination or a specific binary-point-only scaling
combination on fixed-point operator inputs and output. Specify
false
if you are matching relative scaling or
relative slope and bias values across fixed-point operator inputs and
output.
Example: 'CheckBias',true
'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'
Specify the data type scaling of the argument as
'BinaryPoint'
for binary-point scaling or
'SlopeBias'
for slope and bias scaling.
Example: 'Scaling','BinaryPoint'
'Slope'
— Specifies the slope of the argument1
(default) | floating-point valueIf you are matching a specific [slope bias] scaling combination on
fixed-point operator inputs and output, specify either this parameter or
a combination of the SlopeAdjustmentFactor
and
FixedExponent
parameters.
Example: 'Slope',1.0
'SlopeAdjustmentFactor'
— Specifies the slope adjustment factor (F
) part of the slope,
F
2E
,
of the argument1.0
(default) | floating-point valueIf you are matching a specific [slope bias] scaling combination on
fixed-point operator inputs and output, specify either the
Slope
parameter or a combination of this
parameter and the FixedExponent
parameter.
Example: 'SlopeAdjustmentFactor',1.0
'FixedExponent'
— Specifies the fixed exponent (E
) part of the slope, F
2E
,
of the argument-15
(default) | integer valueIf you are matching a specific [slope bias] scaling combination on
fixed-point operator inputs and output, specify either the
Slope
parameter or a combination of this
parameter and the SlopeAdjustmentFactor
parameter.
Example: 'FixedExponent',-15
'Bias'
— Specifies the bias of the argument0.0
(default) | floating-point valueSpecify this parameter if you are matching a specific [slope bias] scaling combination on fixed-point operator inputs and output.
Example: 'Bias',2.0
'FractionLength'
— Specifies the fraction length for the argument15
(default) | integer valueSpecify this parameter if you are matching a specific binary-point-only scaling combination on fixed-point operator inputs and output.
Example: 'FractionLength',15
'BaseType'
— Specifies the base data type for which a matrix argument is validExample: 'BaseType','double'
'DimRange'
— Specifies the dimensions for which a matrix argument is validYou can also specify a range of dimensions specified in the format
[Dim1Min Dim2Min ... DimNMin; Dim1Max Dim2Max ...
DimNMax]
. For example, [2 2; inf inf]
means a two-dimensional matrix of size 2x2 or larger.
Example: 'DimRange',[2 2]
arg
— Handle to the created conceptual argumentThe arg
is a handle to the created conceptual
argument. Specifying the return argument in the
createAndAddConceptualArg
function call is
optional.