UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Observer urmilagavale
Observer
17,280 Views
Registered: ‎05-20-2014

display image on monitor using spartan3E

I have stored pixels of image on bram using .coe file. now i want to display image on monitor but i am not getting how to do exactly that. i have read some tutorials on vga controller. but my problem is that after writing a code for vga controller, where to assign my bram output which are the pixels of image ,to show image on monitor.Even i am not getting how to write ucf file. i need a guidence.

0 Kudos
22 Replies
Contributor
Contributor
17,272 Views
Registered: ‎09-10-2012

Re: display image on monitor using spartan3E

Hi Urmila,

 

1. VGA Controller is basically a video timing generator which generates video timing parameters

  a. Pixel clock

  b. Hsync

  c. Vsync

  e. Video enable

  f.  Pixel data

 

 2.Since your image is stored in the BRAM,you need to write BRAM read control logic and

    you should synchronize the read data with the timing generated by the VGA Controller(pixel data and video enable should be     alligned).

 

 3. You could use the video enable generated by the VGA controller as read enable for BRAM to read the pixel data .

     (here you may need to  insert delays to video parameters so as to make the read data from BRAM in sync with the video             timing parameters before driving the display)..    

 

Hope this helps.

 

Thanks,
Aneesh.
0 Kudos
Observer urmilagavale
Observer
17,269 Views
Registered: ‎05-20-2014

Re: display image on monitor using spartan3E

ok i will try to write a code. thank you for reply.

0 Kudos
Xilinx Employee
Xilinx Employee
17,264 Views
Registered: ‎08-01-2008

Re: display image on monitor using spartan3E

this seems good link

 

http://www.eetimes.com/document.asp?doc_id=1274613

Thanks and Regards
Balkrishan
--------------------------------------------------------------------------------------------
Please mark the post as an answer "Accept as solution" in case it helped resolve your query.
Give kudos in case a post in case it guided to the solution.
Observer urmilagavale
Observer
17,229 Views
Registered: ‎05-20-2014

Re: display image on monitor using spartan3E

I have written the following code. In which i am reading pixels stored in bram. but can you tell whether i am right or not?

----------------------------------------------------------------------------------
-- Company: 
-- Engineer: 
-- 
-- Create Date:    13:59:44 05/27/2014 
-- Design Name: 
-- Module Name:    maincode - Behavioral 
-- Project Name: 
-- Target Devices: 
-- Tool versions: 
-- Description: 
--
-- Dependencies: 
--
-- Revision: 
-- Revision 0.01 - File Created
-- Additional Comments: 
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;

-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity maincode is
port( 
clk   : in std_logic;
rst   : in std_logic;
hs_out: out std_logic;
vs_out: out std_logic;
red   : out std_logic_vector(1 downto 0);
green : out std_logic_vector(1 downto 0);
blue  : out std_logic_vector(1 downto 0);
Address : out STD_LOGIC_VECTOR(9 DOWNTO 0)
);
end maincode;

architecture Behavioral of maincode is
    signal wea :  STD_LOGIC_VECTOR(0 DOWNTO 0):="0";
    signal addra :  STD_LOGIC_VECTOR(9 DOWNTO 0):="0000000000";
    signal dina :  STD_LOGIC_VECTOR(7 DOWNTO 0):="00000000";
    signal douta :  STD_LOGIC_VECTOR(7 DOWNTO 0):="00000000";
    signal pclk:  STD_LOGIC;
    signal pixel_data: std_logic_vector(7 downto 0);
    signal hcounter : integer range 0 to 800;
    signal vcounter : integer range 0 to 521;
    
	 
COMPONENT input_image    ----component(bram) declaration.
  PORT (
    clka : IN STD_LOGIC;
    wea : IN STD_LOGIC_VECTOR(0 DOWNTO 0);
    addra : IN STD_LOGIC_VECTOR(9 DOWNTO 0);
    dina : IN STD_LOGIC_VECTOR(7 DOWNTO 0);
    douta : OUT STD_LOGIC_VECTOR(7 DOWNTO 0)
  );
END COMPONENT;

begin

process (clk)
begin
  if clk'event and clk='1' then
    if (pclk = '0') then
      pclk <= '1';
    else
      pclk <= '0';
    end if;
  end if;
end process;

your_instance_name : input_image   ---bram instantiation
  PORT MAP (
    clka => clk,
    wea => wea,
    addra => addra,
    dina => dina,
    douta => douta  --pixel out from bram
  );

add_inc: Process(pclk,rst)    --- process to increment address of bram in which pixels are stored.
 begin
 if rst='1' then 
 addra<= (others=>'0');
 elsif pclk ='1' and pclk'event then
 addra <=STD_LOGIC_VECTOR((addra)+1);
 Address<=addra;
 end if;
 end process;
 pixel_data <= douta;                         -- bram out pixels are assigned to pixel_data
 
p2: process (pclk, hcounter, vcounter)
variable x: integer range 0 to 639;
variable y: integer range 0 to 479;
begin
-- hcounter counts from 0 to 799
-- vcounter counts from 0 to 520
-- x coordinate: 0 - 639 (x = hcounter - 144, i.e., hcounter -Tpw-Tbp)
-- y coordinate: 0 - 479 (y = vcounter - 31, i.e., vcounter-Tpw-Tbp)
x := hcounter - 144;
y := vcounter - 31;
if pclk'event and pclk = '1' then
-- To draw a pixel in (x0, y0), simply test if the ray trace to it
-- and set its color to any value between 1 to 7. The following example simply sets 
-- the whole display area to a single-color wash, which is changed every one 
-- second. 
if x < 640 and y < 480 then
red <= pixel_data(1 downto 0);
green <= pixel_data(3 downto 2);
blue <= pixel_data(5 downto 4);
else
-- if not traced, set it to "black" color
red <= "00";
green <= "00";
blue <= "00";
end if;

-- Pulse width: Tpw = 96 cycles @ 25 MHz
-- Back porch: Tbp = 48 cycles
-- Display time: Tdisp = 640 cycles
-- Front porch: Tfp = 16 cycles
-- Sync pulse time (total cycles) Ts = 800 cycles

if hcounter > 0 and hcounter < 97 then
hs_out <= '0';
else
hs_out <= '1';
end if;
-- Pulse width: Tpw = 1600 cycles (2 lines) @ 25 MHz
-- Back porch: Tbp = 23200 cycles (29 lines)
-- Display time: Tdisp = 38400 cycles (480 lines)
-- Front porch: Tfp = 8000 cycles (10 lines)
-- Sync pulse time (total cycles) Ts = 416800 cycles (521 lines)
if vcounter > 0 and vcounter < 3 then
vs_out <= '0';
else
vs_out <= '1';
end if;
-- horizontal counts from 0 to 799
hcounter <= hcounter+1;
if hcounter = 800 then
vcounter <= vcounter+1;
hcounter <= 0;
end if;
-- vertical counts from 0 to 519
if vcounter = 521 then 
vcounter <= 0;
end if;
end if;
end process;


end Behavioral;

 

0 Kudos
Observer urmilagavale
Observer
17,228 Views
Registered: ‎05-20-2014

Re: display image on monitor using spartan3E

thank you i tried to write a code. can check it whether its correct or not?

0 Kudos
Historian
Historian
17,217 Views
Registered: ‎02-25-2008

Re: display image on monitor using spartan3E


urmilagavale wrote:

thank you i tried to write a code. can check it whether its correct or not?


Why haven't you simulated your code? That's a lot more effective than throwing it up on an Internet forum and asking others to verify it for you.

----------------------------Yes, I do this for a living.
0 Kudos
Observer urmilagavale
Observer
17,211 Views
Registered: ‎05-20-2014

Re: display image on monitor using spartan3E

Sorry, but i have simulated it and i got the results. But i am not getting whether it is write or not.

pixel_data in my code is bram output.

And by following assignment i am getting what i have written in assignment.

red <= pixel_data(1 downto 0);
green <= pixel_data(3 downto 2);
blue <= pixel_data(5 downto 4);

 

but my question is now that whether i am going in right direction to display image stored in bram?

0 Kudos
Observer urmilagavale
Observer
17,200 Views
Registered: ‎05-20-2014

Re: display image on monitor using spartan3E

now i have flashed my program on spartan 3E kit and connect laptop's monitor to kit via vga port. but my first problem is my laptop does not recognize connected device. i have vga driver installed already ,then also the same problem. where is the problem?plz guide

0 Kudos
Xilinx Employee
Xilinx Employee
17,197 Views
Registered: ‎08-01-2008

Re: display image on monitor using spartan3E

Can you please monitor HS and VS on scope . You can just generate some test pattern in FPGA and see if you can see something on scope. Assign "FF" monitor should look like white in this case.

Thanks and Regards
Balkrishan
--------------------------------------------------------------------------------------------
Please mark the post as an answer "Accept as solution" in case it helped resolve your query.
Give kudos in case a post in case it guided to the solution.
0 Kudos
Observer urmilagavale
Observer
10,692 Views
Registered: ‎05-20-2014

Re: display image on monitor using spartan3E

to monitor HS and VS on scope i have to use SMA connector? but how my problem of not detecting device will resolved then?

Tags (1)
0 Kudos
Xilinx Employee
Xilinx Employee
10,688 Views
Registered: ‎08-01-2008

Re: display image on monitor using spartan3E

It seems you have issue with device configuration. Check the cable connection. what is the error you are getting while target device configuration.

Is any other code working on your design . check with small code like counter .

VGA driver not needed here.

First you need to make sure you FPGA working condition and you can detect and configure correctly later we will see your specific code
Thanks and Regards
Balkrishan
--------------------------------------------------------------------------------------------
Please mark the post as an answer "Accept as solution" in case it helped resolve your query.
Give kudos in case a post in case it guided to the solution.
0 Kudos
Highlighted
Observer urmilagavale
Observer
10,684 Views
Registered: ‎05-20-2014

Re: display image on monitor using spartan3E

Yes sir, other codes like counter,AND gate are working on fpga. I m getting output on board.

I think the problem is with vga port and cable connection. i will check it again tommorow.

But i want to ask is it possible to display image on laptop's monitor through vga port. I have vga driver installed with my laptop,but  then also when i connect vga cable, i got a message that device not recognize. What can be the problem,i am not understanding.

0 Kudos
Xilinx Employee
Xilinx Employee
10,681 Views
Registered: ‎08-01-2008

Re: display image on monitor using spartan3E

It seems you don't have issue with FPGA configuration. I am not which laptop you and I am not sure whether it possible to input VGA input in Laptop,.

I think you can just use normal desktop PC monitor and configure your monitor for VGA .

The other test i had asked you in the morning . you just need to probe the HS and VS on CRO.
Thanks and Regards
Balkrishan
--------------------------------------------------------------------------------------------
Please mark the post as an answer "Accept as solution" in case it helped resolve your query.
Give kudos in case a post in case it guided to the solution.
0 Kudos
Xilinx Employee
Xilinx Employee
10,681 Views
Registered: ‎08-01-2008

Re: display image on monitor using spartan3E

Check this link

http://www.javiervalcarce.eu/wiki/VGA_Video_Signal_Format_and_Timing_Specifications
Thanks and Regards
Balkrishan
--------------------------------------------------------------------------------------------
Please mark the post as an answer "Accept as solution" in case it helped resolve your query.
Give kudos in case a post in case it guided to the solution.
0 Kudos
Observer urmilagavale
Observer
10,680 Views
Registered: ‎05-20-2014

Re: display image on monitor using spartan3E

Sorry but what do you mean by probe HS and VS on CRO. You mean i have to check HS(i.e hsync) and VS(vsync) on CRO using SMA connector? 

0 Kudos
Xilinx Employee
Xilinx Employee
10,678 Views
Registered: ‎08-01-2008

Re: display image on monitor using spartan3E

I meant horizontal sync(HS) and vertical sync(VS). Probe pin 13 and 14

Thanks and Regards
Balkrishan
--------------------------------------------------------------------------------------------
Please mark the post as an answer "Accept as solution" in case it helped resolve your query.
Give kudos in case a post in case it guided to the solution.
tt.jpg
0 Kudos
Observer urmilagavale
Observer
10,676 Views
Registered: ‎05-20-2014

Re: display image on monitor using spartan3E

ok..thank you.i will check it tomorrow in college.

0 Kudos
Historian
Historian
10,673 Views
Registered: ‎02-25-2008

Re: display image on monitor using spartan3E


@urmilagavale wrote:

now i have flashed my program on spartan 3E kit and connect laptop's monitor to kit via vga port. but my first problem is my laptop does not recognize connected device. i have vga driver installed already ,then also the same problem. where is the problem?plz guide


Why would you connect your laptop's VGA output to the Spartan 3E kit's VGA output?

----------------------------Yes, I do this for a living.
0 Kudos
Xilinx Employee
Xilinx Employee
10,666 Views
Registered: ‎08-01-2008

Re: display image on monitor using spartan3E

For now i believe you must try on some other monitor. You must have spare monitor on your college.

I think probing VGA on SCOPE will definitely help .

In case if you are not getting any output from FPGA board . You must need to check ucf file and your code.
Thanks and Regards
Balkrishan
--------------------------------------------------------------------------------------------
Please mark the post as an answer "Accept as solution" in case it helped resolve your query.
Give kudos in case a post in case it guided to the solution.
0 Kudos
Observer urmilagavale
Observer
6,870 Views
Registered: ‎05-20-2014

Re: display image on monitor using spartan3E

I think i have to check my code again as there is no output even if i changed the monitor.

0 Kudos
Xilinx Employee
Xilinx Employee
6,868 Views
Registered: ‎08-01-2008

Re: display image on monitor using spartan3E

please check the ucf first. You need verify ucf with board ucf.

Have you checked signals on scope.
Thanks and Regards
Balkrishan
--------------------------------------------------------------------------------------------
Please mark the post as an answer "Accept as solution" in case it helped resolve your query.
Give kudos in case a post in case it guided to the solution.
0 Kudos
5,697 Views
Registered: ‎06-11-2015

Re: display image on monitor using spartan3E

I am not familiar to FPGA this may be very basic but I understand that you have the stream of data transfering from the VGA port to the PC but its all zeros and ones how do you transfer those numbers to an image on the PC?

 

thanks

0 Kudos