|
1 |
| -/* Modified by Shaos <[email protected]> |
2 |
| - 24-DEC-2018 - Find top 5 instructions in DEBUG_EXTRA mode |
3 |
| - 20-DEC-2018 - More statistical points |
4 |
| - 22-NOV-2018 - Added saving HEX file with copy of the code in DEBUG_OUTPUT mode |
5 |
| - 21-NOV-2018 - Some statistics added in DEBUG_EXTRA mode |
6 |
| - 20-NOV-2018 - By default RV32M and RV32A extensions are disabled (STRICT_RV32I) |
7 |
| - 18-NOV-2018 - Slghtly modified for pure C |
8 |
| - Source code taken from https://gist.github.com/FrankBuss/c974e59826d33e21d7cad54491ab50e8 |
9 |
| -*/ |
10 |
| - |
11 |
| -/* |
12 |
| -RISCV emulator for the RV32I architecture |
13 |
| -based on TinyEMU by Fabrice Bellard, see https://bellard.org/tinyemu/ |
14 |
| -stripped down for RV32I only, all "gotos" removed, and fixed some bugs for the compliance test |
15 |
| -by Frank Buss, 2018 |
16 |
| -
|
17 |
| -Requires libelf-dev: |
18 |
| -
|
19 |
| -sudo apt-get install libelf-dev |
20 |
| -
|
21 |
| -
|
22 |
| -Compile it like this: |
23 |
| -
|
24 |
| -gcc -O3 -Wall -lelf emu-rv32i.c -o emu-rv32i |
25 |
| -
|
26 |
| -
|
27 |
| -It is compatible to Spike for the command line arguments, which means you can run |
28 |
| -the compliance test from https://github.com/riscv/riscv-compliance like this: |
29 |
| -
|
30 |
| -make RISCV_TARGET=spike RISCV_DEVICE=rv32i TARGET_SIM=/full/path/emulator variant |
31 |
| -
|
32 |
| -It is also compatible with qemu32, as it is used for Zephyr. You can compile the |
33 |
| -Zephyr examples for qemu like this: |
34 |
| -
|
35 |
| -cd zephyr |
36 |
| -source zephyr-env.sh |
37 |
| -cd samples/synchronization |
38 |
| -mkdir build && cd build |
39 |
| -cmake -GNinja -DBOARD=qemu_riscv32 .. |
40 |
| -ninja |
41 |
| -
|
42 |
| -After this you can run it with the emulator like this: |
43 |
| -
|
44 |
| -emu-rv32i zephyr/zephyr.elf |
45 |
| -
|
46 |
| -
|
47 |
| -original copyright: |
48 |
| -*/ |
49 |
| - |
50 | 1 | /*
|
51 |
| - * RISCV emulator |
52 |
| - * |
53 |
| - * Copyright (c) 2016 Fabrice Bellard |
54 |
| - * |
55 |
| - * Permission is hereby granted, free of charge, to any person obtaining a copy |
56 |
| - * of this software and associated documentation files (the "Software"), to deal |
57 |
| - * in the Software without restriction, including without limitation the rights |
58 |
| - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
59 |
| - * copies of the Software, and to permit persons to whom the Software is |
60 |
| - * furnished to do so, subject to the following conditions: |
61 |
| - * |
62 |
| - * The above copyright notice and this permission notice shall be included in |
63 |
| - * all copies or substantial portions of the Software. |
| 2 | + * A minimalist RISC-V emulator for the RV32I architecture. |
64 | 3 | *
|
65 |
| - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
66 |
| - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
67 |
| - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
68 |
| - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
69 |
| - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
70 |
| - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
71 |
| - * THE SOFTWARE. |
| 4 | + * rv32emu is freely redistributable under the MIT License. See the file |
| 5 | + * "LICENSE" for information on usage and redistribution of this file. |
72 | 6 | */
|
73 | 7 |
|
74 | 8 | #define XLEN 32
|
|
0 commit comments