This repository was archived by the owner on Jan 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Integrate rv32i conformance tests #6
Open
eriktai
wants to merge
19
commits into
sysprog21:master
Choose a base branch
from
eriktai:con-tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
25e917c
Perform consistent indention
jserv 275aa51
Create the CSRs.h for CSR
5b853e5
Add the compressed C.NOP and C.ADDI
7a9c406
Add the C.JAL and C.ADDIW insn
dc68602
Modified some implementataion detail to support compressed instruction
6331c15
Add the new function for signature validation
5b143f9
Modified the gitignore
25705a3
Update README.txt
eriktai 5036e85
Update README.txt
eriktai 965e0d8
Modified the makefile to enable to check the validation
3ce2880
Update README.md
eriktai 5b770af
Finish the test for rv32i comformance tests
a4a2aa2
Format all files with postfix c and h
fd0dbd9
Remove RV32C specific codes
e34f0f4
Remove unnecessary comments
a3a7294
Modify the conformance test command line
d30d12b
Put rv32emu folder into riscv-target
a90eeec
Slightly modify README.md
1d5aa67
Remove specific codes for RV32C
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
emu-rv32i | ||
test1 | ||
sig.txt | ||
rom.v | ||
debug.txt | ||
# ignore generated files | ||
*.mem | ||
*.signature.output |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* Modified by Nober <s0913768710@gmail.com> | ||
13-DEC-2019 - Define all CSR macro | ||
*/ | ||
|
||
/* | ||
RISCV emulator for the RV32I architecture | ||
based on TinyEMU by Fabrice Bellard, see https://bellard.org/tinyemu/ | ||
stripped down for RV32I only, all "gotos" removed, and fixed some bugs for the | ||
compliance test by Frank Buss, 2018 | ||
|
||
Requires libelf-dev: | ||
|
||
sudo apt-get install libelf-dev | ||
|
||
|
||
Compile it like this: | ||
|
||
gcc -O3 -Wall -lelf emu-rv32i.c -o emu-rv32i | ||
|
||
|
||
It is compatible to Spike for the command line arguments, which means you can | ||
run the compliance test from https://github.com/riscv/riscv-compliance like | ||
this: | ||
|
||
make RISCV_TARGET=spike RISCV_DEVICE=rv32i TARGET_SIM=/full/path/emulator | ||
variant | ||
|
||
It is also compatible with qemu32, as it is used for Zephyr. You can compile the | ||
Zephyr examples for qemu like this: | ||
|
||
cd zephyr | ||
source zephyr-env.sh | ||
cd samples/synchronization | ||
mkdir build && cd build | ||
cmake -GNinja -DBOARD=qemu_riscv32 .. | ||
ninja | ||
|
||
After this you can run it with the emulator like this: | ||
|
||
emu-rv32i zephyr/zephyr.elf | ||
|
||
|
||
original copyright: | ||
*/ | ||
|
||
|
||
|
||
/* | ||
* RISCV emulator | ||
* | ||
* Copyright (c) 2016 Fabrice Bellard | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
#include <stdint.h> | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose it is necessary to have file |
||
|
||
// ====================================================== // | ||
// =================== User Trap Setup ================== // | ||
// ====================================================== // | ||
uint32_t ustatus; /* User status register */ | ||
uint32_t uie; /* User interrupt-enable register */ | ||
uint32_t utvec; /* User trap handler base address */ | ||
// ====================================================== // | ||
// ================= User Trap Handling ================= // | ||
// ====================================================== // | ||
uint32_t uscratch; /* Scratch register for user trap handlers*/ | ||
uint32_t uepc; /* User exception program counter */ | ||
uint32_t ucause; /* User trap cause*/ | ||
uint32_t ubadaddr; /* User bad address */ | ||
uint32_t uip; /* User interrupt pending */ | ||
// ====================================================== // | ||
// ============== User Floating-Point CSRs ============== // | ||
// ====================================================== // | ||
uint32_t fflags; /* Floating-Point Accrued Exceptions*/ | ||
uint32_t frm; /* Floating-Point Dynamic Rounding Mode*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,23 +12,33 @@ How to compile it: | |
```shell | ||
$ gcc -O3 -Wall -lelf emu-rv32i.c -o emu-rv32i | ||
``` | ||
or | ||
```shell | ||
$ make emu-rv32i | ||
``` | ||
|
||
Run RV32I compliance tests. | ||
Assume `emu-rv32i` in `$PATH` environment variable. | ||
Passed RV32I compliance tests from https://github.com/riscv/riscv-compliance | ||
- Must install the [risc-v toolchain](https://xpack.github.io/riscv-none-embed-gcc/) | ||
```shell | ||
$ git clone https://github.com/riscv/riscv-compliance | ||
$ cd riscv-compliance | ||
$ cd rv32emu | ||
$ cp rv32emu ../riscv-compliance/riscv-target | ||
$ cd ../riscv-compliance | ||
$ make RISCV_PREFIX=riscv-none-embed- RISCV_DEVICE=rv32i TARGET_SIM=emu-rv32i variant | ||
``` | ||
|
||
Compiling and running simple code: | ||
- Run RV32IMC compliance tests. | ||
Assume `emu-rv32i` in `$PATH` environment variable. | ||
```shell | ||
$ riscv32-unknown-elf-gcc -O3 -nostdlib test1.c -o test1 | ||
$ git clone https://github.com/riscv/riscv-compliance | ||
$ cd rv32emu | ||
$ cp rv32emu ../riscv-compliance/riscv-target # If having copied the makefile.include to riscv-compliance, it can be ignored. | ||
$ cd riscv-compliance | ||
$ make RISCV_PREFIX=riscv-none-embed- RISCV_DEVICE=rv32imc TARGET_SIM=/abs/path/to/emu-rv32i variant | ||
``` | ||
|
||
or | ||
Compiling and running simple code: | ||
```shell | ||
$ riscv64-unknown-elf-gcc -march=rv32i -mabi=ilp32 -O3 -nostdlib test1.c -o test1 | ||
$ make test1 | ||
``` | ||
|
||
then | ||
|
@@ -37,8 +47,17 @@ $ ./emu-rv32i test1 | |
Hello RISC-V! | ||
``` | ||
|
||
RV32M and RV32A instructions may be enabled by commenting `#define STRICT_RV32I`. | ||
- RV32M and RV32A instructions may be enabled by commenting `#define STRICT_RV32I`. | ||
|
||
|
||
Passed RV32C compliance tests from https://github.com/riscv/riscv-compliance | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't mention RV32C within this pull request. |
||
```shell | ||
make C-ADDI.log | ||
``` | ||
If there is no accident, it will output the `TEST PASSED` | ||
|
||
|
||
- RV32C instructions can be enabled by commenting `#define RV32C` | ||
## How to build RISC-V toolchain from scratch | ||
|
||
https://github.com/riscv/riscv-gnu-toolchain | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't leave such modification message. Instead, your name will be mentioned as a contributor once this pull request is merged.