Forum Discussion
Altera_Forum
Honored Contributor
18 years agoDE2 board VGA Dispaly
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. Thanks42 Replies
- Altera_Forum
Honored Contributor
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. - Altera_Forum
Honored Contributor
yes, this is very clear. Many Thanks...
I looked into it, my problem is in generating the image from my Matlab file. Thanks - Altera_Forum
Honored Contributor
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 - Altera_Forum
Honored Contributor
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. - Altera_Forum
Honored Contributor
I also meet with it.
- Altera_Forum
Honored Contributor
--- 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 - Altera_Forum
Honored Contributor
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. - Altera_Forum
Honored Contributor
Thanks, It's useful for me!
- Altera_Forum
Honored Contributor
--- 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.. - Altera_Forum
Honored Contributor
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..... :(