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