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

📄 mapper.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 : mapper.c                                                    *//*   Description : WLAN OFDM Subcarrier modulation mapper for Encoder        *//*   author : miffie                                                         *//*   Date   : aug/08/05                                                      *//*   Copyright (c) 2005 miffie   All rights reserved.                          *//*****************************************************************************/struct complexset mapper (struct binaryset datain,                           char Nbpsc,                          char *pilot_shifter ) {int 	ii , pp ;char 	shifter ;char 	tmp1 ;char    pilot_polarity ;struct 	complexset cset ;struct  complex    *top ;char    *p ;static  char  bpsk_map[] = {-1, 1 } ;static  char  qpsk_map[] = {-1, 1 } ;static  char  qam16_map[] = {-3, -1, 3, 1 } ; //Gray codedstatic  char  qam64_map[] = {-7, -5, -1, -3, 7, 5, 1, 3 } ; //Gray codedstatic  double Kmod_bpsk = 1 ;	static  double Kmod_qpsk = 0.70710678 ; //1/(sqrt (2)) ;	static  double Kmod_qam16 = 0.31622777 ;static  double Kmod_qam64 = 0.15430335 ;  //Main     if ((top = (struct complex *)malloc(64*sizeof(struct complex)) ) == NULL) {        PRINTF( " malloc failed in mapper.c\n") ;    } //fail    else { //allocated     //OFDM randomizer     *pilot_shifter = pilot_randomizer( *pilot_shifter ) ;     pilot_polarity = *pilot_shifter & 0x1 ;     if ( pilot_polarity ==1) pilot_polarity = -1 ;     else pilot_polarity =1 ;     PRINTF("mapper size=%d pilot_polarity=%d\n", datain.size, pilot_polarity ) ;     p= datain.data ;     switch ( Nbpsc ) { //switch       case 1: { //BPSK            for(ii=-26;ii<=26;ii++) { //each subcarrier               //pilot              if ((ii!=-21)&(ii!=-7)&(ii!=0)&(ii!=7)&(ii!=21)) { //not pilot                 tmp1 = (*p++) ;                 top[ii+32].realp = bpsk_map[ tmp1 ] * Kmod_bpsk;                 top[ii+32].image = 0 ;              }//not pilot            } //each subcarrier            break ;       } //BPSK       case 2: { //QPSK            for(ii=-26;ii<=26;ii++) { //each subcarrier               //pilot              if ((ii!=-21)&(ii!=-7)&(ii!=0)&(ii!=7)&(ii!=21)) { //not pilot                 //tmp1 = (*p++<<1) + (*p++) ;                 tmp1 = (*p++) ;                 top[ii+32].realp = qpsk_map[ tmp1 ] * Kmod_qpsk;                 tmp1 = (*p++) ;                 top[ii+32].image = qpsk_map[ tmp1 ] * Kmod_qpsk;              }//not pilot            } //each subcarrier            break ;       } //QPSK       case 4: { //16QAM            for(ii=-26;ii<=26;ii++) { //each subcarrier               //pilot              if ((ii!=-21)&(ii!=-7)&(ii!=0)&(ii!=7)&(ii!=21)) { //not pilot                 tmp1 = (*p++<<1)  ;                 tmp1 += (*p++) ;                  //printf("subcarrier (%d) %d ", ii, tmp1 ) ;                 top[ii+32].realp = qam16_map[ tmp1 ] * Kmod_qam16 ;                 tmp1 = (*p++<<1)  ;                 tmp1 += (*p++) ;                  //printf(" %d\n", tmp1 ) ;                 top[ii+32].image = qam16_map[ tmp1 ] * Kmod_qam16 ;              }//not pilot            } //each subcarrier            break ;       } //16QAM       default: { //64QAM            for(ii=-26;ii<=26;ii++) { //each subcarrier               //pilot              if ((ii!=-21)&(ii!=-7)&(ii!=0)&(ii!=7)&(ii!=21)) { //not pilot                 tmp1 = (*p++<<2)  ;                 tmp1 += (*p++<<1)  ;                 tmp1 += (*p++) ;                 top[ii+32].realp = qam64_map[ tmp1 ] * Kmod_qam64 ;                 tmp1 = (*p++<<2)  ;                 tmp1 += (*p++<<1)  ;                 tmp1 += (*p++) ;                 top[ii+32].image = qam64_map[ tmp1 ] * Kmod_qam64 ;              }//not pilot            } //each subcarrier            break ;       } //64QAM     }//switch     //Blank subcarriers     for(ii=-32;ii<=-27;ii++) { //each subcarrier       top[ii+32].realp = 0 ;       top[ii+32].image = 0 ;     } //each subcarrier     for(ii=27;ii<=31;ii++) { //each subcarrier       top[ii+32].realp = 0 ;       top[ii+32].image = 0 ;     } //each subcarrier     //pilot subcarriers     top[ -21 + 32 ].realp =  pilot_polarity ;     top[ -21 + 32 ].image =  0 ;     top[ -7 + 32 ].realp =  pilot_polarity ;     top[ -7 + 32 ].image =  0 ;     top[ 7 + 32 ].realp =  pilot_polarity ;     top[ 7 + 32 ].image =  0 ;     top[ 21 + 32 ].realp =  -pilot_polarity ;     top[ 21 + 32 ].image =  0 ;     cset.size = 64 ;     cset.data = top ;    }//allocated    free( datain.data ) ;    return ( cset ) ;} //mapper

⌨️ 快捷键说明

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