Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - VHDL VGA controller

 
Thread Tools Search this Thread
Old 06-11-2007, 10:10 PM   #1
Default VHDL VGA controller


I've been working on a VGA controller on a DE2 for a while and I can't get the sync to work right. When I connect this to a monitor, the monitor says "out of range" meaning it's getting the signal, but the sync timing seems to be wrong. For the clock, I'm sending a 50 MHz clock through a PLL that brings it down to 25MHz and the resolution is 640 x 480. Can anyone recommend anything to fix it?


library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.STD_LOGIC_ARITH.all;
use IEEE.STD_LOGIC_UNSIGNED.all;

Entity VGA_ctrl IS
port( key: IN std_logic_vector(3 DOWNTO 0);
LEDR: OUT std_logic_vector(17 DOWNTO 0);
LEDG: OUT std_logic_vector(8 DOWNTO 0);
clock_50: IN std_logic;
VGA_R, VGA_G, VGA_B: OUT std_logic_vector(9 DOWNTO 0);
VGA_HS, VGA_VS, VGA_SYNC, VGA_CLK, VGA_BLANK: OUT std_logic;
pixel_row, pixel_column: OUT std_logic_vector(9 DOWNTO 0));
end vga_ctrl;

Architecture a of vga_ctrl is
signal horiz_sync, vert_sync, pixel_clock: std_logic;
signal video_on, video_on_v, video_on_h: std_logic;
signal h_count, v_count: std_logic_vector(9 DOWNTO 0);
signal clock: std_logic;
signal red, green, blue: std_logic_vector(9 DOWNTO 0);

constant h_pixels_across: Natural:=640;
constant h_sync_low: Natural:=664;
constant h_sync_high: Natural:=760;
constant h_end_count: Natural:=800;

constant v_pixels_down: Natural:=480;
constant v_sync_low: Natural:=491;
constant v_sync_high: Natural:=493;
constant v_end_count: Natural:=525;

COMPONENT video_PLL
PORT
(
inclk0 : IN STD_LOGIC := '0';
c0 : OUT STD_LOGIC
);
end component;


Begin

video_pll_inst : video_pll PORT MAP (
inclk0 => clock_50,
c0 => clock
);

VGA_clk<= not clock;
VGA_SYNC<='1';
video_on<= (video_on_h and video_on_v);
vga_blank<= not video_on;


Process
Begin

Wait Until (clock'EVENT) and (clock='1');

If (h_count = h_end_count) Then
h_count <= "0000000000";
Else
h_count <= h_count+1;
End If;

If (v_count = v_end_count) and (h_count >= h_sync_low) Then
v_count <= "0000000000";
Elsif (h_count >= h_sync_low) then
v_count <= v_count+1;
End If;

If (h_count <= (H_sync_high)) and (h_count >= (H_sync_low)) Then
horiz_sync<='0';
Else
horiz_sync<='1';
End If;


If (v_count <= (V_sync_high)) and (v_count >= (v_sync_low)) Then
vert_sync<='0';
Else
vert_sync<='1';
End If;


If (h_count < h_pixels_across) Then
video_on_h<='1';
pixel_column<= h_count;
Else
video_on_h <= '0';
End If;


If (v_count <= v_pixels_down) Then
video_on_v<='1';
pixel_row<= V_count;
Else
video_on_v <='0';
End If;


VGA_HS <= horiz_sync;
VGA_VS <= vert_sync;

If video_on = '1' Then
red<="1111100100";
green<="1111100100";
blue<="1111100100";
Else
red<="0000000000";
green<="0000000000";
blue<="0000000000";
End If;

VGA_R<=red;
VGA_G<=green;
VGA_B<=blue;

End Process;
End a;


dashdingo
dashdingo is offline   Reply With Quote
Old 06-12-2007, 04:34 AM   #2
quantum_dot
Member
 
Join Date: Nov 2006
Posts: 32
Default
I've been working on a VGA controller on a DE2 for a while and I can't get the sync to work right. When I connect this to a monitor, the monitor says "out of range" meaning it's getting the signal, but the sync timing seems to be wrong. For the clock, I'm sending a 50 MHz clock through a PLL that brings it down to 25MHz and the resolution is 640 x 480. Can anyone recommend anything to fix it?

Its difficult to find the cause of error by going through your source code. Have you tried to simulate it ? When the monitor says "out of range" does it refers to Vsync or Hsync ? It may be possible that the Vsync or Hsync is being counted wrong. But this can only be checked through simulation.

One more thing. I would suggest you to use DCM instead of PLL for generating clock freq. DCM can support a min of 25 MHz, so it should not be a problem.



quantum_dot
quantum_dot is offline   Reply With Quote
Old 11-23-2008, 02:33 AM   #3
jpk216
Junior Member
 
Join Date: Nov 2008
Posts: 2
Default Check your number of lines
Every time I have written a VGA driver it has always been 521 lines, not 524. That could be why you are getting the out of ranger error.


jpk216
jpk216 is offline   Reply With Quote
Old 11-23-2008, 02:43 AM   #4
jpk216
Junior Member
 
Join Date: Nov 2008
Posts: 2
Post
Instead of 525, sorry about that.

I know it is not a big issue at the moment but you may end up with timing issues later one. First, putting all of the code in a singe process with a wait statement at the beginning is a very bad coding practice. It will also give you trouble when you try and place and route it when the design gets larger. Also, since everything is in a sequential process the values do not update until the following clock cycle. That is what you normally want but in your case where you check the video_on signal, then assign the colors values, and then assign the colors to VGA_colors. It may look like everything works at first but you actually may be a column or two off.


jpk216
jpk216 is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to execute an external software from VHDL? And how to interface VHDL with JAVA? becool_nikks Software 0 03-06-2009 07:08 PM
plz post the vhdl code for dma controller 8257 with description(very urgent.....plz) vijaygubba General Help Related Topics 0 02-04-2008 02:31 PM
Help on auto conversion from Matlab to vhdl on filter design hardheart Hardware 0 12-07-2007 09:19 AM
ARRAY(n DOWNTO 0) OF STD_LOGIC_VECTOR(m DOWNTO 0) - VHDL freitass Hardware 0 11-01-2007 03:44 PM
Number of EIDE Drives Per Controller JesseTX A+ Certification 5 10-24-2003 10:30 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46