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

📄 c_testbed.c

📁 WCDMA的仿真程序,分别用C和MATLAB两种语言仿真
💻 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"#include "blockcollect.h"#define INPUT_SIZE 16#define PROB_VECTOR_LEN 2int main(int argc, char *argv[]){    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 pn_code[] = {1, 1, -1, -1};    int pn_code_len = 4;    int tx_coded_symbol_bits[3*INPUT_SIZE];    int rx_coded_symbol_bits[3*INPUT_SIZE];    int sf = 4;    int ch_delays[8] = {0, 1, 2,3};    int nTaps = 4;    double ch_amplitudes[] = {0.2, 0.7, 0.1, 0.0, 0.2};    double ch_amplitudes2[] = {0.1, 0.1, 0.8, 0.2};    double r_temppi[3*INPUT_SIZE];    int in_temppi[10000];    int ch_id0 = 0, ch_id1 = 1;    int coder_instance, decoder_instance;    int rake_instance1, rake_instance2;    int channel_instance1, channel_instance2;    int ready;    double out_data[20];    double path_select_threshold;    int round;    double impulse_prob[1] = { 1.0 };    double impulse_cumul[1];    int channel_no = 0;    int bit_delay=0;    int delayI, delayQ;    int nFingers;    int diff;    int i, j, k, m, tmp_value;    ch_id0 = wcdma_channel_init(ch_delays, nTaps,                                 impulse_prob, ch_id0, impulse_cumul);    ch_id1 = wcdma_channel_init(ch_delays, nTaps,                                 impulse_prob, ch_id1, impulse_cumul);    round = 0;    m = 0;    path_select_threshold = 0.18;    nFingers = 4;    rake_instance1 = 0;    rake_instance2 = 1;    wcdma_rake_init(rake_instance1, path_select_threshold, nFingers);    wcdma_rake_init(rake_instance2, path_select_threshold, nFingers);    wcdma_symbolbuffer_init(20, 0);    for (k=0; k < 8; k++) {    if ((round % 2) == 0) {        for (i=0; i < INPUT_SIZE; i++) {            tmp_value = i % 2;            tx_coded_symbol_bits[i] = tmp_value > 0 ? 1 : 0;        }    } else {        for (i=0; i < INPUT_SIZE; i++) {            tmp_value = i % 2;            tx_coded_symbol_bits[i] = tmp_value > 0 ? 0 : 1;        }    }    for (i=0; i < INPUT_SIZE; i++)         in_temppi[k*INPUT_SIZE+i] = tx_coded_symbol_bits[i];    round++;    wcdma_dl_mod(tx_coded_symbol_bits, INPUT_SIZE, pn_code, pn_code_len,                 sf, I_out, Q_out);    wcdma_channel(I_out, sf*INPUT_SIZE/2, ch_amplitudes, ch_delays,                  nTaps, impulse_cumul, 1, ch_id0, I_out_2, &channel_no);    wcdma_channel(Q_out, sf*INPUT_SIZE/2, ch_amplitudes, ch_delays,                  nTaps, impulse_cumul, 1, ch_id1, Q_out_2, &channel_no);    delayI = delayQ = 0;    wcdma_rake_receiver(rake_instance1, I_out_2, sf*INPUT_SIZE/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, sf*INPUT_SIZE/2,                        pn_code, pn_code_len, sf,                        ch_delays, ch_amplitudes, nTaps,                        &Q_symbs_len, &delayQ, Q_out_4);    for (i=0, j=0; i < INPUT_SIZE/2; i++, j += 2) {        rx_coded_symbol_bits[j] = I_out_3[i] = (I_out_4[i] > 0) ? 1 : 0;         rx_coded_symbol_bits[j+1] = Q_out_3[i] = (Q_out_4[i] > 0) ? 1 : 0;     }    ready = 0;    for (i=0; i < I_symbs_len+Q_symbs_len; i++)          r_temppi[i] = (double)rx_coded_symbol_bits[i];    wcdma_symbolbuffer(0, r_temppi,             I_symbs_len+Q_symbs_len, &ready, out_data);    if (ready == 1) {        printf(" round %d output: ", k);        for (j=0; j < 20; j++) {            printf(" %d", (out_data[j] > 0) ? 1 : 0 );            if ( ((m*20+j) % INPUT_SIZE) == 15 ) printf(" x ");        }        printf("\n");        printf(" round %d input : ", k);        for (j=0; j < 20; j++) {            printf(" %d", in_temppi[m*20+j]);            if ( ((m*20+j) % INPUT_SIZE) == 15 ) printf(" x ");        }        m++;        printf("\n");    }#if 0    for (i=0; i < (INPUT_SIZE); i++) {      printf("input %d output %d\n",             tx_coded_symbol_bits[i], rx_coded_symbol_bits[i]);    }#endif    printf(" ---- \n");    } /* for k *//*    printf("\n\tChecking difference of bits before and after convolution.\n");    diff=0;    bit_delay = (delayI == 0) ? 0 : (delayI/pn_code_len + 1);    for (i=0; i < (INPUT_SIZE-bit_delay); i++) {      printf("input %d output %d\n",             tx_coded_symbol_bits[i], rx_coded_symbol_bits[i+bit_delay]);      diff += (tx_coded_symbol_bits[i] == rx_coded_symbol_bits[i+bit_delay])               ? 0 : 1;    }    printf("\t\tDifference is %d bit places.\n", diff);*/    printf("\n");    wcdma_channel_free(ch_id0);    wcdma_channel_free(ch_id1);    wcdma_symbolbuffer_free(0);    return(0);}

⌨️ 快捷键说明

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