FPGA開発日記

カテゴリ別記事インデックス https://msyksphinz.github.io/github_pages , English Version https://fpgadevdiary.hatenadiary.com/

RTLシミュレータ DSimに入門してみる (3. DSimをコマンドラインから立ち上げる方法の調査)

DSimをコマンドラインから立ち上げる方法について確認する。 環境は、WSL2 の Ubuntu 22.04 LTS を使用している。

DSimコマンドライン環境の有効化

前回までの環境を構築している状態で、

$ cd /home/msyksphinz/metrics-ca/dsim/20240422.9.0
$ source shell_activate.bash

ここで問題発生。shell_activate.bashがbash用に作成されており、zshの環境だと受け付けない。 zsh用には少し改良する必要があるようだ。

shell_activate_base=$(\cd $(dirname ${BASH_SOURCE:-$0}) && \pwd)

BASH_SOURCEが使えない場合に応じて引数の取得を変更しておくのと、cdなどをオリジナルのコマンドを使うために\cdを使用する(cdのたびにそのディレクトリを表示するように改造などしていると、このコマンドは動作しない)。

次にライセンスを有効化する:

$ export DSIM_LICENSE=/home/msyksphinz/metrics-ca/dsim-license.json

dsimコマンドラインの確認

これで動作を確認してみよう。

$ dsim -version
20240422.9.0
$ dsim -help
                                                             
Metrics tool usage: dsim [option(s)] [file(s)]
                                                                      
valid options:                                                                                                     
                                                                    
=============================== General options ===============================
                                                                                              
  -error MsgName                 Promote severity of MsgName (or "info" / "warning") to the "error" level
  -help                          Print summary of generally available command line options
  -info MsgName                  Demote severity of MsgName (or "warning" / "error") to the "info" level
  -l dsim.log                    Specify log file (compile/run)                                              
  -meter-env-vars ...            Specify environment variables, an optional values, to pass to licensing system
  -repro dsim.env                Reproduce compile/run from file
  -suppress MsgName              Suppress emission of MsgName (or "info" / "warning" / "error")
  -warn MsgName                  Change severity of MsgName (or "info" / "error") to the "warning" level 

DSimコマンドラインの実行

それでは、簡単なテストベンチを実行してみようかと思う。

  • simple_tb.sv
module tb;

initial begin
  $display ("Hello System Verilog");
end

endmodule // tb
$ dsim simple_tb.sv
=N:[UsageMeter (2024-08-11 00:39:56 +0900)] usage server initial connection
=N:[License] 
Licensed for Metrics Design Automation.
=N:[License] New lease granted.
Analyzing...
Elaborating...
  Top-level modules:
    $unit
    tb
  Found 4 unique specialization(s) of 4 design element(s).
Optimizing...
Building models...
PLI/VPI access: (none) 
Simulation time precision is 1ns.
  [1/4] module $root: 98 functions, 229 basic blocks
  [2/4] module $pkgs: 1 functions, 2 basic blocks
  [3/4] module tb: 2 functions, 4 basic blocks
  [4/4] package std: 23 functions, 64 basic blocks
Linking image.so...
Using default typical min/typ/max.
=S:Begin run-time elaboration and static initialization...
=N:Starting event scheduler...
Hello System Verilog
=T:Event queue exhausted - terminating run.
Simulation statistics:
    End time: 0 ticks
    Events processed: 1
      Fast events: 0
    Run time: 0.02 sec
    Garbage collections: 1
    Terminal heap size: 3756032
    Total bytes allocated: 4411104
  Metrics DSim version: 20240422.9.0 (b:R #c:0 h:d63c52d5c2 os:ubuntu_22.04)
  Random seed: (defaulted to 1)

シミュレーションの結果として、Hello System Verilog が表示されているのが分かる。とりあえずシンプルなVerilogコードを立ち上げることは確認した。