mirror of https://github.com/pvnis/srsRAN_4G.git
Scanner version working correctly
parent
92e0db231c
commit
d6797964a5
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,61 +0,0 @@
|
||||
|
||||
clear
|
||||
NofENB = 1;
|
||||
|
||||
for i=1:NofENB
|
||||
enb = lteTestModel('1.1','5MHz');
|
||||
enb.TotSubframes = 10;
|
||||
if (i == 1)
|
||||
tx_signal = lteTestModelTool(enb);
|
||||
else
|
||||
tx_signal = tx_signal + lteTestModelTool(enb);
|
||||
end
|
||||
end
|
||||
|
||||
corrcfg.PSS='On';
|
||||
corrcfg.SSS='On';
|
||||
corrcfg.CellRS='On';
|
||||
|
||||
cec = struct; % Channel estimation config structure
|
||||
cec.PilotAverage = 'UserDefined'; % Type of pilot symbol averaging
|
||||
cec.FreqWindow = 9; % Frequency window size
|
||||
cec.TimeWindow = 9; % Time window size
|
||||
cec.InterpType = 'Linear'; % 2D interpolation type
|
||||
cec.InterpWindow = 'Centered'; % Interpolation window type
|
||||
cec.InterpWinSize = 1; % Interpolation window size
|
||||
|
||||
|
||||
addpath('../../debug/lte/phy/lib/sync/test')
|
||||
addpath('../../debug/lte/phy/lib/ch_estimation/test')
|
||||
|
||||
%tx_signal = signal;
|
||||
|
||||
enb = struct('NDLRB',6,'CyclicPrefix','Normal','DuplexMode','FDD');
|
||||
[cellid, offset] = lteCellSearch(enb, tx_signal,1);
|
||||
|
||||
enb.NCellID=cellid;
|
||||
disp(offset)
|
||||
enb.NSubframe = 0;
|
||||
|
||||
rxWaveform = tx_signal(1+offset:end,:);
|
||||
rxGrid = lteOFDMDemodulate(enb,rxWaveform);
|
||||
|
||||
enb.CellRefP = 4;
|
||||
|
||||
[hest, nest] = lteDLChannelEstimate(enb,cec,rxGrid);
|
||||
|
||||
griddims = lteResourceGridSize(enb); % Resource grid dimensions
|
||||
L = griddims(2);
|
||||
|
||||
pbchIndices = ltePBCHIndices(enb);
|
||||
[pbchRx, pbchHest] = lteExtractResources( ...
|
||||
pbchIndices, rxGrid(:,1:L,:), hest(:,1:L,:,:));
|
||||
|
||||
% Decode PBCH
|
||||
[bchBits, pbchSymbols, nfmod4, mib, enb.CellRefP] = ltePBCHDecode( ...
|
||||
enb, pbchRx, pbchHest, nest);
|
||||
|
||||
% Parse MIB bits
|
||||
enb = lteMIB(mib, enb)
|
||||
|
||||
%plot(angle(hest(:,[1 4],1,1)));
|
@ -1,105 +0,0 @@
|
||||
%% PDCCH Blind Search and DCI Decoding
|
||||
|
||||
%% Cell-Wide Settings
|
||||
% A structure |enbConfig| is used to configure the eNodeB.
|
||||
|
||||
Npackets = 1;
|
||||
SNR_values =20;%linspace(-5,3,8);
|
||||
|
||||
enbConfig.NDLRB = 15; % No of Downlink RBs in total BW
|
||||
enbConfig.CyclicPrefix = 'Normal'; % CP length
|
||||
enbConfig.CFI = 3; ; % 4 PDCCH symbols as NDLRB <= 10
|
||||
enbConfig.Ng = 'Sixth'; % HICH groups
|
||||
enbConfig.CellRefP = 2; % 1-antenna ports
|
||||
enbConfig.NCellID = 10; % Physical layer cell identity
|
||||
enbConfig.NSubframe = 0; % Subframe number 0
|
||||
enbConfig.DuplexMode = 'FDD'; % Frame structure
|
||||
enbConfig.PHICHDuration = 'Normal';
|
||||
|
||||
%% DCI Message Generation
|
||||
% Generate a DCI message to be mapped to the PDCCH.
|
||||
|
||||
dciConfig.DCIFormat = 'Format1A'; % DCI message format
|
||||
dciConfig.Allocation.RIV = 26; % Resource indication value
|
||||
|
||||
% Create DCI message for given configuration
|
||||
[dciMessage, dciMessageBits] = lteDCI(enbConfig, dciConfig);
|
||||
|
||||
%% DCI Channel Coding
|
||||
|
||||
C_RNTI = 65535; % 16-bit UE-specific mask
|
||||
pdcchConfig.RNTI = C_RNTI; % Radio network temporary identifier
|
||||
pdcchConfig.PDCCHFormat = 3; % PDCCH format
|
||||
|
||||
% DCI message bits coding to form coded DCI bits
|
||||
codedDciBits = lteDCIEncode(pdcchConfig, dciMessageBits);
|
||||
|
||||
%% PDCCH Bits Generation
|
||||
|
||||
pdcchDims = ltePDCCHInfo(enbConfig);
|
||||
|
||||
% Initialize elements with -1 to indicate that all the bits are unused
|
||||
pdcchBits = -1*ones(pdcchDims.MTot, 1);
|
||||
|
||||
% Perform search space for UE-specific control channel candidates.
|
||||
candidates = ltePDCCHSpace(enbConfig, pdcchConfig, {'bits', '1based'});
|
||||
|
||||
Ncad=randi(length(candidates),1,1);
|
||||
|
||||
% Map PDCCH payload on available UE-specific candidate. In this example the
|
||||
% first available candidate is used to map the coded DCI bits.
|
||||
pdcchBits ( candidates(Ncad, 1) : candidates(Ncad, 2) ) = codedDciBits;
|
||||
|
||||
%% PDCCH Complex-Valued Modulated Symbol Generation
|
||||
|
||||
pdcchSymbols = ltePDCCH(enbConfig, pdcchBits);
|
||||
|
||||
pdcchIndices = ltePDCCHIndices(enbConfig,{'1based'});
|
||||
|
||||
decoded = zeros(size(SNR_values));
|
||||
decoded_liblte = zeros(size(SNR_values));
|
||||
|
||||
Nports = enbConfig.CellRefP;
|
||||
ueConfig.RNTI = C_RNTI;
|
||||
|
||||
subframe_tx = lteDLResourceGrid(enbConfig);
|
||||
subframe_tx(pdcchIndices) = pdcchSymbols;
|
||||
|
||||
addpath('../../debug/lte/phy/lib/phch/test')
|
||||
|
||||
for snr_idx=1:length(SNR_values)
|
||||
SNRdB = SNR_values(snr_idx);
|
||||
for i=1:Npackets
|
||||
|
||||
%% Noise Addition
|
||||
SNR = 10^(SNRdB/10); % Linear SNR
|
||||
|
||||
N0 = 1/(sqrt(2.0*Nports)*SNR);
|
||||
noise = N0*complex(randn(size(subframe_tx)), randn(size(subframe_tx))); % Generate noise
|
||||
|
||||
subframe_rx = sum(subframe_tx + noise,3); % Add noise to PDCCH symbols
|
||||
|
||||
pdcchSymbolsNoisy = subframe_rx(pdcchIndices(:,1));
|
||||
|
||||
%% PDCCH Decoding
|
||||
recPdcchBits = ltePDCCHDecode(enbConfig, pdcchSymbolsNoisy);
|
||||
|
||||
%% Blind Decoding using DCI Search
|
||||
[rxDCI, rxDCIBits] = ltePDCCHSearch(enbConfig, ueConfig, recPdcchBits);
|
||||
decoded(snr_idx) = decoded(snr_idx) + length(rxDCI);
|
||||
|
||||
[found_liblte, llr, viterbi_in] = liblte_pdcch(enbConfig, ueConfig.RNTI, subframe_rx);
|
||||
|
||||
decoded_liblte(snr_idx) = decoded_liblte(snr_idx)+found_liblte;
|
||||
end
|
||||
fprintf('SNR: %.1f\n',SNRdB)
|
||||
end
|
||||
|
||||
if (Npackets>1)
|
||||
plot(SNR_values,1-decoded/Npackets,SNR_values,1-decoded_liblte/Npackets)
|
||||
grid on
|
||||
legend('Matlab','libLTE')
|
||||
else
|
||||
disp(decoded_liblte)
|
||||
end
|
||||
|
@ -1,102 +0,0 @@
|
||||
%clear
|
||||
rmc = lteRMCDL('R.10');
|
||||
|
||||
NofPortsTx=2;
|
||||
|
||||
SNR_values_db=linspace(-6,0,4);
|
||||
Nrealizations=50;
|
||||
enb = struct('NCellID',0,'NDLRB',50,'CellRefP',NofPortsTx,'CyclicPrefix','Normal','DuplexMode','FDD','NSubframe',0);
|
||||
|
||||
|
||||
cfg.Seed = 8; % Random channel seed
|
||||
cfg.NRxAnts = 1; % 1 receive antenna
|
||||
cfg.DelayProfile = 'EVA'; % EVA delay spread
|
||||
cfg.DopplerFreq = 120; % 120Hz Doppler frequency
|
||||
cfg.MIMOCorrelation = 'Low'; % Low (no) MIMO correlation
|
||||
cfg.InitTime = 0; % Initialize at time zero
|
||||
cfg.NTerms = 16; % Oscillators used in fading model
|
||||
cfg.ModelType = 'GMEDS'; % Rayleigh fading model type
|
||||
cfg.InitPhase = 'Random'; % Random initial phases
|
||||
cfg.NormalizePathGains = 'On'; % Normalize delay profile power
|
||||
cfg.NormalizeTxAnts = 'On'; % Normalize for transmit antennas
|
||||
|
||||
cec.PilotAverage = 'UserDefined'; % Type of pilot averaging
|
||||
cec.FreqWindow = 9; % Frequency window size
|
||||
cec.TimeWindow = 9; % Time window size
|
||||
cec.InterpType = 'linear'; % 2D interpolation type
|
||||
cec.InterpWindow = 'Centered'; % Interpolation window type
|
||||
cec.InterpWinSize = 1; % Interpolation window size
|
||||
|
||||
rmc.PDSCH.Modulation = '16QAM';
|
||||
[waveform,rgrid,info] = lteRMCDLTool(rmc,[1;0;0;1]);
|
||||
|
||||
cfg.SamplingRate = info.SamplingRate;
|
||||
|
||||
addpath('../../debug/lte/phy/lib/phch/test')
|
||||
|
||||
|
||||
error=zeros(length(SNR_values_db),2);
|
||||
for snr_idx=1:length(SNR_values_db)
|
||||
SNRdB = SNR_values_db(snr_idx); % Desired SNR in dB
|
||||
SNR = 10^(SNRdB/20); % Linear SNR
|
||||
|
||||
errorReal = zeros(Nrealizations,2);
|
||||
for i=1:Nrealizations
|
||||
|
||||
griddims = lteResourceGridSize(enb); % Resource grid dimensions
|
||||
L = griddims(2);
|
||||
|
||||
rxWaveform = lteFadingChannel(cfg,waveform(:,1));
|
||||
|
||||
%% Additive Noise
|
||||
N0 = 1/(sqrt(2.0*double(enb.CellRefP)*double(info.Nfft))*SNR);
|
||||
|
||||
% Create additive white Gaussian noise
|
||||
noise = N0*complex(randn(size(rxWaveform)),randn(size(rxWaveform)));
|
||||
|
||||
rxWaveform = noise + rxWaveform;
|
||||
|
||||
% rxWaveform = downsampled;
|
||||
|
||||
% Number of OFDM symbols in a subframe
|
||||
% OFDM demodulate signal
|
||||
rxgrid = lteOFDMDemodulate(enb, rxWaveform);
|
||||
|
||||
% Perform channel estimation
|
||||
[hest, nest] = lteDLChannelEstimate(enb, cec, rxgrid(:,1:L,:));
|
||||
|
||||
pbchIndices = ltePBCHIndices(enb);
|
||||
[pbchRx, pbchHest] = lteExtractResources( ...
|
||||
pbchIndices, rxgrid(:,1:L,:), hest(:,1:L,:,:));
|
||||
|
||||
% Decode PBCH
|
||||
[bchBits, pbchSymbols, nfmod4, mib, nof_ports] = ltePBCHDecode( ...
|
||||
enb, pbchRx, pbchHest, nest);
|
||||
|
||||
if (nof_ports ~= NofPortsTx)
|
||||
errorReal(i,1)=1;
|
||||
end
|
||||
|
||||
[nof_ports2, pbchSymbols2, pbchBits, ce, ce2, pbchRx2, pbchHest2,indices]=...
|
||||
liblte_pbch(enb, rxWaveform, hest, nest);
|
||||
if (nof_ports2 ~= NofPortsTx)
|
||||
errorReal(i,2)=1;
|
||||
end
|
||||
% if (errorReal(i,1) ~= errorReal(i,2))
|
||||
% i=1;
|
||||
% end
|
||||
end
|
||||
error(snr_idx,:) = sum(errorReal);
|
||||
fprintf('SNR: %.2f dB\n', SNR_values_db(snr_idx));
|
||||
end
|
||||
|
||||
if (length(SNR_values_db) > 1)
|
||||
plot(SNR_values_db, 1-error/Nrealizations)
|
||||
grid on
|
||||
xlabel('SNR (dB)');
|
||||
ylabel('Pdet')
|
||||
legend('Matlab','libLTE')
|
||||
else
|
||||
disp(error)
|
||||
end
|
||||
|
@ -1,76 +0,0 @@
|
||||
filename='../../debug/dist_ra.dat';
|
||||
|
||||
enb.NDLRB = 50;
|
||||
enb.CyclicPrefix = 'Normal';
|
||||
enb.PHICHDuration = 'Normal';
|
||||
enb.CFI = 2;
|
||||
enb.Ng = 'Sixth';
|
||||
enb.CellRefP = 1;
|
||||
enb.NCellID = 196;
|
||||
enb.NSubframe = 5;
|
||||
enb.NTotalSubframes=1;
|
||||
enb.DuplexMode = 'FDD';
|
||||
|
||||
dci.NDLRB = enb.NDLRB;
|
||||
dci.DCIFormat = 'Format1C';
|
||||
dci.AllocationType=1;
|
||||
%dci.Allocation.Bitmap='01111000011110000';
|
||||
%dci.Allocation.Subset=3;
|
||||
dci.Allocation.RIV = 33;
|
||||
dci.Allocation.Gap = 0;
|
||||
dci.ModCoding=6;
|
||||
dci.RV=0;
|
||||
dci.DuplexMode = enb.DuplexMode;
|
||||
dci.NTxAnts = enb.CellRefP;
|
||||
pdcch.RNTI = 65535;
|
||||
pdcch.PDCCHFormat = 3;
|
||||
|
||||
pdsch.Modulation='QPSK';
|
||||
pdsch.RNTI=pdcch.RNTI;
|
||||
if (enb.CellRefP == 1)
|
||||
pdsch.TxScheme='Port0';
|
||||
else
|
||||
pdsch.TxScheme='TxDiversity';
|
||||
end
|
||||
pdsch.NLayers=enb.CellRefP;
|
||||
pdsch.trblklen=176;
|
||||
pdsch.RV=dci.RV;
|
||||
|
||||
% Begin frame generation
|
||||
subframe = lteDLResourceGrid(enb);
|
||||
|
||||
%%% Create Reference Signals
|
||||
rsAnt = lteCellRS(enb);
|
||||
indAnt = lteCellRSIndices(enb);
|
||||
subframe(indAnt) = rsAnt;
|
||||
|
||||
%%% Create PDCCH
|
||||
[dciMessage,dciMessageBits] = lteDCI(enb,dci);
|
||||
codedDciBits = lteDCIEncode(pdcch,dciMessageBits);
|
||||
pdcchInfo = ltePDCCHInfo(enb);
|
||||
pdcchBits = -1*ones(1,pdcchInfo.MTot);
|
||||
candidates = ltePDCCHSpace(enb,pdcch,{'bits','1based'});
|
||||
pdcchBits (candidates(1,1):candidates(1,2)) = codedDciBits;
|
||||
pdcchSymbols = ltePDCCH(enb, pdcchBits);
|
||||
pdcchIndices = ltePDCCHIndices(enb,{'1based'});
|
||||
subframe(pdcchIndices) = pdcchSymbols;
|
||||
|
||||
% Create PDSCH
|
||||
pdsch.prbset = lteDCIResourceAllocation(enb,dci);
|
||||
|
||||
[pdschIndices,pdschInfo] = ltePDSCHIndices(enb,pdsch,pdsch.prbset);
|
||||
|
||||
dlschTransportBlk=randi([0 1],pdsch.trblklen,1);
|
||||
pdschcodeword = lteDLSCH(enb,pdsch,pdschInfo.G,dlschTransportBlk);
|
||||
%crced = lteCRCEncode(dlschTransportBlk, '24A');
|
||||
%encoded = lteTurboEncode(crced);
|
||||
%pdschcodeword2 = lteRateMatchTurbo(encoded,pdschInfo.G,pdsch.RV);
|
||||
pdschSymbols = ltePDSCH(enb,pdsch,pdschcodeword);
|
||||
|
||||
subframe(pdschIndices) = pdschSymbols;
|
||||
|
||||
txwaveform = lteOFDMModulate(enb,subframe);
|
||||
|
||||
write_complex(filename,sum(txwaveform,2));
|
||||
fprintf('Written signal to %s\n',filename);
|
||||
|
@ -1,144 +0,0 @@
|
||||
|
||||
SNR_values = linspace(-6,4,10);
|
||||
Npackets = 200;
|
||||
CFO=4/15;
|
||||
m0=7;
|
||||
m1=10;
|
||||
%m0=26;
|
||||
%m1=21;
|
||||
|
||||
recordedWaveform = x;
|
||||
if (~isempty(recordedWaveform))
|
||||
Npackets = floor(length(recordedWaveform)/19200)-1;
|
||||
SNR_values = 0;
|
||||
end
|
||||
|
||||
error = zeros(6,length(SNR_values));
|
||||
|
||||
enb = struct('NCellID',2,'NSubframe',0,'NDLRB',6,'CellRefP',1,'CyclicPrefix','Normal','DuplexMode','FDD');
|
||||
sss=lteSSS(enb);
|
||||
|
||||
cfg.Seed = 2; % Random channel seed
|
||||
cfg.NRxAnts = 1; % 1 receive antenna
|
||||
cfg.DelayProfile = 'ETU'; % EVA delay spread
|
||||
cfg.DopplerFreq = 144; % 120Hz Doppler frequency
|
||||
cfg.MIMOCorrelation = 'Low'; % Low (no) MIMO correlation
|
||||
cfg.NTerms = 16; % Oscillators used in fading model
|
||||
cfg.ModelType = 'GMEDS'; % Rayleigh fading model type
|
||||
cfg.InitPhase = 'Random'; % Random initial phases
|
||||
cfg.NormalizePathGains = 'On'; % Normalize delay profile power
|
||||
cfg.NormalizeTxAnts = 'On'; % Normalize for transmit antennas % Initialize at time zero
|
||||
|
||||
[s, c0, c1] = get_sc(mod(enb.NCellID,3));
|
||||
|
||||
subframe = lteDLResourceGrid(enb);
|
||||
sssSym = lteSSS(enb);
|
||||
sssInd = lteSSSIndices(enb);
|
||||
subframe(sssInd) = sssSym;
|
||||
N_id_1 = floor(enb.NCellID/3);
|
||||
|
||||
[txWaveform,info] = lteOFDMModulate(enb,subframe);
|
||||
cfg.SamplingRate = info.SamplingRate;
|
||||
fftSize = info.Nfft;
|
||||
|
||||
|
||||
addpath('../../debug/lte/phy/lib/sync/test')
|
||||
|
||||
for snr_idx=1:length(SNR_values)
|
||||
SNRdB = SNR_values(snr_idx);
|
||||
for i=1:Npackets
|
||||
%% Noise Addition
|
||||
SNR = 10^(SNRdB/10); % Linear SNR
|
||||
|
||||
if (isempty(recordedWaveform))
|
||||
cfg.InitTime = i*(10^-3);
|
||||
[rxWaveform, info]= lteFadingChannel(cfg,txWaveform);
|
||||
rxWaveform = txWaveform;
|
||||
|
||||
% Add CFO
|
||||
freq = CFO/double(fftSize);
|
||||
rxWaveform = rxWaveform.*exp(1i*2*pi*freq*(1:length(txWaveform))');
|
||||
|
||||
N0 = 1/(sqrt(2.0*enb.CellRefP*double(fftSize))*SNR);
|
||||
noise = N0*complex(randn(size(rxWaveform)), randn(size(rxWaveform))); % Generate noise
|
||||
|
||||
rxWaveform = rxWaveform + noise;
|
||||
else
|
||||
rxWaveform = recordedWaveform(i*19200+1:(i+1)*19200);
|
||||
end
|
||||
|
||||
offset = lteDLFrameOffset(enb,rxWaveform);
|
||||
offsetVec(i)=offset;
|
||||
rxWaveform = [rxWaveform(1+offset:end,:); zeros(offset,1)];
|
||||
|
||||
subframe_rx = lteOFDMDemodulate(enb,rxWaveform,1);
|
||||
|
||||
sss_rx = subframe_rx(lteSSSIndices(enb));
|
||||
sss0=sss_rx(1:2:end);
|
||||
sss1=sss_rx(2:2:end);
|
||||
|
||||
beta0=sss0.*c0';
|
||||
beta1=sss1.*c1';
|
||||
|
||||
corr0=zeros(31,1);
|
||||
for m=1:31
|
||||
corr0(m)=sum(beta0.*s(m,:)');
|
||||
end
|
||||
corr0=abs(corr0).^2;
|
||||
[m, idx]=max(corr0);
|
||||
|
||||
error(1,snr_idx) = error(1,snr_idx) + ((idx ~= m0 && idx ~= m1));
|
||||
|
||||
M=2;
|
||||
Nm=10;
|
||||
|
||||
corr2=zeros(31,1);
|
||||
for m=1:31
|
||||
for j=0:M
|
||||
idx=1+j*Nm:(j+1)*Nm;
|
||||
corr2(m)=corr2(m)+abs(sum(beta0(idx).*s(m,idx)')).^2;
|
||||
end
|
||||
end
|
||||
[m, idx]=max(corr2);
|
||||
|
||||
error(2,snr_idx) = error(2,snr_idx) + ((idx ~= m0 && idx ~= m1));
|
||||
|
||||
corr3=zeros(31,1);
|
||||
for m=1:31
|
||||
corr3(m)=abs(sum(beta0(2:end).*conj(beta0(1:end-1)).*transpose(s(m,2:end).*conj(s(m,1:end-1))))).^2;
|
||||
end
|
||||
[m, idx]=max(corr3);
|
||||
|
||||
error(3,snr_idx) = error(3,snr_idx) + ((idx ~= m0 && idx ~= m1));
|
||||
|
||||
% libLTE results
|
||||
[n,sf_idx,lt_corr0]=liblte_sss(enb,rxWaveform,'full');
|
||||
[m, idx]=max(lt_corr0);
|
||||
error(4,snr_idx) = error(4,snr_idx) + ((idx ~= m0 && idx ~= m1));
|
||||
|
||||
[n,sf_idx,lt_corr2]=liblte_sss(enb,rxWaveform,'partial');
|
||||
[m, idx]=max(lt_corr2);
|
||||
error(5,snr_idx) = error(5,snr_idx) + ((idx ~= m0 && idx ~= m1));
|
||||
|
||||
[n,sf_idx,lt_corr3]=liblte_sss(enb,rxWaveform,'diff');
|
||||
[m, idx]=max(lt_corr3);
|
||||
error(6,snr_idx) = error(6,snr_idx) + ((idx ~= m0 && idx ~= m1));
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
if (length(SNR_values) > 1)
|
||||
plot(SNR_values,1-error/Npackets)
|
||||
legend('Full','Partial','Differential','Full-lt','Partial-lt','Differential-lt')
|
||||
grid on
|
||||
else
|
||||
e=error/Npackets;
|
||||
fprintf('Full (mt/lt): \t%f/%f\n',e(1),e(4));
|
||||
fprintf('Partial (mt/lt):%f/%f\n',e(2),e(5));
|
||||
fprintf('Diff (mt/lt): \t%f/%f\n',e(3),e(6));
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,49 +0,0 @@
|
||||
|
||||
clear
|
||||
blen=40;
|
||||
SNR_values_db=linspace(-6,4,8);
|
||||
Nrealizations=5000;
|
||||
|
||||
addpath('../../debug/lte/phy/lib/fec/test')
|
||||
|
||||
errors1=zeros(1,length(SNR_values_db));
|
||||
errors2=zeros(1,length(SNR_values_db));
|
||||
for snr_idx=1:length(SNR_values_db)
|
||||
SNRdB = SNR_values_db(snr_idx); % Desired SNR in dB
|
||||
SNR = 10^(SNRdB/20); % Linear SNR
|
||||
|
||||
for i=1:Nrealizations
|
||||
Data = randi(2,blen,1)==1;
|
||||
codedData = lteConvolutionalEncode(Data);
|
||||
|
||||
codedsymbols = 2*double(codedData)-1;
|
||||
|
||||
%% Additive Noise
|
||||
N0 = 1/SNR;
|
||||
|
||||
% Create additive white Gaussian noise
|
||||
noise = N0*randn(size(codedsymbols));
|
||||
|
||||
noisysymbols = noise + codedsymbols;
|
||||
|
||||
decodedData = lteConvolutionalDecode(noisysymbols);
|
||||
interleavedSymbols = reshape(reshape(noisysymbols,[],3)',1,[]);
|
||||
[decodedData2, quant] = liblte_viterbi(interleavedSymbols);
|
||||
|
||||
errors1(snr_idx) = errors1(snr_idx) + any(decodedData ~= Data);
|
||||
errors2(snr_idx) = errors2(snr_idx) + any(decodedData2 ~= Data);
|
||||
end
|
||||
end
|
||||
|
||||
if (length(SNR_values_db) > 1)
|
||||
semilogy(SNR_values_db, errors1/Nrealizations, ...
|
||||
SNR_values_db, errors2/Nrealizations)
|
||||
grid on
|
||||
xlabel('SNR (dB)')
|
||||
ylabel('BLER')
|
||||
legend('Matlab','libLTE');
|
||||
else
|
||||
disp(errors1);
|
||||
disp(errors2);
|
||||
disp(errors3);
|
||||
end
|
Loading…
Reference in New Issue