FPGA開発日記

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

Gem5 for RISC-Vのビルド試行 (1. ビルドとhelloを流す)

f:id:msyksphinz:20181129165439p:plain

Gem5というのは命令セットシミュレータの一つで、複数のISAをサポートしている。

現在のサポートしているアーキテクチャの状況はこんな感じだ。

Supported Architectures - gem5

RISC-Vも限定的にサポートされており、ビルドの試行くらいは出来そうだ。

ソースのダウンロードからRISC-V向けのビルドは以下のようになる。途中でsconなるものをインストールする必要があるが、これはビルドツールの一つらしい。

git clone https://github.com/gem5/gem5.git
sudo apt install scons
scons build/RISCV/gem5.opt 

しばらくするとビルドが完了する。build/RISCV/gem5.optが生成されている。これでテストパタンを流すためには以下のようにするらしい。

./build/RISCV/gem5.opt configs/example/se.py -c tests/test-progs/hello/bin/riscv/linux/hello

実行結果。正しく実行できていることが確認できた。

$ ./build/RISCV/gem5.opt configs/example/se.py -c tests/test-progs/hello/bin/riscv/linux/hello
gem5 Simulator System.  http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.

gem5 compiled Nov 29 2018 15:22:49
gem5 started Nov 29 2018 15:37:40
gem5 executing on msyksphinz-VirtualBox, pid 10450
command line: ./build/RISCV/gem5.opt configs/example/se.py -c tests/test-progs/hello/bin/riscv/linux/hello

/home/msyksphinz/work/riscv/gem5/configs/common/CacheConfig.py:50: SyntaxWarning: import * only allowed at module level
  def config_cache(options, system):
Global frequency set at 1000000000000 ticks per second
warn: DRAM device capacity (8192 Mbytes) does not match the address range assigned (512 Mbytes)
0: system.remote_gdb: listening for remote gdb on port 7000
**** REAL SIMULATION ****
info: Entering event queue @ 0.  Starting simulation...
warn: readlink() called on '/proc/self/exe' may yield unexpected results in various settings.
      Returning '/home/msyksphinz/work/riscv/gem5/tests/test-progs/hello/bin/riscv/linux/hello'
info: Increasing stack size by one page.
Hello world!
Exiting @ tick 3544500 because exiting with last active thread context