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: Compiler errror with movd32 instruction

Part Number: TMS320F28379D

Hello,

I stumbled upon compiler error for Delfino F28379D compiler (checked on TI compilers 20.2.1 and 21.6.0).

Below minimal code example to invoke compiler error:

#include <stddef.h>
#include <stdlib.h>

typedef struct
{
    float a;  float b;
    float c;  float d;
    float e;  float f;
    float in; float in_prev;
} str;

typedef struct
{
    float reserved[25];
    str aa;
} movd32_example;

#pragma DATA_ALIGN ( md32 , 0x40 )
movd32_example md32;

static inline void calculate(str *a, float in) {
    a->c = a->a * a->in_prev + a->b * a->c;
    a->in_prev = in;
    a->e = a->f * (a->in - a->c);
    a->d = in - a->e;
}

void main(void) {
    for (;;) {
        md32.aa.in = (rand() % 100) / 10.0f;
        calculate(&md32.aa, md32.aa.in);
    }
}

For my project (attached), linker places m32 at address 0xa800 - at the beginning of 64 word page.

Line 

a->in_prev = in;

is realised as following set of instructions:

MOVW      DP,#_md32+64          ; [CPU_ARAU]
MOV32     *+XAR4[AR1],R0H       ; [CPU_FPU] |30| 
MOVB      XAR1,#58              ; [CPU_ALU] |24| 
MOV32     R2H,*+XAR4[AR0]       ; [CPU_FPU] |24| 
SUBF32    R1H,R2H,R1H           ; [CPU_FPU] |24| 
MOVD32    R4H,@$BLOCKED(_md32)+62 ; [CPU_FPU] |23|

Last MOVD32 instruction uses direct addressing, so DP register needs to be set for data page number, and in MOVD32 instruction, only last 6 bits are passed.

Intended effect of MOVD32 instruction is:

R4H := [md32+62:md32+63]
[md32+64:md32+65] := [md32+62:md32+63]

due to md32+62 and md32+64 addresses being on different 64 word pages, and DP register set to md32+64 page, both parts of movd32 instruction are executed incorrectly.

R2H register gets value from md32+126 instead of md32+62, and this value is written to md+128, potentially overwriting some other data.

I attach compete CCS project to reproduce this fenomenon.

 

movd32_compiler_error.zip

  • Unfortunately, parts of the CCS project are missing, and I cannot build it.  

    Even so, I can come close to building it with what you did send. I am only missing the compiler build options.  Build this CCS project, then copy-n-paste the text of the full compile command from the Console view into your next post.  Please do not use a screen shot.

    Thanks and regards,

    -George

  • Sorry, I thought .cproject file contains all relevant data. Here is my compilation output:

    **** Build of configuration 2837xD_CPU2_Release for project MP26 ****

    /home/krezolekpa/ti/ccs1011/ccs/utils/bin/gmake -k -j 8 all -O

    Building file: "../DSP2837xD/F2837xD_CodeStartBranch.asm"
    Invoking: C2000 Compiler
    "/home/krezolekpa/ti/ccs1011/ccs/tools/compiler/ti-cgt-c2000_20.2.1.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 -O4 --opt_for_speed=5 --fp_mode=relaxed --include_path="/home/krezolekpa/repo/mp26" --include_path="/home/krezolekpa/ti/ccs1011/ccs/tools/compiler/ti-cgt-c2000_20.2.1.LTS/include" --include_path="/home/krezolekpa/repo/mp26/include" --include_path="/home/krezolekpa/repo/mp26/include/DSP2837xD" --advice:performance=all --define=CPU2 --define=F2837xD -g --c99 --diag_warning=225 --diag_wrap=off --display_error_number --abi=coffabi -k --asm_listing --preproc_with_compile --preproc_dependency="DSP2837xD/F2837xD_CodeStartBranch.d_raw" --obj_directory="DSP2837xD" "../DSP2837xD/F2837xD_CodeStartBranch.asm"
    Finished building: "../DSP2837xD/F2837xD_CodeStartBranch.asm"

    Building file: "../cpu2/main_cpu2.c"
    Invoking: C2000 Compiler
    "/home/krezolekpa/ti/ccs1011/ccs/tools/compiler/ti-cgt-c2000_20.2.1.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 -O4 --opt_for_speed=5 --fp_mode=relaxed --include_path="/home/krezolekpa/repo/mp26" --include_path="/home/krezolekpa/ti/ccs1011/ccs/tools/compiler/ti-cgt-c2000_20.2.1.LTS/include" --include_path="/home/krezolekpa/repo/mp26/include" --include_path="/home/krezolekpa/repo/mp26/include/DSP2837xD" --advice:performance=all --define=CPU2 --define=F2837xD -g --c99 --diag_warning=225 --diag_wrap=off --display_error_number --abi=coffabi -k --asm_listing --preproc_with_compile --preproc_dependency="cpu2/main_cpu2.d_raw" --obj_directory="cpu2" "../cpu2/main_cpu2.c"
    Finished building: "../cpu2/main_cpu2.c"

    Building target: "MP26_cpu2.out"
    Invoking: C2000 Linker
    "/home/krezolekpa/ti/ccs1011/ccs/tools/compiler/ti-cgt-c2000_20.2.1.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 -O4 --opt_for_speed=5 --fp_mode=relaxed --advice:performance=all --define=CPU2 --define=F2837xD -g --c99 --diag_warning=225 --diag_wrap=off --display_error_number --abi=coffabi -k --asm_listing -z -m"MP26_cpu2.map" --heap_size=0x200 --stack_size=0x200 --warn_sections -i"/home/krezolekpa/ti/ccs1011/ccs/tools/compiler/ti-cgt-c2000_20.2.1.LTS/lib" -i"/home/krezolekpa/ti/ccs1011/ccs/tools/compiler/ti-cgt-c2000_20.2.1.LTS/include" --reread_libs --diag_wrap=off --display_error_number --xml_link_info="MP26_linkInfo.xml" --entry_point=code_start --rom_model -o "MP26_cpu2.out" "./DSP2837xD/F2837xD_CodeStartBranch.obj" "./cpu2/main_cpu2.obj" "../linker/2837xD/2837xD_FLASH_lnk_cpu2.cmd" "../linker/2837xD/F2837xD_Headers_nonBIOS_cpu2.cmd" -llibc.a
    <Linking>
    warning #10063-D: entry-point symbol other than "_c_int00" specified: "code_start"
    Finished building target: "MP26_cpu2.out"

  • Thank you for the build options.  When I use version 20.2.1.LTS, I am able to reproduce the problem.  The latest 20.2.x.LTS release, which is version 20.2.5.LTS, does not have the problem.  So, upgrading to version 20.2.5.LTS is one possible way to resolve the problem.

    I stumbled upon compiler error for Delfino F28379D compiler (checked on TI compilers 20.2.1 and 21.6.0).

    I am unable to reproduce the problem with compiler version 21.6.0.LTS.

    Thanks and regards,

    -George