基于状态机与LFSR的FPGA“打地鼠”游戏系统设计
Design of FPGA “Whack-a-Mole” Game System Based on State Machine and LFSR
摘要: 随着可编程逻辑器件在互动娱乐领域的应用日益深入,本文设计并实现了一款基于FPGA的趣味“打地鼠”游戏机系统。该系统以Altera Cyclone IV系列芯片为控制核心,采用Verilog HDL进行全硬件逻辑描述,旨在提供一种高实时性、高可靠性的游戏解决方案。系统的核心亮点在于其精巧的逻辑架构:首先,利用多项式反馈逻辑构造线性反馈移位寄存器(LFSR),高效地生成了控制LED地鼠位置的伪随机序列;其次,设计了一套包含空闲、激活和防连击等待三个主状态的有限状态机,它不仅实现了击中计分、超时扣血等基础游戏规则,还通过引入按键上升沿检测机制,成功解决了长按作弊与连击误判的技术难题。此外,系统内置了基于分数梯度的动态难度自适应算法,能够根据玩家表现自动调整地鼠的出现频率与停留时间,极大地增强了游戏的可玩性与挑战性。最终,在小梅哥AC101开发板上的综合板级验证表明:系统逻辑正确,状态流转无误;按键消抖稳定,随机机制有效;动态难度调节与音视频反馈现象均与设计预期完全一致。该设计方案为基于FPGA的反应测试类游戏平台开发提供了一种可靠且可扩展的实现范例。
Abstract: With the deepening application of programmable logic devices in the field of interactive entertainment, this paper designs and implements a fun “Whack-a-Mole” game console system based on FPGA. The system takes the Altera Cyclone IV series chip as the control core and uses Verilog HDL for full hardware logic description, aiming to provide a high-real-time and high-reliability game solution. The core highlight of the system lies in its ingenious logic architecture: Firstly, a Linear Feedback Shift Register (LFSR) is constructed using polynomial feedback logic, which efficiently generates a pseudo-random sequence to control the positions of the LED “moles”. Secondly, a Finite State Machine comprising three main states—Idle, Active, and Anti-double-click Wait—is designed. It not only realizes basic game rules such as hit scoring and timeout health deduction, but also successfully solves the technical challenges of long-press cheating and double-click misjudgment by introducing a button rising-edge detection mechanism. Furthermore, the system incorporates a dynamic difficulty self-adaptation algorithm based on score gradients, which automatically adjusts the appearance frequency and residence time of the moles according to the player’s performance, greatly enhancing the playability and challenge of the game. Finally, comprehensive board-level verification on the AC101 development board shows that: the system logic is correct, and the state transitions are error-free; the button debouncing is stable, and the random mechanism is effective; the dynamic difficulty adjustment and audio-visual feedback phenomena are completely consistent with the design expectations. This design scheme provides a reliable and scalable implementation paradigm for the development of reaction-testing game platforms based on FPGA.
文章引用:陈初侠, 沈静雨, 邵倩, 苏安邦, 徐雨豪. 基于状态机与LFSR的FPGA“打地鼠”游戏系统设计[J]. 电路与系统, 2026, 15(2): 58-68. https://doi.org/10.12677/ojcs.2026.15205

参考文献

[1] 刘红伟, 周宇, 李茂娇, 等. 一种基于FPGA资源的并行计算系统设计及实现[J]. 电子技术应用, 2025, 51(12): 8-13.
[2] 郝子坤, 卫建华, 罗鑫迪. 基于FPGA的运动目标检测与跟踪系统设计与实现[J]. 信息技术与信息化, 2025(11): 45-49.
[3] 周慧灵, 杨淑惠. 基于FPGA的物联智能化拔河游戏系统设计实现[J]. 科技创新与生产力, 2025, 46(7): 107-109+113.
[4] 杨楠, 肖军. 基于FPGA与MRFO算法的交通信号灯智能控制方法[J]. 现代电子技术, 2025, 48(20): 51-55.
[5] 彭雅岚, 肖顺文. 基于FPGA的LFSR结构伪随机数发生器的实现[J]. 数字技术与应用, 2018, 36(3): 91-92.
[6] 潘必韬, 聂小龙, 王祖强. 基于FPGA的LFSR异步加解密系统[J]. 电子技术应用, 2016, 42(6): 56-58.
[7] 丁宗杰, 门永平, 白正尧, 等. FPGA状态机综合可靠性探究[J]. 空间电子技术, 2021, 18(1): 23-27.
[8] 李营, 吕兆承, 施勇. 基于FPGA的俄罗斯方块游戏设计与实现[J]. 通化师范学院学报, 2022, 43(2): 118-122.
[9] 吴小红. 基于FPGA的多功能数字钟的设计与实现[J]. 电子测试, 2018(22): 19-20+22.
[10] 徐华伟, 林凡. 基于FPGA的推箱子游戏设计与实现[J]. 电子制作, 2019(19): 24-26.
[11] 金伟正, 夏可为, 李皓, 等. 基于无线游戏的FPGA创新实验系统[J]. 电气电子教学学报, 2019, 41(2): 85-88.
[12] 杨浩然, 李晓博, 金星宇, 等. 基于FPGA的电子密码锁系统设计[J]. 电子制作, 2024, 32(20): 102-104.