set_directive_reset - 2023.2 简体中文

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

Document ID
UG1399
Release Date
2023-12-18
Version
2023.2 简体中文

描述

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

复位端口用于在应用复位信号时,立即将连接到复位端口的寄存器和块 RAM 还原为初始值。在全局范围内,config_rtl -reset 命令可用于控制 RTL 复位端口是否存在及其行为。复位配置设置包含定义复位极性以及指定使用同步复位还是异步复位的功能,但更重要的是,它可通过复位选项来控制应用复位信号时所复位的寄存器。如需了解更多信息,请参阅 控制初始化与复位行为

通过 RESET 编译指示可提供更具体的复位控制。对于全局变量或静态变量,RESET 编译指示用于显式启用复位(前提是不存在任何变量),或者可通过设为 off 关闭此编译指示来从复位中移除变量。当设计中存在静态阵列或全局阵列时,该选项非常实用。

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

语法

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

set_directive_reset <location> [ variable=<a> | off ]

其中:

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

示例

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

set_directive_reset foo a

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

set_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 函数指定的 set_directive_reset 命令将如下所示:
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

示例 3