Transcript demo
Implementation of Pong over VGA on the Nexys 4 FPGA EECS 443: Digital Systems Design Final Project Presentation Austin Cosner and David Easley 5/3/2016 Presentation Overview • • • • • Project Introduction VGA Tutorial Project Implementation Project Demo Wrap-Up 2 Project Introduction • Project Objective – Game using VGA • Advantages of Pong – Easy Implementation – Rectangular Objects – Basic Physics 3 VGA Tutorial • Basic VGA Components – H Sync (Horizontal Sync) – V Sync (Vertical Sync) – Colors • On the Nexys 4 Board – 4 bits per color – RGB 4 VGA Tutorial • H Sync and V Sync Signal Explanation 5 VGA Tutorial • Sync Signal Components – Sync Pulse – Back Porch – Front Porch – Visible Display Area 6 VGA Tutorial • RGB Signal Explanation • 4 bits for each RGB Component • 12 bit Color total • 4096 Color Combinations • Creates a Voltage • 0V to 0.7V • Color is sampled per pixel 7 VGA Tutorial • Timing Example (800x600@60 Hz) 8 Project Implementation 7 Modules 9 Project Implementation (G1 : CLK Wiz) • Module 1 : Clocking Wizard • Xilinx IP • Found in IP Catalog • Operation • 100 MHz => 40 MHz • Generate Pixel Clock 10 Project Implementation (G2 : VGA Contr.) • Module 2 : VGA Controller • Custom Design • Backbone Module • Operation • Create H Sync, V Sync and Video On Signals • Generate Signals and Pixel Counters 11 Project Implementation (G2 : VGA Contr.) • Main Process • 2 Counters • Horizontal Counter Range • 0 to 1055 • Vertical Counter Range • 0 to 627 • Horizontal Visible • 216 to 1016 • Vertical Visible • 29 to 629 12 Project Implementation (G3 : Pixel Gen.) • Module 3 : Pixel Generator • Custom Design • Backbone Module • Operation • Generate RGB Signals • Generate RGB Signals based on VGA Controller Counters 13 Project Implementation (G3 : Pixel Gen.) • Object Drawing • While the current pixel being drawn is within the bounds of an object, set that object to the “on” state • Constants (for permanent bounds) and signals (for movement) 14 Project Implementation (G3 : Pixel Gen.) • Color Selection Processes • Decisions made on a per-pixel basis • Aligned with the VGA clock • With-select-when dependent on what pixel is currently in question 15 Project Implementation (G3 : Pixel Gen.) • Paddle Movement • Reset to middle of side • Button press sends paddle up/down • Paddle movement signals used in ball reflection 16 Project Implementation (G3 : Pixel Gen.) • Ball Movement • Reset to center, starting velocity randomized (see random generator later) • Next state logic advancement at beginning of process iteration 17 Project Implementation (G3 : Pixel Gen.) • Ball Movement ctd. • Result of ball impact on paddle varies on paddle movement • Same direction movement = higher velocity ball • Opposite direction slows and changes ball’s vertical movement 18 Project Implementation (G3 : Pixel Gen.) • Ball Movement ctd. • Ball reflects off of the screen bounds and the wall based on current position 19 Project Implementation (G3 : Pixel Gen.) • Ball Movement ctd. • Prevent ball’s next position from going through the paddle or wall 20 Project Implementation (G4 : CLK Divider) • Module 4 : Clock Divider • Custom Design • Support Module • Operation • Create the Animation Clock • Used in: • Paddle/Ball Movement 21 Project Implementation (G4 : CLK Divider) • Main Process • Simple Counter • Generic Input Argument • Max Count Val • 50% Duty Cycle • Count to Half 22 Project Implementation (G5 : State Mach.) • Module 5 : State Machine Contrl. • Custom Design • Backbone Module • Operation • Control the Game State and Internal Signals • Used in: • Scorekeeping • Object Reset 23 Project Implementation (G5 : State Mach.) • Basic State Diagram • Simple FSM, only three states • Returns to idle state upon reset signal • Point scored during game adds to count and returns to idle 24 Project Implementation (G5 : State Mach.) • Main Process • Basic case statement • State iteration through conditional signal assignment 25 Project Implementation (G6 : 7-Seg Contr.) • Module 6 : 7-Segment Controller • Custom Design • Support Module • Operation • Display the Score for the game on the 7-Segments • Used in: • Score Counter Output 26 Project Implementation (G6 : 7-Seg Contr.) • Main Process • With...Select MUX • Build Cathode String • Hardcoded Anode String 27 Project Implementation (G7 : RNG) • Module 7 : Random Number Gen. • Custom Design • Support Module • Operation • Create 2 pseudo-random numbers • Used in: • Velocity variation 28 Project Implementation (G7 : RNG) • Two Processes • Each process is triggered off of a different VGA clock • Pseudo random at its finest • Two counters for 6 states (0-5) • Mapped to speeds via with-select-when statements 29 Project Demo Wrap-Up • Future Work/Improvements – 2 players – Round Ball – Variable Speed – Improved Input – Display Buffer 31 Wrap-Up • Thanks for listening! • Questions? 32