Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
饶先宏
hdl4se
提交
836b7294
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 搜索 >>
提交
836b7294
编写于
6月 29, 2021
作者:
饶先宏
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
202106291109 全部verilog版本的俄罗斯方块终于跑通了
上级
f3b209ca
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
728 addition
and
671 deletion
+728
-671
examples/terris/src/main.c
examples/terris/src/main.c
+13
-5
examples/terris/src/terris_main_module.c
examples/terris/src/terris_main_module.c
+687
-637
examples/terris/verilog/terris_ctrl.v
examples/terris/verilog/terris_ctrl.v
+16
-15
examples/terris/verilog/terris_main_asm.v
examples/terris/verilog/terris_main_asm.v
+12
-14
未找到文件。
examples/terris/src/main.c
浏览文件 @
836b7294
...
...
@@ -49,7 +49,7 @@ unsigned long long clocks = 0;
static
int
running
=
1
;
#define VCDOUTPUT
1
#define VCDOUTPUT
0
int
StopRunning
()
{
...
...
@@ -73,10 +73,12 @@ int main(int argc, char* argv[])
{
int
i
;
int
width
;
int
resetwidth
;
int
count
,
unitcount
;
IHDL4SEUnit
**
sim_unit
;
IHDL4SEWaveOutput
**
vcdfile
;
srand
((
unsigned
int
)
time
(
NULL
));
resetwidth
=
10
+
rand
()
%
50
;
A_u_t_o_registor_terrisctrl
();
A_u_t_o_registor_terrisctrl1
();
A_u_t_o_registor_terris_flushtodisp
();
...
...
@@ -107,10 +109,16 @@ int main(int argc, char* argv[])
objectCall2
(
vcdfile
,
AddSignal
,
"/top/terrisctrl/ctrl/wireout_tick"
,
"out"
);
objectCall2
(
vcdfile
,
AddSignal
,
"/top/terrisctrl/ctrl/wireout_speed"
,
"out"
);
objectCall2
(
vcdfile
,
AddSignal
,
"/top/terrisctrl/ctrl/cur_key"
,
"out"
);
objectCall2
(
vcdfile
,
AddSignal
,
"/top/terrisctrl/ctrl/stateAfterCheckKey"
,
"out"
);
objectCall2
(
vcdfile
,
AddSignal
,
"/top/terrisctrl/ctrl/testidwhencheckkey"
,
"out"
);
objectCall2
(
vcdfile
,
AddSignal
,
"/top/terrisctrl/ctrl/cur_key"
,
"out"
);
objectCall2
(
vcdfile
,
AddSignal
,
"/top/terrisctrl/ctrl/outputx"
,
"out"
);
objectCall2
(
vcdfile
,
AddSignal
,
"/top/terrisctrl/ctrl/wireout_curposx"
,
"out"
);
objectCall2
(
vcdfile
,
AddSignal
,
"/top/terrisctrl/ctrl/outputy"
,
"out"
);
objectCall2
(
vcdfile
,
AddSignal
,
"/top/terrisctrl/ctrl/wireout_curposy"
,
"out"
);
objectCall2
(
vcdfile
,
AddSignal
,
"/top/terrisctrl/ctrl/wireout_testid"
,
"out"
);
objectCall2
(
vcdfile
,
AddSignal
,
"/top/terrisctrl/ctrl/bResult"
,
"out"
);
objectCall2
(
vcdfile
,
AddSignal
,
"/top/terrisctrl/ctrl/wireout_testx"
,
"out"
);
objectCall2
(
vcdfile
,
AddSignal
,
"/top/terrisctrl/ctrl/wireout_testy"
,
"out"
);
objectCall2
(
vcdfile
,
AddSignal
,
"/top/terrisctrl/ctrl/wireout_curposx"
,
"out"
);
objectCall2
(
vcdfile
,
AddSignal
,
"/top/terrisctrl/ctrl/wireout_curposy"
,
"out"
);
objectCall1
(
vcdfile
,
SetTopModule
,
topmodule
);
objectCall0
(
vcdfile
,
StartRecord
);
...
...
@@ -123,7 +131,7 @@ int main(int argc, char* argv[])
#endif
objectCall0
(
sim_unit
,
Setup
);
clocks
++
;
if
(
clocks
>
10
+
(
rand
()
%
50
)
)
if
(
clocks
==
resetwidth
)
objectCall1
(
sim
,
SetReset
,
1
);
}
while
(
running
);
#if VCDOUTPUT
...
...
examples/terris/src/terris_main_module.c
浏览文件 @
836b7294
此差异已折叠。
点击以展开。
examples/terris/verilog/terris_ctrl.v
浏览文件 @
836b7294
...
...
@@ -91,7 +91,7 @@ module turnright(input [63:0] inblock,
hdl4se_bind4
#(
16
,
16
,
16
,
16
)
bindline
(
line0
,
line1
,
line2
,
line3
,
outblock
);
endmodule
`define
MAXSPEED 32
'
d
20
00
`define
MAXSPEED 32
'
d
5
00
/* 俄罗斯方块控制器V1 */
(
*
...
...
@@ -159,13 +159,16 @@ module teris_ctrl
);
assign
stateAfterFlushToDisp
=
(
wireout_curblock
==
64'h0
)
?
`ST_GENBLOCK
:
(
wStateComplete
?
`ST_CHECKKEY
:
`ST_FLUSHTODISP
);
assign
stateAfterCheckBlockCanSetTo
=
wStateComplete
?
(
((
bResult
==
0
)
&&
(
wireout_testid
==
0
))
?
`ST_BLOCKWRITE
:
`ST_FLUSHTODISP
)
assign
stateAfterCheckBlockCanSetTo
=
wStateComplete
?
(
(
wireout_testid
==
0
)
?
(
bResult
?
`ST_FLUSHTODISP
:
`ST_BLOCKWRITE
)
:
(
(
wireout_testid
==
4
)
?
(
bResult
?
`ST_GENBLOCK
:
`ST_INIT
)
:
`ST_FLUSHTODISP
)
)
:
`ST_CHECKBLOCKCANSETTO
;
assign
stateAfterCheckLine
=
wStateComplete
?
(
(
bResult
<
`YCOUNT
)
?
`ST_COPYLINES
:
`ST_CHECKBLOCKCANSETTO
)
:
`ST_CHECKLINE
;
assign
stateAfterCheckKey
=
((
cur_key
==
0
)
&&
(
wireout_tick
<=
wireout_speed
))
?
`ST_CHECKKEY
:
`ST_CHECKBLOCKCANSETTO
;
assign
stateAfterCheckKey
=
((
cur_key
[
0
]
||
cur_key
[
1
]
||
cur_key
[
3
])
&&
(
wireout_score
==
0
))
?
`ST_INIT
:
(((
cur_key
==
0
)
&&
(
wireout_tick
<=
wireout_speed
))
?
`ST_CHECKKEY
:
`ST_CHECKBLOCKCANSETTO
);
/* 内部变量 */
/* 测试块 testx, testy, testid */
...
...
@@ -178,7 +181,7 @@ module teris_ctrl
testxwencheckkey
,
// 2: ST_CHECKKEY,
wireout_testx
,
// 3: ST_CHECKBLOCKCANSETTO,
wireout_testx
,
// 4: ST_BLOCKWRITE,
wireout_curposx
,
// 5: ST_CHECKLINE,
8'd8
,
// 5: ST_CHECKLINE,
wireout_testx
,
// 6: ST_COPYLINES
wireout_testx
,
// 7: ST_GENBLOCK
wirein_testx
...
...
@@ -196,7 +199,7 @@ module teris_ctrl
testywencheckkey
,
// 2: ST_CHECKKEY,
wireout_testy
,
// 3: ST_CHECKBLOCKCANSETTO,
wireout_testy
,
// 4: ST_BLOCKWRITE,
wireout_curposy
,
// 5: ST_CHECKLINE,
8'd0
,
// 5: ST_CHECKLINE,
wireout_testy
,
// 6: ST_COPYLINES
wireout_testy
,
// 7: ST_GENBLOCK
wirein_testy
...
...
@@ -211,7 +214,7 @@ module teris_ctrl
*/
wire
[
7
:
0
]
wirein_testid
,
wireout_testid
;
hdl4se_reg
#(
8
)
reg_testid
(
wClk
,
wirein_testid
,
wireout_testid
);
hdl4se_mux8
#(
8
)
mux_te
x
tid
(
hdl4se_mux8
#(
8
)
mux_te
s
tid
(
wireout_state
,
wireout_testid
,
// 0: ST_INIT
wireout_testid
,
// 1: ST_FLUSHTODISP,
...
...
@@ -257,8 +260,6 @@ module teris_ctrl
wire
[
31
:
0
]
scoreAfterCheckLine
,
scoreAfterCheckKey
;
wire
[
31
:
0
]
wirein_score
,
wireout_score
;
hdl4se_reg
#(
32
)
terris_score
(
wClk
,
wirein_score
,
wireout_score
);
assign
wirein_score
=
wStateComplete
?
nextscore
:
wireout_score
;
wire
[
31
:
0
]
nextscore
;
hdl4se_mux8
#(
32
)
mux_score
(
wireout_state
,
32'd200
,
// 0: ST_INIT
...
...
@@ -269,10 +270,10 @@ module teris_ctrl
scoreAfterCheckLine
,
// 5: ST_CHECKLINE,
wireout_score
,
// 6: ST_COPYLINES
wireout_score
,
// 7: ST_GENBLOCK
next
score
wirein_
score
);
assign
scoreAfterCheckKey
=
(
cur_key
&
8'b111
)
?
(
wireout_score
-
1
)
:
(
(
cur_key
&
8'b1000
)
?
(
wireout_score
+
2
)
:
wireout_score
);
assign
scoreAfterCheckKey
=
(
(
cur_key
[
3
]
||
cur_key
[
1
]
||
cur_key
[
0
])
)
?
(
wireout_score
-
1
)
:
(
cur_key
[
2
]
?
(
wireout_score
+
2
)
:
wireout_score
);
assign
scoreAfterCheckLine
=
(
wStateComplete
&&
(
bResult
>=
`YCOUNT
))
?
(
wireout_score
+
((
wireout_checklinecount
>
0
)
?
linescore
:
0
))
:
wireout_score
;
wire
[
31
:
0
]
linescore
;
hdl4se_mux4
#(
32
)
mux_linescore
(
...
...
@@ -335,7 +336,7 @@ module teris_ctrl
nextblockx
);
assign
curposxAfterCheckLine
=
wireout_curposx
;
assign
curposxAfterCheckLine
=
8'd8
;
wire
[
7
:
0
]
curposyAfterCheckKey
,
curposyAfterCheckLine
,
cursoryAfterCheckBlock
;
wire
[
7
:
0
]
wirein_curposy
,
wireout_curposy
;
...
...
@@ -355,7 +356,7 @@ module teris_ctrl
nextblocky
);
assign
curposyAfterCheckKey
=
wireout_curposy
;
assign
curposyAfterCheckLine
=
wireout_curposy
;
assign
curposyAfterCheckLine
=
8'd0
;
assign
cursoryAfterCheckBlock
=
(
bResult
&&
(
wireout_testid
==
0
))
?
(
wireout_curposy
+
1
)
:
wireout_curposy
;
...
...
@@ -381,7 +382,7 @@ module teris_ctrl
assign
curblockWhenFlushToDisp
=
(
wireout_curblock
==
64'b0
)
?
wireout_nextblock
:
wireout_curblock
;
assign
curblockAfterCheckBlock
=
(
wStateComplete
&&
bResult
&&
(
wireout_testid
==
3
))
?
curblockturnleft
:
wireout_curblock
;
assign
curblockAfterCheckLine
=
wireout_curblock
;
assign
curblockAfterCheckLine
=
(
wStateComplete
&&
(
bResult
>=
`YCOUNT
))
?
wireout_nextblock
:
wireout_curblock
;
/* 下一块形状: INIT和CHECKLINE会修改,其他状态保持 */
wire
[
63
:
0
]
wirein_nextblock
,
wireout_nextblock
;
...
...
examples/terris/verilog/terris_main_asm.v
浏览文件 @
836b7294
...
...
@@ -573,7 +573,6 @@ module teris_ctrl
wire
[
31
:
0
]
scoreAfterCheckKey
;
wire
[
31
:
0
]
wirein_score
;
wire
[
31
:
0
]
wireout_score
;
wire
[
31
:
0
]
nextscore
;
wire
[
31
:
0
]
linescore
;
wire
[
31
:
0
]
levelAfterCheckLine
;
wire
[
31
:
0
]
wirein_level
;
...
...
@@ -609,33 +608,32 @@ module teris_ctrl
wire
[
31
:
0
]
cur_key
;
assign
bState
=
wireout_state
;
assign
bScore
=
wireout_score
;
assign
bSpeed
=
(
32'h
7d0
-
wireout_speed
);
assign
bSpeed
=
(
32'h
1f4
-
wireout_speed
);
assign
bLevel
=
wireout_level
;
assign
bNextBlock
=
wireout_nextblock
;
assign
bCurBlock
=
((
cur_key
[
3
]
)
?
(
curblockturnleft
)
:
(
wireout_curblock
));
assign
wirein_state
=
((
nwReset
)
?
(
nextstate
)
:
(
0
));
assign
stateAfterFlushToDisp
=
(((
wireout_curblock
==
64'h0
))
?
(
7
)
:
(((
wStateComplete
)
?
(
2
)
:
(
1
))));
assign
stateAfterCheckBlockCanSetTo
=
((
wStateComplete
)
?
((((
(
bResult
==
0
)
&&
(
wireout_testid
==
0
)))
?
(
4
)
:
(
1
)))
:
(
3
));
assign
stateAfterCheckBlockCanSetTo
=
((
wStateComplete
)
?
((((
wireout_testid
==
0
))
?
(((
bResult
)
?
(
1
)
:
(
4
)))
:
((((
wireout_testid
==
4
))
?
(((
bResult
)
?
(
7
)
:
(
0
)))
:
(
1
))
)))
:
(
3
));
assign
stateAfterCheckLine
=
((
wStateComplete
)
?
((((
bResult
<
24
))
?
(
6
)
:
(
3
)))
:
(
5
));
assign
stateAfterCheckKey
=
((((
cur_key
==
0
)
&&
(
wireout_tick
<=
wireout_speed
)))
?
(
2
)
:
(
3
));
assign
stateAfterCheckKey
=
((((
cur_key
[
0
]
||
(
cur_key
[
1
]
||
cur_key
[
3
]
))
&&
(
wireout_score
==
0
)))
?
(
0
)
:
(((((
cur_key
==
0
)
&&
(
wireout_tick
<=
wireout_speed
)))
?
(
2
)
:
(
3
))
));
assign
wirein_startline
=
(((
wStateComplete
&&
(
bState
==
5
)))
?
(
bResult
)
:
(
wireout_startline
));
assign
wirein_testparam
=
(((
bState
==
2
))
?
(
cur_key
)
:
(
wireout_testparam
));
assign
wirein_score
=
((
wStateComplete
)
?
(
nextscore
)
:
(
wireout_score
));
assign
scoreAfterCheckKey
=
(((
cur_key
&
8'b111
))
?
((
wireout_score
-
1
))
:
((((
cur_key
&
8'b1000
))
?
((
wireout_score
+
2
))
:
(
wireout_score
))));
assign
scoreAfterCheckKey
=
(((
cur_key
[
3
]
||
(
cur_key
[
1
]
||
cur_key
[
0
]
)))
?
((
wireout_score
-
1
))
:
(((
cur_key
[
2
]
)
?
((
wireout_score
+
2
))
:
(
wireout_score
))));
assign
scoreAfterCheckLine
=
(((
wStateComplete
&&
(
bResult
>=
24
)))
?
((
wireout_score
+
(((
wireout_checklinecount
>
0
))
?
(
linescore
)
:
(
0
))))
:
(
wireout_score
));
assign
wirein_level
=
((
wStateComplete
)
?
(
nextlevel
)
:
(
wireout_level
));
assign
levelAfterCheckLine
=
(((
wStateComplete
&&
(
bResult
>=
24
)))
?
((
wireout_level
+
wireout_checklinecount
))
:
(
wireout_level
));
assign
wirein_speed
=
(((
32'h
7d0
>
scorediv4
))
?
((
32'd20
00
-
scorediv4
))
:
(
1
));
assign
wirein_speed
=
(((
32'h
1f4
>
scorediv4
))
?
((
32'd5
00
-
scorediv4
))
:
(
1
));
assign
wirein_tick
=
((((
nwReset
==
0
)
||
((
cur_key
!=
0
)
||
(
wireout_state
!=
2
))))
?
(
0
)
:
((
wireout_tick
+
1
)));
assign
wirein_curposx
=
((
wStateComplete
)
?
(
nextblockx
)
:
(
wireout_curposx
));
assign
curposxAfterCheckLine
=
wireout_curposx
;
assign
curposxAfterCheckLine
=
8
;
assign
wirein_curposy
=
((
wStateComplete
)
?
(
nextblocky
)
:
(
wireout_curposy
));
assign
curposyAfterCheckKey
=
wireout_curposy
;
assign
curposyAfterCheckLine
=
wireout_curposy
;
assign
curposyAfterCheckLine
=
0
;
assign
cursoryAfterCheckBlock
=
(((
bResult
&&
(
wireout_testid
==
0
)))
?
((
wireout_curposy
+
1
))
:
(
wireout_curposy
));
assign
curblockWhenFlushToDisp
=
(((
wireout_curblock
==
64'b0
))
?
(
wireout_nextblock
)
:
(
wireout_curblock
));
assign
curblockAfterCheckBlock
=
(((
wStateComplete
&&
(
bResult
&&
(
wireout_testid
==
3
))))
?
(
curblockturnleft
)
:
(
wireout_curblock
));
assign
curblockAfterCheckLine
=
wireout_curblock
;
assign
curblockAfterCheckLine
=
(((
wStateComplete
&&
(
bResult
>=
24
)))
?
(
wireout_nextblock
)
:
(
wireout_curblock
))
;
assign
wirein_nextblock
=
(((
wStateComplete
&&
(
wireout_state
==
7
)))
?
(
bNewNextBlock
)
:
(
wireout_nextblock
));
assign
wirein_key
=
bKeyData
;
assign
outputx
=
(((
wireout_state
==
3
))
?
((
wireout_testx
+
1
))
:
((((
wireout_state
==
6
))
?
(
wireout_startline
)
:
((
wireout_curposx
+
1
)))));
...
...
@@ -652,12 +650,12 @@ module teris_ctrl
,
stateAfterCheckLine
,
((
wStateComplete
)
?
(
5
)
:
(
6
)),
((
wStateComplete
)
?
(
1
)
:
(
7
)),
nextstate
);
hdl4se_reg
#(
8
)
reg_testx
(
wClk
,
wirein_testx
,
wireout_testx
);
hdl4se_mux8
#(
8
)
mux_testx
(
wireout_state
,
wireout_testx
,
wireout_testx
,
testxwencheckkey
,
wireout_testx
,
wireout_testx
,
wireout_curposx
,
wireout_testx
,
wireout_testx
,
wirein_testx
);
,
8
,
wireout_testx
,
wireout_testx
,
wirein_testx
);
hdl4se_reg
#(
8
)
reg_testy
(
wClk
,
wirein_testy
,
wireout_testy
);
hdl4se_mux8
#(
8
)
mux_testy
(
wireout_state
,
wireout_testy
,
wireout_testy
,
testywencheckkey
,
wireout_testy
,
wireout_testy
,
wireout_curposy
,
wireout_testy
,
wireout_testy
,
wirein_testy
);
,
0
,
wireout_testy
,
wireout_testy
,
wirein_testy
);
hdl4se_reg
#(
8
)
reg_testid
(
wClk
,
wirein_testid
,
wireout_testid
);
hdl4se_mux8
#(
8
)
mux_te
x
tid
(
wireout_state
,
wireout_testid
,
wireout_testid
,
testidwhencheckkey
,
wireout_testid
,
wireout_testid
hdl4se_mux8
#(
8
)
mux_te
s
tid
(
wireout_state
,
wireout_testid
,
wireout_testid
,
testidwhencheckkey
,
wireout_testid
,
wireout_testid
,
4
,
wireout_testid
,
wireout_testid
,
wirein_testid
);
hdl4se_reg
#(
8
)
reg_startline
(
wClk
,
wirein_startline
,
wireout_startline
);
hdl4se_reg
#(
32
)
reg_checklinecount
(
wClk
,
wirein_checklinecount
,
wireout_checklinecount
);
...
...
@@ -666,7 +664,7 @@ module teris_ctrl
hdl4se_reg
#(
8
)
reg_testparam
(
wClk
,
wirein_testparam
,
wireout_testparam
);
hdl4se_reg
#(
32
)
terris_score
(
wClk
,
wirein_score
,
wireout_score
);
hdl4se_mux8
#(
32
)
mux_score
(
wireout_state
,
32'hc8
,
wireout_score
,
scoreAfterCheckKey
,
wireout_score
,
wireout_score
,
scoreAfterCheckLine
,
wireout_score
,
wireout_score
,
next
score
);
,
scoreAfterCheckLine
,
wireout_score
,
wireout_score
,
wirein_
score
);
hdl4se_mux4
#(
32
)
mux_linescore
(
(
wireout_checklinecount
-
1
),
32'ha
,
32'h28
,
32'ha0
,
32'h280
,
linescore
);
hdl4se_reg
#(
32
)
terris_level
(
wClk
,
wirein_level
,
wireout_level
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录