My application must be miserly with memory usage, and single precision math is enough. I am coming from using assmebly language on the TMS20VC33 to using CCS 4.x and the C compiler. My initial test app is an analytic (complex) oscillator.
Here is the simple function in C:
Note that cosc is an array of floats.
void analytic_osc ( void )
{
float register mag_sq, tcos, tsin; // compiler issues warning "storage class is not first" whatever that means
// the vc33 assembler takes 19 cycles and 16 words for the entire function including exit cycles
// when put into this as a function, it takes the 674x 125 + exit cycles and 67 words of memory !!
tcos = cosc[2] * cosc[4] - cosc[3] * cosc[5];
tsin = cosc[2] * cosc[5] + cosc[3] * cosc[4];
// now apply AGC
mag_sq = tcos * tcos + tsin * tsin;
tcos = tcos * (3.0 - (mag_sq)) * 0.5;
tsin = tsin * (3.0 - (mag_sq)) * 0.5;
// update previous results with current results for next iteration
cosc[4] = tcos;
cosc[5] = tsin;
}
When compiled and disassembled, there is a huge memory and performance penalty taken because the compiler seems to insist on making the 'float register" values into "double register" and applying double-precision math. Here is a snippet of the disassembled code:
25 tcos = tcos * (3.0 - (mag_sq)) * 0.5;
020C10A2 SPDP.S2X A3,B5:B4
06A6 MVK.L1 0,A5
0626 MVK.L1 0,A4
02A00468 || MVKH.S1 0x40080000,A5
02109338 SUBDP.L1X A5:A4,B5:B4,A5:A4
03800028 MVK.S1 0x0000,A7
039EBD88 SET.S1 A7,21,29,A7
E0800020 .fphead n, l, W, BU, nobr, nosat, 0000100
00006000 NOP 4
0210C5B0 MPYSPDP.M1 A6,A5:A4,A5:A4
0726 MVK.L1 0,A6
8C6E NOP 5
0210C700 MPYDP.M1 A7:A6,A5:A4,A5:A4
00010000 NOP 9
04148138 DPSP.L1 A5:A4,A8
00004000 NOP 3
This snippet takes 14 words and 31 cycles to execute, compared with the 'VC33 section taking 3 words and 3 cycles.
As you can see there is a huge penalty in execution time (NOP 9 for example) as well as memory. I'm still trying to figure out why all the constants are being generated and loaded into various registers.
I admit to being a complete novice with the IDE (I am used to Code Composer, not CCS, for the VC33) and with C (I am used to assembler, but the 674x assembly language is scary with all the limitations and dependencies and pipeline delays etc).
Any help on how to force the compiler to use single precision math? If it is a compiler option that has to be set somehow, help on where/how to set it within the CCS 4.x project IDE would be most appreciated, too
Thanks in advance for any help!
Lyle Johnson
Elecraft, Inc.

