Forum Discussion
Altera_Forum
Honored Contributor
15 years agoSoftware size is too big
Hello guys, i've tried small C lib, reduced device drivers and everything else but nothing works.. I am using Quartus V10.0SP1 and NIOSEDS V10.0SP1, A hello word simple program with a printf ta...
Altera_Forum
Honored Contributor
15 years agosomething like (untested):
void put_uint(unsigned int x)
{
char b, *p = b + 9;
unsigned int n;
b = 0;
do {
n = x / 10;
*--p = '0' + (x - n * 10);
} while ((x = n) != 0);
alt_putstr(p);
}will output an unsigned value to the terminal in decimal. The above will pull in the libc function to do divide (unless you added the hardware instruction and told gcc to use it). The 'divide by constant' can be replaced by a multiply and shift, but that requires the 64bit result from the multiply - which altera don't have support for on the older fpgas (needs the DSP based multiply) and might need a 64bit shift. Splitting the value into two 16bit values does make this possible (I've done that to avoid needing 64bit divide when converting 'long long'.) Writing printf() is just a SMOP (simple matter of programming).