Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
XiangShan
提交
1545277a
X
XiangShan
项目概览
OpenXiangShan
/
XiangShan
10 个月 前同步成功
通知
1183
Star
3914
Fork
526
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
XiangShan
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
1545277a
编写于
11月 11, 2021
作者:
Y
Yinan Xu
提交者:
GitHub
11月 11, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
top: enable fpga option for simulation emu (#1213)
* disable log as default * code clean up
上级
3c473edf
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
170 addition
and
186 deletion
+170
-186
.github/workflows/emu.yml
.github/workflows/emu.yml
+4
-4
Makefile
Makefile
+17
-11
README.md
README.md
+1
-1
difftest
difftest
+1
-1
readme.zh-cn.md
readme.zh-cn.md
+96
-96
scripts/xiangshan.py
scripts/xiangshan.py
+6
-3
src/main/scala/top/ArgParser.scala
src/main/scala/top/ArgParser.scala
+14
-12
src/main/scala/utils/LogUtils.scala
src/main/scala/utils/LogUtils.scala
+4
-3
src/main/scala/xiangshan/Parameters.scala
src/main/scala/xiangshan/Parameters.scala
+3
-2
src/main/scala/xiangshan/XSCore.scala
src/main/scala/xiangshan/XSCore.scala
+0
-8
src/main/scala/xiangshan/backend/Scheduler.scala
src/main/scala/xiangshan/backend/Scheduler.scala
+2
-2
src/main/scala/xiangshan/backend/dispatch/Dispatch.scala
src/main/scala/xiangshan/backend/dispatch/Dispatch.scala
+1
-1
src/main/scala/xiangshan/backend/fu/CSR.scala
src/main/scala/xiangshan/backend/fu/CSR.scala
+3
-16
src/main/scala/xiangshan/backend/rob/Rob.scala
src/main/scala/xiangshan/backend/rob/Rob.scala
+5
-11
src/main/scala/xiangshan/cache/dcache/mainpipe/MissQueue.scala
...ain/scala/xiangshan/cache/dcache/mainpipe/MissQueue.scala
+1
-1
src/main/scala/xiangshan/mem/lsqueue/StoreQueue.scala
src/main/scala/xiangshan/mem/lsqueue/StoreQueue.scala
+1
-1
src/main/scala/xiangshan/mem/pipeline/AtomicsUnit.scala
src/main/scala/xiangshan/mem/pipeline/AtomicsUnit.scala
+1
-1
src/main/scala/xiangshan/mem/sbuffer/Sbuffer.scala
src/main/scala/xiangshan/mem/sbuffer/Sbuffer.scala
+1
-1
src/test/scala/top/SimTop.scala
src/test/scala/top/SimTop.scala
+9
-11
未找到文件。
.github/workflows/emu.yml
浏览文件 @
1545277a
...
...
@@ -31,10 +31,10 @@ jobs:
-
name
:
check verilog
run
:
python3 $GITHUB_WORKSPACE/.github/workflows/check_verilog.py build/XSTop.v
-
name
:
build MinimalConfig emu
-
name
:
build MinimalConfig
Release
emu
run
:
|
python3 $GITHUB_WORKSPACE/scripts/xiangshan.py --build \
--
disable-log --threads 4 --config MinimalConfig
--
threads 4 --config MinimalConfig --release
-
name
:
run MinimalConfig - Linux
run
:
|
python3 $GITHUB_WORKSPACE/scripts/xiangshan.py --wave-dump $WAVE_HOME --threads 4 --numa --ci linux-hello 2> perf.log
...
...
@@ -59,7 +59,7 @@ jobs:
mkdir -p /bigdata/xs-wave/${HEAD_SHA}
-
name
:
Build EMU
run
:
|
python3 $GITHUB_WORKSPACE/scripts/xiangshan.py --wave-dump $WAVE_HOME --build --
disable-log --
threads 8
python3 $GITHUB_WORKSPACE/scripts/xiangshan.py --wave-dump $WAVE_HOME --build --threads 8
-
name
:
Basic Test - cputest
run
:
|
python3 $GITHUB_WORKSPACE/scripts/xiangshan.py --wave-dump $WAVE_HOME --threads 8 --ci cputest 2> /dev/zero
...
...
@@ -107,7 +107,7 @@ jobs:
run
:
|
python3 $GITHUB_WORKSPACE/scripts/xiangshan.py --build \
--dramsim3 /home/ci-runner/xsenv/DRAMsim3 \
--
disable-log --
with-dramsim3 --threads 16
--with-dramsim3 --threads 16
-
name
:
SPEC06 Test - mcf
run
:
|
python3 $GITHUB_WORKSPACE/scripts/xiangshan.py --wave-dump $WAVE_HOME --threads 16 --max-instr 5000000 --numa --ci mcf 2> perf.log
...
...
Makefile
浏览文件 @
1545277a
...
...
@@ -35,6 +35,13 @@ endif
override
SIM_ARGS
+=
--with-dramsim3
endif
# emu for the release version
RELEASE_ARGS
=
--disable-all
--remove-assert
--fpga-platform
DEBUG_ARGS
=
--enable-difftest
ifeq
($(RELEASE),1)
override
SIM_ARGS
+=
$(RELEASE_ARGS)
endif
TIMELOG
=
$(BUILD_DIR)
/time.log
TIME_CMD
=
time
-a
-o
$(TIMELOG)
...
...
@@ -45,12 +52,11 @@ help:
$(TOP_V)
:
$(SCALA_FILE)
mkdir
-p
$
(
@D
)
mill
-i
XiangShan.runMain
$(FPGATOP)
-td
$
(
@D
)
\
--config
$(CONFIG)
--full-stacktrace
--output-file
$
(
@F
)
\
--disable-all
--remove-assert
--infer-rw
\
--repl-seq-mem
-c
:
$(FPGATOP)
:-o:
$
(
@D
)
/
$
(
@F
)
.conf
\
--gen-mem-verilog
full
$(SIM_ARGS)
\
--num-cores
$(NUM_CORES)
mill
-i
XiangShan.runMain
$(FPGATOP)
-td
$
(
@D
)
\
--config
$(CONFIG)
--full-stacktrace
--output-file
$
(
@F
)
\
--repl-seq-mem
-c
:
$(FPGATOP)
:-o:
$
(
@D
)
/
$
(
@F
)
.conf
--infer-rw
\
--gen-mem-verilog
full
--num-cores
$(NUM_CORES)
\
$(RELEASE_ARGS)
sed
-i
-e
's/_\(aw\|ar\|w\|r\|b\)_\(\|bits_\)/_\1/g'
$@
@
git log
-n
1
>>
.__head__
@
git diff
>>
.__diff__
...
...
@@ -68,11 +74,11 @@ $(SIM_TOP_V): $(SCALA_FILE) $(TEST_FILE)
mkdir
-p
$
(
@D
)
@
echo
"
\n
[mill] Generating Verilog files..."
>
$(TIMELOG)
@
date
-R
|
tee
-a
$(TIMELOG)
$(TIME_CMD)
mill
-i
XiangShan.test.runMain
$(SIMTOP)
-td
$
(
@D
)
\
--config
$(CONFIG)
--full-stacktrace
--output-file
$
(
@F
)
\
--
num-cores
$(NUM_CORES)
$(SIM_ARGS)
--infer-rw
\
--
repl-seq-mem
-c
:
$(SIMTOP)
:-o:
$
(
@D
)
/
$
(
@F
)
.conf
\
--gen-mem-verilog
full
$(TIME_CMD)
mill
-i
XiangShan.test.runMain
$(SIMTOP)
-td
$
(
@D
)
\
--config
$(CONFIG)
--full-stacktrace
--output-file
$
(
@F
)
\
--
repl-seq-mem
-c
:
$(SIMTOP)
:-o:
$
(
@D
)
/
$
(
@F
)
.conf
--infer-rw
\
--
gen-mem-verilog
full
--num-cores
$(NUM_CORES)
\
$(DEBUG_ARGS)
$(SIM_ARGS)
@
git log
-n
1
>>
.__head__
@
git diff
>>
.__diff__
@
sed
-i
's/^/\/\// '
.__head__
...
...
README.md
浏览文件 @
1545277a
...
...
@@ -86,7 +86,7 @@ Some of the key directories are shown below.
Example:
```
bash
make emu
CONFIG
=
MinimalConfig
SIM_ARGS
=
--disable-log
EMU_THREADS
=
2
-j10
make emu
CONFIG
=
MinimalConfig
EMU_THREADS
=
2
-j10
./build/emu
-b
0
-e
0
-i
./ready-to-run/coremark-2-iteration.bin
--diff
./ready-to-run/riscv64-nemu-interpreter-so
```
...
...
difftest
@
fb00a5a7
比较
ccc5d733
...
fb00a5a7
Subproject commit
ccc5d73381c4e3a1bf79d8f51aa068dc118b6963
Subproject commit
fb00a5a7b020a1d66f854322c862c8cdaf2fb5a9
readme.zh-cn.md
浏览文件 @
1545277a
# 香山
香山是一款开源的高性能 RISC-V 处理器。采用 Chisel 硬件设计语言开发,支持 RV64GC 指令集。
详细文档将在未来放出。
English Readme is
[
here
](
README.md
)
.
©2020-2021 中国科学院计算技术研究所版权所有。
## 文档和报告
在 2021 年 6 月的 RISC-V 中国峰会上,我们给出了超过 20 个技术报告。报告已经更新到
[
我们的文档仓库
](
https://github.com/OpenXiangShan/XiangShan-doc
)
。
更多的文档也将持续更新到相同的仓库。
## 关注我们
Wechat/微信:香山开源处理器
<div
align=
left
><img
width=
"340"
height=
"117"
src=
"images/wechat.png"
/></div>
Zhihu/知乎:
[
香山开源处理器
](
https://www.zhihu.com/people/openxiangshan
)
Weibo/微博:
[
香山开源处理器
](
https://weibo.com/u/7706264932
)
可以通过
[
我们的邮件列表
](
mailto:xiangshan-all@ict.ac.cn
)
联系我们。列表中的所有邮件会存档到
[
这里
](
https://www.mail-archive.com/xiangshan-all@ict.ac.cn/
)
。
## 处理器架构
自 2020 年 6 月开始开发的
[
雁栖湖
](
https://github.com/OpenXiangShan/XiangShan/tree/yanqihu
)
为香山处理器的首个稳定的微架构。目前版本的香山(即南湖)正在 master 分支上不断开发中。
微架构概览:
![
xs-arch-single
](
images/xs-arch-simple.svg
)
## 目录概览
以下是一些关键目录:
```
.
├── fpga # 支持的 FPGA 开发板、用于构建 Vivado 项目的文件
├── read-to-run # 预建的仿真镜像文件
├── scripts # 用于敏捷开发的脚本文件
└── src
├── test # 测试文件(包括差异测试(diff-test)和模块测试(module-test) 等)
└── main/scala # 设计文件
├── bus/tilelink # tilelink 实用工具
├── device # 用于仿真的虚拟设备
├── difftest # chisel 差异测试接口
├── system # SoC 封装
├── top # 顶层模块
├── utils # 复用封装
├── xiangshan # 主体设计代码
└── xstransforms # 一些实用的 firrtl 变换代码
```
## 生成 Verilog
*
运行
`make verilog`
以生成 verilog 代码。输出文件为
`build/XSTop.v`
。
*
更多信息详见
`Makefile`
。
## 仿真运行
### 环境搭建
*
设定环境变量
`NEMU_HOME`
为
[
香山 NEMU
](
https://github.com/OpenXiangShan/NEMU
)
在您机器上的绝对路径。
*
设定环境变量
`NOOP_HOME`
为香山工程文件夹的绝对路径。
*
设定环境变量
`AM_HOME`
为
[
香山 AM
](
https://github.com/OpenXiangShan/nexus-am
)
的绝对路径。
*
项目使用
`mill`
进行 scala 编译,因此需要安装
`mill`
,详见
[
mill 手动安装指南
](
https://com-lihaoyi.github.io/mill/mill/Intro_to_Mill.html#_installation
)
(目前仅英文版本)。
*
克隆本项目,运行
`make init`
以初始化本项目引用的开源子模块。
### 运行仿真
*
安装开源 verilog 仿真器
[
Verilator
](
https://verilator.org/guide/latest/
)
。
*
运行
`make emu`
以利用 Verilator 构建 C++ 仿真器
`./build/emu`
。
*
运行
`./build/emu --help`
可以获得仿真器的各种运行时参数。
*
更多细节详见
`Makefile`
与
`verilator.mk`
。
运行示例:
```
bash
make emu
CONFIG
=
MinimalConfig
SIM_ARGS
=
--disable-log
EMU_THREADS
=
2
-j10
./build/emu
-b
0
-e
0
-i
./ready-to-run/coremark-2-iteration.bin
--diff
./ready-to-run/riscv64-nemu-interpreter-so
```
## 致谢
在香山的开发过程中,我们采用了来自开源社区的子模块。具体情况如下:
| 子模块 | 来源 | 详细用途 |
| ------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| L2 Cache/LLC |
[
Sifive block-inclusivecache
](
https://github.com/ucb-bar/block-inclusivecache-sifive
)
| 我们增强了原模块的功能和时序,最终使之能胜任 L2/LLC 任务的缓存生成器 |
| Diplomacy/TileLink |
[
Rocket-chip
](
https://github.com/chipsalliance/rocket-chip
)
| 我们复用了来自 rocket-chip 的外接框架和链接,来调度总线 |
| FPU |
[
Berkeley hardfloat
](
https://github.com/ucb-bar/berkeley-hardfloat
)
| 我们使用了 Barkeley-hardfloat 作为浮点运算器并为之设计了 SRT-4 除法/开方运算单元。此外我们分割了 FMA 流水线以优化时序 |
我们深深地感谢来自开源社区的支持,我们也鼓励其他开源项目在
[
木兰宽松许可证
](
LICENSE
)
的范围下复用我们的代码。:)
# 香山
香山是一款开源的高性能 RISC-V 处理器。采用 Chisel 硬件设计语言开发,支持 RV64GC 指令集。
详细文档将在未来放出。
English Readme is
[
here
](
README.md
)
.
©2020-2021 中国科学院计算技术研究所版权所有。
## 文档和报告
在 2021 年 6 月的 RISC-V 中国峰会上,我们给出了超过 20 个技术报告。报告已经更新到
[
我们的文档仓库
](
https://github.com/OpenXiangShan/XiangShan-doc
)
。
更多的文档也将持续更新到相同的仓库。
## 关注我们
Wechat/微信:香山开源处理器
<div
align=
left
><img
width=
"340"
height=
"117"
src=
"images/wechat.png"
/></div>
Zhihu/知乎:
[
香山开源处理器
](
https://www.zhihu.com/people/openxiangshan
)
Weibo/微博:
[
香山开源处理器
](
https://weibo.com/u/7706264932
)
可以通过
[
我们的邮件列表
](
mailto:xiangshan-all@ict.ac.cn
)
联系我们。列表中的所有邮件会存档到
[
这里
](
https://www.mail-archive.com/xiangshan-all@ict.ac.cn/
)
。
## 处理器架构
自 2020 年 6 月开始开发的
[
雁栖湖
](
https://github.com/OpenXiangShan/XiangShan/tree/yanqihu
)
为香山处理器的首个稳定的微架构。目前版本的香山(即南湖)正在 master 分支上不断开发中。
微架构概览:
![
xs-arch-single
](
images/xs-arch-simple.svg
)
## 目录概览
以下是一些关键目录:
```
.
├── fpga # 支持的 FPGA 开发板、用于构建 Vivado 项目的文件
├── read-to-run # 预建的仿真镜像文件
├── scripts # 用于敏捷开发的脚本文件
└── src
├── test # 测试文件(包括差异测试(diff-test)和模块测试(module-test) 等)
└── main/scala # 设计文件
├── bus/tilelink # tilelink 实用工具
├── device # 用于仿真的虚拟设备
├── difftest # chisel 差异测试接口
├── system # SoC 封装
├── top # 顶层模块
├── utils # 复用封装
├── xiangshan # 主体设计代码
└── xstransforms # 一些实用的 firrtl 变换代码
```
## 生成 Verilog
*
运行
`make verilog`
以生成 verilog 代码。输出文件为
`build/XSTop.v`
。
*
更多信息详见
`Makefile`
。
## 仿真运行
### 环境搭建
*
设定环境变量
`NEMU_HOME`
为
[
香山 NEMU
](
https://github.com/OpenXiangShan/NEMU
)
在您机器上的绝对路径。
*
设定环境变量
`NOOP_HOME`
为香山工程文件夹的绝对路径。
*
设定环境变量
`AM_HOME`
为
[
香山 AM
](
https://github.com/OpenXiangShan/nexus-am
)
的绝对路径。
*
项目使用
`mill`
进行 scala 编译,因此需要安装
`mill`
,详见
[
mill 手动安装指南
](
https://com-lihaoyi.github.io/mill/mill/Intro_to_Mill.html#_installation
)
(目前仅英文版本)。
*
克隆本项目,运行
`make init`
以初始化本项目引用的开源子模块。
### 运行仿真
*
安装开源 verilog 仿真器
[
Verilator
](
https://verilator.org/guide/latest/
)
。
*
运行
`make emu`
以利用 Verilator 构建 C++ 仿真器
`./build/emu`
。
*
运行
`./build/emu --help`
可以获得仿真器的各种运行时参数。
*
更多细节详见
`Makefile`
与
`verilator.mk`
。
运行示例:
```
bash
make emu
CONFIG
=
MinimalConfig
EMU_THREADS
=
2
-j10
./build/emu
-b
0
-e
0
-i
./ready-to-run/coremark-2-iteration.bin
--diff
./ready-to-run/riscv64-nemu-interpreter-so
```
## 致谢
在香山的开发过程中,我们采用了来自开源社区的子模块。具体情况如下:
| 子模块 | 来源 | 详细用途 |
| ------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| L2 Cache/LLC |
[
Sifive block-inclusivecache
](
https://github.com/ucb-bar/block-inclusivecache-sifive
)
| 我们增强了原模块的功能和时序,最终使之能胜任 L2/LLC 任务的缓存生成器 |
| Diplomacy/TileLink |
[
Rocket-chip
](
https://github.com/chipsalliance/rocket-chip
)
| 我们复用了来自 rocket-chip 的外接框架和链接,来调度总线 |
| FPU |
[
Berkeley hardfloat
](
https://github.com/ucb-bar/berkeley-hardfloat
)
| 我们使用了 Barkeley-hardfloat 作为浮点运算器并为之设计了 SRT-4 除法/开方运算单元。此外我们分割了 FMA 流水线以优化时序 |
我们深深地感谢来自开源社区的支持,我们也鼓励其他开源项目在
[
木兰宽松许可证
](
LICENSE
)
的范围下复用我们的代码。:)
scripts/xiangshan.py
浏览文件 @
1545277a
...
...
@@ -48,11 +48,12 @@ class XSArgs(object):
for
(
arg_in
,
env
,
default
,
set_func
)
in
all_path
:
set_func
(
self
.
__extract_path
(
arg_in
,
env
,
default
))
# Chisel arguments
self
.
disable_log
=
args
.
dis
able_log
self
.
enable_log
=
args
.
en
able_log
self
.
num_cores
=
args
.
num_cores
# Makefile arguments
self
.
threads
=
args
.
threads
self
.
with_dramsim3
=
1
if
args
.
with_dramsim3
else
None
self
.
is_release
=
1
if
args
.
release
else
None
self
.
trace
=
1
if
args
.
trace
or
not
args
.
disable_fork
else
None
self
.
config
=
args
.
config
# emu arguments
...
...
@@ -79,7 +80,7 @@ class XSArgs(object):
def
get_chisel_args
(
self
,
prefix
=
None
):
chisel_args
=
[
(
self
.
disable_log
,
"dis
able-log"
)
(
self
.
enable_log
,
"en
able-log"
)
]
args
=
map
(
lambda
x
:
x
[
1
],
filter
(
lambda
arg
:
arg
[
0
],
chisel_args
))
if
prefix
is
not
None
:
...
...
@@ -90,6 +91,7 @@ class XSArgs(object):
makefile_args
=
[
(
self
.
threads
,
"EMU_THREADS"
),
(
self
.
with_dramsim3
,
"WITH_DRAMSIM3"
),
(
self
.
is_release
,
"RELEASE"
),
(
self
.
trace
,
"EMU_TRACE"
),
(
self
.
config
,
"CONFIG"
),
(
self
.
num_cores
,
"NUM_CORES"
)
...
...
@@ -300,9 +302,10 @@ if __name__ == "__main__":
parser
.
add_argument
(
'--rvtest'
,
nargs
=
'?'
,
type
=
str
,
help
=
'path to riscv-tests'
)
parser
.
add_argument
(
'--wave-dump'
,
nargs
=
'?'
,
type
=
str
,
help
=
'path to dump wave'
)
# chisel arguments
parser
.
add_argument
(
'--
disable-log'
,
action
=
'store_true'
,
help
=
'dis
able log'
)
parser
.
add_argument
(
'--
enable-log'
,
action
=
'store_true'
,
help
=
'en
able log'
)
parser
.
add_argument
(
'--num-cores'
,
type
=
int
,
help
=
'number of cores'
)
# makefile arguments
parser
.
add_argument
(
'--release'
,
action
=
'store_true'
,
help
=
'enable release'
)
parser
.
add_argument
(
'--with-dramsim3'
,
action
=
'store_true'
,
help
=
'enable dramsim3'
)
parser
.
add_argument
(
'--threads'
,
nargs
=
'?'
,
type
=
int
,
help
=
'number of emu threads'
)
parser
.
add_argument
(
'--trace'
,
action
=
'store_true'
,
help
=
'enable waveform'
)
...
...
src/main/scala/top/ArgParser.scala
浏览文件 @
1545277a
...
...
@@ -31,9 +31,10 @@ object ArgParser {
|--xs-help print this help message
|--config <ConfigClassName>
|--num-cores <Int>
|--dual-core same as '--num-cores 2'
|--with-dramsim3
|--disable-log
|--fpga-platform
|--enable-difftest
|--enable-log
|--disable-perf
|"""
.
stripMargin
...
...
@@ -45,7 +46,7 @@ object ArgParser {
val
c
=
Class
.
forName
(
prefix
+
confString
).
getConstructor
(
Integer
.
TYPE
)
c
.
newInstance
(
1.
asInstanceOf
[
Object
]).
asInstanceOf
[
Parameters
]
}
def
parse
(
args
:
Array
[
String
]
,
fpga
:
Boolean
=
true
)
:
(
Parameters
,
Array
[
String
])
=
{
def
parse
(
args
:
Array
[
String
])
:
(
Parameters
,
Array
[
String
])
=
{
val
default
=
new
DefaultConfig
(
1
)
var
firrtlOpts
=
Array
[
String
]()
@tailrec
...
...
@@ -64,15 +65,21 @@ object ArgParser {
up
(
XSTileKey
).
head
.
copy
(
HartId
=
i
)
}
}),
tail
)
case
"--dual-core"
::
tail
=>
nextOption
(
config
,
"--num-cores"
::
"2"
::
tail
)
case
"--with-dramsim3"
::
tail
=>
nextOption
(
config
.
alter
((
site
,
here
,
up
)
=>
{
case
DebugOptionsKey
=>
up
(
DebugOptionsKey
).
copy
(
UseDRAMSim
=
true
)
}),
tail
)
case
"--
disable-log
"
::
tail
=>
case
"--
fpga-platform
"
::
tail
=>
nextOption
(
config
.
alter
((
site
,
here
,
up
)
=>
{
case
DebugOptionsKey
=>
up
(
DebugOptionsKey
).
copy
(
EnableDebug
=
false
)
case
DebugOptionsKey
=>
up
(
DebugOptionsKey
).
copy
(
FPGAPlatform
=
true
)
}),
tail
)
case
"--enable-difftest"
::
tail
=>
nextOption
(
config
.
alter
((
site
,
here
,
up
)
=>
{
case
DebugOptionsKey
=>
up
(
DebugOptionsKey
).
copy
(
EnableDifftest
=
true
)
}),
tail
)
case
"--enable-log"
::
tail
=>
nextOption
(
config
.
alter
((
site
,
here
,
up
)
=>
{
case
DebugOptionsKey
=>
up
(
DebugOptionsKey
).
copy
(
EnableDebug
=
true
)
}),
tail
)
case
"--disable-perf"
::
tail
=>
nextOption
(
config
.
alter
((
site
,
here
,
up
)
=>
{
...
...
@@ -85,11 +92,6 @@ object ArgParser {
}
}
var
config
=
nextOption
(
default
,
args
.
toList
)
if
(!
fpga
){
config
=
config
.
alter
((
site
,
here
,
up
)
=>
{
case
DebugOptionsKey
=>
up
(
DebugOptionsKey
).
copy
(
FPGAPlatform
=
false
)
})
}
(
config
,
firrtlOpts
)
}
}
src/main/scala/utils/LogUtils.scala
浏览文件 @
1545277a
...
...
@@ -43,7 +43,7 @@ object XSLog {
val
logTimestamp
=
WireInit
(
0.
U
(
64.
W
))
val
enableDebug
=
debugOpts
.
EnableDebug
&&
debugLevel
!=
XSLogLevel
.
PERF
val
enablePerf
=
debugOpts
.
EnablePerfDebug
&&
debugLevel
==
XSLogLevel
.
PERF
if
(
enableDebug
||
enablePerf
||
debugLevel
==
XSLogLevel
.
ERROR
)
{
if
(
!
debugOpts
.
FPGAPlatform
&&
(
enableDebug
||
enablePerf
||
debugLevel
==
XSLogLevel
.
ERROR
)
)
{
ExcitingUtils
.
addSink
(
logEnable
,
"DISPLAY_LOG_ENABLE"
)
ExcitingUtils
.
addSink
(
logTimestamp
,
"logTimestamp"
)
val
check_cond
=
(
if
(
debugLevel
==
XSLogLevel
.
ERROR
)
true
.
B
else
logEnable
)
&&
cond
...
...
@@ -58,9 +58,10 @@ object XSLog {
}
def
displayLog
(
implicit
p
:
Parameters
)
:
Bool
=
{
val
logEnable
=
WireInit
(
false
.
B
)
val
debugOpts
=
p
(
DebugOptionsKey
)
val
ret
=
WireInit
(
false
.
B
)
if
(
p
(
DebugOptionsKey
).
EnableDebug
)
{
if
(!
debugOpts
.
FPGAPlatform
&&
debugOpts
.
EnableDebug
)
{
val
logEnable
=
WireInit
(
false
.
B
)
ExcitingUtils
.
addSink
(
logEnable
,
"DISPLAY_LOG_ENABLE"
)
ret
:=
logEnable
}
...
...
src/main/scala/xiangshan/Parameters.scala
浏览文件 @
1545277a
...
...
@@ -226,8 +226,9 @@ case object DebugOptionsKey extends Field[DebugOptions]
case
class
DebugOptions
(
FPGAPlatform
:
Boolean
=
true
,
EnableDebug
:
Boolean
=
true
,
FPGAPlatform
:
Boolean
=
false
,
EnableDifftest
:
Boolean
=
false
,
EnableDebug
:
Boolean
=
false
,
EnablePerfDebug
:
Boolean
=
true
,
UseDRAMSim
:
Boolean
=
false
)
...
...
src/main/scala/xiangshan/XSCore.scala
浏览文件 @
1545277a
...
...
@@ -52,14 +52,6 @@ trait NeedImpl {
abstract
class
XSBundle
(
implicit
val
p
:
Parameters
)
extends
Bundle
with
HasXSParameter
case
class
EnviromentParameters
(
FPGAPlatform
:
Boolean
=
true
,
EnableDebug
:
Boolean
=
false
,
EnablePerfDebug
:
Boolean
=
true
,
DualCore
:
Boolean
=
false
)
abstract
class
XSCoreBase
()(
implicit
p
:
config.Parameters
)
extends
LazyModule
with
HasXSParameter
with
HasExuWbMappingHelper
{
...
...
src/main/scala/xiangshan/backend/Scheduler.scala
浏览文件 @
1545277a
...
...
@@ -448,13 +448,13 @@ class SchedulerImp(outer: Scheduler) extends LazyModuleImp(outer) with HasXSPara
}
}
if
(
!
env
.
FPGAPlatform
&&
intRfConfig
.
_1
)
{
if
(
env
.
EnableDifftest
&&
intRfConfig
.
_1
)
{
val
difftest
=
Module
(
new
DifftestArchIntRegState
)
difftest
.
io
.
clock
:=
clock
difftest
.
io
.
coreid
:=
hardId
.
U
difftest
.
io
.
gpr
:=
intRfReadData
.
takeRight
(
32
)
}
if
(
!
env
.
FPGAPlatform
&&
fpRfConfig
.
_1
)
{
if
(
env
.
EnableDifftest
&&
fpRfConfig
.
_1
)
{
val
difftest
=
Module
(
new
DifftestArchFpRegState
)
difftest
.
io
.
clock
:=
clock
difftest
.
io
.
coreid
:=
hardId
.
U
...
...
src/main/scala/xiangshan/backend/dispatch/Dispatch.scala
浏览文件 @
1545277a
...
...
@@ -156,7 +156,7 @@ class Dispatch(implicit p: Parameters) extends XSModule with HasExceptionNO {
// update singleStep
updatedUop
(
i
).
ctrl
.
singleStep
:=
io
.
singleStep
&&
(
if
(
i
==
0
)
singleStepStatus
else
true
.
B
)
if
(
!
env
.
FPGAPlatform
)
{
if
(
env
.
EnableDifftest
)
{
// debug runahead hint
val
debug_runahead_checkpoint_id
=
Wire
(
checkpoint_id
.
cloneType
)
if
(
i
==
0
){
...
...
src/main/scala/xiangshan/backend/fu/CSR.scala
浏览文件 @
1545277a
...
...
@@ -517,18 +517,6 @@ class CSR(implicit p: Parameters) extends FunctionUnit with HasCSRConst with PMP
// Hart Priviledge Mode
val
priviledgeMode
=
RegInit
(
UInt
(
2.
W
),
ModeM
)
// Emu perfcnt
val
hasEmuPerfCnt
=
!
env
.
FPGAPlatform
val
nrEmuPerfCnts
=
if
(
hasEmuPerfCnt
)
0x80
else
0x3
val
emuPerfCnts
=
List
.
fill
(
nrEmuPerfCnts
)(
RegInit
(
0.
U
(
XLEN
.
W
)))
val
emuPerfCntCond
=
List
.
fill
(
nrEmuPerfCnts
)(
WireInit
(
false
.
B
))
(
emuPerfCnts
zip
emuPerfCntCond
).
map
{
case
(
c
,
e
)
=>
when
(
e
)
{
c
:=
c
+
1.
U
}
}
val
emuPerfCntsLoMapping
=
(
0
until
nrEmuPerfCnts
).
map
(
i
=>
MaskedRegMap
(
0x1000
+
i
,
emuPerfCnts
(
i
)))
val
emuPerfCntsHiMapping
=
(
0
until
nrEmuPerfCnts
).
map
(
i
=>
MaskedRegMap
(
0x1080
+
i
,
emuPerfCnts
(
i
)(
63
,
32
)))
println
(
s
"CSR: hasEmuPerfCnt:${hasEmuPerfCnt}"
)
//val perfEventscounten = List.fill(nrPerfCnts)(RegInit(false(Bool())))
// Perf Counter
val
nrPerfCnts
=
29
// 3...31
...
...
@@ -746,8 +734,6 @@ class CSR(implicit p: Parameters) extends FunctionUnit with HasCSRConst with PMP
perfCntMapping
++
pmpMapping
++
pmaMapping
++
emuPerfCntsLoMapping
++
(
if
(
XLEN
==
32
)
emuPerfCntsHiMapping
else
Nil
)
++
(
if
(
HasFPU
)
fcsrMapping
else
Nil
)
++
(
if
(
HasCustomCSRCacheOp
)
cacheopMapping
else
Nil
)
...
...
@@ -1094,7 +1080,7 @@ class CSR(implicit p: Parameters) extends FunctionUnit with HasCSRConst with PMP
val
difftestIntrNO
=
Mux
(
raiseIntr
,
causeNO
,
0.
U
)
if
(
!
env
.
FPGAPlatform
)
{
if
(
env
.
EnableDifftest
)
{
val
difftest
=
Module
(
new
DifftestArchEvent
)
difftest
.
io
.
clock
:=
clock
difftest
.
io
.
coreid
:=
hardId
.
U
...
...
@@ -1103,7 +1089,7 @@ class CSR(implicit p: Parameters) extends FunctionUnit with HasCSRConst with PMP
difftest
.
io
.
exceptionPC
:=
RegNext
(
SignExt
(
csrio
.
exception
.
bits
.
uop
.
cf
.
pc
,
XLEN
))
}
if
(
!
env
.
FPGAPlatform
)
{
if
(
env
.
EnableDifftest
)
{
val
difftest
=
Module
(
new
DifftestCSRState
)
difftest
.
io
.
clock
:=
clock
difftest
.
io
.
coreid
:=
hardId
.
U
...
...
@@ -1127,6 +1113,7 @@ class CSR(implicit p: Parameters) extends FunctionUnit with HasCSRConst with PMP
difftest
.
io
.
medeleg
:=
medeleg
}
}
class
PFEvent
(
implicit
p
:
Parameters
)
extends
XSModule
with
HasCSRConst
{
val
io
=
IO
(
new
Bundle
{
val
distribute_csr
=
Flipped
(
new
DistributedCSRIO
())
...
...
src/main/scala/xiangshan/backend/rob/Rob.scala
浏览文件 @
1545277a
...
...
@@ -547,7 +547,7 @@ class Rob(numWbPorts: Int)(implicit p: Parameters) extends XSModule with HasCirc
io
.
commits
.
info
(
i
).
ldest
)
}
if
(
!
env
.
FPGAPlatform
)
{
if
(
env
.
EnableDifftest
)
{
io
.
commits
.
info
.
map
(
info
=>
dontTouch
(
info
.
pc
))
}
...
...
@@ -905,11 +905,6 @@ class Rob(numWbPorts: Int)(implicit p: Parameters) extends XSModule with HasCirc
XSPerfAccumulate
(
s
"${fuName}_latency_execute_fma"
,
ifCommit
(
latencySum
(
commitIsFma
,
executeLatency
)))
}
}
val
l1Miss
=
Wire
(
Bool
())
l1Miss
:=
false
.
B
ExcitingUtils
.
addSink
(
l1Miss
,
"TMA_l1miss"
)
XSPerfAccumulate
(
"TMA_L1miss"
,
deqNotWritebacked
&&
deqUopCommitType
===
CommitType
.
LOAD
&&
l1Miss
)
//difftest signals
val
firstValidCommit
=
(
deqPtr
+
PriorityMux
(
io
.
commits
.
valid
,
VecInit
(
List
.
tabulate
(
CommitWidth
)(
_
.
U
)))).
value
...
...
@@ -931,7 +926,7 @@ class Rob(numWbPorts: Int)(implicit p: Parameters) extends XSModule with HasCirc
val
trapCode
=
PriorityMux
(
wdata
.
zip
(
trapVec
).
map
(
x
=>
x
.
_2
->
x
.
_1
))
val
trapPC
=
SignExt
(
PriorityMux
(
wpc
.
zip
(
trapVec
).
map
(
x
=>
x
.
_2
->
x
.
_1
)),
XLEN
)
if
(
!
env
.
FPGAPlatform
)
{
if
(
env
.
EnableDifftest
)
{
for
(
i
<-
0
until
CommitWidth
)
{
val
difftest
=
Module
(
new
DifftestInstrCommit
)
difftest
.
io
.
clock
:=
clock
...
...
@@ -957,8 +952,6 @@ class Rob(numWbPorts: Int)(implicit p: Parameters) extends XSModule with HasCirc
difftest
.
io
.
wdata
:=
RegNext
(
exuData
)
difftest
.
io
.
wdest
:=
RegNext
(
uop
.
ctrl
.
ldest
)
// XSDebug(p"[difftest-instr-commit]valid:${difftest.io.valid},pc:${difftest.io.pc},instr:${difftest.io.instr},skip:${difftest.io.skip},isRVC:${difftest.io.isRVC},scFailed:${difftest.io.scFailed},wen:${difftest.io.wen},wdata:${difftest.io.wdata},wdest:${difftest.io.wdest}\n")
// runahead commit hint
val
runahead_commit
=
Module
(
new
DifftestRunaheadCommitEvent
)
runahead_commit
.
io
.
clock
:=
clock
...
...
@@ -971,7 +964,7 @@ class Rob(numWbPorts: Int)(implicit p: Parameters) extends XSModule with HasCirc
}
}
if
(
!
env
.
FPGAPlatform
)
{
if
(
env
.
EnableDifftest
)
{
for
(
i
<-
0
until
CommitWidth
)
{
val
difftest
=
Module
(
new
DifftestLoadEvent
)
difftest
.
io
.
clock
:=
clock
...
...
@@ -988,7 +981,7 @@ class Rob(numWbPorts: Int)(implicit p: Parameters) extends XSModule with HasCirc
}
}
if
(
!
env
.
FPGAPlatform
)
{
if
(
env
.
EnableDifftest
)
{
val
difftest
=
Module
(
new
DifftestTrapEvent
)
difftest
.
io
.
clock
:=
clock
difftest
.
io
.
coreid
:=
hardId
.
U
...
...
@@ -998,6 +991,7 @@ class Rob(numWbPorts: Int)(implicit p: Parameters) extends XSModule with HasCirc
difftest
.
io
.
cycleCnt
:=
timer
difftest
.
io
.
instrCnt
:=
instrCnt
}
val
perfinfo
=
IO
(
new
Bundle
(){
val
perfEvents
=
Output
(
new
PerfEventsBundle
(
18
))
})
...
...
src/main/scala/xiangshan/cache/dcache/mainpipe/MissQueue.scala
浏览文件 @
1545277a
...
...
@@ -518,7 +518,7 @@ class MissQueue(edge: TLEdgeOut)(implicit p: Parameters) extends DCacheModule {
io
.
full
:=
~
Cat
(
entries
.
map
(
_
.
io
.
primary_ready
)).
andR
if
(
!
env
.
FPGAPlatform
)
{
if
(
env
.
EnableDifftest
)
{
val
difftest
=
Module
(
new
DifftestRefillEvent
)
difftest
.
io
.
clock
:=
clock
difftest
.
io
.
coreid
:=
hardId
.
U
...
...
src/main/scala/xiangshan/mem/lsqueue/StoreQueue.scala
浏览文件 @
1545277a
...
...
@@ -556,7 +556,7 @@ class StoreQueue(implicit p: Parameters) extends XSModule with HasDCacheParamete
}
}
if
(
!
env
.
FPGAPlatform
)
{
if
(
env
.
EnableDifftest
)
{
for
(
i
<-
0
until
StorePipelineWidth
)
{
val
storeCommit
=
io
.
sbuffer
(
i
).
fire
()
val
waddr
=
SignExt
(
io
.
sbuffer
(
i
).
bits
.
addr
,
64
)
...
...
src/main/scala/xiangshan/mem/pipeline/AtomicsUnit.scala
浏览文件 @
1545277a
...
...
@@ -290,7 +290,7 @@ class AtomicsUnit(implicit p: Parameters) extends XSModule with MemoryOpConstant
atom_override_xtval
:=
false
.
B
}
if
(
!
env
.
FPGAPlatform
)
{
if
(
env
.
EnableDifftest
)
{
val
difftest
=
Module
(
new
DifftestAtomicEvent
)
difftest
.
io
.
clock
:=
clock
difftest
.
io
.
coreid
:=
hardId
.
U
...
...
src/main/scala/xiangshan/mem/sbuffer/Sbuffer.scala
浏览文件 @
1545277a
...
...
@@ -485,7 +485,7 @@ class Sbuffer(implicit p: Parameters) extends DCacheModule with HasSbufferConst
// val num_valids = PopCount(entries.map(e => !e.io.lsu.req.ready))
// XSPerfHistogram("num_valids", num_valids, true.B, 0, cfg.nStoreReplayEntries, 1)
if
(
!
env
.
FPGAPlatform
)
{
if
(
env
.
EnableDifftest
)
{
// hit resp
io
.
dcache
.
hit_resps
.
zipWithIndex
.
map
{
case
(
resp
,
index
)
=>
{
val
difftest
=
Module
(
new
DifftestSbufferEvent
)
...
...
src/test/scala/top/SimTop.scala
浏览文件 @
1545277a
...
...
@@ -74,14 +74,14 @@ class SimTop(implicit p: Parameters) extends Module {
io
.
memAXI
<>
soc
.
memory
}
if
(
debugOpts
.
EnableDebug
||
debugOpts
.
EnablePerfDebug
)
{
if
(
!
debugOpts
.
FPGAPlatform
&&
(
debugOpts
.
EnableDebug
||
debugOpts
.
EnablePerfDebug
)
)
{
val
timer
=
GTimer
()
val
logEnable
=
(
timer
>=
io
.
logCtrl
.
log_begin
)
&&
(
timer
<
io
.
logCtrl
.
log_end
)
ExcitingUtils
.
addSource
(
logEnable
,
"DISPLAY_LOG_ENABLE"
)
ExcitingUtils
.
addSource
(
timer
,
"logTimestamp"
)
}
if
(
debugOpts
.
EnablePerfDebug
)
{
if
(
!
debugOpts
.
FPGAPlatform
&&
debugOpts
.
EnablePerfDebug
)
{
val
clean
=
io
.
perfInfo
.
clean
val
dump
=
io
.
perfInfo
.
dump
ExcitingUtils
.
addSource
(
clean
,
"XSPERF_CLEAN"
)
...
...
@@ -94,15 +94,13 @@ class SimTop(implicit p: Parameters) extends Module {
}
object
SimTop
extends
App
{
override
def
main
(
args
:
Array
[
String
])
:
Unit
=
{
val
(
config
,
firrtlOpts
)
=
ArgParser
.
parse
(
args
,
fpga
=
false
)
// generate verilog
XiangShanStage
.
execute
(
firrtlOpts
,
Seq
(
ChiselGeneratorAnnotation
(()
=>
DisableMonitors
(
p
=>
new
SimTop
()(
p
))(
config
))
)
)
// Keep this the same as TopMain except that SimTop is used here instead of XSTop
val
(
config
,
firrtlOpts
)
=
ArgParser
.
parse
(
args
)
XiangShanStage
.
execute
(
firrtlOpts
,
Seq
(
ChiselGeneratorAnnotation
(()
=>
{
DisableMonitors
(
p
=>
new
SimTop
()(
p
))(
config
)
})
))
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录