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.

TMS320F2800157: Integer division using TMU

Part Number: TMS320F2800157


Hi Team,

=============================================================================

sTmpUint32_3 = sTmpUint32_1 / sTmpUint32_2;   ---- divide two integers


0849e8: A306 MOVL P, @0x6
0849e9: 0200 MOVB ACC, #0
0849ea: F61F RPT #31
0849eb: 56170008 || SUBCUL ACC, @0x8     ---- TMU is not used. Actual measurement shows that this division takes many CPU cycles.
0849ed: A90A MOVL @0xa, P

=============================================================================

sTmpFloat32_3 = sTmpFloat32_1 / sTmpFloat32_2;   ---- divide two floating point numbers

084a60: E2AF0100 MOV32 R1H, @0x0, UNCF
084a62: E2AF0002 MOV32 R0H, @0x2, UNCF
084a64: E2740008 DIVF32 R0H, R1H, R0H     ---- The TMU instruction is used. Actual measurement shows that this division costs less CPU cycles.
084a66: 7700 NOP
084a67: 7700 NOP
084a68: 7700 NOP
084a69: 7700 NOP
084a6a: E2030004 MOV32 @0x4, R0H


How can I make integer division also compiled into a TMU instruction?

--

Thanks & Regards

  • Yale, 

    The TMU supports only floating-point operations.

    The FINTDIV (Fast Integer Division) hardware does integer division. However, it isn't present on the F280015x. You can try casting the integers to floats, perform the division, and cast back to integer. There are efficient instructions for the conversion (F32TOI32, I32TOF32) that the compiler can leverage for the casting operations, and the TMU for the division operation.

    Thanks,

    Sira