microblaze nios
I'm really impressed with microblaze, and even more impressed with the gnu gcc compiler and the MB assembler.
Real world example :
(val =9)
The C :
int SetBit(Xuint32 addr, Xuint32 val)
{
Xuint32 temp, pmask, nmask;
pmask = 0;
pmask = 1 << (31 - val);
nmask = ~pmask;
temp = XGpio_mGetDataReg(addr);
temp = temp | pmask;
XGpio_mSetDataReg(addr, temp);
}
The produced assembler :
clks code
2 lw r4,r0,r5
1 rsubik r6,r6,31
1 addik r3,r0,1 # 0x1
2 bsll r3,r3,r6
1 or r4,r4,r3
2 sw r4,r0,r5
2 lw r3,r0,r5
2 rtsd r15, 8
That's effectively 6 lines of C plus func declaration and local vars turning into 8 lines of assembler and executing in 13 clock cycles. I'd be interested to see how many clock cycles the NIOS takes for the same C source code. All vars are 32 bit, the function calls are macros which do a bit of pointer casting and read/write a memory mapped peripheral addr. GCC optimisation level was 2.
Git