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: the build code size has large different between C28x and CLA

Part Number: TMS320F280039C

Hi Team 

Customer try to move PFC control logic form C28x to CLA, but they find when put the same C code into .c file and .cla file, the code size is significantly larger in .cla than in .c, which can be found in found in .map file.

I can also test this issue using "cla_ex4_pwm_control" demo, just to add some simple function and click "build".

Questions are:

1. Why there is the difference happen?

2. How to optimize the CLA code to make the code size as small as possible.

Thanks and best regards

Joe

25th April. 

  • Hi Joe,

    Here are a couple potential reasons as to why the CLA code is taking up more memory:

    • The instruction set for the CLA is smaller/more limited than that of the c28x core (in fact it is only a subset of the FPU instruction set, which is just an extension to the c28x instruction set.) It also contains fewer registers than the c28x core. So, the disassembly code generated from the program code during compilation on the CLA core would likely require more lines of code to perform the same functionality, which thus would take up a larger portion of memory to store. They could potentially look through the disassembly and see if there are any lines of code being unnecessarily generated and try using their own .asm files with these lines removed. This could however be risky and would require a lot of time to go through and ensure that whatever lines are removed wouldn't interfere with the proper flow of code, so I wouldn't recommend it.
    • There is a difference in how data types are stored in the CLA vs the c28x. The differences are listed below. If they for example are using a lot of int type variables in their code, these would take up double the amount of memory on the CLA (32 bits rather than 16 bits). To avoid this issue, they can use type declarations that specify the size information, for example: uint16_t, int16_t etc. to ensure 32 bits aren't being taken up in memory when only 16 bits of the value are needed/used. This would also avoid any type discrepancies/issues when porting the code over to CLA as well.
    • .cla code goes through a different optimizer when it is compiled, and there could be some differences with how well the c28x optimizer is able to optimize their code vs the CLA optimizer. For more information about this, please see the TMS320C28x Optimizing C/C++ Compiler v17.6.0.STS User's Guide (Rev. N).

    In general, the CLA is meant to offload real-time tasks to reduce c28x overhead. It isn't necessarily made to do the same amount/level of computations and logic that the c28x core is capable of, which is why they are seeing a memory tradeoff when attempting this.

    Best Regards,

    Delaney