📄 pccc_logmap_bcjr.cpp
字号:
cout<<endl;*/
for(j=0;j<PCCC_FrameLen;j++)
PCCC_seq[j]+=sigma*AWGN_seq[j];
//Iterative PCCC decoding process
//Receive and Initialization aprior information process
//Receive sequence deassembly
if(puncture==1)
{ for(j=0;j<PCCC_FrameLen;j++)
PCCC_seq[j]*=Gain;
for(j=0;j<Data_Length;j++)
for(k=0;k<RSC_Rate;k++)
Dec1_receive_seq[j*RSC_Rate+k]=PCCC_seq[j*(RSC_Rate+puncture)+k];
for(j=0;j<RSC_TailLen*RSC_Rate;j++)
Dec1_receive_seq[RSC_Rate*Data_Length+j]=
PCCC_seq[(RSC_Rate+puncture)*Data_Length+j];
/*for(j=0;j<RSC_FrameLen;j++)
printf("%5.0f",(1-Dec1_receive_seq[j])/2);*/
//interleavering
for(j=0;j<Data_Length;j++)
SPC2_seq[j]=PCCC_seq[j*(RSC_Rate+puncture)];
Random_interleaver(SPC2_seq,Permu_seq,1,Data_Length);
for(j=0;j<Data_Length;j++)
{ Dec2_receive_seq[j*RSC_Rate]=SPC2_seq[j];
Dec2_receive_seq[j*RSC_Rate+1]=PCCC_seq[j*(RSC_Rate+puncture)+2];
}
for(j=0;j<RSC_TailLen*RSC_Rate;j++)
Dec2_receive_seq[RSC_Rate*Data_Length+j]=
PCCC_seq[(RSC_Rate+puncture)*Data_Length+RSC_TailLen*RSC_Rate+j];
for(j=0;j<RSC_SymLen;j++)
apriori_info[j]=0;
for(j=0;j<Data_Length;j++)
extrinsic_info[j]=0;
}
else
{ for(j=0;j<PCCC_FrameLen;j++)
PCCC_seq[j]*=Gain;
for(j=0;j<Data_Length;j++)
{ Dec1_receive_seq[j*RSC_Rate]=PCCC_seq[j*(RSC_Rate+puncture)];
if(j&1==0)
Dec1_receive_seq[j*RSC_Rate+1]=PCCC_seq[j*(RSC_Rate+puncture)+1];
else
Dec1_receive_seq[j*RSC_Rate+1]=0;
}
for(j=0;j<RSC_TailLen*RSC_Rate;j++)
Dec1_receive_seq[RSC_Rate*Data_Length+j]=
PCCC_seq[(RSC_Rate+puncture)*Data_Length+j];
//interleavering
for(j=0;j<Data_Length;j++)
SPC2_seq[j]=PCCC_seq[j*(RSC_Rate+puncture)];
Random_interleaver(SPC2_seq,Permu_seq,1,Data_Length);
for(j=0;j<Data_Length;j++)
{ Dec2_receive_seq[j*RSC_Rate]=SPC2_seq[j];
if(j&1==0)
Dec2_receive_seq[j*RSC_Rate+1]=0;
else
Dec2_receive_seq[j*RSC_Rate+1]=PCCC_seq[j*(RSC_Rate+puncture)+1];
}
for(j=0;j<RSC_TailLen*RSC_Rate;j++)
Dec2_receive_seq[RSC_Rate*Data_Length+j]=
PCCC_seq[(RSC_Rate+puncture)*Data_Length+RSC_TailLen*RSC_Rate+j];
for(j=0;j<RSC_SymLen;j++)
apriori_info[j]=0;
for(j=0;j<Data_Length;j++)
extrinsic_info[j]=0;
}
for(j=0;j<IterationNumber;j++)
{ Twoway_Logmap_Algorithm(Dec1_receive_seq,apriori_info,
extrinsic_info,
RSC_FST,RSC_FBT,RSC_RST,
RSC_RBT,RSC_RSLT,RSC_RBLT,
RSC_Rate,RSC_CLen,RSC_SymLen);
/*for(k=0;k<Data_Length;k++)
printf(" %5.2f ",extrinsic_info[k]);
cout<<endl;*/
//interleaving process
Random_interleaver(extrinsic_info,Permu_seq,1,Data_Length);
for(k=0;k<Data_Length;k++)
apriori_info[k]=extrinsic_info[k];
for(k=0;k<RSC_TailLen;k++)
apriori_info[Data_Length+k]=0;
/*for(k=0;k<RSC_SymLen;k++)
printf(" %5.2f ",apriori_info[k]);
cout<<endl;*/
Twoway_Logmap_Algorithm(Dec2_receive_seq,apriori_info,
extrinsic_info,
RSC_FST,RSC_FBT,RSC_RST,
RSC_RBT,RSC_RSLT,RSC_RBLT,
RSC_Rate,RSC_CLen,RSC_SymLen);
/*for(k=0;k<Data_Length;k++)
printf(" %5.2f ",extrinsic_info[k]);
cout<<endl;*/
//decision sequence deinterleaving process
for(k=0;k<Data_Length;k++)
soft_decision[k]=extrinsic_info[k]+apriori_info[k]+2*Dec2_receive_seq[RSC_Rate*k];
Random_interleaver(soft_decision,Permu_seq,2,Data_Length);
/*for(k=0;k<Data_Length;k++)
printf(" %5.2f ",soft_decision[k]);
cout<<endl;*/
Frame_BER_counter=0;
//error event statistics
for(k=0;k<Data_Length;k++)
{ if(soft_decision[k]>0)
decision_bit=0;
else
decision_bit=1;
Frame_BER_counter+=decision_bit^Source_seq[k];
}
//cout<<endl;
BER_Pb[i*IterationNumber+j]+=Frame_BER_counter;
/*if(Frame_BER_counter!=0)
{ cout<<Frame_BER_counter<<" "<<total_frame_number<<endl;
//getch();
}*/
//cout<<BER_Pb[i*IterationNumber+j]<<" "<<total_frame_number<<endl;
if(Frame_BER_counter!=0)
FER_Pb[i*IterationNumber+j]+=1;
//extrinsic information sequence deinterleaving process
Random_interleaver(extrinsic_info,Permu_seq,2,Data_Length);
/*for(k=0;k<Data_Length;k++)
printf(" %5.2f ",extrinsic_info[k]);
cout<<endl;*/
for(k=0;k<Data_Length;k++)
apriori_info[k]=extrinsic_info[k];
for(k=0;k<RSC_TailLen;k++)
apriori_info[Data_Length+k]=0;
}
}
//elapse time output process
time(&Iteration_end);
elapse_time=difftime(Iteration_end,Iteration_start)/60;
printf("\n%It takes %f minutes in the %d th Test\n",elapse_time,i+1);
//BER and FER statistics
for(j=0;j<IterationNumber;j++)
{ BER_Pb[i*IterationNumber+j]/=total_frame_number*Data_Length;
FER_Pb[i*IterationNumber+j]/=total_frame_number;
}
printf("The Bit Error Ratio performance\n");
for(j=0;j<IterationNumber;j++)
printf(" The %d th ",j+1);
cout<<endl;
for(j=0;j<IterationNumber;j++)
printf(" %7.3e ",BER_Pb[i*IterationNumber+j]);
cout<<endl;
printf("\nThe Frame Error Ratio performance\n");
for(j=0;j<IterationNumber;j++)
printf(" The %d th ",j+1);
cout<<endl;
for(j=0;j<IterationNumber;j++)
printf(" %7.3e ",FER_Pb[i*IterationNumber+j]);
cout<<endl;
}
//output to the result files
fprintf(Statistics_Data,"\nThe PCCC1 code performance parameters\n");
fprintf(Statistics_Data,"The Bit Error Ratio performance\n");
fprintf(Statistics_Data,"The Frame Length is %4d",Data_Length);
for(i=0;i<TestNumber;i++)
{ fprintf(Statistics_Data,"SNR[%d]=%5.2f\n",i+1,SNR[i]);
for(j=0;j<IterationNumber;j++)
fprintf(Statistics_Data," The %d th ",j+1);
fprintf(Statistics_Data,"\n");
for(j=0;j<IterationNumber;j++)
fprintf(Statistics_Data," %10.5e, ",BER_Pb[i*IterationNumber+j]);
fprintf(Statistics_Data,"\n");
}
fprintf(Statistics_Data,"\nThe Frame Error Ratio performance\n");
for(i=0;i<TestNumber;i++)
{ fprintf(Statistics_Data,"SNR[%d]=%5.2f\n",i+1,SNR[i]);
for(j=0;j<IterationNumber;j++)
fprintf(Statistics_Data," The %d th ",j+1);
fprintf(Statistics_Data,"\n");
for(j=0;j<IterationNumber;j++)
fprintf(Statistics_Data," %10.5e, ",FER_Pb[i*IterationNumber+j]);
fprintf(Statistics_Data,"\n");
}
fprintf(Statistics_Data,"\n");
fclose(Statistics_Data);
free(RSC_FST);
free(RSC_FBT);
free(RSC_RST);
free(RSC_RBT);
free(RSC_RSLT);
free(RSC_RBLT);
free(Source_seq);
free(Psource_seq);
free(Permu_seq);
free(SPC1_seq);
free(SPC2_seq);
free(PCCC_seq);
free(AWGN_seq);
free(Dec1_receive_seq);
free(Dec2_receive_seq);
free(extrinsic_info);
free(apriori_info);
free(soft_decision);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -