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

📄 frame_enc.c

📁 OFDM是wimax的关键技术
💻 C
字号:
/*****************************************************************************//*   FIle Name : frame_enc.c                                                 *//*   Description : WiMax SC  downlink frame encoder                          *//*   author : miffie                                                         *//*   Date   : oct/13/05                                                      *//*   Copyright (c) 2005 miffie   All rights reserved.                        *//*****************************************************************************///This frame encoder can have only a single payload burst.//DIUC=0 set for frame control //DIUC=1 will be selected randomlystruct complexset frame_enc( struct binaryset datain,                             struct Downlink_Burst_Profile diuc1   ) { // int 	ii , jj , nn ;struct  binaryset bset0, bset1 , btop ;struct  complexset cset0, cset1 , ctop ;short 	tmp1 ;int     length ;struct  Downlink_Burst_Profile diuc[8] ;struct  DLFP_IE   dlfp[4] ;char 	PHY_type = 0x01 ; //0:TDD 1:FDDchar 	Frame_duration = 0x01 ; //1: 0.5ms 2:1  3:2 4-0xf:reservedchar 	fec_code_type  ; short   pilot_shifter ;char    subchannel_index ;char    Nbpsc ;short   Nsub, Ndbps, Nbps ;//bit per subchannel per symbol before FECchar    Nbpss[] = { 6, 12, 18, 24, 36, 48, 54 } ;char    rs_cc_block[] =  { 12, 24, 36, 48, 72, 96, 108 } ;char    btc_block[] =  { 23, 35, 58, 77, 96, 120 } ;char    ctc_block[] =  { 6, 8, 9, 12, 18, 24, 27 } ;char    CP ;short   randomizer_seed ;short 	BSID = 1 ;short 	DIUC = 7 ;short 	frame_number = 1 ;static char QPSK = 1 ;static char QAM16 = 2 ;static char QAM64 = 3 ; //DCD  //DIUC=0 well-known PRINTF(" frame_enc  DIUC1 fec_code_type=%d size=0x%x\n",  diuc1.fec_code_type, datain.size ) ; ///////////////////////////////////////////////////////////////////////// //CALCULATE xfr SIZE // This xfr size calculation is just for test purpose. // In real system, you may need to find another way to calculate  // frame size. ///////////////////////////////////////////////////////////////////////// subchannel_index = 0x10 ; CP = 64 ; Nsub = (subchannel_index&0x1) ? 1 :        (subchannel_index&0x2) ? 2 :        (subchannel_index&0x4) ? 4 :        (subchannel_index&0x8) ? 8 :        (subchannel_index==0x10) ? 16 : 0 ; fec_code_type = diuc1.fec_code_type ; if (fec_code_type<=6) { //RS-CC   Ndbps = Nsub * Nbpss[ fec_code_type ] ;   length = (datain.size+1 + rs_cc_block[ fec_code_type ]-1) /              rs_cc_block[ fec_code_type ] ;   length = (length * rs_cc_block[ fec_code_type ])  ; } else if (fec_code_type<=12) { //BTC   Ndbps = btc_block[ fec_code_type-7 ] *8 ;   length = (datain.size + btc_block[ fec_code_type-7 ] -1) /              btc_block[ fec_code_type-7 ] ;   length = (length * btc_block[ fec_code_type-7 ])  ; } else if (fec_code_type<=19) { //CTC   Ndbps = ctc_block[ fec_code_type-13 ] *Nsub ;   length = (datain.size + ctc_block[ fec_code_type-13 ] -1) /              ctc_block[ fec_code_type-13 ] ;   length = (length * ctc_block[ fec_code_type-13 ])  ; } //DL_FP_ELEMENT //DL_FP_ELEMENT //HCS example: pp452 //dlfp[0].DIUC = 1 ;  //dlfp[0].Preamble_present = 0 ; //dlfp[0].Length = 204 ;  //dlfp[1].DIUC = 1 ; //dlfp[1].Preamble_present = 1 ; //dlfp[1].Length = 50 ;  //dlfp[2].DIUC = 0 ;  //dlfp[2].Length = 0 ;  //dlfp[3].DIUC = 0 ;  //dlfp[3].Length = 0 ;  dlfp[0].DIUC = 1 ; //diuc1.fec_code_type ; //diuc1 dlfp[0].Preamble_present = 0 ; dlfp[0].Length =  ( (length*8) + Ndbps-1) / Ndbps ; dlfp[1].DIUC = 0 ; dlfp[1].Length = 0 ; dlfp[2].DIUC = 0 ;  dlfp[2].Length = 0 ;  dlfp[3].DIUC = 0 ;  dlfp[3].Length = 0 ;    ///////////////////////////////////////////////////////////////////////// //ENCODING /////////////////////////////////////////////////////////////////////////  //1.preamble    pilot_shifter = 0x7ff ;    ctop = preamble( CP ) ;    //print_complexset( ctop ) ;  //2.frame control    fec_code_type = 0 ;    Nbpsc = 1 ;    Nbps = Nsub * Nbpsc*12 ;    bset0 = frameprefix( &dlfp[0] , BSID, frame_number ) ;    print_binaryset( bset0 ) ;    //FEC    randomizer_seed = 0x00a9 ;    bset0 = fecenc( bset0, fec_code_type , &randomizer_seed ) ;    print_binaryset( bset0 ) ;    for (nn=0;nn<bset0.size;nn+=Nbps) { //each symbol      //Interleaver      bset1 = extract_binaryset( bset0, nn, Nbps ) ;      bset1 = interleaver(bset1 , Nbpsc ) ;      print_binaryset(bset1) ;      //OFDM mapper      cset0 = mapper (bset1, Nbpsc, subchannel_index, &pilot_shifter) ;      print_complexset( cset0 ) ;      //OFDM IFFT      cset0 = ofdm_symbol ( cset0 , CP ) ;      print_complexset( cset0 ) ;      ctop = cat_complexset( ctop , cset0 ) ;    } //each symbol  //3.payload  for (ii=0;ii<1;ii++) { //each burst    //FEC    fec_code_type = diuc1.fec_code_type ; //dlfp[ii].DIUC ;    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 ;    Nbps =  Nsub * Nbpsc*12 ;    if (ii>0) { //subsequent bursts      DIUC = dlfp[ii].DIUC ;      randomizer_seed= (BSID<<11) + (0x3<<9) + (DIUC<<5) + (0x1<<4) + frame_number ;      randomizer_seed = swap_short( randomizer_seed ) >> 1 ;    } //subsequent bursts    if (fec_code_type<=6) {      bset0 = pad_binaryset(length -  datain.size -1 ) ;      bset0.format = 1 ;      for (nn=0;nn<length-datain.size;nn++) bset0.data[nn]= 0xff ;      bset0 = cat_binaryset( datain, bset0 ) ;    }     else if (fec_code_type<=19) {      bset0 = copy_binaryset( datain ) ;    }    bset0 = fecenc( bset0, fec_code_type, &randomizer_seed ) ;    for (nn=0;nn<bset0.size;nn+=Nbps) { //each symbol      //Interleaver      bset1 = extract_binaryset( bset0, nn, Nbps ) ;      bset1 = interleaver(bset1 , Nbpsc ) ;      print_binaryset(bset1) ;      //OFDM mapper      cset0 = mapper (bset1, Nbpsc, subchannel_index, &pilot_shifter) ;      print_complexset( cset0 ) ;      //OFDM IFFT      cset0 = ofdm_symbol ( cset0 , CP ) ;      //print_complexset( cset0 ) ;      ctop = cat_complexset( ctop , cset0 ) ;    } //each symbol  } //each burst  //print_complexset( ctop ) ; ///////////////////////////////////////////////////////////////////////// //Shaping /////////////////////////////////////////////////////////////////////////  //ctop = doubler( ctop ) ;  return( ctop ) ;} //frame_enc

⌨️ 快捷键说明

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