FPGA開発日記

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

自作CPUのSpikeモデルシミュレータ環境の変更 (4. LiteX BIOSのブート)

自作CPUのSpikeシミュレータをかなり久しぶりにアップデートすると、いろんな関数が変わっていてかなり戸惑ってしまった。

LiteXとSpikeの設定を変更できるようにして、とりあえずLiteXモードで動作するようにした。 Spike側のBootROMを削除する必要がある。

diff --git a/riscv/sim.cc b/riscv/sim.cc
index f4919c91..5714549a 100644
--- a/riscv/sim.cc
+++ b/riscv/sim.cc
@@ -69,7 +69,7 @@ sim_t::sim_t(const cfg_t *cfg, bool halted,
   for (auto& x : mems)
     bus.add_device(x.first, x.second);
 
-  bus.add_device(DEBUG_START, &debug_module);
+  // bus.add_device(DEBUG_START, &debug_module);
 
   socketif = NULL;
 #ifdef HAVE_BOOST_ASIO
@@ -376,8 +376,8 @@ void sim_t::set_rom()
   const int align = 0x1000;
   rom.resize((rom.size() + align - 1) / align * align);
 
-  std::shared_ptr<rom_device_t> boot_rom(new rom_device_t(rom));
-  add_device(DEFAULT_RSTVEC, boot_rom);
+  // std::shared_ptr<rom_device_t> boot_rom(new rom_device_t(rom));
+  // add_device(DEFAULT_RSTVEC, boot_rom);
 }

とりあえずこれで動き始めた。今度はmain()に到達したところで落ちる。要解析...

MW4(0x000000000c200000)=>0000000000000000
GPR[00](0) <= 0000000000000000
GPR[10](86) <= 0000000000001000
GPR[10](83) <= 0000000000000880
33526 : L1D Evict       : c200000(00000) : 00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000
33526 : EVict ISS Check : c200000        : 00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000
8385 : RTL(43,1) Exception Cause = CSR Update Flush(27) PC=000000000168, Inst=30451073, csrw    mie, a0
GPR[01](52) <= 0000000000000170
8418 : RTL(12,1) Exception Cause = Illegal Instruction(2) PC=00000000174c, Inst=00000000, c.unimp
==========================================
8418 : Exception Happened(12,1) : Cause = Illegal Instruction(2)
==========================================
==========================================
Wrong PC: RTL = 0000000000000020, ISS = 000000000000174c
==========================================
===============================
SIMULATION FINISH : FAIL (CODE=100)
RUNNING TIME : 8442
===============================