使用 <= 与 =。 class 任务中的赋值运算符

Using <= vs =. Assignment operator in a class task

我很困惑为什么我不能使用 <= 在我的 class 中分配变量?我以前在任务中使用过 <=,这只是我分配给 class 局部变量的问题吗?这是有问题的代码:

package MyPackage;

class test;
  logic b_val;

  task set_val;
    //this.b_val = 1'b1;   // WORKS
    this.b_val <= 1'b1; // ERROR
  endtask
endclass // test

endpackage

module Test;
  import MyPackage::*;
  test t1 = new;

  initial 
    begin  
      t1.set_val;
    end  
endmodule : Test

我收到的错误是:

# ** Fatal: (SIGSEGV) Bad handle or reference.
#    Time: 0 ns  Iteration: 0  Process: /Test/#INITIAL#18 File: C:/Projects/SystemVerilog/sim/test.sv
# Fatal error in Task MyPackage/test::set_val at C:/Projects/SystemVerilog/sim/test.sv line 8

允许对 class 成员进行 non-blocking 赋值是 SystemVerilog 的一项相对较新的功能。您将需要 2012 年之后发布的模拟器版本。即使如此,我也无法在早期版本中重现您的错误。