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

DDR2 as a program and data memory

Altera_Forum
Honored Contributor II
1,098 Views

Hi All, 

 

Can I use DDR2 as a program memory (option in system library properties) and also as storage memory for some data?? 

I'm interesting if I can specify some area for program memory and use other space. 

 

Thanks a lot 

AD
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
404 Views

Sure can. Just tell the tools you wish to do that in the same area.

0 Kudos
Altera_Forum
Honored Contributor II
404 Views

Thanks Avatar for your replay :). 

I know that I can choose varios memory devices for program memory (all I' ve specified in the system), but I want to be be sure that when writing some thata I'm not colliding with program's data. 

To be clear ... when using IOWR_32DIRECT for writing DDR2 how can I be sure that address I want to use is available? Which addresses is nios system using for program (always starting from address 0x0 or can reserve space for that?) 

 

thanks  

AD
0 Kudos
Altera_Forum
Honored Contributor II
404 Views

The simple answer is you can't be sure that memory is not being used. Now you could do some profiling to determine how much of the RAM is used by code and how big your stack is, etc. Not a good method.  

If you want to make sure that you are accessing memory appropriately than simply allocate a chunk of memory by creating an array or using malloc or something like that. Then you don't need to worry about where in memory it is located. If you've specified in the IDE system library settings to use your DDR2 for Read-only, Read/write, stack and heap memory, then it will automatically be located in the DDR2. 

You can also use compiler directives to specify what section of memory you would like a global variable to be located in.
0 Kudos
Altera_Forum
Honored Contributor II
404 Views

Thanks for your help. In my case the best solution is to declare an array and with compiler directives locate it in ddr2. 

 

AD
0 Kudos
Reply