Lab 4 Performance Part.pdf

10 Pages
86 Views
Unlock Document

Department
Electrical and Computer Engineering
Course
EECE 252
Professor
lemieux,guy
Semester
Fall

Description
library IEEE; USEIEEE.STD_LOGIC_1164.ALL; --USEIEEE.STD_LOGIC_SIGNED.ALL; USEIEEE.NUMERIC_STD.ALL; ENTITYlab4_test IS PORT( CLOCK_50: in STD_LOGIC; KEY: in STD_LOGIC_VECTOR(3downto 0); SW : in STD_LOGIC_VECTOR(17downto 0); VGA_R, VGA_G, VGA_B: out STD_LOGIC_VECTOR(9downto 0); VGA_HS : out STD_LOGIC; VGA_VS : out STD_LOGIC; VGA_BLANK : out STD_LOGIC; VGA_SYNC : out STD_LOGIC; VGA_CLK : out STD_LOGIC); --LEDR: out STD_LOGIC_VECTOR(17downto 0)); endlab4_test; architecture rtl of lab4_test is component vga_adapter ---- Componentfrom the Verilog file: vga_adapter.v generic(RESOLUTION: STRING); port ( resetn : in STD_LOGIC; clock : in STD_LOGIC; colour: in STD_LOGIC_VECTOR(2downto 0); x : in STD_LOGIC_VECTOR(7downto 0); y : in STD_LOGIC_VECTOR(6downto 0); plot : in STD_LOGIC; VGA_R, VGA_G, VGA_B: out STD_LOGIC_VECTOR(9downto 0); VGA_HS, VGA_VS, VGA_BLANK, VGA_SYNC, VGA_CLK : out STD_LOGIC); end component; type particle is record xnew: SIGNED(11downto 0); -- 11bit significantfigure 1forsign { the new location } ynew: SIGNED(11downto 0); -- 11bit significantfigure 1forsign xold: SIGNED(11downto 0); -- the currentlocation yold: SIGNED(11downto 0); dx: SIGNED(11downto 0); -- the horizontal change (could be -ve) dy: SIGNED(11downto 0); -- the vertical change(could be -ve) colour: STD_LOGIC_VECTOR(2downto 0); --edge: STD_LOGIC_VECTOR(3downto 0); -- The boundary (left right top bottom) end record; type borderis record x_pos: SIGNED( 11downto 0); y_pos: SIGNED( 11downto 0); x_max: SIGNED( 11downto 0); y_max: SIGNED( 11downto 0); x_min: SIGNED( 11downto 0); y_min: SIGNED( 11downto 0); dx: SIGNED(11downto 0); dy: SIGNED(11downto 0); colour: STD_LOGIC_VECTOR( 2downto 0); end record; type particleset is array (1downto 0) of particle; -- ball1orball2... type bordersetis array ( 3downto 0) of border; constant BACKGROUND: STD_LOGIC_VECTOR(2downto 0) :="000"; -- colourof background constant YMAX : SIGNED(11downto 0) :=b"001110111000"; -- 119x 8(4extrabits) constant XMAX : SIGNED(11downto 0) :=b"010011111000"; -- 159x 8(4 extrabits) signal resetn : STD_LOGIC; signal x: STD_LOGIC_VECTOR(7downto 0); signal y: STD_LOGIC_VECTOR(6downto 0); signal colour: STD_LOGIC_VECTOR(2downto 0); signal plot : STD_LOGIC; begin resetn <=SW(17); -- It is active low, so keepit high foroperation --x <=SW(7downto 0); --y <=SW(14downto 8); --colour<=SW(17downto 15); --plot <=not KEY(0); vga_u0: vga_adapter genericmap(RESOLUTION =>"160x120") ---- Sets the resolution of display (as pervga_adapter.v description) port map(resetn =>resetn, clock =>CLOCK_50, colour=>colour, x =>x, y =>y, plot =>plot, VGA_R=>VGA_R, VGA_G=>VGA_G, VGA_B=>VGA_B, VGA_HS =>VGA_HS, VGA_VS =>VGA_VS, VGA_BLANK =>VGA_BLANK, VGA_SYNC =>VGA_SYNC, VGA_CLK =>VGA_CLK ); ----------- We are using extra4bits forprecision, so ourdelta X and deltaYshould have afactorof 8 ----------- Otherwise, we loose theirsignificance during the rounding process(CLOCK_50) variable p: particleset :=((xnew=>b"000111011000", ynew=>b"001010101000", ---- p(0) Green xold=>"000111011000", yold=>"001010101000", dx=>"000000011000", dy=>"000000001000", ---- speed of ball 1(in X/Ydirections) colour=>"010" ), (xnew=>b"000111110000", ynew=>b"000000011000", ---- p(1) Red xold=>"000111110000", yold=>"000000011000", dx=>"000000001000", dy=>"000000000000", colour=>"100" ) ); variable b: borderset :=( ( x_pos => "000000000000", y_pos =>"000000000000", x_min => b"000000000000", y_min =>b"000000000000", x_max => b"000111100000", y_max =>b"000000011000", dx => "000000001000", dy => "000000001000", colour=> "001" ), ( x_pos => "001100100000", y_pos =>"000000000000", x_min => "000000000000", y_min =>"000000000000", x_max => XMAX, y_max =>"000000011000", dx => "000000001000", dy => "000000001000", colour=> "001" ), ( x_pos => "000000000000", y_pos =>"001110100000", x_min => b"000000000000", y_min =>b"001110100000", x_max => b"000000000000", y_max =>b"001110111000", dx => "000000001000", dy => "000000001000", colour=> "001" ), ( x_pos => "000000000000", y_pos =>"001110100000", x_min => "000000000000", y_min =>"001110100000", x_max => "000000000000", y_max =>"001110111000", dx => "000000001000", dy => "000000001000", colour=> "001" ) ); variable count: UNSIGNED(19downto 0):="00000000000000000000"; type stateis ( border0, border1, border2, border3, border4, game ); type bstate is (init, good ); variable borderState : bstate :=init; variable gameState : state :=border0; variable newP: STD_LOGIC :='0'; variable dxo, dyo, tempXY: SIGNED(11downto 0); --- temp X/Yspeed begin if RISING_EDGE(CLOCK_50) then if ( gameState =border0) then newP :='1'; if ( borderState =init ) then b(0)
More Less

Related notes for EECE 252

Log In


OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.


Submit