📄 data_sim_154a.m
字号:
%%clear all, close all;%% Necessary pathaddpath ./../rng;addpath ./../util;addpath ./../signal;addpath ./../receiver;addpath ./../data_signal;addpath ./../reed_solomon;addpath ./../preamble_signal;addpath ../../src/channel;addpath ../../src/scrambling_timehopping;% Simulation parametersPLOT_DEBUG = 0;FS_CONT = 10e9;RSCODE = 1;if RSCODE == 1 DATA_LENGTH = 870; fullblock = floor(DATA_LENGTH/330); PACKET_LENGTH = fullblock*378 + (DATA_LENGTH-fullblock*330) + 48;else DATA_LENGTH = 127*8; PACKET_LENGTH = DATA_LENGTH;endNpacket = 1;% Physical layerTC = 2e-9; % Chip length in secondsBURST_LENGTH = 4; % LPRF, in chip%BURST_LENGTH = 16; % HPRF, in chipSYMBOL_LENGTH = 512; % In chip% Multipath channelCH_MODEL = 1;CH_ATT_THLD_DB = 30; %rays with bigger attenuation are considered 0CH_RNG_SEED = sum(100*clock);%group all the parameters corresponding to the channelchannel_p = group_channel_params(CH_RNG_SEED,CH_MODEL,CH_ATT_THLD_DB,0.5,1e-9);% Bandwidth of the noisesnr_dB = 16;snr = 10.^(snr_dB/10);Eb = 1;s2 = Eb ./ (2*snr);B = 2e9;% ReceiverT_INT = 1e-9;N_INT = 8;% Result from the timing synchronization and from the channel% estimation% $$$ channel_mask = [];% $$$ channel_mask = ones(1,16);% $$$ channel_mask_unit = 8e-9; % Duration in seconds of a channel mask% $$$ % sample% $$$ channel_mask_unit = T_INT*N_INT;timing_offset = 0; % In secondstiming_offset_samples = timing_offset*FS_CONT;t0 = clock;% Pre-construction of the data signal of interestsamples = get_samples_values(TC,FS_CONT, ... BURST_LENGTH, ... SYMBOL_LENGTH, ... PACKET_LENGTH);[ep] = get_ep(PACKET_LENGTH, ... SYMBOL_LENGTH, ... BURST_LENGTH, ... samples);symbol_start = get_symbol_start(PACKET_LENGTH,samples);[burst, compound_channel, burstlength] ... = init_data_signal(FS_CONT, PACKET_LENGTH, TC,BURST_LENGTH,SYMBOL_LENGTH, ... ep.ths, ep.scrambling, samples, ... channel_p);% Parameters for the generation of the Gaussian noiseALPHA = PACKET_LENGTH/2;Ts = TC * SYMBOL_LENGTH;Nt = Ts * FS_CONT;% Fake estimation of the channel maskL = 64;CODE_ID = 5;preamble_code = abs(len31_preamble_code(CODE_ID));channel_mask = fake_estimate_channel(TC,FS_CONT,samples,... L,preamble_code,CODE_ID,... compound_channel,... T_INT,N_INT,... s2,B);channel_mask = channel_mask';channel_mask_unit = T_INT*N_INT;%for l = 1:Npacket fprintf('Packet %d, ',l); % Get the data bit (coded or uncoded) [tx_bit,data_bit] = get_tx_bit(DATA_LENGTH,RSCODE,ep.interleaver_seed); % Get the data signal of interest [rx_data, signal_start] ... = get_data_signal(PACKET_LENGTH, ... samples.burst, samples.symbol, burstlength, ... burst,ep.ths,symbol_start,tx_bit); % Add AWGN fprintf('add noise, '); [noise_0 noise_1] = randn_bl(ALPHA,Ts,Nt,B,s2*(2*B)/FS_CONT); rx_data = rx_data + [noise_0 noise_1]; clear noise_0 noise_1; % Receiver % fprintf('receive\n'); demod_bit = ed_decoder(rx_data, ep.ths, ... symbol_start, ... burstlength,samples.burst,samples.symbol, ... channel_mask, channel_mask_unit, ... timing_offset_samples, ... PACKET_LENGTH, FS_CONT, T_INT, N_INT); if RSCODE == 1 % RS decoding dec_bit = rs_decoder_154a(demod_bit,ep.interleaver_seed); else dec_bit = demod_bit; end % Compute the BER [num_err(l),ber_sim(l)] = symerr(data_bit,dec_bit);enddt=etime(clock,t0);fprintf('(dt = %.2f), ber = %.12f\n',dt,mean(ber_sim));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -