7b74b23de694d6f4be8d3a3f49b9a82c683640ea
[libreriscv.git] / 3d_gpu / spike_sv.mdwn
1 # Simple-V Spike emulator
2
3 ####1. Set RISCV and PATH variables
4
5 RISCV will be the location where riscv-tools will place all created
6 executables into when building. RISCV must also be appended to the PATH
7 to allow the usage of the created executables without specifying RISCV.
8
9 > example dev script (riscvdev.sh):
10
11 > export RISCV="$HOME/src/riscv"
12 > export PATH="$PATH:$RISCV/bin"
13
14 ####2. Install riscv-tools: <https://github.com/riscv/riscv-tools>
15 riscv-tools is needed to perform a variety of actions such as: compiling
16 a program to work with a spike simulator, simulate the kernel running
17 on spike, and more!
18
19 > 1. Clone the riscv-tools repository
20 * git clone https://github.com/riscv/riscv-tools
21
22 > 2. Follow the instructions found in the README.md
23 * Note: Be sure to be inside the riscv-tools directory when executing the instructions found there
24
25 > 3. Run the riscv-tests within riscv-tools to verify installation
26 * Navigate to riscv-tests/isa inside riscv-tools and execute the following:
27 * make
28 * make run
29
30 > 4. Make a cache of the current installation somewhere
31 * When all else fails you will not have to run the build script again. Just be sure it is not in the same directory as the current installation.
32
33 When the tests a stream of text will be output to the terminal, however,
34 this is normal. Both commands must complete without error and errors
35 will stop the execution of either command.
36
37 ####3. Clone and check out Simple-V riscv-isa-sim:
38
39 This is a repository used by libre and contains an augmented version of the spike simulator . Do not clone these inside riscv-tools!
40
41 > 1. Clone Simple-V riscv-isa-sim
42 * git clone https://git.libre-riscv.org/git/riscv-isa-sim.git
43
44 >2. Checkout the correct branch
45 * cd riscv-isa-sim
46 * git branch sv origin/sv
47 * git checkout sv
48
49
50 ####4. Compile and Install Simple-V riscv-isa-sim:
51
52 In order for the spike libraries to use the Simple-V version of the
53 simulator the cloned repository must be compiled and installed to
54 the toolchain.
55
56 >1. Navigate into the recently cloned riscv-isa-sim directory
57 * cd riscv-isa-sim
58
59 >2. Create a build directory inside riscv-isa-sim
60 * cd riscv-isa-sim
61 * mkdir build
62
63 >3. Compile riscv-isa-sim
64 * cd build
65 * ../configure --prefix=$RISCV --with-fesvr=$RISCV
66 * make
67
68 >3. Install riscv-isa-sim
69 * make install
70
71 ####5. Clone Simple-V riscv-tests:
72
73 This repository is used by libre and contains an augmented versions of
74 the tests found in riscv-tools. Do not clone these inside riscv-tools!
75
76 >1. Clone the Simple-V version of riscv-tests
77 * git clone https://git.libre-riscv.org/git/riscv-tests.git
78
79 >2. Checkout the correct branch
80 * cd riscv-tests
81 * git branch sv origin/sv
82 * git checkout sv
83
84 >3. Update internal repository
85 * git submodule update --init --recursive
86
87 ####6. Compile and Run Simple-V riscv-tests:
88
89 These tests verify that everything was both generated and installed properly.
90
91 >1. Navigate to riscv-tests/isa
92
93 >2. Compile riscv-tests
94 * make
95
96 >3. Run riscv-tests
97 * make run
98
99 To run the sv unit tests (requires $RISCV to be set correctly i think, or
100 at least riscv32/64-unknown-elf-gcc to be in the path)
101
102 * $ cd riscv-tests
103 * $ cd isa
104 * $ make
105 * $ make run
106
107 To override the fact that spike loads libspike\_main.so and other dynamic
108 libraries from /usr/local/lib (or other location in the path):
109
110 $ export LD_LIBRARY_PATH=`pwd`
111 $ ./spike pk ./a.out
112