ECE 448 Lecture 11. VGA Display Part 3 Animation

Similar documents
ECE 448 Lecture 11. VGA Display Part 3 Animation

ECE 448 Lecture 12. VGA Display Part 4 Text Generation

ECE 448 Lecture 10. VGA Display Part 1 VGA Synchronization

Flip-flop and Registers

Lab 6: Video Game PONG

Lab 3: VGA Bouncing Ball I

Ryerson University Department of Electrical and Computer Engineering EES508 Digital Systems

Vending Machine. Keywords FSM, Vending Machine, FPGA, VHDL

Lab # 9 VGA Controller

VHDL test bench for digital image processing systems using a new image format

Tic-Tac-Toe Using VGA Output Alexander Ivanovic, Shane Mahaffy, Johnathan Hannosh, Luca Wagner

Design of VGA Controller using VHDL for LCD Display using FPGA

Eng. Mohammed Samara. Fall The Islamic University of Gaza. Faculty of Engineering. Computer Engineering Department

Design Problem 4 Solutions

Class 06 Sequential Logic: Flip-Flop

Lab 4: Hex Calculator

Class 19 Sequential Logic: Flip-Flop

Figure 1 Block diagram of a 4-bit binary counter

Bachelor Thesis. Augmented Reality using a Virtual Reality. R.J.A. Blokker & L.M. Noordam. Implementation on an FPGA device

library IEEE; use IEEE.STD_LOGIC_1164.ALL;

HDL & High Level Synthesize (EEET 2035) Laboratory II Sequential Circuits with VHDL: DFF, Counter, TFF and Timer

TSIU03: Lab 3 - VGA. Petter Källström, Mario Garrido. September 10, 2018

Design and Implementation of an AHB VGA Peripheral

Laboratory 4 Check Off Sheet. Student Name: Staff Member Signature/Date: Part A: VGA Interface You must show a TA the following for check off:

Flip-Flops and Registers

ECE 3401 Lecture 11. Sequential Circuits

Laboratory 4 Check Off Sheet. Student Name: Staff Member Signature/Date: Part A: VGA Interface You must show a TA the following for check off:

hochschule fu r angewandte wissenschaften hamburg Prof. Dr. B. Schwarz FB Elektrotechnik/Informatik

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Sciences

Spartan-II Development System

Real-Time Digital Oscilloscope Implementation in 90nm CMOS Technology FPGA

Block Diagram. dw*3 pixin (RGB) pixin_vsync pixin_hsync pixin_val pixin_rdy. clk_a. clk_b. h_s, h_bp, h_fp, h_disp, h_line

Design of VGA and Implementing On FPGA

Level and edge-sensitive behaviour

VHDL 4 BUILDING BLOCKS OF A COMPUTER.

Video. Prof. Stephen A. Edwards Columbia University Spring Video p. 1/2

Digital Blocks Semiconductor IP

FPGA Laboratory Assignment 4. Due Date: 06/11/2012

VGA Configuration Algorithm using VHDL

ECE 263 Digital Systems, Fall 2015

download instant at

Video. Prof. Stephen A. Edwards Columbia University Spring Video p.

Professor Henry Selvaraj, PhD. November 30, CPE 302 Digital System Design. Super Project

VGA Port. Chapter 5. Pin 5 Pin 10. Pin 1. Pin 6. Pin 11. Pin 15. DB15 VGA Connector (front view) DB15 Connector. Red (R12) Green (T12) Blue (R11)

EE178 Spring 2018 Lecture Module 5. Eric Crabill

ECE 545 Digital System Design with VHDL Lecture 2. Digital Logic Refresher Part B Sequential Logic Building Blocks

Lecture 6: Simple and Complex Programmable Logic Devices. EE 3610 Digital Systems

Using the XSV Board Xchecker Interface

Spartan-II Development System

The Nexys 4 Number Cruncher. Electrical and Computer Engineering Department

EEM Digital Systems II

VGA Pixel Buffer Stephen Just

DEPARTMENT OF ELECTRICAL &ELECTRONICS ENGINEERING DIGITAL DESIGN

4:1 Mux Symbol 4:1 Mux Circuit

ECE337 Lab 4 Introduction to State Machines in VHDL

Lab 5 FPGA Design Flow Based on Aldec Active-HDL. Fast Reflex Game.

DIGITAL SYSTEM DESIGN VHDL Coding for FPGAs Unit 7

Lecture 14: Computer Peripherals

EE178 Lecture Module 4. Eric Crabill SJSU / Xilinx Fall 2005

VHDL Design and Implementation of FPGA Based Logic Analyzer: Work in Progress

ECE 545 Digital System Design with VHDL Lecture 1B. Digital Logic Refresher Part B Sequential Logic Building Blocks

Implementing VGA Application on FPGA using an Innovative Algorithm with the help of NIOS-II

Traffic Light Controller

VID_OVERLAY. Digital Video Overlay Module Rev Key Design Features. Block Diagram. Applications. Pin-out Description

ACS College of Engineering. Department of Biomedical Engineering. HDL pre lab questions ( ) Cycle-1

Asynchronous & Synchronous Reset Design Techniques - Part Deux

ECE 545 Digital System Design with VHDL Lecture 1. Digital Logic Refresher Part B Sequential Logic Building Blocks

CALIFORNIA STATE UNIVERSITY, NORTHRIDGE. Reconfigurable RGB Video Test Pattern Generator

COE758 Xilinx ISE 9.2 Tutorial 2. Integrating ChipScope Pro into a project

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Introductory Digital Systems Laboratory

Lab #5: Design Example: Keypad Scanner and Encoder - Part 1 (120 pts)

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Introductory Digital Systems Laboratory

ECE 3401 Lecture 12. Sequential Circuits (II)

ECE 341. Lecture # 2

Lab #10 Hexadecimal-to-Seven-Segment Decoder, 4-bit Adder-Subtractor and Shift Register. Fall 2017

... User Guide - Revision /23/04. H Happ Controls. Copyright 2003, UltraCade Technologies UVC User Guide 1/23/2004

AbhijeetKhandale. H R Bhagyalakshmi

Bachelor of Technology (Electronics and Instrumentation Engg.)

FSM Implementations. TIE Logic Synthesis Arto Perttula Tampere University of Technology Fall Output. Input. Next. State.

T2210HD/T2210HDA 21.5 Wide-Screen LCD Monitor User Manual

PC/HDTV to PC/HDTV converter (CP-251F)

Using HERON modules with FPGAs to connect to FPDP

ThedesignsofthemasterandslaveCCBFPGAs

Feedback Sequential Circuits

VGA 8-bit VGA Controller

CS/EE Homework 6

Block Diagram. 16/24/32 etc. pixin pixin_sof pixin_val. Supports 300 MHz+ operation on basic FPGA devices 2 Memory Read/Write Arbiter SYSTEM SIGNALS

ECE 532 PONG Group Report

Modeling Latches and Flip-flops

Smooth Ternary Signaling For Deep-Submicron(DSM) Buses

VSP 168HD Quick Start

An Efficient SOC approach to Design CRT controller on CPLD s

CYPRESS TECHNOLOGY CO., LTD.

Fixed-Point Calculator

15 Inch CGA EGA VGA to XGA LCD Wide Viewing Angle Panel ID# 833

Testing Results for a Video Poker System on a Chip

Virtual Basketball: How Well Do You Shoot?

LOCAL DECODING OF WALSH CODES TO REDUCE CDMA DESPREADING COMPUTATION. Matt Doherty Introductory Digital Systems Laboratory.

EECS150 - Digital Design Lecture 12 - Video Interfacing. Recap and Outline

Digilent Nexys-3 Cellular RAM Controller Reference Design Overview

Transcription:

ECE 448 Lecture 11 VGA Display Part 3 Animation George Mason University

Required Reading P. Chu, FPGA Prototyping by VHDL Examples Chapter 12, VGA Controller I: Graphic Source Codes of Examples http://academic.csuohio.edu/chu_p/rtl/fpga_vhdl.html Nexys 3 Board Reference Manual Nexys 4 DDR FPGA Board Reference Manual VGA Port 2

PONG 3

PONG Commonly regarded as the first "commercially successful" video game Released by Atari in 1972 Created by Allan Alcorn as a training exercise assigned to him by Atari co-founder Nolan Bushnell The first prototype developed completely in hardware using TTL devices Originally used as an arcade video game Home version released during the 1975 Christmas season 4

PONG 5

PONG Interesting Videos Pong Game http://www.ponggame.org First documented Video Ping-Pong game 1969 https://www.youtube.com/watch?v=xnrx5hc4gyc Classic Game Room HD - PONG for Nintendo DS / GBA https://www.youtube.com/watch?v=trezfjgf-kg 6

Animation 7

Animation Basics Animation is achieved by an object changing its location gradually in each frame We use signals, instead of constants, to determine boundaries of an object VGA monitor is refreshed 60 times per second The boundary signals need to be updated at this rate We create a 60 Hz enable tick, refr_tick, which is asserted for 1 pixel period every 1/60 th of a second 8

Moving the Bar (Paddle) 600 x 603 bar_y_t y bar_y_b bar_y_t = bar_y_reg bar_y_b=bar_y_t +BAR_Y_SIZE-1 BAR_V is a velocity of the bar (#pixels/frame) 9

Moving the Bar in VHDL (1) -- bar left, right boundary constant BAR_X_L: integer:=600; constant BAR_X_R: integer:=603; -- bar top, bottom boundary signal bar_y_t, bar_y_b: unsigned(9 downto 0); constant BAR_Y_SIZE: integer:=72; -- reg to track top boundary (x position is fixed) signal bar_y_reg, bar_y_next: unsigned(9 downto 0); -- bar moving velocity when the button is pressed constant BAR_V: integer:=4; 10

Moving the Bar in VHDL (2) -- boundary bar_y_t <= bar_y_reg; bar_y_b <= bar_y_t + BAR_Y_SIZE - 1; -- pixel within bar bar_on <= '1' when (BAR_X_L<=pix_x) and (pix_x<=bar_x_r) and (bar_y_t<=pix_y) and (pix_y<=bar_y_b) else '0'; -- bar rgb output bar_rgb <= "010"; --green 11

bar_y_reg, bar_y_t, and bar_y_b 12

Moving the Bar in VHDL (4) process (clk, reset) begin if reset='1' then bar_y_reg <= (others=>'0'); elsif (clk'event and clk='1') then bar_y_reg <= bar_y_next; end if; end process; 13

Circuit calculating bar_y_next 14

Moving the Bar in VHDL (3) -- new bar y-position process(bar_y_reg, bar_y_b, bar_y_t, refr_tick, btn) begin bar_y_next <= bar_y_reg; -- no move if refr_tick='1' then if btn(1)='1' and bar_y_b <= (MAX_Y-1-BAR_V) then bar_y_next <= bar_y_reg + BAR_V; -- move down elsif btn(0)='1' and bar_y_t >= BAR_V then bar_y_next <= bar_y_reg - BAR_V; -- move up end if; end if; end process; 15

Moving the Ball ball_x_l x ball_x_r ball_y_t y ball_y_b ball_x_l = ball_x_reg ball_x_r=ball_x_l +BALL_SIZE-1 ball_y_t = ball_y_reg ball_y_b=ball_y_t +BALL_SIZE-1 16

Ball Velocity The ball may change direction by hitting the wall, the paddle, or the bottom or top of the screen We decompose velocity into an x-component and a y-component Each component can have either a positive value BALL_V_P or a negative value BALL_V_N The current value of each component is kept in x_delta_reg and y_delta_reg 17

Velocity Components of the Ball x x_delta_reg = BALL_V_N y_delta_reg = BALL_V_N x_delta_reg = BALL_V_P y_delta_reg = BALL_V_N x_delta_reg = BALL_V_N y_delta_reg = BALL_V_P x_delta_reg = BALL_V_P y_delta_reg = BALL_V_P y 18

Moving the Ball in VHDL (1) constant BALL_SIZE: integer:=8; -- 8 -- ball boundaries signal ball_x_l, ball_x_r: unsigned(9 downto 0); signal ball_y_t, ball_y_b: unsigned(9 downto 0); -- reg to track left, top boundary signal ball_x_reg, ball_x_next: unsigned(9 downto 0); signal ball_y_reg, ball_y_next: unsigned(9 downto 0); -- reg to track ball speed signal x_delta_reg, x_delta_next: unsigned(9 downto 0); signal y_delta_reg, y_delta_next: unsigned(9 downto 0); -- ball velocity can be pos or neg constant BALL_V_P: unsigned(9 downto 0) := to_unsigned(2,10); constant BALL_V_N: unsigned(9 downto 0) := unsigned(to_signed(-2,10)); 19

Moving the Ball in VHDL (3) ball_x_l <= ball_x_reg; ball_y_t <= ball_y_reg; ball_x_r <= ball_x_l + BALL_SIZE - 1; ball_y_b <= ball_y_t + BALL_SIZE - 1; -- pixel within ball sq_ball_on <= '1' when (ball_x_l<=pix_x) and (pix_x<=ball_x_r) and '0'; (ball_y_t<=pix_y) and (pix_y<=ball_y_b) else 20

Moving the Ball in VHDL (2) type rom_type is array (0 to 7) of std_logic_vector(0 to 7); constant BALL_ROM: rom_type := ( "00111100", -- **** ); "01111110", -- ****** "11111111", -- ******** "11111111", -- ******** "11111111", -- ******** "11111111", -- ******** "01111110", -- ****** "00111100" -- **** signal rom_addr, rom_col: unsigned(2 downto 0); signal rom_data: std_logic_vector(0 to 7); signal rom_bit: std_logic; 21

Moving the Ball in VHDL (4) -- map current pixel location to ROM addr/col rom_addr <= pix_y(2 downto 0) - ball_y_t(2 downto 0); rom_col <= pix_x(2 downto 0) - ball_x_l(2 downto 0); rom_data <= BALL_ROM(to_integer(rom_addr)); rom_bit <= rom_data(to_integer(rom_col)); -- pixel within ball rd_ball_on <= '1' when (sq_ball_on='1') and (rom_bit='1') else '0'; -- ball rgb output ball_rgb <= "100"; -- red 22

Moving the Ball in VHDL (5) -- new ball position ball_x_next <= ball_x_reg + x_delta_reg when refr_tick='1' else ball_x_reg ; ball_y_next <= ball_y_reg + y_delta_reg when refr_tick='1' else ball_y_reg ; 23

Bouncing y_delta_next <= BALL_V_P x_delta_next <= BALL_V_P x_delta_next <= BALL_V_N y_delta_next <= BALL_V_N 24

Circuit calculating y_delta_next 25

Circuit calculating x_delta_next 26

Moving the Ball in VHDL (6) process(x_delta_reg, y_delta_reg, ball_x_l, ball_x_r, ball_y_t, ball_y_b, bar_y_t, bar_y_b) begin x_delta_next <= x_delta_reg; if ball_y_t < 1 then -- reach top y_delta_next <= BALL_V_P; y_delta_next <= y_delta_reg; elsif ball_y_b >= (MAX_Y-1) then -- reach bottom y_delta_next <= BALL_V_N; elsif ball_x_l <= WALL_X_R then -- reach wall x_delta_next <= BALL_V_P; -- bounce back elsif (BAR_X_L<=ball_x_r) and (ball_x_r<=bar_x_r) then -- reach x of right bar if (bar_y_t<=ball_y_b) and (ball_y_t<=bar_y_b) then x_delta_next <= BALL_V_N; --hit, bounce back end if; end if; end process; 27

Moving the Ball in VHDL (7) process (clk, reset) begin if reset='1' then ball_x_reg <= (others=>'0'); ball_y_reg <= (others=>'0'); x_delta_reg <= BALL_V_P; y_delta_reg <= BALL_V_P; elsif (clk'event and clk='1') then ball_x_reg <= ball_x_next; ball_y_reg <= ball_y_next; x_delta_reg <= x_delta_next; y_delta_reg <= y_delta_next; end if; end process; 28

Generating ref_tick in VHDL pix_x <= unsigned(pixel_x); pix_y <= unsigned(pixel_y); -- refr_tick: 1-clock tick asserted at start of v-sync -- i.e., when the screen is refreshed (60 Hz) refr_tick <= '1' when (pix_y=481) and (pix_x=0) else '0'; 29

Vertical Synchronization 30