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.

Compiler/TDA4VM: C7X SE host emulation on windows

Part Number: TDA4VM

Tool/software: TI C/C++ Compiler

Hi, friends.

I am using C7000 CGT for windows to simulate C7X. The version is 1.3.0.My visual studio version is 2019.
I noticed that the SE interface has been updated and I see some sample code in c7x_strm.h.
In a sample, the VECLEN is set to __SE_VECLEN_4ELEMS.
I executed this code.
Vout.lo = __SE1ADV(uint4);
But it only loaded one element.
I tried the old version of the interface in the header file and it loaded correctly.
Can you help me to solve this problem?
Regards.
Henry
  • Henry,

    I'm not sure what your problem could be. Can you try to compile and run the following code in your environment? Also, it would be helpful if you posted/attached your code.

    #include <c7x.h>
    #include <stddef.h>
    #include <stdio.h>
    
    #define SIZE_ARRAY (1024)
    
    uint uint_array[SIZE_ARRAY];
    
    void init_memory()
    {
        for (int i = 0; i < SIZE_ARRAY; i++)
            uint_array[i] = i + 1;
    }
    
    uint8 se_func(uint32_t *startaddr)
    {
        uint8 Vresult;
        __SE_TEMPLATE_v1 params = __gen_SE_TEMPLATE_v1(); // SE PARAMETERS
    
        params.DIMFMT   = __SE_DIMFMT_2D;
        params.ELETYPE  = __SE_ELETYPE_32BIT;
        params.VECLEN   = __SE_VECLEN_4ELEMS; // 4 ELEMENTS
    
        // SETUP TEMPLATE VECTOR BASED ON SETTINGS AND OPEN THE STREAM
        // BASED ON ITERATION COUNTERS AND DIMENSIONS (IN TERMS OF # OF ELEMS)
        params.ICNT0 = 128;
        params.ICNT1 = 128;
        params.DIM1  = 0;
        params.ICNT2 = 128;
        params.DIM2  = 0;
        params.ICNT3 = 128;
        params.DIM3  = 0;
    
        // DECDIM1 WIDTH (0 by default)
        params.DECDIM1_WIDTH = 0;
    
        // DECDIM2 WIDTH (0 by default)
        params.DECDIM2_WIDTH = 0;
    
        // LEZR COUNT (0 by default)
        params.LEZR_CNT = 0;
    
        __SE1_OPEN((void*)startaddr, params);
    
        // READ THE STREAM AND ADVANCE THE COUNTERS
        for (int I0 = 0; I0 < 8; I0++)
        {
            printf("-----------------\n");
            uint8 Vout =
    #ifdef __C7X_HOSTEM__
                uint8(0);
    #else
                (uint8)(0);
    #endif
            Vout.lo = __SE1ADV(uint4);
    #ifdef __C7X_HOSTEM__
            Vout.print();
    #else
            printf("%d,%d,%d,%d,%d,%d,%d,%d\n", Vout.s0, Vout.s1, Vout.s2, Vout.s3, Vout.s4, Vout.s5, Vout.s6, Vout.s7);
    #endif
    
            Vout.hi = __SE1ADV(uint4);
    #ifdef __C7X_HOSTEM__
            Vout.print();
    #else
            printf("%d,%d,%d,%d,%d,%d,%d,%d\n", Vout.s0, Vout.s1, Vout.s2, Vout.s3, Vout.s4, Vout.s5, Vout.s6, Vout.s7);
    #endif
    
            Vresult += Vout;
        }
    
        // CLOSE THE STREAM
        __SE1_CLOSE();
    
        return Vresult;
    }
    
    int main()
    {
        init_memory();
        se_func(uint_array); // Not using the return value
    
        return 0;
    }

  • Hi,

    Thank you for the reply.This is the code I executed.

    #include <c7x.h>                                                          
    #include <stddef.h>                                                       
    uint8 se_func(uint32_t *startaddr)                                        
    {                                                                         
        int I0;                                                               
        uint8 Vresult;                                                        
        __SE_TEMPLATE_v1 params = __gen_SE_TEMPLATE_v1(); // SE PARAMETERS    
                                                                              
        params.DIMFMT   = __SE_DIMFMT_4D;                                     
        params.ELETYPE  = __SE_ELETYPE_32BIT;                                 
        params.VECLEN   = __SE_VECLEN_4ELEMS; // 4 ELEMENTS                   
                                                                              
        // SETUP TEMPLATE VECTOR BASED ON SETTINGS AND OPEN THE STREAM        
        // BASED ON ITERATION COUNTERS AND DIMENSIONS (IN TERMS OF # OF ELEMS)
        params.ICNT0 = 4;                                                     
        params.ICNT1 = 2;                                                     
        params.DIM1  = 4;                                                     
        params.ICNT2 = 2;                                                     
        params.DIM2  = 8;                                                     
        params.ICNT3 = 4;                                                     
        params.DIM3  = -16;                                                   
                                                                              
        // DECDIM1 WIDTH (0 by default)                                       
        params.DECDIM1_WIDTH = 0;                                             
                                                                              
        // DECDIM2 WIDTH (0 by default)                                       
        params.DECDIM2_WIDTH = 0;                                             
                                                                              
        // LEZR COUNT (0 by default)                                          
        params.LEZR_CNT = 0;                                                  
                                                                              
        __SE1_OPEN((void*)startaddr, params);                                 
                                                                              
        // READ THE STREAM AND ADVANCE THE COUNTERS                           
        for (I0 = 0; I0 < 8; I0++)                                            
        {                                                                     
            uint8 Vout;                                                       
            Vout.lo = __SE1ADV(uint4);                                        
            Vout.hi = __SE1ADV(uint4);                                        
                                                                              
            Vresult += Vout;                                                  
        }                                                                     
                                                                              
        // CLOSE THE STREAM                                                   
        __SE1_CLOSE();                                                        
                                                                              
        return Vresult;                                                       
    }                                                                         

    And I executed your code, this is the print information.

  • Henry,

    I'm going to look into this issue with host emulation and the MS Visual Studio compiler. In the meantime, could you try the g++ compiler and let me know what happens?

    Just for reference, the expected output for the code I posted above is (and the output I get with g++):

    -----------------
    (1, 2, 3, 4, 0, 0, 0, 0)
    (1, 2, 3, 4, 5, 6, 7, 8)
    -----------------
    (9, 10, 11, 12, 0, 0, 0, 0)
    (9, 10, 11, 12, 13, 14, 15, 16)
    -----------------
    (17, 18, 19, 20, 0, 0, 0, 0)
    (17, 18, 19, 20, 21, 22, 23, 24)
    -----------------
    (25, 26, 27, 28, 0, 0, 0, 0)
    (25, 26, 27, 28, 29, 30, 31, 32)
    -----------------
    (33, 34, 35, 36, 0, 0, 0, 0)
    (33, 34, 35, 36, 37, 38, 39, 40)
    -----------------
    (41, 42, 43, 44, 0, 0, 0, 0)
    (41, 42, 43, 44, 45, 46, 47, 48)
    -----------------
    (49, 50, 51, 52, 0, 0, 0, 0)
    (49, 50, 51, 52, 53, 54, 55, 56)
    -----------------
    (57, 58, 59, 60, 0, 0, 0, 0)
    (57, 58, 59, 60, 61, 62, 63, 64)

  • Henry,

    It appears MS Visual C++ cannot pack bitfields like gcc/g++ can. Furthermore, the implementation of the SE setup register and SA setup register is dependent upon this bitfield packing behavior. It seems the previous C7000 compiler package worked in some cases with MS Visual C++ because there were _set* functions that did the bitfield packing of the SE setup register manually. Although we were all probably all still getting lucky there as some bitfields in the SE setup register didn't have a "set" function to do the bitpacking. (The v1.3 C7000 compiler changed the API to the SE and SA setup registers to make it cleaner and more extensible. Thus, those "set" functions were removed from the API.)

    In short, it appears MS Visual C++ cannot be used for Host Emulation (at least at this time). g++ must be used instead.

    I will add a work-item to the team that involves fixing the issue (not sure if this can be done) or documenting that MS Visual C++ won't work with host emulation.

    -Todd

  • Todd,

    Thank you.