ずっと試してみたかった、Tenstorrentが公開したRISC-V検証パタンである riscv_arch_tests
を試してみることにした。
自作CPUに適用して、さらなるバグが発見されることを期待している。
”RISC-V Architectural Self Checking Tests" なので、セルフチェック型のテストケースなのだと思う。 対応しているRISC-V拡張命令セットは以下の通り。
RV64-I RV-M RV-F RV-D RV-C RV-V Zfh Zba, Zbb, Zbc, Zbs
注目すべきはRVVが入っていることだが、READMEによると、現在はVLEN=128, VLEN=256がサポートされているらしい。 RISC-V RVVはVLENに関わらず基本的な動作は変わらないはずなのだが、VLENが変わることによりどのようにテストパタンが変わるのだろうか? 気になるところだ。
とりあえず、まずは基本的なテストケースから試していく。GitHub上には、バイナリしか公開されていない。
objdump
してみると、一応テストケースとして成立しているらしい。
0000000080002000 <test_setup>: 80002000: 3400006f j 80002340 <passed> 0000000080002004 <test1>: 80002004: 0d5794b7 lui s1,0xd579 80002008: 1ad4849b addiw s1,s1,429 # d5791ad <check_excp_actual_cause+0xce52285> 8000200c: 00c49493 slli s1,s1,0xc 80002010: 03d48493 addi s1,s1,61 80002014: 00d49493 slli s1,s1,0xd 80002018: cff48493 addi s1,s1,-769 8000201c: 000906b7 lui a3,0x90 80002020: 94b6869b addiw a3,a3,-1717 # 8f94b <CAUSE_STORE_PAGE_FAULT+0x8f93c> 80002024: 00d69693 slli a3,a3,0xd 80002028: 62f68693 addi a3,a3,1583 8000202c: 00c69693 slli a3,a3,0xc 80002030: 17568693 addi a3,a3,373 80002034: 00c69693 slli a3,a3,0xc 80002038: 2ba68693 addi a3,a3,698
とりあえずSpikeで動かそうとしたら、どうもProxy Kernelが必要なようだ。
$ spike -l ../tests/riscv_arch_tests/riscv_tests/rv_i/rvi_compute_register_register/rvi_compute_register_register_1
Access exception occurred while loading payload ../tests/riscv_arch_tests/riscv_tests/rv_i/rvi_compute_register_register/rvi_compute_register_register_1: Memory address 0x726000 is invalid
$ spike -l pk ../tests/riscv_arch_tests/riscv_tests/rv_i/rvi_compute_register_register/rvi_compute_register_register_1
core 0: 0x0000000000001000 (0x00000297) auipc t0, 0x0 core 0: 0x0000000000001004 (0x02028593) addi a1, t0, 32 core 0: 0x0000000000001008 (0xf1402573) csrr a0, mhartid core 0: 0x000000000000100c (0x0182b283) ld t0, 24(t0) core 0: 0x0000000000001010 (0x00028067) jr t0 core 0: >>>> MEM_START core 0: 0x0000000080000000 (0x1f80006f) j pc + 0x1f8 core 0: >>>> do_reset core 0: 0x00000000800001f8 (0x00000093) li ra, 0 core 0: 0x00000000800001fc (0x00000113) li sp, 0 core 0: 0x0000000080000200 (0x00000193) li gp, 0 core 0: 0x0000000080000204 (0x00000213) li tp, 0 core 0: 0x0000000080000208 (0x00000293) li t0, 0 core 0: 0x000000008000020c (0x00000313) li t1, 0 core 0: 0x0000000080000210 (0x00000393) li t2, 0 core 0: 0x0000000080000214 (0x00000413) li s0, 0 core 0: 0x0000000080000218 (0x00000493) li s1, 0 core 0: 0x000000008000021c (0x00000613) li a2, 0 core 0: 0x0000000080000220 (0x00000693) li a3, 0 core 0: 0x0000000080000224 (0x00000713) li a4, 0
うーん困ったな、自作CPU上で動かすためには、pkは使わない前提だ。pkを入れたほうがいいのかな。