MENU

[Tutoral] Run Zce program on Spike

December 31, 2021 • 实习

[Tutoral] Run Zce program on Spike

In this Tutoral, we will run an RISCV zce program on Spiek.

The files mentioned in the article are in follow links Materials

Build GNU tool chain

GNU Tool chain is a pre-requirement of building RISC-V Proxy Kernel pk

Looking riscv-gnu-toolchain repo for more information

git clone https://github.com/riscv/riscv-gnu-toolchain
cd riscv-gnu-toolchain
./configure --prefix=$HOME/opt/riscv --enable-multilib --with-arch=rv64imac --with-abi=lp64
make # Newlib

Export the Env path for GNU tool chain

export PATH=$HOME/opt/riscv/bin:$PATH

Compile RISCV PK

Repo: https://github.com/riscv-software-src/riscv-pk

# clone the source code of PK
git clone https://github.com/riscv-software-src/riscv-pk.git
cd riscv-pk/
mkdir build
cd build
../configure --prefix=$HOME/opt/riscv-pk --host=riscv64-unknown-elf
make install -j

Export the path of risk-pk

export PATH=$HOME/opt/riscv-pk/riscv64-unknown-elf/bin:$PATH

Install device-tree-compiler

we need install device-tree-compiler(dtc) first before build Spike

# Ubuntu
apt-get install device-tree-compiler
# Cent OS
yum install dtc

Build Spike

Repo: https://github.com/plctlab/plct-spike

git clone -b plct-zce-dev https://github.com/plctlab/plct-spike.git
cd plct-spike
mkdir build
cd build
../configure --prefix=$HOME/opt/spike
make install -j

Export the path of risk-pk

export PATH=$HOME/opt/spike/bin:$PATH

Run on Spike

Now we assume that there is already exist a RISCV zce program called hello.o.

Please refer to Compile a C file with Zce ext in LLVM for details about how hello.o is compiled.

Run command

spike --isa=rv64imaczce $(which pk) hello.o

To run hello.o

To invoke interactive debug mode, launch spike with -d:

spike -d --isa=rv64imaczce $(which pk) hello.o

To see the contents of an integer register (0 is for core 0):

: reg 0 a0

You can continue execution indefinitely by:

: r

At any point during execution (even without -d), you can enter the interactive debug mode with <control>-<c>.

To end the simulation from the debug prompt, press <control>-<c> or:

: q

More Usage please refer to https://github.com/plctlab/plct-spike/tree/plct-zce-dev

Note: do not enable d ext and zce ext at same time. Because there are some instructions conflicting.

You can comment below or email me if you have any issues.