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

📄 c_testbed2.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 "discmod.h"#include "discdemod.h"#include "channel.h"#include "rake.h"#define INPUT_SIZE 80#define PROB_VECTOR_LEN 2int main(int argc, char *argv[]){    int metric_type;    int num_encode_stages, 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 decoded_bits[INPUT_SIZE];    int I_out[3*4*INPUT_SIZE];    double I_out_2[3*4*INPUT_SIZE];    int I_out_3[3*4*INPUT_SIZE];    double I_out_4[3*4*INPUT_SIZE];    int Q_out[3*4*INPUT_SIZE];    double Q_out_2[3*4*INPUT_SIZE];    int Q_out_3[3*4*INPUT_SIZE];    double Q_out_4[3*4*INPUT_SIZE];    int I_symbs_len, Q_symbs_len;    int tail[8];    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];    int pn_code[] = {1,1,-1,-1 };    int pn_code_len = 4;    int sf = 4;    int ch_delays[8] = {2};    int nTaps = 1;    double ch_amplitudes[] = {1.0, 0.2, 0.05, 0.05};    int ch_id0 = 0, ch_id1 = 1;    MealyEncoder encoder1;    MealyEncoder encoder2;    ViterbiDecoder decoder;    int coder_instance, decoder_instance;    int rake_instance1, rake_instance2;    int nFingers;    double path_select_threshold;    int coded_data_len;    int bit_delay;    int delayI, delayQ;    int diff;    int i, tmp_value;    inputs[0] = 0;    for (i=1; i < INPUT_SIZE; i++) {        tmp_value = i % 3;        inputs[i] = tmp_value > 0 ? 1 : 0;    }    for (i=0; i < 3*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;    metric_type = 0; /* 0 = hard, 1 = soft */    gen_poly_1 = 0x16f;    gen_poly_2 = 0x1b3;    gen_poly_3 = 0x1c9;    coder_instance = wcdma_convcoding_init(metric_type,                          gen_poly_1, gen_poly_2, gen_poly_3,                          INPUT_SIZE);    decoder_instance = wcdma_chdecoding_init(3*INPUT_SIZE, metric_type,                          gen_poly_1, gen_poly_2, gen_poly_3,                          soft_prob_0, soft_prob_1,                          PROB_VECTOR_LEN);    wcdma_channel_init(ch_delays, nTaps, ch_id0);    wcdma_channel_init(ch_delays, nTaps, ch_id1);    path_select_threshold = 0.18;    nFingers = 4;    wcdma_rake_init(rake_instance1, path_select_threshold, nFingers);    wcdma_rake_init(rake_instance2, path_select_threshold, nFingers);    interleaver_cols = 12;    interleaver_rows = 20;    wcdma_chcoding_enc(inputs, INPUT_SIZE,                       interleaver_cols, interleaver_rows,                       tx_coded_symbol_bits, tail, coder_instance);    wcdma_dl_mod(tx_coded_symbol_bits, 3*INPUT_SIZE, pn_code, pn_code_len,                 sf, I_out, Q_out);#if 0    wcdma_channel(I_out, (3*INPUT_SIZE*sf)/2, ch_amplitudes, ch_delays,                  nTaps, I_out_2, ch_id0);    wcdma_channel(Q_out, (3*INPUT_SIZE*sf)/2, ch_amplitudes, ch_delays,                  nTaps, Q_out_2, ch_id1);    delayI = delayQ = 0;    wcdma_rake_receiver(rake_instance1, I_out_2, (3*INPUT_SIZE*sf)/2,                         pn_code, pn_code_len, sf,                        ch_delays, ch_amplitudes, nTaps,                        &I_symbs_len, &delayI, I_out_4);    wcdma_rake_receiver(rake_instance2, Q_out_2, (3*INPUT_SIZE*sf)/2,                        pn_code, pn_code_len, sf,                        ch_delays, ch_amplitudes, nTaps,                        &Q_symbs_len, &delayQ, Q_out_4);    for (i=0; i < (3*INPUT_SIZE); i++) {        I_out_3[i] = (I_out_4[i] > 0) ? 1 : 0;         Q_out_3[i] = (Q_out_4[i] > 0) ? 1 : 0;     }    wcdma_dl_qpsk_demod(I_out_3, Q_out_3, I_symbs_len,                        rx_coded_symbol_bits, &coded_data_len);#else    for (i=0; i < (3*INPUT_SIZE*sf)/2; i++) {        I_out_3[i] = I_out[i];        Q_out_3[i] = Q_out[i];    }    wcdma_dl_demod(I_out_3, Q_out_3, (3*INPUT_SIZE*sf)/2, pn_code, pn_code_len,                   sf, rx_coded_symbol_bits);#endif    wcdma_chdecoding_dec(rx_coded_symbol_bits, 3*INPUT_SIZE, soft_bits,                         interleaver_cols, interleaver_rows,                         decoded_bits, tail, decoder_instance);    printf("\n\tChecking difference of bits before and after convolution.\n");    diff=0;    bit_delay = delayI/pn_code_len + 1;    for (i=0; i < INPUT_SIZE; 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);    wcdma_channel_free(ch_id0);    wcdma_channel_free(ch_id1);    return(0);}

⌨️ 快捷键说明

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