Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
12 years ago

Read file from SDRAM

Hi,

I am trying to develop an IP that read a file which will be stored in the SDRAM and then send the data read. I've seen that we can read from the SDRAM with the IORD function but I prefer not to do it with the soft. What I am actually trying to do is to use a DMA to read the data. Is that possible ? How can I proceed ?

Thanks !

4 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You can do it many different ways. A couple of options:

    1. Add an Avalon-MM Master port to your IP block. Your module would, for example, have a base address control register with the pointer to the file buffer you want to read.

    2. Add an Avalon-MM Slave port to your IP block, and use an Altera DMA controller to execute the copy from the memory to your IP block.

    Here is one example from Altera which may be a useful illustration of a similar task:

    http://www.altera.com/support/examples/nios2/exm-checksum-acc.html
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks for your answer :)

    --- Quote Start ---

    2. Add an Avalon-MM Slave port to your IP block, and use an Altera DMA controller to execute the copy from the memory to your IP block.

    --- Quote End ---

    That's the option I've thought of. But as it will be in a file and not in a buffer, what is the address we need to give ? The one of the first word in the file ?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You would have to look at the specification for how the file is stored in SDRAM. However the file is getting placed into SDRAM, you need to understand that buffer layout and if it is broken up into multiple sections (pages) then you would need to DMA each of them separately.

    If you're simply doing fopen() and fread() the entire contents of a file, then yes you simply supply the address of the first word in your buffer.