Altera_Forum
Honored Contributor
20 years agopre-initialized onchip memory
I have a design that uses several onchip memories. To keep it simple here, say I have: main_memory & my_init_memory.
Naturally, the main_memory is the code space for my Nios II processor, and my_init_memory is some pre-initialized memory (effectively a look-up table with some constants). In the IDE, when I create a simple Hello World design and build it, here is the final output:make -s all
Compiling hello_world.c...
Linking mem_test.elf...
Info: (mem_test.elf) 52 KBytes program size (code + initialized data).
Info: 12 KBytes free for stack + heap.
Creating mem_test.elf.objdump...
Post-processing to create main_memory.hex
Post-processing to create my_init_memory.hex This places my code in main_memory.hex, and sets my_init_memory.hex to all zero's which blows away my predefined lookup table. There are two work-arounds that I can do to get past this... 1) create a variable such as: static const int my_init_array __attribute__ ((section (".my_init_memory"))) = {#some predefined values#}; I do not want my C source file to be responsible for my init data. 2) Create an ALTSYNCRAM using the MegaWizard, and import that into SOPC Builder using the "Create New Component..." wizard and importing my newly created altsyncram. Here I would rather use the onchip memory already provided in SOPC Builder... How do I get the IDE to not overwrite my_init_memory.hex file during compilation? Can I create a custom linker script to avoid this? FYI, the system library has main_memory defined for .text, .rodata, and .rwdata Is there a KEEP function or attribute that I can use? Thoughts? Thanks, -Terry