codigocoVGA PDF
codigocoVGA PDF
codigocoVGA PDF
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity video_vga is
Port ( clk : in STD_LOGIC;
a : in STD_LOGIC_VECTOR(1 downto 0);
shor : out STD_LOGIC;
sver : out STD_LOGIC;
RGB : out STD_LOGIC_VECTOR(7 downto 0));
end video_vga;
begin
--clk es de 50MHz del reloj interno de la FPGA. Se genera la señal clkdiv a 25 MHz.
process (clk)
begin
if (clk = '1' and clk' event) then
clkdiv <= not clkdiv;
end if;
end process;
--Contador horizontal
process (clkdiv)
begin
if (clkdiv = '1' and clkdiv' event) then
if conh = hpixels then --Monitoreo de número de pixeles en línea horizontal
conh <= (others=>'0'); --Inicializa en 0's el contador
vsenable <= '1'; --Habilita el contador veritical cuando conh = 800.
else
conh <= conh + 1; --Incrementa el contador horizontal
vsenable <= '0'; --Deshabilita el contador vertical
end if;
end if;
end process;
--Contador vertical
process (clkdiv)
begin
if (clkdiv = '1' and clkdiv' event and vsenable = '1') then
if conv = vlines then --Monitorea el número de líneas verticales
conv <= (others=>'0'); --Inicializa el contador
else conv <= conv + 1; --Incrementa el contador vertical
end if;
end if;
end process;
--*******************************************************************
--Pixels a visualizar
RGB <= "11111100" when (conh(4 downto 0) = "00000" and
conv(4 downto 0) = "00000" and
vidon = '1' and a = "00") else
-- Cuadro a visualizar
"11100011" when (conh > ("0100001110" + hbp) and conh < ("0101110010" + hbp)
and conv > ("0010111110" + vbp) and conv < ("0100100010" + vbp)
and vidon = '1' and a = "01") else
-- Rayas verticales
"00011111" when (conh (4 downto 0) = "00000" and
vidon = '1' and a = "10" )else
-- Rayas horizontales
"11100000" when (conv (4 downto 0) = "00000" and
vidon = '1' and a = "11" )else "00000000";
--*********************************************************************
end arq_video_vga;