This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F280039C: floating-point

Part Number: TMS320F280039C

Tool/software:

Hi expert,

My customer is currently using float variables for the position estimator of the same motor, which is about 10-20% longer than using fixed-point variables with Q format, has the float calculation time been accelerated?

FPU is already turned on.

Best Regards

Anka Zhang

  • Anka,

    Can you provide some details? 

    Thanks,

    Sira

  • Hi Sira,

    My customer wants to use float point in their project, but they find it is much slower than fix point based 280039C with FPU turned on.

    I time their code step by step with CCS's clock, results as below:

    int a; int b; 

    a+b                 : 9 cycles

    a*b>>11          : 9 cycles

    a*b+a              :10 cycles

    a+b*b>>11      :20 cycles

    a=b                  :1  cycle

    float32 c; float32 d;

    c=d                         :8cycles

    c-d                          :11cycles

    c*d                          :11cycles

    c*d+c                      :23cycles

    c*d+c+d                  :24cycles

    Their project is about to mass produce, but the code cannot meet their requirements.

    How can they accelerate the code?

    Best Regards

    Anka

  • Anka,

    A few comments and suggestions:

    1. int on C28x is 16-bit, so you are performing 16-bit operations in the fixed-pt case. You can refer to spru430f, ADD, MPY are single cycle instructions

    2. In the float case, the operations are 32-bit, and ADD, MPY etc. are 2p instructions i.e. 2 cycles if there's a pipeline conflict, 1 cycle without. You can refer to spruhs1c. Specifically, take a look at section 1.4.7, it shows you floating point code without pipeline optimization and with pipeline optimization for the simple add and multiply use-case like your example.

    3. Has optimization been enabled?

    4. Getting accurate clock cycle numbers for small operations - like in your example -  is going to be a challenge because of pipeline effects and potential compiler optimizations. The number that CCS clock gives you in those cases may not be accurate. It's best to profile large blocks of code. Like in your case, the entire example, as opposed to individual elements. You should also be looking at the generated assembly code to see if it all matches up.

    My overall comment is that for simple operations, you may see some benefits with fixed-point over floating-point, but as you traverse to actual system examples, the limited number of fixed-point registers on C28x will quickly become a limitation, and floating-pt performance will beat fixed-pt performance.

    Thanks,

    Sira