LoginSignup
0
0

More than 5 years have passed since last update.

SweRV ISS by Western Digital (1)

Last updated at Posted at 2018-12-15

12/3-6のRISC-V Summit@Santa Claraにて、Western Digitalが開発中のRISC-Vコアを「SweRV」と名付けてオープンソース化することを発表しました。RTLの公開は1月になるとのことですが、ISSは即日githubに上がったので動作を確認してみます。

実行環境

Windows10 VirtualBox5上でのUbuntu 18.04

1. github

Western DigitalのgithubからSweRV-ISSをcloneします。
$ git clone https://github.com/westerndigitalcorporation/swerv-ISS.git

2. Boostライブラリ

Boostが必要になるということなので、https://www.boost.org/ からboostライブラリの最新版をDownloadしてインストールします。
$ tar zxvf boost_1_69_0.tar.gz
$ cd boost_1_69_0/
$ ./bootstrap.sh

/optにインストールすることにしたのでroot権限でインストール。
$ sudo ./b2 install -j2 --prefix=/opt/boost
結構時間がかかる。。。Warningも結構。。。

3. SweRV ISSのビルド

githubのREADMEに従うまま進めます。

$ cd swerv-ISS
$ vi GNUmakefile
  BOOST_DIR := /opt/boost   <--boostインストール場所を指定
$ make

whisper*ができました。

4. RISC-Vバイナリの準備

ISSに食わせるRISC-Vバイナリは、RISC-V用GNUツールチェインで作られたものを想定します。
例になっているWestern DigitalのRISC-VはRV32IMCです。

例題プログラム(test3.c)
#include <stdio.h>

int
main(int argc, char* argv[])
{
printf("hello world\n");
return 0;
}

RISC-V用バイナリをビルド
$ riscv32-unknown-elf-gcc -mabi=ilp32 -march=rv32imc -static -O3 -o test3 test3.c

5. ISSの実行(旧バージョン)

$ ./whisper --emulatelinux test3
hello world
Target program exited with code 0
Retired 1853 instructions in 0.00s 13828358 inst/s
$
実行できたようです。

--logを付けると実行ログが出ます。
$ ./whisper --emulatelinux --log test3
#1 0 0001008c 00004197 r 03 0001408c auipc x3, 0x4
#2 0 00010090 fb418193 r 03 00014040 addi x3, x3, -0x4c
#3 0 00010094 81418513 r 0a 00013854 addi x10, x3, -0x7ec
#4 0 00010098 86c18613 r 0c 000138ac addi x12, x3, -0x794
#5 0 0001009c 40a60633 r 0c 00000058 sub x12, x12, x10
#6 0 000100a0 00000593 r 0b 00000000 addi x11, x0, 0x0
#7 0 000100a4 278000ef r 01 000100a8 jal x1, 0x278
#8 0 0001031c 00f00313 r 06 0000000f addi x6, x0, 0xf
#9 0 00010320 00050713 r 0e 00013854 addi x14, x10, 0x0
#10 0 00010324 02c37e63 r 00 00000000 bgeu x6, x12, 0x3c
(中略)
#1845 0 00010200 00040513 r 0a 00000000 addi x10, x8, 0x0
#1846 0 00010204 071020ef r 01 00010208 jal x1, 0x2870
#1847 0 00012a74 00000593 r 0b 00000000 addi x11, x0, 0x0
#1848 0 00012a78 00000613 r 0c 00000000 addi x12, x0, 0x0
#1849 0 00012a7c 00000693 r 0d 00000000 addi x13, x0, 0x0
#1850 0 00012a80 00000713 r 0e 00000000 addi x14, x0, 0x0
#1851 0 00012a84 00000793 r 0f 00000000 addi x15, x0, 0x0
#1852 0 00012a88 05d00893 r 11 0000005d addi x17, x0, 0x5d
Target program exited with code 0
Retired 1853 instructions in 0.02s 97209 inst/s
$

interactiveモードで、対話的なシミュレーションができます。
$ ../whisper --interactive test3
whisper> step
#1 0 0001008c 00004197 r 03 0001408c auipc x3, 0x4
whisper> step
#2 0 00010090 fb418193 r 03 00014040 addi x3, x3, -0x4c
whisper> step 5
#3 0 00010094 81418513 r 0a 00013854 addi x10, x3, -0x7ec
#4 0 00010098 86c18613 r 0c 000138ac addi x12, x3, -0x794
#5 0 0001009c 40a60633 r 0c 00000058 sub x12, x12, x10
#6 0 000100a0 00000593 r 0b 00000000 addi x11, x0, 0x0
#7 0 000100a4 278000ef r 01 000100a8 jal x1, 0x278
whisper> peek pc
0x0001031c
whisper> peek all
pc: 0x0001031c

x0: 0x00000000
x1: 0x000100a8
x2: 0x00000000
x3: 0x00014040
x4: 0x00000000
x5: 0x00000000
x6: 0x00000000
x7: 0x00000000
x8: 0x00000000
x9: 0x00000000
x10: 0x00013854
x11: 0x00000000
x12: 0x00000058
x13: 0x00000000
x14: 0x00000000
x15: 0x00000000
x16: 0x00000000
x17: 0x00000000
x18: 0x00000000
x19: 0x00000000
x20: 0x00000000
x21: 0x00000000
x22: 0x00000000
x23: 0x00000000
x24: 0x00000000
x25: 0x00000000
x26: 0x00000000
x27: 0x00000000
x28: 0x00000000
x29: 0x00000000
x30: 0x00000000
x31: 0x00000000

csr value reset mask pokemask

mstatus(0x300): 0x00000000 0x00000000 0x007ff9bb 0x007ff9bb
misa(0x301): 0x40001104 0x40001104 0x00000000 0x00000000
mie(0x304): 0x00000000 0x00000000 0x00000fff 0x00000fff
mtvec(0x305): 0x00000000 0x00000000 0xfffffffd 0xfffffffd
mhpmevent3(0x323): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent4(0x324): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent5(0x325): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent6(0x326): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent7(0x327): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent8(0x328): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent9(0x329): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent10(0x32a): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent11(0x32b): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent12(0x32c): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent13(0x32d): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent14(0x32e): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent15(0x32f): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent16(0x330): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent17(0x331): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent18(0x332): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent19(0x333): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent20(0x334): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent21(0x335): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent22(0x336): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent23(0x337): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent24(0x338): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent25(0x339): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent26(0x33a): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent27(0x33b): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent28(0x33c): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent29(0x33d): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent30(0x33e): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmevent31(0x33f): 0x00000000 0x00000000 0x00000000 0x00000000
mscratch(0x340): 0x00000000 0x00000000 0xffffffff 0xffffffff
mepc(0x341): 0x00000000 0x00000000 0xfffffffe 0xfffffffe
mcause(0x342): 0x00000000 0x00000000 0xffffffff 0xffffffff
mtval(0x343): 0x00000000 0x00000000 0xffffffff 0xffffffff
mip(0x344): 0x00000000 0x00000000 0x00000000 0x00000fff
pmpcfg0(0x3a0): 0x00000000 0x00000000 0xffffffff 0xffffffff
pmpcfg1(0x3a1): 0x00000000 0x00000000 0xffffffff 0xffffffff
pmpcfg2(0x3a2): 0x00000000 0x00000000 0xffffffff 0xffffffff
pmpcfg3(0x3a3): 0x00000000 0x00000000 0xffffffff 0xffffffff
pmpaddr0(0x3b0): 0x00000000 0x00000000 0xffffffff 0xffffffff
pmpaddr1(0x3b1): 0x00000000 0x00000000 0xffffffff 0xffffffff
pmpaddr2(0x3b2): 0x00000000 0x00000000 0xffffffff 0xffffffff
pmpaddr3(0x3b3): 0x00000000 0x00000000 0xffffffff 0xffffffff
pmpaddr4(0x3b4): 0x00000000 0x00000000 0xffffffff 0xffffffff
pmpaddr5(0x3b5): 0x00000000 0x00000000 0xffffffff 0xffffffff
pmpaddr6(0x3b6): 0x00000000 0x00000000 0xffffffff 0xffffffff
pmpaddr7(0x3b7): 0x00000000 0x00000000 0xffffffff 0xffffffff
pmpaddr8(0x3b8): 0x00000000 0x00000000 0xffffffff 0xffffffff
pmpaddr9(0x3b9): 0x00000000 0x00000000 0xffffffff 0xffffffff
pmpaddr10(0x3ba): 0x00000000 0x00000000 0xffffffff 0xffffffff
pmpaddr11(0x3bb): 0x00000000 0x00000000 0xffffffff 0xffffffff
pmpaddr12(0x3bc): 0x00000000 0x00000000 0xffffffff 0xffffffff
pmpaddr13(0x3bd): 0x00000000 0x00000000 0xffffffff 0xffffffff
pmpaddr14(0x3be): 0x00000000 0x00000000 0xffffffff 0xffffffff
pmpaddr15(0x3bf): 0x00000000 0x00000000 0xffffffff 0xffffffff
tselect(0x7a0): 0x00000000 0x00000000 0xffffffff 0xffffffff
tdata1(0x7a1): 0x23e00000 0x00000000 0xffffffff 0xffffffff
tdata2(0x7a2): 0x00000000 0x00000000 0xffffffff 0xffffffff
dcsr(0x7b0): 0x40000003 0x40000003 0x00008e04 0x00008fcc
dpc(0x7b1): 0x00000000 0x00000000 0xfffffffe 0xfffffffe
mrac(0x7c0): 0x00000000 0x00000000 0xffffffff 0xffffffff
mcpc(0x7c2): 0x00000000 0x00000000 0x00000000 0x00000000
dmst(0x7c4): 0x00000000 0x00000000 0x00000000 0x00000000
mpmc(0x7c6): 0x00000000 0x00000000 0x00000000 0x00000000
dicawics(0x7c8): 0x00000000 0x00000000 0x0130fffc 0x0130fffc
dicad0(0x7c9): 0x00000000 0x00000000 0xffffffff 0xffffffff
dicad1(0x7ca): 0x00000000 0x00000000 0x00000003 0x00000003
dicago(0x7cb): 0x00000000 0x00000000 0x00000000 0x00000000
mgpmc(0x7d0): 0x00000001 0x00000001 0x00000001 0x00000001
mitcnt0(0x7d2): 0x00000000 0x00000000 0xffffffff 0xffffffff
mitbnd0(0x7d3): 0xffffffff 0xffffffff 0xffffffff 0xffffffff
mitctl0(0x7d4): 0x00000001 0x00000001 0x00000007 0x00000007
mitcnt1(0x7d5): 0x00000000 0x00000000 0xffffffff 0xffffffff
mitbnd1(0x7d6): 0xffffffff 0xffffffff 0xffffffff 0xffffffff
mitctl1(0x7d7): 0x00000001 0x00000001 0x00000007 0x00000007
micect(0x7f0): 0x00000000 0x00000000 0xffffffff 0xffffffff
miccmect(0x7f1): 0x00000000 0x00000000 0xffffffff 0xffffffff
mdccmect(0x7f2): 0x00000000 0x00000000 0xffffffff 0xffffffff
mcgc(0x7f8): 0x00000000 0x00000000 0x000000ff 0x000000ff
mfdc(0x7f9): 0x00000000 0x00000000 0x000007ff 0x000007ff
mcycle(0xb00): 0x00000007 0x00000000 0xffffffff 0xffffffff
minstret(0xb02): 0x00000007 0x00000000 0xffffffff 0xffffffff
mhpmcounter3(0xb03): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter4(0xb04): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter5(0xb05): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter6(0xb06): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter7(0xb07): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter8(0xb08): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter9(0xb09): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter10(0xb0a): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter11(0xb0b): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter12(0xb0c): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter13(0xb0d): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter14(0xb0e): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter15(0xb0f): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter16(0xb10): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter17(0xb11): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter18(0xb12): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter19(0xb13): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter20(0xb14): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter21(0xb15): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter22(0xb16): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter23(0xb17): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter24(0xb18): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter25(0xb19): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter26(0xb1a): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter27(0xb1b): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter28(0xb1c): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter29(0xb1d): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter30(0xb1e): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter31(0xb1f): 0x00000000 0x00000000 0x00000000 0x00000000
mcycleh(0xb80): 0x00000000 0x00000000 0xffffffff 0xffffffff
minstreth(0xb82): 0x00000000 0x00000000 0xffffffff 0xffffffff
mhpmcounter3h(0xb83): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter4h(0xb84): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter5h(0xb85): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter6h(0xb86): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter7h(0xb87): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter8h(0xb88): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter9h(0xb89): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter10h(0xb8a): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter11h(0xb8b): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter12h(0xb8c): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter13h(0xb8d): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter14h(0xb8e): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter15h(0xb8f): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter16h(0xb90): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter17h(0xb91): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter18h(0xb92): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter19h(0xb93): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter20h(0xb94): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter21h(0xb95): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter22h(0xb96): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter23h(0xb97): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter24h(0xb98): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter25h(0xb99): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter26h(0xb9a): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter27h(0xb9b): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter28h(0xb9c): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter29h(0xb9d): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter30h(0xb9e): 0x00000000 0x00000000 0x00000000 0x00000000
mhpmcounter31h(0xb9f): 0x00000000 0x00000000 0x00000000 0x00000000
mdeau(0xbc0): 0x00000000 0x00000000 0x00000000 0x00000000
meivt(0xbc8): 0x00000000 0x00000000 0xfffffc00 0xfffffc00
meipt(0xbc9): 0x00000000 0x00000000 0x0000000f 0x0000000f
meicpct(0xbca): 0x00000000 0x00000000 0x00000000 0x00000000
meicidpl(0xbcb): 0x00000000 0x00000000 0x0000000f 0x0000000f
meicurpl(0xbcc): 0x00000000 0x00000000 0x0000000f 0x0000000f
cycle(0xc00): 0x00000000 0x00000000 0xffffffff 0xffffffff
time(0xc01): 0x00000000 0x00000000 0xffffffff 0xffffffff
instret(0xc02): 0x00000000 0x00000000 0xffffffff 0xffffffff
mvendorid(0xf11): 0x00000000 0x00000000 0x00000000 0x00000000
marchid(0xf12): 0x00000000 0x00000000 0x00000000 0x00000000
mimpid(0xf13): 0x00000000 0x00000000 0x00000000 0x00000000
mhartid(0xf14): 0x00000000 0x00000000 0x00000000 0x00000000
mdseac(0xfc0): 0x00000000 0x00000000 0x00000000 0xffffffff
meihap(0xfc8): 0x00000000 0x00000000 0x00000000 0xfffffffc

trigger0: 0x23e00000 0x00000000 0x00000000 0x081818c7 0xffffffff 0x00000000 0x081818c7 0xffffffff 0x00000000
trigger1: 0x23e00000 0x00000000 0x00000000 0x081818c7 0xffffffff 0x00000000 0x081818c7 0xffffffff 0x00000000
trigger2: 0x23e00000 0x00000000 0x00000000 0x081818c7 0xffffffff 0x00000000 0x081818c7 0xffffffff 0x00000000
trigger3: 0x30000000 0x00000000 0x00000000 0x08fffe3f 0x00000000 0x00000000 0x08fffe3f 0x00000000 0x00000000
whisper> step
#8 0 0001031c 00f00313 r 06 0000000f addi x6, x0, 0xf
whisper> step
#9 0 00010320 00050713 r 0e 00013854 addi x14, x10, 0x0
whisper> quit
$

動いているようです。

現在はRISC-Vの A, C, D, F, I, M, S, U の仕様に対応しています。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0