Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

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.

TMS320F28379D: CLA have any in-built protection for arrays

Genius 15689 points
Part Number: TMS320F28379D

Hi Experts,

Good day. We have this query asking about the memory allocation of TMS320F28379D:

"I am using a TMS320F28379D evaluation board and I am planning to set a struct as a variable that is meant to be accessed by the CLA and the C28x. I understand that the pointer sizes in the CLA and the C28x are different and having contiguous pointers in a struct would result in incorrect memory access. My question is since c arrays decay to pointers, do contiguous arrays in a struct suffer from this bug as well(within an array and between arrays), or does the CLA have any in-built protection for arrays?"

Seeking your advise. Thank you

Regards,
Archie A.

  • Hi Archie,

    It depends on how the array is being allocated:

    1. Array allocated inside struct - this should result in the same offset and allocation on C28 and CLA side.

    struct A {

    uint32_t X;

    uint32_t filler[1];

    uint32_t Y[50]; // Array size 50 allocated inside struct

    }

    The following C source line results in the same offset on C28 and CLA.

    C source line:         

    struct A alpha;

    alpha.Y[0] = 0x255; 

    C28 generated assembly:

    MOVL      @$BLOCKED(||alpha||)+4,ACC

    CLA generated assembly:

    MMOV32    @alpha+4,MR0

    2. Pointer allocated inside struct - this will need to be padded as now a pointer is being allocated and size of pointer is different.

    struct A {

    uint32_t X;

    uint32_t *filler;

    uint32_t *Y; // Array pointer allocated

    }

    The same C source line results in the different offset on C28 and CLA.

    C source line:         

    struct A alpha;

    alpha.Y = malloc (50* sizeof(uint32_t));

    alpha.Y[0] = 0x255; 

    C28 generated assembly:

    MOVL      @$BLOCKED(||alpha||)+4,ACC

    CLA generated assembly:

    MMOV32    @alpha+3,MR0

    The pointer usage can be fixed using a union:

    struct A {

    uint32_t X;

    union

    {

      uint32_t dummy1;

      uint32_t *filler;

    }

    union

    {

      uint32_t dummy2;

      uint32_t *Y; // Array pointer allocated

    }

    }

    Let me know if you have further questions.

    Thanks,

    Ashwini