新RISC-V ISSの検証のために、まずはPrimitive命令の検証パタンを実行してみた。
利用しているのは、RISC-Vが提供している以下のパタンだ。
これのMakefileを一部書き換え、srecファイルが生成されるようにして、ビルドしている。
$ git diff diff --git a/env b/env index cdf86f5..dac4ddd 160000 --- a/env +++ b/env @@ -1 +1 @@ -Subproject commit cdf86f59e5706d1c35371b555892fe7b8ab2b01d +Subproject commit dac4ddd40078f31f4c2e766368c237eba84ef68c diff --git a/isa/Makefile b/isa/Makefile index 3a8b265..2c11c08 100644 --- a/isa/Makefile +++ b/isa/Makefile @@ -33,7 +33,8 @@ vpath %.S $(isa_src_dir) # Build assembly tests %.hex: % - (elf2hex 16 8192 $< 2> /dev/null || elf2hex 16 16384 $<) > $@ + riscv64-unknown-elf-objcopy -F srec $< $@ +# (elf2hex 16 8192 $< 2> /dev/null || elf2hex 16 16384 $<) > $@ %.dump: % $(RISCV_OBJDUMP) $< > $@
一気に検証するために、以下のようなスクリプトを使った。
#!/bin/sh rm -f rv32ui-p.log for hex in `ls -1 rv32ui-p-*.hex` do echo -n ${hex} swimmer_riscv --hexfile ${hex} --max 1000 --debug | ag mtohost done
実行結果は以下となった。mtohostに1が格納されれば、検証パタンはPassだ。
$ ./rv32ui-p-test.sh rv32ui-p-add.hex 446 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-addi.hex 223 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-amoadd_w.hex 84 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-amoand_w.hex 82 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-amomaxu_w.hex 46 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-amomax_w.hex 46 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-amominu_w.hex 46 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-amomin_w.hex 46 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-amoor_w.hex 82 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-amoswap_w.hex 82 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-and.hex 466 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-andi.hex 179 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-auipc.hex 40 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-beq.hex 272 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-bge.hex 290 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-bgeu.hex 315 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-blt.hex 272 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-bltu.hex 297 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-bne.hex 272 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-div.hex 77 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-divu.hex 78 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-fence_i.hex 258 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-jal.hex 37 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-jalr.hex 96 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-j.hex 32 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-lb.hex 226 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-lbu.hex 226 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-lh.hex 238 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-lhu.hex 245 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-lui.hex 46 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-lw.hex 248 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-mul.hex 440 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-mulh.hex 440 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-mulhsu.hex 440 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-mulhu.hex 440 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-or.hex 469 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-ori.hex 186 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-rem.hex 77 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-remu.hex 77 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-sb.hex 411 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-sh.hex 464 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-simple.hex 22 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-sll.hex 481 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-slli.hex 222 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-slt.hex 440 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-slti.hex 218 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-sra.hex 493 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-srai.hex 237 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-srl.hex 501 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-srli.hex 234 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-sub.hex 438 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-sw.hex 471 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-xor.hex 468 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001 rv32ui-p-xori.hex 188 : [00000184] 780e1073 : csrrw r00,0x780,r28 mtohost=>00000000 r28=>00000001 mtohost<=00000001
全てPassとなった!