Professional Documents
Culture Documents
While I was working on the vga module I have produced some objects with different
colors and shapes. Unfortunately, Spartan 3e can provide only 1 bit for each color and
this limits your choices. Not like Spartan 3e which has 4 bit for each color, also not as
virtex2 which has 8 bit color using an IC .
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use ieee.numeric_std.all;
entity vga is
Port ( CLK50_in : in STD_LOGIC;
HS : out STD_LOGIC;
VS : out STD_LOGIC;
r,g,b : out std_logic
);
end vga;
begin
obj1_on <=
'1' when (obj1_x_l <= x ) and (x <= obj1_x_r) else
'0';
obj2_on <=
'1' when (obj2_x_l <= x ) and (x <= obj2_x_r) and (obj2_y_u <=y) and (obj2_y_d >=
y) else
'0';
ball_on <=
'1' when (ball_x_l <= x ) and (x <= ball_x_r) and (ball_y_u <=y) and (ball_y_d >= y)
else
'0';
begin
if clk25'event and clk25='1' then
H_counter_value <= H_counter_value +1;
if (H_counter_value = 800)then
H_counter_value <= 0;
V_counter_value <= V_counter_value +1;
end if;
if (V_counter_value = 521)then
V_counter_value <= 0;
end if;
x <= H_counter_value-143;
y <= V_counter_value-31;
x_ball<= x - ball_x_l;
y_ball<= y - ball_y_u;
--if (H_counter_value >=144 and H_counter_value < 783 and V_counter_value >=31
and V_counter_value <510) then
-- if((x>=0)and(x<256)and(y>=0)and(y<256))then
-- addr<=addr+1;
-- reed<='1';ena<='1';
-- r<='0';b<='0';--g<=(others=>'0');
-- g<='1';
--else
-- r<='1';b<='0';g<='0';addr<="0000000000000000";
-- reed<='0';ena<='0';
-- end if;
--else
-- r<='0';g<='0';b<='0';addr<="0000000000000000";
--reed<='0';ena<='0';
--end if;
end if;
end process;
process(clk25,ball_on)
begin
if ball_on='1' then
data <=mem(y_ball);
c<= data (x_ball);
end if;
end process;
process(clk25,H_counter_value,V_counter_value,obj1_on,obj2_on,ball_on,c)
begin
else
r<='1';g<='0';b<='0';
end if;
end process;
end Behavioral;