xref: /XiangShan/README.md (revision 0af3f74617cd9c3314a2d30006ddd7d5fcdcb215)
105f23f57SWilliam Wang# XiangShan
264fc9c9dSZihao Yu
340adeb5aSwangkaifanXiangShan (香山) is an open-source high-performance RISC-V processor project.
464fc9c9dSZihao Yu
5f1d6f360SZibo Huang中文说明[在此](readme.zh-cn.md)。
664fc9c9dSZihao Yu
7a2ba9cdcSYinan XuCopyright 2020-2021 by Institute of Computing Technology, Chinese Academy of Sciences.
864fc9c9dSZihao Yu
9f320e0f0SYinan XuCopyright 2020-2021 by Peng Cheng Laboratory.
10f320e0f0SYinan Xu
11770ded88SLingrui98## Docs and slides
1259381a79SYinan XuWe gave 20+ presentations on RISC-V World Conference China 2021. XiangShan tutorial was held at the same place. Our slides for RVWC2021 have been updated on [our doc repo](https://github.com/OpenXiangShan/XiangShan-doc) (in Chinese).
1340adeb5aSwangkaifan
14708ceed4SYinan Xu我们在2021年RISC-V中国峰会的报告已经更新到[这里](https://github.com/OpenXiangShan/XiangShan-doc)。文档和相关信息也将持续更新到相同的仓库。
1540adeb5aSwangkaifan
16708ceed4SYinan Xu## Follow us
17708ceed4SYinan Xu
18708ceed4SYinan XuWechat/微信:香山开源处理器
19708ceed4SYinan Xu
20708ceed4SYinan Xu<div align=left><img width="340" height="117" src="images/wechat.png"/></div>
21708ceed4SYinan Xu
22708ceed4SYinan XuZhihu/知乎:[香山开源处理器](https://www.zhihu.com/people/openxiangshan)
23708ceed4SYinan Xu
24708ceed4SYinan XuWeibo/微博:[香山开源处理器](https://weibo.com/u/7706264932)
25708ceed4SYinan Xu
26770ded88SLingrui98You can contact us through [our mail list](mailto:[email protected]). All mails from this list will be archived to [here](https://www.mail-archive.com/[email protected]/).
27770ded88SLingrui98
2840adeb5aSwangkaifan## Architecture
2940adeb5aSwangkaifan
308c0a01afSClSlaidThe 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.
3140adeb5aSwangkaifan
3240adeb5aSwangkaifanThe micro-architecture overview is shown below.
3340adeb5aSwangkaifan
34708ceed4SYinan Xu![xs-arch-single](images/xs-arch-simple.svg)
3540adeb5aSwangkaifan
3640adeb5aSwangkaifan
3740adeb5aSwangkaifan
3840adeb5aSwangkaifan## Sub-directories Overview
3940adeb5aSwangkaifan
4040adeb5aSwangkaifanSome of the key directories are shown below.
4140adeb5aSwangkaifan
4240adeb5aSwangkaifan```
4340adeb5aSwangkaifan.
446a326a79SHaojin Tang├── ready-to-run           # pre-built simulation images
4540adeb5aSwangkaifan├── scripts                # scripts for agile development
4640adeb5aSwangkaifan└── src
4740adeb5aSwangkaifan    ├── test               # test files (including diff-test, module-test, etc.)
4840adeb5aSwangkaifan    └── main/scala         # design files
4940adeb5aSwangkaifan        ├── device         # virtual device for simulation
5040adeb5aSwangkaifan        ├── difftest       # diff-test chisel interface
5140adeb5aSwangkaifan        ├── system         # SoC wrapper
5240adeb5aSwangkaifan        ├── top            # top module
5340adeb5aSwangkaifan        ├── utils          # utilization code
5440adeb5aSwangkaifan        ├── xiangshan      # main design code
5540adeb5aSwangkaifan        └── xstransforms   # some useful firrtl transforms
5640adeb5aSwangkaifan```
5740adeb5aSwangkaifan
58*0af3f746SJiawei Lin## IDE Support
59*0af3f746SJiawei Lin
60*0af3f746SJiawei Lin### bsp
61*0af3f746SJiawei Lin```
62*0af3f746SJiawei Linmake bsp
63*0af3f746SJiawei Lin```
64*0af3f746SJiawei Lin
65*0af3f746SJiawei Lin### IDEA
66*0af3f746SJiawei Lin```
67*0af3f746SJiawei Linmake idea
68*0af3f746SJiawei Lin```
6940adeb5aSwangkaifan
7040adeb5aSwangkaifan
7140adeb5aSwangkaifan## Generate Verilog
7240adeb5aSwangkaifan
7340adeb5aSwangkaifan* Run `make verilog` to generate verilog code. The output file is `build/XSTop.v`.
7440adeb5aSwangkaifan* Refer to `Makefile` for more information.
7540adeb5aSwangkaifan
7640adeb5aSwangkaifan
7740adeb5aSwangkaifan
7840adeb5aSwangkaifan## Run Programs by Simulation
7940adeb5aSwangkaifan
8040adeb5aSwangkaifan### Prepare environment
8164fc9c9dSZihao Yu
82a2ba9cdcSYinan Xu* Set environment variable `NEMU_HOME` to the **absolute path** of the [NEMU project](https://github.com/OpenXiangShan/NEMU).
83a2ba9cdcSYinan Xu* Set environment variable `NOOP_HOME` to the **absolute path** of the XiangShan project.
84a2ba9cdcSYinan Xu* Set environment variable `AM_HOME` to the **absolute path** of the [AM project](https://github.com/OpenXiangShan/nexus-am).
85a2ba9cdcSYinan Xu* Install `mill`. Refer to [the Manual section in this guide](https://com-lihaoyi.github.io/mill/mill/Intro_to_Mill.html#_installation).
8640adeb5aSwangkaifan* Clone this project and run `make init` to initialize submodules.
8764fc9c9dSZihao Yu
8840adeb5aSwangkaifan### Run with simulator
8905f23f57SWilliam Wang
90a2ba9cdcSYinan Xu* Install [Verilator](https://verilator.org/guide/latest/), the open-source Verilog simulator.
91a2ba9cdcSYinan Xu* Run `make emu` to build the C++ simulator `./build/emu` with Verilator.
92a2ba9cdcSYinan Xu* Refer to `./build/emu --help` for run-time arguments of the simulator.
93a2ba9cdcSYinan Xu* Refer to `Makefile` and `verilator.mk` for more information.
9405f23f57SWilliam Wang
9505f23f57SWilliam WangExample:
968c0a01afSClSlaid
97a2ba9cdcSYinan Xu```bash
981545277aSYinan Xumake emu CONFIG=MinimalConfig EMU_THREADS=2 -j10
992f256e1dSwakafa./build/emu -b 0 -e 0 -i ./ready-to-run/coremark-2-iteration.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so
1005c647eb5SZihao Yu```
1015c647eb5SZihao Yu
1022d02df72SWilliam Wang## Troubleshooting Guide
1032d02df72SWilliam Wang
1042d02df72SWilliam Wang[Troubleshooting Guide](https://github.com/OpenXiangShan/XiangShan/wiki/Troubleshooting-Guide)
1052d02df72SWilliam Wang
106d8e5e781Swakafa## Acknowledgement
107d8e5e781Swakafa
1088c0a01afSClSlaidIn the development of XiangShan, some sub-modules from the open-source community are employed. All relevant usage is listed below.
109d8e5e781Swakafa
110d8e5e781Swakafa| Sub-module         | Source                                                       | Detail                                                       |
111d8e5e781Swakafa| ------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
11272060888SJiawei Lin| L2 Cache/LLC       | [Sifive block-inclusivecache](https://github.com/ucb-bar/block-inclusivecache-sifive) | Our new L2/L3 design are inspired by Sifive's `block-inclusivecache`. |
113d8e5e781Swakafa| 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. |
114d8e5e781Swakafa
1158c0a01afSClSlaidWe 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).
116d8e5e781Swakafa
117