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

📄 ppdu_dec.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 : ppdu_dec.c                                                  *//*   Description : WLAN PPDU  Decoder                                        *//*   author : miffie                                                         *//*   Date   : aug/12/05                                                      *//*   Copyright (c) 2005 miffie   All rights reserved.                        *//*****************************************************************************/struct binaryset ppdu_dec ( struct complexset datain ) { //ppdu_decint 	ii ;struct	binaryset btop, bset0, bset1 ;struct  complexset cset0, cset1 , sram ;char 	pilot_shifter ;char 	*tmp1 , *tmp2 ;char    Nbpsc, coding_rate ;short   Ncbps, Ndbps, Nsym, Ndata, Npad ;char	RATE ;short 	LENGTH ;char	scrtmp ;double  drift_phase, drift_amount, previous_drift ;char    drift_change ;int	detection ; //Decoder  PRINTF("... start Decoding\n" ) ;  print_complexset( datain ) ;  //Detection  detection = detect_pre( datain ) ;   if (detection<datain.size) { //Preamble detected    //Short sequence    //Course phase error detection    cset1 = extract_complexset(datain , detection-64 , 32 ) ; //Short sequence    drift_amount =   detect_drift( cset1 , 16 ) ;    //Long sequence    //Fine phase error detection    drift_phase = 0 ;    cset1 = extract_complexset(datain , detection , 128 ) ; //Long sequence    cset1 = phase_drift(cset1 , &drift_phase , &drift_amount ) ;    drift_amount += detect_drift( cset1 , 64 ) ;    //DFT64    //if use 2 of 64samples for the DFT in LONGseq ,     //S/N will be got better by +3dB (Not implemented)    cset1 = extract_complexset(cset1 , 64 , 64 ) ; //The latter Long sequence    //print_complexset( cset1 ) ;    cset1 = dft64 ( cset1 ) ;    //Compare with Table G.5 for Frequency Domain of the long sequence    //print_complexset( cset1 ) ;    sram = long_track( cset1 ) ;    //print_complexset( sram ) ;    previous_drift = 100 ;    drift_phase += drift_amount *16 ; //for Guard interval    //SIGNAL    pilot_shifter = 0x7f ;    cset1 = extract_complexset(datain , detection+64+80 , 64 ) ; //Long sequence    cset1 = phase_drift(cset1 , &drift_phase , &drift_amount ) ;    drift_phase += drift_amount *16 ; //for Guard interval    cset1 = dft64 ( cset1 ) ;    //print_complexset( cset1 ) ;    drift_change = 0 ;    cset1 = data_track( cset1 , &sram , &pilot_shifter,                  &previous_drift, &drift_amount, &drift_change ) ;    //Compare with Table G.10 for Frequency Domain of SIGNAL     //print_complexset( cset1 ) ;    bset1 = constellation ( cset1 , 1 ) ; //Nbpsc=1    bset1 = deinterleaver(bset1 , 1 ) ; //Nbpsc=1    //Compare with Table G.18 for deinterleaved data    //pad bit    bset0 = pad_binaryset(138) ;    bset1 = cat_binaryset(bset1, bset0) ;    //print_binaryset( bset1 ) ;    //viterbi decoder    bset1 = viterbi(bset1) ;    //print_binaryset( bset1 ) ;    //Decode SIGNAL Field    bset1 = binary2byte ( bset1 ) ;    RATE = bset1.data[0] & 0xf ;    LENGTH = (bset1.data[0]>>5) & 0x7 ;    LENGTH += (bset1.data[1]<<3) & 0x7f8 ;    LENGTH += ((bset1.data[2]&0x1)<<11) & 0x800 ;    PRINTF("SIGNAL decoded RATE=0x%0x LENGTH=0x%0x\n", RATE, LENGTH ) ;// Rate(Mbps)   RATE(R1-R4) Coding_Rate Modulation Nbpsc Ncbps Ndbps//     6          1101        0:1/2        BPSK     1     48    24//     9          1111        2:3/4        BPSK     1     48    36//    12          0101        0:1/2        QPSK     2     96    48//    18          0111        2:3/4        QPSK     2     96    72//    24          1001        0:1/2        QAM16    4    192    96//    36          1011        2:3/4        QAM16    4    192   144//    48          0001        1:2/3        QAM64    6    288   192//    54          0011        2:3/4        QAM64    6    288   216    switch ( RATE ) { //switch      case 0xb: { //6Mbps           Nbpsc  = 1 ;           coding_rate = 0 ;           Ncbps = 48 ;           Ndbps = 24 ;           break ;      }      case 0xf: { //9Mbps           Nbpsc  = 1 ;           coding_rate = 2 ;           Ncbps = 48 ;           Ndbps = 36 ;           break ;      }      case 0xa: { //12Mbps           Nbpsc  = 2 ;           coding_rate = 0 ;           Ncbps = 96 ;           Ndbps = 48 ;           break ;      }      case 0xe: { //18Mbps           Nbpsc  = 2 ;           coding_rate = 2 ;           Ncbps = 96 ;           Ndbps = 72 ;           break ;      }      case 0x9: { //24Mbps           Nbpsc  = 4 ;           coding_rate = 0 ;           Ncbps = 192 ;           Ndbps = 96 ;           break ;      }      case 0xd: { //36Mbps           Nbpsc  = 4 ;           coding_rate = 2 ;           Ncbps = 192 ;           Ndbps = 144 ;           break ;      }      case 0x8: { //48Mbps           Nbpsc  = 6 ;           coding_rate = 1 ;           Ncbps = 288 ;           Ndbps = 192 ;           break ;      }      case 0xc: { //54Mbps           Nbpsc  = 6 ;           coding_rate = 2 ;           Ncbps = 288 ;           Ndbps = 216 ;           break ;      }    } //switch    //Nsym , Ndata, Npad    Nsym = (16 + 8* LENGTH +6+ Ndbps-1)/Ndbps ;    Ndata = Nsym * Ndbps ;    Npad = Ndata - ( 16 + 8*LENGTH + 6 ) ;    //DATA    for (ii=0;ii<Nsym;ii++) { //each symbol      PRINTF(" the %dth Symbol out of %d\n" , ii, Nsym ) ;      cset1 = extract_complexset(datain , detection+80*2+64+(80*ii) , 64 ) ; //Long sequence      //print_complexset( cset1 ) ;      cset1 = phase_drift(cset1 , &drift_phase , &drift_amount ) ;      drift_phase += drift_amount *16 ; //for Guard interval      //print_complexset( cset1 ) ;      cset1 = dft64 ( cset1 ) ;      print_complexset( cset1 ) ;      cset1 = data_track( cset1 , &sram , &pilot_shifter ,                  &previous_drift, &drift_amount, &drift_change ) ;      //Compare with Table G.22 for Frequency Domain of first DATA      print_complexset( cset1 ) ;      bset1 = constellation ( cset1 , Nbpsc ) ; //Nbpsc=4      print_binaryset( bset1 ) ;      bset1 = deinterleaver(bset1 , Nbpsc ) ; //Nbpsc=4      //Compare with Table G.18 for deinterleaved data      //print_binaryset( bset1 ) ;      //depuncturing      bset1 = depuncturing(bset1 , coding_rate ) ; //rate 2:3/4      //print_binaryset( bset1 ) ;      if (ii==0) { //first DATA symbol         btop = copy_binaryset( bset1 ) ;      } //first DATA symbol      else { //other DATA symbols         btop = cat_binaryset( btop, bset1 ) ;      }    } //each symbol      //viterbi decoder      //take only valid bits      //remove unnecessary padding bit      btop.size =  ( 16 + 8*LENGTH + 6 )*2 ;      //pad bit      bset0 = pad_binaryset(138) ;      btop = cat_binaryset(btop, bset0) ;      //print_binaryset( btop ) ;      btop = viterbi(btop) ;      //print_binaryset( btop ) ;          //Scrambler      //first 7 bit will initialize the scrambler       scrtmp = 0 ;      for(ii=0;ii<=6;ii++) {        scrtmp += btop.data[ii]<<(6-ii) ;      }       //remove first 7bit      btop.data = &btop.data[7] ;       btop.size = btop.size-7 ;       btop = scrambler(btop , scrtmp ) ;      //remove SREVICE field      btop.data = &btop.data[9] ;       btop.size = btop.size-9 ;       btop.size = LENGTH*8 ;      //COmpare with Table G.16 &G.17 for scrambling      //print_binaryset( btop ) ;  } //detected  return ( btop ) ;} //ppdu_dec

⌨️ 快捷键说明

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