Intel® FPGA University Program
University Program Material, Education Boards, and Laboratory Exercises

DE2 board VGA Dispaly

Altera_Forum
Honored Contributor II
6,453 Views

Hello All, 

 

I am trying to use the board's SRAM to store an image and dispaly it on the screen.  

I designed a project using QuartusII and was able to manage the 

VGA dispaly timing. I used a reference design from John Loomis Webpage. 

http://www.johnloomis.org/digitallab/vgalab/vgalab3/vgalab3.html which  

is very helpful and nice. However, I am having a problem in dowloading the 

raw image file to the SRAM. My question is:  

How can I get a typical 640 X 480 bitmap image to be stored in the SRAM?  

I tried to use Terasic ImgConv, but it doesn't work :(  

 

I appricate your help. 

 

Thanks
0 Kudos
42 Replies
Altera_Forum
Honored Contributor II
437 Views

Hi Monish. 

Obviously you did a mistake (if you see it dark), or, you are not catching the correct order pixel image. You'll need your image in 8bit gray scale to do that. We're comming back to the first part of the problem, I ask you, How do you get the correct pixels image in SRAM ?? 

 

Let me explain why the shift by 2. 

 

The ADV7123 DAC VGA chip of the DE2 board have three inputs of 10 bit wide each. They are R9-R0, G9-G0, and B9-B0. 

IF you have per example (taking R input only in this example), all bits R9-R0 in "0", the R output will be off, but if you have all bits R9-R0 in "1" you'll have the maximun bright in the R channel output. (This is for 1023 dec.) 

 

OK, If your data for R channel is 255 := 8'b11111111 you'll want maximun bright in the R output, but your DAC chip needs this: 10'b1111111111, so to aproximate to this, you'll need to get this: 10'b1111111100, and how to get that ? 

This is shifting by 2 your eight bit data. 

Do that for all R,G,B channels, and you'll get almost a "white pixel" for your RGB data in "255" each one of them. 

 

Is it clear now ? 

 

Cheers. 

Alberto.
0 Kudos
Altera_Forum
Honored Contributor II
437 Views

yes, this is very clear. Many Thanks... 

 

I looked into it, my problem is in generating the image from my Matlab file. 

 

Thanks
0 Kudos
Altera_Forum
Honored Contributor II
437 Views

BTW, I tried this and I got the picture little brighter.... 

VGA_R <= {2'b11, ROM_DATA}; 

VGA_B <= {2'b11, ROM_DATA}; 

VGA_G <= {2'b11, ROM_DATA}; 

 

Here is my Matlab file. I don't see anything wrong with ?!! 

 

 

%% read the image and show it 

 

name = 'anouv1'; 

img = imread(strcat(name,'.gif')); 

g = im2double(img); 

g = g/max(max(g)); 

rgb = cat(3,g,g,g); 

imshow(rgb); 

 

%% insert into 640 x 480 region 

 

out = ones(480,640); 

out(10+(1:460),90+(1:460)) = img; 

imshow(out); 

 

%% print pixels 

 

x = out'; 

x = uint8(x(: ) ); 

fid = fopen(strcat(name,'.txt'),'w'); 

fprintf(fid,'%X ',x); 

fclose(fid);  

 

 

 

 

Many Thanks
0 Kudos
Altera_Forum
Honored Contributor II
437 Views

Hi Monish. 

Wrong, you should do this: 

VGA_R <= ROM_DATA << 2; 

VGA_B <= ROM_DATA << 2; 

VGA_G <= ROM_DATA << 2; 

 

SHIFT LEFT data, Not concatenate data.
0 Kudos
Altera_Forum
Honored Contributor II
437 Views

I also meet with it.

0 Kudos
Altera_Forum
Honored Contributor II
437 Views

 

--- Quote Start ---  

Hi monish 

You don't explain, if you want o show a RGB image in the VGA.... 

I tried the same as you, but I began showing a 320x240 8bit grayscale, with my own code in the FPGA. Also, I did a RS232 comunication to pass the data from my PC to the DE2 board, and a simple software in my PC to extract the bmp header from the file to send, and send all usefull bytes of the bmp file to DE2. It's quiet easy. (Avoiding the DE2 control panel use) 

 

Then I did the same, but in 320x240 pixeles in RGB, obviously I use the DE2 on board SRAM to store the image data in both cases, all was succesufully. And all this for like a "learn practique". 

 

To show a 640x480 pixeles in RGB mode on VGA, SRAM is out of space, so I decided to use SDRAM to store the data, I'm trying this now...but I still can't get manage the SDRAM data as fast as I need. 

If you want, or ask some about the FPGA code...I can post it (But I'm so begginer like you...so maybe my code is not very "academic") 

--- Quote End ---  

 

 

Hello BXTsistemas, 

I was wondering if you could post an english version of your file? Also, does it include the your program of transferring the image from pc to the board? I'm just working on using the D5M camera module to capture an image to the sdram, but this is proving quite an obstacle. Any pointers on how i can learn more about it? 

 

Thanks so much
0 Kudos
Altera_Forum
Honored Contributor II
437 Views

Hi ayhoung. 

Sorry I've not an English version of the code, and I'm very short of time now. 

Neither I've a finished software to transfer the data, but you can do it easily in VB or any programming language. 

Just try to understand how my code works, it is very simple, I did that when I was beggining to learn about this theme. 

 

Regards. 

Alberto.
0 Kudos
Altera_Forum
Honored Contributor II
437 Views

Thanks, It's useful for me!

0 Kudos
Altera_Forum
Honored Contributor II
437 Views

 

--- Quote Start ---  

 

Also, I did a RS232 comunication to pass the data from my PC to the DE2 board, and a simple software in my PC to extract the bmp header from the file to send, and send all usefull bytes of the bmp file to DE2. It's quiet easy. (Avoiding the DE2 control panel use) 

 

 

--- Quote End ---  

 

 

This is exactly what I'm trying to do now. 

The VGA section works well. But the UART..., I have problems with UART code. About this problem, I have opened a topic today entitled "randomly occuring UART reception problem" 

After that, I will try to establish communication between FPGA and SRAM. 

Good Luck..
0 Kudos
Altera_Forum
Honored Contributor II
437 Views

Google man, google, & take a look at OpenCores.org. 

Also, you can download some examples for another boards, and then try to adapt it to yours. 

 

Sorry this answer is for another thread..... :(
0 Kudos
Altera_Forum
Honored Contributor II
437 Views

Hi fadd 

Right now I'm going out for vacations, contact me again in June. 

Anyway I have not an english version for that code (sorry that was a mistake from me). 

But later, if I have some free time, I will translate it. 

 

To get the camera image through VGA output, I recomend you to test the DE2_TV code (provided with the DE2 board), maybe that is exactly what you want to do. 

 

Cheers. 

Alberto.
0 Kudos
Altera_Forum
Honored Contributor II
437 Views

hy Monish! 

I started to develop an image processing desing using DE2. now i want to design a SRAM controller and I have a little problem. I don't know exactly if a SRAM location stores 2 consecutive pixels or only one. so please give me an answer. I suppose it's a simple problem for you.
0 Kudos
Altera_Forum
Honored Contributor II
437 Views

hi,BTXSistemas.I tried your code about 320x240 24 bit RGB image. 

However,it't didn't work 

My topic is:i want to display 256x256 x 24bit RGB, i use DE2 control panel to send directly my data of image to Sram DE2 board.However, i can't display the image from Sram to Vga...i need your help ..May be you can resend your another code or explain more carefully for me the way to solve that problem 

thanks alot 

 

 

 

--- Quote Start ---  

Hi. 

Here´s some code to try the 320x240 image. 

Let me know if it was usefull. 

--- Quote End ---  

0 Kudos
Altera_Forum
Honored Contributor II
437 Views

Hi, the code I posted should work fine, please let me know where is your problem, or what is your exactly problem to show the image. 

Cheers. 

Alberto.
0 Kudos
Altera_Forum
Honored Contributor II
437 Views

Hello, please help me..!! Now Im doing a proyect where i have to save a image in sdram , it s the first thing that i have to do..!! can you help how can i do it..!! i can use anyway to sa ve the image in sdram and after read fron nios ii with de2 altera.. help me

0 Kudos
Altera_Forum
Honored Contributor II
437 Views

Dear. 

Download the sample code, modify it, and voila !! :) 

I can't do your homework sorry.. 

 

 

--- Quote Start ---  

Hello, please help me..!! Now Im doing a proyect where i have to save a image in sdram , it s the first thing that i have to do..!! can you help how can i do it..!! i can use anyway to sa ve the image in sdram and after read fron nios ii with de2 altera.. help me 

--- Quote End ---  

0 Kudos
Altera_Forum
Honored Contributor II
437 Views

Hi BTXSistemas,  

 

Thanks for sharing your code, it was quite useful to me.  

I am sending images from memory to compress them via JPEG200 standard (using ADV212 IC), but as you said, SRAM is too small to hold images greather than 240x320 pixels. 

 

Can you tell about your experience using SDRAM? 

 

Regards,
0 Kudos
Altera_Forum
Honored Contributor II
437 Views

 

--- Quote Start ---  

Hi BTXSistemas,  

 

Thanks for sharing your code, it was quite useful to me.  

I am sending images from memory to compress them via JPEG200 standard (using ADV212 IC), but as you said, SRAM is too small to hold images greather than 240x320 pixels. 

 

Can you tell about your experience using SDRAM? 

 

Regards, 

--- Quote End ---  

 

Just use a SDRAM core... to use the DE2 SDRAM instead SRAM...it's not so difficult. I only used them inside NIOS, but as video memory, SRAM is the best, don't forget "read speed" :)
0 Kudos
Altera_Forum
Honored Contributor II
437 Views

 

--- Quote Start ---  

Hi. 

Here´s some code to try the 320x240 image. 

Let me know if it was usefull. 

--- Quote End ---  

 

 

Hello, i had been reading about this subject, so my question is: does this code works on De0 Nano SoC? I'm working on a school project and i hadn't found any helping information about this FPGA (De0 Nano Soc) and trdb d5m
0 Kudos
Altera_Forum
Honored Contributor II
434 Views

Hey dekiks12,  

 

If you want to interface to the d5M camera module, there is examples in the rocketboard.org  

 

If you are after interfacing to vga, the de0-soc board does not have a vga output, so presumably you are interested in some other clocked video output.  

 

I have connected my de1-soc board to the MT2 board and created a video of how to do it - it builds upon the Altera tutorials 

 

[video]https://youtu.be/7sNJ5Tf1gAE[/video] 

 

I hope that helps.
0 Kudos
Altera_Forum
Honored Contributor II
434 Views

Hello thanks for answering, actually i have a code that i found on rockets boards "VIP camera", it works fine. I tryed to add an LCD to whatch the video output but i couldn´t. I´m new on video processing and i got a new more question: do you know how can i get a image frame capture or how can i get access to the RAM memory and extract an image? Thanks a lot.

0 Kudos
Reply