📄 single_ofdm_packet.m
字号:
function [packet_rf_data, info_bits, coded_bits, symbols, packet_baseband_data]=single_ofdm_packet(sim, ofdm_sim);
%Generate wave for signel packet.
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%source bits generation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
info_bits=gen_sourcebits(sim);
%disp('[single_ofdm_packet]Display: Number of source bits.');
%disp(num2str([length(info_bits)]))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%channe coding(optional)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%tcm/convolutional coding
if strcmp(lower(sim.coding_type), '802_15_3_tcm'),
trellis=ieee802_15_3_tcm_code(sim.mapping_type);
coded_bits=trellis_encoder(info_bits, trellis);
elseif strcmp(lower(sim.coding_type), '802_16_tcm')
disp('[single_ofdm_packet]Info: Coming soon...'); return;
coded_bits=[];
elseif ~isempty(findstr(lower(sim.coding_type), '802_16_ctc')),
[coded_bits, info_bits]=ieee802_16_punct_ctc(info_bits, sim.coding_type, sim.coding_rate);
elseif isempty(sim.coding_type),
coded_bits=info_bits;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%interleaver(optional) %last step before complex domain
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if strcmp(lower(sim.interleaver), 'random'),
woven_bits= randintrlv(double(coded_bits), sim.interleaver_size);
elseif isempty(sim.interleaver),
woven_bits=coded_bits;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%mapping
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
constell=get_constell(sim.mapping_type);
symbols=mapping(woven_bits, constell, sim.mapping_msb);
disp('[single_ofdm_packet]Display: Number of source bits/coded bits/complex symbols.');
disp(num2str([length(info_bits), length(coded_bits), length(symbols)]));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%multiplexing (optional)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if ~isempty(sim.multiplex_type)
frame_length=round(sim.frame_time*sim.symbol_rate)
mx_symbols=multiplexing(symbols, frame_length);
else
mx_symbols=symbols;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%generate and add OFDM pilot tones
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Add pilot symbols
pilots=get_ofdm_pilots(ofdm_sim);
freqd_symbols=add_ofdm_pilots(mx_symbols, pilots, ofdm_sim);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%FFT/Add OFDM cyclic prefix
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
timed_symbols=freqd_to_timed(freqd_symbols, ofdm_sim.Nfft);
ofdm_symbols=add_ofdm_prefix(timed_symbols, ofdm_sim.Nfft, ofdm_sim.Ncp);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%generate and OFDM preamble %last step before passband processing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Construction of the preamble
preamble = get_ofdm_preamble(ofdm_sim);
% Concatenate preamble and data part
packet_data = [preamble; ofdm_symbols];%
packet_baseband_data=packet_data;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%carrier modulations.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ps_filter=get_psfilter(sim);
packet_rf_data=carrier_modulations(packet_data, sim.carrier_freq, sim.sampling_rate, sim.symbol_rate, ps_filter);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%add blank, lfm (optional)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
blank_len=round(sim.blank_time*sim.sampling_rate);
blank=zeros(blank_len, size(packet_rf_data, 2));
if ~isempty(sim.lfm_type),
lfm_seq=get_lfm(sim);
packet_rf_data=[lfm_seq; packet_rf_data];
end
packet_rf_data=[blank; packet_rf_data];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -