惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
SegmentFault 最新的问题
博客园 - 三生石上(FineUI控件)
Hugging Face - Blog
Hugging Face - Blog
博客园 - Franky
云风的 BLOG
云风的 BLOG
I
InfoQ
小众软件
小众软件
Last Week in AI
Last Week in AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
大猫的无限游戏
大猫的无限游戏
A
About on SuperTechFans
Stack Overflow Blog
Stack Overflow Blog
The Cloudflare Blog
雷峰网
雷峰网
P
Proofpoint News Feed
腾讯CDC
H
Help Net Security
V
Visual Studio Blog
美团技术团队
F
Fortinet All Blogs
MongoDB | Blog
MongoDB | Blog
阮一峰的网络日志
阮一峰的网络日志

博客园 - yf.x

超声波测距#倒车雷达#DE10-Lite 按键计数器#DE10-Lite 按键消抖#DE10-Lite 流水呼吸灯v2#DE10-Lite 流水呼吸灯-v1#DE10-Lite 呼吸灯-#DE10-Lite 流水灯#DE10-Lite#Verilog HDLBits_review 2015fsm 补码FSM-HDLbits 串行数据流输出其中的数据位-HDLbits 串行数据接收判断-HDLbits 输出PS2数据流-HDLbits PS2数据流检测状态机-HDLbits 独热码状态机-HDLbits 旅鼠4-HDLbits 旅鼠游戏2-HDLbits 旅鼠游戏--HDLbits 水库水位控制问题-HDLbits 康威生命游戏-hdlbits
旅鼠游戏3-HDLbits
yf.x · 2025-12-16 · via 博客园 - yf.x

在左右走,掉落的基础上再加上挖坑的动作,重点是判断优先级,掉落》挖坑》左右走。

注意:不能边掉边挖,只能在没掉,行走时,停下来挖。也就状态转换的逻辑要清晰。

image

module top_module(
input clk,
input areset, // Freshly brainwashed Lemmings walk left.
input bump_left,
input bump_right,
input ground,
input dig,
output walk_left,
output walk_right,
output aaah,
output digging );
parameter LEFT=0,RIGHT=1,FALL_L=2,FALL_R=3,DIG_L=4,DIG_R=5;
reg [2:0]state,next_state;

always @(posedge clk,posedge areset)
if(areset)
state<=LEFT;
else
state<=next_state;

always @(*)
case(state)
LEFT:next_state=!ground?FALL_L:(dig?DIG_L:(bump_left?RIGHT:LEFT));
RIGHT:next_state=!ground?FALL_R:(dig?DIG_R:(bump_right?LEFT:RIGHT));
FALL_L:next_state=!ground?FALL_L:LEFT;
FALL_R:next_state=!ground?FALL_R:RIGHT;
DIG_L:next_state=!ground?FALL_L:DIG_L;
DIG_R:next_state=!ground?FALL_R:DIG_R;
endcase

assign walk_left=(state==LEFT)?1'b1:1'b0;
assign walk_right=(state==RIGHT)?1'b1:1'b0;
assign aaah=(state==FALL_L || state==FALL_R)?1'b1:1'b0;
assign digging=(state==DIG_L || state==DIG_R)?1'b1:1'b0;
endmodule

image