2015-02-16 09:22:02 -08:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* \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>
|
2015-03-18 05:31:13 -07:00
|
|
|
#include "srslte/srslte.h"
|
2015-03-18 05:16:28 -07:00
|
|
|
#include "srslte/mex/mexutils.h"
|
2015-02-16 09:22:02 -08:00
|
|
|
|
|
|
|
/** 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
|
2015-03-18 05:16:28 -07:00
|
|
|
("waveform = srslte_prach(ueConfig, prachConfig)\n\n");
|
2015-02-16 09:22:02 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|
2015-03-18 05:59:29 -07:00
|
|
|
int r = srslte_symbol_sz(n_ul_rb);
|
2015-02-16 09:22:02 -08:00
|
|
|
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);
|
|
|
|
|
2015-03-18 11:14:24 -07:00
|
|
|
srslte_prach_t prach;
|
|
|
|
if (srslte_prach_init(&prach, N_ifft_ul, preamble_format, root_seq_idx, high_speed_flag, zero_corr_zone)) {
|
2015-02-16 09:22:02 -08:00
|
|
|
mexErrMsgTxt("Error initiating PRACH\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-18 05:59:29 -07:00
|
|
|
uint32_t nof_samples = srslte_sampling_freq_hz(n_ul_rb) * 0.003;
|
2015-02-16 09:22:02 -08:00
|
|
|
|
2015-03-18 11:14:24 -07:00
|
|
|
cf_t *signal = srslte_vec_malloc(sizeof(cf_t) * nof_samples);
|
2015-02-16 09:22:02 -08:00
|
|
|
if (!signal) {
|
|
|
|
mexErrMsgTxt("malloc");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bzero(signal, sizeof(cf_t) * nof_samples);
|
2015-03-18 11:14:24 -07:00
|
|
|
if (srslte_prach_gen(&prach, seq_idx, frequency_offset, 0.2, signal)) {
|
2015-02-16 09:22:02 -08:00
|
|
|
mexErrMsgTxt("Error generating PRACH\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (nlhs >= 0) {
|
|
|
|
mexutils_write_cf(signal, &plhs[0], nof_samples, 1);
|
|
|
|
}
|
|
|
|
|
2015-02-16 09:53:36 -08:00
|
|
|
free(signal);
|
|
|
|
|
2015-03-18 11:14:24 -07:00
|
|
|
srslte_prach_free(&prach);
|
2015-02-16 09:53:36 -08:00
|
|
|
|
2015-02-16 09:22:02 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|