Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
饶先宏
hdl4se
提交
ad85fc11
H
hdl4se
项目概览
饶先宏
/
hdl4se
通知
12
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hdl4se
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ad85fc11
编写于
9月 05, 2021
作者:
饶先宏
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
202109051002
上级
6f8db5d8
变更
12
展开全部
显示空白变更内容
内联
并排
Showing
12 changed file
with
17093 addition
and
9296 deletion
+17093
-9296
examples/hdl4se_riscv/de2/PLLJ_PLLSPE_INFO.txt
examples/hdl4se_riscv/de2/PLLJ_PLLSPE_INFO.txt
+1
-1
examples/hdl4se_riscv/de2/de2_riscv_v4.qws
examples/hdl4se_riscv/de2/de2_riscv_v4.qws
+0
-0
examples/hdl4se_riscv/de2/de2_riscv_v4.sof
examples/hdl4se_riscv/de2/de2_riscv_v4.sof
+0
-0
examples/hdl4se_riscv/de2/de2_riscv_v4.v
examples/hdl4se_riscv/de2/de2_riscv_v4.v
+1
-1
examples/hdl4se_riscv/test_code/console.c
examples/hdl4se_riscv/test_code/console.c
+122
-33
examples/hdl4se_riscv/test_code/test.cod
examples/hdl4se_riscv/test_code/test.cod
+639
-375
examples/hdl4se_riscv/test_code/test.elf
examples/hdl4se_riscv/test_code/test.elf
+0
-0
examples/hdl4se_riscv/test_code/test.hex
examples/hdl4se_riscv/test_code/test.hex
+761
-497
examples/hdl4se_riscv/test_code/test.info
examples/hdl4se_riscv/test_code/test.info
+111
-95
examples/hdl4se_riscv/test_code/test.mif
examples/hdl4se_riscv/test_code/test.mif
+2974
-2974
examples/hdl4se_riscv/test_code/test.txt
examples/hdl4se_riscv/test_code/test.txt
+12344
-5213
examples/hdl4se_riscv/verilog/riscv_core_v4.v
examples/hdl4se_riscv/verilog/riscv_core_v4.v
+140
-107
未找到文件。
examples/hdl4se_riscv/de2/PLLJ_PLLSPE_INFO.txt
浏览文件 @
ad85fc11
PLL_Name pllqsys:c
omb_9
|pllqsys_altpll_0:altpll_0|pllqsys_altpll_0_altpll_m342:sd1|pll7
PLL_Name pllqsys:c
lk
|pllqsys_altpll_0:altpll_0|pllqsys_altpll_0_altpll_m342:sd1|pll7
PLLJITTER 30
PLLJITTER 30
PLLSPEmax 84
PLLSPEmax 84
PLLSPEmin -53
PLLSPEmin -53
...
...
examples/hdl4se_riscv/de2/de2_riscv_v4.qws
0 → 100644
浏览文件 @
ad85fc11
文件已添加
examples/hdl4se_riscv/de2/de2_riscv_v4.sof
浏览文件 @
ad85fc11
无法预览此类型文件
examples/hdl4se_riscv/de2/de2_riscv_v4.v
浏览文件 @
ad85fc11
...
@@ -380,7 +380,7 @@ inout [35:0] GPIO;
...
@@ -380,7 +380,7 @@ inout [35:0] GPIO;
`else
`else
wire
clk100MHz
;
wire
clk100MHz
;
wire
nwReset
=
KEY
[
3
];
wire
nwReset
=
KEY
[
3
];
pllqsys
(
pllqsys
clk
(
.
clk_clk
(
CLOCK_50
),
// clk.clk
.
clk_clk
(
CLOCK_50
),
// clk.clk
.
reset_reset_n
(
nwReset
),
// reset.reset_n
.
reset_reset_n
(
nwReset
),
// reset.reset_n
.
altpll_0_c0_clk
(
clk100MHz
),
// altpll_0_c0.clk
.
altpll_0_c0_clk
(
clk100MHz
),
// altpll_0_c0.clk
...
...
examples/hdl4se_riscv/test_code/console.c
浏览文件 @
ad85fc11
...
@@ -78,7 +78,7 @@ static int _gets(char* s, int buflen)
...
@@ -78,7 +78,7 @@ static int _gets(char* s, int buflen)
return
ind
;
return
ind
;
}
}
static
int
_d2s
(
char
*
buf
,
int
num
)
static
int
_d2s
(
char
*
buf
,
long
long
num
)
{
{
int
i
;
int
i
;
int
len
;
int
len
;
...
@@ -89,12 +89,16 @@ static int _d2s(char* buf, int num)
...
@@ -89,12 +89,16 @@ static int _d2s(char* buf, int num)
num
=
-
num
;
num
=
-
num
;
sign
=
0
;
sign
=
0
;
}
}
if
(
num
==
0
)
buf
[
len
++
]
=
'0'
;
else
{
while
(
num
>
0
)
{
while
(
num
>
0
)
{
buf
[
len
++
]
=
(
num
%
10
)
+
'0'
;
buf
[
len
++
]
=
(
num
%
10
)
+
'0'
;
num
/=
10
;
num
/=
10
;
}
}
if
(
sign
)
if
(
sign
)
buf
[
len
++
]
=
'-'
;
buf
[
len
++
]
=
'-'
;
}
for
(
i
=
0
;
i
<
len
/
2
;
i
++
)
{
for
(
i
=
0
;
i
<
len
/
2
;
i
++
)
{
int
di
=
len
-
1
-
i
;
int
di
=
len
-
1
-
i
;
char
temp
;
char
temp
;
...
@@ -303,7 +307,7 @@ static void dispmem()
...
@@ -303,7 +307,7 @@ static void dispmem()
if
(
(
startaddr
&
0xff
)
==
0
)
if
(
(
startaddr
&
0xff
)
==
0
)
break
;
break
;
}
}
_puts
(
"
\n
"
);
_puts
(
"
\n
\r
"
);
displayaddr
=
startaddr
;
displayaddr
=
startaddr
;
}
}
...
@@ -326,34 +330,108 @@ static unsigned int num2seg(unsigned int num)
...
@@ -326,34 +330,108 @@ static unsigned int num2seg(unsigned int num)
return
segcode
[
num
%
10
];
return
segcode
[
num
%
10
];
}
}
static
unsigned
long
long
cycle
()
{
unsigned
long
long
ret
;
#define DEFINECSRGET(csrname, csrno) \
unsigned
int
retl
,
reth
;
static unsigned long long csrname() { \
asm
volatile
(
unsigned long long ret; \
"csrrsi %0, %1, %2 "
:
"=r"
(
retl
)
:
"i"
(
0xc00
),
"i"
(
0
)
:
"a0"
unsigned int retl, reth; \
);
asm volatile ( \
asm
volatile
(
"csrrsi %0, %1, %2 " : "=r"(retl) : "i"(csrno), "i"(0) : "a0" \
"csrrsi %0, %1, %2 "
:
"=r"
(
reth
)
:
"i"
(
0xc80
),
"i"
(
0
)
:
"a0"
); \
);
asm volatile ( \
ret
=
reth
;
"csrrsi %0, %1, %2 " : "=r"(reth) : "i"(csrno + 0x080), "i"(0) : "a0" \
ret
<<=
32
;
); \
ret
|=
retl
;
ret = reth; \
return
ret
;
ret <<= 32; \
ret |= retl; \
return ret; \
}
}
static
unsigned
long
long
instrcount
()
{
#define DEFINECSRGETCLEAR(csrname, csrno) \
unsigned
long
long
ret
;
static unsigned long long csrname() { \
unsigned
int
retl
,
reth
;
unsigned long long ret; \
asm
volatile
(
unsigned int retl = 0, reth = 0; \
"csrrsi %0, %1, %2 "
:
"=r"
(
retl
)
:
"i"
(
0xc02
),
"i"
(
0
)
:
"a0"
asm volatile ( \
);
"csrrw %0, %1, %2 " : "=r"(retl) : "i"(csrno), "r"(retl) : "a0" \
asm
volatile
(
); \
"csrrsi %0, %1, %2 "
:
"=r"
(
reth
)
:
"i"
(
0xc82
),
"i"
(
0
)
:
"a0"
asm volatile ( \
);
"csrrw %0, %1, %2 " : "=r"(reth) : "i"(csrno + 0x080), "r"(reth) : "a0" \
ret
=
reth
;
); \
ret
<<=
32
;
ret = reth; \
ret
|=
retl
;
ret <<= 32; \
return
ret
;
ret |= retl; \
return ret; \
}
DEFINECSRGET
(
cycle
,
0xc00
)
DEFINECSRGETCLEAR
(
cycle_clear
,
0xc00
)
DEFINECSRGET
(
instrcount
,
0xc02
)
DEFINECSRGETCLEAR
(
instrcount_clear
,
0xc02
)
DEFINECSRGET
(
get_counter_addsub
,
0xc20
)
DEFINECSRGETCLEAR
(
get_counter_addsub_clear
,
0xc20
)
DEFINECSRGET
(
get_counter_mul
,
0xc21
)
DEFINECSRGETCLEAR
(
get_counter_mul_clear
,
0xc21
)
DEFINECSRGET
(
get_counter_div
,
0xc22
)
DEFINECSRGETCLEAR
(
get_counter_div_clear
,
0xc22
)
DEFINECSRGET
(
get_counter_ld
,
0xc23
)
DEFINECSRGETCLEAR
(
get_counter_ld_clear
,
0xc23
)
DEFINECSRGET
(
get_counter_st
,
0xc24
)
DEFINECSRGETCLEAR
(
get_counter_st_clear
,
0xc24
)
DEFINECSRGET
(
get_counter_jmp
,
0xc25
)
DEFINECSRGETCLEAR
(
get_counter_jmp_clear
,
0xc25
)
DEFINECSRGET
(
get_counter_j
,
0xc26
)
DEFINECSRGETCLEAR
(
get_counter_j_clear
,
0xc26
)
DEFINECSRGET
(
get_counter_alui
,
0xc27
)
DEFINECSRGETCLEAR
(
get_counter_alui_clear
,
0xc27
)
DEFINECSRGET
(
get_counter_alu
,
0xc28
)
DEFINECSRGETCLEAR
(
get_counter_alu_clear
,
0xc28
)
typedef
unsigned
long
long
(
*
statusget
)();
statusget
statusgetfuncs
[
10
]
=
{
instrcount
,
get_counter_addsub
,
get_counter_mul
,
get_counter_div
,
get_counter_ld
,
get_counter_st
,
get_counter_jmp
,
get_counter_j
,
get_counter_alui
,
get_counter_alu
};
const
char
*
statusname
[
10
]
=
{
"total : "
,
"add/sub : "
,
"mul : "
,
"div : "
,
"ld : "
,
"st : "
,
"jmp : "
,
"j : "
,
"alui : "
,
"alu : "
,
};
static
void
liststatus
()
{
char
buf
[
40
];
unsigned
long
long
total
=
instrcount
();
unsigned
long
long
num
;
int
i
;
for
(
i
=
0
;
i
<
10
;
i
++
)
{
_puts
(
"
\n
"
);
_puts
(
statusname
[
i
]);
num
=
statusgetfuncs
[
i
]();
_d2s
(
buf
,
num
);
_puts
(
buf
);
_puts
(
", "
);
///num *= 10000;
num
/=
total
/
10000
;
_d2s
(
buf
,
num
);
_puts
(
buf
);
}
_puts
(
"
\n\r
"
);
}
}
static
void
printhelp
()
static
void
printhelp
()
...
@@ -440,6 +518,15 @@ int main(int argc, char* argv[])
...
@@ -440,6 +518,15 @@ int main(int argc, char* argv[])
if
(
_strncmp
(
buf
,
"help "
,
4
)
==
0
)
{
if
(
_strncmp
(
buf
,
"help "
,
4
)
==
0
)
{
printhelp
();
printhelp
();
}
}
/*
else if (buf[0] == 'c') {
cycle_clear();
instrcount_clear();
}
*/
else
if
(
buf
[
0
]
==
'l'
)
{
liststatus
();
}
else
if
(
buf
[
0
]
==
'b'
)
{
else
if
(
buf
[
0
]
==
'b'
)
{
int
baud
=
_s2d
(
buf
+
2
,
0
);
int
baud
=
_s2d
(
buf
+
2
,
0
);
if
(
baud
>
0
)
{
if
(
baud
>
0
)
{
...
@@ -506,6 +593,8 @@ int main(int argc, char* argv[])
...
@@ -506,6 +593,8 @@ int main(int argc, char* argv[])
_puts
(
")
\n\r
"
);
_puts
(
")
\n\r
"
);
}
}
}
}
while
(
_canputchar
()
==
0
)
;
}
while
(
1
);
}
while
(
1
);
return
1
;
return
1
;
}
}
examples/hdl4se_riscv/test_code/test.cod
浏览文件 @
ad85fc11
此差异已折叠。
点击以展开。
examples/hdl4se_riscv/test_code/test.elf
浏览文件 @
ad85fc11
无法预览此类型文件
examples/hdl4se_riscv/test_code/test.hex
浏览文件 @
ad85fc11
此差异已折叠。
点击以展开。
examples/hdl4se_riscv/test_code/test.info
浏览文件 @
ad85fc11
...
@@ -10,7 +10,7 @@ ELF Header:
...
@@ -10,7 +10,7 @@ ELF Header:
Version: 0x1
Version: 0x1
Entry point address: 0x8c
Entry point address: 0x8c
Start of program headers: 52 (bytes into file)
Start of program headers: 52 (bytes into file)
Start of section headers:
20312
(bytes into file)
Start of section headers:
38636
(bytes into file)
Flags: 0x0
Flags: 0x0
Size of this header: 52 (bytes)
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Size of program headers: 32 (bytes)
...
@@ -22,28 +22,28 @@ ELF Header:
...
@@ -22,28 +22,28 @@ ELF Header:
Section Headers:
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 00000074 000074 00
1a5c
00 AX 0 0 4
[ 1] .text PROGBITS 00000074 000074 00
29d4
00 AX 0 0 4
[ 2] .rodata PROGBITS 0000
1ad0 001ad0 000210
00 A 0 0 4
[ 2] .rodata PROGBITS 0000
2a48 002a48 00028c
00 A 0 0 4
[ 3] .eh_frame PROGBITS 0000
2000 002000 00002c
00 WA 0 0 4
[ 3] .eh_frame PROGBITS 0000
3000 003000 000054
00 WA 0 0 4
[ 4] .init_array INIT_ARRAY 0000
202c 00202c
000008 04 WA 0 0 4
[ 4] .init_array INIT_ARRAY 0000
3054 003054
000008 04 WA 0 0 4
[ 5] .fini_array FINI_ARRAY 0000
2034 002034
000004 04 WA 0 0 4
[ 5] .fini_array FINI_ARRAY 0000
305c 00305c
000004 04 WA 0 0 4
[ 6] .data PROGBITS 0000
2038 002038 00042
8 00 WA 0 0 8
[ 6] .data PROGBITS 0000
3060 003060 00047
8 00 WA 0 0 8
[ 7] .sdata PROGBITS 0000
2460 002460
00000c 00 WA 0 0 4
[ 7] .sdata PROGBITS 0000
34d8 0034d8
00000c 00 WA 0 0 4
[ 8] .sbss NOBITS 0000
246c 00246c
000008 00 WA 0 0 4
[ 8] .sbss NOBITS 0000
34e4 0034e4
000008 00 WA 0 0 4
[ 9] .bss NOBITS 0000
2474 00246c
00001c 00 WA 0 0 4
[ 9] .bss NOBITS 0000
34ec 0034e4
00001c 00 WA 0 0 4
[10] .comment PROGBITS 00000000 00
246c
000012 01 MS 0 0 1
[10] .comment PROGBITS 00000000 00
34e4
000012 01 MS 0 0 1
[11] .riscv.attributes RISCV_ATTRIBUTE 00000000 00
247e
000025 00 0 0 1
[11] .riscv.attributes RISCV_ATTRIBUTE 00000000 00
34f6
000025 00 0 0 1
[12] .debug_aranges PROGBITS 00000000 00
24a3 00003
8 00 0 0 1
[12] .debug_aranges PROGBITS 00000000 00
351b 00007
8 00 0 0 1
[13] .debug_info PROGBITS 00000000 00
24db 000839
00 0 0 1
[13] .debug_info PROGBITS 00000000 00
3593 0017b0
00 0 0 1
[14] .debug_abbrev PROGBITS 00000000 00
2d14 000216
00 0 0 1
[14] .debug_abbrev PROGBITS 00000000 00
4d43 00059f
00 0 0 1
[15] .debug_line PROGBITS 00000000 00
2f2a 000766
00 0 0 1
[15] .debug_line PROGBITS 00000000 00
52e2 001792
00 0 0 1
[16] .debug_str PROGBITS 00000000 00
3690 000296
01 MS 0 0 1
[16] .debug_str PROGBITS 00000000 00
6a74 0002a8
01 MS 0 0 1
[17] .debug_line_str PROGBITS 00000000 00
3926
0000b0 01 MS 0 0 1
[17] .debug_line_str PROGBITS 00000000 00
6d1c
0000b0 01 MS 0 0 1
[18] .debug_loclists PROGBITS 00000000 00
39d6 000a99
00 0 0 1
[18] .debug_loclists PROGBITS 00000000 00
6dcc 001aba
00 0 0 1
[19] .debug_rnglists PROGBITS 00000000 00
446f 000111
00 0 0 1
[19] .debug_rnglists PROGBITS 00000000 00
8886 0002c6
00 0 0 1
[20] .symtab SYMTAB 00000000 00
4580 0005d0 10 21 71
4
[20] .symtab SYMTAB 00000000 00
8b4c 0006d0 10 21 83
4
[21] .strtab STRTAB 00000000 00
4b50 000319
00 0 0 1
[21] .strtab STRTAB 00000000 00
921c 0003e0
00 0 0 1
[22] .shstrtab STRTAB 00000000 00
4e69
0000ee 00 0 0 1
[22] .shstrtab STRTAB 00000000 00
95fc
0000ee 00 0 0 1
Key to Flags:
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
L (link order), O (extra OS processing required), G (group), T (TLS),
...
@@ -54,8 +54,8 @@ There are no section groups in this file.
...
@@ -54,8 +54,8 @@ There are no section groups in this file.
Program Headers:
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x00000000 0x00000000 0x0
1ce0 0x01ce0
R E 0x1000
LOAD 0x000000 0x00000000 0x00000000 0x0
2cd4 0x02cd4
R E 0x1000
LOAD 0x00
2000 0x00002000 0x00002000 0x0046c 0x00490
RW 0x1000
LOAD 0x00
3000 0x00003000 0x00003000 0x004e4 0x00508
RW 0x1000
Section to Segment mapping:
Section to Segment mapping:
Segment Sections...
Segment Sections...
...
@@ -68,18 +68,18 @@ There are no relocations in this file.
...
@@ -68,18 +68,18 @@ There are no relocations in this file.
The decoding of unwind sections for machine type RISC-V is not currently supported.
The decoding of unwind sections for machine type RISC-V is not currently supported.
Symbol table '.symtab' contains
93
entries:
Symbol table '.symtab' contains
109
entries:
Num: Value Size Type Bind Vis Ndx Name
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000074 0 SECTION LOCAL DEFAULT 1 .text
1: 00000074 0 SECTION LOCAL DEFAULT 1 .text
2: 0000
1ad0
0 SECTION LOCAL DEFAULT 2 .rodata
2: 0000
2a48
0 SECTION LOCAL DEFAULT 2 .rodata
3: 0000
2
000 0 SECTION LOCAL DEFAULT 3 .eh_frame
3: 0000
3
000 0 SECTION LOCAL DEFAULT 3 .eh_frame
4: 0000
202c
0 SECTION LOCAL DEFAULT 4 .init_array
4: 0000
3054
0 SECTION LOCAL DEFAULT 4 .init_array
5: 0000
2034
0 SECTION LOCAL DEFAULT 5 .fini_array
5: 0000
305c
0 SECTION LOCAL DEFAULT 5 .fini_array
6: 0000
2038
0 SECTION LOCAL DEFAULT 6 .data
6: 0000
3060
0 SECTION LOCAL DEFAULT 6 .data
7: 0000
2460
0 SECTION LOCAL DEFAULT 7 .sdata
7: 0000
34d8
0 SECTION LOCAL DEFAULT 7 .sdata
8: 0000
246c
0 SECTION LOCAL DEFAULT 8 .sbss
8: 0000
34e4
0 SECTION LOCAL DEFAULT 8 .sbss
9: 0000
2474
0 SECTION LOCAL DEFAULT 9 .bss
9: 0000
34ec
0 SECTION LOCAL DEFAULT 9 .bss
10: 00000000 0 SECTION LOCAL DEFAULT 10 .comment
10: 00000000 0 SECTION LOCAL DEFAULT 10 .comment
11: 00000000 0 SECTION LOCAL DEFAULT 11 .riscv.attributes
11: 00000000 0 SECTION LOCAL DEFAULT 11 .riscv.attributes
12: 00000000 0 SECTION LOCAL DEFAULT 12 .debug_aranges
12: 00000000 0 SECTION LOCAL DEFAULT 12 .debug_aranges
...
@@ -93,76 +93,92 @@ Symbol table '.symtab' contains 93 entries:
...
@@ -93,76 +93,92 @@ Symbol table '.symtab' contains 93 entries:
20: 00000000 0 FILE LOCAL DEFAULT ABS __call_atexit.c
20: 00000000 0 FILE LOCAL DEFAULT ABS __call_atexit.c
21: 00000074 24 FUNC LOCAL DEFAULT 1 register_fini
21: 00000074 24 FUNC LOCAL DEFAULT 1 register_fini
22: 00000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
22: 00000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
23: 0000
2
000 0 OBJECT LOCAL DEFAULT 3 __EH_FRAME_BEGIN__
23: 0000
3
000 0 OBJECT LOCAL DEFAULT 3 __EH_FRAME_BEGIN__
24: 000000d8 0 FUNC LOCAL DEFAULT 1 __do_global_dtors_aux
24: 000000d8 0 FUNC LOCAL DEFAULT 1 __do_global_dtors_aux
25: 0000
2474
1 OBJECT LOCAL DEFAULT 9 completed.1
25: 0000
34ec
1 OBJECT LOCAL DEFAULT 9 completed.1
26: 0000
2034
0 OBJECT LOCAL DEFAULT 5 __do_global_dtor[...]
26: 0000
305c
0 OBJECT LOCAL DEFAULT 5 __do_global_dtor[...]
27: 0000011c 0 FUNC LOCAL DEFAULT 1 frame_dummy
27: 0000011c 0 FUNC LOCAL DEFAULT 1 frame_dummy
28: 0000
2478
24 OBJECT LOCAL DEFAULT 9 object.0
28: 0000
34f0
24 OBJECT LOCAL DEFAULT 9 object.0
29: 0000
2030
0 OBJECT LOCAL DEFAULT 4 __frame_dummy_in[...]
29: 0000
3058
0 OBJECT LOCAL DEFAULT 4 __frame_dummy_in[...]
30: 00000000 0 FILE LOCAL DEFAULT ABS console.c
30: 00000000 0 FILE LOCAL DEFAULT ABS console.c
31: 0000
2464
4 OBJECT LOCAL DEFAULT 7 _uartaddr
31: 0000
34dc
4 OBJECT LOCAL DEFAULT 7 _uartaddr
32: 0000
246c
4 OBJECT LOCAL DEFAULT 8 _uartstate
32: 0000
34e4
4 OBJECT LOCAL DEFAULT 8 _uartstate
33: 0000013c 60 FUNC LOCAL DEFAULT 1 _canputchar
33: 0000013c 60 FUNC LOCAL DEFAULT 1 _canputchar
34: 00000178 64 FUNC LOCAL DEFAULT 1 _haschar
34: 00000178 64 FUNC LOCAL DEFAULT 1 _haschar
35: 000001b8 88 FUNC LOCAL DEFAULT 1 _putchar
35: 000001b8 88 FUNC LOCAL DEFAULT 1 _putchar
36: 00000210 76 FUNC LOCAL DEFAULT 1 _getchar
36: 00000210 76 FUNC LOCAL DEFAULT 1 _getchar
37: 0000025c 104 FUNC LOCAL DEFAULT 1 _puts
37: 0000025c 104 FUNC LOCAL DEFAULT 1 _puts
38: 000002c4 216 FUNC LOCAL DEFAULT 1 _gets
38: 000002c4 216 FUNC LOCAL DEFAULT 1 _gets
39: 0000039c 348 FUNC LOCAL DEFAULT 1 _d2s
39: 0000039c 512 FUNC LOCAL DEFAULT 1 _d2s
40: 000004f8 424 FUNC LOCAL DEFAULT 1 _h2s
40: 0000059c 424 FUNC LOCAL DEFAULT 1 _h2s
41: 000006a0 252 FUNC LOCAL DEFAULT 1 _s2d
41: 00000744 252 FUNC LOCAL DEFAULT 1 _s2d
42: 0000079c 312 FUNC LOCAL DEFAULT 1 _s2h
42: 00000840 312 FUNC LOCAL DEFAULT 1 _s2h
43: 000008d4 140 FUNC LOCAL DEFAULT 1 _strcat
43: 00000978 140 FUNC LOCAL DEFAULT 1 _strcat
44: 00000960 152 FUNC LOCAL DEFAULT 1 _strncmp
44: 00000a04 152 FUNC LOCAL DEFAULT 1 _strncmp
45: 000009f8 64 FUNC LOCAL DEFAULT 1 _buadrateset
45: 00000a9c 64 FUNC LOCAL DEFAULT 1 _buadrateset
46: 00002470 4 OBJECT LOCAL DEFAULT 8 displayaddr
46: 000034e8 4 OBJECT LOCAL DEFAULT 8 displayaddr
47: 00000a38 628 FUNC LOCAL DEFAULT 1 dispmem
47: 00000adc 628 FUNC LOCAL DEFAULT 1 dispmem
48: 00000cac 124 FUNC LOCAL DEFAULT 1 cycle
48: 00000d50 124 FUNC LOCAL DEFAULT 1 cycle
49: 00000d28 124 FUNC LOCAL DEFAULT 1 instrcount
49: 00000dcc 124 FUNC LOCAL DEFAULT 1 instrcount
50: 00000da4 96 FUNC LOCAL DEFAULT 1 printhelp
50: 00000e48 124 FUNC LOCAL DEFAULT 1 get_counter_addsub
51: 00000000 0 FILE LOCAL DEFAULT ABS libgcc2.c
51: 00000ec4 124 FUNC LOCAL DEFAULT 1 get_counter_mul
52: 00000000 0 FILE LOCAL DEFAULT ABS exit.c
52: 00000f40 124 FUNC LOCAL DEFAULT 1 get_counter_div
53: 00000000 0 FILE LOCAL DEFAULT ABS init.c
53: 00000fbc 124 FUNC LOCAL DEFAULT 1 get_counter_ld
54: 00000000 0 FILE LOCAL DEFAULT ABS fini.c
54: 00001038 124 FUNC LOCAL DEFAULT 1 get_counter_st
55: 00000000 0 FILE LOCAL DEFAULT ABS atexit.c
55: 000010b4 124 FUNC LOCAL DEFAULT 1 get_counter_jmp
56: 00000000 0 FILE LOCAL DEFAULT ABS __atexit.c
56: 00001130 124 FUNC LOCAL DEFAULT 1 get_counter_j
57: 00000000 0 FILE LOCAL DEFAULT ABS sys_exit.c
57: 000011ac 124 FUNC LOCAL DEFAULT 1 get_counter_alui
58: 00000000 0 FILE LOCAL DEFAULT ABS errno.c
58: 00001228 124 FUNC LOCAL DEFAULT 1 get_counter_alu
59: 00000000 0 FILE LOCAL DEFAULT ABS libgcc2.c
59: 000012a4 340 FUNC LOCAL DEFAULT 1 liststatus
60: 00000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
60: 000013f8 96 FUNC LOCAL DEFAULT 1 printhelp
61: 00002028 0 OBJECT LOCAL DEFAULT 3 __FRAME_END__
61: 00000000 0 FILE LOCAL DEFAULT ABS libgcc2.c
62: 00000000 0 FILE LOCAL DEFAULT ABS impure.c
62: 00000000 0 FILE LOCAL DEFAULT ABS libgcc2.c
63: 00002038 1064 OBJECT LOCAL DEFAULT 6 impure_data
63: 00000000 0 FILE LOCAL DEFAULT ABS libgcc2.c
64: 00000000 0 FILE LOCAL DEFAULT ABS
64: 00000000 0 FILE LOCAL DEFAULT ABS exit.c
65: 00002038 0 NOTYPE LOCAL DEFAULT 5 __fini_array_end
65: 00000000 0 FILE LOCAL DEFAULT ABS init.c
66: 00002034 0 NOTYPE LOCAL DEFAULT 5 __fini_array_start
66: 00000000 0 FILE LOCAL DEFAULT ABS fini.c
67: 00002034 0 NOTYPE LOCAL DEFAULT 4 __init_array_end
67: 00000000 0 FILE LOCAL DEFAULT ABS atexit.c
68: 0000202c 0 NOTYPE LOCAL DEFAULT 4 __preinit_array_end
68: 00000000 0 FILE LOCAL DEFAULT ABS __atexit.c
69: 0000202c 0 NOTYPE LOCAL DEFAULT 4 __init_array_start
69: 00000000 0 FILE LOCAL DEFAULT ABS sys_exit.c
70: 0000202c 0 NOTYPE LOCAL DEFAULT 4 __preinit_array_start
70: 00000000 0 FILE LOCAL DEFAULT ABS errno.c
71: 00002838 0 NOTYPE GLOBAL DEFAULT ABS __global_pointer$
71: 00000000 0 FILE LOCAL DEFAULT ABS libgcc2.c
72: 00001ac8 8 FUNC GLOBAL DEFAULT 1 __errno
72: 00000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
73: 00002460 0 NOTYPE GLOBAL DEFAULT 7 __SDATA_BEGIN__
73: 00003050 0 OBJECT LOCAL DEFAULT 3 __FRAME_END__
74: 00002460 4 OBJECT GLOBAL DEFAULT 7 _global_impure_ptr
74: 00000000 0 FILE LOCAL DEFAULT ABS impure.c
75: 000016f8 156 FUNC GLOBAL DEFAULT 1 __libc_init_array
75: 000030b0 1064 OBJECT LOCAL DEFAULT 6 impure_data
76: 00001298 1072 FUNC GLOBAL HIDDEN 1 __udivdi3
76: 00000000 0 FILE LOCAL DEFAULT ABS
77: 00001990 92 FUNC GLOBAL DEFAULT 1 __libc_fini_array
77: 00003060 0 NOTYPE LOCAL DEFAULT 5 __fini_array_end
78: 00001870 288 FUNC GLOBAL DEFAULT 1 __call_exitprocs
78: 0000305c 0 NOTYPE LOCAL DEFAULT 5 __fini_array_start
79: 0000008c 76 FUNC GLOBAL DEFAULT 1 _start
79: 0000305c 0 NOTYPE LOCAL DEFAULT 4 __init_array_end
80: 00001a00 152 FUNC GLOBAL DEFAULT 1 __register_exitproc
80: 00003054 0 NOTYPE LOCAL DEFAULT 4 __preinit_array_end
81: 00002490 0 NOTYPE GLOBAL DEFAULT 9 __BSS_END__
81: 00003054 0 NOTYPE LOCAL DEFAULT 4 __init_array_start
82: 0000246c 0 NOTYPE GLOBAL DEFAULT 8 __bss_start
82: 00003054 0 NOTYPE LOCAL DEFAULT 4 __preinit_array_start
83: 00001794 220 FUNC GLOBAL DEFAULT 1 memset
83: 00001948 1144 FUNC GLOBAL HIDDEN 1 __divdi3
84: 00000e04 1172 FUNC GLOBAL DEFAULT 1 main
84: 00003860 0 NOTYPE GLOBAL DEFAULT ABS __global_pointer$
85: 00001be0 256 OBJECT GLOBAL HIDDEN 2 __clz_tab
85: 00002a40 8 FUNC GLOBAL DEFAULT 1 __errno
86: 000019ec 20 FUNC GLOBAL DEFAULT 1 atexit
86: 000034d8 0 NOTYPE GLOBAL DEFAULT 7 __SDATA_BEGIN__
87: 00002468 4 OBJECT GLOBAL DEFAULT 7 _impure_ptr
87: 000034d8 4 OBJECT GLOBAL DEFAULT 7 _global_impure_ptr
88: 00002038 0 NOTYPE GLOBAL DEFAULT 6 __DATA_BEGIN__
88: 00002670 156 FUNC GLOBAL DEFAULT 1 __libc_init_array
89: 0000246c 0 NOTYPE GLOBAL DEFAULT 7 _edata
89: 00002210 1072 FUNC GLOBAL HIDDEN 1 __udivdi3
90: 00002490 0 NOTYPE GLOBAL DEFAULT 9 _end
90: 00002908 92 FUNC GLOBAL DEFAULT 1 __libc_fini_array
91: 000016c8 48 FUNC GLOBAL DEFAULT 1 exit
91: 000027e8 288 FUNC GLOBAL DEFAULT 1 __call_exitprocs
92: 00001a98 48 FUNC GLOBAL DEFAULT 1 _exit
92: 0000008c 76 FUNC GLOBAL DEFAULT 1 _start
93: 00002978 152 FUNC GLOBAL DEFAULT 1 __register_exitproc
94: 00003088 40 OBJECT GLOBAL DEFAULT 6 statusname
95: 00003508 0 NOTYPE GLOBAL DEFAULT 9 __BSS_END__
96: 000034e4 0 NOTYPE GLOBAL DEFAULT 8 __bss_start
97: 0000270c 220 FUNC GLOBAL DEFAULT 1 memset
98: 00001458 1264 FUNC GLOBAL DEFAULT 1 main
99: 00002bd4 256 OBJECT GLOBAL HIDDEN 2 __clz_tab
100: 00002964 20 FUNC GLOBAL DEFAULT 1 atexit
101: 000034e0 4 OBJECT GLOBAL DEFAULT 7 _impure_ptr
102: 00003060 0 NOTYPE GLOBAL DEFAULT 6 __DATA_BEGIN__
103: 000034e4 0 NOTYPE GLOBAL DEFAULT 7 _edata
104: 00003508 0 NOTYPE GLOBAL DEFAULT 9 _end
105: 00003060 40 OBJECT GLOBAL DEFAULT 6 statusgetfuncs
106: 00002640 48 FUNC GLOBAL DEFAULT 1 exit
107: 00001dc0 1104 FUNC GLOBAL HIDDEN 1 __moddi3
108: 00002a10 48 FUNC GLOBAL DEFAULT 1 _exit
No version information found in this file.
No version information found in this file.
Attribute Section: riscv
Attribute Section: riscv
...
...
examples/hdl4se_riscv/test_code/test.mif
浏览文件 @
ad85fc11
此差异已折叠。
点击以展开。
examples/hdl4se_riscv/test_code/test.txt
浏览文件 @
ad85fc11
此差异已折叠。
点击以展开。
examples/hdl4se_riscv/verilog/riscv_core_v4.v
浏览文件 @
ad85fc11
...
@@ -45,6 +45,8 @@
...
@@ -45,6 +45,8 @@
`define
RAMSIZE 4096
`define
RAMSIZE 4096
`define
CSROPCOUNTER
(
*
(
*
HDL4SE
=
"LCOM"
,
HDL4SE
=
"LCOM"
,
CLSID
=
"638E8BC3-B0E0-41DC-9EDD-D35A39FD8051"
,
CLSID
=
"638E8BC3-B0E0-41DC-9EDD-D35A39FD8051"
,
...
@@ -89,32 +91,58 @@ module riscv_core(
...
@@ -89,32 +91,58 @@ module riscv_core(
/* CSR register */
/* CSR register */
reg
[
31
:
0
]
misa
;
/*0301*/
reg
[
31
:
0
]
misa
;
/*0301*/
reg
[
31
:
0
]
ucycle
;
/*0c00*/
reg
[
63
:
0
]
ucycle64
;
/*0c00/0c80*/
reg
[
31
:
0
]
utime
;
/*0c01*/
reg
[
63
:
0
]
utime64
;
/*0c01/0c81*/
reg
[
31
:
0
]
uinstret
;
/*0c02*/
reg
[
63
:
0
]
uinstret64
;
/*0c02/0c82*/
reg
[
31
:
0
]
ucycleh
;
/*0c80*/
reg
[
63
:
0
]
mcycle64
;
/*0b00/0b80*/
reg
[
31
:
0
]
utimeh
;
/*0c81*/
reg
[
63
:
0
]
minstret64
;
/*0b02/0b82*/
reg
[
31
:
0
]
uinstreth
;
/*0c82*/
`ifdef
CSROPCOUNTER
reg
[
31
:
0
]
mcycle
;
/*0b00*/
reg
[
63
:
0
]
opcounter_addsub64
;
/*0c20/0ca0*/
reg
[
31
:
0
]
minstret
;
/*0b02*/
reg
[
63
:
0
]
opcounter_mul64
;
/*0c21/0ca0*/
reg
[
31
:
0
]
mcycleh
;
/*0b80*/
reg
[
63
:
0
]
opcounter_div64
;
/*0c22/0ca0*/
reg
[
31
:
0
]
minstreth
;
/*0b82*/
reg
[
63
:
0
]
opcounter_ld64
;
/*0c23/0ca0*/
reg
[
63
:
0
]
opcounter_st64
;
/*0c24/0ca0*/
reg
[
63
:
0
]
opcounter_jmp64
;
/*0c25/0ca0*/
reg
[
63
:
0
]
opcounter_j64
;
/*0c26/0ca0*/
reg
[
63
:
0
]
opcounter_alui64
;
/* 0c27/0ca7*/
reg
[
63
:
0
]
opcounter_alu64
;
/* 0c28/0ca8*/
`endif
reg
[
31
:
0
]
csr_r
;
reg
[
31
:
0
]
csr_r
;
always
@
(
posedge
wClk
)
always
@
(
posedge
wClk
)
if
(
state
==
`RISCVSTATE_READ_REGS
)
if
(
state
==
`RISCVSTATE_READ_REGS
)
case
(
bReadData
[
31
:
20
])
case
(
bReadData
[
31
:
20
])
12'h301
:
csr_r
<=
misa
;
12'h301
:
csr_r
<=
misa
;
12'hc00
:
csr_r
<=
ucycle
;
12'hc00
:
csr_r
<=
ucycle64
[
31
:
0
];
12'hc01
:
csr_r
<=
utime
;
12'hc80
:
csr_r
<=
ucycle64
[
63
:
32
];
12'hc02
:
csr_r
<=
uinstret
;
12'hc01
:
csr_r
<=
utime64
[
31
:
0
];
12'hc80
:
csr_r
<=
ucycleh
;
12'hc81
:
csr_r
<=
utime64
[
63
:
32
];
12'hc81
:
csr_r
<=
utimeh
;
12'hc02
:
csr_r
<=
uinstret64
[
31
:
0
];
12'hc82
:
csr_r
<=
uinstreth
;
12'hc82
:
csr_r
<=
uinstret64
[
63
:
32
];
12'hb00
:
csr_r
<=
mcycle
;
12'hb00
:
csr_r
<=
mcycle64
[
31
:
0
];
12'hb02
:
csr_r
<=
minstret
;
12'hb80
:
csr_r
<=
mcycle64
[
63
:
32
];
12'hb80
:
csr_r
<=
mcycleh
;
12'hb02
:
csr_r
<=
minstret64
[
31
:
0
];
12'hb82
:
csr_r
<=
minstreth
;
12'hb82
:
csr_r
<=
minstret64
[
63
:
32
];
`ifdef
CSROPCOUNTER
12'hc20
:
csr_r
<=
opcounter_addsub64
[
31
:
0
];
12'hca0
:
csr_r
<=
opcounter_addsub64
[
63
:
32
];
12'hc21
:
csr_r
<=
opcounter_mul64
[
31
:
0
];
12'hca1
:
csr_r
<=
opcounter_mul64
[
63
:
32
];
12'hc22
:
csr_r
<=
opcounter_div64
[
31
:
0
];
12'hca2
:
csr_r
<=
opcounter_div64
[
63
:
32
];
12'hc23
:
csr_r
<=
opcounter_ld64
[
31
:
0
];
12'hca3
:
csr_r
<=
opcounter_ld64
[
63
:
32
];
12'hc24
:
csr_r
<=
opcounter_st64
[
31
:
0
];
12'hca4
:
csr_r
<=
opcounter_st64
[
63
:
32
];
12'hc25
:
csr_r
<=
opcounter_jmp64
[
31
:
0
];
12'hca5
:
csr_r
<=
opcounter_jmp64
[
63
:
32
];
12'hc26
:
csr_r
<=
opcounter_j64
[
31
:
0
];
12'hca6
:
csr_r
<=
opcounter_j64
[
63
:
32
];
12'hc27
:
csr_r
<=
opcounter_alui64
[
31
:
0
];
12'hca7
:
csr_r
<=
opcounter_alui64
[
63
:
32
];
12'hc28
:
csr_r
<=
opcounter_alu64
[
31
:
0
];
12'hca8
:
csr_r
<=
opcounter_alu64
[
63
:
32
];
`endif
default:
csr_r
<=
0
;
default:
csr_r
<=
0
;
endcase
endcase
...
@@ -131,18 +159,15 @@ module riscv_core(
...
@@ -131,18 +159,15 @@ module riscv_core(
wire
[
31
:
0
]
rs2
=
regrddata2
;
wire
[
31
:
0
]
rs2
=
regrddata2
;
wire
signed
[
31
:
0
]
rs1_s
=
rs1
;
wire
signed
[
31
:
0
]
rs1_s
=
rs1
;
wire
signed
[
31
:
0
]
rs2_s
=
rs2
;
wire
signed
[
31
:
0
]
rs2_s
=
rs2
;
wire
[
31
:
0
]
rs1_abs
=
rs1
[
31
]
?
(
-
rs1_s
)
:
rs1_s
;
wire
[
31
:
0
]
rs2_abs
=
rs2
[
31
]
?
(
-
rs2_s
)
:
rs2_s
;
wire
signed
[
31
:
0
]
imm_s
=
imm
;
wire
signed
[
31
:
0
]
imm_s
=
imm
;
wire
[
31
:
0
]
add_result
;
wire
[
31
:
0
]
sub_result
;
wire
[
63
:
0
]
mul_result
;
wire
[
63
:
0
]
mul_result
;
wire
[
63
:
0
]
muls_result
;
wire
[
63
:
0
]
muls_result
;
wire
[
71
:
0
]
mulsu_result
;
wire
[
71
:
0
]
mulsu_result
;
wire
[
31
:
0
]
div_result_r
,
mod_result_r
,
divs_result_r
,
mods_result_r
;
wire
[
31
:
0
]
div_result_r
,
mod_result_r
,
divs_result_r
,
mods_result_r
;
wire
[
31
:
0
]
div_result
,
mod_result
,
divs_result
,
mods_result
;
wire
[
31
:
0
]
div_result
,
mod_result
,
divs_result
,
mods_result
;
adder
add
(
rs1
,
rs2
,
add_result
);
suber
sub
(
rs1
,
rs2
,
sub_result
);
`define
USE3MUL
`define
USE3MUL
`ifdef
USE3MUL
`ifdef
USE3MUL
...
@@ -152,8 +177,6 @@ module riscv_core(
...
@@ -152,8 +177,6 @@ module riscv_core(
`else
`else
wire
signed
[
63
:
0
]
mul_result_sign
=
mul_result
;
wire
signed
[
63
:
0
]
mul_result_sign
=
mul_result
;
reg
[
31
:
0
]
mul_rs1
,
mul_rs2
;
reg
[
31
:
0
]
mul_rs1
,
mul_rs2
;
wire
[
31
:
0
]
rs1_abs
=
rs1
[
31
]
?
(
~
rs1
+
1
)
:
rs1
;
wire
[
31
:
0
]
rs2_abs
=
rs2
[
31
]
?
(
~
rs2
+
1
)
:
rs2
;
mult
mul
(
mul_rs1
,
mul_rs2
,
mul_result
);
mult
mul
(
mul_rs1
,
mul_rs2
,
mul_result
);
...
@@ -207,35 +230,19 @@ module riscv_core(
...
@@ -207,35 +230,19 @@ module riscv_core(
Total combinational functions 7,107 / 114,480 ( 6 % )
Total combinational functions 7,107 / 114,480 ( 6 % )
Dedicated logic registers 4,309 / 114,480 ( 4 % )
Dedicated logic registers 4,309 / 114,480 ( 4 % )
Total registers 4309
Total registers 4309
Total memory bits 151,274 / 3,981,312 ( 4 % )
Embedded Multiplier 9-bit elements 0 / 532 ( 0 % )
Embedded Multiplier 9-bit elements 0 / 532 ( 0 % )
一个除法器:
一个除法器:
Total logic elements 6,
264 / 114,480 ( 5
% )
Total logic elements 6,
319 / 114,480 ( 6
% )
Total combinational functions 5,60
7
/ 114,480 ( 5 % )
Total combinational functions 5,60
1
/ 114,480 ( 5 % )
Dedicated logic registers 2,916 / 114,480 ( 3 % )
Dedicated logic registers 2,916 / 114,480 ( 3 % )
Total registers 2916
Total registers 2916
Embedded Multiplier 9-bit elements 0 / 532 ( 0 % )
去掉两个乘法器:(比较怪异的是,逻辑门数反而增加了,这个很奇怪,难度综合的时候它能合并乘法器?)
Total logic elements 6,331 / 114,480 ( 6 % )
Total combinational functions 5,609 / 114,480 ( 5 % )
Dedicated logic registers 2,917 / 114,480 ( 3 % )
Total registers 2917
Total memory bits 150,192 / 3,981,312 ( 4 % )
Total memory bits 150,192 / 3,981,312 ( 4 % )
Embedded Multiplier 9-bit elements 0 / 532 ( 0 % )
Embedded Multiplier 9-bit elements 0 / 532 ( 0 % )
Total logic elements 6,238 / 114,480 ( 5 % )
Total combinational functions 5,527 / 114,480 ( 5 % )
Dedicated logic registers 2,916 / 114,480 ( 3 % )
Total registers 2916
Total pins 436 / 529 ( 82 % )
Total virtual pins 0
Total memory bits 150,192 / 3,981,312 ( 4 % )
Embedded Multiplier 9-bit elements 0 / 532 ( 0 % )
Total PLLs 1 / 4 ( 25 % )
*/
*/
`define
USE1DIV
_
`define
USE1DIV
`ifdef
USE1DIV
`ifdef
USE1DIV
wire
div_unsign_op
=
func3
[
0
];
wire
div_unsign_op
=
func3
[
0
];
...
@@ -539,72 +546,101 @@ module riscv_core(
...
@@ -539,72 +546,101 @@ module riscv_core(
default:
begin
csr_v
=
0
;
csr_op
=
0
;
end
default:
begin
csr_v
=
0
;
csr_op
=
0
;
end
endcase
endcase
//DEFINE_FUNC(riscv_core_gen_csr, "nwReset, ucycle
, ucycleh, misa, mcycle, mcycleh, utime,utimeh, uinstret, uinstreth, minstret, minstreth
, instr, imm, regrddata") {
//DEFINE_FUNC(riscv_core_gen_csr, "nwReset, ucycle
64, misa, mcycle64, utime64, uinstret64, minstret64
, instr, imm, regrddata") {
always
@
(
posedge
wClk
)
always
@
(
posedge
wClk
)
if
(
nwReset
==
0
)
begin
if
(
nwReset
==
0
)
begin
misa
<=
32'b0100_0000_0001_0000_0001_0001_0000_0000
;
// RV32IM
misa
<=
32'b0100_0000_0001_0000_0001_0001_0000_0000
;
// RV32IM
ucycle
<=
0
;
ucycle64
<=
0
;
ucycleh
<=
0
;
mcycle64
<=
0
;
mcycle
<=
0
;
utime64
<=
0
;
mcycleh
<=
0
;
uinstret64
<=
0
;
utime
<=
0
;
minstret64
<=
0
;
utimeh
<=
0
;
`ifdef
CSROPCOUNTER
uinstret
<=
0
;
opcounter_addsub64
<=
0
;
uinstreth
<=
0
;
opcounter_alui64
<=
0
;
minstret
<=
0
;
opcounter_alu64
<=
0
;
minstreth
<=
0
;
opcounter_mul64
<=
0
;
end
opcounter_div64
<=
0
;
else
begin
opcounter_ld64
<=
0
;
if
(
ucycle
==
32'hffffffff
)
begin
opcounter_st64
<=
0
;
ucycleh
<=
ucycleh
+
1
;
opcounter_jmp64
<=
0
;
ucycle
<=
0
;
opcounter_j64
<=
0
;
end
`endif
else
begin
ucycle
<=
ucycle
+
1
;
end
if
(
utime
==
32'hffffffff
)
begin
utimeh
<=
utimeh
+
1
;
utime
<=
0
;
end
else
begin
utime
<=
utime
+
1
;
end
if
(
mcycle
==
32'hffffffff
)
begin
mcycleh
<=
mcycleh
+
1
;
mcycle
<=
0
;
end
end
else
begin
else
begin
mcycle
<=
mcycle
+
1
;
ucycle64
<=
ucycle64
+
1
;
end
utime64
<=
utime64
+
1
;
mcycle64
<=
mcycle64
+
1
;
if
(
state
==
`RISCVSTATE_EXEC_INST
)
begin
if
(
state
==
`RISCVSTATE_EXEC_INST
)
begin
if
(
uinstret
==
32'hffffffff
)
begin
uinstret64
<=
uinstret64
+
1
;
uinstreth
<=
uinstreth
+
1
;
minstret64
<=
minstret64
+
1
;
uinstret
<=
0
;
`ifdef
CSROPCOUNTER
end
case
(
opcode
)
else
begin
5'h0d
:
;
//riscv_core_exec_lui_inst(pobj, pc, instr); break;
uinstret
<=
uinstret
+
1
;
5'h05
:
;
//riscv_core_exec_auipc_inst(pobj, pc, instr); break;
5'h1b
:
//riscv_core_exec_jal_inst(pobj, pc, instr); break;
opcounter_jmp64
<=
opcounter_jmp64
+
1
;
5'h19
:
//riscv_core_exec_jalr_inst(pobj, pc, instr); break;
opcounter_jmp64
<=
opcounter_jmp64
+
1
;
5'h18
:
//riscv_core_exec_b_inst(pobj, pc, instr); break;
opcounter_j64
<=
opcounter_j64
+
1
;
5'h00
:
//riscv_core_exec_ld_inst(pobj, pc, instr); break;
opcounter_ld64
<=
opcounter_ld64
+
1
;
5'h08
:
//riscv_core_exec_st_inst(pobj, pc, instr); break;
opcounter_st64
<=
opcounter_st64
+
1
;
5'h04
:
//riscv_core_exec_alui_inst(pobj, pc, instr); break;
opcounter_alui64
<=
opcounter_alui64
+
1
;
5'h0c
:
begin
//riscv_core_exec_alu_inst(pobj, pc, instr); break;
opcounter_alu64
<=
opcounter_alu64
+
1
;
if
(
instr
[
25
])
begin
/* MUL/DIV */
if
(
func3
[
2
])
begin
opcounter_div64
<=
opcounter_div64
+
1
;
end
else
begin
opcounter_mul64
<=
opcounter_mul64
+
1
;
end
end
if
(
minstret
==
32'hffffffff
)
begin
end
else
begin
minstreth
<=
minstreth
+
1
;
if
(
func3
==
0
)
minstret
<=
0
;
opcounter_addsub64
<=
opcounter_addsub64
+
1
;
end
end
else
begin
minstret
<=
minstret
+
1
;
end
end
5'h03
:
;
//riscv_core_exec_fence_inst(pobj, pc, instr); break;
5'h1c
:
;
//riscv_core_exec_sys_inst(pobj, pc, instr); break;
endcase
`endif
if
(
opcode
==
5'h1c
)
begin
/* CSR */
if
(
opcode
==
5'h1c
)
begin
/* CSR */
if
(
csr_op
)
begin
if
(
csr_op
)
begin
case
(
instr
[
31
:
20
])
case
(
instr
[
31
:
20
])
12'h301
:
misa
<=
csr_v
;
12'h301
:
misa
<=
csr_v
;
12'hc00
:
ucycle
<=
csr_v
;
12'hc00
:
ucycle64
[
31
:
0
]
<=
csr_v
;
12'hc01
:
utime
<=
csr_v
;
12'hc80
:
ucycle64
[
63
:
32
]
<=
csr_v
;
12'hc02
:
uinstret
<=
csr_v
;
12'hc01
:
utime64
[
31
:
0
]
<=
csr_v
;
12'hc80
:
ucycleh
<=
csr_v
;
12'hc81
:
utime64
[
63
:
32
]
<=
csr_v
;
12'hc81
:
utimeh
<=
csr_v
;
12'hc02
:
uinstret64
[
31
:
0
]
<=
csr_v
;
12'hc82
:
uinstreth
<=
csr_v
;
12'hc82
:
uinstret64
[
63
:
32
]
<=
csr_v
;
12'hb00
:
mcycle
<=
csr_v
;
12'hb00
:
mcycle64
[
31
:
0
]
<=
csr_v
;
12'hb02
:
minstret
<=
csr_v
;
12'hb80
:
mcycle64
[
63
:
32
]
<=
csr_v
;
12'hb80
:
mcycleh
<=
csr_v
;
12'hb02
:
minstret64
[
31
:
0
]
<=
csr_v
;
12'hb82
:
minstreth
<=
csr_v
;
12'hb82
:
minstret64
[
63
:
32
]
<=
csr_v
;
`ifdef
CSROPCOUNTER
12'hc20
:
opcounter_addsub64
[
31
:
0
]
<=
csr_v
;
12'hca0
:
opcounter_addsub64
[
63
:
32
]
<=
csr_v
;
12'hc21
:
opcounter_mul64
[
31
:
0
]
<=
csr_v
;
12'hca1
:
opcounter_mul64
[
63
:
32
]
<=
csr_v
;
12'hc22
:
opcounter_div64
[
31
:
0
]
<=
csr_v
;
12'hca2
:
opcounter_div64
[
63
:
32
]
<=
csr_v
;
12'hc23
:
opcounter_ld64
[
31
:
0
]
<=
csr_v
;
12'hca3
:
opcounter_ld64
[
63
:
32
]
<=
csr_v
;
12'hc24
:
opcounter_st64
[
31
:
0
]
<=
csr_v
;
12'hca4
:
opcounter_st64
[
63
:
32
]
<=
csr_v
;
12'hc25
:
opcounter_jmp64
[
31
:
0
]
<=
csr_v
;
12'hca5
:
opcounter_jmp64
[
63
:
32
]
<=
csr_v
;
12'hc26
:
opcounter_j64
[
31
:
0
]
<=
csr_v
;
12'hca6
:
opcounter_j64
[
63
:
32
]
<=
csr_v
;
12'hc27
:
opcounter_alui64
[
31
:
0
]
<=
csr_v
;
12'hca7
:
opcounter_alui64
[
63
:
32
]
<=
csr_v
;
12'hc28
:
opcounter_alu64
[
31
:
0
]
<=
csr_v
;
12'hca8
:
opcounter_alu64
[
63
:
32
]
<=
csr_v
;
`endif
endcase
endcase
end
end
end
end
...
@@ -684,7 +720,6 @@ module riscv_core(
...
@@ -684,7 +720,6 @@ module riscv_core(
//DEFINE_FUNC(riscv_core_gen_dstreg, "state, instr, ldaddr, readreg, bReadData, pc, rs1, regrddata, imm") {
//DEFINE_FUNC(riscv_core_gen_dstreg, "state, instr, ldaddr, readreg, bReadData, pc, rs1, regrddata, imm") {
always
@
(
state
or
readreg
or
instr
or
func3
or
ldaddr
or
bReadData
or
rd
or
rs1
or
rs2
or
rs1_s
or
rs2_s
or
lastv
or
divclk
always
@
(
state
or
readreg
or
instr
or
func3
or
ldaddr
or
bReadData
or
rd
or
rs1
or
rs2
or
rs1_s
or
rs2_s
or
lastv
or
divclk
or
divs_result
or
div_result
or
mods_result
or
mod_result
or
muls_result
or
mulsu_result
or
mul_result
or
divs_result
or
div_result
or
mods_result
or
mod_result
or
muls_result
or
mulsu_result
or
mul_result
or
sub_result
or
add_result
or
opcode
or
imm
or
pc
)
begin
or
opcode
or
imm
or
pc
)
begin
dstreg
=
0
;
dstreg
=
0
;
dstvalue
=
0
;
dstvalue
=
0
;
...
@@ -896,11 +931,9 @@ module riscv_core(
...
@@ -896,11 +931,9 @@ module riscv_core(
case
(
func3
)
case
(
func3
)
0
:
begin
0
:
begin
if
(
instr
[
30
])
if
(
instr
[
30
])
dstvalue
=
sub_result
;
dstvalue
=
rs1
-
rs2
;
//rs1 - rs2;//sub_result;
else
else
dstvalue
=
add_result
;
dstvalue
=
rs1
+
rs2
;
//rs1 + rs2;//add_result;
end
end
1
:
begin
//sll
1
:
begin
//sll
dstvalue
=
rs1
<<
rs2
[
4
:
0
];
dstvalue
=
rs1
<<
rs2
[
4
:
0
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录