?? simulation.m
字號:
%Electronic System Design for
%IEEE 802.15 3a UWB DSSS system
%second time simulation by G.Jin 27/Feb/2005
%team 10
%Hantao Liu, Guanghua Chen, Hao Wang and Guoxin Jin
clear all;
%% step 1: input simulation parameters
mac_head_length=80; %MAC header must 80bit exactly
mac_data_length=256;%assume data from MAC layer is 1024 bit;
seed=01;%scrambler seed identifier 00,01,10,11
band='high';
Preamble_type='medium';
SFD=[0 0 0 0 1 1 0 0 1 0 1 1 1 1 0 1];%start frame delimiter
% Training sequence for medium preamble.
datarate=55;%Mbps
modem_type='BPSK';
sample_times=3;
preamble_type_descriptor=[0 0 0 0 0 0 0 0];
segma=0.025e-9;
%% step 2: preparation MAC data and header
% Implemented by G. Chen
mac_header=(sign(rand(1,mac_head_length)-0.5)+1)/2;
mac_data=(sign(rand(1,mac_data_length)-0.5)+1)/2;
% MAC data and header are transmit from upper layer, we do not have
% response to know what it is so I use random bits instead.
%% step 3: scrambler the MAC header and data
% Function implemented by H. Liu( need new version scrambler)
scramb_mac_header=scrambler(seed,mac_header);
scramb_mac_data=scrambler(seed,mac_data);
% Only MAC data and header need scrambler.
%% step 4: Create PHY header with respect to the parameter in step 1
% functioned by G. Jin
phy_header = phyhd(mac_data,seed,band,datarate,modem_type);
%% step 5: CRC of PHY header and MAC header
% function implemented by G. Chen(modify little here by G. Jin)
hcs=crc([mac_header,phy_header]);
%% step 6: Stuffing bit------------need your help!!!
%G. Jin functioned reference to G. Chen
stuffed_body=stuff(scramb_mac_data,phy_header);% do not know TS here need help
% I do not know how to unstuff the sb from stuffed data. If somebody have
% idea, please tell me as soon as possible!!
%% step 7: Choose piconet number
% Implemented by G. Jin
piconet=choose_piconet(band);
%% step 8:Acquisition sequence % ---do not know what is acq_seq
% Implemented by G. Jin
% Maybe a sequence of PN.
% acq_seq=acq(piconet,phy_header);
% assume acq_seq_length=128 bits ????????????????
acq_seq_length=128;
acq_seq=(sign(rand(1,acq_seq_length)-0.5)+1)/2;
%% step 9: Choose Training Seq
% Implemented by G. Jin----------need help what pn code?page 17;
tr_seq=trans_training(band);
%% step 10: Packeting
% Implemented by G. Chen
header=[tr_seq SFD phy_header scramb_mac_header hcs];
body=stuffed_body;
packet=[header body];
%% step 11: FEC (Notice: I only use constraint length 6 here)
% implemented by H. Liu
% Notice only apply on body
fec_body=conv_encd(6,body);
%% step 12: Puncture
% Implemented by H. Liu
punc_body=puncture(fec_body,datarate);
%% step 13: Interleaver
% Implemented by H. Liu
intx_body=interleaver(punc_body);
%% step 14: spreading spectrum
% Function implemented by G. Jin
% Notice: Preamble and Headers are only use length 24 code
codelength=find_spreadcode_length(piconet,phy_header);
header_code=codeset(piconet,24);
body_code=codeset(piconet,codelength);
spreaded_body=spreading(intx_body,body_code);
spreaded_header=spreading(header,header_code);
spreaded_acq=spreading(acq_seq,header_code);
%% step 15: bit to pulse map
% Function implemented by G. Jin
% Notice: I set 3 samples per pulse, since one bit is represented by 3
% pulses, as a result, there a 3x3=9 sample points for one bit.
shaped_body=p_shaping(spreaded_body,sample_times);
shaped_header=p_shaping(spreaded_header,sample_times);
%% step 16: modulation
% Function implemented by G. Jin
mo_body=modulation(spreaded_body,piconet,sample_times);
mo_header=modulation(spreaded_header,piconet,sample_times);
[mo_data,min_position,max_position,fs]=modulation([spreaded_header spreaded_body],piconet,sample_times);
duration=min_position:1/fs:max_position;
[mo_acq,mn_acq,mx_acq,fs]=modulation(spreaded_acq,piconet,sample_times);
%% step 17: transparent by channel
fc=find_centre_freq(piconet);
[after_channel,h]=channel([mo_header mo_body],fc,sample_times,duration);
[after_channel_acq,h_temp]=channel(mo_acq,fc,sample_times,duration);
plot(duration(1:100),after_channel(1:100));
%% step 18: demodulation-RAKE receiver
% The points of acq_seq is 128x24x3x3=27648;
delay_corr=conv(mo_acq,after_channel_acq);
t=mn_acq:1/fs:3*mx_acq;
plot(t,delay_corr(1:length(t)));
plot(1:100,mo_acq(1:100));
delay=find(h);% Here I don't have function to detect delay, so I use delay in channel.m
%% step 19: unspreading
%% step 20: deinterleaver
%% step 21: viterbi_decoding
%% step 22: depacketing
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -