pong/vga.vhd

74 lines
1.3 KiB
VHDL
Raw Normal View History

2013-02-22 02:27:53 +00:00
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity vga is
port (
CLK : in std_logic;
IRGB : in std_logic_vector(7 downto 0);
RGB : out std_logic_vector(7 downto 0);
2013-02-22 22:00:03 +00:00
FRAME: out std_logic;
2013-02-22 02:27:53 +00:00
W : out std_logic;
X : out std_logic_vector(9 downto 0);
Y : out std_logic_vector(9 downto 0);
HS : out std_logic;
VS : out std_logic
);
end vga;
architecture Behavioral of vga is
signal horiz : std_logic_vector(9 downto 0);
signal vert : std_logic_vector(9 downto 0);
begin
2013-02-22 22:00:03 +00:00
process (CLK)
variable fout : std_logic := '0';
begin
2013-02-22 02:27:53 +00:00
if CLK'event and CLK = '1' then
2013-02-22 22:00:03 +00:00
if (horiz >= 145) and (horiz < 788)
and (vert >= 35) and (vert < 514) then
2013-02-22 02:27:53 +00:00
W <= '1';
RGB <= IRGB;
2013-02-22 22:00:03 +00:00
X <= horiz - 146 + 1;
Y <= vert - 34 + 1;
2013-02-22 02:27:53 +00:00
else
W <= '0';
2013-02-22 22:00:03 +00:00
RGB <= "00000000";
2013-02-22 02:27:53 +00:00
end if;
if (horiz > 0) and (horiz < 97) then
HS <= '0';
else
HS <= '1';
end if;
if (vert > 0) and (vert < 3) then
VS <= '0';
else
VS <= '1';
end if;
horiz <= horiz + 1;
if (horiz = 800) then
vert <= vert + 1;
horiz <= (others => '0');
end if;
if (vert = 521) then
2013-02-22 22:00:03 +00:00
fout := '1';
2013-02-22 02:27:53 +00:00
vert <= (others => '0');
2013-02-22 22:00:03 +00:00
else
fout := '0';
2013-02-22 02:27:53 +00:00
end if;
2013-02-22 22:00:03 +00:00
FRAME <= fout;
2013-02-22 02:27:53 +00:00
end if;
end process;
end Behavioral;