mirror of https://github.com/pvnis/srsRAN_4G.git
Fixed issue in PRACH generation. Added Matlab test
parent
58ccecc8d7
commit
f8d48961ef
@ -0,0 +1,112 @@
|
||||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2014 The libLTE Developers. See the
|
||||
* COPYRIGHT file at the top-level directory of this distribution.
|
||||
*
|
||||
* \section LICENSE
|
||||
*
|
||||
* This file is part of the libLTE library.
|
||||
*
|
||||
* libLTE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* libLTE is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* A copy of the GNU Lesser General Public License can be found in
|
||||
* the LICENSE file in the top-level directory of this distribution
|
||||
* and at http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "liblte/phy/phy.h"
|
||||
#include "liblte/mex/mexutils.h"
|
||||
|
||||
/** MEX function to be called from MATLAB to test the channel estimator
|
||||
*/
|
||||
|
||||
#define UECFG prhs[0]
|
||||
#define PRACHCFG prhs[1]
|
||||
#define NOF_INPUTS 2
|
||||
|
||||
void help()
|
||||
{
|
||||
mexErrMsgTxt
|
||||
("waveform = liblte_prach(ueConfig, prachConfig)\n\n");
|
||||
}
|
||||
|
||||
/* the gateway function */
|
||||
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
|
||||
{
|
||||
|
||||
if (nrhs != NOF_INPUTS) {
|
||||
help();
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t n_ul_rb = 0;
|
||||
if (mexutils_read_uint32_struct(UECFG, "NULRB", &n_ul_rb)) {
|
||||
mexErrMsgTxt("Field NULRB not found in UE config\n");
|
||||
return;
|
||||
}
|
||||
int r = lte_symbol_sz(n_ul_rb);
|
||||
if (r < 0) {
|
||||
mexErrMsgTxt("Invalid NULRB\n");
|
||||
return;
|
||||
}
|
||||
uint32_t N_ifft_ul = (uint32_t) r;
|
||||
|
||||
uint32_t sf_idx = 0;
|
||||
mexutils_read_uint32_struct(UECFG, "NSubframe", &sf_idx);
|
||||
uint32_t nframe = 0;
|
||||
mexutils_read_uint32_struct(UECFG, "NFrame", &nframe);
|
||||
|
||||
uint32_t preamble_format = 0;
|
||||
mexutils_read_uint32_struct(PRACHCFG, "Format", &preamble_format);
|
||||
uint32_t root_seq_idx = 0;
|
||||
mexutils_read_uint32_struct(PRACHCFG, "SeqIdx", &root_seq_idx);
|
||||
uint32_t seq_idx = 0;
|
||||
mexutils_read_uint32_struct(PRACHCFG, "PreambleIdx", &seq_idx);
|
||||
uint32_t zero_corr_zone = 0;
|
||||
mexutils_read_uint32_struct(PRACHCFG, "CyclicShiftIdx", &zero_corr_zone);
|
||||
uint32_t high_speed_flag = 0;
|
||||
mexutils_read_uint32_struct(PRACHCFG, "HighSpeed", &high_speed_flag);
|
||||
uint32_t timing_offset = 0;
|
||||
mexutils_read_uint32_struct(PRACHCFG, "TimingOffset", &timing_offset);
|
||||
uint32_t frequency_offset = 0;
|
||||
mexutils_read_uint32_struct(PRACHCFG, "FreqOffset", &frequency_offset);
|
||||
|
||||
prach_t prach;
|
||||
if (prach_init(&prach, N_ifft_ul, preamble_format, root_seq_idx, high_speed_flag, zero_corr_zone)) {
|
||||
mexErrMsgTxt("Error initiating PRACH\n");
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t nof_samples = lte_sampling_freq_hz(n_ul_rb) * 0.001;
|
||||
|
||||
cf_t *signal = vec_malloc(sizeof(cf_t) * nof_samples);
|
||||
if (!signal) {
|
||||
mexErrMsgTxt("malloc");
|
||||
return;
|
||||
}
|
||||
bzero(signal, sizeof(cf_t) * nof_samples);
|
||||
if (prach_gen(&prach, seq_idx, frequency_offset, signal)) {
|
||||
mexErrMsgTxt("Error generating PRACH\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (nlhs >= 0) {
|
||||
mexutils_write_cf(signal, &plhs[0], nof_samples, 1);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
Binary file not shown.
@ -0,0 +1,48 @@
|
||||
clear
|
||||
ueConfig=struct('NULRB',6,'DuplexMode','FDD','CyclicPrefix','Normal');
|
||||
prachConfig=struct('Format',0,'SeqIdx',0,'PreambleIdx',0,'CyclicShiftIdx',0,'HighSpeed',0,'TimingOffset',0,'FreqIdx',0,'FreqOffset',0);
|
||||
|
||||
addpath('../../debug/lte/phy/lib/phch/test')
|
||||
|
||||
NULRB=[6 15 25 50 100];
|
||||
|
||||
% FreqIdx, FreqOffset and TimeOffset need to be tested
|
||||
|
||||
for n_rb=1:length(NULRB)
|
||||
for format=0:3
|
||||
for seqIdx=0:837
|
||||
fprintf('format %d, seqIdx: %d\n',format,seqIdx);
|
||||
for preambleIdx=0:63
|
||||
for CyclicShift=0:15
|
||||
%for hs=0:1
|
||||
hs=0;
|
||||
ueConfig.NULRB=NULRB(n_rb);
|
||||
prachConfig.Format=format;
|
||||
prachConfig.SeqIdx=seqIdx;
|
||||
prachConfig.PreambleIdx=preambleIdx;
|
||||
prachConfig.CyclicShiftIdx=CyclicShift;
|
||||
prachConfig.HighSpeed=hs;
|
||||
|
||||
[mat, info]=ltePRACH(ueConfig,prachConfig);
|
||||
|
||||
lib=liblte_prach(ueConfig,prachConfig);
|
||||
err=mean(abs(mat(:)-lib(:)));
|
||||
if (err > 10^-3)
|
||||
disp(err)
|
||||
error('Error!');
|
||||
end
|
||||
% end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
%
|
||||
% disp(info)
|
||||
n=1:length(mat);
|
||||
% plot(abs(double(mat)-double(lib)))
|
||||
flib=fft(lib(199:end),1536);
|
||||
fmat=fft(mat(199:end),1536);
|
||||
n=1:1536;
|
||||
plot(n,real(flib(n)),n,real(fmat(n)))
|
Loading…
Reference in New Issue