pragma HLS reset - 2023.2 English

Vitis High-Level Synthesis User Guide (UG1399)

Document ID
UG1399
Release Date
2023-12-18
Version
2023.2 English

Description

The RESET pragma or directive adds or disables reset ports for specific state variables (global or static).

The reset port is used to restore the registers and block RAM, connected to the port, to an initial value any time the reset signal is applied. Globally, the presence and behavior of the RTL reset port is controlled using the syn.rtl.reset configuration settings (or config_rtl -reset). The reset configuration settings include the ability to define the polarity of the reset, and specify whether the reset is synchronous or asynchronous, but more importantly it controls, through the reset option, which registers are reset when the reset signal is applied. For more information, see Controlling Initialization and Reset Behavior.

More specific control over reset is provided through the RESET pragma. For global or static variables the RESET pragma is used to explicitly enable a reset when none is present, or the variable can be removed from the reset by turning off the pragma. This can be particularly useful when static or global arrays are present in the design.

Note: For public variables of a class, the RESET pragma must be used as the reset configuration settings only apply to variables declared at the function or file level. In addition, the RESET pragma must be applied to an object of the class in the top-function or sub-function, and cannot be applied to private variables of the class.

Syntax

Place the pragma in the C source within the boundaries of the variable life cycle.

#pragma HLS reset variable=<a> off

Where:

variable=<a>
Specifies the variable to which the RESET pragma is applied.
off
Indicates that reset is not generated for the specified variable.

Example 1

This example adds reset to the variable a in function foo even when the global reset setting is none or control.

void foo(int in[3], char a, char b, char c, int out[3]) {
#pragma HLS reset variable=a 

Example 2

Removes reset from variable a in function foo even when the global reset setting is state or all.

void foo(int in[3], char a, char b, char c, int out[3]) {
#pragma HLS reset variable=a off

Example 3

The following example shows the use of the RESET pragma or directive with class variables and methods. A variable declared in a class must be a public static variable in the class and can have the RESET pragma specified for the variable in a method of the class, or after an object of the class has been created in the top function or sub-function of the HLS design.

class bar {
public:
  static int a; // class level static; must be public
  int a1;       // class-level non-static; must be public
  bar(...) {
  // #pragma reset does not work here for a or a1
  }
  // this is the function that is called in the top
  void run(...) {
  // #pragma reset does not work here for non-static variable a1
  // but does work for static variable a
  #pragma reset variable=a
  }
};
static int c; // file level 
int d; // file level
void top(...) {
#pragma HLS top
  static int b; // function level
  bar t;
  static bar s;

  // #pragma reset works here for b, c and d, as well as t and s members
  // except for t.a1 because it is not static
  #pragma reset variable=b
  #pragma reset variable=c
  #pragma reset variable=d
  #pragma reset variable=t.a
  #pragma reset variable=s.a
  #pragma reset variable=s.a1
  t.run(...); 
  s.run(...); 
}