Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
XiangShan
提交
76e34764
X
XiangShan
项目概览
OpenXiangShan
/
XiangShan
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
76e34764
编写于
2月 01, 2021
作者:
W
wangkaifan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
difftest: dualcore framework adapts to single core
上级
4064a617
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
152 addition
and
119 deletion
+152
-119
src/test/csrc/difftest.cpp
src/test/csrc/difftest.cpp
+35
-28
src/test/csrc/emu.cpp
src/test/csrc/emu.cpp
+110
-90
src/test/csrc/emu.h
src/test/csrc/emu.h
+7
-1
未找到文件。
src/test/csrc/difftest.cpp
浏览文件 @
76e34764
...
@@ -27,6 +27,34 @@ static void (*ref_difftest_exec)(uint64_t n, int coreid) = NULL;
...
@@ -27,6 +27,34 @@ static void (*ref_difftest_exec)(uint64_t n, int coreid) = NULL;
static
void
(
*
ref_difftest_raise_intr
)(
uint64_t
NO
,
int
coreid
)
=
NULL
;
static
void
(
*
ref_difftest_raise_intr
)(
uint64_t
NO
,
int
coreid
)
=
NULL
;
static
void
(
*
ref_isa_reg_display
)(
int
coreid
)
=
NULL
;
static
void
(
*
ref_isa_reg_display
)(
int
coreid
)
=
NULL
;
static
const
char
*
reg_name
[
DIFFTEST_NR_REG
]
=
{
"$0"
,
"ra"
,
"sp"
,
"gp"
,
"tp"
,
"t0"
,
"t1"
,
"t2"
,
"s0"
,
"s1"
,
"a0"
,
"a1"
,
"a2"
,
"a3"
,
"a4"
,
"a5"
,
"a6"
,
"a7"
,
"s2"
,
"s3"
,
"s4"
,
"s5"
,
"s6"
,
"s7"
,
"s8"
,
"s9"
,
"s10"
,
"s11"
,
"t3"
,
"t4"
,
"t5"
,
"t6"
,
"ft0"
,
"ft1"
,
"ft2"
,
"ft3"
,
"ft4"
,
"ft5"
,
"ft6"
,
"ft7"
,
"fs0"
,
"fs1"
,
"fa0"
,
"fa1"
,
"fa2"
,
"fa3"
,
"fa4"
,
"fa5"
,
"fa6"
,
"fa7"
,
"fs2"
,
"fs3"
,
"fs4"
,
"fs5"
,
"fs6"
,
"fs7"
,
"fs8"
,
"fs9"
,
"fs10"
,
"fs11"
,
"ft8"
,
"ft9"
,
"ft10"
,
"ft11"
,
"this_pc"
,
"mstatus"
,
"mcause"
,
"mepc"
,
"sstatus"
,
"scause"
,
"sepc"
,
"satp"
,
"mip"
,
"mie"
,
"mscratch"
,
"sscratch"
,
"mideleg"
,
"medeleg"
,
"mtval"
,
"stval"
,
"mtvec"
,
"stvec"
,
"mode"
};
static
uint64_t
nemu_this_pc
[
NumCore
];
static
uint64_t
pc_retire_queue
[
NumCore
][
DEBUG_RETIRE_TRACE_SIZE
]
=
{
0
};
static
uint32_t
inst_retire_queue
[
NumCore
][
DEBUG_RETIRE_TRACE_SIZE
]
=
{
0
};
static
uint32_t
retire_cnt_queue
[
NumCore
][
DEBUG_RETIRE_TRACE_SIZE
]
=
{
0
};
static
int
pc_retire_pointer
[
NumCore
];
static
uint64_t
pc_wb_queue
[
NumCore
][
DEBUG_WB_TRACE_SIZE
]
=
{
0
};
static
uint64_t
wen_wb_queue
[
NumCore
][
DEBUG_WB_TRACE_SIZE
]
=
{
0
};
static
uint32_t
wdst_wb_queue
[
NumCore
][
DEBUG_WB_TRACE_SIZE
]
=
{
0
};
static
uint64_t
wdata_wb_queue
[
NumCore
][
DEBUG_WB_TRACE_SIZE
]
=
{
0
};
static
int
wb_pointer
[
NumCore
]
=
{
0
};
void
init_difftest
()
{
void
init_difftest
()
{
#undef REF_SO
#undef REF_SO
...
@@ -85,35 +113,12 @@ void init_difftest() {
...
@@ -85,35 +113,12 @@ void init_difftest() {
for
(
int
i
=
0
;
i
<
NumCore
;
i
++
)
{
for
(
int
i
=
0
;
i
<
NumCore
;
i
++
)
{
ref_difftest_init
(
i
);
ref_difftest_init
(
i
);
}
}
}
static
const
char
*
reg_name
[
DIFFTEST_NR_REG
]
=
{
"$0"
,
"ra"
,
"sp"
,
"gp"
,
"tp"
,
"t0"
,
"t1"
,
"t2"
,
"s0"
,
"s1"
,
"a0"
,
"a1"
,
"a2"
,
"a3"
,
"a4"
,
"a5"
,
"a6"
,
"a7"
,
"s2"
,
"s3"
,
"s4"
,
"s5"
,
"s6"
,
"s7"
,
"s8"
,
"s9"
,
"s10"
,
"s11"
,
"t3"
,
"t4"
,
"t5"
,
"t6"
,
"ft0"
,
"ft1"
,
"ft2"
,
"ft3"
,
"ft4"
,
"ft5"
,
"ft6"
,
"ft7"
,
"fs0"
,
"fs1"
,
"fa0"
,
"fa1"
,
"fa2"
,
"fa3"
,
"fa4"
,
"fa5"
,
"fa6"
,
"fa7"
,
"fs2"
,
"fs3"
,
"fs4"
,
"fs5"
,
"fs6"
,
"fs7"
,
"fs8"
,
"fs9"
,
"fs10"
,
"fs11"
,
"ft8"
,
"ft9"
,
"ft10"
,
"ft11"
,
"this_pc"
,
"mstatus"
,
"mcause"
,
"mepc"
,
"sstatus"
,
"scause"
,
"sepc"
,
"satp"
,
"mip"
,
"mie"
,
"mscratch"
,
"sscratch"
,
"mideleg"
,
"medeleg"
,
"mtval"
,
"stval"
,
"mtvec"
,
"stvec"
,
"mode"
};
static
uint64_t
nemu_this_pc
[
NumCore
]
=
{
0x80000000
,
0x80000000
};
for
(
int
i
=
0
;
i
<
NumCore
;
i
++
)
{
static
uint64_t
pc_retire_queue
[
NumCore
][
DEBUG_RETIRE_TRACE_SIZE
]
=
{
0
};
nemu_this_pc
[
i
]
=
0x80000000
;
static
uint32_t
inst_retire_queue
[
NumCore
][
DEBUG_RETIRE_TRACE_SIZE
]
=
{
0
};
pc_retire_pointer
[
i
]
=
DEBUG_RETIRE_TRACE_SIZE
-
1
;
static
uint32_t
retire_cnt_queue
[
NumCore
][
DEBUG_RETIRE_TRACE_SIZE
]
=
{
0
};
}
static
int
pc_retire_pointer
[
NumCore
]
=
{
DEBUG_RETIRE_TRACE_SIZE
-
1
,
DEBUG_RETIRE_TRACE_SIZE
-
1
};
}
static
uint64_t
pc_wb_queue
[
NumCore
][
DEBUG_WB_TRACE_SIZE
]
=
{
0
};
static
uint64_t
wen_wb_queue
[
NumCore
][
DEBUG_WB_TRACE_SIZE
]
=
{
0
};
static
uint32_t
wdst_wb_queue
[
NumCore
][
DEBUG_WB_TRACE_SIZE
]
=
{
0
};
static
uint64_t
wdata_wb_queue
[
NumCore
][
DEBUG_WB_TRACE_SIZE
]
=
{
0
};
static
int
wb_pointer
[
NumCore
]
=
{
0
,
0
};
uint64_t
get_nemu_this_pc
(
int
coreid
)
{
return
nemu_this_pc
[
coreid
];
}
uint64_t
get_nemu_this_pc
(
int
coreid
)
{
return
nemu_this_pc
[
coreid
];
}
void
set_nemu_this_pc
(
uint64_t
pc
,
int
coreid
)
{
nemu_this_pc
[
coreid
]
=
pc
;
}
void
set_nemu_this_pc
(
uint64_t
pc
,
int
coreid
)
{
nemu_this_pc
[
coreid
]
=
pc
;
}
...
@@ -294,8 +299,10 @@ int difftest_step(DiffState *s, int coreid) {
...
@@ -294,8 +299,10 @@ int difftest_step(DiffState *s, int coreid) {
reg_name
[
i
],
this_pc
,
ref_r
[
i
],
s
->
reg_scala
[
i
]);
reg_name
[
i
],
this_pc
,
ref_r
[
i
],
s
->
reg_scala
[
i
]);
}
}
}
}
#ifdef DUALCORE
printf
(
"(((Another Core)))
\n
"
);
printf
(
"(((Another Core)))
\n
"
);
difftest_display
(
s
->
priviledgeMode
,
1
-
coreid
);
difftest_display
(
s
->
priviledgeMode
,
1
-
coreid
);
#endif
return
1
;
return
1
;
}
}
return
0
;
return
0
;
...
...
src/test/csrc/emu.cpp
浏览文件 @
76e34764
...
@@ -178,37 +178,6 @@ inline void Emulator::read_emu_regs(uint64_t *r) {
...
@@ -178,37 +178,6 @@ inline void Emulator::read_emu_regs(uint64_t *r) {
r
[
DIFFTEST_MODE
]
=
dut_ptr
->
io_difftest_priviledgeMode
;
r
[
DIFFTEST_MODE
]
=
dut_ptr
->
io_difftest_priviledgeMode
;
}
}
inline
void
Emulator
::
read_emu_regs2
(
uint64_t
*
r
)
{
#define macro2(x) r[x] = dut_ptr->io_difftest2_r_##x
macro2
(
0
);
macro2
(
1
);
macro2
(
2
);
macro2
(
3
);
macro2
(
4
);
macro2
(
5
);
macro2
(
6
);
macro2
(
7
);
macro2
(
8
);
macro2
(
9
);
macro2
(
10
);
macro2
(
11
);
macro2
(
12
);
macro2
(
13
);
macro2
(
14
);
macro2
(
15
);
macro2
(
16
);
macro2
(
17
);
macro2
(
18
);
macro2
(
19
);
macro2
(
20
);
macro2
(
21
);
macro2
(
22
);
macro2
(
23
);
macro2
(
24
);
macro2
(
25
);
macro2
(
26
);
macro2
(
27
);
macro2
(
28
);
macro2
(
29
);
macro2
(
30
);
macro2
(
31
);
macro2
(
32
);
macro2
(
33
);
macro2
(
34
);
macro2
(
35
);
macro2
(
36
);
macro2
(
37
);
macro2
(
38
);
macro2
(
39
);
macro2
(
40
);
macro2
(
41
);
macro2
(
42
);
macro2
(
43
);
macro2
(
44
);
macro2
(
45
);
macro2
(
46
);
macro2
(
47
);
macro2
(
48
);
macro2
(
49
);
macro2
(
50
);
macro2
(
51
);
macro2
(
52
);
macro2
(
53
);
macro2
(
54
);
macro2
(
55
);
macro2
(
56
);
macro2
(
57
);
macro2
(
58
);
macro2
(
59
);
macro2
(
60
);
macro2
(
61
);
macro2
(
62
);
macro2
(
63
);
r
[
DIFFTEST_THIS_PC
]
=
dut_ptr
->
io_difftest2_thisPC
;
r
[
DIFFTEST_MSTATUS
]
=
dut_ptr
->
io_difftest2_mstatus
;
r
[
DIFFTEST_SSTATUS
]
=
dut_ptr
->
io_difftest2_sstatus
;
r
[
DIFFTEST_MEPC
]
=
dut_ptr
->
io_difftest2_mepc
;
r
[
DIFFTEST_SEPC
]
=
dut_ptr
->
io_difftest2_sepc
;
r
[
DIFFTEST_MCAUSE
]
=
dut_ptr
->
io_difftest2_mcause
;
r
[
DIFFTEST_SCAUSE
]
=
dut_ptr
->
io_difftest2_scause
;
r
[
DIFFTEST_SATP
]
=
dut_ptr
->
io_difftest2_satp
;
r
[
DIFFTEST_MIP
]
=
dut_ptr
->
io_difftest2_mip
;
r
[
DIFFTEST_MIE
]
=
dut_ptr
->
io_difftest2_mie
;
r
[
DIFFTEST_MSCRATCH
]
=
dut_ptr
->
io_difftest2_mscratch
;
r
[
DIFFTEST_SSCRATCH
]
=
dut_ptr
->
io_difftest2_sscratch
;
r
[
DIFFTEST_MIDELEG
]
=
dut_ptr
->
io_difftest2_mideleg
;
r
[
DIFFTEST_MEDELEG
]
=
dut_ptr
->
io_difftest2_medeleg
;
r
[
DIFFTEST_MTVAL
]
=
dut_ptr
->
io_difftest2_mtval
;
r
[
DIFFTEST_STVAL
]
=
dut_ptr
->
io_difftest2_stval
;
r
[
DIFFTEST_MTVEC
]
=
dut_ptr
->
io_difftest2_mtvec
;
r
[
DIFFTEST_STVEC
]
=
dut_ptr
->
io_difftest2_stvec
;
r
[
DIFFTEST_MODE
]
=
dut_ptr
->
io_difftest2_priviledgeMode
;
}
inline
void
Emulator
::
read_wb_info
(
uint64_t
*
wpc
,
uint64_t
*
wdata
,
uint32_t
*
wdst
,
uint64_t
*
lpaddr
,
uint32_t
*
ltype
,
uint8_t
*
lfu
)
{
inline
void
Emulator
::
read_wb_info
(
uint64_t
*
wpc
,
uint64_t
*
wdata
,
uint32_t
*
wdst
,
uint64_t
*
lpaddr
,
uint32_t
*
ltype
,
uint8_t
*
lfu
)
{
#define dut_ptr_wpc(x) wpc[x] = dut_ptr->io_difftest_wpc_##x
#define dut_ptr_wpc(x) wpc[x] = dut_ptr->io_difftest_wpc_##x
#define dut_ptr_wdata(x) wdata[x] = dut_ptr->io_difftest_wdata_##x
#define dut_ptr_wdata(x) wdata[x] = dut_ptr->io_difftest_wdata_##x
...
@@ -248,6 +217,77 @@ inline void Emulator::read_wb_info(uint64_t *wpc, uint64_t *wdata, uint32_t *wds
...
@@ -248,6 +217,77 @@ inline void Emulator::read_wb_info(uint64_t *wpc, uint64_t *wdata, uint32_t *wds
#endif
#endif
}
}
inline
void
Emulator
::
read_store_info
(
uint64_t
*
saddr
,
uint64_t
*
sdata
,
uint8_t
*
smask
)
{
#define dut_ptr_saddr(x) saddr[x] = dut_ptr->io_difftest_storeAddr_##x
#define dut_ptr_sdata(x) sdata[x] = dut_ptr->io_difftest_storeData_##x
#define dut_ptr_smask(x) smask[x] = dut_ptr->io_difftest_storeMask_##x
#define dut_ptr_read_store(x) dut_ptr_saddr(x); dut_ptr_sdata(x); dut_ptr_smask(x);
dut_ptr_read_store
(
0
);
dut_ptr_read_store
(
1
);
}
inline
void
Emulator
::
read_sbuffer_info
(
uint8_t
*
sbufferData
)
{
#define dut_ptr_data(x) sbufferData[x] = dut_ptr->io_difftest_sbufferData_##x
dut_ptr_data
(
0
);
dut_ptr_data
(
1
);
dut_ptr_data
(
2
);
dut_ptr_data
(
3
);
dut_ptr_data
(
4
);
dut_ptr_data
(
5
);
dut_ptr_data
(
6
);
dut_ptr_data
(
7
);
dut_ptr_data
(
8
);
dut_ptr_data
(
9
);
dut_ptr_data
(
10
);
dut_ptr_data
(
11
);
dut_ptr_data
(
12
);
dut_ptr_data
(
13
);
dut_ptr_data
(
14
);
dut_ptr_data
(
15
);
dut_ptr_data
(
16
);
dut_ptr_data
(
17
);
dut_ptr_data
(
18
);
dut_ptr_data
(
19
);
dut_ptr_data
(
20
);
dut_ptr_data
(
21
);
dut_ptr_data
(
22
);
dut_ptr_data
(
23
);
dut_ptr_data
(
24
);
dut_ptr_data
(
25
);
dut_ptr_data
(
26
);
dut_ptr_data
(
27
);
dut_ptr_data
(
28
);
dut_ptr_data
(
29
);
dut_ptr_data
(
30
);
dut_ptr_data
(
31
);
dut_ptr_data
(
32
);
dut_ptr_data
(
33
);
dut_ptr_data
(
34
);
dut_ptr_data
(
35
);
dut_ptr_data
(
36
);
dut_ptr_data
(
37
);
dut_ptr_data
(
38
);
dut_ptr_data
(
39
);
dut_ptr_data
(
40
);
dut_ptr_data
(
41
);
dut_ptr_data
(
42
);
dut_ptr_data
(
43
);
dut_ptr_data
(
44
);
dut_ptr_data
(
45
);
dut_ptr_data
(
46
);
dut_ptr_data
(
47
);
dut_ptr_data
(
48
);
dut_ptr_data
(
49
);
dut_ptr_data
(
50
);
dut_ptr_data
(
51
);
dut_ptr_data
(
52
);
dut_ptr_data
(
53
);
dut_ptr_data
(
54
);
dut_ptr_data
(
55
);
dut_ptr_data
(
56
);
dut_ptr_data
(
57
);
dut_ptr_data
(
58
);
dut_ptr_data
(
59
);
dut_ptr_data
(
60
);
dut_ptr_data
(
61
);
dut_ptr_data
(
62
);
dut_ptr_data
(
63
);
}
inline
void
Emulator
::
load_diff_info
(
void
*
diff_ptr
,
int
coreid
)
{
#define load_info(x) diff[coreid].x = dut_ptr->io_difftest_##x
DiffState
*
diff
=
(
DiffState
*
)
diff_ptr
;
load_info
(
commit
);
load_info
(
thisINST
);
load_info
(
skip
);
load_info
(
isRVC
);
load_info
(
wen
);
load_info
(
intrNO
);
load_info
(
cause
);
load_info
(
priviledgeMode
);
load_info
(
scFailed
);
}
#ifdef DUALCORE
inline
void
Emulator
::
read_emu_regs2
(
uint64_t
*
r
)
{
#define macro2(x) r[x] = dut_ptr->io_difftest2_r_##x
macro2
(
0
);
macro2
(
1
);
macro2
(
2
);
macro2
(
3
);
macro2
(
4
);
macro2
(
5
);
macro2
(
6
);
macro2
(
7
);
macro2
(
8
);
macro2
(
9
);
macro2
(
10
);
macro2
(
11
);
macro2
(
12
);
macro2
(
13
);
macro2
(
14
);
macro2
(
15
);
macro2
(
16
);
macro2
(
17
);
macro2
(
18
);
macro2
(
19
);
macro2
(
20
);
macro2
(
21
);
macro2
(
22
);
macro2
(
23
);
macro2
(
24
);
macro2
(
25
);
macro2
(
26
);
macro2
(
27
);
macro2
(
28
);
macro2
(
29
);
macro2
(
30
);
macro2
(
31
);
macro2
(
32
);
macro2
(
33
);
macro2
(
34
);
macro2
(
35
);
macro2
(
36
);
macro2
(
37
);
macro2
(
38
);
macro2
(
39
);
macro2
(
40
);
macro2
(
41
);
macro2
(
42
);
macro2
(
43
);
macro2
(
44
);
macro2
(
45
);
macro2
(
46
);
macro2
(
47
);
macro2
(
48
);
macro2
(
49
);
macro2
(
50
);
macro2
(
51
);
macro2
(
52
);
macro2
(
53
);
macro2
(
54
);
macro2
(
55
);
macro2
(
56
);
macro2
(
57
);
macro2
(
58
);
macro2
(
59
);
macro2
(
60
);
macro2
(
61
);
macro2
(
62
);
macro2
(
63
);
r
[
DIFFTEST_THIS_PC
]
=
dut_ptr
->
io_difftest2_thisPC
;
r
[
DIFFTEST_MSTATUS
]
=
dut_ptr
->
io_difftest2_mstatus
;
r
[
DIFFTEST_SSTATUS
]
=
dut_ptr
->
io_difftest2_sstatus
;
r
[
DIFFTEST_MEPC
]
=
dut_ptr
->
io_difftest2_mepc
;
r
[
DIFFTEST_SEPC
]
=
dut_ptr
->
io_difftest2_sepc
;
r
[
DIFFTEST_MCAUSE
]
=
dut_ptr
->
io_difftest2_mcause
;
r
[
DIFFTEST_SCAUSE
]
=
dut_ptr
->
io_difftest2_scause
;
r
[
DIFFTEST_SATP
]
=
dut_ptr
->
io_difftest2_satp
;
r
[
DIFFTEST_MIP
]
=
dut_ptr
->
io_difftest2_mip
;
r
[
DIFFTEST_MIE
]
=
dut_ptr
->
io_difftest2_mie
;
r
[
DIFFTEST_MSCRATCH
]
=
dut_ptr
->
io_difftest2_mscratch
;
r
[
DIFFTEST_SSCRATCH
]
=
dut_ptr
->
io_difftest2_sscratch
;
r
[
DIFFTEST_MIDELEG
]
=
dut_ptr
->
io_difftest2_mideleg
;
r
[
DIFFTEST_MEDELEG
]
=
dut_ptr
->
io_difftest2_medeleg
;
r
[
DIFFTEST_MTVAL
]
=
dut_ptr
->
io_difftest2_mtval
;
r
[
DIFFTEST_STVAL
]
=
dut_ptr
->
io_difftest2_stval
;
r
[
DIFFTEST_MTVEC
]
=
dut_ptr
->
io_difftest2_mtvec
;
r
[
DIFFTEST_STVEC
]
=
dut_ptr
->
io_difftest2_stvec
;
r
[
DIFFTEST_MODE
]
=
dut_ptr
->
io_difftest2_priviledgeMode
;
}
inline
void
Emulator
::
read_wb_info2
(
uint64_t
*
wpc
,
uint64_t
*
wdata
,
uint32_t
*
wdst
,
uint64_t
*
lpaddr
,
uint32_t
*
ltype
,
uint8_t
*
lfu
)
{
inline
void
Emulator
::
read_wb_info2
(
uint64_t
*
wpc
,
uint64_t
*
wdata
,
uint32_t
*
wdst
,
uint64_t
*
lpaddr
,
uint32_t
*
ltype
,
uint8_t
*
lfu
)
{
#define dut_ptr_wpc2(x) wpc[x] = dut_ptr->io_difftest2_wpc_##x
#define dut_ptr_wpc2(x) wpc[x] = dut_ptr->io_difftest2_wpc_##x
#define dut_ptr_wdata2(x) wdata[x] = dut_ptr->io_difftest2_wdata_##x
#define dut_ptr_wdata2(x) wdata[x] = dut_ptr->io_difftest2_wdata_##x
...
@@ -287,15 +327,6 @@ inline void Emulator::read_wb_info2(uint64_t *wpc, uint64_t *wdata, uint32_t *wd
...
@@ -287,15 +327,6 @@ inline void Emulator::read_wb_info2(uint64_t *wpc, uint64_t *wdata, uint32_t *wd
#endif
#endif
}
}
inline
void
Emulator
::
read_store_info
(
uint64_t
*
saddr
,
uint64_t
*
sdata
,
uint8_t
*
smask
)
{
#define dut_ptr_saddr(x) saddr[x] = dut_ptr->io_difftest_storeAddr_##x
#define dut_ptr_sdata(x) sdata[x] = dut_ptr->io_difftest_storeData_##x
#define dut_ptr_smask(x) smask[x] = dut_ptr->io_difftest_storeMask_##x
#define dut_ptr_read_store(x) dut_ptr_saddr(x); dut_ptr_sdata(x); dut_ptr_smask(x);
dut_ptr_read_store
(
0
);
dut_ptr_read_store
(
1
);
}
inline
void
Emulator
::
read_store_info2
(
uint64_t
*
saddr
,
uint64_t
*
sdata
,
uint8_t
*
smask
)
{
inline
void
Emulator
::
read_store_info2
(
uint64_t
*
saddr
,
uint64_t
*
sdata
,
uint8_t
*
smask
)
{
#define dut_ptr_saddr2(x) saddr[x] = dut_ptr->io_difftest2_storeAddr_##x
#define dut_ptr_saddr2(x) saddr[x] = dut_ptr->io_difftest2_storeAddr_##x
#define dut_ptr_sdata2(x) sdata[x] = dut_ptr->io_difftest2_storeData_##x
#define dut_ptr_sdata2(x) sdata[x] = dut_ptr->io_difftest2_storeData_##x
...
@@ -305,26 +336,6 @@ inline void Emulator::read_store_info2(uint64_t *saddr, uint64_t *sdata, uint8_t
...
@@ -305,26 +336,6 @@ inline void Emulator::read_store_info2(uint64_t *saddr, uint64_t *sdata, uint8_t
dut_ptr_read_store2
(
1
);
dut_ptr_read_store2
(
1
);
}
}
inline
void
Emulator
::
read_sbuffer_info
(
uint8_t
*
sbufferData
)
{
#define dut_ptr_data(x) sbufferData[x] = dut_ptr->io_difftest_sbufferData_##x
dut_ptr_data
(
0
);
dut_ptr_data
(
1
);
dut_ptr_data
(
2
);
dut_ptr_data
(
3
);
dut_ptr_data
(
4
);
dut_ptr_data
(
5
);
dut_ptr_data
(
6
);
dut_ptr_data
(
7
);
dut_ptr_data
(
8
);
dut_ptr_data
(
9
);
dut_ptr_data
(
10
);
dut_ptr_data
(
11
);
dut_ptr_data
(
12
);
dut_ptr_data
(
13
);
dut_ptr_data
(
14
);
dut_ptr_data
(
15
);
dut_ptr_data
(
16
);
dut_ptr_data
(
17
);
dut_ptr_data
(
18
);
dut_ptr_data
(
19
);
dut_ptr_data
(
20
);
dut_ptr_data
(
21
);
dut_ptr_data
(
22
);
dut_ptr_data
(
23
);
dut_ptr_data
(
24
);
dut_ptr_data
(
25
);
dut_ptr_data
(
26
);
dut_ptr_data
(
27
);
dut_ptr_data
(
28
);
dut_ptr_data
(
29
);
dut_ptr_data
(
30
);
dut_ptr_data
(
31
);
dut_ptr_data
(
32
);
dut_ptr_data
(
33
);
dut_ptr_data
(
34
);
dut_ptr_data
(
35
);
dut_ptr_data
(
36
);
dut_ptr_data
(
37
);
dut_ptr_data
(
38
);
dut_ptr_data
(
39
);
dut_ptr_data
(
40
);
dut_ptr_data
(
41
);
dut_ptr_data
(
42
);
dut_ptr_data
(
43
);
dut_ptr_data
(
44
);
dut_ptr_data
(
45
);
dut_ptr_data
(
46
);
dut_ptr_data
(
47
);
dut_ptr_data
(
48
);
dut_ptr_data
(
49
);
dut_ptr_data
(
50
);
dut_ptr_data
(
51
);
dut_ptr_data
(
52
);
dut_ptr_data
(
53
);
dut_ptr_data
(
54
);
dut_ptr_data
(
55
);
dut_ptr_data
(
56
);
dut_ptr_data
(
57
);
dut_ptr_data
(
58
);
dut_ptr_data
(
59
);
dut_ptr_data
(
60
);
dut_ptr_data
(
61
);
dut_ptr_data
(
62
);
dut_ptr_data
(
63
);
}
inline
void
Emulator
::
read_sbuffer_info2
(
uint8_t
*
sbufferData
)
{
inline
void
Emulator
::
read_sbuffer_info2
(
uint8_t
*
sbufferData
)
{
#define dut_ptr_data2(x) sbufferData[x] = dut_ptr->io_difftest2_sbufferData_##x
#define dut_ptr_data2(x) sbufferData[x] = dut_ptr->io_difftest2_sbufferData_##x
dut_ptr_data2
(
0
);
dut_ptr_data2
(
1
);
dut_ptr_data2
(
2
);
dut_ptr_data2
(
3
);
dut_ptr_data2
(
0
);
dut_ptr_data2
(
1
);
dut_ptr_data2
(
2
);
dut_ptr_data2
(
3
);
...
@@ -345,6 +356,18 @@ inline void Emulator::read_sbuffer_info2(uint8_t *sbufferData) {
...
@@ -345,6 +356,18 @@ inline void Emulator::read_sbuffer_info2(uint8_t *sbufferData) {
dut_ptr_data2
(
60
);
dut_ptr_data2
(
61
);
dut_ptr_data2
(
62
);
dut_ptr_data2
(
63
);
dut_ptr_data2
(
60
);
dut_ptr_data2
(
61
);
dut_ptr_data2
(
62
);
dut_ptr_data2
(
63
);
}
}
inline
void
Emulator
::
load_diff_info2
(
void
*
diff_ptr
,
int
coreid
)
{
#define load_info2(x) diff[coreid].x = dut_ptr->io_difftest2_##x
assert
(
coreid
==
1
);
DiffState
*
diff
=
(
DiffState
*
)
diff_ptr
;
load_info2
(
commit
);
load_info2
(
thisINST
);
load_info2
(
skip
);
load_info2
(
isRVC
);
load_info2
(
wen
);
load_info2
(
intrNO
);
load_info2
(
cause
);
load_info2
(
priviledgeMode
);
load_info2
(
scFailed
);
}
#endif
inline
void
Emulator
::
reset_ncycles
(
size_t
cycles
)
{
inline
void
Emulator
::
reset_ncycles
(
size_t
cycles
)
{
for
(
int
i
=
0
;
i
<
cycles
;
i
++
)
{
for
(
int
i
=
0
;
i
<
cycles
;
i
++
)
{
dut_ptr
->
reset
=
1
;
dut_ptr
->
reset
=
1
;
...
@@ -474,25 +497,6 @@ inline void handle_atomic(uint64_t atomicAddr, uint64_t* atomicData, uint64_t at
...
@@ -474,25 +497,6 @@ inline void handle_atomic(uint64_t atomicAddr, uint64_t* atomicData, uint64_t at
}
}
inline
void
Emulator
::
load_diff_info
(
void
*
diff_ptr
,
int
coreid
)
{
#define load_info(x) diff[0].x = dut_ptr->io_difftest_##x
#define load_info2(x) diff[1].x = dut_ptr->io_difftest2_##x
DiffState
*
diff
=
(
DiffState
*
)
diff_ptr
;
if
(
coreid
==
0
)
{
load_info
(
commit
);
load_info
(
thisINST
);
load_info
(
skip
);
load_info
(
isRVC
);
load_info
(
wen
);
load_info
(
intrNO
);
load_info
(
cause
);
load_info
(
priviledgeMode
);
load_info
(
scFailed
);
}
else
{
load_info2
(
commit
);
load_info2
(
thisINST
);
load_info2
(
skip
);
load_info2
(
isRVC
);
load_info2
(
wen
);
load_info2
(
intrNO
);
load_info2
(
cause
);
load_info2
(
priviledgeMode
);
load_info2
(
scFailed
);
}
}
uint64_t
Emulator
::
execute
(
uint64_t
max_cycle
,
uint64_t
max_instr
)
{
uint64_t
Emulator
::
execute
(
uint64_t
max_cycle
,
uint64_t
max_instr
)
{
extern
void
poll_event
(
void
);
extern
void
poll_event
(
void
);
extern
uint32_t
uptime
(
void
);
extern
uint32_t
uptime
(
void
);
...
@@ -562,15 +566,23 @@ uint64_t Emulator::execute(uint64_t max_cycle, uint64_t max_instr) {
...
@@ -562,15 +566,23 @@ uint64_t Emulator::execute(uint64_t max_cycle, uint64_t max_instr) {
eprintf
(
"No instruction of core%d commits for %d cycles, maybe get stuck
\n
"
eprintf
(
"No instruction of core%d commits for %d cycles, maybe get stuck
\n
"
"(please also check whether a fence.i instruction requires more than %d cycles to flush the icache)
\n
"
,
"(please also check whether a fence.i instruction requires more than %d cycles to flush the icache)
\n
"
,
i
,
stuck_limit
,
stuck_limit
);
i
,
stuck_limit
,
stuck_limit
);
#ifdef DUALCORE
int
priviledgeMode
=
(
i
==
0
)
?
dut_ptr
->
io_difftest_priviledgeMode
:
dut_ptr
->
io_difftest2_priviledgeMode
;
int
priviledgeMode
=
(
i
==
0
)
?
dut_ptr
->
io_difftest_priviledgeMode
:
dut_ptr
->
io_difftest2_priviledgeMode
;
#else
int
priviledgeMode
=
dut_ptr
->
io_difftest_priviledgeMode
;
#endif
difftest_display
(
priviledgeMode
,
i
);
difftest_display
(
priviledgeMode
,
i
);
trapCode
=
STATE_ABORT
;
trapCode
=
STATE_ABORT
;
}
}
}
}
for
(
int
i
=
0
;
i
<
NumCore
;
i
++
)
{
for
(
int
i
=
0
;
i
<
NumCore
;
i
++
)
{
#ifdef DUALCORE
int
first_instr_commit
=
(
i
==
0
)
?
dut_ptr
->
io_difftest_commit
&&
dut_ptr
->
io_difftest_thisPC
==
0x80000000u
:
int
first_instr_commit
=
(
i
==
0
)
?
dut_ptr
->
io_difftest_commit
&&
dut_ptr
->
io_difftest_thisPC
==
0x80000000u
:
dut_ptr
->
io_difftest2_commit
&&
dut_ptr
->
io_difftest2_thisPC
==
0x80000000u
;
dut_ptr
->
io_difftest2_commit
&&
dut_ptr
->
io_difftest2_thisPC
==
0x80000000u
;
#else
int
first_instr_commit
=
dut_ptr
->
io_difftest_commit
&&
dut_ptr
->
io_difftest_thisPC
==
0x80000000u
;
#endif
if
(
!
hascommit
[
i
]
&&
first_instr_commit
)
{
if
(
!
hascommit
[
i
]
&&
first_instr_commit
)
{
hascommit
[
i
]
=
1
;
hascommit
[
i
]
=
1
;
if
(
i
==
0
)
read_emu_regs
(
reg
[
i
]);
else
read_emu_regs2
(
reg
[
i
]);
if
(
i
==
0
)
read_emu_regs
(
reg
[
i
]);
else
read_emu_regs2
(
reg
[
i
]);
...
@@ -585,16 +597,25 @@ uint64_t Emulator::execute(uint64_t max_cycle, uint64_t max_instr) {
...
@@ -585,16 +597,25 @@ uint64_t Emulator::execute(uint64_t max_cycle, uint64_t max_instr) {
// difftest
// difftest
for
(
int
i
=
0
;
i
<
NumCore
;
i
++
)
{
for
(
int
i
=
0
;
i
<
NumCore
;
i
++
)
{
#ifdef DUALCORE
int
core_nr_commit
=
(
i
==
0
)
?
dut_ptr
->
io_difftest_commit
:
dut_ptr
->
io_difftest2_commit
;
int
core_nr_commit
=
(
i
==
0
)
?
dut_ptr
->
io_difftest_commit
:
dut_ptr
->
io_difftest2_commit
;
#else
int
core_nr_commit
=
dut_ptr
->
io_difftest_commit
;
#endif
if
(
core_nr_commit
&&
hascommit
[
i
])
{
if
(
core_nr_commit
&&
hascommit
[
i
])
{
if
(
i
==
0
)
{
if
(
i
==
0
)
{
read_emu_regs
(
reg
[
i
]);
read_emu_regs
(
reg
[
i
]);
read_wb_info
(
wpc
[
i
],
wdata
[
i
],
wdst
[
i
],
lpaddr
[
i
],
ltype
[
i
],
lfu
[
i
]);
read_wb_info
(
wpc
[
i
],
wdata
[
i
],
wdst
[
i
],
lpaddr
[
i
],
ltype
[
i
],
lfu
[
i
]);
load_diff_info
(
diff
,
i
);
}
else
{
}
else
{
#ifdef DUALCORE
read_emu_regs2
(
reg
[
i
]);
read_emu_regs2
(
reg
[
i
]);
read_wb_info2
(
wpc
[
i
],
wdata
[
i
],
wdst
[
i
],
lpaddr
[
i
],
ltype
[
i
],
lfu
[
i
]);
read_wb_info2
(
wpc
[
i
],
wdata
[
i
],
wdst
[
i
],
lpaddr
[
i
],
ltype
[
i
],
lfu
[
i
]);
load_diff_info2
(
diff
,
i
);
#else
assert
(
0
);
#endif
}
}
load_diff_info
(
diff
,
i
);
if
(
difftest_step
(
&
diff
[
i
],
i
))
{
if
(
difftest_step
(
&
diff
[
i
],
i
))
{
trapCode
=
STATE_ABORT
;
trapCode
=
STATE_ABORT
;
...
@@ -631,22 +652,12 @@ uint64_t Emulator::execute(uint64_t max_cycle, uint64_t max_instr) {
...
@@ -631,22 +652,12 @@ uint64_t Emulator::execute(uint64_t max_cycle, uint64_t max_instr) {
}
}
// Update Golden Memory info
// Update Golden Memory info
// if (dut_ptr->io_difftest_sbufferResp && dut_ptr->io_difftest2_sbufferResp) {
// printf("Double sbuffer resp\n");
// }
// assert(!(dut_ptr->io_difftest_sbufferResp && dut_ptr->io_difftest2_sbufferResp));
if
(
dut_ptr
->
io_difftest_sbufferResp
)
{
if
(
dut_ptr
->
io_difftest_sbufferResp
)
{
read_sbuffer_info
(
sbufferData
);
read_sbuffer_info
(
sbufferData
);
uint64_t
sbufferAddr
=
dut_ptr
->
io_difftest_sbufferAddr
;
uint64_t
sbufferAddr
=
dut_ptr
->
io_difftest_sbufferAddr
;
uint64_t
sbufferMask
=
dut_ptr
->
io_difftest_sbufferMask
;
uint64_t
sbufferMask
=
dut_ptr
->
io_difftest_sbufferMask
;
update_goldenmem
(
sbufferAddr
,
sbufferData
,
sbufferMask
,
64
);
update_goldenmem
(
sbufferAddr
,
sbufferData
,
sbufferMask
,
64
);
}
}
if
(
dut_ptr
->
io_difftest2_sbufferResp
)
{
read_sbuffer_info2
(
sbufferData
);
uint64_t
sbufferAddr
=
dut_ptr
->
io_difftest2_sbufferAddr
;
uint64_t
sbufferMask
=
dut_ptr
->
io_difftest2_sbufferMask
;
update_goldenmem
(
sbufferAddr
,
sbufferData
,
sbufferMask
,
64
);
}
if
(
dut_ptr
->
io_difftest_atomicResp
)
{
if
(
dut_ptr
->
io_difftest_atomicResp
)
{
uint64_t
*
atomicData
=
&
dut_ptr
->
io_difftest_atomicData
;
uint64_t
*
atomicData
=
&
dut_ptr
->
io_difftest_atomicData
;
...
@@ -656,6 +667,14 @@ uint64_t Emulator::execute(uint64_t max_cycle, uint64_t max_instr) {
...
@@ -656,6 +667,14 @@ uint64_t Emulator::execute(uint64_t max_cycle, uint64_t max_instr) {
uint64_t
atomicOut
=
dut_ptr
->
io_difftest_atomicOut
;
uint64_t
atomicOut
=
dut_ptr
->
io_difftest_atomicOut
;
handle_atomic
(
atomicAddr
,
atomicData
,
atomicMask
,
atomicFuop
,
atomicOut
);
handle_atomic
(
atomicAddr
,
atomicData
,
atomicMask
,
atomicFuop
,
atomicOut
);
}
}
#ifdef DUALCORE
if
(
dut_ptr
->
io_difftest2_sbufferResp
)
{
read_sbuffer_info2
(
sbufferData
);
uint64_t
sbufferAddr
=
dut_ptr
->
io_difftest2_sbufferAddr
;
uint64_t
sbufferMask
=
dut_ptr
->
io_difftest2_sbufferMask
;
update_goldenmem
(
sbufferAddr
,
sbufferData
,
sbufferMask
,
64
);
}
if
(
dut_ptr
->
io_difftest2_atomicResp
)
{
if
(
dut_ptr
->
io_difftest2_atomicResp
)
{
uint64_t
*
atomicData
=
&
dut_ptr
->
io_difftest2_atomicData
;
uint64_t
*
atomicData
=
&
dut_ptr
->
io_difftest2_atomicData
;
uint64_t
atomicAddr
=
dut_ptr
->
io_difftest2_atomicAddr
;
uint64_t
atomicAddr
=
dut_ptr
->
io_difftest2_atomicAddr
;
...
@@ -664,6 +683,7 @@ uint64_t Emulator::execute(uint64_t max_cycle, uint64_t max_instr) {
...
@@ -664,6 +683,7 @@ uint64_t Emulator::execute(uint64_t max_cycle, uint64_t max_instr) {
uint64_t
atomicOut
=
dut_ptr
->
io_difftest2_atomicOut
;
uint64_t
atomicOut
=
dut_ptr
->
io_difftest2_atomicOut
;
handle_atomic
(
atomicAddr
,
atomicData
,
atomicMask
,
atomicFuop
,
atomicOut
);
handle_atomic
(
atomicAddr
,
atomicData
,
atomicMask
,
atomicFuop
,
atomicOut
);
}
}
#endif
uint32_t
t
=
uptime
();
uint32_t
t
=
uptime
();
if
(
t
-
lasttime_poll
>
100
)
{
if
(
t
-
lasttime_poll
>
100
)
{
...
...
src/test/csrc/emu.h
浏览文件 @
76e34764
...
@@ -8,7 +8,13 @@
...
@@ -8,7 +8,13 @@
#define SNAPSHOT_INTERVAL 60 // unit: second
#define SNAPSHOT_INTERVAL 60 // unit: second
// #define DIFFTEST_STORE_COMMIT
// #define DIFFTEST_STORE_COMMIT
#define NumCore 2
// #define DUALCORE
#ifdef DUALCORE
#define NumCore 2
#else
#define NumCore 1
#endif
struct
EmuArgs
{
struct
EmuArgs
{
uint32_t
seed
;
uint32_t
seed
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录