自作CPUをChipyardの環境で動かすために、何が必要かを久しぶりに確認した。
Chipyardの環境で自作CPUを動かすために、Chipyardに自分のコアを認識させるのと、ソースファイルを食わせる必要がある。 色々やって、BOOMと同じ状況を作るためにソースファイルを1つの大きなファイルとして変換して読み込ませるようにしている。
これはArianeでもやっている処理なので、特に問題ないと思う。
default: echo "\`define RV64" > MSRHCoreBlackbox.preprocessed.sv cat $(SRC_VLOG) >> MSRHCoreBlackbox.preprocessed.sv sed -i "/\`include/d" MSRHCoreBlackbox.preprocessed.sv ln -sf ../../../../generators/msrh/src/main/resources/vsrc/MSRHCoreBlackbox.preprocessed.sv \ ../../../../../../sims/verilator/generated-src/chipyard.TestHarness.MSRHConfig/
作ったプリプロセスファイルを読ませながらVerilatorのバイナリを作ってみる。
make CONFIG=MSRHConfig debug
紆余曲折合ってどうにかVerilatorのバイナリが生成された!それにしたっていちいちChiselを介するためにScalaの遅いコンパイルに付き合っているのが面倒くさいな...
./simulator-chipyard-MSRHConfig-debug +verbose rv64ui-p-add.vcd $RISCV/riscv64-unknown-elf/share/riscv-tests/isa/rv64ui-p-add
using random seed 1650043437 This emulator compiled with JTAG Remote Bitbang client. To enable, use +jtag_rbb_enable=1. Listening on port 54070 [UART] UART0 is here (stdin/stdout). - Verilated::debug attempted, but compiled without VL_DEBUG, so messages suppressed. - Suggest remake using 'make ... CPPFLAGS=-DVL_DEBUG' %Error: /home/msyksphinz/work/riscv/chipyard_msrh/sims/verilator/generated-src/chipyard.TestHarness.MSRHConfig/chipyard.TestHarness.MSRHConfig.harness.v:3849: Verilated model didn't DC converge - See https://verilator.org/warn/DIDNOTCONVERGE Aborting...
エラーで落ちた。Verilated model didn't DC converge
とは何だろう?
https://manpages.debian.org/jessie/verilator/verilator_bin.1
うーんsensitivity listの無限ループで落ちたと書いてある。これを解析するためにはデバッグモードでコンパイルする必要があるらしい。 少し面倒くさいな...
Verilated model didn't converge Verilator sometimes has to evaluate combinatorial logic multiple times, usually around code where a UNOPTFLAT warning was issued, but disabled. For example: always @ (a) b=~a; always @ (b) a=b will toggle forever and thus the executable will give the didn't converge error to prevent an infinite loop. To debug this, run Verilator with --profile-cfuncs. Run make on the generated files with "OPT=-DVL_DEBUG". Then call Verilated::debug(1) in your main.cpp.