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

📄 test_chcoding.c

📁 这是一个c++编写的WCDMA链路采用RAKE接收的方针源代码
💻 C
字号:
/* | | Copyright disclaimer: |   This software was developed at the National Institute of Standards |   and Technology by employees of the Federal Government in the course |   of their official duties. Pursuant to title 17 Section 105 of the |   United States Code this software is not subject to copyright |   protection and is in the public domain. | |   We would appreciate acknowledgement if the software is used. |*//* | Project:     WCDMA simulation environment | Module:      C-level Test bed for downlink routines | Author:      Tommi Makelainen, Nokia/NIST | Date:        February 17, 1999 | | History: |              February 17, 1999 Tommi Makelainen |                      Initial version. | */#include <stdio.h>#include <math.h>#include "chcoding.h"#include "chdecoding.h"#include "interleaver.h"#include "discmod.h"#include "discdemod.h"#include "channel.h"#include "rake.h"#include "crc_routines.h"#define INPUT_SIZE 80#define PROB_VECTOR_LEN 2#define ARIB_CRC16 0x1021int main(int argc, char *argv[]){    int metric_type;    int num_encode_stages, gen_polys[3], gen_poly_1, gen_poly_2, gen_poly_3;    int inputs[INPUT_SIZE];    int tx_coded_symbol_bits[3*INPUT_SIZE];    int rx_coded_symbol_bits[3*INPUT_SIZE];    int tx_interleaved_symbol_bits[3*INPUT_SIZE];    int decoded_bits[INPUT_SIZE];    int tail[8];    int crc_bits[16], crc_result;    int interleaver_cols, interleaver_rows;    double soft_prob_0[] = {0.9, 0.1};    double soft_prob_1[] = {0.1, 0.9};    double soft_bits[3*INPUT_SIZE];    MealyEncoder encoder1;    MealyEncoder encoder2;    ViterbiDecoder decoder;    int coder_type, coding_ratio;    int coder_instance, decoder_instance;    int coded_data_len;    int bit_delay;    int diff, j;    int i, tmp_value;    inputs[0] = 1;    /* CRC16 length is 16 */    for (i=1; i < (INPUT_SIZE-16); i++) {        tmp_value = i % 3;        inputs[i] = tmp_value > 0 ? 1 : 1;    }    wcdma_crctable_init(ARIB_CRC16);    /* wcdma_crctable_init(4129); */     coding_ratio = 3; /* 2 = 1/2 or 3 = 1/3 */    for (i=0; i < coding_ratio*INPUT_SIZE; i++) soft_bits[i] = 1.0;    for (i=0; i < INPUT_SIZE; i++) decoded_bits[i] = -2;    for (i=0; i < 8; i++) tail[i] = 0;    coder_type = 1;  /* 1=conv., 2=turbo */    metric_type = 0; /* 0 = hard, 1 = soft */    gen_polys[0] = 0x16f;    gen_polys[1] = 0x1b3;    gen_polys[2] = 0x1c9;/*    coder_instance = wcdma_convcoding_init(metric_type,                          gen_poly_1, gen_poly_2, gen_poly_3,                          INPUT_SIZE);  */    coder_instance = wcdma_chcoding_init(coder_type, metric_type,                          coding_ratio, gen_polys, INPUT_SIZE);    if (coder_instance == -1) {        return(-1);    }    decoder_instance = wcdma_chdecoding_init(coder_type, coding_ratio,                          coding_ratio*INPUT_SIZE, metric_type, gen_polys,                           soft_prob_0, soft_prob_1, PROB_VECTOR_LEN);    if (coder_instance == -1) {        wcdma_chcoding_free(coder_instance);        return(-1);    }    interleaver_cols = 12;    interleaver_rows = 20;    wcdma_get_crc_value(inputs, INPUT_SIZE-16, crc_bits);    for (i=INPUT_SIZE-16, j=0; i < INPUT_SIZE; i++, j++) {        inputs[i] = crc_bits[j];    }    wcdma_chcoding_enc(coder_type, coding_ratio, inputs, INPUT_SIZE,                       tx_coded_symbol_bits, tail, coder_instance);    wcdma_block_interleaver(interleaver_rows, interleaver_cols,                            tx_coded_symbol_bits, tx_interleaved_symbol_bits);    wcdma_block_deinterleaver(interleaver_cols, interleaver_rows,                              tx_interleaved_symbol_bits, rx_coded_symbol_bits);    wcdma_chdecoding_dec(coder_type, coding_ratio,                         rx_coded_symbol_bits, coding_ratio*INPUT_SIZE,                         soft_bits, decoded_bits, tail, decoder_instance);    crc_result = wcdma_get_crc_value(decoded_bits,                                     INPUT_SIZE, crc_bits);    printf("\n\tCRC check %d\n\n", crc_result);    printf("\n\tChecking difference of bits before and after convolution.\n");    diff=0;    bit_delay = 0;    for (i=0; i < (INPUT_SIZE-16); i++) {      printf("input %d output %d\n", inputs[i], decoded_bits[i]);      diff += (inputs[i+bit_delay] == decoded_bits[i]) ? 0 : 1;    }    printf("\t\tDifference is %d bit places.\n", diff);    printf("\n");    wcdma_chcoding_free(coder_instance);    wcdma_chdecoding_free(decoder_instance);    return(0);}

⌨️ 快捷键说明

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