From 35ebaa30da3f0a36328bffe78c33b355e9bfdd94 Mon Sep 17 00:00:00 2001 From: ismagom Date: Mon, 9 Nov 2015 23:54:53 +0100 Subject: [PATCH] Added missing files --- srslte/include/srslte/sync/cp.h | 55 +++++++++++++++++++ srslte/lib/phch/src/pusch.c | 1 - srslte/lib/sync/test/cp_mex.c | 94 +++++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 srslte/include/srslte/sync/cp.h create mode 100644 srslte/lib/sync/test/cp_mex.c diff --git a/srslte/include/srslte/sync/cp.h b/srslte/include/srslte/sync/cp.h new file mode 100644 index 000000000..9989c339a --- /dev/null +++ b/srslte/include/srslte/sync/cp.h @@ -0,0 +1,55 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2015 The srsLTE Developers. See the + * COPYRIGHT file at the top-level directory of this distribution. + * + * \section LICENSE + * + * This file is part of the srsLTE library. + * + * srsLTE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * srsLTE 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 Affero General Public License for more details. + * + * A copy of the GNU Affero 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/. + * + */ + +#ifndef CP_ +#define CP_ + +#include +#include + +#include "srslte/config.h" + +typedef struct { + cf_t *corr; + uint32_t symbol_sz; +} srslte_cp_synch_t; + +SRSLTE_API int srslte_cp_synch_init(srslte_cp_synch_t *q, + uint32_t symbol_sz); + +SRSLTE_API void srslte_cp_synch_free(srslte_cp_synch_t *q); + +SRSLTE_API uint32_t srslte_cp_synch(srslte_cp_synch_t *q, + cf_t *input, + uint32_t max_offset, + uint32_t nof_symbols, + uint32_t cp_len); + +SRSLTE_API cf_t srslte_cp_synch_corr_output(srslte_cp_synch_t *q, + uint32_t offset); + +#endif // CP_ diff --git a/srslte/lib/phch/src/pusch.c b/srslte/lib/phch/src/pusch.c index 74e134037..e625914a9 100644 --- a/srslte/lib/phch/src/pusch.c +++ b/srslte/lib/phch/src/pusch.c @@ -342,7 +342,6 @@ int srslte_pusch_cfg(srslte_pusch_t *q, if (cfg->grant.n_prb_tilde[ns] == k0_srs + nrb_srs || // If PUSCH is contiguous on the right-hand side of SRS cfg->grant.n_prb_tilde[ns] + cfg->grant.L_prb == k0_srs) // If SRS is contiguous on the left-hand side of PUSCH { - printf("Not shortened because are continuous, k0_srs=%d, L_srs=%d, n_prb=%d, L_prb=%d\n", k0_srs, nrb_srs, cfg->grant.n_prb_tilde[ns], cfg->grant.L_prb); q->shortened = false; } } diff --git a/srslte/lib/sync/test/cp_mex.c b/srslte/lib/sync/test/cp_mex.c new file mode 100644 index 000000000..2edc358f7 --- /dev/null +++ b/srslte/lib/sync/test/cp_mex.c @@ -0,0 +1,94 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2015 The srsLTE Developers. See the + * COPYRIGHT file at the top-level directory of this distribution. + * + * \section LICENSE + * + * This file is part of the srsLTE library. + * + * srsLTE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * srsLTE 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 Affero General Public License for more details. + * + * A copy of the GNU Affero 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 +#include "srslte/srslte.h" +#include "srslte/mex/mexutils.h" + +/** MEX function to be called from MATLAB to test the channel estimator + */ + +#define ENBCFG prhs[0] +#define INPUT prhs[1] +#define NOF_INPUTS 2 + + +void help() +{ + mexErrMsgTxt + ("[offset,corr] = srslte_cp_synch(enbConfig, inputSignal)\n\n"); +} + +/* the gateway function */ +void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) +{ + + srslte_cell_t cell; + srslte_cp_synch_t cp_synch; + cf_t *input_symbols; + int frame_len; + + if (nrhs != NOF_INPUTS) { + help(); + return; + } + + if (mexutils_read_cell(ENBCFG, &cell)) { + help(); + return; + } + + /** Allocate input buffers */ + frame_len = mexutils_read_cf(INPUT, &input_symbols); + if (frame_len < 0) { + mexErrMsgTxt("Error reading input symbols\n"); + return; + } + + uint32_t symbol_sz = srslte_symbol_sz(cell.nof_prb); + if (srslte_cp_synch_init(&cp_synch, symbol_sz)) { + fprintf(stderr, "Error initiating CP\n"); + return; + } + + uint32_t cp_len = SRSLTE_CP_LEN_NORM(1, symbol_sz); + uint32_t nsymbols = frame_len/(symbol_sz+cp_len)-1; + uint32_t peak_idx = srslte_cp_synch(&cp_synch, input_symbols, symbol_sz, nsymbols, cp_len); + + if (nlhs >= 1) { + plhs[0] = mxCreateDoubleScalar(peak_idx); + } + if (nlhs >= 2) { + mexutils_write_cf(cp_synch.corr, &plhs[1], symbol_sz, 1); + } + + srslte_cp_synch_free(&cp_synch); + free(input_symbols); + + return; +} +