www.pudn.com > wimax_ofdm_implementation_code.rar > frame_dec.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_dec
int 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 FEC
char 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>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;ii0) { //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