xref: /XiangShan/readme.zh-cn.md (revision 57bb43b5f11c3f1e89ac52f232fe73056b35d9bd)
1# 香山
2
3香山(XiangShan)是一款开源的高性能 RISC-V 处理器。
4
5English Readme is [here](README.md).
6
7©2020-2022 中国科学院计算技术研究所版权所有
8
9©2020-2022 鹏城实验室版权所有
10
11## 文档和报告
12
13[XiangShan-doc](https://github.com/OpenXiangShan/XiangShan-doc) 是我们的官方文档仓库,其中包含了设计文档、技术报告、使用教程等内容。
14
15* 香山微结构文档已经发布,欢迎访问 https://xiangshan-doc.readthedocs.io
16
17## 关注我们
18
19Wechat/微信:香山开源处理器
20
21<div align=left><img width="340" height="117" src="images/wechat.png"/></div>
22
23Zhihu/知乎:[香山开源处理器](https://www.zhihu.com/people/openxiangshan)
24
25Weibo/微博:[香山开源处理器](https://weibo.com/u/7706264932)
26
27可以通过[我们的邮件列表](mailto:[email protected])联系我们。列表中的所有邮件会存档到[这里](https://www.mail-archive.com/[email protected]/)28
29## 处理器架构
30
31自 2020 年 6 月开始开发的[雁栖湖](https://github.com/OpenXiangShan/XiangShan/tree/yanqihu)为香山处理器的首个稳定的微架构。目前版本的香山(即南湖)正在 master 分支上不断开发中。
32
33南湖微架构概览:
34![xs-arch-nanhu](images/xs-arch-nanhu.svg)
35
36## 目录概览
37
38以下是一些关键目录:
39
40```
41.
42├── src
43│   └── main/scala         # 设计文件
44│       ├── device         # 用于仿真的虚拟设备
45│       ├── system         # SoC 封装
46│       ├── top            # 顶层模块
47│       ├── utils          # 复用封装
48│       ├── xiangshan      # 主体设计代码
49│       └── xstransforms   # 一些实用的 firrtl 变换代码
50├── scripts                # 用于敏捷开发的脚本文件
51├── fudian                 # 香山浮点子模块
52├── huancun                # 香山 L2/L3 缓存子模块
53├── difftest               # 香山协同仿真框架
54└── read-to-run            # 预建的仿真镜像文件
55```
56
57## IDE 支持
58
59### bsp
60```
61make bsp
62```
63
64### IDEA
65```
66make idea
67```
68
69
70## 生成 Verilog
71
72* 运行 `make verilog` 以生成 verilog 代码。输出文件为 `build/XSTop.v`。
73* 更多信息详见 `Makefile`。
74
75## 仿真运行
76
77### 环境搭建
78
79* 设定环境变量 `NEMU_HOME` 为[香山 NEMU](https://github.com/OpenXiangShan/NEMU) 在您机器上的绝对路径。
80* 设定环境变量 `NOOP_HOME` 为香山工程文件夹的绝对路径。
81* 设定环境变量 `AM_HOME` 为[香山 AM](https://github.com/OpenXiangShan/nexus-am) 的绝对路径。
82* 项目使用 `mill` 进行 scala 编译,因此需要安装 `mill`,详见 [mill 手动安装指南](https://com-lihaoyi.github.io/mill/mill/Intro_to_Mill.html#_installation)(目前仅英文版本)。
83* 克隆本项目,运行 `make init` 以初始化本项目引用的开源子模块。
84
85### 运行仿真
86
87* 安装开源 verilog 仿真器 [Verilator](https://verilator.org/guide/latest/)88* 运行 `make emu` 以利用 Verilator 构建 C++ 仿真器 `./build/emu`。
89* 运行 `./build/emu --help` 可以获得仿真器的各种运行时参数。
90* 更多细节详见 `Makefile` 与 `verilator.mk`。
91
92运行示例:
93
94```bash
95make emu CONFIG=MinimalConfig EMU_THREADS=2 -j10
96./build/emu -b 0 -e 0 -i ./ready-to-run/coremark-2-iteration.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so
97```
98
99## 错误排除指南
100
101[Troubleshooting Guide](https://github.com/OpenXiangShan/XiangShan/wiki/Troubleshooting-Guide)
102
103## 致谢
104
105在香山的开发过程中,我们采用了来自开源社区的子模块。具体情况如下:
106
107| 子模块         | 来源                                                       | 详细用途                                                       |
108| ------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
109| L2 Cache/LLC       | [Sifive block-inclusivecache](https://github.com/ucb-bar/block-inclusivecache-sifive) | 我们的新 L2/L3 缓存设计受到了 Sifive `block-inclusivecache` 的启发. |
110| Diplomacy/TileLink | [Rocket-chip](https://github.com/chipsalliance/rocket-chip)  | 我们复用了来自 rocket-chip 的 Diplomacy 框架和 Tilelink 工具,来协商总线. |
111
112我们深深地感谢来自开源社区的支持,我们也鼓励其他开源项目在[木兰宽松许可证](LICENSE)的范围下复用我们的代码。
113