Altera_Forum
Honored Contributor
13 years agoVGA Timing problem
Hi guys, I'm on an Altera DE1 board and I've just gotten my hands dirty with trying to output to a VGA monitor, and its not going as well as I'd like. I've been using
*well apparently I can't post urls... if you google "vga timing lasierra" its the first result, a pdf file* to try and get the idea of it and I've struggled with that, but I've been trying to recreate their circuit and then mess around and try to understand it more. For a while, when I misunderstood the idea a bit (I kept the hsync cycles running repeatedly, not just in the specified window of the vsync cycle), I got the monitor to show "black" and not go into power saving mode. I even got it to show very brief flashes of color when I made the RGB values match KEY/SW values on the board, but since I realized I'd been doing it wrong I haven't even gotten that. Seems odd that when I rework things to make them "right", I go back in progress...but oh well. As far as I can tell, I'm following their circuit (Figure 5, a-d) closely, but no luck. As you can see, I'm using a 50MHz clock and turning into a 25 MHz clock, while the site says use 25.175MHz..could that be the problem? Also if there are other problems with the code I'd welcome suggestions, but the timing issue is my main priority here. Thanks!library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity vgatest is
PORT ( C50 : in BIT;
SW : in UNSIGNED(9 downto 0);
KEY : in UNSIGNED(3 downto 0);
LEDG : out UNSIGNED(7 downto 0);
VGA_R,VGA_G,VGA_B : out UNSIGNED(3 downto 0) := "0000";
VGA_HS : out BIT := '1';
VGA_VS : out BIT := '1';
DEB1 : out INTEGER;
DEB2 : out INTEGER
);
end vgatest;
architecture vtbehav of vgatest is
signal C25 : bit := '0';
signal H_READY : boolean := true;
signal V_READY : boolean := true;
signal H_CNT : integer := 0;
signal V_CNT : integer := 0;
signal RDATA, GDATA, BDATA: UNSIGNED(3 downto 0) := "1111";
begin
process(C50)
begin
if C50'event and C50 = '1' then
C25 <= not(C25);
end if;
end process;
process(C25)
begin
if C25'event and C25 = '1' then
if H_READY and V_READY then
VGA_R <= "0000";
VGA_G <= "0000";
VGA_B <= "1111";
end if;
H_CNT <= H_CNT + 1;
--HSYNC
if H_CNT = 640 then
H_READY <= false;
elsif H_CNT = 660 then
VGA_HS <= '0';
elsif H_CNT = 755 then
VGA_HS <= '1';
elsif H_CNT = 800 then
H_READY <= true;
H_CNT <= 0;
V_CNT <= V_CNT + 1;
end if;
end if;
end process;
process(C25)
begin
if C25'event and C25 = '1' then
--VSYNC
if V_CNT = 480 then
V_READY <= false;
elsif V_CNT = 494 then
VGA_VS <= '0';
elsif V_CNT = 496 then
VGA_VS <= '1';
elsif V_CNT = 528 then
V_READY <= true;
end if;
end if;
end process;
DEB1 <= H_CNT;
DEB2 <= V_CNT;
end vtbehav;