Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20687 Discussions

How to convert On Chip memory to SRAM .??

Altera_Forum
Honored Contributor II
1,712 Views

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,
0 Kudos
10 Replies
Altera_Forum
Honored Contributor II
619 Views

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.

0 Kudos
Altera_Forum
Honored Contributor II
619 Views

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.
0 Kudos
Altera_Forum
Honored Contributor II
619 Views

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.
0 Kudos
Altera_Forum
Honored Contributor II
619 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
619 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
619 Views

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).

0 Kudos
Altera_Forum
Honored Contributor II
619 Views

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?

0 Kudos
Altera_Forum
Honored Contributor II
619 Views

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.
0 Kudos
Altera_Forum
Honored Contributor II
619 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
619 Views

You will find information about system console here (https://www.altera.com/content/dam/altera-www/global/en_us/pdfs/literature/ug/ug_system_console.pdf). You will have to write a script in TCL to write to the memory. I've never done it but it should be possible to open and read a binary file in TCL.

0 Kudos
Reply