FPGA開発日記

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

QEMU5.1.0でRISC-Vバイナリの動かし方調査 (2. Dhrystone調査)

前回の続き。同じようにメモリマップを変更したDhrystoneをコンパイルして実行する。

diff --git a/bsp/qemu-sifive-u54/metal-platform.h b/bsp/qemu-sifive-u54/metal-platform.h
index cd1e5e3..2f5f89a 100644
--- a/bsp/qemu-sifive-u54/metal-platform.h
+++ b/bsp/qemu-sifive-u54/metal-platform.h
@@ -47,8 +47,8 @@
 #define METAL_SIFIVE_TEST0_FINISHER_OFFSET 0UL

 /* From uart@10013000 */
-#define METAL_SIFIVE_UART0_10013000_BASE_ADDRESS 268513280UL
-#define METAL_SIFIVE_UART0_0_BASE_ADDRESS 268513280UL
+#define METAL_SIFIVE_UART0_10013000_BASE_ADDRESS 0x10000000UL
+#define METAL_SIFIVE_UART0_0_BASE_ADDRESS 0x10010000UL
 #define METAL_SIFIVE_UART0_10013000_SIZE 4096UL
 #define METAL_SIFIVE_UART0_0_SIZE 4096UL
$ make PROGRAM=dhrystone TARGET=qemu-sifive-u54
$ ./qemu-5.1.0/build/riscv64-softmmu/qemu-system-riscv64 -d in_asm --nographic --machine virt --bios none \
    --kernel /home/msyksphinz/work/riscv/freedom-e-sdk/software/dhrystone/release/dhrystone.elf
Dhrystone Benchmark, Version 2.1 (Language: C)

Program compiled without 'register' attribute

Execution starts, 20000000 runs through Dhrystone
Execution ends

Final values of the variables used in the benchmark:

Int_Glob:            5
        should be:   5
Bool_Glob:           1
        should be:   1
Ch_1_Glob:           A
        should be:   A
Ch_2_Glob:           B
        should be:   B
Arr_1_Glob[8]:       7
        should be:   7
Arr_2_Glob[8][7]:    20000010
        should be:   Number_Of_Runs + 10
Ptr_Glob->
  Ptr_Comp:          -2147446664
        should be:   (implementation-dependent)
  Discr:             0
        should be:   0
  Enum_Comp:         2
        should be:   2
  Int_Comp:          17
        should be:   17
  Str_Comp:          DHRYSTONE PROGRAM, SOME STRING
        should be:   DHRYSTONE PROGRAM, SOME STRING
Next_Ptr_Glob->
  Ptr_Comp:          -2147446664
        should be:   (implementation-dependent), same as above
  Discr:             0
        should be:   0
  Enum_Comp:         1
        should be:   1
  Int_Comp:          18
        should be:   18
  Str_Comp:          DHRYSTONE PROGRAM, SOME STRING
        should be:   DHRYSTONE PROGRAM, SOME STRING
Int_1_Loc:           5
        should be:   5
Int_2_Loc:           13
        should be:   13
Int_3_Loc:           7
        should be:   7
Enum_Loc:            1
        should be:   1
Str_1_Loc:           DHRYSTONE PROGRAM, 1'ST STRING
        should be:   DHRYSTONE PROGRAM, 1'ST STRING
Str_2_Loc:           DHRYSTONE PROGRAM, 2'ND STRING
        should be:   DHRYSTONE PROGRAM, 2'ND STRING

Microseconds for one run through Dhrystone: 59
Dhrystones per Second:                      16750

正しく動作していることが確認できた。