Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
饶先宏
hdl4se
提交
259f8d21
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,体验更适合开发者的 AI 搜索 >>
提交
259f8d21
编写于
9月 15, 2021
作者:
饶先宏
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
202109150639
上级
c6d66fde
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
135 addition
and
107 deletion
+135
-107
examples/hdl4se_riscv/de2/de2_riscv_axi.sof
examples/hdl4se_riscv/de2/de2_riscv_axi.sof
+0
-0
examples/hdl4se_riscv/verilog/riscv_axi/riscv_core_v5.v
examples/hdl4se_riscv/verilog/riscv_axi/riscv_core_v5.v
+135
-107
未找到文件。
examples/hdl4se_riscv/de2/de2_riscv_axi.sof
浏览文件 @
259f8d21
无法预览此类型文件
examples/hdl4se_riscv/verilog/riscv_axi/riscv_core_v5.v
浏览文件 @
259f8d21
...
...
@@ -359,6 +359,18 @@ module riscv_core_v5(
if
(
opcode
==
5'h00
)
readreg
<=
rd
;
reg
[
31
:
0
]
lastWriteAddr
;
reg
[
31
:
0
]
lastWriteData
;
reg
[
3
:
0
]
lastWriteMask
;
reg
lastWrite
;
always
@
(
posedge
wClk
)
begin
lastWrite
<=
write
;
lastWriteAddr
<=
writeaddr
;
lastWriteData
<=
writedata
;
lastWriteMask
<=
writemask
;
end
wire
[
31
:
0
]
newwriteaddr
=
rs1
+
imm
;
//DEFINE_FUNC(riscv_core_gen_write, "nwReset, state, pc, instr, rs1, regrddata, imm") {
always
@
(
nwReset
or
state
or
opcode
or
newwriteaddr
or
rs2
or
func3
or
lastaddr
or
lastv
)
begin
...
...
@@ -366,117 +378,128 @@ module riscv_core_v5(
writeaddr
=
0
;
writemask
=
0
;
writedata
=
0
;
if
(
!
nwReset
)
begin
write
=
0
;
end
else
if
(
state
==
`RISCVSTATE_EXEC_INST
)
begin
write
=
0
;
if
(
opcode
==
5'h08
)
begin
writeaddr
=
{
newwriteaddr
[
31
:
2
],
2'b00
}
;
writemask
=
4'h0
;
writedata
=
rs2
;
write
=
1'b1
;
case
(
func3
)
0
:
/*sb*/
begin
case
(
newwriteaddr
[
1
:
0
])
0
:
begin
writemask
=
4'he
;
writedata
=
rs2
;
end
1
:
begin
writemask
=
4'hd
;
writedata
=
{
rs2
[
23
:
0
],
8'h0
}
;
end
2
:
begin
writemask
=
4'hb
;
writedata
=
{
rs2
[
15
:
0
],
16'h0
}
;
end
3
:
begin
writemask
=
4'h7
;
writedata
=
{
rs2
[
7
:
0
],
24'h0
}
;
end
endcase
end
1
:
/*sh*/
begin
case
(
newwriteaddr
[
1
:
0
])
0
:
begin
writemask
=
4'hc
;
writedata
=
rs2
;
end
1
:
begin
writemask
=
4'h9
;
writedata
=
{
rs2
[
23
:
0
],
8'h0
}
;
end
2
:
begin
writemask
=
4'h3
;
writedata
=
{
rs2
[
15
:
0
],
16'h0
}
;
end
3
:
begin
writemask
=
4'h7
;
writedata
=
{
rs2
[
7
:
0
],
24'h0
}
;
end
endcase
end
2
:
/*sw*/
begin
case
(
newwriteaddr
[
1
:
0
])
0
:
begin
writemask
=
4'h0
;
writedata
=
rs2
;
end
1
:
begin
writemask
=
4'h1
;
writedata
=
{
rs2
[
23
:
0
],
8'h0
}
;
if
(
state
==
`RISCVSTATE_EXEC_INST
)
begin
write
=
0
;
if
(
opcode
==
5'h08
)
begin
writeaddr
=
{
newwriteaddr
[
31
:
2
],
2'b00
}
;
writemask
=
4'h0
;
writedata
=
rs2
;
write
=
1'b1
;
case
(
func3
)
0
:
/*sb*/
begin
case
(
newwriteaddr
[
1
:
0
])
0
:
begin
writemask
=
4'he
;
writedata
=
rs2
;
end
1
:
begin
writemask
=
4'hd
;
writedata
=
{
rs2
[
23
:
0
],
8'h0
}
;
end
2
:
begin
writemask
=
4'hb
;
writedata
=
{
rs2
[
15
:
0
],
16'h0
}
;
end
3
:
begin
writemask
=
4'h7
;
writedata
=
{
rs2
[
7
:
0
],
24'h0
}
;
end
endcase
end
2
:
begin
writemask
=
4'h3
;
writedata
=
{
rs2
[
15
:
0
],
16'h0
}
;
1
:
/*sh*/
begin
case
(
newwriteaddr
[
1
:
0
])
0
:
begin
writemask
=
4'hc
;
writedata
=
rs2
;
end
1
:
begin
writemask
=
4'h9
;
writedata
=
{
rs2
[
23
:
0
],
8'h0
}
;
end
2
:
begin
writemask
=
4'h3
;
writedata
=
{
rs2
[
15
:
0
],
16'h0
}
;
end
3
:
begin
writemask
=
4'h7
;
writedata
=
{
rs2
[
7
:
0
],
24'h0
}
;
end
endcase
end
3
:
begin
writemask
=
4'h7
;
writedata
=
{
rs2
[
7
:
0
],
24'h0
}
;
2
:
/*sw*/
begin
case
(
newwriteaddr
[
1
:
0
])
0
:
begin
writemask
=
4'h0
;
writedata
=
rs2
;
end
1
:
begin
writemask
=
4'h1
;
writedata
=
{
rs2
[
23
:
0
],
8'h0
}
;
end
2
:
begin
writemask
=
4'h3
;
writedata
=
{
rs2
[
15
:
0
],
16'h0
}
;
end
3
:
begin
writemask
=
4'h7
;
writedata
=
{
rs2
[
7
:
0
],
24'h0
}
;
end
endcase
end
endcase
end
endcase
end
end
else
if
(
state
==
`RISCVSTATE_WAIT_ST
)
begin
write
=
0
;
writeaddr
=
{
lastaddr
[
31
:
2
],
2'b0
}
+
4
;
if
(
opcode
==
5'h08
)
begin
case
(
func3
)
1
:
/*sh*/
begin
case
(
lastaddr
[
1
:
0
])
3
:
begin
writemask
=
4'he
;
writedata
=
{
24'b0
,
lastv
[
31
:
24
]
}
;
write
=
1
;
end
else
if
(
state
==
`RISCVSTATE_WAIT_ST
)
begin
if
(
wWriteReady
)
begin
write
=
0
;
writeaddr
=
{
lastaddr
[
31
:
2
],
2'b0
}
+
4
;
if
(
opcode
==
5'h08
)
begin
case
(
func3
)
1
:
/*sh*/
begin
case
(
lastaddr
[
1
:
0
])
3
:
begin
writemask
=
4'he
;
writedata
=
{
24'b0
,
lastv
[
31
:
24
]
}
;
write
=
1
;
end
endcase
end
2
:
/*sw*/
begin
case
(
lastaddr
[
1
:
0
])
1
:
begin
writemask
=
4'he
;
writedata
=
{
24'b0
,
lastv
[
31
:
24
]
}
;
write
=
1
;
end
2
:
begin
writemask
=
4'hc
;
writedata
=
{
16'b0
,
lastv
[
31
:
16
]
}
;
write
=
1
;
end
3
:
begin
writemask
=
4'h8
;
writedata
=
{
8'b0
,
lastv
[
31
:
8
]
}
;
write
=
1
;
end
endcase
end
endcase
end
endcase
end
else
begin
write
=
lastWrite
;
writemask
=
lastWriteMask
;
writedata
=
lastWriteData
;
writeaddr
=
lastWriteAddr
;
end
2
:
/*sw*/
begin
case
(
lastaddr
[
1
:
0
])
1
:
begin
writemask
=
4'he
;
writedata
=
{
24'b0
,
lastv
[
31
:
24
]
}
;
write
=
1
;
end
2
:
begin
writemask
=
4'hc
;
writedata
=
{
16'b0
,
lastv
[
31
:
16
]
}
;
write
=
1
;
end
3
:
begin
writemask
=
4'h8
;
writedata
=
{
8'b0
,
lastv
[
31
:
8
]
}
;
write
=
1
;
end
endcase
end
else
if
(
state
==
`RISCVSTATE_WAIT_ST2
)
begin
if
(
~
wWriteReady
)
begin
write
=
lastWrite
;
writemask
=
lastWriteMask
;
writedata
=
lastWriteData
;
writeaddr
=
lastWriteAddr
;
end
endcase
end
else
begin
write
=
0
;
end
end
else
begin
write
=
0
;
end
end
//DEFINE_FUNC(riscv_core_gen_state, "state, instr, nwReset") {
...
...
@@ -524,7 +547,7 @@ module riscv_core_v5(
if
(
wReadReady
)
begin
state
<=
`RISCVSTATE_READ_REGS
;
end
`RISCVSTATE_WAIT_ST
:
begin
`RISCVSTATE_WAIT_ST
:
if
(
wWriteReady
)
begin
state
<=
`RISCVSTATE_READ_REGS
;
if
(
opcode
==
5'h08
)
begin
if
(
func3
==
1
&&
(
lastaddr
&
3
)
==
3
)
begin
/* sh */
...
...
@@ -535,7 +558,9 @@ module riscv_core_v5(
end
end
end
`RISCVSTATE_WAIT_ST2
:
state
<=
`RISCVSTATE_READ_REGS
;
`RISCVSTATE_WAIT_ST2
:
if
(
wWriteReady
)
state
<=
`RISCVSTATE_READ_REGS
;
`RISCVSTATE_WAIT_MUL
:
begin
`ifdef
USEMUL32
if
(
muldone
)
...
...
@@ -1084,7 +1109,10 @@ module riscv_core_v5(
wRead
=
lastRead
;
bReadAddr
=
lastReadAddr
;
end
`RISCVSTATE_WAIT_ST2
,
`RISCVSTATE_WAIT_ST2
:
if
(
wWriteReady
)
begin
wRead
=
1
;
bReadAddr
=
pc
;
end
`RISCVSTATE_READ_INST
:
begin
wRead
=
1
;
bReadAddr
=
pc
;
...
...
@@ -1125,8 +1153,8 @@ module riscv_core_v5(
bReadAddr
=
lastReadAddr
;
end
end
`RISCVSTATE_WAIT_ST
:
begin
if
(
opcode
==
5'h08
)
begin
`RISCVSTATE_WAIT_ST
:
if
(
wWriteReady
)
begin
if
(
opcode
==
5'h08
)
begin
if
(
func3
==
1
&&
lastaddr
[
1
:
0
]
==
3
)
begin
/* sh */
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录