/** * * \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 #include #include #include #include #include #include #include #include "srslte/phy/phch/pucch.h" #include "srslte/phy/phch/uci.h" #include "srslte/phy/common/phy_common.h" #include "srslte/phy/utils/bit.h" #include "srslte/phy/utils/debug.h" #include "srslte/phy/utils/vector.h" #include "srslte/phy/filter/dft_precoding.h" #define MAX_PUSCH_RE(cp) (2 * CP_NSYMB(cp) * 12) bool pucch_cfg_isvalid(pucch_cfg_t *cfg) { return true; } /* Generates n_cs_cell according to Sec 5.4 of 36.211 */ int generate_n_cs_cell(lte_cell_t cell, uint32_t n_cs_cell[NSLOTS_X_FRAME][CPNORM_NSYMB]) { sequence_t seq; bzero(&seq, sizeof(sequence_t)); sequence_LTE_pr(&seq, 8*CP_NSYMB(cell.cp)*NSLOTS_X_FRAME, cell.id); for (uint32_t ns=0;nsn_pucch < c*cfg->N_cs/cfg->delta_pucch_shift)?cfg->N_cs:12; uint32_t n_prime = cfg->n_pucch; if (cfg->n_pucch >= c*cfg->N_cs/cfg->delta_pucch_shift) { n_prime = (cfg->n_pucch-c*cfg->N_cs/cfg->delta_pucch_shift)%(cfg->N_cs/cfg->delta_pucch_shift); } uint32_t n_oc_div = (!is_drms && CP_ISEXT(cp))?2:1; uint32_t n_oc = n_prime*cfg->delta_pucch_shift/N_prime; if (!is_drms && CP_ISEXT(cp)) { n_oc *= 2; } if (n_oc_ptr) { *n_oc_ptr = n_oc; } uint32_t n_cs = 0; if (CP_ISNORM(cp)) { n_cs = (n_cs_cell[ns][l]+(n_prime*cfg->delta_pucch_shift+(n_oc%cfg->delta_pucch_shift))%N_prime)%12; } else { n_cs = (n_cs_cell[ns][l]+(n_prime*cfg->delta_pucch_shift+n_oc/n_oc_div)%N_prime)%12; } return 2 * M_PI * (n_cs) / 12; } int pucch_cp(pucch_t *q, harq_t *harq, cf_t *input, cf_t *output, bool advance_input) { return LIBLTE_ERROR; } int pucch_put(pucch_t *q, harq_t *harq, cf_t *input, cf_t *output) { return pucch_cp(q, harq, input, output, true); } int pucch_get(pucch_t *q, harq_t *harq, cf_t *input, cf_t *output) { return pucch_cp(q, harq, input, output, false); } /** Initializes the PDCCH transmitter and receiver */ int pucch_init(pucch_t *q, lte_cell_t cell) { int ret = LIBLTE_ERROR_INVALID_INPUTS; if (q != NULL && lte_cell_isvalid(&cell)) { ret = LIBLTE_ERROR; bzero(q, sizeof(pucch_t)); q->cell = cell; if (generate_n_cs_cell(q->cell, q->n_cs_cell)) { return LIBLTE_ERROR; } ret = LIBLTE_SUCCESS; } return ret; } void pucch_free(pucch_t *q) { bzero(q, sizeof(pucch_t)); } /** Decodes the PUSCH from the received symbols */ int pucch_decode(pucch_t *q, harq_t *harq, cf_t *sf_symbols, cf_t *ce, float noise_estimate, uint8_t *data) { return LIBLTE_ERROR_INVALID_INPUTS; } static cf_t uci_encode_format1() { return 1.0; } static cf_t uci_encode_format1a(uint8_t bit) { return bit?1.0:-1.0; } static cf_t uci_encode_format1b(uint8_t bits[2]) { if (bits[0] == 0) { if (bits[1] == 0) { return 1; } else { return -I; } } else { if (bits[1] == 0) { return I; } else { return -1.0; } } } static void uci_mod_bits(pucch_t *q, pucch_cfg_t *cfg, uint8_t bits[PUCCH_MAX_BITS]) { cf_t d_0 = 0; uint8_t tmp[2]; switch(cfg->format) { case PUCCH_FORMAT_1: d_0 = uci_encode_format1(); break; case PUCCH_FORMAT_1A: d_0 = uci_encode_format1a(bits[0]); break; case PUCCH_FORMAT_1B: tmp[0] = bits[0]; tmp[1] = bits[1]; d_0 = uci_encode_format1b(tmp); default: fprintf(stderr, "PUCCH format 2 not supported\n"); return; } /* for (uint32_t n=0;ny[n] = d_0+ } */ } int pucch_encode(pucch_t *q, pucch_cfg_t *cfg, uint8_t bits[PUCCH_MAX_BITS], cf_t *sf_symbols) { uci_mod_bits(q, cfg, bits); return LIBLTE_ERROR; }