際際滷

際際滷Share a Scribd company logo
Copyright2013-2014
Multiplayer Ping-Pong On VGA Display Using VHDL
Submitted by:
Amritangshu
Roll no.101306020
BE-3rd Year
Thapar University
Patiala
Under the guidance of :
Ms Vemu Sulochana
Project engineer
CDAC
Copyright2013-2014
Wednesday, September 14,
THAPAR UNIVERSITY, PATIALA 2
VHDL implementation of the classic Pong game was the
first major task of the project.
The game Pong is one of the first complete, standalone
digital arcade games to reach mainstream popularity.
Pong, released in 1972, is a simple tennis-like game that
pits two players against each other on an almost-empty
screen.
A small, square ball bounces back and forth between
paddles controlled by two players, who attempt to bounce
it back at their opponent.
If either player fails to hit the ball (it goes off the edge of
their screen), that player loses the round, and their
opponent gets a point
The main objective of the project is to understand the
concept of Hardware Software co-design in system
design. The hardware platform used for this project was
Xilinx Spartan3 board.
INTRODUCTION
Copyright2013-2014
VGA
 VGA is an analogue video standard
that is mostly used in personal computers. V
GA can also refer to a piece of display hardw
are developed by IBM (Video Graphics Array
) or a display mode, that uses 640 x 480 pixe
ls resolution.
VGA connector uses a total of 15 pins, but o
nly 5 signals are needed for operation:
HSYNC
horizontal synchronization signal.
VSYNC- vertical synchronization signal
 RED  red colour channel
GREEN  green colour channel
BLUE  blue colour channel
Wednesday, September 14,
THAPAR UNIVERSITY, PATIALA 3
Copyright2013-2014
Components of the program
Wednesday, September 14,
THAPAR UNIVERSITY, PATIALA 4
Main
Contains all the
components and their
definitions
Sync
module
Generates h sync and
v sync signals
Pixel
generation
module
Generates rgb signal
Copyright2013-2014
Sync module
This module will generate the horizontal sync and vertical sync
for VGA video. In addition, sync module also produce control
signals for the IMG GEN (image Generation) module
SYNC module has 3 inputs and 2 output signals. The following
shows the definition of these signals.
 Input Signals
 start: is used to activate/deactivate the module
 clk: system clock
 reset: is used to reset the module
 Output Signals
 H_S: Horizontal sync
 V_S: Vertical sync
 X_counter: output of a counter which placed in the sync module.
it counts from 0 to 639 (horizontal resolution of the VGA
 Y_counter: output of a counter which placed in the sync module.
It counts from 0 to 479(vertical resolution of the VGA video )
 Video_on: is used to enable/disable the video
Wednesday, September 14,
THAPAR UNIVERSITY, PATIALA 5
Copyright2013-2014
Horizontal synchronization
Wednesday, September 14,
THAPAR UNIVERSITY, PATIALA 6
 The hsync signal can be obtained by
a special mod-800 counter and a
decoding circuit.
 We intentionally start the counting
from the beginning of the display
region.
 This allows us to use the counter
output as the horizontal (x-axis)
coordinate. This output constitutes
the pixel-x signal.
 The hsync signal goes low when the
counters output is between 656
and 751.
Copyright2013-2014
Vertical synchronization
 The vsync signal can be obtained by a special
mod-525 counter and a decoding circuit.
Wednesday, September 14,
THAPAR UNIVERSITY, PATIALA 7
Copyright2013-2014
Pixel generation module
 The pixel generation circuit generates the 3-bit rgb signal for
the VGA port.
 The external control and data signals specify the content of
the screen, and the pixel-x and pixel-y signals from the vga-
sync circuit provide the current coordinates of the pixel
Wednesday, September 14,
THAPAR UNIVERSITY, PATIALA 8
Copyright2013-2014
Design of the Paddle
 Each paddle has a fixed X-coordinate on the screen, and the only thing
that will change is the Y-coordinate as the user moves the paddle up and
down.
 The paddle module will take two one-bit inputs: U, telling the paddle to
move up, and D, to move down.
 If the U input is 1, the paddle will move up by 4 (decrease Y by 4).
 If the D input is 1, the paddle will move down by 4 (increase Y by 4).
 If both are 1, the paddle should stay in position.
Wednesday, September 14,
THAPAR UNIVERSITY, PATIALA 9
Copyright2013-2014
Design of the ball
 The ball will bounce back and forth from one players side to the other.
 For the ball, we will track the current direction it is traveling in separate X
and Y-components, or its velocity.
 We will store the velocity using two flip-flops, one for X and the other for Y.
 One flip-flop will tell us whether the ball is moving in the positive-X direction
(1, right) or the negative-X direction (0, left), and the other will do the same
for Y (1 is down, 0 is up).
Wednesday, September 14,
THAPAR UNIVERSITY, PATIALA 10
Copyright2013-2014
Ball collisions
 When the ball collides with a paddle or the border of the
screen, the ball will bounce away from the object it collides
with. This will be done by reversing direction away from the
collision.
Wednesday, September 14,
THAPAR UNIVERSITY, PATIALA 11
Copyright2013-2014
Animation of the ball
 When an object changes its location gradually in each scan, it
creates the illusion of motion and becomes animated.
 To achieve this, we can use registers to store the boundaries
of an object and update its value in each scan.
 In the pong game, the paddle is controlled by two
pushbuttons and can move up and down, and the ball can
move and bounce in all directions.
Wednesday, September 14,
THAPAR UNIVERSITY, PATIALA 12
Copyright2013-2014
Implimentation
Wednesday, September 14,
THAPAR UNIVERSITY, PATIALA 13
Copyright2013-2014
Lab setup
Wednesday, September 14,
THAPAR UNIVERSITY, PATIALA 14
Copyright2013-2014
Wednesday, September 14,
THAPAR UNIVERSITY, PATIALA 15
Actual lab setup used
Copyright2013-2014
Additional projects
 Breakout game
The breakout game is a somewhat like the pong game. In this game, the
left wall is replaced by several layers of bricks. When the ball hits a
brick, the ball bounces back and the brick disappears.
Wednesday, September 14,
THAPAR UNIVERSITY, PATIALA 16
Copyright2013-2014
Background colour options
 Colour multiplexing circuit
 This provides 9 colour options in multiplayer ping pong to change
the background of the screen through switches on the spartan 3.
Wednesday, September 14,
THAPAR UNIVERSITY, PATIALA 17
Copyright2013-2014
FSM based vending machine
Wednesday, September 14,
THAPAR UNIVERSITY, PATIALA 18
Copyright2013-2014
 INTRODUCTION Vending
Machines are used to dispense
various products like Coffee,
Snacks, and Cold Drink etc. when
money is inserted into it.
 Vending Machines have been in
existence since 1880s. The first
commercial coin operated
machine was introduced in
London and England used for
selling post cards.
 The vending machines are more
accessible and practical than the
convention purchasing method
Copyright2013-2014
Wednesday, September 14,
THAPAR UNIVERSITY, PATIALA 20
Copyright2013-2014
Case1 : snacks selected
Copyright2013-2014
Case2 : cofee selected
Copyright2013-2014
Case3 : cold drinks selected
Copyright2013-2014
Case4 : candy selected
Copyright2013-2014
Case5 : purchase cancel

More Related Content

final stuff

  • 1. Copyright2013-2014 Multiplayer Ping-Pong On VGA Display Using VHDL Submitted by: Amritangshu Roll no.101306020 BE-3rd Year Thapar University Patiala Under the guidance of : Ms Vemu Sulochana Project engineer CDAC
  • 2. Copyright2013-2014 Wednesday, September 14, THAPAR UNIVERSITY, PATIALA 2 VHDL implementation of the classic Pong game was the first major task of the project. The game Pong is one of the first complete, standalone digital arcade games to reach mainstream popularity. Pong, released in 1972, is a simple tennis-like game that pits two players against each other on an almost-empty screen. A small, square ball bounces back and forth between paddles controlled by two players, who attempt to bounce it back at their opponent. If either player fails to hit the ball (it goes off the edge of their screen), that player loses the round, and their opponent gets a point The main objective of the project is to understand the concept of Hardware Software co-design in system design. The hardware platform used for this project was Xilinx Spartan3 board. INTRODUCTION
  • 3. Copyright2013-2014 VGA VGA is an analogue video standard that is mostly used in personal computers. V GA can also refer to a piece of display hardw are developed by IBM (Video Graphics Array ) or a display mode, that uses 640 x 480 pixe ls resolution. VGA connector uses a total of 15 pins, but o nly 5 signals are needed for operation: HSYNC horizontal synchronization signal. VSYNC- vertical synchronization signal RED red colour channel GREEN green colour channel BLUE blue colour channel Wednesday, September 14, THAPAR UNIVERSITY, PATIALA 3
  • 4. Copyright2013-2014 Components of the program Wednesday, September 14, THAPAR UNIVERSITY, PATIALA 4 Main Contains all the components and their definitions Sync module Generates h sync and v sync signals Pixel generation module Generates rgb signal
  • 5. Copyright2013-2014 Sync module This module will generate the horizontal sync and vertical sync for VGA video. In addition, sync module also produce control signals for the IMG GEN (image Generation) module SYNC module has 3 inputs and 2 output signals. The following shows the definition of these signals. Input Signals start: is used to activate/deactivate the module clk: system clock reset: is used to reset the module Output Signals H_S: Horizontal sync V_S: Vertical sync X_counter: output of a counter which placed in the sync module. it counts from 0 to 639 (horizontal resolution of the VGA Y_counter: output of a counter which placed in the sync module. It counts from 0 to 479(vertical resolution of the VGA video ) Video_on: is used to enable/disable the video Wednesday, September 14, THAPAR UNIVERSITY, PATIALA 5
  • 6. Copyright2013-2014 Horizontal synchronization Wednesday, September 14, THAPAR UNIVERSITY, PATIALA 6 The hsync signal can be obtained by a special mod-800 counter and a decoding circuit. We intentionally start the counting from the beginning of the display region. This allows us to use the counter output as the horizontal (x-axis) coordinate. This output constitutes the pixel-x signal. The hsync signal goes low when the counters output is between 656 and 751.
  • 7. Copyright2013-2014 Vertical synchronization The vsync signal can be obtained by a special mod-525 counter and a decoding circuit. Wednesday, September 14, THAPAR UNIVERSITY, PATIALA 7
  • 8. Copyright2013-2014 Pixel generation module The pixel generation circuit generates the 3-bit rgb signal for the VGA port. The external control and data signals specify the content of the screen, and the pixel-x and pixel-y signals from the vga- sync circuit provide the current coordinates of the pixel Wednesday, September 14, THAPAR UNIVERSITY, PATIALA 8
  • 9. Copyright2013-2014 Design of the Paddle Each paddle has a fixed X-coordinate on the screen, and the only thing that will change is the Y-coordinate as the user moves the paddle up and down. The paddle module will take two one-bit inputs: U, telling the paddle to move up, and D, to move down. If the U input is 1, the paddle will move up by 4 (decrease Y by 4). If the D input is 1, the paddle will move down by 4 (increase Y by 4). If both are 1, the paddle should stay in position. Wednesday, September 14, THAPAR UNIVERSITY, PATIALA 9
  • 10. Copyright2013-2014 Design of the ball The ball will bounce back and forth from one players side to the other. For the ball, we will track the current direction it is traveling in separate X and Y-components, or its velocity. We will store the velocity using two flip-flops, one for X and the other for Y. One flip-flop will tell us whether the ball is moving in the positive-X direction (1, right) or the negative-X direction (0, left), and the other will do the same for Y (1 is down, 0 is up). Wednesday, September 14, THAPAR UNIVERSITY, PATIALA 10
  • 11. Copyright2013-2014 Ball collisions When the ball collides with a paddle or the border of the screen, the ball will bounce away from the object it collides with. This will be done by reversing direction away from the collision. Wednesday, September 14, THAPAR UNIVERSITY, PATIALA 11
  • 12. Copyright2013-2014 Animation of the ball When an object changes its location gradually in each scan, it creates the illusion of motion and becomes animated. To achieve this, we can use registers to store the boundaries of an object and update its value in each scan. In the pong game, the paddle is controlled by two pushbuttons and can move up and down, and the ball can move and bounce in all directions. Wednesday, September 14, THAPAR UNIVERSITY, PATIALA 12
  • 14. Copyright2013-2014 Lab setup Wednesday, September 14, THAPAR UNIVERSITY, PATIALA 14
  • 15. Copyright2013-2014 Wednesday, September 14, THAPAR UNIVERSITY, PATIALA 15 Actual lab setup used
  • 16. Copyright2013-2014 Additional projects Breakout game The breakout game is a somewhat like the pong game. In this game, the left wall is replaced by several layers of bricks. When the ball hits a brick, the ball bounces back and the brick disappears. Wednesday, September 14, THAPAR UNIVERSITY, PATIALA 16
  • 17. Copyright2013-2014 Background colour options Colour multiplexing circuit This provides 9 colour options in multiplayer ping pong to change the background of the screen through switches on the spartan 3. Wednesday, September 14, THAPAR UNIVERSITY, PATIALA 17
  • 18. Copyright2013-2014 FSM based vending machine Wednesday, September 14, THAPAR UNIVERSITY, PATIALA 18
  • 19. Copyright2013-2014 INTRODUCTION Vending Machines are used to dispense various products like Coffee, Snacks, and Cold Drink etc. when money is inserted into it. Vending Machines have been in existence since 1880s. The first commercial coin operated machine was introduced in London and England used for selling post cards. The vending machines are more accessible and practical than the convention purchasing method