Specify Properties of Entry-Point Function Inputs
When to Specify Input Properties
If you supply a test bench for your MATLAB® algorithm, you do not need to specify the primary function inputs manually. HDL Coder™ uses the test bench to infer the data types.
Why You Must Specify Input Properties
HDL Coder must determine the properties of all variables in the MATLAB files at compile time. To infer variable properties in MATLAB files, HDL Coder must be able to identify the properties of the inputs to the primary function, also known as the top-level or entry-point function. Therefore, if your primary function has inputs, you must specify the properties of these inputs, to HDL Coder. If your primary function has no input parameters, HDL Coder can compile your MATLAB file without modification. You do not need to specify properties of inputs to local functions or external functions called by the primary function.
Note
Your primary function cannot be within a MATLAB namespace. Create a wrapper function as the primary function outside the namespace. Call the desired function within the new function as the primary function.
If you use the tilde (~) character to specify unused function inputs in an HDL Coder project, and you want a different type to appear in the generated code, specify the type. Otherwise, the inputs default to real, scalar doubles.
Methods of Input-Type Specification
Method | Advantages | Disadvantages |
---|---|---|
Specify Input Types at the Command Line Note You cannot use this method if you define input properties
by using
|
|
|
|
|
Properties to Specify
If your primary function has inputs, you must specify the following properties for each input.
For | Specify properties | ||||
---|---|---|---|---|---|
Class | Size | Complexity | numerictype | fimath | |
Fixed-point inputs |
|
|
|
|
|
Other inputs |
|
|
|
The following data types are not supported for primary function inputs, although you can use them within the primary function:
structure
matrix
Variable-size data is not supported in the test bench or the primary function.
Default Property Values
HDL Coder assigns the following default values for properties of primary function inputs.
Property | Default |
---|---|
class | double |
size | scalar |
complexity | real |
numerictype | No default |
fimath | hdlfimath |
Supported Classes
The following table presents the class names supported by HDL Coder.
Class Name | Description |
---|---|
logical | Logical array of true and false values |
char | Character array |
int8 | 8-bit signed integer array |
uint8 | 8-bit unsigned integer array |
int16 | 16-bit signed integer array |
uint16 | 16-bit unsigned integer array |
int32 | 32-bit signed integer array |
uint32 | 32-bit unsigned integer array |
single | Single-precision floating-point or fixed-point number array |
double | Double-precision floating-point or fixed-point number array |
embedded.fi | Fixed-point number array |
Rules for Specifying Properties of Primary Inputs
When specifying the properties of primary inputs, follow these rules:
You must specify the class of all primary inputs. If you do not specify the size or complexity of primary inputs, they default to real scalars.
For each primary function input whose class is fixed point (
fi
), you must specify the inputnumerictype
andfimath
properties.