SystemVerilog:自动变量不能为静态reg出现非阻塞分配

问题描述 投票:0回答:1

我实际上使寄存器静态后,我开始得到这个错误。

这符合Quartus的要求:

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给了我这个错误:

# ** 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 Quartus前面添加reg [$clog2(AUTOREFRESH_CLOCKS):0] AutoRefreshCounter = 0;时,给出了这个错误(看起来与我的更改相反):

Error (10959): SystemVerilog error at Ram.sv(139): illegal assignment - automatic variables can't have non-blocking assignments

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

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

static system-verilog modelsim quartus
1个回答
2
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.