syn.directive.reset - 2025.2 简体中文 - UG1399

Vitis 高层次综合用户指南 (UG1399)

Document ID
UG1399
Release Date
2026-01-22
Version
2025.2 简体中文

描述

RESET 编译指示或指令用于为特定状态变量(全局变量或静态变量)添加或禁用复位端口。

使用复位端口将与端口连接的寄存器和块 RAM 复原为初始值。您可在应用复位信号时,随时执行此操作。syn.rtl.reset 配置设置会对 RTL 复位端口的存在和行为进行全局配置。复位配置设置不仅能定义复位极性,还能指定采用同步复位还是异步复位。更重要的是,复位配置设置能控制在应用复位信号时对哪些寄存器进行复位。如需了解更多信息,请参阅 Vitis 高层次综合用户指南(UG1399) 中的“控制初始化与复位行为”。

RESET 编译指示可对复位进行更具体的控制。对于全局变量或静态变量,如果不存在任何复位,那么 RESET 编译指示会显式启用一个复位。您也可以通过 off 来关闭编译指示,以便从复位移除变量。当设计中存在静态阵列或全局阵列时,该选项非常实用。

注释: 对于类的公开变量,您必须使用 RESET 编译指示,因为复位配置设置仅适用于在函数级别或文件级别声明的变量。此外,您还必须将 RESET 编译指示应用于顶层函数或子函数中的类的对象。您无法将其应用于类的私有变量。

语法

将 C 语言源代码中的编译指示置于变量生命周期边界内。

syn.directive.reset=<location> [ variable=<a> | off=true ]

其中:

location>
指定您定义变量的位置(格式为 function[/label])。
variable=<a>
指定 RESET 编译指示应用到的变量。
offoff=true
指示针对指定变量不生成复位。

示例

foo 函数中的 a 变量添加复位,即使全局复位 (syn.rtl.reset) 设置为 nonecontrol 也是如此。

syn.directive.reset=foo a

foo 函数中的 static int a 变量移除复位,即使全局复位设置为 stateall 也是如此。

syn.directive.reset=off foo a

以下示例显示了如何将 RESET 编译指示或指令与类变量和方法搭配使用。在类中声明变量时,该变量必须是该类中的公共静态变量。您可以在类的方法中为变量创建 RESET 编译指示。在 HLS 设计的顶层函数或子函数中创建对象后,您也可以创建 RESET 编译指示。

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(...); 
} 
以下显示了为 top 函数指定的 syn.directive.reset 命令。
syn.directive.reset=top variable=b
syn.directive.reset=top variable=c
syn.directive.reset=top variable=d
syn.directive.reset=top variable=t.a
syn.directive.reset=top variable=s.a
syn.directive.reset=top variable=s.a1

另请参阅