The University of Queensland Homepage
School of ITEE ITEE Main Website

 LED PING-PONG GAME - Design Challenge

Goal:

In this challenge, design a Ping-Pong Machine for two human players using Shift Registers and Sequential State Machine Controllers.

Description:

The circuit designed and loaded on to the BASYS board will function as a simple Ping-Pong game. The Game uses the 8 LEDs to represent a moving Ping-Pong ball and choice of two push buttons as serving as paddles. At any given time, one of the 8 LEDs is lit and moved to represent the Ping-Pong ball moving in a specific direction. The players use the push button to bounce the ball back whenever the ball reaches the respective ends. The rules of the game and design specifications are listed in the following sections.

Specification:

CLOCK

50MHz on board oscillator

INPUT

RESET

Asynchronous Master Reset

INPUT

LPB

Left paddle from a Push Button

INPUT

RPB

Right paddle from a Push Button

INPUT

LED<7> - LED<0>

Eight LED outputs that represent the ball

(7 - left most; 0 - right most)

OUTPUT

R_SCORE[6:0]

Right player's Score on 7-SEG display

OUTPUT

L_SCORE[6:0]

Left player's Score on 7-SEG display

OUTPUT

 

Rules:

  1. The rules for left and right players are symmetric except for the first serve. The left player always serves first.

  2. The ball position is moved by the clock source, that causes LED output to serially shift every one-sixth of a second.

  3. After the first serve, the circuit knows who gets to serve the next time (L - Left Player; R - Right Player) according to the rules.

  4. When it is L's turn to serve, L hits the push button LPB, the ball (LED - ON) starts to move from left most (LED<7>) to the right most position (LED<0>).

  5. When the ball is in the right most position (LED<0>) and R returns the volley using the right paddle when LED<0> is turned "ON", the ball starts to move from right to left.

  6. The direction of shift reverses whenever the correct push button is pressed at the correct time.

  7. After a player serves or returns a volley, the corresponding push button is ignored or disabled.

  8. If a player hits the paddle either "too early" (when the ball is not in LED<7> or LED<0> correspondingly) or "too late" (when the ball falls off the end, thereby a miss), then the opponent scores a point.

  9. A player who scores a point, gets to serve the next time.

  10. The score is maintained using two 4-bit counters.

  11. A player who scores 9 points first wins the game. The counter then resets to start all over again.

Keeping Scores:

  1. The scores are displayed using the 7-SEG displays.

  2. The game finishes once one of the players reaches 9 points. The first player to reach 9 has won the game.

  3. The game should stop until the user presses the Master RESET button for another game.

Laboratory work:

 

It takes time to get this design completed and working to the specification. So make quick progression through the design by reusing some of the work during previous class activities.

  1. The push buttons need to be de-bounced. The de-bouncing circuit from the previous class activity can be re-used here. However, one should be aware of timing issues related to propagation delay in the de-bouncing circuit.

  2. The Universal Shift register can be "modified" appropriately to suit your requirements and reused here for shifting the LEDs left and right.

  3. The ball should move at approximately 6 Hz. So there is a requirement for a clock divider, which can also be picked and re-used from previous activities.

  4. A BCD-to-7SEG module required here can also obtained from appropriately modified from previous Activity.

  5. The challenging part is the core state machine controller that controls the game. Use the time efficiently as you work in a team to discuss the strategy for the game controller. Derive a FSM diagram or ASM chart for your strategy.

  6. The Entity for the top-level VHDL is given below (only this entity should be used by all):
    entity
    lamp_pingpong_top is
    port(
            LPB          : in STD_LOGIC;
            RPB          : in STD_LOGIC;
            RESET      : in STD_LOGIC;
            CLK          : in STD_LOGIC;
            L_SCORE : out STD_LOGIC_VECTOR(6 downto 0);
            R_SCORE : out STD_LOGIC_VECTOR(6 downto 0);
            BOARD     : out STD_LOGIC_VECTOR(7 downto 0)
    );
    end lamp_pingpong_top;

 

NOTE: For whatever reason, YOU MUST NOT GATE THE CLOCK. This means all the state machines in your design must be fully synchronous.