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

📄 frame_dec.c

📁 OFDM是wimax的关键技术
💻 C
字号:
/*****************************************************************************//*   FIle Name : frame_dec.c                                                  *//*   Description : WI-Max OFDM  frame  Decoder                               *//*   author : miffie                                                         *//*   Date   : Nov/07/05                                                      *//*   Copyright (c) 2005 miffie   All rights reserved.                        *//*****************************************************************************/struct binaryset frame_dec ( struct complexset datain,                             struct Downlink_Burst_Profile diuc1 ) { //frame_decint 	ii , nn ;struct	binaryset btop, bset0, bset1 ;struct  complexset cset0, cset1 , sram ;short 	pilot_shifter ;char 	*tmp1 , *tmp2 ;char    Nbpsc, coding_rate ;short   Ncbps, Ndbps, Nsym, Ndata, Npad ;char	scrtmp ;double  drift_phase, drift_amount, previous_drift ;char    drift_cnt, sram_cnt ;int	detection ;short   randomizer_seed ;//bit per subchannel per symbol before FECchar    Nbpss[] = { 6, 12, 18, 24, 36, 48, 54 } ;char    Nsub ;char	BSID ;char	frame_number, fec_code_type ;struct  DLFP_IE dlfp[4] ;char    subchannel_index = 0x10 ;char    CP = 64 ;char    OFFSET = 8 ;//        <------symbol------>//         __________________ ___________________//        X_CP_|_____________X_CP_|______________X//           <---fft256---->//                         <->OFFSET Nsub = (subchannel_index&0x1) ? 1 :        (subchannel_index&0x2) ? 2 :        (subchannel_index&0x4) ? 4 :        (subchannel_index&0x8) ? 8 :        (subchannel_index==0x10) ? 16 : 0 ; //Decoder  PRINTF("... start Decoding\n" ) ;  //Detection  detection = detect_pre( datain ) ;   detection -= OFFSET ;  if (detection<datain.size) { //Preamble detected    /////////////////////////////    //Preamble    /////////////////////////////    //Short sequence    //Course phase error detection    cset1 = extract_complexset(datain , detection-256 , 256 ) ; //Short sequence    drift_amount = -detect_drift( cset1 , 64 , (double)(1.0/16.0),  0 ) ;    //Long sequence    //Fine phase error detection    drift_phase = 0 ;    detection+= CP ;    cset1 = extract_complexset(datain , detection , 256 ) ; //Long sequence    print_complexset( cset1 ) ;    cset1 = phase_drift(cset1 , &drift_phase , &drift_amount ) ;    print_complexset( cset1 ) ;    drift_amount -= detect_drift( cset1 , 128 , (double)(1.0/64.0),  0 ) ;    //DFT256    cset1 = dft256 ( cset1 ) ;    print_complexset( cset1 ) ;    sram = long_track( cset1 ) ;    print_complexset( sram ) ;    previous_drift = 100 ;    drift_phase += drift_amount *CP ; //for Guard interval    /////////////////////////////    //DLFP    /////////////////////////////    pilot_shifter = 0x7ff ;    detection += (CP+256) ; //Length of Long Sequence    cset1 = extract_complexset(datain , detection , 256 ) ; //DLFP    detection += (CP+256) ; //Length of DLFP    cset1 = phase_drift(cset1 , &drift_phase , &drift_amount ) ;    drift_phase += drift_amount *16 ; //for Guard interval    cset1 = dft256 ( cset1 ) ;    print_complexset( cset1 ) ;    drift_cnt = 0 ;    sram_cnt = 0 ;    cset1 = equalizer( cset1 , subchannel_index, &sram , &pilot_shifter,                  &drift_phase , &drift_cnt, &sram_cnt ) ;    print_complexset( cset1 ) ;    bset1 = constellation ( cset1 , 1 ) ; //Nbpsc=1    print_binaryset( bset1 ) ;    bset1 = deinterleaver(bset1 , 1 ) ; //Nbpsc=1    print_binaryset( bset1 ) ;    fec_code_type = 0 ;    randomizer_seed = 0x00a9 ;    bset1 = fecdec(bset1 , fec_code_type, &randomizer_seed ) ;    //Decode DLFP Field    btop.size=0;    btop.format=1;    bset0 = hcs( bset1 ) ;    if (bset0.data[0]==0) { //good HCS      BSID = (bset1.data[0]>>4) & 0xf ;      frame_number = bset1.data[0] & 0xf ;      printf(" Decoding DLFramePrefix\n" ) ;      printf("   BSID=%x frame_number=%x\n", BSID, frame_number ) ;      for(nn=0;nn<4;nn++) {        dlfp[nn].DIUC = (bset1.data[2+nn*2]>>4) & 0xf ;        dlfp[nn].Preamble_present = (bset1.data[2+nn*2]>>3) & 0x1 ;        dlfp[nn].Length = (bset1.data[2+nn*2]&0x7)<<8 ;        dlfp[nn].Length += bset1.data[3+nn*2]&0xff ;        printf("   DIUC(%d)=%x pp=%x Length=0x%x\n", nn, dlfp[nn].DIUC,                    dlfp[nn].Preamble_present, dlfp[nn].Length ) ;      }       //Nsym , Ndata, Npad      //Nsym = (16 + 8* Length +6+ Ndbps-1)/Ndbps ;      //Ndata = Nsym * Ndbps ;      //Npad = Ndata - ( 16 + 8*Length + 6 ) ;    /////////////////////////////    //Burst    /////////////////////////////      for (nn=0;nn<1;nn++) { //each burst        fec_code_type = diuc1.fec_code_type ; //diuc1[dlfp[0].DIUC].fec_code_type ;        //if (nn==0) fec_code_type = dlfp[0].DIUC ; //Rate_ID        //else fec_code_type = 0 ; //diuc[dlfp[0].DIUC].fec_code_type ;        Nbpsc = (fec_code_type==0) ? 1 :              (fec_code_type<=2) ? 2 :              (fec_code_type<=4) ? 4 :              (fec_code_type<=6) ? 6 :               (fec_code_type<=8) ? 2 :               (fec_code_type<=10) ? 4 :               (fec_code_type<=12) ? 6 :              (fec_code_type<=15) ? 2 :              (fec_code_type<=17) ? 4 :              (fec_code_type<=19) ? 6 : 0 ;        Ndbps = Nsub * Nbpsc*12 ;        for (ii=0;ii<dlfp[nn].Length;ii++) { //each symbol          PRINTF(" the %dth Symbol out of %d\n" , ii, dlfp[nn].Length ) ;          cset1 = extract_complexset(datain ,                                 detection  , 256 ) ;           detection += CP+256 ; //Length of each symbol          //print_complexset( cset1 ) ;          cset1 = phase_drift(cset1 , &drift_phase , &drift_amount ) ;          drift_phase += drift_amount *CP ; //for Guard interval          //print_complexset( cset1 ) ;          cset1 = dft256 ( cset1 ) ;          //print_complexset( cset1 ) ;          cset1 = equalizer( cset1 , subchannel_index, &sram , &pilot_shifter ,                  &drift_phase , &drift_cnt, &sram_cnt ) ;          print_complexset( cset1 ) ;          bset1 = constellation ( cset1 , Nbpsc ) ; //Nbpsc=4          print_binaryset( bset1 ) ;          bset1 = deinterleaver(bset1 , Nbpsc ) ; //Nbpsc=4          //print_binaryset( bset1 ) ;          btop = cat_binaryset( btop , bset1 ) ;        } //each symbol        //FEC        if (btop.size>0) { //not zero           if (nn>0) { //subsequent bursts            randomizer_seed= (BSID<<11) + (0x3<<9) + (dlfp[nn].DIUC<<5) +                              (0x1<<4) + frame_number ;            randomizer_seed = swap_short( randomizer_seed ) >> 1 ;          } //subsequent bursts          btop = fecdec(btop , fec_code_type, &randomizer_seed ) ;        } //not zero      } //each burst    } //good HCS  } //detected  return ( btop ) ;}//frame_dec

⌨️ 快捷键说明

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