【问题标题】:SystemVerilog: Automatic variables cannot have non-blocking assignments appearing for static regSystemVerilog:自动变量不能为静态 reg 出现非阻塞赋值
【发布时间】:2018-09-17 22:07:05
【问题描述】:

在我实际将寄存器设为静态后,我开始收到此错误。

这在 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.

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

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

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

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

【问题讨论】:

    标签: static system-verilog modelsim quartus


    【解决方案1】:

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

    【讨论】:

    • 这就是我现在最终要做的事情。我想将其保留在任务中,以便重用代码。我是一个新手,Verilog 让我在尝试代码重用方面遇到了困难(就像我在程序编程中所做的那样)
    猜你喜欢
    • 1970-01-01
    • 2013-01-14
    • 2021-12-29
    • 1970-01-01
    • 2019-08-19
    • 2012-12-01
    • 1970-01-01
    • 2012-06-23
    • 2013-12-03
    相关资源
    最近更新 更多