Design of a Whac-A-Mole Game Machine Based on FPGA with VHDL Code Simulation in ISE

Name: Design of a Whac-A-Mole Game Machine Based on FPGA with VHDL Code Simulation in ISE

Software: Quartus

Language: VHDL

Code Function:

The design of the Whac-A-Mole game machine uses 8 LED lights to represent 8 moles, a 3-digit 7-segment display to show the score, and 8 buttons to indicate the hitting points. A start button is used to begin the game, which can also be used to pause the game midway. Before the game starts, the score is reset to zero, and pressing the start button begins the game. At regular intervals (T1), a random LED light is turned on for a certain duration (T2). If the corresponding button is pressed within the T2 time frame, it indicates a successful hit on the mole, turning off the light and scoring points; otherwise, no points are awarded. The game consists of three rounds, and after each round (8 lights on), if more than 4 moles are successfully hit, the player advances to the next round, where T2 can be shortened for the second round, and each score can also be 2 points. The same logic applies to the third round, and finally, the game ends with the total score displayed. The random timing must be sufficiently unpredictable to prevent players from anticipating the lights, and the start button should include debouncing functionality.

The above design follows a TOP DOWN design process, completing system block diagram design, RTL design, synthesis, functional and timing simulation, and physical implementation.

1. Project Files

Design of a Whac-A-Mole Game Machine Based on FPGA with VHDL Code Simulation in ISE

2. Program Files

Design of a Whac-A-Mole Game Machine Based on FPGA with VHDL Code Simulation in ISE

3. Program Synthesis

Design of a Whac-A-Mole Game Machine Based on FPGA with VHDL Code Simulation in ISE

4. RTL Diagram

Design of a Whac-A-Mole Game Machine Based on FPGA with VHDL Code Simulation in ISE

5. Testbench

Design of a Whac-A-Mole Game Machine Based on FPGA with VHDL Code Simulation in ISE

6. Simulation Diagram

Overall Simulation Diagram

Design of a Whac-A-Mole Game Machine Based on FPGA with VHDL Code Simulation in ISE

Frequency Division Module

Design of a Whac-A-Mole Game Machine Based on FPGA with VHDL Code Simulation in ISE

Random Generation Module

Design of a Whac-A-Mole Game Machine Based on FPGA with VHDL Code Simulation in ISE

Button Module

Design of a Whac-A-Mole Game Machine Based on FPGA with VHDL Code Simulation in ISE

Control Module

Design of a Whac-A-Mole Game Machine Based on FPGA with VHDL Code Simulation in ISE

Display Module

Design of a Whac-A-Mole Game Machine Based on FPGA with VHDL Code Simulation in ISE

Partial Code Display:

LIBRARY ieee;
   USE ieee.std_logic_1164.all;
   USE ieee.std_logic_unsigned.all;
--Frequency Division Module
ENTITY fengping IS
   PORT (
      clk_50M  : IN STD_LOGIC;
      clk_div  : OUT STD_LOGIC--50M divided to 100KHz
   );
END fengping;
ARCHITECTURE behave OF fengping IS
   SIGNAL count   : integer:=0;
BEGIN
   PROCESS (clk_50M)
   BEGIN
      IF (clk_50M'EVENT AND clk_50M = '1') THEN
         IF (count >= 499) THEN--Count to 499, divide by 500
            count <= 0;
         ELSE
            count <= count + 1;
         END IF;
      END IF;
   END PROCESS;
   
   PROCESS (clk_50M)
   BEGIN
      IF (clk_50M'EVENT AND clk_50M = '1') THEN
         IF (count >= 250) THEN--Divide to clk_div
            clk_div <= '0';
         ELSE
            clk_div <= '1';
         END IF;
      END IF;
   END PROCESS;
   
END behave;

Design of a Whac-A-Mole Game Machine Based on FPGA with VHDL Code Simulation in ISE

Leave a Comment