3.6.1.1 Introduction to Pragmas

SmartHLS accepts pragma directives in the source code to guide the hardware generation. This reference section explains all of the pragmas available for SmartHLS.

The pragmas follow the following syntax:
#pragma HLS <category> <feature> <parameter>(<value>)
The category refers to the general usage class of the pragma. Each pragma has one of the following categories:
  • function: configure a hardware function.
  • loop: configure loop optimizations.
  • interface: configure hardware interfaces (arguments / global variables).
  • memory: configure hardware memory implementation.

Each category can have different configurable features. Some categories / features have parameters to passed to the pragma. A parameter can be optional with a default behaviour if not specified. The value of a parameter can be either integer, boolean (true|false), name (variable / argument), or a set of pre-specified values.

Note

Important:

For integer parameters, the user is allowed to use constants (or expressions of constants) defined using #define directive. For example, this is allowed:

#define N 10
void fun() {
  #pragma HLS loop unroll factor(N+1)
  for (int i = 0; i < 100; i++)
    ...
}
The pragma position is not arbitrary and placing the pragma in an incorrect position will cause an error. Each pragma can has one of the following positions:
  • At the beginning of function definition block before any other statements.
  • Before global / local variable declaration.
  • Before loop block.