Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
NEMU
提交
495c2d73
N
NEMU
项目概览
OpenXiangShan
/
NEMU
大约 1 年 前同步成功
通知
7
Star
171
Fork
67
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
NEMU
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
495c2d73
编写于
9月 04, 2019
作者:
P
Parallels
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add "ISA64" micro to control the system, support all ISAs to pass the tests
上级
7a4a23cd
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
82 addition
and
5 deletion
+82
-5
include/common.h
include/common.h
+7
-0
include/cpu/decode.h
include/cpu/decode.h
+9
-0
include/memory/memory.h
include/memory/memory.h
+6
-0
include/monitor/diff-test.h
include/monitor/diff-test.h
+5
-0
include/rtl/rtl.h
include/rtl/rtl.h
+12
-5
src/cpu/inv.c
src/cpu/inv.c
+8
-0
src/device/io/map.c
src/device/io/map.c
+6
-0
src/monitor/cpu-exec.c
src/monitor/cpu-exec.c
+11
-0
src/monitor/debug/log.c
src/monitor/debug/log.c
+5
-0
src/monitor/debug/ui.c
src/monitor/debug/ui.c
+9
-0
src/monitor/diff-test/diff-test.c
src/monitor/diff-test/diff-test.c
+4
-0
未找到文件。
include/common.h
浏览文件 @
495c2d73
...
...
@@ -21,10 +21,17 @@
typedef
uint8_t
bool
;
#ifdef ISA64
typedef
uint64_t
rtlreg_t
;
typedef
uint32_t
paddr_t
;
typedef
uint64_t
vaddr_t
;
#else
typedef
uint32_t
rtlreg_t
;
typedef
uint32_t
paddr_t
;
typedef
uint32_t
vaddr_t
;
#endif
typedef
uint16_t
ioaddr_t
;
...
...
include/cpu/decode.h
浏览文件 @
495c2d73
...
...
@@ -12,12 +12,21 @@ enum { OP_TYPE_REG, OP_TYPE_MEM, OP_TYPE_IMM };
typedef
struct
{
uint32_t
type
;
int
width
;
#ifdef ISA64
union
{
uint64_t
reg
;
rtlreg_t
addr
;
uint64_t
imm
;
int64_t
simm
;
};
#else
union
{
uint32_t
reg
;
rtlreg_t
addr
;
uint32_t
imm
;
int32_t
simm
;
};
#endif
rtlreg_t
val
;
char
str
[
OP_STR_SIZE
];
}
Operand
;
...
...
include/memory/memory.h
浏览文件 @
495c2d73
...
...
@@ -17,18 +17,24 @@ void register_pmem(paddr_t base);
uint32_t
isa_vaddr_read
(
vaddr_t
,
int
);
void
isa_vaddr_write
(
vaddr_t
,
uint32_t
,
int
);
#ifdef ISA64
uint64_t
isa_vaddr_read64
(
vaddr_t
,
int
);
void
isa_vaddr_write64
(
vaddr_t
,
uint64_t
,
int
);
#endif
#define vaddr_read isa_vaddr_read
#define vaddr_write isa_vaddr_write
#ifdef ISA64
#define vaddr_read64 isa_vaddr_read64
#define vaddr_write64 isa_vaddr_write64
#endif
uint32_t
paddr_read
(
paddr_t
,
int
);
void
paddr_write
(
paddr_t
,
uint32_t
,
int
);
#ifdef ISA64
uint64_t
paddr_read64
(
paddr_t
,
int
);
void
paddr_write64
(
paddr_t
,
uint64_t
,
int
);
#endif
#define PAGE_SIZE 4096
#define PAGE_MASK (PAGE_SIZE - 1)
...
...
include/monitor/diff-test.h
浏览文件 @
495c2d73
...
...
@@ -21,8 +21,13 @@ extern void (*ref_difftest_exec)(uint64_t n);
static
inline
bool
difftest_check_reg
(
const
char
*
name
,
vaddr_t
pc
,
rtlreg_t
ref
,
rtlreg_t
dut
)
{
if
(
ref
!=
dut
)
{
#ifdef ISA64
Log
(
"%s is different after executing instruction at pc = 0x%16lx, right = 0x%16lx, wrong = 0x%16lx"
,
name
,
pc
,
ref
,
dut
);
#else
Log
(
"%s is different after executing instruction at pc = 0x%08x, right = 0x%08x, wrong = 0x%08x"
,
name
,
pc
,
ref
,
dut
);
#endif
return
false
;
}
return
true
;
...
...
include/rtl/rtl.h
浏览文件 @
495c2d73
...
...
@@ -39,21 +39,24 @@ make_rtl_arith_logic(or)
make_rtl_arith_logic
(
xor
)
make_rtl_arith_logic
(
shl
)
make_rtl_arith_logic
(
shr
)
make_rtl_arith_logic
(
shr64
)
make_rtl_arith_logic
(
sar
)
make_rtl_arith_logic
(
sar64
)
make_rtl_arith_logic
(
mul_lo
)
make_rtl_arith_logic
(
mul_hi
)
make_rtl_arith_logic
(
imul_lo
)
make_rtl_arith_logic
(
imul_hi
)
make_rtl_arith_logic
(
div_q
)
make_rtl_arith_logic
(
div_q64
)
make_rtl_arith_logic
(
div_r
)
make_rtl_arith_logic
(
div_r64
)
make_rtl_arith_logic
(
idiv_q
)
make_rtl_arith_logic
(
idiv_q64
)
make_rtl_arith_logic
(
idiv_r
)
#ifdef ISA64
make_rtl_arith_logic
(
shr64
)
make_rtl_arith_logic
(
sar64
)
make_rtl_arith_logic
(
div_q64
)
make_rtl_arith_logic
(
div_r64
)
make_rtl_arith_logic
(
idiv_q64
)
make_rtl_arith_logic
(
idiv_r64
)
#endif
static
inline
void
interpret_rtl_div64_q
(
rtlreg_t
*
dest
,
const
rtlreg_t
*
src1_hi
,
const
rtlreg_t
*
src1_lo
,
const
rtlreg_t
*
src2
)
{
...
...
@@ -84,16 +87,20 @@ static inline void interpret_rtl_idiv64_r(rtlreg_t* dest,
}
static
inline
void
interpret_rtl_lm
(
rtlreg_t
*
dest
,
const
rtlreg_t
*
addr
,
int
len
)
{
#ifdef ISA64
if
(
len
==
8
)
*
dest
=
vaddr_read64
(
*
addr
,
len
);
else
#endif
*
dest
=
vaddr_read
(
*
addr
,
len
);
}
static
inline
void
interpret_rtl_sm
(
const
rtlreg_t
*
addr
,
const
rtlreg_t
*
src1
,
int
len
)
{
#ifdef ISA64
if
(
len
==
8
)
vaddr_write64
(
*
addr
,
*
src1
,
len
);
else
#endif
vaddr_write
(
*
addr
,
*
src1
,
len
);
}
...
...
src/cpu/inv.c
浏览文件 @
495c2d73
...
...
@@ -2,10 +2,18 @@
void
display_inv_msg
(
vaddr_t
pc
)
{
extern
char
isa_logo
[];
#ifdef ISA64
printf
(
"There are two cases which will trigger this unexpected exception:
\n
"
"1. The instruction at PC = 0x%16lx is not implemented.
\n
"
"2. Something is implemented incorrectly.
\n
"
,
pc
);
printf
(
"Find this PC(0x%16lx) in the disassembling result to distinguish which case it is.
\n\n
"
,
pc
);
#else
printf
(
"There are two cases which will trigger this unexpected exception:
\n
"
"1. The instruction at PC = 0x%08x is not implemented.
\n
"
"2. Something is implemented incorrectly.
\n
"
,
pc
);
printf
(
"Find this PC(0x%08x) in the disassembling result to distinguish which case it is.
\n\n
"
,
pc
);
#endif
printf
(
"
\33
[1;31mIf it is the first case, see
\n
%s
\n
for more details.
\n\n
If it is the second case, remember:
\n
"
"* The machine is always right!
\n
"
"* Every line of untested code is always wrong!
\33
[0m
\n\n
"
,
isa_logo
);
...
...
src/device/io/map.c
浏览文件 @
495c2d73
...
...
@@ -17,9 +17,15 @@ uint8_t* new_space(int size) {
}
static
inline
void
check_bound
(
IOMap
*
map
,
paddr_t
addr
)
{
#ifdef ISA64
Assert
(
map
!=
NULL
&&
addr
<=
map
->
high
&&
addr
>=
map
->
low
,
"address (0x%08x) is out of bound {%s} [0x%08x, 0x%08x] at pc = 0x%16lx"
,
addr
,
(
map
?
map
->
name
:
"???"
),
(
map
?
map
->
low
:
0
),
(
map
?
map
->
high
:
0
),
cpu
.
pc
);
#else
Assert
(
map
!=
NULL
&&
addr
<=
map
->
high
&&
addr
>=
map
->
low
,
"address (0x%08x) is out of bound {%s} [0x%08x, 0x%08x] at pc = 0x%08x"
,
addr
,
(
map
?
map
->
name
:
"???"
),
(
map
?
map
->
low
:
0
),
(
map
?
map
->
high
:
0
),
cpu
.
pc
);
#endif
}
static
inline
void
invoke_callback
(
io_callback_t
c
,
uint32_t
offset
,
int
len
,
bool
is_write
)
{
...
...
src/monitor/cpu-exec.c
浏览文件 @
495c2d73
...
...
@@ -61,7 +61,11 @@ void cpu_exec(uint64_t n) {
/* TODO: check watchpoints here. */
WP
*
wp
=
scan_watchpoint
();
if
(
wp
!=
NULL
)
{
#ifdef ISA64
printf
(
"
\n\n
Hint watchpoint %d at address 0x%16lx, expr = %s
\n
"
,
wp
->
NO
,
ori_pc
,
wp
->
expr
);
#else
printf
(
"
\n\n
Hint watchpoint %d at address 0x%08x, expr = %s
\n
"
,
wp
->
NO
,
ori_pc
,
wp
->
expr
);
#endif
printf
(
"old value = %#08x
\n
new value = %#08x
\n
"
,
wp
->
old_val
,
wp
->
new_val
);
wp
->
old_val
=
wp
->
new_val
;
return
;
...
...
@@ -83,10 +87,17 @@ void cpu_exec(uint64_t n) {
case
NEMU_RUNNING
:
nemu_state
.
state
=
NEMU_STOP
;
break
;
case
NEMU_END
:
case
NEMU_ABORT
:
#ifdef ISA64
_Log
(
"nemu: %s
\33
[0m at pc = 0x%16lx
\n\n
"
,
(
nemu_state
.
state
==
NEMU_ABORT
?
"
\33
[1;31mABORT"
:
(
nemu_state
.
halt_ret
==
0
?
"
\33
[1;32mHIT GOOD TRAP"
:
"
\33
[1;31mHIT BAD TRAP"
)),
nemu_state
.
halt_pc
);
#else
_Log
(
"nemu: %s
\33
[0m at pc = 0x%08x
\n\n
"
,
(
nemu_state
.
state
==
NEMU_ABORT
?
"
\33
[1;31mABORT"
:
(
nemu_state
.
halt_ret
==
0
?
"
\33
[1;32mHIT GOOD TRAP"
:
"
\33
[1;31mHIT BAD TRAP"
)),
nemu_state
.
halt_pc
);
#endif
monitor_statistic
();
}
}
src/monitor/debug/log.c
浏览文件 @
495c2d73
...
...
@@ -22,8 +22,13 @@ void strcatf(char *buf, const char *fmt, ...) {
}
void
asm_print
(
vaddr_t
ori_pc
,
int
instr_len
,
bool
print_flag
)
{
#ifdef ISA64
snprintf
(
tempbuf
,
sizeof
(
tempbuf
),
"%16lx: %s%*.s%s"
,
ori_pc
,
log_bytebuf
,
50
-
(
12
+
3
*
instr_len
),
""
,
log_asmbuf
);
#else
snprintf
(
tempbuf
,
sizeof
(
tempbuf
),
"%08x: %s%*.s%s"
,
ori_pc
,
log_bytebuf
,
50
-
(
12
+
3
*
instr_len
),
""
,
log_asmbuf
);
#endif
log_write
(
"%s
\n
"
,
tempbuf
);
if
(
print_flag
)
{
puts
(
tempbuf
);
...
...
src/monitor/debug/ui.c
浏览文件 @
495c2d73
...
...
@@ -88,8 +88,13 @@ static int cmd_d(char *args) {
static
int
cmd_p
(
char
*
args
)
{
if
(
args
!=
NULL
)
{
bool
success
;
#ifdef ISA64
uint64_t
r
=
expr
(
args
,
&
success
);
if
(
success
)
{
printf
(
"0x%lx
\n
"
,
r
);
}
#else
uint32_t
r
=
expr
(
args
,
&
success
);
if
(
success
)
{
printf
(
"0x%x
\n
"
,
r
);
}
#endif
else
{
printf
(
"Bad expression
\n
"
);
}
}
return
0
;
...
...
@@ -122,7 +127,11 @@ static int cmd_x(char *args) {
if
(
success
)
{
for
(
i
=
0
;
i
<
n
;
i
++
)
{
if
(
i
%
4
==
0
)
{
#ifdef ISA64
printf
(
"0x%16lx: "
,
addr
);
#else
printf
(
"0x%08x: "
,
addr
);
#endif
}
printf
(
"0x%08x "
,
vaddr_read
(
addr
,
4
));
...
...
src/monitor/diff-test/diff-test.c
浏览文件 @
495c2d73
...
...
@@ -95,7 +95,11 @@ void difftest_step(vaddr_t ori_pc, vaddr_t next_pc) {
}
skip_dut_nr_instr
--
;
if
(
skip_dut_nr_instr
==
0
)
#ifdef ISA64
panic
(
"can not catch up with ref.pc = %lx at pc = %lx"
,
ref_r
.
pc
,
ori_pc
);
#else
panic
(
"can not catch up with ref.pc = %x at pc = %x"
,
ref_r
.
pc
,
ori_pc
);
#endif
return
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录