• 大小: 29KB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2021-06-16
  • 语言: C/C++
  • 标签: C语言  信道编码  

资源简介

C语言实现了卷积码的不同约束长度下的编译码,使用维特比译码方法进行译码,经code::block测试通过,欢迎下载

资源截图

代码片段和文件信息

/*
**************************************************************************************************************
*description:
*   Convolution encodingdecoding and BER calculating(hard decisioncode rate 1/2constraint length 3-8arbitrary generate sequence)
*
*time:
*   2018.10.9
*
*   2018.11.17
*   revise Gaussian function(old function has error)
**************************************************************************************************************
*/


#include “convolution_code.h“


int main()
{
    int ijkq;                                                                     //loop variable
    int temp;
    FILE * fp;                                                                       //file pointer
    fp = fopen(“err_rate.txt““w“);                                                  //create or open file
    int frame = 5000;                                                                //frame number
    float err_rate[RANGE]err_bit = 0;                                               //error bits numberserror rates in different EbN0
    srand(time(NULL));                                                               //random seed
    initial_set();                                                                   //set constrain length and generate sequence
    state_transition();                                                              //Calculating state transition diagram
    setEbN0();                                                                       //set EbN0

    //generate state contrast decoder table
    for(i = 0;i < state_num;i++)
    {
        temp = (i + state_num)/2;
        compare_table[i/2][i] = 0;
        compare_table[temp][i] = 1;
    }

    //different EbN0
    for(j = 0;j < RANGE;j++)
    {
        //repeat frame times
        for(k = 0;k < frame;k++)
        {
            binaryrand(binary_array);                                               //generate binary sequence
            convcode(binary_arraygen_seq1conv_out1);                              //carry out convolution
            convcode(binary_arraygen_seq2conv_out2);                              //carry out convolution
            mergeconv(conv_out1conv_out2conv_out);                                //merge data

            //BPSK modulation and generate Gaussian noise
            for(i = 0;i < 2*(NUM + constraint_length - 1);i++)
            {
                if(conv_out[i] == 0)                                                //BPSK modulation
                    conv_out[i] = -1;
                gaussian[i] = 1/sqrt(2)*gaussianrand();                             //Gaussian noise
                gauss_out[i] = conv_out[i] + pow(10-EcN0[j]/20.0)*gaussian[i];     //BPSK modulation with noise
            }

            hard_decision(gauss_out);                                               //hard decision

            for(i = 0;i < NUM + constraint_length - 1;i++)
    

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-06-27 11:07  cc_code_comparetable_hard\
     目录           0  2019-06-27 11:07  cc_code_comparetable_hard\bin\
     目录           0  2019-06-27 11:07  cc_code_comparetable_hard\bin\Debug\
     文件       44876  2018-11-17 14:48  cc_code_comparetable_hard\bin\Debug\cc_code.exe
     文件        1116  2018-10-10 22:39  cc_code_comparetable_hard\cc_code.cbp
     文件         934  2018-10-15 22:25  cc_code_comparetable_hard\cc_code.depend
     文件         552  2018-11-17 14:48  cc_code_comparetable_hard\cc_code.layout
     文件        2876  2018-10-15 18:29  cc_code_comparetable_hard\convolution_code.h
     文件           0  2018-10-15 22:25  cc_code_comparetable_hard\err_rate.txt
     文件       17226  2018-11-17 14:48  cc_code_comparetable_hard\main.c
     目录           0  2019-06-27 11:07  cc_code_comparetable_hard\obj\
     目录           0  2019-06-27 11:07  cc_code_comparetable_hard\obj\Debug\
     文件       17321  2018-11-17 14:48  cc_code_comparetable_hard\obj\Debug\main.o

评论

共有 条评论