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

📄 viterbi_ctc.c

📁 这个文件包括wimax中所有的编解码源代码
💻 C
字号:
/*****************************************************************************//*   FIle Name : viterbi_ctc.c                                               *//*   Description : WiMax OFDM FEC Viterbi decoder for CTC                    *//*                 8x32 search                                               *//*   author : miffie                                                         *//*   Date   : Nov/21/05                                                      *//*   Copyright (c) 2005 miffie   All rights reserved.                        *//*****************************************************************************/struct binaryset viterbi_ctc (struct binaryset datain ) {int 	ii , jj ;short 	tmp0, tmp1, tmp2, tmp3 ;short 	exp0, exp1, exp2, exp3 ;struct 	binaryset bset ;char    *top ;short	brmetric[4] ;short	expmetric[2] ;short 	metric0[8], metric1[8] ;short	minimum_metric ;short	won_metric ;char	exp[8][4] ;char	rev[8][4] ;char	won[8] ;char    state ;int     NN ;long long   sdata0[8],sdata1[8] ;short	MAX_METRIC = 0x7f ;char    soft[1296] ;char    DELAY=16 ;  //Main     PRINTF("viterbi_ctc size=%d\n", datain.size ) ;    //initialize    NN = datain.size/3 ;    for(ii=0;ii<8;ii++) { //init      metric0[ii] = 0 ;      state =ii ;      exp[ii][0]  = constituent_encoder ( 0, 0, &state ) ;      rev[state][0]=ii;      state =ii ;      exp[ii][1]  = constituent_encoder ( 0, 1, &state ) ;      rev[state][1]=ii;      state =ii ;      exp[ii][2]  = constituent_encoder ( 1, 0, &state ) ;      rev[state][2]=ii;      state =ii ;      exp[ii][3]  = constituent_encoder ( 1, 1, &state ) ;      rev[state][3]=ii;    } //init           //metric0[0] = 0 ; //assumed the shiftregister reset to 0    for(ii=0;ii<(2*NN+DELAY);ii=ii+2) { //each cycle        //branch metric        tmp1 = (ii>=2*NN) ? 0 : datain.data[ii] ;        tmp2 = (ii>=2*NN) ? 0 : datain.data[ii+1] ;        tmp3 = (ii>=2*NN) ? 0 : datain.data[2*NN+(ii/2)] ;        brmetric[0] = tmp1 + tmp2 ;        brmetric[1] = tmp1 + (0xf-tmp2) ;        brmetric[2] = (0xf-tmp1) + tmp2 ;        brmetric[3] = (0xf-tmp1) + (0xf-tmp2) ;        expmetric[0] = tmp3 ;        expmetric[1] = 0xf - tmp3 ;               //metric        minimum_metric = MAX_METRIC ;        for(jj=0;jj<8;jj++) { //each metric1           tmp0 = rev[jj][0] ;           tmp1 = rev[jj][1] ;           tmp2 = rev[jj][2] ;           tmp3 = rev[jj][3] ;           exp0 = exp[tmp0][0] ;           exp1 = exp[tmp1][1] ;           exp2 = exp[tmp2][2] ;           exp3 = exp[tmp3][3] ;           //printf("%d %d 0: %2x + %2x + %2x = ", ii, jj, metric0[tmp0], brmetric[0], expmetric[ exp[tmp0][0] ] ) ;           tmp0 = metric0[tmp0] + brmetric[0] + expmetric[ exp[tmp0][0] ] ;           //printf("%3x exp=%x\n", tmp0 , exp0) ;           //printf("%d %d 0: %2x + %2x + %2x = ", ii, jj, metric0[tmp1], brmetric[1], expmetric[ exp[tmp1][1] ] ) ;           tmp1 = metric0[tmp1] + brmetric[1] + expmetric[ exp[tmp1][1] ];           //printf("%3x exp=%x\n", tmp1 , exp1) ;           //printf("%d %d 0: %2x + %2x + %2x = ", ii, jj, metric0[tmp2], brmetric[2], expmetric[ exp[tmp2][2] ] ) ;           tmp2 = metric0[tmp2] + brmetric[2] + expmetric[ exp[tmp2][2] ];           //printf("%3x exp=%x\n", tmp2 , exp2) ;           //printf("%d %d 0: %2x + %2x + %2x = ", ii, jj, metric0[tmp3], brmetric[3], expmetric[ exp[tmp3][3] ] ) ;           tmp3 = metric0[tmp3] + brmetric[3] + expmetric[ exp[tmp3][3] ];           //printf("%3x exp=%x\n", tmp3 , exp3) ;                      //tmp0=min(tmp0,tmp1,tmp2,tmp3) ;           if (tmp0>tmp1) {              tmp0 = tmp1 ; //tmp0 =min(tmp0,tmp1) ;              tmp1 =1 ;              exp0 =exp1 ;           } else tmp1=0 ;           if (tmp2>tmp3) {              tmp2 = tmp3 ; //tmp2 =min(tmp2,tmp3) ;              tmp3 =3 ;              exp2 =exp3 ;           } else tmp3=2 ;           if (tmp0>tmp2) {              tmp0 = tmp2 ; //tmp0 =min(tmp0,tmp2) ;              tmp1 = tmp3 ; //tmp1 is a position of won metric              exp0 = exp2 ;           } else tmp1=tmp1 ;           metric1[jj] = tmp0 ;           //limitter           if (metric1[jj] > MAX_METRIC ) metric1[jj] = MAX_METRIC ;           //printf("%d metric[%d]=%d\n", ii, jj,  metric1[jj] ) ;                      if (metric1[jj] < minimum_metric) {               minimum_metric = metric1[jj] ;               won_metric = jj ;           }           //serial data process           sdata1[ jj ] = (sdata0[rev[jj][tmp1]]<<3 ) + (tmp1&0x3) + (exp0<<2) ;           //printf( "sdata1(%d) = 0x%x\n", jj , sdata1[ jj] ) ;                 } //each metric1      for(jj=0;jj<8;jj++) { //each metric1          //Normalization          metric1[jj] -= minimum_metric ; //force the won_metric to zero          //copy metric1 to metric0 for the next cycle operation          metric0[jj] = metric1[jj] ;          //copy metric1 to metric0 for the next cycle operation          sdata0[jj] = sdata1[jj] ;      } //each metric1            if (ii>=DELAY)  {//output           //printf("sdata1(%d)=0x%x\n", (ii-DELAY), sdata1[won_metric] ) ;           tmp0 = datain.data[ii-DELAY+0] ;           tmp1 = (sdata1[won_metric]>>((DELAY/2)*3+1))&0x1 ;           datain.data[ii-DELAY+0] = ((tmp0>=8) & (tmp1==0))  ? tmp0-2:                                     ((tmp0<8) & (tmp1==1))   ? tmp0+2: tmp0 ;           tmp0 = datain.data[ii-DELAY+1] ;           tmp1 = (sdata1[won_metric]>>((DELAY/2)*3+0))&0x1 ;           datain.data[ii-DELAY+1] = ((tmp0>=8) & (tmp1==0))  ? tmp0-2:                                     ((tmp0<8) & (tmp1==1))   ? tmp0+2: tmp0 ;           tmp0 = datain.data[(ii-DELAY)/2 + 2*NN ] ;           tmp1 = (sdata1[won_metric]>>((DELAY/2)*3+2))&0x1 ;           //printf("(%d %d) tmp0=%x tmp1=%x\n", ii-DELAY, won_metric, tmp0, tmp1 ) ;           datain.data[(ii-DELAY)/2+2*NN] = ((tmp0>=8) & (tmp1==0))  ? tmp0-2:                                     ((tmp0<8) & (tmp1==1))   ? tmp0+2: tmp0 ;      } //output            } //each cycle    return ( datain ) ;} //viterbi_ctc

⌨️ 快捷键说明

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