Forum Discussion

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

How to convert On Chip memory to SRAM .??

Hi All,

I am a newbie to Altera FPGA. I am using Altera FPGA for a class project.

I am using a custom processor ( not NIOS) and I am as of now using Onchip memory for instruction and data. I now need to use SRAM instead of onchip memory.

I am using DE4 development board with Stratix 4 FPGA. As of now I am instantiating "altsyncram" for both instruction and data and initialising them using .mif file.

I have no idea how to migrate this to SRAM. I have generated SRAM controller using Megawizard and I am struck as how to initalise SRAM.?? If you could give any links of project code where SRAM controller is used it would be helpful.

Thanks,

10 Replies

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

    If the SRAM is an external component then you can't initialize it with a .mif file and you will need a system to fill it up. A very common way is to use a small on-chip memory that the CPU can boot on. This memory holds a bootloader, that will read the application code from an external source (a flash memory for example) and copy it into the SRAM. Then it sets the CPU to jump to the application.

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

    Thank you ... If I could get some example design as how to interface SRAM to a custom project it would be helpful.

    I am not able to understant how to access avalon bus and from there to SRAM controller.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    If you aren't using SOPC builder or QSys to connect your CPU to memories or components, it may be easier to avoid using the controller generated by the megawizard and make it yourself. Accessing an SRAM is pretty easy, just set the address and read signal, or address, data and write signal, and wait for the correct timing.

    Alternatively if you want to use Avalon bus (which should make your system easier to expand and adapt) then you should learn about the avalon specifications, by reading this document: http://www.altera.com/literature/manual/mnl_avalon_spec.pdf.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks again !! Its the exact solution what I was lookking. I feel its better for me to implement a SRAM controller on my own.

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

    Daixiwen, could you provide some more details on how to initialize SRAM/SDRAM? Thanks!

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

    I don't understand your question. If it it the main memory (used for the .text, .data. and .bss sections) it will automatically get initialized when you upload the elf file. If it is separate memory section you can use memset to initialize its contents to a fixed value (most usually 0).

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

    I mean if you want to load a particular file into SRAM/SDRAM and later process it by reading from the memory, how would you initialize the SRAM/SDRAM to that file content?

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

    If you have an on-board CPU such as a Nios ", then you can write your own communication protocol to transfer the data from Ethernet or a serial link to the RAM.

    If you have a JTAG connection then you could also use system console to do the transfer.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    The latter one sounds good to me. Any link (or examples) on the details of that? Thanks!