mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
2.9 KiB
C
109 lines
2.9 KiB
C
11 years ago
|
/**
|
||
11 years ago
|
*
|
||
11 years ago
|
* \section COPYRIGHT
|
||
11 years ago
|
*
|
||
9 years ago
|
* Copyright 2013-2015 Software Radio Systems Limited
|
||
11 years ago
|
*
|
||
|
* \section LICENSE
|
||
|
*
|
||
10 years ago
|
* This file is part of the srsLTE library.
|
||
11 years ago
|
*
|
||
10 years ago
|
* srsLTE is free software: you can redistribute it and/or modify
|
||
10 years ago
|
* it under the terms of the GNU Affero General Public License as
|
||
11 years ago
|
* published by the Free Software Foundation, either version 3 of
|
||
|
* the License, or (at your option) any later version.
|
||
|
*
|
||
10 years ago
|
* srsLTE is distributed in the hope that it will be useful,
|
||
11 years ago
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
10 years ago
|
* GNU Affero General Public License for more details.
|
||
11 years ago
|
*
|
||
10 years ago
|
* A copy of the GNU Affero General Public License can be found in
|
||
11 years ago
|
* the LICENSE file in the top-level directory of this distribution
|
||
|
* and at http://www.gnu.org/licenses/.
|
||
|
*
|
||
11 years ago
|
*/
|
||
|
|
||
11 years ago
|
|
||
11 years ago
|
#include <stdbool.h>
|
||
|
#include <string.h>
|
||
|
|
||
10 years ago
|
#include "prb_dl.h"
|
||
10 years ago
|
#include "srslte/common/phy_common.h"
|
||
11 years ago
|
|
||
10 years ago
|
//#define DEBUG_IDX
|
||
10 years ago
|
|
||
|
#ifdef DEBUG_IDX
|
||
|
extern cf_t *offset_original;
|
||
10 years ago
|
SRSLTE_API int indices[100000];
|
||
|
SRSLTE_API int indices_ptr=0;
|
||
10 years ago
|
#endif
|
||
|
|
||
|
void print_indexes(cf_t *offset, int len) {
|
||
|
#ifdef DEBUG_IDX
|
||
|
for (int i=0;i<len;i++) {
|
||
10 years ago
|
indices[(i+indices_ptr)%100000]=offset-offset_original+i;
|
||
10 years ago
|
}
|
||
10 years ago
|
indices_ptr+=len;
|
||
10 years ago
|
#endif
|
||
|
}
|
||
|
|
||
11 years ago
|
void prb_cp_ref(cf_t **input, cf_t **output, int offset, int nof_refs,
|
||
11 years ago
|
int nof_intervals, bool advance_output) {
|
||
11 years ago
|
int i;
|
||
11 years ago
|
|
||
10 years ago
|
int ref_interval = ((SRSLTE_NRE / nof_refs) - 1);
|
||
11 years ago
|
memcpy(*output, *input, offset * sizeof(cf_t));
|
||
10 years ago
|
print_indexes(*input, offset);
|
||
11 years ago
|
*input += offset;
|
||
|
*output += offset;
|
||
11 years ago
|
for (i = 0; i < nof_intervals - 1; i++) {
|
||
11 years ago
|
if (advance_output) {
|
||
|
(*output)++;
|
||
|
} else {
|
||
|
(*input)++;
|
||
|
}
|
||
|
memcpy(*output, *input, ref_interval * sizeof(cf_t));
|
||
10 years ago
|
print_indexes(*input, ref_interval);
|
||
11 years ago
|
*output += ref_interval;
|
||
|
*input += ref_interval;
|
||
|
}
|
||
|
if (ref_interval - offset > 0) {
|
||
|
if (advance_output) {
|
||
|
(*output)++;
|
||
|
} else {
|
||
|
(*input)++;
|
||
|
}
|
||
|
memcpy(*output, *input, (ref_interval - offset) * sizeof(cf_t));
|
||
10 years ago
|
print_indexes(*input, ref_interval-offset);
|
||
11 years ago
|
*output += (ref_interval - offset);
|
||
|
*input += (ref_interval - offset);
|
||
|
}
|
||
11 years ago
|
}
|
||
|
|
||
11 years ago
|
void prb_cp(cf_t **input, cf_t **output, int nof_prb) {
|
||
10 years ago
|
memcpy(*output, *input, sizeof(cf_t) * SRSLTE_NRE * nof_prb);
|
||
|
print_indexes(*input, SRSLTE_NRE);
|
||
|
*input += nof_prb * SRSLTE_NRE;
|
||
|
*output += nof_prb * SRSLTE_NRE;
|
||
11 years ago
|
}
|
||
|
|
||
11 years ago
|
|
||
|
void prb_cp_half(cf_t **input, cf_t **output, int nof_prb) {
|
||
10 years ago
|
memcpy(*output, *input, sizeof(cf_t) * SRSLTE_NRE * nof_prb / 2);
|
||
|
print_indexes(*input, SRSLTE_NRE/2);
|
||
|
*input += nof_prb * SRSLTE_NRE / 2;
|
||
|
*output += nof_prb * SRSLTE_NRE / 2;
|
||
11 years ago
|
}
|
||
|
|
||
11 years ago
|
void prb_put_ref_(cf_t **input, cf_t **output, int offset, int nof_refs,
|
||
11 years ago
|
int nof_intervals) {
|
||
|
prb_cp_ref(input, output, offset, nof_refs, nof_intervals, false);
|
||
11 years ago
|
}
|
||
|
|
||
11 years ago
|
void prb_get_ref_(cf_t **input, cf_t **output, int offset, int nof_refs,
|
||
11 years ago
|
int nof_intervals) {
|
||
|
prb_cp_ref(input, output, offset, nof_refs, nof_intervals, true);
|
||
11 years ago
|
}
|
||
|
|