Forum Discussion
Altera_Forum
Honored Contributor
15 years agowhere does code resides
one small querry.. when i use external SRAM in my design using nios2 for DE1 board my code wil be placed there in sram .. i want my code to be in onchip memory.. not sram.. how to do this..please he...
Altera_Forum
Honored Contributor
15 years agoIf you put the code in internal memory, you may need to write your own linker script in order to get the other sections assigned to appropriate places.
In the code memory is tightly coupled (which makes sense), you want to put the readonly data with the rest of the data (no point doing an avalon MM transfer into the dual port of the code memory - especially is much of your data is also in tightly coupled memory. This allows you to remove the cpu data access to the instrcution memory (unless you need it for loading the code - I don't). If you are using gcc4 there is a slight fubar! The Altera gcc4 build forces switch statement jump tables into the code section (instead of readonly data - or a section which the linker script can assign appropriately). The comments imply this was done because of missing relocation types for PIC code. But they forced it for all compilations (it would have been trivial to do this only for PIC builds). The jump table could be shortened by one instruction anyway! and even more if the jump table could be marked as 'small data' and appropriate gcc instruction patterns written - I didn't have any in my really critical code so didn't try too hard to do this!