Skip to content

Commit

Permalink
Add spike-devices as a submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
joonho3020 committed Dec 16, 2023
1 parent d1822c0 commit 6bf915a
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 21 additions & 0 deletions docs/Software/Spike.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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=<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.
25 changes: 13 additions & 12 deletions generators/chipyard/src/main/resources/csrc/spiketile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<mem_cfg_t>(),
std::vector<size_t>(),
false,
0),
accessed_tofrom_host(false),
icache_ways(icache_ways),
icache_sets(icache_sets),
Expand All @@ -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<mem_cfg_t>();
cfg.hartids = std::vector<size_t>();
cfg.explicit_hartids = false;
cfg.trigger_count = 0;

icache.resize(icache_ways);
for (auto &w : icache) {
w.resize(icache_sets);
Expand Down
2 changes: 1 addition & 1 deletion generators/testchipip
6 changes: 6 additions & 0 deletions scripts/build-toolchain-extra.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
1 change: 1 addition & 0 deletions toolchains/riscv-tools/riscv-spike-devices
Submodule riscv-spike-devices added at 8b4836

0 comments on commit 6bf915a

Please sign in to comment.