createAndAddImplementationArg
Create implementation argument from specified properties and add to implementation arguments for code replacement table entry
Description
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,Name=Name,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).
Examples
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', ... '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 type
uint8.
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 and
bus2.
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
The 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
Argument type to create, specified as a character vector or string scalar. Specify one of these types of arguments.
'RTW.TflArgNumeric'— numeric argument'RTW.TflArgNumericConstant'— numeric constant argument'RTW.TflArgMatrix'— matrix argument'RTW.TflArgComplex'— complex argument'RTW.TflArgChar'— character argument'RTW.TflArgVoid'— void argument'RTW.TflArgStruct'— structure argument
Name of the argument to create, specified as a character vector or string scalar. You may specify:
'u1','u2', or follow the format'un'for input arguments'y1','y2', or follow the format'yn'for output argumentsOther character vector or string scalar names for input or output arguments
Example: 'Name','y1'
Example: 'Name','u1'
Example: 'IOType','RTW_IO_INPUT'
Name-Value Arguments
Specify optional pairs of arguments as
Name1=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 as
uint8, 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 the
Type, 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
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
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
Specifying the return argument in the
createAndAddImplementationArg function call is
optional.
Version History
Introduced in R2007bYou can now specify pre-defined data types for the argument by using the
Type 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 as
IsSigned or WordLength.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)