Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

Questions on program size in Nios II

Hi!

I'm learning Nios II with DE2 Development Board, and I made a very simple MCU in the SOPC Builder which contains a Nios II processor(standard) with reset vector = epcs_controller and exception vector = sram, a jtag_uart, three bidirectional I/O, an interval timer, a sram controller and a epcs_controller. The SOPC was generated successfully. Then I write C code in Nios II IDE.

After building project, I found program size(code + initialized data) is high up to 58KBytes.I used to develop Atmel AVR MCU, I wrote thousands of lines of codes in a project but program size is less than 32KBytes. However, I just set timer registers, interruption registers and set IO output as high or low and so on in the Nios II, and the code is less than 200 lines. Why so little codes take up so big size in Nios II?

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    A few things to remember.

    1 - Your Atmel AVR was most likely an 8-bit MCU. NIOS is 32-bit.

    2 - There is a lot you can do to reduce the code footprint on NIOS. For example; rather than running your little application, try starting with the "Hello World Small" example application and go from there. I frequently write very rich little applications in around 16K of code.

    In addition, read the section entitled "Reducing Code Footprint" beginning on page 6-30 of the NIOS II Software Developers Handbook:

    http://www.altera.com/literature/hb/nios2/n2sw_nii52004.pdf

    Jake