Add spike-devices as a submodule

This commit is contained in:
joey0320
2023-12-11 17:11:45 -08:00
parent d1822c04e2
commit 6bf915a89c
6 changed files with 45 additions and 13 deletions

3
.gitmodules vendored
View File

@@ -142,3 +142,6 @@
[submodule "tools/install-circt"] [submodule "tools/install-circt"]
path = tools/install-circt path = tools/install-circt
url = https://github.com/circt/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

View File

@@ -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-fast-clint``: Enables fast-forwarding through WFI stalls by generating fake timer interrupts
* ``+spike-debug``: Enables debug Spike logging * ``+spike-debug``: Enables debug Spike logging
* ``+spike-verbose``: Enables Spike commit-log generation * ``+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=<path to Linux image>" <path to kernel binary>
.
The ``--device`` option consists of the device name and arguments.
In the above example ``iceblk`` is the device name and ``img=<path to Linux image>`` is the argument passed on to the plugin device.

View File

@@ -447,18 +447,6 @@ chipyard_simif_t::chipyard_simif_t(size_t icache_ways,
use_stq(false), use_stq(false),
htif(nullptr), htif(nullptr),
fast_clint(false), fast_clint(false),
cfg(std::make_pair(0, 0),
nullptr,
isastr,
"MSU",
"vlen:128,elen:64",
false,
endianness_little,
pmpregions,
std::vector<mem_cfg_t>(),
std::vector<size_t>(),
false,
0),
accessed_tofrom_host(false), accessed_tofrom_host(false),
icache_ways(icache_ways), icache_ways(icache_ways),
icache_sets(icache_sets), icache_sets(icache_sets),
@@ -470,6 +458,19 @@ chipyard_simif_t::chipyard_simif_t(size_t icache_ways,
mmio_inflight(false) 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<mem_cfg_t>();
cfg.hartids = std::vector<size_t>();
cfg.explicit_hartids = false;
cfg.trigger_count = 0;
icache.resize(icache_ways); icache.resize(icache_ways);
for (auto &w : icache) { for (auto &w : icache) {
w.resize(icache_sets); w.resize(icache_sets);

View File

@@ -125,4 +125,10 @@ cd generators/testchipip/uart_tsi
make make
cp uart_tsi $RISCV/bin 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!" echo "Extra Toolchain Utilities/Tests Build Complete!"