Vengineerの妄想(準備期間)

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

Bluespec SystemVerilog : HELLO WORLDを学ぶ(その1)

Verification Engineerの戯言

Bluespec SystemVerilog : でHello WorldBSV Hello World Tutorialで学びます。

このHELLO WORLDについて、6回に分けて書きていきます。
Bluespec SystemVerilogのコードは、BSV Hello World Tutorialの中と同じものです(コードの著作権は、Bluespecにあります)。

Bluespec SystemVerilogでは、package/endpackageで囲む必要があります。SystemVerilogのpackage/endpackageのようなものです。
コメントもSystemVerilogと同じ // です。

package/endpackageは必要ではないですが、強く推奨しています。

file : FirstAttempt.bsv

ファイル名は、パッケージ名.bsv になります(拡張子は、.bsv です)

    package FirstAttempt;

        // My first design in the cool Bluespec language

    endpackage

コンパイルするには、次のコマンドを実行します。

    % bsc FistAttempt.bsv

bscがBluespec SystemVerilogのコンパイラです。

この例では、コンパイルしても何も起こないです。

つぎに文字列を定義するには、SystemVerilogと同じような String 型の変数を使います
(SystemVerilogでは、string 型:最初が小文字)

    package FirstAttempt;

      // My first design in the cool Bluespec language

      String s = "Hello world";
    endpackage
式の後ろには、セミコロン( ; )が必要なものSystemVerilogと同じです。

Bluespec SystemVerilogでは、SystemVerilogと同じように module/endmodule で1つのデザインをモジュールとして記述します。
モジュール名の最初は、mk で始まります。

    package FirstAttempt;

      // My first design in the cool Bluespec language

      String s = "Hello world";

      module mkAttempt;
      endmodule

    endpackage

ここでコンパイルすると、
    % bsc FistAttempt.bsv
    Error: "FirstAttempt.bsv", line 7, column 19: (P0005)
      Unexpected `;'; expected `#', module interface, or dynamic (port-like) args    
とエラーになります。エラーを無くすには、mkAttemptの後に(Empty)を追加します。

    package FirstAttempt;

      // My first design in the cool Bluespec language

      String s = "Hello world";

      module mkAttempt(Empty);
      endmodule

    endpackage

検証、Verification、Bluespec SystemVerilog