SystemVerilog Class スコープ演算子

タイトルは適当につけていますが、規格上の説明は

Class scope resolution operator ::

のようになってます。

  • サンプルコード
class hoge;
  static function void show(int a, int b);
    $display("- a = %3d, b = %3d", a, b);
  endfunction
endclass

module testbench;

  int i,j;
  hoge cl_hoge = new;

  initial begin
    i = 10; j = 4;
    cl_hoge.show(i, j);
    hoge::show(i,j);
    $finish;
  end

endmodule
  • 実行結果
# - a =  10, b =   4
# - a =  10, b =   4

解説

記述と実行結果のとおりで、「::」を使うことで、
クラスのメンバ関数を直接使うことができます。
ただし、task/function は static でないといけません。