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 help out
If you use the IDE, open the syslib properties. Here you can select where each part of your program (code, data, stack, ...) will be placed.If you use a linker script, you'll need to modify the appropriate entry in the file.
It depends on the tools you are using. If you have the old IDE you need to look into the system library properties. There you will be able to set which memory to use for different parts of your application.If you use the new development environment you need to look into the BSP settings.
If 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!
hey replies really helped... thanks.. few more things1)is it must to have .rodata , .rwdata , .heap in same mem location...... 2) and which is my code in .rodata and .rwdata ....... 3)if im correct .rodata is my code and .rwdata is the data wat i use for processing like inputs outputs and memory i update right? please correct me if im wrong.. and it would be of good help if you guys can provide me literature to read for such thing (and some heads up about multiprocessor design other than tutorial)
1) each section can be mapped to a different mem location2) .rodata: read only (constant) data .rwdata: read/write data, i.e. all your program variables .text : program code For further information browse the Nios literature: http://www.altera.com/literature/lit-nio2.jsp In particular you find the information about memory sections in the Nios Software Developer's HandBook Regards
You can find which sections are actually in a program by running 'objdump -h prog.o'.You might also see .sdata, .sbss (ie normal data sections with an extra 's' (for small) in their names). The compiler generated code to access these will use offsets from the 'gp' (global pointer) register to save code space and increase execution speed. These sections must be linked together and must not exceed 64k bytes, the 'gp' register is set to the symbol _gp which is (IIRC) 32k bytes above the base of the small data areas.
hey guys can u tel me why .text file wil so big like 16kb-20kb n all .. is there any way i can change settings to make it small..i dont want any special features in my nios 2 design.. im expecting its size to be small. any heads up... pls
Or try not to use any of the C library at all!printf() pulls is a lot of code. You may have code to initialise/destroy stdin/stdout/stderr being exected before/after main() is called - this also pulls in malloc() etc. Calling your code alt_main() will remove the stdio stuff (this probably isn't the official way to do it! but worked for me). The linker map file (possibly with cross references) will show why each library function was added. Although I don't know how to persuade the IDE to generate it.
how to disable c library usage... u mean to say not to add any header file or not to call any functions like printf n all.. i hvnt used printf statement. i hvnt added stdio.h also..and wat abt that alt_main
hey sorry prob wit my server.. so multiple same posts.. and sorry to be dumb again.. but im not finding that compiler option .. where to change or set it to optimise for size.. pls be prceise on GUI
In the old IDE: Project > Settings > C/C++ Build > Tool Settings > Nios II Compiler > General > Optimization LevelsIn the new EDS: Project > Settings > Nios II Application Properties > Optimization Level