Main Content

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. The HDL Coder™ software 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 for Defining Properties of Primary Inputs

MethodAdvantagesDisadvantages
 

Define Input Properties by Example at the Command Line

Note

If you define input properties programmatically in the MATLAB file, you cannot use this method

  • Easy to use

  • Does not alter original MATLAB code

  • Designed for prototyping a function that has a few primary inputs

  • Must be specified at the command line every time you invoke (unless you use a script)

  • Not efficient for specifying memory-intensive inputs such as large structures and arrays

 

Define Input Properties Using assert Statements in MATLAB Code

  • Integrated with MATLAB code; no need to redefine properties each time you invoke HDL Coder

  • Provides documentation of property specifications in the MATLAB code

  • Efficient for specifying memory-intensive inputs such as large structures

  • Uses complex syntax

  • HDL Coder project files do not currently recognize properties defined programmatically. If you are using a project, you must reenter the input types in the project.

Properties to Specify

If your primary function has inputs, you must specify the following properties for each input.

ForSpecify properties
 ClassSizeComplexitynumerictypefimath
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.

PropertyDefault
classdouble
sizescalar
complexityreal
numerictypeNo default
fimathhdlfimath

Supported Classes

The following table presents the class names supported by HDL Coder.

Class NameDescription
logicalLogical array of true and false values
charCharacter array
int88-bit signed integer array
uint88-bit unsigned integer array
int1616-bit signed integer array
uint1616-bit unsigned integer array
int3232-bit signed integer array
uint3232-bit unsigned integer array
singleSingle-precision floating-point or fixed-point number array
doubleDouble-precision floating-point or fixed-point number array
embedded.fiFixed-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 input numerictype and fimath properties.