diff --git a/.gitmodules b/.gitmodules index db0837ec..e1768873 100644 --- a/.gitmodules +++ b/.gitmodules @@ -142,3 +142,6 @@ [submodule "tools/install-circt"] path = tools/install-circt url = https://github.com/circt/install-circt/ +[submodule "toolchains/riscv-tools/riscv-spike-devices"] + path = toolchains/riscv-tools/riscv-spike-devices + url = https://github.com/ucb-bar/spike-devices.git diff --git a/docs/Software/Spike.rst b/docs/Software/Spike.rst index e9abe0c0..10fa8429 100644 --- a/docs/Software/Spike.rst +++ b/docs/Software/Spike.rst @@ -50,3 +50,24 @@ Spike-as-a-Tile can be configured with custom IPC, commit logging, and other beh * ``+spike-fast-clint``: Enables fast-forwarding through WFI stalls by generating fake timer interrupts * ``+spike-debug``: Enables debug Spike logging * ``+spike-verbose``: Enables Spike commit-log generation + +Adding a new spike device model +------------------------------- + +Spike comes with a few functional device models such as UART, CLINT, and PLIC. +However, you may want to add custom device models into Spike such as a block device. +Example devices are in the ``toolchains/riscv-tools/riscv-spike-devices`` directory. +These devices are compiled as a shared library that can be dynamically linked to Spike. + +To compile these plugins, run ``make`` inside ``toolchains/riscv-tools/riscv-spike-devices``. This will generate a ``libspikedevices.so``. + +To hook up a block device to spike and provide a default image to initialize the block device, run + +.. code-block:: shell + + spike --extlib=libspikedevices.so --device="iceblk,img=" + +. + +The ``--device`` option consists of the device name and arguments. +In the above example ``iceblk`` is the device name and ``img=`` is the argument passed on to the plugin device. diff --git a/generators/chipyard/src/main/resources/csrc/spiketile.cc b/generators/chipyard/src/main/resources/csrc/spiketile.cc index 3b14079b..5483cf6b 100644 --- a/generators/chipyard/src/main/resources/csrc/spiketile.cc +++ b/generators/chipyard/src/main/resources/csrc/spiketile.cc @@ -447,18 +447,6 @@ chipyard_simif_t::chipyard_simif_t(size_t icache_ways, use_stq(false), htif(nullptr), fast_clint(false), - cfg(std::make_pair(0, 0), - nullptr, - isastr, - "MSU", - "vlen:128,elen:64", - false, - endianness_little, - pmpregions, - std::vector(), - std::vector(), - false, - 0), accessed_tofrom_host(false), icache_ways(icache_ways), icache_sets(icache_sets), @@ -470,6 +458,19 @@ chipyard_simif_t::chipyard_simif_t(size_t icache_ways, mmio_inflight(false) { + cfg.initrd_bounds = std::make_pair(0, 0); + cfg.bootargs = nullptr; + cfg.isa = isastr; + cfg.priv = "MSU"; + cfg.varch = "vlen:128,elen:64"; + cfg.misaligned = false; + cfg.endianness = endianness_little; + cfg.pmpregions = pmpregions; + cfg.mem_layout = std::vector(); + cfg.hartids = std::vector(); + cfg.explicit_hartids = false; + cfg.trigger_count = 0; + icache.resize(icache_ways); for (auto &w : icache) { w.resize(icache_sets); diff --git a/generators/testchipip b/generators/testchipip index c4c0774f..7e075b9c 160000 --- a/generators/testchipip +++ b/generators/testchipip @@ -1 +1 @@ -Subproject commit c4c0774f5ff7a407dd81e5f0b4289a2fdd9e8d63 +Subproject commit 7e075b9cf63da626234dc22fda45ac9f1e82ffbc diff --git a/scripts/build-toolchain-extra.sh b/scripts/build-toolchain-extra.sh index cc69ae1d..28cc9dfa 100755 --- a/scripts/build-toolchain-extra.sh +++ b/scripts/build-toolchain-extra.sh @@ -125,4 +125,10 @@ cd generators/testchipip/uart_tsi make cp uart_tsi $RISCV/bin +echo '==> Installing spike-devices' +cd $RDIR +git submodule update --init toolchains/riscv-tools/riscv-spike-devices +cd toolchains/riscv-tools/riscv-spike-devices +make install + echo "Extra Toolchain Utilities/Tests Build Complete!" diff --git a/toolchains/riscv-tools/riscv-spike-devices b/toolchains/riscv-tools/riscv-spike-devices new file mode 160000 index 00000000..8b4836db --- /dev/null +++ b/toolchains/riscv-tools/riscv-spike-devices @@ -0,0 +1 @@ +Subproject commit 8b4836db0b5b4ed0a9bab34e7707fe40c7c014be