Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
17244 Discussions

Read from sd card an image on DE2-115

Altera_Forum
Honored Contributor II
5,886 Views

Hello 

 

I am writing a pure verilog code reading an image from sd card which i will show on display(vga). 

Can anyone help me with it i can't find the way to start. 

 

Thank you A.A
0 Kudos
12 Replies
Altera_Forum
Honored Contributor II
4,376 Views

Not so easy, not so fast :-) 

 

Start with VGA signal synthesis: http://www.fpga4fun.com/ponggame.html 

Then move to SD card interfacing: http://opencores.org/project,sdcard_mass_storage_controller 

Then add a CPU system: NIOS 

Then add FAT file system: http://elm-chan.org/fsw/ff/00index_e.html 

 

From now on, it's all software stuff :-)
0 Kudos
Altera_Forum
Honored Contributor II
4,376 Views

Pretty good task for a pure verilog implementation. I'm assuming this means you can't instantiate a NIOS cpu core and write some C code. 

 

First things first, is how can you simply the problem. What Image format must it be in. If you can choose one, choose the simplest, (BMP or PPM), then if you don't have to have a FAT system, don't, just write the data raw to the SD card at a specific offset so you can READ it raw from the SD. 

 

Then store it in a faster memory, (internal if you can), so that you can loop the output and not have video underrun's when displaying the image. 

 

Once you have the simplest form running, you can start looking into more advanced features, like dealing with FAT tables, and different image formats, etc. 

 

Pete
0 Kudos
Altera_Forum
Honored Contributor II
4,376 Views

Hi Pete 

 

At first i am not using NIOS at all.  

I will choose simple image format as you told. Which is the best protocol to read from sd card and if you have some link with or without code to help me with. 

 

 

A.A
0 Kudos
Altera_Forum
Honored Contributor II
4,376 Views

The 'best' protocol for speed is to implement the nibble (4-bit) wide interface SD cards support. However, the 'best' protocol for simplicity (probably the one you want) is the standard SPI interface SD cards also support. 3 signals driven into the SD card (clock, data in and chip select) and one return signal (data out). All transactions are byte (8-bit) based. 

 

The following link takes you to a page with plenty of information on using the SPI protocol with SD cards: 

http://elm-chan.org/docs/mmc/mmc_e.html (http://elm-chan.org/docs/mmc/mmc_e.html

 

Assuming you run the interface at 25MHz and you store uncompressed data in the SD card, you should be able to read out a standard VGA image in around 30ms. Higher definition images will take proportionally longer.
0 Kudos
Altera_Forum
Honored Contributor II
4,376 Views

Thanks for the link it help me a lot ... now about vga i have to make 2 files? one for the sync and one for colours?

0 Kudos
Altera_Forum
Honored Contributor II
4,376 Views

I'm not sure you need two files. Every image will need to be driven to the display with the appropriate vertical & horizontal sync control. This timing control is more likely to come directly from the control logic in your FPGA. 

 

If you're only trying to display a simple colour bars image on screen then I'd suggest you don't even need an SD card to store it. Assuming that is what you intend, and you know the size of the image you're trying to deliver (e.g. VGA), then you can create a colour bars screen entirely in the FPGA. A small state machine or counter is used to deliver the correct number of pixels before changing colour. Vertical and horizontal sync signals will drop out from the same controlling logic. You will only need the storage if you're trying to store an image, rather than a regular pattern. 

 

Regards, 

Alex
0 Kudos
Altera_Forum
Honored Contributor II
4,376 Views

Thanks for the post Alex.  

i choose to have a simple image format which i will show into the display (gray scale) and store it from sd to fpga so i don't have to connect ram. I make the calculations and it fits. The problem i have is with h_sync and v_sync which i don't know how to use them.Any help would be like gold...
0 Kudos
Altera_Forum
Honored Contributor II
4,376 Views
0 Kudos
Altera_Forum
Honored Contributor II
4,376 Views

thank you very much it is what i needed ..

0 Kudos
Altera_Forum
Honored Contributor II
4,376 Views

I am too building a very similar project on a de0 nano board, but i need to do some image processing with it too. 

Would be really grateful if you could provide the verilog code, or alternatively some other help
0 Kudos
Altera_Forum
Honored Contributor II
4,376 Views

i also having a same problem. can you please send me those code to me

0 Kudos
Altera_Forum
Honored Contributor II
4,376 Views

Hi anthimos, 

It seems that you know how to display an image on VGA. I don't know how to do it. Please help me ! 

First, I don't know how VGA get the input data (image), and what the role of h_sync and v_sync ? Any help would be like gold..
0 Kudos
Reply