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

📄 interlev.c

📁 TI的DSP C55X的应用程序
💻 C
字号:
/***********************************************************************************/
/*                      IS54 Baseband Simulation Software                          */
/*                                                                                 */
/*  File Description : IS54 Data Interleave/De-Interleave routines                 */
/*  File Name        : interlev.c                                                  */
/*  Date             : 12/30/93                                                    */
/*                   : July, 20001 - Modified for TMS320C55x project               */
/*                                                                                 */
/*   IS54 Data Interleave/De-Interleave routines.                                  */
/*                                                                                 */
/*    This file serves as a utility for the data interleave/de-interleave          */
/*    requirements for IS54 slot data. Prior to transmit, even bits from           */
/*    the previous frame are interleaved with odd bits in the current              */
/*    frame, while the even bits of the current frame are stored for the           */
/*    interleave process in the next frame. On the receive side, a similar         */
/*    de-interleave process is performed to re-construct the original data.        */
/*                                                                                 */
/*    Functions:                                                                   */
/*                                                                                 */
/*        interleave_init() : This function initializes the previous               */
/*                            frame data to zeroes. This should be called          */
/*                            during initialization.                               */
/*                                                                                 */
/*        interleave()      : This function interleaves transmit data with         */
/*                            saved data from the previous frame, while            */
/*                            updating the saved data for use in the following     */
/*                            frame.                                               */
/*                                                                                 */
/*        deinterleave()    : This function de-interleaves receive data with       */
/*                            saved data from the previous frame, while            */
/*                            updating the saved data for use in the following     */
/*                            frame.                                               */
/*                                                                                 */
/*                                                                                 */
/*    Data :                                                                       */
/*        tx_save[130]      : This array holds the "even" bits of the previous     */
/*                            transmit frame.                                      */
/*                                                                                 */
/*        rx_save[130]      : This array holds the "odd" bits of the previous      */
/*                            receive frame.                                       */
/*                                                                                 */
/***********************************************************************************/

/* Include Files */

/* Defines */

/* Function Prototypes */

void    interleave_init( void );
void    interleave( unsigned*, unsigned* );
void    deinterleave( unsigned*, unsigned* );

/* External Function Prototypes */

/* Data */

unsigned    rx_save[130], tx_save[130];

/* External Data */

/* Code */


/****************************************************/
/* Function : interleave_init()                     */
/*                                                  */
/* Procedure :                                      */
/*          This routine initializes the receive    */
/*          and transmit history bits to zero.      */
/* Inputs :                                         */
/*          NONE                                    */
/* Outputs :                                        */
/*          tx_save[] : Filled with zeroes          */
/*          rx_save[] : Filled with zeroes          */
/*                                                  */
/****************************************************/
 
void    interleave_init()
{
    int i;
    
    for( i = 0; i < 130; i++ )  rx_save[i] = tx_save[i] = 0;
    return;
}

/************************************************************************/
/* Function : interleave()                                              */
/*                                                                      */
/* Procedure :                                                          */
/*          This routine inputs an 260-bit array of transmit data       */
/*          bits for the current frame. The "odd" bits of the current   */
/*          frame are interleaved with the old "even" bits (stored in   */
/*          tx_save[]) to produce a 260-bit interleaved transmit data   */
/*          array. The "even" bits of the current frame are stored in   */
/*          tx_save[].                                                  */
/*                                                                      */
/* Inputs :                                                             */
/*          slot_data : Pointer to 260-bit array, whose elements        */
/*                      (0's & 1's) represent the 260 data bits in the  */
/*                      current transmit slot.                          */
/*                                                                      */
/*          tx_save   : This is a 130-element array containing the      */
/*                      "even" bits for the previous frame.             */
/*                                                                      */
/* Outputs :                                                            */
/*          islot_data : Pointer to 260-bit array, whose elements       */
/*                      (0's & 1's) represent the 260 interleaved data  */
/*                      bits in the current transmit slot. The odd bits */
/*                      in this stream are filled from the odd bits of  */
/*                      "slot_data", and the even bits are filled from  */
/*                      the bits in "tx_save" prior to the call.        */
/*                                                                      */
/*          tx_save   : The 130 "even" bits of the current frame are    */
/*                      written here for use in interleaving the next   */
/*                      frame.                                          */
/*                                                                      */
/************************************************************************/
        
void    interleave( unsigned *slot_data, unsigned *islot_data )
{
    unsigned    *save_ptr; 
    int         i;
    
    save_ptr = tx_save;
    for( i = 0; i < 130; i++ )
    {
        *(islot_data++)   = *(save_ptr);        /* Grab old "even" bit  */
        *(save_ptr++)     = *(slot_data++);     /* Store new "even" bit */
        *(islot_data++)   = *(slot_data++);     /* New "odd" bit      */ 
    }
    return;
}


/************************************************************************/
/* Function : deinterleave()                                            */
/*                                                                      */
/* Procedure :                                                          */
/*          This routine inputs an 260-bit array of receive data        */
/*          bits for the current frame. The "even" bits of the current  */
/*          frame are deinterleaved with the old "odd" bits (stored in  */
/*          rx_save[]) to produce a 260-bit deinterleaved receive data  */
/*          array. The "odd" bits of the current frame are stored in    */
/*          rx_save[].                                                  */
/*                                                                      */
/* Inputs :                                                             */
/*          islot_data : Pointer to 260-bit array, whose elements       */
/*                      (0's & 1's) represent the 260 data bits in the  */
/*                      current receive slot.                           */
/*                                                                      */
/*          rx_save   : This is a 130-element array containing the      */
/*                      "odd" bits for the previous frame.              */
/*                                                                      */
/* Outputs :                                                            */
/*          slot_data : Pointer to 260-bit array, whose elements        */
/*                      (0's & 1's) represent the 260 deinterleaved     */
/*                      data bits in the current receive slot. The      */
/*                      even bits in this stream are filled from the    */
/*                      even bits of "islot_data", and the odd bits     */
/*                      are filled from the bits in "rx_save" prior to  */
/*                      the call.                                       */
/*                                                                      */
/*          rx_save   : The 130 "odd" bits of the current frame are     */
/*                      written here for use in deinterleaving the next */
/*                      frame.                                          */
/*                                                                      */
/************************************************************************/

void    deinterleave( unsigned *islot_data, unsigned *slot_data )
{ 
    unsigned    *save_ptr; 
    int         i;
    
    save_ptr = rx_save;
    for( i = 0; i < 130; i++ )
    {
        *(slot_data++)   = *(islot_data++);     /* New "even" bit       */ 
        *(slot_data++)   = *(save_ptr);         /* Grab old "odd" bit   */
        *(save_ptr++)    = *(islot_data++);     /* Store new "odd" bit  */
    }
    return;
}




⌨️ 快捷键说明

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