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

📄 pseudo_channel.c

📁 This model is just testing an idea of MIMO, which IEEE802.11n will have. But I havo not seen the s
💻 C
字号:
/*****************************************************************************//*   FIle Name : pseudo_channel.c                                            *//*   Description : WLAN Pseudo Channel Estimatitor                           *//*                 mode : [3]  1:step 0:bilinear interpolation               *//*                      : [2]  0:doubler input                               *//*                      : [1:0]  0:drift both in freq & time domain          *//*                      : [1:0]  1:drift only in freq_domain                 *//*                 level : White Noise level                                 *//*                 tx_freqerr : Transmitter's Frequency error                *//*                            : 0:0ppm 1:ppm -20:-20ppm (-20< f <20ppm)      *//*                 rx_freqerr : Receiver's Frequency error                   *//*                            : 0:0ppm 1:ppm -20:-20ppm (-20< f <20ppm)      *//*   author : miffie                                                         *//*   Date   : aug/12/05                                                      *//*   Copyright (c) 2005 miffie   All rights reserved.                        *//*****************************************************************************/struct complexset pseudo_channel(struct complexset datain, char mode, char level,                                char tx_freqerr, char rx_freqerr ) { int 	ii ;int 	size ;int     tmp0 ;int     startpoint ;double  tx_clock, rx_clock ;double  tx_carrierclock, rx_carrierclock ;double  tx_phase, rx_phase ;double  rx_time ;struct 	complex  *top ;struct 	complex  *noise ;struct 	complex  tmp1, tmp2 , tmp3;int     tx_floor , tx_ceil ;struct  complexset  ctop ;static  double pi = 3.14159265 ;   PRINTF("pseudo_channel size=%d tx_freqerr=%d rx_freqerr=%d\n", datain.size , tx_freqerr, rx_freqerr) ;   if (mode<4) { //doubler     tx_clock = 25.0* (1.0+(tx_freqerr/1000000.0)) ; //ns      rx_clock = 50.0* (1.0+(rx_freqerr/1000000.0)) ; //ns     size = (datain.size/2) +32 ; //+32 for extention   } //doubler   else { //single     tx_clock = 50.0* (1.0+(tx_freqerr/1000000.0)) ; //ns      rx_clock = 50.0* (1.0+(rx_freqerr/1000000.0)) ; //ns     size = datain.size +32 ; //+32 for extention   } //single   tx_carrierclock = 0.2*(1.0+(tx_freqerr/1000000.0)) ; //ns 5GHz   rx_carrierclock = 0.2*(1.0+(rx_freqerr/1000000.0)) ; //ns 5GHz          //sampling clock width    if (((top = (struct complex *)malloc(size*sizeof(struct complex)) ) == NULL) |       ((noise = (struct complex *)malloc((datain.size+72)*                                           sizeof(struct complex)) ) == NULL)){        PRINTF( " malloc failed in pseudo_channel.c\n") ;   } //fail   else { //allocated     //noise generation     for( ii=0;ii<(datain.size+72);ii++) {//noise         tmp0 = int_random( 2 ) ;        if (tmp0==0) tmp0= -1 ;        noise[ii].realp = (tmp0 * gamma_random( level )/4096.0)  ;        tmp1.realp = datain.data[ ii ].realp ;        tmp0 = int_random( 2 ) ;        if (tmp0==0) tmp0= -1 ;        noise[ii].image = (tmp0 * gamma_random( level )/4096.0) ;     } //noise     //add noise     startpoint = int_random( 24 ) ;     for( ii=0;ii<(datain.size);ii++) {//noise         noise[ii+startpoint].realp += datain.data[ ii ].realp ;        //printf("noise.realp(%d)=%6.3f <= %6.3f\n", ii, noise[ii+startpoint].realp, datain.data[ ii ].realp ) ;        noise[ii+startpoint].image += datain.data[ ii ].image ;        //printf("noise.image(%d)=%6.3f <= %6.3f\n", ii, noise[ii+startpoint].image, datain.data[ ii ].image ) ;     } //noise     //receiver's phase is randomized      rx_time = ((double )int_random(512)/512.0)*0.2 ; //ns 2pi=0.2ns     for( ii=0;ii<size;ii++) {//for       //printf("rx_time = %10.6f\n",  rx_time ) ;       //Bi-Linear Interpolation @rx_time       tx_floor = floor(rx_time/tx_clock) ;       tx_ceil = tx_floor +1 ;       tmp1.realp = noise[tx_floor].realp ;       tmp1.image = noise[tx_floor].image ;       tmp2.realp = noise[tx_ceil].realp ;       tmp2.image = noise[tx_ceil].image ;       if (mode&0x8)  { //step         //step          top[ii].realp = tmp1.realp ;         top[ii].image = tmp1.image ;       } //step       else { //else         //Bi-Linear interpolation         top[ii].realp =          (((rx_time - (tx_clock*tx_floor))* tmp2.realp) +          (((tx_clock*tx_ceil) - rx_time)* tmp1.realp)) /          tx_clock  ;         top[ii].image =          (((rx_time - (tx_clock*tx_floor))* tmp2.image) +          (((tx_clock*tx_ceil) - rx_time)* tmp1.image)) /          tx_clock  ;       } //else       if ((mode&0x1)==0) { //time domain drift & freq         //calculate phase drift in Tx         tx_phase = (rx_time*2.0*pi)/tx_carrierclock ;         tmp1.realp = cos ( tx_phase ) ;         tmp1.image = sin ( tx_phase ) ;         tmp2 = multiply_complex(top[ ii ] , tmp1 ) ;         //calculate phase drift in Rx         rx_phase = (rx_time*2.0*pi)/rx_carrierclock ;         tmp1.realp = cos ( rx_phase ) ;         tmp1.image = sin ( rx_phase ) ;         top[ ii ] = multiply_complex(tmp2  ,tmp1 )  ;       } //time domain drift & freq       rx_time += rx_clock ;     } //for   } //allocated      ctop.data = top ;   ctop.size = size ;   free( datain.data ) ;   free( noise ) ;   return( ctop ) ;}//pseudo_channel 

⌨️ 快捷键说明

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