Hello all,
I have what I believe to be a relatively beginner question, but I am new here, so go easy on me...
Here are the tools I am currently using:
-Tiva C series development board with a TM4C123GH6PGE processor. This is supposedly equivalent to the Stellaris LM4F232H5QG.
-Code Composer Studio v5.4.0.00091
Compiler version: TI v5.0.4
Runtime support library: <automatic>
And as for the question: I am running a very time sensitive application that needs to do a moderate amount of math including divides, square roots, and possibly trig functions such as sine(x). If I am not mistaken the processor is capable of floating point hardware divides and square roots, the datasheet shows the assembly commands as "VDIV.F32" and "VSQRT.F32" respectively. Furthermore, the "ARM Cortex-M4 Processor Technical Reference Manual" (rev r0p1) states that those instruction each require 14 clock cycles.
I have written test code that successfully performs the divide and square root, which can be seen as
float x,y,z,zdiv;
x = 2.34457123123;
y = 5.12366434127;
zdiv = x / y;
z = sqrtf(x);
Using JTAG I am able to verify that the values of "zdiv" and "z" are what you would expect, but the timing and the assembly code is not what I expect. The last 4 lines above are repeatedly run inside a very slow loop, and I used a very rough method of toggling a GPIO line immediately before and after those lines to get a rough estimate of timing (I understand this is imperfect) and am seeing something like 700ns execution time. I am certain that the CPU clock is configured for 80MHz, this has already been verified several other ways. Most confusing however is the assembly code. I see no evidence of any divide, let alone a hardware floating point divide. There is a long branch to a square root routine, also not what I was hoping for/expecting. As far as I can tell these are the assembly lines associated with the C code shown above:
;---------------------------------------------------------------------- ; 153 | x = 2.34457123123; ;---------------------------------------------------------------------- LDR A1, $C$FL1 ; [DPU_3_PIPE] |153| VMOV S0, A1 ; [DPU_LIN_PIPE] |153| LDR A1, $C$CON25 ; [DPU_3_PIPE] |153| .dwpsn file "../timers.c",line 154,column 2,is_stmt,isa 1 ;---------------------------------------------------------------------- ; 154 | y = 5.12366434127; ;---------------------------------------------------------------------- LDR A2, $C$CON26 ; [DPU_3_PIPE] |154| .dwpsn file "../timers.c",line 153,column 2,is_stmt,isa 1 VSTR.32 S0, [A1, #0] ; [DPU_LIN_PIPE] |153| .dwpsn file "../timers.c",line 154,column 2,is_stmt,isa 1 LDR A1, $C$FL2 ; [DPU_3_PIPE] |154| STR A1, [A2, #0] ; [DPU_3_PIPE] |154| .dwpsn file "../timers.c",line 155,column 2,is_stmt,isa 1 ;---------------------------------------------------------------------- ; 155 | zdiv = x / y; ;---------------------------------------------------------------------- LDR A1, $C$FL3 ; [DPU_3_PIPE] |155| LDR A2, $C$CON27 ; [DPU_3_PIPE] |155| STR A1, [A2, #0] ; [DPU_3_PIPE] |155| .dwpsn file "../timers.c",line 156,column 2,is_stmt,isa 1 ;---------------------------------------------------------------------- ; 156 | z = sqrtf(x); ;---------------------------------------------------------------------- $C$DW$88 .dwtag DW_TAG_TI_branch .dwattr $C$DW$88, DW_AT_low_pc(0x00) .dwattr $C$DW$88, DW_AT_name("sqrtf") .dwattr $C$DW$88, DW_AT_TI_call BL sqrtf ; [DPU_3_PIPE] |156| ; CALL OCCURS {sqrtf } ; [] |156| LDR A1, $C$CON28 ; [DPU_3_PIPE] |156| .dwpsn file "../timers.c",line 157,column 2,is_stmt,isa 1 STR V3, [V1, #0] ; [DPU_3_PIPE] |157| .dwpsn file "../timers.c",line 156,column 2,is_stmt,isa 1 VSTR.32 S0, [A1, #0] ; [DPU_LIN_PIPE] |156|
Any help would be so appreciated! Thanks.