如果 "abc_seq_item m_tx;" 不是 "task run_phase(uvm_phase phase)" 中的第一个可执行行,则 UVM 编译失败

UVM compile fail if "abc_seq_item m_tx;" is not the first executable line in "task run_phase(uvm_phase phase)"

这种情况我遇到过几次。

在用户定义的 uvm 驱动程序中,如果我像下面那样输入 run_phase,它会失败。

task run_phase(uvm_phase phase);
    #1; // It fail even if I put something like `uvm_info() instead of "#1".
    abc_seq_item m_tx;
    ...

这种类似的行为也可能发生在序列 class.

task body();
    #1;
    abc_seq_item m_tx;
    ...

如果“abc_seq_item m_tx”是任务中的第一个可执行文件,它将通过。 请问具体是什么原因?

这是来自 Verilog 的一般 BNF 规则,即在任何程序代码块中,声明必须位于任何语句之前。此规则适用于任何任务、函数、begin/end、fork/join 块。我不确定 LRM 中是否有一个特定的地方用文字提到了这一点,但它在 BNF 中编纂了你寻找 block_item_declaration