Esperanto Technologiesと言えば、RISC-Vを採用したメニーコアチップを開発しているシリコンバレーのベンチャー企業であるが、チップに先立ちRISC-Vの命令セットシミュレータをChipsAllianceの成果物として公開したようだ。 RISC-Vのシミュレータと言えば一番普及しているのはriscv-isa-sim(いわゆるSpike)だが、これはSpikeとは異なる、フルスクラッチから実装したRISC-Vシミュレータになっている様子。
とりあえずREADMEを眺めていると、Co-simulationの環境も含まれているようで、おそらくEsperantoはRTLとISSをシミュレータ上で接続して、DPIか何かで通信してシミュレーション中に一対一の検証を行っている様子。そのための環境を一部公開、という訳か。Co-simulationの環境はRTLが無いと実行できないので今回は確かめられないが、独立したバイナリならば実行できる。
ダウンロードとセットアップは簡単で、git clone
してmakeしたらすぐにバイナリがビルドできた。
git clone https://github.com/chipsalliance/dromajo.git cd dromajo make -C src
$ ./dromajo error: missing config file Dromajo-0.1, Copyright (c) 2016-2017 Fabrice Bellard, Copyright (c) 2018,2019 Esperanto Technologies usage: ./dromajo {options} [config|elf-file] --cmdline Kernel command line arguments to append --ncpus number of cpus to simulate (default 1) --load resumes a previously saved snapshot --save saves a snapshot upon exit --maxinsns terminates execution after a number of instructions --terminate-event name of the validate event to terminate execution --trace start trace dump after a number of instructions. Trace disabled by default --ignore_sbi_shutdown continue simulation even upon seeing the SBI_SHUTDOWN call --dump_memories dump memories that could be used to load a cosimulation --memory_size sets the memory size in MiB (default 256 MiB) --memory_addr sets the memory start address (default 0x80000000)
単純なテストパタンを通すためには、riscv-testsのディレクトリを指定して実行する。
./dromajo --trace 0 ${RISCV}/riscv64-unknown-elf/share/riscv-tests/isa/rv64ui-p-simple
逆アセンブルは出ないようだ。
0 3 0x00000000800000f8 (0x30200073) 0 0 0x00000000800000fc (0x0ff0000f) 0 0 0x0000000080000100 (0x00100193) x 3 0x0000000000000001 0 0 0x0000000080000104 (0x00000073) exception 8, tval 0000000000000000 0 3 0x0000000080000004 (0x34202f73) x30 0x0000000000000008 0 3 0x0000000080000008 (0x00800f93) x31 0x0000000000000008 0 3 0x000000008000000c (0x03ff0a63) 0 3 0x0000000080000040 (0x00001f17) x30 0x0000000080001040 0 3 0x0000000080000044 (0xfc3f2023)
それでも、最終コードを確認するとパタンがPassしているのは分かる。
ちなみに、rv32ui-p-simpleを実行するとトレースログが出る前にコケた。64bitのみ対応だから仕方がないのかな?
$ ./dromajo --trace 0 /home/msyksphinz/riscv64/riscv64-unknown-elf/share/riscv-tests/isa/rv32ui-p-simple error: unexpected character
buildrootを試す
以下の要領でbuildrootをダウンロードして実行できるようだ。
wget https://github.com/buildroot/buildroot/archive/2019.08.1.tar.gz tar xzf 2019.08.1.tar.gz\ncp config-buildroot-2019.08.1 buildroot-2019.08.1/.config\n unset LD_LIBRARY_PATH printenv PERL_MM_OPT unset PERL_MM_OPT make -j6 -C buildroot-2019.08.1
fakeroot ?で失敗した。
a/tools/img/cs_v131/Toolchains/mips-img-linux-elf/2015.06-05/bin:/storage/eda/tools/img/cs_v131/Toolchains/mips-img-elf/2015.06-05/bin:/home/msyksphinz/.local/opt/mips/simulators/iasim/IASim_4_1_0/bin:/home/msyksphinz/work/riscv/swimmer_riscv/build:/home/msyksphinz/software/sbt/bin:/home/m syksphinz/others/usr/bin:/home/msyksphinz/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0:/mnt/c/WINDOWS/System32/OpenSSH:/ mnt/c/Program Files/PuTTY:/mnt/c/Users/masay/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/masay/AppData/Local/Programs/Microsoft VS Code Insiders/bin:/mnt/c/Users/masay/AppData/Local/atom/bin:/%USERPROFILE%/AppData/Local/Microsoft/WindowsApps:/home/msyksphinz/work/scripts:/usr/local/sc ala/bin:/usr/local/go/bin:/home/msyksphinz/go/bin:/home/msyksphinz/others/usr/0.10.1-18-g81e5f35:/home/msyksphinz/node_modules/.bin:/home/msyksphinz/others/idea-IC-192.7142.36/bin" FAKEROOTDONTTRYCHOWN=1 /home/msyksphinz/work/riscv/esperanto_dromajo/dromajo/run/buildroot-2019.08.1/output/h ost/bin/fakeroot -- /home/msyksphinz/work/riscv/esperanto_dromajo/dromajo/run/buildroot-2019.08.1/output/build/buildroot-fs/cpio/fakeroot fakeroot, while creating message channels: Function not implemented This may be due to a lack of SYSV IPC support. fakeroot: error while starting the `faked' daemon. kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec] make[1]: *** [fs/cpio/cpio.mk:68: /home/msyksphinz/work/riscv/esperanto_dromajo/dromajo/run/buildroot-2019.08.1/output/images/rootfs.cpio] Error 1 make: *** [Makefile:84: _all] Error 2 make: Leaving directory '/home/msyksphinz/work/riscv/esperanto_dromajo/dromajo/run/buildroot-2019.08.1'
うーん、buildrootで組み上げるfakerootだから、さすがに対処できないか。やはりWSLでは無理か... 環境を別に構築してみようかな。