尧图网站建设 尧图网络
  • 首页
  • 关于我们
  • 服务项目
  • 案例展示
  • 建站流程
  • 资讯中心
  • 联系我们
首页/资讯中心/详情

verilog HDLBits刷题[Finite State Machines]“Lemmings2”---Lemmings2

verilog HDLBits刷题[Finite State Machines]“Lemmings2”---Lemmings2
📅 发布时间:2026/7/30 3:58:40

1、题目

See also: Lemmings1.

In addition to walking left and right, Lemmings will fall (and presumably go "aaah!") if the ground disappears underneath them.

In addition to walking left and right and changing direction when bumped, when ground=0, the Lemming will fall and say "aaah!". When the ground reappears (ground=1), the Lemming will resume walking in the same direction as before the fall. Being bumped while falling does not affect the walking direction, and being bumped in the same cycle as ground disappears (but not yet falling), or when the ground reappears while still falling, also does not affect the walking direction.

Build a finite state machine that models this behaviour.

See also: Lemmings3 and Lemmings4.

2、分析

旅鼠游戏2:旅鼠可以左右行走,如果地面消失于脚下,它们会摔跤并发出“啊啊啊”的声音,;如果地面重新出现,它们就以之前的方向继续前进。注意掉落前的状态为左还是左,如此看来,可知有四种情况:向左,向右,掉落前向左,掉落前向右。

3、代码

module top_module( input clk, input areset, // Freshly brainwashed Lemmings walk left. input bump_left, input bump_right, input ground, output walk_left, output walk_right, output reg aaah ); parameter LEFT=2'b00,RIGHT=2'b01,fall_left=2'b10,fall_right=2'b11; reg [1:0]state,next_state; always@(*)begin next_state = state; case(state) LEFT:begin if(!ground) next_state=fall_left; else begin if(bump_left) next_state=RIGHT; else next_state=LEFT; end end RIGHT:begin if(!ground) next_state=fall_right; else begin if(bump_right) next_state=LEFT; else next_state=RIGHT; end end fall_left:begin if(ground) next_state=LEFT; else next_state=fall_left; end fall_right:begin if(ground) next_state=RIGHT; else next_state=fall_right; end default:next_state=LEFT; endcase end always@(posedge clk,posedge areset)begin if(areset) state<=LEFT; else state<=next_state; end always@(posedge clk,posedge areset)begin if(areset) aaah<=1'b0; else if(ground==1'b0) aaah<=1'b1; else aaah<=1'b0; end assign walk_left=(state==LEFT); assign walk_right=(state==RIGHT); endmodule

4、结果

相关新闻

  • 2026年7月广西省移动1000M融合宽带怎么选不踩坑_一篇说透 - 找卡家园
  • 2026内江门窗投诉最少推荐榜:良率、安装、售后决定口碑 - 家居装修资讯
  • 4.1RAG知识库基础

最新新闻

  • 桌面待办事项工具支持置顶提醒喝水「智护日程・健康饮水管家」
  • 嵌入式Linux忘记root密码的三种破解路径与实战操作
  • U-Boot编译全解析:从.config生成到镜像构建的底层原理
  • 2026 年现阶段,朝阳正规的稻草毯定做厂家哪家强,这玩意儿能让零下20度的棚里,作物比暖房长得还旺? - 企业推荐管【认证】
  • 医院病房订餐系统架构设计与一床一码技术实现详解
  • 2026年7月西安工业用油/西安抗磨液压油公司靠谱推荐_陕西金好易石化有限公司 - 品牌宣传支持者

日新闻

  • 终极TeamSpeak3音乐机器人搭建指南:5分钟实现语音聊天室音频播放
  • 广州海珠区内搬家攻略,平价靠谱搬家服务商推荐,专业打包搬运省心避坑全流程指南 - 厚道搬家
  • 大语言模型入门指南:从零到精通掌握AI核心技术的5大步骤

周新闻

  • 大连理工大学与东京大学联手打造的“主动型AI助手“
  • 170.2026年国家级科研瓶颈:超精密单点金刚石切削(SPDT)光学表面生成
  • SongBloom:革命性歌曲生成框架深度解析——如何通过交织自回归与扩散模型创作完整音乐

月新闻

  • 2026年6月公司网站搭建最新热门渠道测评:四大低成本/零代码平台对比+避坑
  • 【Linux】Linux arm 编译QT程序,出现expected “}“报错
  • 【MATLAB例程】四基站二维AOA定位与距离辅助增强对比仿真。基于角度观测和测距修正的固定目标平面定位精度分析

关于尧图

  • 公司简介
  • 团队介绍
  • 企业文化
  • 荣誉资质

服务项目

  • 定制开发
  • 电商建站
  • UI 设计
  • 运维服务

快速链接

  • 案例展示
  • 建站流程
  • 常见问题
  • 资讯中心

联系方式

  • 📍北京市朝阳区互联网产业园 A 座 10 层
  • 📞400-888-8888
  • ✉️contact@rkmt.cn
  • 🕐周一至周日 9:00-21:00

© 2024 北京尧图网络科技有限公司 版权所有 | 京 ICP 备 XXXXXXXX 号