Name Date Size #Lines LOC

..--

.github/H25-Apr-2025-1,1491,059

ChiselAIA/H25-Apr-2025-

coupledL2/H25-Apr-2025-

debug/H25-Apr-2025-437238

difftest/H25-Apr-2025-

fudian/H25-Apr-2025-

huancun/H25-Apr-2025-

images/H25-Apr-2025-119

macros/src/main/scala/H25-Apr-2025-11087

openLLC/H25-Apr-2025-

project/H25-Apr-2025-21

ready-to-run/H25-Apr-2025-

rocket-chip/H25-Apr-2025-

scripts/H25-Apr-2025-5,8034,880

src/H25-Apr-2025-120,37490,127

tools/readmemh/H25-Apr-2025-221126

utility/H25-Apr-2025-

yunsuan/H25-Apr-2025-

.gitignoreH A D25-Apr-20254.5 KiB371311

.gitmodulesH A D25-Apr-2025939 3130

.mill-versionH A D25-Apr-20257 21

.scalafmt.confH A D25-Apr-2025530 2721

LICENSEH A D25-Apr-20259.4 KiB12770

MakefileH A D25-Apr-20258.7 KiB319213

Makefile.testH A D25-Apr-2025331 136

README.mdH A D25-Apr-20255.9 KiB13784

build.sbtH A D25-Apr-20252 KiB5344

build.scH A D25-Apr-202510.6 KiB378261

readme.zh-cn.mdH A D25-Apr-20255.4 KiB13182

scalastyle-config.xmlH A D25-Apr-20258 KiB181135

scalastyle-test-config.xmlH A D25-Apr-20258 KiB181135

README.md

1# XiangShan
2
3XiangShan (香山) is an open-source high-performance RISC-V processor project.
4
5中文说明[在此](readme.zh-cn.md)。
6
7## Documentation
8
9XiangShan's documentation is available at [docs.xiangshan.cc](https://docs.xiangshan.cc).
10
11The microarchitecture documentation on [docs.xiangshan.cc](https://docs.xiangshan.cc) is currently outdated for the latest version (Kunminghu). An updated version is in progress.
12
13XiangShan User Guide has been published separately. You can find it at [XiangShan-User-Guide/releases](https://github.com/OpenXiangShan/XiangShan-User-Guide/releases).
14
15## Publications
16
17### MICRO 2022: Towards Developing High Performance RISC-V Processors Using Agile Methodology
18
19Our paper introduces XiangShan and the practice of agile development methodology on high performance RISC-V processors.
20It covers some representative tools we have developed and used to accelerate the chip development process, including design, functional verification, debugging, performance validation, etc.
21This paper is awarded all three available badges for artifact evaluation (Available, Functional, and Reproduced).
22
23![Artifacts Available](https://github.com/OpenXiangShan/XiangShan-doc/raw/main/publications/images/artifacts_available_dl.jpg)
24![Artifacts Evaluated — Functional](https://github.com/OpenXiangShan/XiangShan-doc/raw/main/publications/images/artifacts_evaluated_functional_dl.jpg)
25![Results Reproduced](https://github.com/OpenXiangShan/XiangShan-doc/raw/main/publications/images/results_reproduced_dl.jpg)
26
27[Paper PDF](https://github.com/OpenXiangShan/XiangShan-doc/blob/main/publications/micro2022-xiangshan.pdf) | [IEEE Xplore](https://ieeexplore.ieee.org/abstract/document/9923860) | [BibTeX](https://github.com/OpenXiangShan/XiangShan-doc/blob/main/publications/micro2022-xiangshan.bib) | [Presentation Slides](https://github.com/OpenXiangShan/XiangShan-doc/blob/main/publications/micro2022-xiangshan-slides.pdf) | [Presentation Video](https://www.bilibili.com/video/BV1FB4y1j7Jy)
28
29## Follow us
30
31Wechat/微信:香山开源处理器
32
33<div align=left><img width="340" height="117" src="images/wechat.png"/></div>
34
35Zhihu/知乎:[香山开源处理器](https://www.zhihu.com/people/openxiangshan)
36
37Weibo/微博:[香山开源处理器](https://weibo.com/u/7706264932)
38
39You can contact us through [our mailing list](mailto:[email protected]). All mails from this list will be archived [here](https://www.mail-archive.com/[email protected]/).
40
41## Architecture
42
43The first stable micro-architecture of XiangShan is called Yanqihu (雁栖湖) and is [on the yanqihu branch](https://github.com/OpenXiangShan/XiangShan/tree/yanqihu), which has been developed since June 2020.
44
45The second stable micro-architecture of XiangShan is called Nanhu (南湖) and is [on the nanhu branch](https://github.com/OpenXiangShan/XiangShan/tree/nanhu).
46
47The current version of XiangShan, also known as Kunminghu (昆明湖), is still under development on the master branch.
48
49The micro-architecture overview of Kunminghu (昆明湖) is shown below.
50
51![xs-arch-kunminghu](images/xs-arch-kunminghu.svg)
52
53
54
55## Sub-directories Overview
56
57Some of the key directories are shown below.
58
59```
60.
61├── src
62│   └── main/scala         # design files
63│       ├── device         # virtual device for simulation
64│       ├── system         # SoC wrapper
65│       ├── top            # top module
66│       ├── utils          # utilization code
67│       └── xiangshan      # main design code
68│           └── transforms # some useful firrtl transforms
69├── scripts                # scripts for agile development
70├── fudian                 # floating unit submodule of XiangShan
71├── huancun                # L2/L3 cache submodule of XiangShan
72├── difftest               # difftest co-simulation framework
73└── ready-to-run           # pre-built simulation images
74```
75
76## IDE Support
77
78### bsp
79```
80make bsp
81```
82
83### IDEA
84```
85make idea
86```
87
88
89## Generate Verilog
90
91* Run `make verilog` to generate verilog code. The output file is `build/XSTop.v`.
92* Refer to `Makefile` for more information.
93
94
95
96## Run Programs by Simulation
97
98### Prepare environment
99
100* Set environment variable `NEMU_HOME` to the **absolute path** of the [NEMU project](https://github.com/OpenXiangShan/NEMU).
101* Set environment variable `NOOP_HOME` to the **absolute path** of the XiangShan project.
102* Set environment variable `AM_HOME` to the **absolute path** of the [AM project](https://github.com/OpenXiangShan/nexus-am).
103* Install `mill`. Refer to [the Manual section in this guide](https://mill-build.org/mill/0.11.11/Scala_Installation_IDE_Support.html#_bootstrap_scripts).
104* Clone this project and run `make init` to initialize submodules.
105
106### Run with simulator
107
108* Install [Verilator](https://verilator.org/guide/latest/), the open-source Verilog simulator.
109* Run `make emu` to build the C++ simulator `./build/emu` with Verilator.
110* Refer to `./build/emu --help` for run-time arguments of the simulator.
111* Refer to `Makefile` and `verilator.mk` for more information.
112
113Example:
114
115```bash
116make emu CONFIG=MinimalConfig EMU_THREADS=2 -j10
117./build/emu -b 0 -e 0 -i ./ready-to-run/coremark-2-iteration.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so
118```
119
120## Troubleshooting Guide
121
122[Troubleshooting Guide](https://github.com/OpenXiangShan/XiangShan/wiki/Troubleshooting-Guide)
123
124## Acknowledgement
125
126The implementation of XiangShan is inspired by several key papers. We list these papers in XiangShan document, see: [Acknowledgements](https://docs.xiangshan.cc/zh-cn/latest/acknowledgments/). We very much encourage and expect that more academic innovations can be realised based on XiangShan in the future.
127
128## LICENSE
129
130Copyright © 2020-2025 Institute of Computing Technology, Chinese Academy of Sciences.
131
132Copyright © 2021-2025 Beijing Institute of Open Source Chip
133
134Copyright © 2020-2022 by Peng Cheng Laboratory.
135
136XiangShan is licensed under [Mulan PSL v2](LICENSE).
137

readme.zh-cn.md

1# 香山
2
3香山(XiangShan)是一款开源的高性能 RISC-V 处理器。
4
5English Readme is [here](README.md).
6
7## 文档和报告
8
9香山的文档托管在 [docs.xiangshan.cc](https://docs.xiangshan.cc)10
11[docs.xiangshan.cc](https://docs.xiangshan.cc) 上的微架构文档尚未根据最新架构(昆明湖)更新,我们正在撰写新的设计文档。
12
13香山用户文档已单独发布,您可在此处查看:[XiangShan-User-Guide/releases](https://github.com/OpenXiangShan/XiangShan-User-Guide/releases)
14
15## 论文发表情况
16
17### MICRO 2022: Towards Developing High Performance RISC-V Processors Using Agile Methodology
18
19我们在 MICRO'22 会议上的论文介绍了香山处理器及敏捷开发实践经验,包括一些面向设计、功能验证、调试、性能评估等方面的敏捷开发工具。论文得到了 Artifact Evaluation 的所有三个徽章。
20
21![Artifacts Available](https://github.com/OpenXiangShan/XiangShan-doc/raw/main/publications/images/artifacts_available_dl.jpg)
22![Artifacts Evaluated — Functional](https://github.com/OpenXiangShan/XiangShan-doc/raw/main/publications/images/artifacts_evaluated_functional_dl.jpg)
23![Results Reproduced](https://github.com/OpenXiangShan/XiangShan-doc/raw/main/publications/images/results_reproduced_dl.jpg)
24
25[Paper PDF](https://github.com/OpenXiangShan/XiangShan-doc/blob/main/publications/micro2022-xiangshan.pdf) | [IEEE Xplore](https://ieeexplore.ieee.org/abstract/document/9923860) | [BibTeX](https://github.com/OpenXiangShan/XiangShan-doc/blob/main/publications/micro2022-xiangshan.bib) | [Presentation Slides](https://github.com/OpenXiangShan/XiangShan-doc/blob/main/publications/micro2022-xiangshan-slides.pdf) | [Presentation Video](https://www.bilibili.com/video/BV1FB4y1j7Jy)
26
27
28## 关注我们
29
30Wechat/微信:香山开源处理器
31
32<div align=left><img width="340" height="117" src="images/wechat.png"/></div>
33
34Zhihu/知乎:[香山开源处理器](https://www.zhihu.com/people/openxiangshan)
35
36Weibo/微博:[香山开源处理器](https://weibo.com/u/7706264932)
37
38可以通过[我们的邮件列表](mailto:[email protected])联系我们。列表中的所有邮件会存档到[这里](https://www.mail-archive.com/[email protected]/)39
40## 处理器架构
41
42自 2020 年 6 月开始开发的[雁栖湖](https://github.com/OpenXiangShan/XiangShan/tree/yanqihu)为香山处理器的首个稳定的微架构。
43
44香山的第二代微架构被命名为[南湖](https://github.com/OpenXiangShan/XiangShan/tree/nanhu)45
46香山的第三代微架构(昆明湖)正在 master 分支上不断开发中。
47
48昆明湖微架构概览:
49![xs-arch-kunminghu](images/xs-arch-kunminghu.svg)
50
51## 目录概览
52
53以下是一些关键目录:
54
55```
56.
57├── src
58│   └── main/scala         # 设计文件
59│       ├── device         # 用于仿真的虚拟设备
60│       ├── system         # SoC 封装
61│       ├── top            # 顶层模块
62│       ├── utils          # 复用封装
63│       └── xiangshan      # 主体设计代码
64│           └── transforms # 一些实用的 firrtl 变换代码
65├── scripts                # 用于敏捷开发的脚本文件
66├── fudian                 # 香山浮点子模块
67├── huancun                # 香山 L2/L3 缓存子模块
68├── difftest               # 香山协同仿真框架
69└── read-to-run            # 预建的仿真镜像文件
70```
71
72## IDE 支持
73
74### bsp
75```
76make bsp
77```
78
79### IDEA
80```
81make idea
82```
83
84
85## 生成 Verilog
86
87* 运行 `make verilog` 以生成 verilog 代码。输出文件为 `build/XSTop.v`。
88* 更多信息详见 `Makefile`。
89
90## 仿真运行
91
92### 环境搭建
93
94* 设定环境变量 `NEMU_HOME` 为[香山 NEMU](https://github.com/OpenXiangShan/NEMU) 在您机器上的绝对路径。
95* 设定环境变量 `NOOP_HOME` 为香山工程文件夹的绝对路径。
96* 设定环境变量 `AM_HOME` 为[香山 AM](https://github.com/OpenXiangShan/nexus-am) 的绝对路径。
97* 项目使用 `mill` 进行 scala 编译,因此需要安装 `mill`,详见 [mill 手动安装指南](https://com-lihaoyi.github.io/mill/mill/Intro_to_Mill.html#_installation)(目前仅英文版本)。
98* 克隆本项目,运行 `make init` 以初始化本项目引用的开源子模块。
99
100### 运行仿真
101
102* 安装开源 verilog 仿真器 [Verilator](https://verilator.org/guide/latest/)103* 运行 `make emu` 以利用 Verilator 构建 C++ 仿真器 `./build/emu`。
104* 运行 `./build/emu --help` 可以获得仿真器的各种运行时参数。
105* 更多细节详见 `Makefile` 与 `verilator.mk`。
106
107运行示例:
108
109```bash
110make emu CONFIG=MinimalConfig EMU_THREADS=2 -j10
111./build/emu -b 0 -e 0 -i ./ready-to-run/coremark-2-iteration.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so
112```
113
114## 错误排除指南
115
116[Troubleshooting Guide](https://github.com/OpenXiangShan/XiangShan/wiki/Troubleshooting-Guide)
117
118## 致谢
119
120香山处理器是绝佳的微架构学术研究平台,能够充分支持学术界的试验创新想法。香山处理器中已经实现或参考借鉴了如下论文,列举如下:[致谢](https://docs.xiangshan.cc/zh-cn/latest/acknowledgments/)。我们非常鼓励并期待,未来能够基于香山处理器实现更多的学术创新。
121
122## 许可证
123
124版权所有 © 2020-2025 中国科学院计算技术研究所
125
126版权所有 © 2021-2025 北京开源芯片研究院
127
128版权所有 © 2020-2022 鹏城实验室
129
130香山以 [木兰宽松许可证 第2版](LICENSE) 授权。
131