Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
XiangShan
提交
c4401c32
X
XiangShan
项目概览
OpenXiangShan
/
XiangShan
8 个月 前同步成功
通知
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 搜索 >>
提交
c4401c32
编写于
12月 29, 2020
作者:
Y
Yinan Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
emu: add xs_assert to replace finish to support exception handling
上级
020e2057
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
51 addition
and
10 deletion
+51
-10
Makefile
Makefile
+2
-2
src/test/csrc/assert.cpp
src/test/csrc/assert.cpp
+20
-0
src/test/csrc/common.h
src/test/csrc/common.h
+5
-0
src/test/csrc/difftest.h
src/test/csrc/difftest.h
+3
-0
src/test/csrc/emu.cpp
src/test/csrc/emu.cpp
+3
-7
src/test/csrc/ram.cpp
src/test/csrc/ram.cpp
+12
-1
src/test/csrc/ram.h
src/test/csrc/ram.h
+2
-0
src/test/vsrc/assert.v
src/test/vsrc/assert.v
+4
-0
未找到文件。
Makefile
浏览文件 @
c4401c32
...
...
@@ -56,7 +56,7 @@ $(SIM_TOP_V): $(SCALA_FILE) $(TEST_FILE)
date
-R
mill XiangShan.test.runMain
$(SIMTOP)
-X
verilog
-td
$
(
@D
)
--full-stacktrace
--output-file
$
(
@F
)
$(SIM_ARGS)
sed
-i
'/module XSSimTop/,/endmodule/d'
$(SIM_TOP_V)
sed
-i
-e
's/$$fatal/
$$finish
/g'
$(SIM_TOP_V)
sed
-i
-e
's/$$fatal/
xs_assert(`__LINE__)
/g'
$(SIM_TOP_V)
date
-R
EMU_TOP
=
XSSimSoC
...
...
@@ -80,7 +80,7 @@ endif
# Verilator multi-thread support
EMU_THREADS
?=
1
ifneq
($(EMU_THREADS),1)
VEXTRA_FLAGS
+=
--threads
$(EMU_THREADS)
--threads-dpi
none
VEXTRA_FLAGS
+=
--threads
$(EMU_THREADS)
--threads-dpi
all
endif
# Verilator savable
...
...
src/test/csrc/assert.cpp
0 → 100644
浏览文件 @
c4401c32
#include "common.h"
#include "emu.h"
int
assert_count
=
0
;
static
pthread_mutex_t
assert_mutex
;
void
assert_init
()
{
pthread_mutex_init
(
&
assert_mutex
,
0
);
}
void
assert_finish
()
{
pthread_mutex_destroy
(
&
assert_mutex
);
}
extern
"C"
void
xs_assert
(
long
long
line
)
{
pthread_mutex_lock
(
&
assert_mutex
);
printf
(
"Assertion failed at line %lld
\n
."
,
line
);
assert_count
++
;
pthread_mutex_unlock
(
&
assert_mutex
);
}
src/test/csrc/common.h
浏览文件 @
c4401c32
...
...
@@ -6,6 +6,7 @@
#include <cstdlib>
#include <stdint.h>
#include <assert.h>
#include <pthread.h>
#define ANSI_COLOR_RED "\x1b[31m"
#define ANSI_COLOR_GREEN "\x1b[32m"
...
...
@@ -21,4 +22,8 @@
#include "cosimulation.h"
#endif
extern
int
assert_count
;
void
assert_init
();
void
assert_finish
();
#endif // __COMMON_H
src/test/csrc/difftest.h
浏览文件 @
c4401c32
...
...
@@ -96,4 +96,7 @@ int difftest_step(DiffState *s);
int
difftest_store_step
(
uint64_t
*
saddr
,
uint64_t
*
sdata
,
uint8_t
*
smask
);
void
difftest_display
(
uint8_t
mode
);
uint64_t
get_nemu_this_pc
();
void
set_nemu_this_pc
(
uint64_t
pc
);
#endif
src/test/csrc/emu.cpp
浏览文件 @
c4401c32
...
...
@@ -8,12 +8,6 @@
#include "zlib.h"
#include "compress.h"
void
*
get_ram_start
();
long
get_ram_size
();
uint64_t
get_nemu_this_pc
();
void
set_nemu_this_pc
(
uint64_t
pc
);
static
inline
void
print_help
(
const
char
*
file
)
{
printf
(
"Usage: %s [OPTION...]
\n
"
,
file
);
printf
(
"
\n
"
);
...
...
@@ -90,6 +84,7 @@ Emulator::Emulator(int argc, const char *argv[]):
srand
(
args
.
seed
);
srand48
(
args
.
seed
);
Verilated
::
randReset
(
2
);
assert_init
();
// init core
reset_ncycles
(
10
);
...
...
@@ -132,6 +127,7 @@ Emulator::Emulator(int argc, const char *argv[]):
Emulator
::~
Emulator
()
{
ram_finish
();
assert_finish
();
#ifdef VM_SAVABLE
if
(
args
.
enable_snapshot
&&
trapCode
!=
STATE_GOODTRAP
&&
trapCode
!=
STATE_LIMIT_EXCEEDED
)
{
...
...
@@ -382,7 +378,7 @@ uint64_t Emulator::execute(uint64_t max_cycle, uint64_t max_instr) {
#endif
}
if
(
Verilated
::
gotFinish
()
)
{
if
(
assert_count
>
0
)
{
difftest_display
(
dut_ptr
->
io_difftest_priviledgeMode
);
eprintf
(
"The simulation stopped. There might be some assertion failed.
\n
"
);
trapCode
=
STATE_ABORT
;
...
...
src/test/csrc/ram.cpp
浏览文件 @
c4401c32
...
...
@@ -12,6 +12,8 @@ CoDRAMsim3 *dram = NULL;
static
uint64_t
*
ram
;
static
long
img_size
=
0
;
static
pthread_mutex_t
ram_mutex
;
void
*
get_img_start
()
{
return
&
ram
[
0
];
}
long
get_img_size
()
{
return
img_size
;
}
void
*
get_ram_start
()
{
return
&
ram
[
0
];
}
...
...
@@ -155,6 +157,8 @@ void init_ram(const char *img) {
dram
=
new
CoDRAMsim3
(
DRAMSIM3_CONFIG
,
DRAMSIM3_OUTDIR
);
#endif
pthread_mutex_init
(
&
ram_mutex
,
0
);
}
void
ram_finish
()
{
...
...
@@ -162,13 +166,18 @@ void ram_finish() {
#ifdef WITH_DRAMSIM3
dramsim3_finish
();
#endif
pthread_mutex_destroy
(
&
ram_mutex
);
}
extern
"C"
uint64_t
ram_read_helper
(
uint8_t
en
,
uint64_t
rIdx
)
{
if
(
en
&&
rIdx
>=
EMU_RAM_SIZE
/
sizeof
(
uint64_t
))
{
rIdx
%=
EMU_RAM_SIZE
/
sizeof
(
uint64_t
);
}
return
(
en
)
?
ram
[
rIdx
]
:
0
;
pthread_mutex_lock
(
&
ram_mutex
);
uint64_t
rdata
=
(
en
)
?
ram
[
rIdx
]
:
0
;
pthread_mutex_unlock
(
&
ram_mutex
);
return
rdata
;
}
extern
"C"
void
ram_write_helper
(
uint64_t
wIdx
,
uint64_t
wdata
,
uint64_t
wmask
,
uint8_t
wen
)
{
...
...
@@ -177,7 +186,9 @@ extern "C" void ram_write_helper(uint64_t wIdx, uint64_t wdata, uint64_t wmask,
printf
(
"ERROR: ram wIdx = 0x%lx out of bound!
\n
"
,
wIdx
);
assert
(
wIdx
<
EMU_RAM_SIZE
/
sizeof
(
uint64_t
));
}
pthread_mutex_lock
(
&
ram_mutex
);
ram
[
wIdx
]
=
(
ram
[
wIdx
]
&
~
wmask
)
|
(
wdata
&
wmask
);
pthread_mutex_unlock
(
&
ram_mutex
);
}
}
...
...
src/test/csrc/ram.h
浏览文件 @
c4401c32
...
...
@@ -8,6 +8,8 @@
void
init_ram
(
const
char
*
img
);
void
ram_finish
();
void
*
get_ram_start
();
long
get_ram_size
();
#ifdef WITH_DRAMSIM3
// 4*64 bits
...
...
src/test/vsrc/assert.v
0 → 100644
浏览文件 @
c4401c32
import
"DPI-C"
function
void
xs_assert
(
input
longint
line
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录