4 Author : Andrew Waterman, Yunsup Lee
8 Version : (under version control)
13 The RISC-V ISA Simulator implements a functional model of one or more
19 We assume that the RISCV environment variable is set to the RISC-V tools
20 install path, and that the riscv-fesvr package is installed there.
24 $ ../configure --prefix=$RISCV --with-fesvr=$RISCV
28 Compiling and Running a Simple C Program
29 -------------------------------------------
31 Install spike (see Build Steps), riscv-gnu-toolchain, and riscv-pk.
33 Write a short C program and name it hello.c. Then, compile it into a RISC-V
34 ELF binary named hello:
36 $ riscv64-unknown-elf-gcc -o hello hello.c
38 Now you can simulate the program atop the proxy kernel:
42 Simulating a New Instruction
43 ------------------------------------
45 Adding an instruction to the simulator requires two steps:
47 1. Describe the instruction's functional behavior in the file
48 riscv/insns/<new_instruction_name>.h. Examine other instructions
49 in that directory as a starting point.
51 2. Add the opcode and opcode mask to riscv/opcodes.h. Alternatively,
52 add it to the riscv-opcodes package, and it will do so for you:
55 $ vi opcodes // add a line for the new instruction
58 3. Rebuild the simulator.
60 Interactive Debug Mode
61 ---------------------------
63 To invoke interactive debug mode, launch spike with -d:
67 To see the contents of an integer register (0 is for core 0):
71 To see the contents of a floating point register:
79 depending upon whether you wish to print the register as single- or double-precision.
81 To see the contents of a memory location (physical address in hex):
85 To see the contents of memory with a virtual address (0 for core 0):
89 You can advance by one instruction by pressing <enter>. You can also
90 execute until a desired equality is reached:
92 : until pc 0 2020 (stop when pc=2020)
93 : until mem 2020 50a9907311096993 (stop when mem[2020]=50a9907311096993)
95 Alternatively, you can execute as long as an equality is true:
97 : while mem 2020 50a9907311096993
99 You can continue execution indefinitely by:
103 At any point during execution (even without -d), you can enter the
104 interactive debug mode with `<control>-<c>`.
106 To end the simulation from the debug prompt, press `<control>-<c>` or: