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
config_rtl -reset
command. 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.
Syntax
Place the pragma in the C source within the boundaries of the variable life cycle.
set_directive_reset <location> [ variable=<a> | off ]
Where:
-
location>
- Specifies the location (in the format
function[/label]
) at which the variable is defined. -
variable=<a>
- Specifies the variable to which the RESET pragma is applied.
-
off
oroff=true
- Indicates that reset is not generated for the specified variable.
Examples
Adds reset to variable a
in function
foo
even when the global reset
(config_rtl -reset
) setting is none
or control
.
set_directive_reset foo a
Removes reset from variable static int
a
in function foo
even when
the global reset setting is state
or
all
.
set_directive_reset -off foo a
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(...);
}
set_directive_reset
command specified for the function
top
shown above would be as follows:
set_directive_reset top variable=b
set_directive_reset top variable=c
set_directive_reset top variable=d
set_directive_reset top variable=t.a
set_directive_reset top variable=s.a
set_directive_reset top variable=s.a1