Commit c820dbce9b284fc6de7664304a8a8001848c13b1

Authored by Nicola Bui
1 parent 660a4b78
Exists in master

OWL update based on srsLTE_v1.3

Showing 132 changed files with 7364 additions and 3117 deletions   Show diff stats

Too many changes.

To preserve performance only 100 of 132 files displayed.

cmake/modules/FindVolk.cmake
... ... @@ -57,10 +57,18 @@ IF(VOLK_FOUND)
57 57 CHECK_FUNCTION_EXISTS_MATH(volk_32fc_deinterleave_real_32f HAVE_VOLK_DEINTERLEAVE_FUNCTION)
58 58 CHECK_FUNCTION_EXISTS_MATH(volk_32fc_index_max_16u HAVE_VOLK_MAX_ABS_FUNCTION)
59 59 CHECK_FUNCTION_EXISTS_MATH(volk_32f_x2_multiply_32f HAVE_VOLK_MULT_REAL2_FUNCTION)
  60 + CHECK_FUNCTION_EXISTS_MATH(volk_16i_max_star_16i HAVE_VOLK_MAX_STAR_S_FUNCTION)
  61 + CHECK_FUNCTION_EXISTS_MATH(volk_8i_convert_16i HAVE_VOLK_CONVERT_CI_FUNCTION)
60 62  
61 63  
62 64  
63 65 SET(VOLK_DEFINITIONS "HAVE_VOLK")
  66 + IF(${HAVE_VOLK_CONVERT_CI_FUNCTION})
  67 + SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_CONVERT_CI_FUNCTION")
  68 + ENDIF()
  69 + IF(${HAVE_VOLK_MAX_STAR_S_FUNCTION})
  70 + SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_MAX_STAR_S_FUNCTION")
  71 + ENDIF()
64 72 IF(${HAVE_VOLK_MAX_ABS_FUNCTION})
65 73 SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_MAX_ABS_FUNCTION")
66 74 ENDIF()
... ...
cmake/modules/SRSLTEVersion.cmake
... ... @@ -19,6 +19,6 @@
19 19 #
20 20  
21 21 SET(SRSLTE_VERSION_MAJOR 001)
22   -SET(SRSLTE_VERSION_MINOR 002)
  22 +SET(SRSLTE_VERSION_MINOR 003)
23 23 SET(SRSLTE_VERSION_PATCH 000)
24 24 SET(SRSLTE_VERSION_STRING "${SRSLTE_VERSION_MAJOR}.${SRSLTE_VERSION_MINOR}.${SRSLTE_VERSION_PATCH}")
... ...
matlab/common/bin2hex.m 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +function [ s ] = bin2hex( in )
  2 +%BIN2HEX Summary of this function goes here
  3 +% Detailed explanation goes here
  4 +
  5 +a=reshape(in,8,[]);
  6 +t=size(a);
  7 +s=cell(1,t(2));
  8 +nbit=2.^(7:-1:0);
  9 +for i=1:t(2)
  10 + s{i}=dec2hex(sum(nbit'.*double(a(:,i))));
  11 +end
  12 +for i=1:t(2)
  13 + if (length(s{i})==1)
  14 + fprintf('0%s ',s{i})
  15 + else
  16 + fprintf('%s ',s{i})
  17 + end
  18 +end
  19 +fprintf('\n');
  20 +end
  21 +
... ...
matlab/tests/dmrs_equalizer_test.m 0 → 100644
... ... @@ -0,0 +1,184 @@
  1 +%% LTE Downlink Channel Estimation and Equalization
  2 +
  3 +%% Cell-Wide Settings
  4 +
  5 +clear
  6 +
  7 +plot_noise_estimation_only=false;
  8 +
  9 +SNR_values_db=100;%linspace(0,30,5);
  10 +Nrealizations=1;
  11 +
  12 +w1=1/3;
  13 +
  14 +%% UE Configuration
  15 +ue = lteRMCUL('A3-5');
  16 +ue.TotSubframes = 2;
  17 +
  18 +K=ue.NULRB*12;
  19 +P=K/6;
  20 +
  21 +%% Channel Model Configuration
  22 +chs.Seed = 1; % Random channel seed
  23 +chs.InitTime = 0;
  24 +chs.NRxAnts = 1; % 1 receive antenna
  25 +chs.DelayProfile = 'EVA';
  26 +chs.DopplerFreq = 300; % 120Hz Doppler frequency
  27 +chs.MIMOCorrelation = 'Low'; % Low (no) MIMO correlation
  28 +chs.NTerms = 16; % Oscillators used in fading model
  29 +chs.ModelType = 'GMEDS'; % Rayleigh fading model type
  30 +chs.InitPhase = 'Random'; % Random initial phases
  31 +chs.NormalizePathGains = 'On'; % Normalize delay profile power
  32 +chs.NormalizeTxAnts = 'On'; % Normalize for transmit antennas
  33 +
  34 +%% Channel Estimator Configuration
  35 +cec = struct; % Channel estimation config structure
  36 +cec.PilotAverage = 'UserDefined'; % Type of pilot symbol averaging
  37 +cec.FreqWindow = 9; % Frequency window size
  38 +cec.TimeWindow = 9; % Time window size
  39 +cec.InterpType = 'Linear'; % 2D interpolation type
  40 +cec.InterpWindow = 'Causal'; % Interpolation window type
  41 +cec.InterpWinSize = 1; % Interpolation window size
  42 +
  43 +
  44 +%% Allocate memory
  45 +Ntests=3;
  46 +hest=cell(1,Ntests);
  47 +for i=1:Ntests
  48 + hest{i}=zeros(K,14);
  49 +end
  50 +MSE=zeros(Ntests,Nrealizations,length(SNR_values_db));
  51 +noiseEst=zeros(Ntests,Nrealizations,length(SNR_values_db));
  52 +
  53 +legends={'matlab','ls',num2str(w1)};
  54 +colors={'bo-','rx-','m*-','k+-','c+-'};
  55 +colors2={'b-','r-','m-','k-','c-'};
  56 +
  57 +addpath('../../debug/srslte/lib/ch_estimation/test')
  58 +
  59 +offset = -1;
  60 +for nreal=1:Nrealizations
  61 +
  62 + %% Signal Generation
  63 + [txWaveform, txGrid, info] = lteRMCULTool(ue,[1;0;0;1]);
  64 +
  65 + %% SNR Configuration
  66 + for snr_idx=1:length(SNR_values_db)
  67 + SNRdB = SNR_values_db(snr_idx); % Desired SNR in dB
  68 + SNR = 10^(SNRdB/20); % Linear SNR
  69 +
  70 + fprintf('SNR=%.1f dB\n',SNRdB)
  71 +
  72 + %% Fading Channel
  73 +
  74 + chs.SamplingRate = info.SamplingRate;
  75 + [rxWaveform, chinfo] = lteFadingChannel(chs,txWaveform);
  76 +
  77 + %% Additive Noise
  78 +
  79 + % Calculate noise gain
  80 + N0 = 1/(sqrt(2.0*double(info.Nfft))*SNR);
  81 +
  82 + % Create additive white Gaussian noise
  83 + noise = N0*complex(randn(size(rxWaveform)),randn(size(rxWaveform)));
  84 +
  85 + % Add noise to the received time domain waveform
  86 + rxWaveform = rxWaveform + noise;
  87 +
  88 + %% Synchronization
  89 +
  90 + % Time offset estimation is done once because depends on channel
  91 + % model only
  92 + if (offset==-1)
  93 + offset = lteULFrameOffset(ue,ue.PUSCH,rxWaveform);
  94 + end
  95 + rxWaveform = rxWaveform(1+offset:end);
  96 +
  97 + %% OFDM Demodulation
  98 + rxGrid = lteSCFDMADemodulate(ue,rxWaveform);
  99 + rxGrid = rxGrid(:,1:14);
  100 +
  101 + %% Perfect channel estimate
  102 + h=lteULPerfectChannelEstimate(ue,chs,offset);
  103 + h=h(:,1:14);
  104 +
  105 + %% Channel Estimation with Matlab
  106 + [hest{1}, noiseEst(1,nreal,snr_idx)] = lteULChannelEstimate(ue,ue.PUSCH,cec,rxGrid);
  107 +
  108 + %% LS-Linear estimation with srsLTE
  109 + [hest{2}, noiseEst(2,nreal,snr_idx)] = srslte_chest_ul(ue,ue.PUSCH,rxGrid);
  110 +
  111 + %% LS-Linear estimation + averaging with srsLTE
  112 + [hest{3}, noiseEst(3,nreal,snr_idx)] = srslte_chest_ul(ue,ue.PUSCH,rxGrid,w1);
  113 +
  114 + %% Compute MSE
  115 + for i=1:Ntests
  116 + MSE(i,nreal,snr_idx)=mean(mean(abs(h-hest{i}).^2));
  117 + fprintf('MSE test %d: %f\n',i, 10*log10(MSE(i,nreal,snr_idx)));
  118 + end
  119 +
  120 + %% Plot a single realization
  121 + if (length(SNR_values_db) == 1)
  122 + subplot(1,1,1)
  123 + sym=1;
  124 + n=1:(K*length(sym));
  125 + for i=1:Ntests
  126 + plot(n,abs(reshape(hest{i}(:,sym),1,[])),colors2{i});
  127 + hold on;
  128 + end
  129 + plot(n,abs(reshape(h(:,sym),1,[])),'k');
  130 + hold off;
  131 +
  132 + tmp=cell(Ntests+1,1);
  133 + for i=1:Ntests
  134 + tmp{i}=legends{i};
  135 + end
  136 + tmp{Ntests+1}='Perfect';
  137 + legend(tmp)
  138 +
  139 + xlabel('SNR (dB)')
  140 + ylabel('Channel Gain')
  141 + grid on;
  142 +
  143 + end
  144 +
  145 + end
  146 +end
  147 +
  148 +%% Compute average MSE and noise estimation
  149 +mean_mse=mean(MSE,2);
  150 +mean_snr=10*log10(1./mean(noiseEst,2));
  151 +
  152 +%disp(mean_snr(3)
  153 +
  154 +%% Plot average over all SNR values
  155 +if (length(SNR_values_db) > 1)
  156 + subplot(1,2,1)
  157 + for i=1:Ntests
  158 + plot(SNR_values_db, 10*log10(mean_mse(i,:)),colors{i})
  159 + hold on;
  160 + end
  161 + hold off;
  162 + legend(legends);
  163 + grid on
  164 + xlabel('SNR (dB)')
  165 + ylabel('MSE (dB)')
  166 +
  167 + subplot(1,2,2)
  168 + plot(SNR_values_db, SNR_values_db,'k:')
  169 + hold on;
  170 + for i=1:Ntests
  171 + plot(SNR_values_db, mean_snr(i,:), colors{i})
  172 + end
  173 + hold off
  174 + tmp=cell(Ntests+1,1);
  175 + tmp{1}='Theory';
  176 + for i=2:Ntests+1
  177 + tmp{i}=legends{i-1};
  178 + end
  179 + legend(tmp)
  180 + grid on
  181 + xlabel('SNR (dB)')
  182 + ylabel('Estimated SNR (dB)')
  183 +end
  184 +
... ...
matlab/tests/equalizer_test.m
... ... @@ -6,13 +6,13 @@ clear
6 6  
7 7 plot_noise_estimation_only=false;
8 8  
9   -SNR_values_db=linspace(0,30,5);
10   -Nrealizations=4;
  9 +SNR_values_db=linspace(0,30,8);
  10 +Nrealizations=10;
11 11  
12 12 w1=0.1;
13 13 w2=0.2;
14 14  
15   -enb.NDLRB = 50; % Number of resource blocks
  15 +enb.NDLRB = 6; % Number of resource blocks
16 16  
17 17 enb.CellRefP = 1; % One transmit antenna port
18 18 enb.NCellID = 0; % Cell ID
... ... @@ -57,8 +57,10 @@ Ports = gridsize(3); % Number of transmit antenna ports
57 57 %% Allocate memory
58 58 Ntests=4;
59 59 hest=cell(1,Ntests);
  60 +tmpnoise=cell(1,Ntests);
60 61 for i=1:Ntests
61 62 hest{i}=zeros(K,140);
  63 + tmpnoise{i}=zeros(1,10);
62 64 end
63 65 hls=zeros(4,4*P*10);
64 66 MSE=zeros(Ntests,Nrealizations,length(SNR_values_db));
... ... @@ -173,27 +175,31 @@ rxGrid_nonoise = rxGrid_nonoise(:,1:140);
173 175 % True channel
174 176 h=rxGrid_nonoise./(txGrid);
175 177  
176   -
177   -%% Channel Estimation with Matlab
178   -tmpnoise=zeros(10,1);
179 178 for i=1:10
180 179 enb.NSubframe=i-1;
181   - [hest{1}(:,(1:14)+(i-1)*14), tmpnoise(i), hls(:,(1:4*P)+(i-1)*4*P)] = ...
182   - lteDLChannelEstimate2(enb,cec,rxGrid(:,(i-1)*14+1:i*14));
183   -end
184   -noiseEst(1,nreal,snr_idx)=mean(tmpnoise)*sqrt(2)*enb.CellRefP;
185 180  
186   -%% LS-Linear estimation with srsLTE
187   -[tmp, ~, ~, noiseEst(2,nreal,snr_idx)] = srslte_chest(enb.NCellID,enb.CellRefP,rxGrid);
188   -hest{2}=reshape(tmp, size(hest{1}));
  181 + rxGrid_sf = rxGrid(:,(i-1)*14+1:i*14);
  182 +
  183 + %% Channel Estimation with Matlab
  184 + [hest{1}(:,(1:14)+(i-1)*14), tmpnoise{1}(i)] = ...
  185 + lteDLChannelEstimate(enb,cec,rxGrid_sf);
  186 + tmpnoise{1}(i)=tmpnoise{1}(i)*sqrt(2)*enb.CellRefP;
  187 +
  188 + %% LS-Linear estimation with srsLTE
  189 + [hest{2}(:,(1:14)+(i-1)*14), tmpnoise{2}(i)] = srslte_chest_dl(enb,rxGrid_sf);
  190 +
  191 + %% LS-Linear + averaging with srsLTE
  192 + [hest{3}(:,(1:14)+(i-1)*14), tmpnoise{3}(i)] = srslte_chest_dl(enb,rxGrid_sf,w1);
  193 +
  194 + %% LS-Linear + more averaging with srsLTE
  195 + [hest{4}(:,(1:14)+(i-1)*14), tmpnoise{4}(i)] = srslte_chest_dl(enb,rxGrid_sf,w2);
189 196  
190   -%% LS-Linear + averaging with srsLTE
191   -[tmp, ~, ~, noiseEst(3,nreal,snr_idx)] = srslte_chest(enb.NCellID,enb.CellRefP,rxGrid,w1);
192   -hest{3}=reshape(tmp, size(hest{1}));
  197 +end
193 198  
194   -%% LS-Linear + more averaging with srsLTE
195   -[tmp, ~, ~, noiseEst(4,nreal,snr_idx)] = srslte_chest(enb.NCellID,enb.CellRefP,rxGrid,w2);
196   -hest{4}=reshape(tmp, size(hest{1}));
  199 +%% Average noise estimates over all frame
  200 +for i=1:Ntests
  201 + noiseEst(i,nreal,snr_idx)=mean(tmpnoise{i});
  202 +end
197 203  
198 204 %% Compute MSE
199 205 for i=1:Ntests
... ... @@ -203,7 +209,6 @@ end
203 209  
204 210 %% Plot a single realization
205 211 if (length(SNR_values_db) == 1)
206   - subplot(2,1,1)
207 212 sym=1;
208 213 ref_idx=1:P;
209 214 ref_idx_x=[1:6:K];% (292:6:360)-216];% 577:6:648];
... ... @@ -212,13 +217,14 @@ if (length(SNR_values_db) == 1)
212 217 plot(n,abs(reshape(hest{i}(:,sym),1,[])),colors2{i});
213 218 hold on;
214 219 end
215   - plot(ref_idx_x,abs(hls(3,ref_idx)),'ro');
  220 + plot(n, abs(h(:,sym)),'g-')
  221 +% plot(ref_idx_x,real(hls(3,ref_idx)),'ro');
216 222 hold off;
217 223 tmp=cell(Ntests+1,1);
218 224 for i=1:Ntests
219 225 tmp{i}=legends{i};
220 226 end
221   - tmp{Ntests+1}='LS';
  227 + tmp{Ntests+1}='Real';
222 228 legend(tmp)
223 229  
224 230 xlabel('SNR (dB)')
... ... @@ -227,10 +233,6 @@ if (length(SNR_values_db) == 1)
227 233  
228 234 fprintf('Mean MMSE Robust %.2f dB\n', 10*log10(MSE(4,nreal,snr_idx)))
229 235 fprintf('Mean MMSE matlab %.2f dB\n', 10*log10(MSE(1,nreal,snr_idx)))
230   -
231   - subplot(2,1,2)
232   - plot(1:P,abs(W3(P/2,:)))
233   -
234 236 end
235 237  
236 238 end
... ...
matlab/tests/pdcch_bler.m
... ... @@ -11,7 +11,7 @@ SNR_values = linspace(2,6,6);
11 11 txCFI = 3;
12 12 enbConfig.NDLRB = 15; % No of Downlink RBs in total BW
13 13 enbConfig.CyclicPrefix = 'Normal'; % CP length
14   -enbConfig.CFI = txCFI; ; % 4 PDCCH symbols as NDLRB <= 10
  14 +enbConfig.CFI = txCFI; % 4 PDCCH symbols as NDLRB <= 10
15 15 enbConfig.Ng = 'One'; % HICH groups
16 16 enbConfig.CellRefP = 1; % 1-antenna ports
17 17 enbConfig.NCellID = 0; % Physical layer cell identity
... ... @@ -23,7 +23,7 @@ C_RNTI = 1; % 16-bit UE-specific mask
23 23 %% Setup Fading channel model
24 24 cfg.Seed = 8; % Random channel seed
25 25 cfg.NRxAnts = 1; % 1 receive antenna
26   -cfg.DelayProfile = 'EVA'; % EVA delay spread
  26 +cfg.DelayProfile = 'EPA'; % EVA delay spread
27 27 cfg.DopplerFreq = 5; % 120Hz Doppler frequency
28 28 cfg.MIMOCorrelation = 'Low'; % Low (no) MIMO correlation
29 29 cfg.InitTime = 0; % Initialize at time zero
... ... @@ -56,7 +56,7 @@ dciConfig.Allocation.RIV = 26; % Resource indication value
56 56 if C_RNTI<65535
57 57 pdcchConfig.RNTI = C_RNTI; % Radio network temporary identifier
58 58 end
59   -pdcchConfig.PDCCHFormat = 0; % PDCCH format
  59 +pdcchConfig.PDCCHFormat = 3; % PDCCH format
60 60 ueConfig.RNTI = C_RNTI;
61 61  
62 62 candidates = ltePDCCHSpace(enbConfig, pdcchConfig, {'bits', '1based'});
... ... @@ -153,7 +153,7 @@ for snr_idx=1:length(SNR_values)
153 153 %% Same with srsLTE
154 154 [rxCFI_srslte, pcfichRx2, pcfichSymbols2] = srslte_pcfich(enbConfigRx, subframe_rx);
155 155 decoded_cfi_srslte(snr_idx) = decoded_cfi_srslte(snr_idx) + (rxCFI_srslte == txCFI);
156   - enbConfigRx.CFI = rxCFI;
  156 + enbConfigRx.CFI = txCFI;
157 157 [found_srslte, pdcchBits2, pdcchRx2, pdcchSymbols2, hest2] = srslte_pdcch(enbConfigRx, ueConfig.RNTI, subframe_rx, hest, nest);
158 158 decoded_srslte(snr_idx) = decoded_srslte(snr_idx)+found_srslte;
159 159 end
... ...
matlab/tests/pdsch_bler_equal.m
... ... @@ -1,159 +0,0 @@
1   -
2   -%% PDSCH decoding based on RMC channels
3   -
4   -%% Cell-Wide Settings
5   -% A structure |enbConfig| is used to configure the eNodeB.
6   -%clear12
7   -
8   -recordedSignal=[];
9   -
10   -Npackets = 20;
11   -SNR_values = linspace(2,6,10);
12   -
13   -Lp=12;
14   -N=256;
15   -K=180;
16   -rstart=(N-K)/2;
17   -P=K/6;
18   -Rhphp=zeros(P,P);
19   -Rhhp=zeros(K,P);
20   -Rhh=zeros(K,K);
21   -
22   -t=0:Lp-1;
23   -alfa=log(2*Lp)/Lp;
24   -c_l=exp(-t*alfa);
25   -c_l=c_l/sum(c_l);
26   -C_l=diag(1./c_l);
27   -prows=rstart+(1:6:K);
28   -
29   -F=dftmtx(N);
30   -F_p=F(prows,1:Lp);
31   -F_l=F((rstart+1):(K+rstart),1:Lp);
32   -Wi=(F_p'*F_p+C_l*0.01)^(-1);
33   -W2=F_l*Wi*F_p';
34   -w2=reshape(transpose(W2),1,[]);
35   -
36   -
37   -%% Choose RMC
38   -[waveform,rgrid,rmccFgOut] = lteRMCDLTool('R.0',[1;0;0;1]);
39   -waveform = sum(waveform,2);
40   -
41   -if ~isempty(recordedSignal)
42   - rmccFgOut = struct('CellRefP',1,'NDLRB',100,'DuplexMode','FDD','CyclicPrefix','Normal');
43   - rmccFgOut.PDSCH.RNTI = 1234;
44   - rmccFgOut.PDSCH.PRBSet = repmat(transpose(0:rmccFgOut.NDLRB-1),1,2);
45   - rmccFgOut.PDSCH.TxScheme = 'Port0';
46   - rmccFgOut.PDSCH.NLayers = 1;
47   - rmccFgOut.PDSCH.NTurboDecIts = 5;
48   - rmccFgOut.PDSCH.Modulation = {'64QAM'};
49   - trblklen=75376;
50   - rmccFgOut.PDSCH.TrBlkSizes = trblklen*ones(10,1);
51   - rmccFgOut.PDSCH.RV = 0;
52   -end
53   -
54   -flen=rmccFgOut.SamplingRate/1000;
55   -
56   -Nsf = 9;
57   -
58   -%% Setup Fading channel model
59   -cfg.Seed = 0; % Random channel seed
60   -cfg.NRxAnts = 1; % 1 receive antenna
61   -cfg.DelayProfile = 'EPA'; % EVA delay spread
62   -cfg.DopplerFreq = 5; % 120Hz Doppler frequency
63   -cfg.MIMOCorrelation = 'Low'; % Low (no) MIMO correlation
64   -cfg.InitTime = 0; % Initialize at time zero
65   -cfg.NTerms = 16; % Oscillators used in fading model
66   -cfg.ModelType = 'GMEDS'; % Rayleigh fading model type
67   -cfg.InitPhase = 'Random'; % Random initial phases
68   -cfg.NormalizePathGains = 'On'; % Normalize delay profile power
69   -cfg.NormalizeTxAnts = 'On'; % Normalize for transmit antennas
70   -cfg.SamplingRate = rmccFgOut.SamplingRate;
71   -
72   -% Setup channel equalizer
73   -cec.PilotAverage = 'UserDefined'; % Type of pilot averaging
74   -cec.FreqWindow = 9; % Frequency window size
75   -cec.TimeWindow = 9; % Time window size
76   -cec.InterpType = 'linear'; % 2D interpolation type
77   -cec.InterpWindow = 'Causal'; % Interpolation window type
78   -cec.InterpWinSize = 1; % Interpolation window size
79   -
80   -addpath('../../build/srslte/lib/phch/test')
81   -
82   -decoded = zeros(size(SNR_values));
83   -decoded_srslte = zeros(size(SNR_values));
84   -
85   -for snr_idx=1:length(SNR_values)
86   - SNRdB = SNR_values(snr_idx);
87   - SNR = 10^(SNRdB/10); % Linear SNR
88   - N0 = 1/(sqrt(2.0*rmccFgOut.CellRefP*double(rmccFgOut.Nfft))*SNR);
89   -
90   - Rhphp=zeros(30,30);
91   - Rhhp=zeros(180,30);
92   -
93   - for i=1:Npackets
94   -
95   - if isempty(recordedSignal)
96   -
97   - %% Fading
98   - %rxWaveform = lteFadingChannel(cfg,waveform);
99   - rxWaveform = waveform;
100   -
101   - %% Noise Addition
102   - noise = N0*complex(randn(size(rxWaveform)), randn(size(rxWaveform))); % Generate noise
103   - rxWaveform = rxWaveform + noise;
104   - else
105   - rxWaveform = recordedSignal;
106   - end
107   -
108   - %% Demodulate
109   - frame_rx = lteOFDMDemodulate(rmccFgOut, rxWaveform);
110   -
111   - for sf_idx=0:Nsf-1
112   - % sf_idx=9;
113   - subframe_rx=frame_rx(:,sf_idx*14+1:(sf_idx+1)*14);
114   - rmccFgOut.NSubframe=sf_idx;
115   - rmccFgOut.TotSubframes=1;
116   -
117   - % Perform channel estimation
118   - [hest, nest,estimates] = lteDLChannelEstimate2(rmccFgOut, cec, subframe_rx);
119   -
120   - [cws,symbols] = ltePDSCHDecode(rmccFgOut,rmccFgOut.PDSCH,subframe_rx,hest,nest);
121   - [trblkout,blkcrc,dstate] = lteDLSCHDecode(rmccFgOut,rmccFgOut.PDSCH, ...
122   - rmccFgOut.PDSCH.TrBlkSizes(sf_idx+1),cws);
123   -
124   - decoded(snr_idx) = decoded(snr_idx) + ~blkcrc;
125   -
126   -
127   - %% Same with srsLTE
128   - if (rmccFgOut.PDSCH.TrBlkSizes(sf_idx+1) > 0)
129   - [dec2, data, pdschRx, pdschSymbols2, cws2] = srslte_pdsch(rmccFgOut, rmccFgOut.PDSCH, ...
130   - rmccFgOut.PDSCH.TrBlkSizes(sf_idx+1), ...
131   - subframe_rx);
132   - else
133   - dec2 = 1;
134   - end
135   - if (~dec2)
136   - fprintf('Error in sf=%d\n',sf_idx);
137   - end
138   - decoded_srslte(snr_idx) = decoded_srslte(snr_idx)+dec2;
139   - end
140   -
141   - if ~isempty(recordedSignal)
142   - recordedSignal = recordedSignal(flen*10+1:end);
143   - end
144   - end
145   - fprintf('SNR: %.1f. Decoded: %d-%d\n',SNRdB, decoded(snr_idx), decoded_srslte(snr_idx))
146   -end
147   -
148   -if (length(SNR_values)>1)
149   - semilogy(SNR_values,1-decoded/Npackets/(Nsf),'bo-',...
150   - SNR_values,1-decoded_srslte/Npackets/(Nsf), 'ro-')
151   - grid on;
152   - legend('Matlab','srsLTE')
153   - xlabel('SNR (dB)')
154   - ylabel('BLER')
155   - axis([min(SNR_values) max(SNR_values) 1/Npackets/(Nsf+1) 1])
156   -else
157   - fprintf('Matlab: %d OK\nsrsLTE: %d OK\n',decoded, decoded_srslte);
158   -end
159   -
matlab/tests/pdsch_decode_signal.m
1   -enb=struct('NCellID',1,'NDLRB',50,'NSubframe',2,'CFI',2,'CyclicPrefix','Normal','CellRefP',1,'Ng','One','PHICHDuration','Normal','DuplexMode','FDD');
  1 +enb=struct('NCellID',313,'NDLRB',75,'NSubframe',5,'CFI',1,'CyclicPrefix','Normal','CellRefP',2,'Ng','One','PHICHDuration','Normal','DuplexMode','FDD');
2 2  
3 3 RNTI=65535;
4 4  
5 5 addpath('../../build/srslte/lib/phch/test')
6 6  
7 7 cec.PilotAverage = 'UserDefined'; % Type of pilot averaging
8   -cec.FreqWindow = 9; % Frequency window size
9   -cec.TimeWindow = 9; % Time window size
  8 +cec.FreqWindow = 1; % Frequency window size
  9 +cec.TimeWindow = 1; % Time window size
10 10 cec.InterpType = 'linear'; % 2D interpolation type
11 11 cec.InterpWindow = 'Causal'; % Interpolation window type
12 12 cec.InterpWinSize = 1; % Interpolation window size
13 13  
14   -subframe_rx=lteOFDMDemodulate(enb,y);
15   -%subframe_rx=reshape(input,[],14);
  14 +%subframe_rx=lteOFDMDemodulate(enb,x);
  15 +subframe_rx=reshape(x,[],14);
16 16 [hest,nest] = lteDLChannelEstimate(enb, cec, subframe_rx);
17 17  
18 18 % Search PDCCH
... ... @@ -20,7 +20,7 @@ pdcchIndices = ltePDCCHIndices(enb);
20 20 [pdcchRx, pdcchHest] = lteExtractResources(pdcchIndices, subframe_rx, hest);
21 21 [dciBits, pdcchSymbols] = ltePDCCHDecode(enb, pdcchRx, pdcchHest, nest);
22 22 pdcch = struct('RNTI', RNTI);
23   -dci = ltePDCCHSearch(enb, pdcch, dciBits); % Search PDCCH for DCI
  23 +[dci, dcidecBits] = ltePDCCHSearch(enb, pdcch, dciBits); % Search PDCCH for DCI
24 24  
25 25 if ~isempty(dci)
26 26  
... ... @@ -29,10 +29,9 @@ if ~isempty(dci)
29 29  
30 30 % Get the PDSCH configuration from the DCI
31 31 [pdsch, trblklen] = hPDSCHConfiguration(enb, dci, pdcch.RNTI);
32   - pdsch.NTurboDecIts = 10;
33   - pdsch.Modulation = {'QPSK'};
  32 + pdsch.NTurboDecIts = 16;
  33 + %pdsch.Modulation = {'64QAM'};
34 34 pdsch.RV=0;
35   - %trblklen=75376;
36 35 fprintf('PDSCH settings after DCI decoding:\n');
37 36 disp(pdsch);
38 37  
... ... @@ -41,22 +40,32 @@ if ~isempty(dci)
41 40 [pdschIndices,pdschIndicesInfo] = ltePDSCHIndices(enb, pdsch, pdsch.PRBSet);
42 41 [pdschRx, pdschHest] = lteExtractResources(pdschIndices, subframe_rx, hest);
43 42 % Decode PDSCH
44   - [dlschBits,pdschSymbols] = ltePDSCHDecode(enb, pdsch, pdschRx, pdschHest, nest);
  43 + [dlschBits,pdschSymbols] = ltePDSCHDecode(enb, pdsch, pdschRx, pdschHest, 0);
45 44 [sib1, crc] = lteDLSCHDecode(enb, pdsch, trblklen, dlschBits);
46 45  
47   - %[dec2, data, pdschRx2, pdschSymbols2, e_bits] = srslte_pdsch(enb, pdsch, ...
48   - % trblklen, ...
49   - % subframe_rx, hest, nest);
  46 +
  47 + [dec2, data, pdschRx2, pdschSymbols2, e_bits, ce] = srslte_pdsch(enb, pdsch, ...
  48 + trblklen, ...
  49 + subframe_rx);
50 50  
51 51  
  52 + subplot(2,1,1)
52 53 scatter(real(pdschSymbols{1}),imag(pdschSymbols{1}))
  54 + subplot(2,1,2)
  55 + scatter(real(pdschSymbols2),imag(pdschSymbols2))
53 56  
54 57 if crc == 0
55   - fprintf('PDSCH OK.\n\n');
  58 + fprintf('PDSCH Matlab OK.\n\n');
56 59 else
57   - fprintf('PDSCH ERROR.\n\n');
  60 + fprintf('PDSCH Matlab ERROR.\n\n');
58 61 end
59   -
  62 +
  63 + if dec2 == 1
  64 + fprintf('PDSCH srsLTE OK.\n\n');
  65 + else
  66 + fprintf('PDSCH srsLTE ERROR.\n\n');
  67 + end
  68 +
60 69 else
61 70 % indicate that DCI decoding failed
62 71 fprintf('DCI decoding failed.\n\n');
... ...
matlab/tests/pdsch_equal.m 0 → 100644
... ... @@ -0,0 +1,166 @@
  1 +
  2 +%% PDSCH decoding based on RMC channels
  3 +
  4 +%% Cell-Wide Settings
  5 +% A structure |enbConfig| is used to configure the eNodeB.
  6 +%clear12
  7 +
  8 +recordedSignal=[];
  9 +
  10 +Npackets = 1;
  11 +SNR_values = 56;%linspace(2,6,10);
  12 +
  13 +Lp=12;
  14 +N=256;
  15 +K=180;
  16 +rstart=(N-K)/2;
  17 +P=K/6;
  18 +Rhphp=zeros(P,P);
  19 +Rhhp=zeros(K,P);
  20 +Rhh=zeros(K,K);
  21 +
  22 +t=0:Lp-1;
  23 +alfa=log(2*Lp)/Lp;
  24 +c_l=exp(-t*alfa);
  25 +c_l=c_l/sum(c_l);
  26 +C_l=diag(1./c_l);
  27 +prows=rstart+(1:6:K);
  28 +
  29 +F=dftmtx(N);
  30 +F_p=F(prows,1:Lp);
  31 +F_l=F((rstart+1):(K+rstart),1:Lp);
  32 +Wi=(F_p'*F_p+C_l*0.01)^(-1);
  33 +W2=F_l*Wi*F_p';
  34 +w2=reshape(transpose(W2),1,[]);
  35 +
  36 +
  37 +%% Choose RMC
  38 +[waveform,rgrid,rmccFgOut] = lteRMCDLTool('R.5',[1;0;0;1]);
  39 +waveform = sum(waveform,2);
  40 +
  41 +if ~isempty(recordedSignal)
  42 + rmccFgOut = struct('CellRefP',1,'NDLRB',25,'DuplexMode','FDD','CyclicPrefix','Normal');
  43 + rmccFgOut.PDSCH.RNTI = 1234;
  44 + rmccFgOut.PDSCH.PRBSet = repmat(transpose(0:rmccFgOut.NDLRB-1),1,2);
  45 + rmccFgOut.PDSCH.TxScheme = 'Port0';
  46 + rmccFgOut.PDSCH.NLayers = 1;
  47 + rmccFgOut.PDSCH.NTurboDecIts = 5;
  48 + rmccFgOut.PDSCH.Modulation = {'64QAM'};
  49 + trblklen=75376;
  50 + rmccFgOut.PDSCH.TrBlkSizes = trblklen*ones(10,1);
  51 + rmccFgOut.PDSCH.RV = 0;
  52 +end
  53 +
  54 +flen=rmccFgOut.SamplingRate/1000;
  55 +
  56 +Nsf = 2;
  57 +
  58 +%% Setup Fading channel model
  59 +cfg.Seed = 0; % Random channel seed
  60 +cfg.NRxAnts = 1; % 1 receive antenna
  61 +cfg.DelayProfile = 'EPA'; % EVA delay spread
  62 +cfg.DopplerFreq = 5; % 120Hz Doppler frequency
  63 +cfg.MIMOCorrelation = 'Low'; % Low (no) MIMO correlation
  64 +cfg.InitTime = 0; % Initialize at time zero
  65 +cfg.NTerms = 16; % Oscillators used in fading model
  66 +cfg.ModelType = 'GMEDS'; % Rayleigh fading model type
  67 +cfg.InitPhase = 'Random'; % Random initial phases
  68 +cfg.NormalizePathGains = 'On'; % Normalize delay profile power
  69 +cfg.NormalizeTxAnts = 'On'; % Normalize for transmit antennas
  70 +cfg.SamplingRate = rmccFgOut.SamplingRate;
  71 +
  72 +% Setup channel equalizer
  73 +cec.PilotAverage = 'UserDefined'; % Type of pilot averaging
  74 +cec.FreqWindow = 1; % Frequency window size
  75 +cec.TimeWindow = 1; % Time window size
  76 +cec.InterpType = 'linear'; % 2D interpolation type
  77 +cec.InterpWindow = 'Causal'; % Interpolation window type
  78 +cec.InterpWinSize = 1; % Interpolation window size
  79 +
  80 +addpath('../../build/srslte/lib/phch/test')
  81 +
  82 +decoded = zeros(size(SNR_values));
  83 +decoded_srslte = zeros(size(SNR_values));
  84 +
  85 +for snr_idx=1:length(SNR_values)
  86 + SNRdB = SNR_values(snr_idx);
  87 + SNR = 10^(SNRdB/10); % Linear SNR
  88 + N0 = 1/(sqrt(2.0*rmccFgOut.CellRefP*double(rmccFgOut.Nfft))*SNR);
  89 +
  90 + Rhphp=zeros(30,30);
  91 + Rhhp=zeros(180,30);
  92 +
  93 + for i=1:Npackets
  94 +
  95 + if isempty(recordedSignal)
  96 +
  97 + %% Fading
  98 + [rxWaveform, chinfo] = lteFadingChannel(cfg,waveform);
  99 + rxWaveform = rxWaveform(chinfo.ChannelFilterDelay+1:end);
  100 + %rxWaveform = waveform;
  101 +
  102 + %% Noise Addition
  103 + noise = N0*complex(randn(size(rxWaveform)), randn(size(rxWaveform))); % Generate noise
  104 + rxWaveform = rxWaveform + noise;
  105 + else
  106 + rxWaveform = recordedSignal;
  107 + end
  108 +
  109 + %% Demodulate
  110 + frame_rx = lteOFDMDemodulate(rmccFgOut, rxWaveform);
  111 +
  112 + for sf_idx=0:Nsf-1
  113 + % sf_idx=9;
  114 + subframe_rx=frame_rx(:,sf_idx*14+1:(sf_idx+1)*14);
  115 + rmccFgOut.NSubframe=sf_idx;
  116 + rmccFgOut.TotSubframes=1;
  117 +
  118 + % Perform channel estimation
  119 + [hest, nest] = lteDLChannelEstimate(rmccFgOut, cec, subframe_rx);
  120 +
  121 + [cws,symbols] = ltePDSCHDecode(rmccFgOut,rmccFgOut.PDSCH,subframe_rx,hest,nest);
  122 + [trblkout,blkcrc,dstate] = lteDLSCHDecode(rmccFgOut,rmccFgOut.PDSCH, ...
  123 + rmccFgOut.PDSCH.TrBlkSizes(sf_idx+1),cws);
  124 +
  125 + decoded(snr_idx) = decoded(snr_idx) + ~blkcrc;
  126 +
  127 +
  128 + %% Same with srsLTE
  129 + if (rmccFgOut.PDSCH.TrBlkSizes(sf_idx+1) > 0)
  130 + [dec2, data, pdschRx, pdschSymbols2, cws2, ce] = srslte_pdsch(rmccFgOut, rmccFgOut.PDSCH, ...
  131 + rmccFgOut.PDSCH.TrBlkSizes(sf_idx+1), ...
  132 + subframe_rx);
  133 + else
  134 + dec2 = 1;
  135 + end
  136 + if (~dec2)
  137 + fprintf('Error in sf=%d\n',sf_idx);
  138 + end
  139 + decoded_srslte(snr_idx) = decoded_srslte(snr_idx)+dec2;
  140 + end
  141 +
  142 + if ~isempty(recordedSignal)
  143 + recordedSignal = recordedSignal(flen*10+1:end);
  144 + end
  145 + end
  146 + fprintf('SNR: %.1f. Decoded: %d-%d\n',SNRdB, decoded(snr_idx), decoded_srslte(snr_idx))
  147 +end
  148 +
  149 +if (length(SNR_values)>1)
  150 + semilogy(SNR_values,1-decoded/Npackets/(Nsf),'bo-',...
  151 + SNR_values,1-decoded_srslte/Npackets/(Nsf), 'ro-')
  152 + grid on;
  153 + legend('Matlab','srsLTE')
  154 + xlabel('SNR (dB)')
  155 + ylabel('BLER')
  156 + axis([min(SNR_values) max(SNR_values) 1/Npackets/(Nsf+1) 1])
  157 +else
  158 + subplot(2,1,1)
  159 + scatter(real(pdschSymbols2),imag(pdschSymbols2))
  160 + %plot(real(hest))
  161 + subplot(2,1,2)
  162 + %plot(1:180,angle(ce(1:180)),1:180,angle(hest(:,1)))
  163 + plot(abs(ce-hest(:)))
  164 + fprintf('Matlab: %d OK\nsrsLTE: %d OK\n',decoded, decoded_srslte);
  165 +end
  166 +
... ...
matlab/tests/phich_bler.m 0 → 100644
... ... @@ -0,0 +1,132 @@
  1 +clear
  2 +
  3 +%% PHICH encoding/decoding
  4 +
  5 +%% Setup simulation
  6 +Npackets = 80;
  7 +SNR_values = linspace(-6,0,6);
  8 +enable_fading=false;
  9 +addpath('../../debug/srslte/lib/phch/test')
  10 +
  11 +
  12 +%% Cell-Wide Settings
  13 +enbConfig.NDLRB = 50; % No of Downlink RBs in total BW
  14 +enbConfig.CyclicPrefix = 'Normal'; % CP length
  15 +enbConfig.Ng = 'One'; % HICH groups
  16 +enbConfig.CellRefP = 1; % 1-antenna ports
  17 +enbConfig.NCellID = 36; % Physical layer cell identity
  18 +enbConfig.NSubframe = 5; % Subframe number 0
  19 +enbConfig.DuplexMode = 'FDD'; % Frame structure
  20 +enbConfig.PHICHDuration = 'Normal';
  21 +
  22 +%% Define HI resource
  23 +hi_res = [1 1];
  24 +ack_bit = 1;
  25 +
  26 +%% Setup Fading channel model
  27 +if (enable_fading)
  28 + cfg.Seed = 8; % Random channel seed
  29 + cfg.NRxAnts = 1; % 1 receive antenna
  30 + cfg.DelayProfile = 'EPA'; % EVA delay spread
  31 + cfg.DopplerFreq = 5; % 120Hz Doppler frequency
  32 + cfg.MIMOCorrelation = 'Low'; % Low (no) MIMO correlation
  33 + cfg.InitTime = 0; % Initialize at time zero
  34 + cfg.NTerms = 16; % Oscillators used in fading model
  35 + cfg.ModelType = 'GMEDS'; % Rayleigh fading model type
  36 + cfg.InitPhase = 'Random'; % Random initial phases
  37 + cfg.NormalizePathGains = 'On'; % Normalize delay profile power
  38 + cfg.NormalizeTxAnts = 'On'; % Normalize for transmit antennas
  39 +end
  40 +
  41 +% Setup channel equalizer
  42 +cec.PilotAverage = 'UserDefined'; % Type of pilot averaging
  43 +cec.FreqWindow = 9; % Frequency window size
  44 +cec.TimeWindow = 9; % Time window size
  45 +cec.InterpType = 'linear'; % 2D interpolation type
  46 +cec.InterpWindow = 'Causal'; % Interpolation window type
  47 +cec.InterpWinSize = 1; % Interpolation window size
  48 +
  49 +%% Generate TX subframe
  50 +subframe_tx = lteDLResourceGrid(enbConfig);
  51 +
  52 +%% Genearte PHICH signal
  53 +hi_sym_tx = ltePHICH(enbConfig, [hi_res ack_bit]);
  54 +hi_indices = ltePHICHIndices(enbConfig);
  55 +subframe_tx(hi_indices)=hi_sym_tx;
  56 +
  57 +%% Add references to subframe
  58 +cellRsSym = lteCellRS(enbConfig);
  59 +cellRsInd = lteCellRSIndices(enbConfig);
  60 +subframe_tx(cellRsInd) = cellRsSym;
  61 +
  62 +%% Modulate signal
  63 +[txWaveform, info] = lteOFDMModulate(enbConfig,subframe_tx);
  64 +cfg.SamplingRate = info.SamplingRate;
  65 +
  66 +%% Start simulation
  67 +decoded = zeros(size(SNR_values));
  68 +decoded_srslte = zeros(size(SNR_values));
  69 +
  70 +for snr_idx=1:length(SNR_values)
  71 + SNRdB = SNR_values(snr_idx);
  72 + SNR = 10^(SNRdB/10); % Linear SNR
  73 + N0 = 1/(sqrt(2.0*enbConfig.CellRefP*double(info.Nfft))*SNR);
  74 + for i=1:Npackets
  75 +
  76 + %% Fading
  77 + rxWaveform = sum(txWaveform,2);
  78 + if (enable_fading)
  79 + rxWaveform = lteFadingChannel(cfg,rxWaveform);
  80 + end
  81 +
  82 + %% Noise Addition
  83 + noise = N0*complex(randn(size(rxWaveform)), randn(size(rxWaveform)));
  84 + rxWaveform = rxWaveform + noise;
  85 +
  86 + %% Demodulate
  87 + subframe_rx = lteOFDMDemodulate(enbConfig, rxWaveform);
  88 +
  89 + %% Channel estimation
  90 + if (enable_fading)
  91 + [hest, nest] = lteDLChannelEstimate(enbConfig, cec, subframe_rx);
  92 + else
  93 + hest=ones(size(subframe_rx));
  94 + nest=0;
  95 + end
  96 +
  97 + %% Extract resources
  98 + phichSymbolsRx = subframe_rx(hi_indices);
  99 + phichSymbolsHest = hest(hi_indices);
  100 +
  101 + %% PHICH decoding
  102 + [hi, hi_symbols] = ltePHICHDecode(enbConfig,hi_res, phichSymbolsRx, phichSymbolsHest, nest);
  103 + decoded(snr_idx) = decoded(snr_idx) + (hi == ack_bit);
  104 +
  105 + %% Same with srsLTE
  106 + [hi_srslte, hi_symbols_srslte] = srslte_phich(enbConfig, hi_res, subframe_rx, hest, nest);
  107 + decoded_srslte(snr_idx) = decoded_srslte(snr_idx) + (hi_srslte == ack_bit);
  108 + end
  109 + fprintf('SNR: %.1f\n',SNRdB)
  110 +end
  111 +
  112 +if (Npackets>1)
  113 + semilogy(SNR_values,1-decoded/Npackets,'bo-',...
  114 + SNR_values,1-decoded_srslte/Npackets, 'ro-')
  115 + grid on
  116 + legend('Matlab','srsLTE')
  117 + xlabel('SNR (dB)')
  118 + ylabel('BLER')
  119 + axis([min(SNR_values) max(SNR_values) 1/Npackets/10 1])
  120 +else
  121 +
  122 + scatter(real(hi_symbols),imag(hi_symbols))
  123 + hold on
  124 + scatter(real(hi_symbols_srslte),imag(hi_symbols_srslte))
  125 + hold off
  126 + grid on;
  127 + axis([-2 2 -2 2])
  128 + disp(hi)
  129 + disp(hi_srslte)
  130 +
  131 +end
  132 +
... ...
matlab/tests/prach_detect_test.m 0 → 100644
... ... @@ -0,0 +1,199 @@
  1 +%% PRACH Detection Conformance Test
  2 +%clear
  3 +
  4 +d=50;%linspace(4,14,6);
  5 +pDetection2 = zeros(2,length(d));
  6 +for dd=1:length(d)
  7 +detect_factor=d(dd);
  8 +
  9 +numSubframes = 1; % Number of subframes frames to simulate at each SNR
  10 +SNRdB = 10;%linspace(-14,10,8); % SNR points to simulate
  11 +foffset = 0.0; % Frequency offset in Hertz
  12 +delay=0;
  13 +add_fading=false;
  14 +
  15 +addpath('../../build/srslte/lib/phch/test')
  16 +
  17 +%% UE Configuration
  18 +% User Equipment (UE) settings are specified in the structure |ue|.
  19 +
  20 +ue.NULRB = 15; % 6 Resource Blocks
  21 +ue.DuplexMode = 'FDD'; % Frequency Division Duplexing (FDD)
  22 +ue.CyclicPrefixUL = 'Normal'; % Normal cyclic prefix length
  23 +ue.NTxAnts = 1; % Number of transmission antennas
  24 +
  25 +%% PRACH Configuration
  26 +
  27 +prach.Format = 0; % PRACH format: TS36.104, Table 8.4.2.1-1
  28 +prach.HighSpeed = 0; % Normal mode: TS36.104, Table 8.4.2.1-1
  29 +prach.FreqOffset = 4; % Default frequency location
  30 +info = ltePRACHInfo(ue, prach); % PRACH information
  31 +
  32 +%% Propagation Channel Configuration
  33 +% Configure the propagation channel model using a structure |chcfg| as per
  34 +% TS36.104, Table 8.4.2.1-1 [ <#9 1> ].
  35 +
  36 +chcfg.NRxAnts = 1; % Number of receive antenna
  37 +chcfg.DelayProfile = 'ETU'; % Delay profile
  38 +chcfg.DopplerFreq = 70.0; % Doppler frequency
  39 +chcfg.MIMOCorrelation = 'Low'; % MIMO correlation
  40 +chcfg.Seed = 1; % Channel seed
  41 +chcfg.NTerms = 16; % Oscillators used in fading model
  42 +chcfg.ModelType = 'GMEDS'; % Rayleigh fading model type
  43 +chcfg.InitPhase = 'Random'; % Random initial phases
  44 +chcfg.NormalizePathGains = 'On'; % Normalize delay profile power
  45 +chcfg.NormalizeTxAnts = 'On'; % Normalize for transmit antennas
  46 +chcfg.SamplingRate = info.SamplingRate; % Sampling rate
  47 +
  48 +%% Loop for SNR Values
  49 +
  50 +% Initialize the random number generator stream
  51 +rng('default');
  52 +
  53 +% Initialize variables storing probability of detection at each SNR
  54 +pDetection = zeros(2,length(SNRdB));
  55 +
  56 +for nSNR = 1:length(SNRdB)
  57 +
  58 + % Scale noise to ensure the desired SNR after SC-FDMA demodulation
  59 + ulinfo = lteSCFDMAInfo(ue);
  60 + SNR = 10^(SNRdB(nSNR)/20);
  61 + N = 1/(SNR*sqrt(double(ulinfo.Nfft)))/sqrt(2.0);
  62 +
  63 + % Detected preamble count
  64 + detectedCount = 0;
  65 + detectedCount_srs = 0;
  66 +
  67 + % Loop for each subframe
  68 + for nsf = 1:numSubframes
  69 +
  70 + prach.SeqIdx = 0;%randi(838,1,1)-1; % Logical sequence index: TS36.141, Table A.6-1
  71 + prach.CyclicShiftIdx = 11;%randi(16,1,1)-1; % Cyclic shift index: TS36.141, Table A.6-1
  72 + prach.PreambleIdx = 1;%randi(64,1,1)-1; % Preamble index: TS36.141, Table A.6-1
  73 + info = ltePRACHInfo(ue, prach); % PRACH information
  74 +
  75 + % PRACH transmission
  76 + ue.NSubframe = mod(nsf-1, 10);
  77 + ue.NFrame = fix((nsf-1)/10);
  78 +
  79 + % Set PRACH timing offset in us as per TS36.141, Figure 8.4.1.4.2-2