Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20735 Discussions

optimize the size of a C program????

Altera_Forum
Honored Contributor II
1,218 Views

hi, 

i have write a C program with 20 line of code, i try optimize it with NIOS II compliler option like -Os, -g3 i obtain 7700 bytes but is not sufficient for my design, because i use an onchip memory. 

my question is: 

can I optimize my program for obtain a smaller size ? 

Nios II compiler contain others options for program optimisation? 

 

thks for all members
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
335 Views

Is the 7700 bytes you mention code space or data space? 

 

Optimization will attempt to reduce code size but not have much of an effect on data size. 

 

Since it's only 20 lines of C, perhaps you could post it so members could take a look and suggest any code style optimizations . 

 

Thanks
0 Kudos
Altera_Forum
Honored Contributor II
335 Views

Have you tried customizing the system library? This can make a relatively big difference when your actual program is quite small. 

 

For example, in the system library you can disable C++ support as well as enable "reduced device drivers" and "small C library".
0 Kudos
Altera_Forum
Honored Contributor II
335 Views

thk kevin and vernmid (http://www.alteraforum.com/forum/member.php?u=3282) it is the best idea! 

i try this and it work well. 

my mrogram become very small from 7700 bytes to 2096 bytes. 

thks for all members
0 Kudos
Reply