README.md 4.4 KB
Newer Older
1
# XiangShan
Z
add doc  
Zihao Yu 已提交
2

W
wangkaifan 已提交
3
XiangShan (香山) is an open-source high-performance RISC-V processor project. 
Z
add doc  
Zihao Yu 已提交
4

W
wangkaifan 已提交
5
Detailed documents will be released in the near future.
6
中文说明[在此](README-ZH-HANS.md)
Z
add doc  
Zihao Yu 已提交
7

Y
Yinan Xu 已提交
8
Copyright 2020-2021 by Institute of Computing Technology, Chinese Academy of Sciences.
Z
add doc  
Zihao Yu 已提交
9

W
wangkaifan 已提交
10 11


F
Felix Yan 已提交
12
## === Tutorial is Coming! ===
W
wangkaifan 已提交
13 14 15 16 17 18 19 20 21

A tutorial on XiangShan is held at RISC-V World Conference China 2021 in June.  Multiple technical reports will be included in the conference as well. Stay tuned!

For more information, please refer to [this link](https://openxiangshan.github.io).



## Architecture

22
The first stable micro-architecture of XiangShan is called Yanqihu (雁栖湖) on this [branch](https://github.com/OpenXiangShan/XiangShan/tree/yanqihu), which has been developed since June 2020. The current version of XiangShan, also known as Nanhu (南湖), is still under development on the master branch.
W
wangkaifan 已提交
23 24 25

The micro-architecture overview is shown below.

W
wangkaifan 已提交
26
![xs-arch-single](xs-arch-simple.svg)
W
wangkaifan 已提交
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41



## Sub-directories Overview

Some of the key directories are shown below.

```
.
├── fpga                   # supported FPGA boards and files to build a Vivado project
├── read-to-run            # pre-built simulation images
├── scripts                # scripts for agile development
└── src
    ├── test               # test files (including diff-test, module-test, etc.)
    └── main/scala         # design files
W
wangkaifan 已提交
42 43 44 45 46 47 48 49
        ├── bus/tilelink   # tilelink utils
        ├── device         # virtual device for simulation
        ├── difftest       # diff-test chisel interface
        ├── system         # SoC wrapper
        ├── top            # top module
        ├── utils          # utilization code
        ├── xiangshan      # main design code
        └── xstransforms   # some useful firrtl transforms
W
wangkaifan 已提交
50 51 52 53 54 55 56 57 58 59 60 61 62 63
```



## Generate Verilog

* Run `make verilog` to generate verilog code. The output file is `build/XSTop.v`.
* Refer to `Makefile` for more information.



## Run Programs by Simulation

### Prepare environment
Z
add doc  
Zihao Yu 已提交
64

Y
Yinan Xu 已提交
65 66 67 68
* Set environment variable `NEMU_HOME` to the **absolute path** of the [NEMU project](https://github.com/OpenXiangShan/NEMU).
* Set environment variable `NOOP_HOME` to the **absolute path** of the XiangShan project.
* Set environment variable `AM_HOME` to the **absolute path** of the [AM project](https://github.com/OpenXiangShan/nexus-am).
* Install `mill`. Refer to [the Manual section in this guide](https://com-lihaoyi.github.io/mill/mill/Intro_to_Mill.html#_installation).
W
wangkaifan 已提交
69
* Clone this project and run `make init` to initialize submodules.
Z
add doc  
Zihao Yu 已提交
70

W
wangkaifan 已提交
71
### Run with simulator
72

Y
Yinan Xu 已提交
73 74 75 76
* Install [Verilator](https://verilator.org/guide/latest/), the open-source Verilog simulator.
* Run `make emu` to build the C++ simulator `./build/emu` with Verilator.
* Refer to `./build/emu --help` for run-time arguments of the simulator. 
* Refer to `Makefile` and `verilator.mk` for more information.
Z
Zihao Yu 已提交
77

78
Example:
79

Y
Yinan Xu 已提交
80 81
```bash
make emu CONFIG=MinimalConfig SIM_ARGS=--disable-log EMU_THREADS=2 -j10
W
wakafa 已提交
82
./build/emu -b 0 -e 0 -i ./ready-to-run/coremark-2-iteration.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so
83
```
Z
Zihao Yu 已提交
84

W
wakafa 已提交
85 86
## Acknowledgement

87
In the development of XiangShan, some sub-modules from the open-source community are employed. All relevant usage is listed below.
W
wakafa 已提交
88 89 90 91 92

| Sub-module         | Source                                                       | Detail                                                       |
| ------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| L2 Cache/LLC       | [Sifive block-inclusivecache](https://github.com/ucb-bar/block-inclusivecache-sifive) | We enhance the function and the timing of the original module, finally turning it into a Cache generator that can be configured as L2/LLC. |
| Diplomacy/TileLink | [Rocket-chip](https://github.com/chipsalliance/rocket-chip)  | We reused the diplomacy framework and TileLink utility that exist in rocket-chip to negotiate bus. |
93
| FPU                | [Berkeley hardfloat](https://github.com/ucb-bar/berkeley-hardfloat) | We use Berkeley-hardfloat as our FPU and implement an SRT-4 div/sqrt unit for it. Additionally, we split the FMA pipeline to optimize the timing. |
W
wakafa 已提交
94

95
We are grateful for the support of the open-source community and encourage other open-source projects to reuse our code within the scope of the [license](LICENSE).
W
wakafa 已提交
96