EmbDev.net

Forum: FPGA, VHDL & Verilog Display 640x480 Nexys 3 board


von sketchy (Guest)


Rate this post
useful
not useful
I've been trying to display something with a vga. I wanted a signal 640 
x 480 @ 60 Hz.
So what I have so far in my code: Implemented the clk signal, the red, 
blue, green, hsync and vsync. Using a Clocking Wizard I made the 
25.175MHz needed from 100MHz(nexys 3 board) then the hcounter and 
vcounter but this is where I get lost, when I have to asign the 1's  to 
all RGB signals I kinda don't know where I need to use it to make it 
work.

Also the timing I got it from here 
http://tinyvga.com/vga-timing/640x480@60Hz

.ucf
1
--------------------------------------------------------
2
NET "clk" LOC = V10;
3
4
NET "red[0]" LOC = U7;
5
NET "red[1]" LOC = V7;
6
NET "red[2]" LOC = N7;
7
8
NET "green[0]" LOC = P8;
9
NET "green[1]" LOC = T6;
10
NET "green[2]" LOC =  V6;
11
12
NET "blue[1]" LOC = R7;
13
NET "blue[2]" LOC = T7;
14
15
16
NET "Hsync" LOC = N6;
17
NET "Vsync" LOC = P7;
18
--------------------------------------------------------

.vhd
1
---------------------------------------------------------
2
library IEEE;
3
use IEEE.STD_LOGIC_1164.ALL;
4
use IEEE.NUMERIC_STD.ALL;
5
use IEEE.STD_LOGIC_UNSIGNED.ALL;
6
7
entity vgax is
8
    Port ( clk : in  STD_LOGIC;
9
           Hsync : out  STD_LOGIC;
10
           Vsync : out  STD_LOGIC;
11
           red : out  STD_LOGIC_VECTOR (2 downto 0);
12
           green : out  STD_LOGIC_VECTOR (2 downto 0);
13
           blue : out  STD_LOGIC_VECTOR (2 downto 1));
14
end vgax;
15
16
architecture Behavioral of vgax is
17
COMPONENT dcmx
18
port(CLK_IN1 : in std_logic;
19
    CLK_OUT1 : out std_logic);
20
END COMPONENT;
21
22
signal clk25M : std_logic;
23
signal hcounter : std_logic_vector(9 downto 0) := (others => '0');
24
signal vcounter : std_logic_vector(9 downto 0) := (others => '0');
25
26
begin
27
Inst_dcmx: dcmx PORT MAP(
28
     CLK_IN1 => clk,
29
     CLK_OUT1 => clk25M
30
);
31
32
--process(hcounter,vcounter)
33
--end process;
34
35
process(clk25m)
36
   begin
37
  ------------------------------------------
38
     if clk25M'event and clk25M = '1' then
39
       if hcounter = 799 then
40
         hcounter <= (others => '0');
41
         if vcounter = 524 then
42
           vcounter <= (others => '0');
43
         else
44
           vcounter <= vcounter+1;
45
         end if;
46
       else
47
         hcounter <= hcounter+1;
48
       end if;
49
  ---------------------------------------  
50
  
51
    ----------------------
52
    if hcounter > 656 and hcounter < 752 then
53
    hsync<='0';
54
    else
55
    hsync<='1';
56
    end if;
57
  
58
    if vcounter > 490 and vcounter < 491 then
59
    vsync <='0';
60
    else 
61
    vsync <='1';
62
    end if;
63
    ------------------------------------
64
    --He I want to make it always display the white colour 
65
    ---------------------------------------
66
    if hcounter < 640 and vcounter < 480 then
67
    red<= "111";
68
    green<="111";
69
    blue<="11";
70
    hsync<='1';
71
    vsync<='0';
72
    else
73
    red<= "111";
74
    green<="111";
75
    blue<="11";
76
    hsync<='1';
77
    vsync<='0';
78
    end if;
79
    -------------------------------------------
80
    
81
    
82
    end if;
83
end process;
84
85
end Behavioral;
86
---------------------------------------------------------



The result of this is nothing displayed at the screen.

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
sketchy wrote:
> The result of this is nothing displayed at the screen.
What does the simulation show?
Do you have a scope to measure the signals?

> Using a Clocking Wizard I made the 25.175MHz needed from 100MHz(nexys 3
> board)
And does it work correctly? Do you get the desired 25MHz? If you don't 
have a scope just count to 12500000 and toggle a LED. It should flash 
each second...
BTW: it would be slightly easier to only generate a 25MHz clock enable 
out of the 100MHz. The VGA will cope up with that slight deviation...

Why that:
1
use IEEE.NUMERIC_STD.ALL;
2
use IEEE.STD_LOGIC_UNSIGNED.ALL;
With this you may have some kind of strange errror messages due to 
double definitions of data types. Use the numeric_st alone. And use 
integer for counters!

von sketchy (Guest)


Rate this post
useful
not useful
Lothar Miller wrote:
> What does the simulation show?
> Do you have a scope to measure the signals?

No I don't have it.

Lothar Miller wrote:
> BTW: it would be slightly easier to only generate a 25MHz clock enable
> out of the 100MHz. The VGA will cope up with that slight deviation...

How I'm supposed to do this?

Lothar Miller wrote:
> Why that:use IEEE.NUMERIC_STD.ALL;
> use IEEE.STD_LOGIC_UNSIGNED.ALL;
> With this you may have some kind of strange errror messages due to
> double definitions of data types. Use the numeric_st alone. And use
> integer for counters!

To be able to do numeric operations on STD_LOGIC_VECTOR signals.

I don't have much reference, just my nexys 3 manual to follow, I'm 
trying to figuring it out how to make it on my own but it would be nice 
you could provide me some reference links. I'm very new with VHDL.

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
sketchy wrote:
> To be able to do numeric operations on STD_LOGIC_VECTOR signals.
Don't do calculations with unconstrained std_logic_vectors! Never!!
You don't know, what number a bit pattern in a std_logic_vector 
represents! For example: what number is this "1001" here? Is it 9 or is 
it -7? Both of them are right. Its just a different interpretation of 
that bit pattern.

So use the numeric_std and the integer data type for counters. Or at 
least the unsigned data type...

> I'm very new with VHDL.
Did you do the flashing light and the cahsing light already? Do you 
simulate your designs? If "No" for either case, then do it!

Try Google translator, its German:
http://www.lothar-miller.de/s9y/archives/80-Hello-World!.html
http://www.lothar-miller.de/s9y/archives/61-Lauflicht.html
http://www.lothar-miller.de/s9y/archives/81-Xilinx-ISE-Step-by-Step.html

sketchy wrote:
>> generate a 25MHz clock enable out of the 100MHz.
> How I'm supposed to do this?
See the Hello-World code above. Theres a clock divider generating a 
clock enable inside.

von peter (Guest)


Rate this post
useful
not useful
Der Ausländer möchte kein Lauflicht, der möchte das sein VGA-Gebilde ein 
Bild anzeigt was er gebastelt hat.

Immer diese Lauflichter...das bringt doch nichts, ist nur 
Zeitverschwendung mit so einem Zeugs weiterzuhelfen, das kannst du da 
einstampfen.

Gruss

von -gb- (Guest)


Rate this post
useful
not useful
There are 800x600 with 50MHz and 1024x768 with 75MHz.

von peter (Guest)


Rate this post
useful
not useful
Hier..., aber nicht nach China schicken...
Ist für eine DE0/DE1, kannste auch für dich umstricken.
VGA 640x480.
1
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
use ieee.numeric_std.ALL;
4
5
entity vga_timing1 is
6
port(
7
  clk50_in  : in std_logic;
8
  hs_out    : out std_logic;
9
  vs_out    : out std_logic;
10
  
11
  red_out   : OUT STD_LOGIC_VECTOR(3 downto 0);
12
  green_out : OUT STD_LOGIC_VECTOR(3 downto 0);
13
  blue_out  : OUT STD_LOGIC_VECTOR(3 downto 0)
14
  ); 
15
end vga_timing1;
16
17
architecture behavioral of vga_timing1 is
18
19
signal clk25    : std_logic:='0';
20
signal hcounter : integer := 0;
21
signal vcounter : integer := 0;
22
23
begin
24
25
process (clk50_in)
26
begin
27
  if rising_edge(clk50_in) then
28
    clk25 <= not clk25;
29
  end if;
30
end process;
31
32
process (vcounter,hcounter)
33
begin
34
  if vcounter<480 then
35
    if (hcounter >=  0 and hcounter <= 160) then
36
      red_out<="1000";
37
    else
38
      red_out<="0000";
39
    end if;
40
    
41
    if (hcounter >= 160 and hcounter <= 320) then
42
      green_out<="1000";
43
    else
44
      green_out<="0000";
45
    end if;
46
    
47
    if (hcounter >= 320 and hcounter <= 480) then
48
      blue_out<="1000";
49
    else
50
      blue_out<="0000";
51
    end if;  
52
    
53
    if (hcounter >= 480 and hcounter <= 640) then
54
      red_out<="1000";
55
      green_out<="1000";
56
      blue_out<="1000";
57
    end if;
58
  end if;
59
end process;
60
61
process (clk25)
62
begin
63
  if rising_edge(clk25) then
64
    if hcounter >= (639+16) and hcounter <= (639+16+96) then
65
      hs_out <= '0';
66
    else
67
      hs_out <= '1';
68
    end if;
69
  
70
    if vcounter >= (479+10) and vcounter <= (479+10+2) then
71
      vs_out <= '0';
72
     else
73
      vs_out <= '1';
74
    end if;
75
  
76
--- horizontal counts from 0 to 799
77
    hcounter <= hcounter+1;
78
  
79
    if hcounter = 799 then
80
      vcounter <= vcounter+1;
81
      hcounter <= 0;
82
    end if;
83
  
84
--- vertical counts from 0 to 524
85
    if vcounter = 524 then 
86
      vcounter <= 0;
87
    end if;
88
  end if;
89
end process;
90
91
end behavioral;

von -gb- (Guest)


Rate this post
useful
not useful
Peter, es gibt hier zwei Möglichkeiten:

- Man kann eine fertige Lösung geben.
- Man kann dem Fragenden Hilfen geben, dass er das Problem selber lösen 
kann.

Vielleicht sollte man den Fragenden fragen was er will. Hier wird 
meistens so geantwortet, dass der Fragende auch etwas lernt. Will man 
eine Hardwarebeschreibungssprache lernen, dann geht das eben bei ganz 
einfachen Dingen los wie der blinkenden LED und dem Lauflicht.

Auch wenn du jetzt zwar ein Bild ausgeben kannst, hast du trotzdem noch 
kein VHDL gelernt und wirst andere sogar leichtere Aufgaben nicht ohne 
Hilfe lösen können.

Ich habe auch zu Beginn mit Vektoren gerechnet, aber das war ein 
Holzweg. Das hat mir damals auch Lothar gesagt.

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
-gb- wrote:
> Vielleicht sollte man den Fragenden fragen was er will.
Und vor Allem auf ENGLISCH.
@peter: Dies hier ist nicht umsonst die englische Abteilung des Forums!! 
Wenn du kein Englisch kannst, oder es nicht verwenden willst, dann lass 
hier die Finger raus. Ich werde in Zukunft jeden dieser ignoranten Posts 
hier löschen.

@all:
peter is one of the little obtrusive mannerless guys here. I told him to 
do any futher conversation in English. Otherwise I will delete those 
ignorant posts.

peter wrote:
> process (clk50_in)
> begin
>   if rising_edge(clk50_in) then
>     clk25 <= not clk25;
>   end if;
> end process;
This ist NO WAY to generate a CLOCK. Read the warnings and infos of the 
synthesis tool!

Clocks are generated either by a clock manager, or the easier way: by 
clock enables. The easiest design on a FPGA has exactly 1 clock. And the 
rest is done by clock enables...

peter wrote:
> Der Ausländer möchte kein Lauflicht, der möchte das sein VGA-Gebilde ein
> Bild anzeigt was er gebastelt hat.
Peter, I can read and understand English very well. And I see, what 
sketchy WANTS, but also I must tell him some words about the "better 
way". You throw a piece of code to him without the faintest hint, what 
this snippet does (I know it very well, you got it to 90% from me! 
Remember?). And then you did not even correct the problem with the clock 
generation...

: Edited by Moderator
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.