Vengineerの妄想(準備期間)

人生は短いけど、長いです。人生を楽しみましょう!

Bluespec SystemVerilog : 関数の定義(function)

Verification Engineerの戯言

Bluespec SystemVerilogでの関数は、SystemVerilogとほとんど同じ。

リファレンス・ガイドのPage.60によると、

    function Bool notFn (Bool x);
      if (x) notFn = False;
      else notFn = True;
    endfunction: notFn

    function Bool notFn (Bool x);
      if (x) return False;
      else return True;
    endfunction: notFn

上の例は、関数名に戻り値を代入する方法。下の例は、returnで戻り値を指定する方法。
関数の再帰呼び出しもできる。

また、次のような方法でもOK!

    function Bool notFn (Bool x) = (x ? False : True);

この表記、簡単な関数だと、楽ちん。

検証、Verification、Bluespec SystemVerilog