FPGA開発日記

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

自作RISC-Vアウトオブオーダコアの実装 (標準構成でのベンチマーク)

前回とりあえず最も規模の小さなデザインで上手く動き出したので、徐々にスケールして動作するか確認してみる。

標準構成でシミュレーションすると、Dhrystoneで見事にアサーションエラーとなってしまった。

./msrh_tb_rv64imc_standard-debug -d -e ../tests/riscv-tests/benchmarks/dhrystone.riscv -o dhrystone.log
<stdin>:25.39-29.9: Warning (interrupt_provider): /cpus/cpu@0/interrupt-controller: Missing #address-cells in interrupt provider
<stdin>:25.39-29.9: Warning (interrupt_provider): /cpus/cpu@0/interrupt-controller: Missing #address-cells in interrupt provider
CSR_MCYCLE written 00000000
CSR_MCYCLE written 00000000
CSR_MCYCLE written 00000354
CSR_MCYCLE written 000001fe
CSR_MCYCLE written 0000037c
      1000 :        558 : IPC(recent) = 0.56, IPC(total) = 0.56
CALL : expected ras_index different. Expectd=2, RTL=3
[19756] %Error: msrh_predictor.sv:422: Assertion failed in TOP.msrh_tb.u_msrh_tile_wrapper.u_msrh_tile.u_frontend.u_predictor
%Error: ../src/../src/msrh_predictor.sv:422: Verilog $stop
Aborting...
dhrystone       : UNKNOWN

解析した結果、やはりRASを過剰に更新しているようだ。 0x2bc0でc.jで無条件ジャンプしているが、同じラインにCALLが入っておりCALLが呼ばれるものと勘違いしている。 その結果次のフェッチで2bd0を呼び、もう一度同じラインが呼ばれてCALLが識別され、2回分RASをアップデートしてしまっている。 まあー実害はないんだけど、一応検証の正しさを確かめるべくきちんとRASを更新しておいた方が良い気がする。

GPR[15](65) <= 0000000000000040
4555 : 850 : PC=[0000000080002bb6] (M,02,04) 44e7fa63 bgeu    a5, a4, pc + 1108
4570 : 851 : PC=[0000000080002bba] (M,08,01) 04100a93 li      s5, 65
GPR[21](174) <= 0000000000000041
4570 : 852 : PC=[0000000080002bbe] (M,08,02) 00004b0d c.li    s6, 3
GPR[22](52) <= 0000000000000003
4571 : 853 : PC=[0000000080002bc0] (M,09,01) 0000a801 c.j     pc + 16
GPR[00](0) <= 0000000000000000
4585 : 854 : PC=[0000000080002bd0] (M,14,01) 04300593 li      a1, 67
GPR[11](12) <= 0000000000000043
4585 : 855 : PC=[0000000080002bd4] (M,14,02) 00008556 c.mv    a0, s5
GPR[10](88) <= 0000000000000041
4585 : 856 : PC=[0000000080002bd6] (M,14,04) c7cff0ef jal     pc - 0xb84
GPR[01](33) <= 0000000080002bda
4588 : 857 : PC=[0000000080002052] (M,15,01) 0ff57513 andi    a0, a0, 255
GPR[10](53) <= 0000000000000041
4588 : 858 : PC=[0000000080002056] (M,15,02) 0ff5f593 andi    a1, a1, 255
GPR[11](149) <= 0000000000000043
4588 : 859 : PC=[000000008000205a] (M,15,04) 00b50463 beq     a0, a1, pc + 8
4589 : 860 : PC=[000000008000205e] (M,16,01) 00004501 c.li    a0, 0
GPR[10](9) <= 0000000000000000
4589 : 861 : PC=[0000000080002060] (M,16,02) 00008082 ret
GPR[00](0) <= 0000000000000000
4590 : 862 : PC=[0000000080002bda] (M,17,01) f4c42783 lw      a5, -180(s0)
MR4(0x0000000080025f1c)=>0000000000000001