⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 slotbits.c

📁 TI的DSP C55X的应用程序
💻 C
📖 第 1 页 / 共 3 页
字号:
/* Function : build_slot_data()                                         */
/*                                                                      */
/* Procedure :  This routine constructs 260-bit slot data from the      */
/*              cl2[], cc0[] & cc1[] bit arrays. This routine is passed */
/*              pointers to the cl2[], cc0[] and cc1[] bit arrays in    */
/*              addition to a pointer where the output 260-bit slot     */
/*              data should be stored.                                  */
/*                                                                      */
/*              Each bit in the cl2[], cc0[] & cc1[] bit arrays         */
/*              is assigned a specific bit in the 260-bit slot data     */
/*              data bit array as defined in tables "cl2_table[]",      */
/*              "cc0_table[]" and "cc1_table[]".                        */
/*                                                                      */
/*              For cl2[], cc0[], and cc1[], this routine runs through  */
/*              the corresponding conversion table and sets the         */
/*              appropriate bit in the slot data bit array.             */
/*                                                                      */
/* Inputs :                                                             */
/*      [PARAMETERS]                                                    */
/*          cl2     : Pointer to 82-element class-2 (cl2[]) bit array.  */
/*                    Each element of this array should contain a       */
/*                    binary value (0 or 1).                            */
/*                                                                      */
/*          cc0     : Pointer to 89-element cc0[] bit array.            */
/*                    Each element of this array should contain a       */
/*                    binary value (0 or 1).                            */
/*                                                                      */
/*          cc1     : Pointer to 89-element cc1[] bit array.            */
/*                    Each element of this array should contain a       */
/*                    binary value (0 or 1).                            */
/*                                                                      */
/*      [GLOBALS/TABLES]                                                */
/*          cl2_table[]   : slot_data[] <-> cl2[] conversion table.     */
/*          cc0_table[]   : slot_data[] <-> cc0[] conversion table.     */
/*          cc1_table[]   : slot_data[] <-> cc1[] conversion table.     */
/*                                                                      */
/* Outputs :                                                            */
/*          slot    : Pointer to 260-element buffer where the resultant */
/*                    slot data should be written. Each element of this */
/*                    bit array will be assigned a value (0 or 1)       */
/*                    depending on the current state of the associated  */
/*                    bit in one of the input bit arrays.               */
/*                                                                      */
/* Return Value :                                                       */
/*          NONE                                                        */
/*                                                                      */ 
/************************************************************************/
                            
void    build_slot_data( unsigned *cl2, unsigned *cc0, unsigned *cc1, unsigned *slot )
{
        int i;
        unsigned    *table_ptr;

  /* Set slot data bits associated with cc0[] bits */
        table_ptr = cc0_table;        
        for( i = 0; i < 89; i++ )  slot[ *(table_ptr++) ] = *(cc0++); 

  /* Set slot data bits associated with cc1[] bits */
        table_ptr = cc1_table;        
        for( i = 0; i < 89; i++ )  slot[ *(table_ptr++) ] = *(cc1++); 

  /* Set slot data bits associated with cl2[] bits */
        table_ptr = cl2_table;        
        for( i = 0; i < 82; i++ )  slot[ *(table_ptr++) ] = *(cl2++);
        
        return; 
}                              

/************************************************************************/
/*                                                                      */
/* Function : extract_slot_bits()                                       */
/*                                                                      */
/* Procedure :  This routine constructs the cl2[], cc0[] & cc1[] bit    */
/*              arrays from 260-bit slot data bit array.                */
/*              This routine is passed a pointer to the 260-element     */
/*              slot data buffer in addition to pointers to where       */
/*              the resultant cl2[], cc0[] and cc1[] bit arrays should  */
/*              be stored.                                              */
/*                                                                      */
/*              Each bit in the cl2[], cc0[] & cc1[] bit arrays         */
/*              is assigned a specific bit in the 260-bit slot data     */
/*              data bit array as defined in tables "cl2_table[]",      */
/*              "cc0_table[]" and "cc1_table[]".                        */
/*                                                                      */
/*              For cl2[], cc0[], and cc1[], this routine runs through  */
/*              the corresponding conversion table and sets or clears   */
/*              the appropriate bit in these output arrays depending    */
/*              on the state of the associated slot data bit.           */
/*                                                                      */
/* Inputs :                                                             */
/*      [PARAMETERS]                                                    */
/*          slot    : Pointer to 260-element slot data buffer.          */
/*                    Each element of this array should contain a       */
/*                    binary value (0 or 1).                            */
/*                                                                      */
/*      [GLOBALS/TABLES]                                                */
/*          cl2_table[]   : slot_data[] <-> cl2[] conversion table.     */
/*          cc0_table[]   : slot_data[] <-> cc0[] conversion table.     */
/*          cc1_table[]   : slot_data[] <-> cc1[] conversion table.     */
/*                                                                      */
/* Outputs :                                                            */
/*          cl2     : Pointer to 82-element buffer where the resultant  */
/*                    class-2 (cl2[]) bit array should be written.      */
/*                    Each element of this array will be assigned a     */
/*                    binary value (0 or 1) depending on the state of   */
/*                    the associated slot data bit.                     */
/*                                                                      */
/*          cc0     : Pointer to 89-element buffer where the resultant  */
/*                    cco[] bit array should be written.                */
/*                    Each element of this array will be assigned a     */
/*                    binary value (0 or 1) depending on the state of   */
/*                    the associated slot data bit.                     */
/*                                                                      */
/*          cc1     : Pointer to 89-element buffer where the resultant  */
/*                    cc1[] bit array should be written.                */
/*                    Each element of this array will be assigned a     */
/*                    binary value (0 or 1) depending on the state of   */
/*                    the associated slot data bit.                     */
/*                                                                      */
/* Return Value :                                                       */
/*          NONE                                                        */
/*                                                                      */ 
/************************************************************************/

void    extract_slot_bits( unsigned *cl2, unsigned *cc0, unsigned *cc1, unsigned *slot )
{
        int i;
        unsigned    *table_ptr;

  /* Set cc0[] bits according to states of associated slot data bits */
        table_ptr = cc0_table;        
        for( i = 0; i < 89; i++ )  *(cc0++) = slot[ *(table_ptr++) ]; 

  /* Set cc1[] bits according to states of associated slot data bits */
        table_ptr = cc1_table;        
        for( i = 0; i < 89; i++ )  *(cc1++) = slot[ *(table_ptr++) ]; 

  /* Set cl2[] bits according to states of associated slot data bits */
        table_ptr = cl2_table;        
        for( i = 0; i < 82; i++ )  *(cl2++) = slot[ *(table_ptr++) ];
        
        return; 
}                              
    
/************************************************************************/
/*                                                                      */
/* Function : build_slot()                                              */
/*                                                                      */
/* Procedure :  This routine constructs a 324-bit formatted slot from   */
/*              260-bit slot data according to the following:           */
/*                                                                      */
/*                  1st  28 bits  : Slot #1 Sync Word                   */
/*                  Next 12 bits  : 0                                   */
/*                  Next 130 bits : 1st 130 bits of slot data           */
/*                  Next 12 bits  : 0                                   */
/*                  Next 130 bits : 2nd 130 bits of slot data           */
/*                  Last 12 bits  : 0                                   */
/*                                                                      */
/* Inputs :                                                             */
/*          data    : Pointer to 260-element bit array representing     */
/*                    the data bits for the slot. (Note that all        */
/*                    elements should be binary, i.e. 0's and 1's only).*/
/*                                                                      */
/* Outputs :                                                            */ 
/*          slot    : Pointer to 324-element bit array where the        */
/*                    resultant formatted slot shall be stored.         */
/*                    (Note that since data is copied from the input    */
/*                    slot data buffer, a resulting binary              */
/*                    representation is dependent on a binary           */
/*                    representation for the input slot data).          */
/*                                                                      */
/* Return Value :                                                       */
/*          NONE                                                        */
/*                                                                      */
/************************************************************************/
    
void    build_slot( unsigned *data, unsigned *slot )
{   
    int         i;
    unsigned    sync1[28]= {1,0,1,0,1,0,0,1,0,0,0,1,1,1,0,1,1,1,1,0,
                            0,1,0,0,1,0,1,0};

    for( i = 0; i < 28;  i++ )  *(slot++) = sync1[i];
    for( i = 0; i < 12;  i++ )  *(slot++) = 0;
    for( i = 0; i < 130; i++ )  *(slot++) = *(data++);
    for( i = 0; i < 12;  i++ )  *(slot++) = 0;
    for( i = 0; i < 130; i++ )  *(slot++) = *(data++);
    for( i = 0; i < 12;  i++ )  *(slot++) = 0;    
    return;

} 

/************************************************************************/
/*                                                                      */
/* Function : get_slot_data()                                           */
/*                                                                      */
/* Procedure :  This routine extracts 260-bit slot data from a          */
/*              324-bit formatted slot. The slot data is extracted      */
/*              in two 130-bit segments starting at bit #40, then       */
/*              bit #182.                                               */
/*                                                                      */
/* Inputs :                                                             */
/*          slot    : Pointer to 324-element bit array representing     */
/*                    a formatted IS54 slot. (Note that all elements    */
/*                    should be binary, i.e. 0's and 1's only).         */
/*                                                                      */
/* Outputs :                                                            */ 
/*          data    : Pointer to 260-element bit array where the slot   */
/*                    data shall be stored. (Note that since this data  */
/*                    is copied from the formatted slot, a resulting    */
/*                    binary representation is dependent on a binary    */
/*                    representation for the formatted slot).           */
/*                                                                      */
/* Return Value :                                                       */
/*          NONE                                                        */
/*                                                                      */ 
/************************************************************************/

void    get_slot_data( unsigned *slot, unsigned *data )
{               
    unsigned    *slot_ptr; 
    int         i;
    
    slot_ptr = slot + 40;
    for( i = 0; i < 130; i++ )  *(data++) = *(slot_ptr++);
    slot_ptr = slot + 182;
    for( i = 0; i < 130; i++ )  *(data++) = *(slot_ptr++);
    
    return;    
}  
                        
                            



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -