首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SystemVerilog:自动变量不能为静态reg提供非阻塞赋值。

SystemVerilog:自动变量不能为静态reg提供非阻塞赋值。
EN

Stack Overflow用户
提问于 2018-09-17 22:07:05
回答 1查看 2K关注 0票数 0

当我实际做了一个静态寄存器之后,我就开始得到这个错误。

这符合Quartus公司的规定:

代码语言:javascript
复制
task InitAutoRefresh;

       reg [$clog2(AUTOREFRESH_CLOCKS):0] AutoRefreshCounter = 0;

       AutoRefreshCounter <= AutoRefreshCounter + 1;
       InitState <= (AutoRefreshCounter < AUTOREFRESH_CLOCKS) ? InitState : InitState + 1;       

       InitCmd <= (AutoRefreshCounter == 0) ? CMD_AR : CMD_NOP;

endtask

但是Modelsim给了我这个错误:

代码语言:javascript
复制
# ** Error (suppressible): C:/projects/Camera-RAM-VGA/Ram.sv(137): (vlog-2244) Variable 'AutoRefreshCounter' is implicitly static. You must either explicitly declare it as static or automatic
# or remove the initialization in the declaration of variable.

现在,当我在static前面添加reg [$clog2(AUTOREFRESH_CLOCKS):0] AutoRefreshCounter = 0;时,Quartus给出了这个错误(看起来与我的更改正好相反):

代码语言:javascript
复制
Error (10959): SystemVerilog error at Ram.sv(139): illegal assignment - automatic variables can't have non-blocking assignments

这指向我刚刚添加了static关键字的寄存器!

我能想到的唯一可能的解释是,当我将static添加到这个单一的reg中时,它开始将其他的规则视为automatic,但是错误消息中的行号是错误的。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-09-17 22:41:42

我只需将AutoRefreshCounter的声明移到任务之外。然后很明显,变量只能在0时刻初始化一次。(这就是首先出现“隐式静态”错误消息的原因)。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52376303

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档