Spike使ってriscv-testを試しに実行してみた

RISC-Vの命令セットが期待通り動いているか確認するために、riscv-testがある。今回は命令セットシミュレータspikeを使って、riscv-testがPassすることを確認してみる。 以下方法ではPass/Failの表示がされないため、改良が必要

GitHub - riscv/riscv-tests

 0. 事前準備
  本当に必要かは不明だが、実施しないとriscv-testのコンパイルに失敗した

brew install md5sha1sum
参考: Macにmd5sumが無い【brew】 - DRYな備忘録

 1. riscv-testのコンパイル

$ git clone https://github.com/riscv/riscv-tests
$ cd riscv-tests
$ git submodule update --init --recursive
$ autoconf
$ ./configure --prefix=$RISCV/target
$ make

 2. Spikeによる実行

# 実行方法
spike -l --isa=RV32I isa/rv32ui-p-add

# 実行ログ(Passなどでないので、dumpファイル確認し、Passの命令アドレスからPassしたか特定する必要ある?)
   1 core   0: 0x0000000000001000 (0x00000297) auipc   t0, 0x0
   2 core   0: 0x0000000000001004 (0x02028593) addi    a1, t0, 32
   3 core   0: 0x0000000000001008 (0xf1402573) csrr    a0, mhartid
…
 467 core   0: 0xffffffff800005f4 (0x0ff0000f) fence   
 468 core   0: 0xffffffff800005f8 (0x00100193) li      gp, 1
 469 core   0: 0xffffffff800005fc (0x00000073) ecall   
 470 core   0: exception trap_user_ecall, epc 0xffffffff800005fc
…
5469 core   0: 0xffffffff80000040 (0x00001f17) auipc   t5, 0x1
5470 core   0: 0xffffffff80000044 (0xfc3f2023) sw      gp, -64(t5)

# Passのアドレス確認(isa/rv32ui-p-add.dumpの場合)
474 800005f4 <pass>:
475 800005f4:       0ff0000f                fence
# テストリスト(命令セット毎の命令があるので大量にある)
rv32ui-p-add
rv32ui-p-addi
rv32ui-p-and
rv32ui-p-andi
rv32ui-p-auipc
…
rv32ui-p-xori

# プログラム数
ls -1 isa | grep -  | grep -v dump  |wc
     403     403    5916