/*
| Project: WCDMA simulation environment
| Module:
| Author: Maarit Melvasalo
| Date: February 1999
|
| History:
| March 18, 1999 Maarit Melvasalo
| Channel memory vector changed to mode were
| several different vectors can be memorized
|
| May 3, 1999 Maarit Melvasalo
| Channel model changed
| June 16, 1999 Maarit Melvasalo
| Documentation added and cleaning up the code
|
| 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.
|
/*
* Static data structures.
*/
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include "config_wcdma.h"
#include "channel.h"
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif /* TRUE */
/* Channel matrix to keep in memory the channel impulses
(both amplitudes and delays and their changes)
and previous chips etc
/**/
static channel_matrix_double channel_data_double[MAX_CHANNELS];
/* List that keeps record which channel instances are used /**/
static enum instance_state channel_alloc_list_double[MAX_CHANNELS] ;
/* General initialization flag /**/
static int general_channel_init_flag_double = FALSE;
/* Total number of occupied channels/**/
static int channel_index_double = 0;
/* -------------------------------------------------------------------- */
/*
* Function: wcdma_channel_init
* Desc.: Channel initialization
* Allocates memory for the chips that effect the future call time inputs
*
* Return: instance number or -1 if all instances are already occupied.
*
* Note:
*/
/* -------------------------------------------------------------------- */
int wcdma_channel_init_double(
double channel_impulse[], /* IN: Channel impulse vector*/
int channel_delays[],/* IN: Delay taps */
int nTaps, /* IN: channel impulse vector size */
int nImpulse, /* IN: number of channel impulse vectors */
double impulse_prob[],/* IN: Channel impulse vector probabilities*/
int steps, /* IN: Total number of frames send during ssim/**/
double esno, /* IN: SNR/**/
double power, /* IN: Power/**/
int nCode /* IN: Length of the spreading code/**/
){
int i,j,instance,n_intervals,delay_diff;
/*
* If first call, initialize static data.
*/
if (general_channel_init_flag_double == FALSE) {
for (i=0; i < MAX_CHANNELS; i++) {
channel_alloc_list_double[i] = FREE_INSTANCE;
} /* for */
general_channel_init_flag_double = TRUE;
} /* if general_init_flag */
/*
* Find first free instance number.
*/
instance = -1;
for (i=0; i < MAX_CHANNELS; i++) {
if (channel_alloc_list_double[i] == FREE_INSTANCE) {
instance = i;
break;
} }
if (instance == -1) return(-1); /* no free instances */
if (nCode < 0) return(-1); /* Spreading code length incorrect/**/
/*
Store the channel data
Note if the channel is changed there might be some old data
left in the memory, but this do not effect the calculations.
/**/
channel_data_double[instance].n_taps = nTaps;
channel_data_double[instance].n_impulses = nImpulse;
channel_data_double[instance].cur_impulse = 0;
/*
Standard noise deviation is calculated for each chip.
See Michel C. Jeruchim:
"Simulation of communication Systems", Plenum 1992
page. 283
Power = noise power
nCode = code length
esno = Signal to noise ratio
The random number is scaled between -1 and 1 and multiplied by noise_std
calculated here.
/**/
channel_data_double[instance].noise_std =
sqrt(power / nCode / 2 / pow(10.0,(esno/10.0)) ) ; /**/
/* Select the channel mode
CONSTANT
RANDOM
INTERPOL
/**/
if( nImpulse == 1) { channel_data_double[instance].mode = CONST;} /* CONSTANT channel model /**/
else if (steps == 0)
/* RANDOM channel model /**/
{ channel_data_double[instance].mode = RANDOM;
/*
Calculate cumulative impulse vector probalitites
/**/
channel_data_double[instance].cumul_prob[0] = impulse_prob[0];
for (i = 1; i < nImpulse; i++){
channel_data_double[instance].cumul_prob[i] =
impulse_prob[i] + channel_data_double[instance].cumul_prob[i-1];
}}
else {
/* INTERPOLATING channel model /**/
channel_data_double[instance].mode = INTERPOL;
/*
Define the number of iteration steps in between two channel impulses
/**/
n_intervals = ceil (steps / (nImpulse - 1)) + min(1, steps % (nImpulse - 1));/**/
for(j = 0; j<nImpulse; j++){
channel_data_double[instance].max[j] = n_intervals;
channel_data_double[instance].use[j] = 0;}
}
/*
Update the channel data matrix for all channel taps
/**/
for(i = 0; i < nTaps; i++){
channel_data_double[instance].cur_channel[i] = channel_impulse[i];
channel_data_double[instance].cur_delays[i] = channel_delays[i];
if( channel_data_double[instance].mode == RANDOM){
/* RANDOM channel model
Save all the impulses and delays
/**/
for(j = 0; j < nImpulse-1; j++){
channel_data_double[instance].amplitudes[j][i] = channel_impulse[j * nTaps + i];
channel_data_double[instance].delays[j][i] = channel_delays[j * nTaps + i];
}}
else if( channel_data_double[instance].mode == INTERPOL){
/* INTERPOLATING channel model
Calculate the derivates of the amplitudes and the
number of timesteps between delay tap changes (and the direction of the change)
/**/
for(j = 0; j< nImpulse-1; j++){
channel_data_double[instance].amplitudes[j][i] =
(channel_impulse[(j+1) * nTaps + i] - channel_impulse[j * nTaps + i])/n_intervals;
delay_diff = channel_delays[(j+1) * nTaps + i] - channel_delays[j * nTaps + i] ;
if( delay_diff != 0) {
channel_data_double[instance].delays[j][i] =
( n_intervals / (abs(delay_diff)+1) + min(1, n_intervals % (abs(delay_diff)+1))) ;
if( delay_diff < 0 ) {
channel_data_double[instance].delays[j][i] = - channel_data_double[instance].delays[j][i] ;}
}
else {channel_data_double[instance].delays[j][i] = 0;}
}}
} /*Update for each channel tap/**/
/*
Find the longest delay in the channel (to allocate enough memory for stored chips)
/**/
channel_data_double[instance].max_memory = channel_delays[nTaps-1];
for (j = 2; j <= nImpulse; j++){
if ( channel_delays[j * nTaps - 1] > channel_data_double[instance].max_memory )
channel_data_double[instance].max_memory = channel_delays[j * nTaps-1];
}
/*
Allocate memory for the memory storage of previous time chips
/**/
channel_data_double[instance].I_prev_chips =
(double*)calloc( channel_data_double[instance].max_memory, sizeof(double));
channel_data_double[instance].Q_prev_chips =
(double*)calloc( channel_data_double[instance].max_memory, sizeof(double));
/*
Update the static tables to keep in mind which channel instances are in use
/**/
channel_alloc_list_double[instance] = INSTANCE_IN_USE;
channel_index_double ++;
/*
If you want to check what has been updated call:
channel_print(instance);/**/
return(instance);
}
/* -----------------------------------------------------------
没有合适的资源?快使用搜索试试~ 我知道了~
WCDMA通信系统仿真
共101个文件
c:69个
h:25个
make_interleaver_test:1个
3星 · 超过75%的资源 需积分: 12 18 下载量 76 浏览量
2013-11-07
11:27:41
上传
评论
收藏 159KB RAR 举报
温馨提示
WCDMA通信系统模型仿真的实现,包括信源的编码、调制,扩频调制、信道编解码,以及rack接收机等真个WCDMA通信系统模型的仿真,代码运行环境C++.
资源推荐
资源详情
资源评论
收起资源包目录
WCDMA通信系统仿真 (101个子文件)
channel_real_input.c 24KB
channel.c 23KB
convdec.c 17KB
interleaver.c 16KB
sratematch.c 16KB
rake_supp.c 15KB
code.c 13KB
metrics.c 11KB
dl_pri_ccpch.c 11KB
dl_dch.c 11KB
chdecoding.c 10KB
s_channel.c 10KB
chcoding.c 8KB
rake.c 8KB
test_txrx_statchan.c 8KB
s_chdecoding.c 8KB
s_chcoding.c 8KB
s_rake.c 7KB
s_intra_deinterleaver.c 7KB
mealy.c 7KB
s_deinterleaver.c 6KB
s_dl_demod_buffer.c 6KB
s_interleaver.c 6KB
blockcollect.c 6KB
s_dl_discmod.c 6KB
spreading.c 6KB
s_intra_interleaver.c 6KB
convenc.c 6KB
s_crc_remove.c 6KB
c_testbed.c 6KB
c_testbed2.c 6KB
s_frame_buffer.c 5KB
s_crc_add.c 5KB
build_slot.c 5KB
s_spreading.c 5KB
s_conv_detection.c 5KB
s_ber_calc.c 5KB
test_chcoding.c 4KB
s_buffer.c 4KB
s_channel_estimator.c 4KB
s_ber_direct.c 4KB
s_resize.c 4KB
s_derate.c 4KB
test_conv1o2.c 4KB
s_rate.c 4KB
s_mod_plain.c 4KB
s_pulse_shaping.c 4KB
test_interleavers.c 4KB
test_ratematching.c 3KB
crc_routines.c 3KB
s_code.c 3KB
discdemod.c 3KB
s_hard_decission.c 3KB
qpsk.c 3KB
test_channel.c 3KB
discmod.c 3KB
qpsk_ints.c 3KB
test_crc16.c 2KB
get_ovsf_code.c 2KB
bitroutines.c 2KB
get_ovsf_code_indexes.c 2KB
conversions.c 2KB
utility.c 1KB
control_bits.c 1KB
c_code.c 1KB
testsymbolbuffer.c 1013B
test_symbolbuffer.c 1013B
test_blockinterleaver.c 951B
errormsg.c 706B
channel.h 9KB
rake.h 7KB
interleaver.h 4KB
chcoding.h 4KB
config_wcdma.h 4KB
chdecoding.h 3KB
convdec.h 2KB
sratematch.h 2KB
metrics.h 2KB
blockcollect.h 2KB
discdemod.h 2KB
discmod.h 2KB
mealy.h 2KB
qpsk.h 2KB
code.h 2KB
qpsk_ints.h 2KB
convenc.h 2KB
bitroutines.h 2KB
crc_routines.h 2KB
conversions.h 1KB
spreading.h 1KB
wcdma_simulink.h 849B
utility.h 639B
misdefs.h 614B
errormsg.h 550B
make_chcoding_test 193B
make_conv1o2_test 473B
make_crc_test 71B
make_interleaver_test 100B
make_ratematch_test 183B
make_txrx_test 193B
共 101 条
- 1
- 2
资源评论
- Fuzzy_Fat_Tiger2022-06-06编译不通,有问题
- BeginningXiaoke2015-09-01很不错,是C代码不是C++的
chenmodexizi
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功