placing hot spot functions in on-chip ram

Hill, Jeff johill at
Thu Apr 11 22:38:42 UTC 2013

Hello Sebastian,

Just a quick note to identify my current direction so that you will have an opportunity to provide some comments.

Today I had a closer look at techniques for placing certain Nios2 hotspot functions in on-chip ram. I see only two options for implementing this cleanly.
1) Move code using its section name in the linker script
  o Mark the C function with a section attribute. The function shouldn't contain rwdata or bss variables.
  o Mark the assembler code with a section attribute. Such code shouldn't contain rwdata or bss variables.
2) Place all hot spot functions in separate object files, and manipulate the location of object files in the linker script
  o The entire object file shouldn't contain any rwdata or bss variables.

Until today I have been gravitating towards option 2. However now I have bumped into a nasty bug in the gnu ld where the linker script parsing code will find a short object file name in its input stream, but will not find a long name such as "libscorecpu_a-nios2-iic-low-level.o". Since the file name characters are chopped off somewhere in ld, maybe at about 10 characters from the right hand side of the above name, then it's difficult to work around this issue with wild cards; I end up with file name ambiguities, and too much goes in the tightly coupled code section.

Furthermore, I see that with option 1 we have another benefit being that some rwdata or bss can be in the object file as long as it isn't in the function. Of course the BSS and RWDATA can't be in on-chip ram if we are to survive a reset without reloading everything from flash.

Therefore, my current plan is to make a Nios2 private macro for the C source code gnu section name attribute. This implies that we can initially place only Nios2 specific codes in on-chip ram of course.

Another option would be to just fix the gnu ld program, but finding the exact location of this bug in the source initially appears to be a time consuming task. Perhaps this is even a bug originating from Altera, I don't know.

Open to your suggestions.


More information about the users mailing list