verilog HDLBits刷题[Finite State Machines]“Lemmings4”---Lemmings4 1、题目See also: Lemmings1, Lemmings2, and Lemmings3.Although Lemmings can walk, fall, and dig, Lemmings arent invulnerable. If a Lemming falls for too long then hits the ground, it can splatter. In particular, if a Lemming falls for more than 20 clock cycles then hits the ground, it will splatter and cease walking, falling, or digging (all 4 outputs become 0), forever (Or until the FSM gets reset). There is no upper limit on how far a Lemming can fall before hitting the ground. Lemmings only splatter when hitting the ground; they do not splatter in mid-air.Extend your finite state machine to model this behaviour.Falling for 20 cycles is survivable:2、代码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 ); localparam LEFT 1, RIGHT 2, FALL_L 3, FALL_R 4, DIG_L 5, DIG_R 6, SPLAT 7; reg [2:0] state; reg [2:0] next_state; reg [6:0] cnt; // watch out this! always (posedge clk , posedge areset)begin if(areset) state LEFT; else state next_state; end always (posedge clk or posedge areset)begin if(areset) cnt 7d0; else if(state FALL_L || state FALL_R) cnt cnt 1b1; else cnt 7d0; end 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 ? (cnt 5d20 ? SPLAT : LEFT) : FALL_L; FALL_R : next_state ground ? (cnt 5d20 ? SPLAT : RIGHT) : FALL_R; DIG_L : next_state ~ground ? FALL_L : DIG_L; DIG_R : next_state ~ground ? FALL_R : DIG_R; SPLAT : next_state SPLAT; endcase assign walk_left (state LEFT); assign walk_right (state RIGHT); assign aaah (state FALL_L) || (state FALL_R); assign digging (state DIG_L) || (state DIG_R); endmodule3、结果

相关新闻

最新新闻

初识Git:为什么AI时代的开发者需要版本控制

初识Git:为什么AI时代的开发者需要版本控制

面向 AI 开发者的 Git 实操教程,技术布道式写作,11篇文章从入门到精通 系列目录 序号文章核心主题图解01初识Git版本控制概念、Repo/Commit/Branch/Merge01 手动备份对比02Git基本操作init/add/commit/log/switch,论文案例02 基本工作流03Gi…

2026/7/30 0:39:56
今日头条成功的原因-----界面创新-----节省脑力成本

今日头条成功的原因-----界面创新-----节省脑力成本

在今日头条产生的时候,已经有很多新闻网站了,但是那些都是这个样子的:就是说:你要什么新闻,你自己去找,这里有很多个官网菜单,你要什么自己去挑选。然后今日头条出来了,是这个样子的…

2026/7/30 0:39:56
无畏契约mac版游玩教程 怎么在mac上玩无畏契约

无畏契约mac版游玩教程 怎么在mac上玩无畏契约

游戏官方没有落地成熟的无畏契约mac版,苹果设备用户想要参与对局,很难找到合适的方法。想要找寻稳定流畅的无畏契约mac版游玩渠道,推荐试试无界趣连2.0,依靠远程串流的形式,完美化解mac无法运行这款射击游戏的痛点。极…

2026/7/30 0:39:56
Kimi K3 与 Fable 竞技:当前大模型编码能力的 SoTA 深度解析

Kimi K3 与 Fable 竞技:当前大模型编码能力的 SoTA 深度解析

Kimi K3 与 Fable 竞技:当前大模型编码能力的 SoTA 深度解析 在当今的人工智能辅助开发领域,代码生成能力的竞争已进入白热化阶段。近期,技术社区的热门话题被一组新的基准测试数据点燃:Kimi K3 模型在多项编程任务评测中表现出与…

2026/7/30 0:39:56
单文件架构的极致美学:深入解析 Bento 的 HTML 幻灯片技术实现

单文件架构的极致美学:深入解析 Bento 的 HTML 幻灯片技术实现

单文件架构的极致美学:深入解析 Bento 的 HTML 幻灯片技术实现 在传统的 Web 开发认知中,构建一个包含编辑器、演示视图、数据存储和协作功能的幻灯片应用,通常意味着复杂的前后端分离架构、数据库依赖以及繁琐的部署流程。然而,近…

2026/7/30 0:39:56
XXMI Launcher:一站式游戏模组管理终极指南,轻松管理原神、星穹铁道等热门游戏

XXMI Launcher:一站式游戏模组管理终极指南,轻松管理原神、星穹铁道等热门游戏

XXMI Launcher:一站式游戏模组管理终极指南,轻松管理原神、星穹铁道等热门游戏 【免费下载链接】XXMI-Launcher Modding platform for GI, HSR, WW and ZZZ 项目地址: https://gitcode.com/gh_mirrors/xx/XXMI-Launcher 还在为管理不同游戏的模组…

2026/7/30 0:34:56

月新闻