From e75394b89787a55a4c54de93b7993092b73b38f0 Mon Sep 17 00:00:00 2001 From: Richard Widen Date: Tue, 24 Apr 2012 11:00:15 +0200 Subject: [PATCH] Flytta runt spriten --- FirstGraphicTest.vhd | 16 ++++++++++++---- Nexys3_Master.ucf | 4 ++-- SpriteGpu.vhd | 10 +++++++++- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/FirstGraphicTest.vhd b/FirstGraphicTest.vhd index 1ca404c..ba9be6d 100644 --- a/FirstGraphicTest.vhd +++ b/FirstGraphicTest.vhd @@ -36,7 +36,9 @@ entity FirstGraphicTest is hsync : OUT std_logic; vgaRed: OUT std_logic_vector(2 downto 0); vgaGreen: OUT std_logic_vector(2 downto 0); - vgaBlue: OUT std_logic_vector(2 downto 1) + vgaBlue: OUT std_logic_vector(2 downto 1); + btnd: in std_logic; + btnu: in std_logic ); end FirstGraphicTest; @@ -59,7 +61,7 @@ architecture Behavioral of FirstGraphicTest is vgaRed: OUT std_logic_vector(2 downto 0); vgaGreen: OUT std_logic_vector(2 downto 0); vgaBlue: OUT std_logic_vector(2 downto 1); - spriteDetected : in std_logic + spriteDetected : in std_logic ); END COMPONENT; @@ -83,7 +85,10 @@ architecture Behavioral of FirstGraphicTest is spriteVgaBlue: out std_logic_vector(2 downto 1); collision: out std_logic; rst : in STD_LOGIC; - spriteDetected : out std_logic); + spriteDetected : out std_logic; + btnd: in std_logic; + btnu: in std_logic + ); END COMPONENT; @@ -104,6 +109,7 @@ architecture Behavioral of FirstGraphicTest is signal spriteDetected : std_logic; + --signal clk : std_logic := '0'; signal rst : std_logic := '1'; @@ -145,7 +151,9 @@ begin spriteVgaGreen => spriteVgaGreen, spriteVgaBlue => spriteVgaBlue, collision => collision, - spriteDetected =>spriteDetected + spriteDetected =>spriteDetected, + btnd => btnd, + btnu => btnu ); clk_process :process diff --git a/Nexys3_Master.ucf b/Nexys3_Master.ucf index 666778c..2741f55 100644 --- a/Nexys3_Master.ucf +++ b/Nexys3_Master.ucf @@ -174,9 +174,9 @@ Net "clk" LOC=V10 | IOSTANDARD=LVCMOS33; ## Buttons #Net "btns" LOC = B8 | IOSTANDARD = LVCMOS33; #Bank = 0, pin name = IO_L33P, Sch name = BTNS -#Net "btnu" LOC = A8 | IOSTANDARD = LVCMOS33; #Bank = 0, pin name = IO_L33N, Sch name = BTNU +Net "btnu" LOC = A8 | IOSTANDARD = LVCMOS33; #Bank = 0, pin name = IO_L33N, Sch name = BTNU #Net "btnl" LOC = C4 | IOSTANDARD = LVCMOS33; #Bank = 0, pin name = IO_L1N_VREF, Sch name = BTNL -#Net "btnd" LOC = C9 | IOSTANDARD = LVCMOS33; #Bank = 0, pin name = IO_L34N_GCLK18, Sch name = BTND +Net "btnd" LOC = C9 | IOSTANDARD = LVCMOS33; #Bank = 0, pin name = IO_L34N_GCLK18, Sch name = BTND #Net "btnr" LOC = D9 | IOSTANDARD = LVCMOS33; # Bank = 0, pin name = IO_L34P_GCLK19, Sch name = BTNR ## VGA Connector diff --git a/SpriteGpu.vhd b/SpriteGpu.vhd index a5866b1..c672410 100644 --- a/SpriteGpu.vhd +++ b/SpriteGpu.vhd @@ -40,7 +40,9 @@ entity SpriteGpu is spriteVgaBlue: out std_logic_vector(2 downto 1); collision: out std_logic; spriteDetected: out std_logic; - rst : in STD_LOGIC); + rst : in STD_LOGIC; + btnd: in std_logic; + btnu: in std_logic); end SpriteGpu; @@ -76,6 +78,12 @@ sprite_brick(15) <= "1111111111111111"; process(clk) begin if rising_edge(clk) then + if btnu ='1' then + y_pos <= y_pos-1; + elsif btnd='1' then + y_pos <= y_pos+1; + end if; + if y>y_pos and y <= (y_pos+spriteSize) then if x> x_pos and x <= (x_pos+spriteSize) then if sprite_brick( y - y_pos )( x - x_pos ) = '1' then