How to figure out how much amount of space is being occupied by the C.c file which is used to to run as an NIOS II hardware ??For example in the file http://www.altera.com/literature/hb/external-memory/emi_tut_qdr.pdf consider I am running the DDR_TEST.c file on the NIOS II processor. What will the memory occupied int he ON CHIP RAM???
Most of the memory is needed for the libc functions that Altera support by default.In particular printf() drags in about 70k of code because it is built on top of the standard stdio library code which also pulls in malloc(). Even if you don't actually call printf() there is code to close the fds after main returns. There is a 'small' version (that uses alt_printf() etc), but even that isn't as small as it could be. It really ought to be possible to write a 'hello world' program in less than a 100 instructions, and use that as a base for simple embedded systems.
--- Quote Start --- In particular printf() drags in about 70k of code because it is built on top of the standard stdio library code which also pulls in malloc(). --- Quote End --- I think you're off by 10x. :) WIth "enable_small_c_library" and "enable_reduced_device_drivers" options enabled, then "Hello world" with a JTAG UART console takes 7KB. Without those options enabled, it is around 28KB.
with the ONCHIP RAM memory on the system being only 64KB(max specified by altera), even if a small program like hello world takes 7KB, then it means i cant run a big code on it ??
Running out of memory is an old problem. If you need to run software that is bigger than the available onchip memory, then you may want to consider adding an external memory with adequate capacity to your hardware design.For many traditional microcontroller tasks, 64KB is ample capacity however.
I run real code on two nios, one has under 4k code, the other about 8k. There is 32k of internal memory, about 10k of which is a big lookup table.What this doesn't use is any of the Altera support code. The 4k code contains a multi-channel hdlc controller (doing bit-stuffing and crc in software) that is capable of driving 64 64kb hdlc streams (for telephony). The second nios does the low level hdlc protocol (timers, retransmissions and host interface).