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.

TMS320F28027: Operation instruction cycle issue

Part Number: TMS320F28027

Hi team,

Here's an issue from the customer may need your help:

uint16_t a =60123;float b=0.001236;uint16_t c =0; float d=0;

1) c=a*b;

How many instruction cycles does this need?

2) c=a*5>>12;//(5=b*4096)

For this case, how many instruction cycles does this need?

3) d=a*b;

And this one?

Could you help check these issues? Thanks.

Best Regards,

Cherry

  • The best approach is to show you how to determine...

    How many instruction cycles does this need?

    ... on your own.

    Write a small test case that has the code you are interested in.  For instance ...

    /* file.c */
    
    #include <stdint.h>
    
    uint16_t a =60123;
    float b=0.001236;
    uint16_t c =0;
    float d=0;
    
    void counting_cycles()
    {
        c=a*b;
    }

    Compile it just like you would a source file in your application.  Except add the build option --src_interlist.  The automatically generated assembly code file is deleted by default.  This option causes it to be kept.  In addition, comments are added which make it easy to understand.  The file has the same name as the source file, with the extension changed to .asm.  Inspect the resulting assembly code file.  Some lines may look similar to ...

    ;----------------------------------------------------------------------
    ;  12 | c=a*b;                                                                 
    ;----------------------------------------------------------------------
            MOVW      DP,#_a                ; [CPU_ARAU] 
            MOV       AL,@_a                ; [CPU_ALU] |12| 
    $C$DW$6	.dwtag  DW_TAG_TI_branch
    	.dwattr $C$DW$6, DW_AT_low_pc(0x00)
    	.dwattr $C$DW$6, DW_AT_name("U$$TOFS")
    	.dwattr $C$DW$6, DW_AT_TI_call
    
            LCR       #U$$TOFS              ; [CPU_ALU] |12| 
            ; call occurs [#U$$TOFS] ; [] |12| 
            MOVW      DP,#_b                ; [CPU_ARAU] 
            MOVL      XAR6,@_b              ; [CPU_ALU] |12| 
            MOVL      *-SP[2],XAR6          ; [CPU_ALU] |12| 
    $C$DW$7	.dwtag  DW_TAG_TI_branch
    	.dwattr $C$DW$7, DW_AT_low_pc(0x00)
    	.dwattr $C$DW$7, DW_AT_name("FS$$MPY")
    	.dwattr $C$DW$7, DW_AT_TI_call
    
            LCR       #FS$$MPY              ; [CPU_ALU] |12| 
            ; call occurs [#FS$$MPY] ; [] |12| 
    $C$DW$8	.dwtag  DW_TAG_TI_branch
    	.dwattr $C$DW$8, DW_AT_low_pc(0x00)
    	.dwattr $C$DW$8, DW_AT_name("FS$$TOU")
    	.dwattr $C$DW$8, DW_AT_TI_call
    
            LCR       #FS$$TOU              ; [CPU_ALU] |12| 
            ; call occurs [#FS$$TOU] ; [] |12| 
            MOVW      DP,#_c                ; [CPU_ARAU] 
            MOV       @_c,AL                ; [CPU_ALU] |12| 
    

    Ignore the lines that contain .dwsomething.  Those are assembly directives used by the debugger in CCS.  The remaining lines are CPU instructions.  You can look them up in the TMS320C28x DSP CPU and Instruction Set Reference Guide.  This line ...

        LCR       #U$$TOFS
     

    ... is a call to a function.  It is not a user function, but a function from the compiler RTS library.  This particular function converts an unsigned 16-bit value to a 32-bit floating point value.  The code for this function is supplied with the compiler.  It is in a file with a location similar to ...

    C:\ti\ccs1110\ccs\tools\compiler\ti-cgt-c2000_21.6.0.LTS\lib\src\u_tofs28.asm

    This particular RTS function is not that long, so counting the cycles in it is not very hard.  However, some functions are longer.  At some point, it is easier to run the code and count the cycles that way. For further details, please see the article Counting Cycles.

    Note that, in this post, only CPU cycles are accounted for.  Cycles that occur due to other system effects, such as cache or memory wait states, are ignored.  

    Thanks and regards,

    -George