srsLTE/lib/include/srslte/phy/phch/pucch.h

215 lines
7.8 KiB
C
Raw Normal View History

2015-03-17 10:26:23 -07:00
/**
*
* \section COPYRIGHT
*
2015-11-13 04:22:33 -08:00
* Copyright 2013-2015 Software Radio Systems Limited
2015-03-17 10:26:23 -07:00
*
* \section LICENSE
*
* This file is part of the srsLTE library.
2015-03-17 10:26:23 -07:00
*
* srsLTE is free software: you can redistribute it and/or modify
2015-05-08 08:05:40 -07:00
* it under the terms of the GNU Affero General Public License as
2015-03-17 10:26:23 -07:00
* 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,
2015-03-17 10:26:23 -07:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2015-05-08 08:05:40 -07:00
* GNU Affero General Public License for more details.
2015-03-17 10:26:23 -07:00
*
2015-05-08 08:05:40 -07:00
* A copy of the GNU Affero General Public License can be found in
2015-03-17 10:26:23 -07:00
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
/******************************************************************************
* File: pucch.h
*
* Description: Physical uplink control channel.
*
* Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 5.4
*****************************************************************************/
2015-03-17 10:26:23 -07:00
2018-03-31 10:04:04 -07:00
#ifndef SRSLTE_PUCCH_H
#define SRSLTE_PUCCH_H
2015-03-17 10:26:23 -07:00
#include "srslte/config.h"
2017-05-18 00:48:24 -07:00
#include "srslte/phy/common/phy_common.h"
#include "srslte/phy/common/sequence.h"
#include "srslte/phy/modem/mod.h"
#include "srslte/phy/phch/cqi.h"
#include "srslte/phy/phch/uci.h"
2015-03-17 10:26:23 -07:00
#define SRSLTE_PUCCH_N_SEQ 12
2017-03-28 00:13:24 -07:00
#define SRSLTE_PUCCH2_NOF_BITS SRSLTE_UCI_CQI_CODED_PUCCH_B
#define SRSLTE_PUCCH_MAX_BITS SRSLTE_CQI_MAX_BITS
#define SRSLTE_PUCCH_MAX_SYMBOLS 128
2015-03-17 10:26:23 -07:00
typedef enum SRSLTE_API {
2015-03-18 11:14:24 -07:00
SRSLTE_PUCCH_FORMAT_1 = 0,
SRSLTE_PUCCH_FORMAT_1A,
SRSLTE_PUCCH_FORMAT_1B,
SRSLTE_PUCCH_FORMAT_2,
SRSLTE_PUCCH_FORMAT_2A,
2016-10-20 08:49:51 -07:00
SRSLTE_PUCCH_FORMAT_2B,
SRSLTE_PUCCH_FORMAT_ERROR,
2015-03-18 11:14:24 -07:00
} srslte_pucch_format_t;
2015-03-17 10:26:23 -07:00
typedef struct SRSLTE_API {
bool sps_enabled;
uint32_t tpc_for_pucch;
uint32_t N_pucch_1;
uint32_t n_pucch_1[4]; // 4 n_pucch resources specified by RRC
uint32_t n_pucch_2;
uint32_t n_pucch_sr;
}srslte_pucch_sched_t;
typedef struct SRSLTE_API {
2016-10-18 01:39:49 -07:00
// Common configuration
2015-03-17 10:26:23 -07:00
uint32_t delta_pucch_shift;
2015-04-15 01:06:40 -07:00
uint32_t n_rb_2;
2015-03-17 10:26:23 -07:00
uint32_t N_cs;
2016-10-20 02:57:59 -07:00
uint32_t n1_pucch_an;
2016-10-18 01:39:49 -07:00
// SRS configuration
2015-06-15 04:45:15 -07:00
bool srs_configured;
2015-06-12 08:49:11 -07:00
uint32_t srs_cs_subf_cfg;
bool srs_simul_ack;
2015-03-18 11:14:24 -07:00
} srslte_pucch_cfg_t;
2015-03-17 10:26:23 -07:00
2017-03-28 00:13:24 -07:00
typedef struct {
srslte_sequence_t seq_f2[SRSLTE_NSUBFRAMES_X_FRAME];
bool sequence_generated;
2017-03-28 00:13:24 -07:00
} srslte_pucch_user_t;
2016-10-18 01:39:49 -07:00
/* PUCCH object */
typedef struct SRSLTE_API {
2015-03-18 05:41:50 -07:00
srslte_cell_t cell;
2015-03-18 11:14:24 -07:00
srslte_pucch_cfg_t pucch_cfg;
srslte_modem_table_t mod;
2017-03-28 00:13:24 -07:00
srslte_uci_cqi_pucch_t cqi;
srslte_pucch_user_t **users;
uint8_t bits_scram[SRSLTE_PUCCH_MAX_BITS];
cf_t d[SRSLTE_PUCCH_MAX_BITS/2];
2015-04-05 07:32:35 -07:00
uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CP_NORM_NSYMB];
2015-04-15 01:06:40 -07:00
uint32_t f_gh[SRSLTE_NSLOTS_X_FRAME];
float tmp_arg[SRSLTE_PUCCH_N_SEQ];
2016-10-20 02:57:59 -07:00
2017-09-05 06:26:36 -07:00
cf_t *z;
cf_t *z_tmp;
cf_t *ce;
2016-10-20 02:57:59 -07:00
2015-06-12 08:49:11 -07:00
bool shortened;
2015-06-14 16:56:33 -07:00
bool group_hopping_en;
2016-10-18 01:39:49 -07:00
float threshold_format1;
float last_corr;
2017-01-13 03:59:09 -08:00
uint32_t last_n_prb;
uint32_t last_n_pucch;
2016-10-18 01:39:49 -07:00
2015-03-18 11:14:24 -07:00
}srslte_pucch_t;
2015-03-17 10:26:23 -07:00
SRSLTE_API int srslte_pucch_init(srslte_pucch_t *q);
2015-03-17 10:26:23 -07:00
2015-03-18 11:14:24 -07:00
SRSLTE_API void srslte_pucch_free(srslte_pucch_t *q);
2015-03-17 10:26:23 -07:00
SRSLTE_API int srslte_pucch_set_cell(srslte_pucch_t *q,
srslte_cell_t cell);
SRSLTE_API bool srslte_pucch_set_cfg(srslte_pucch_t* q,
2015-06-14 16:56:33 -07:00
srslte_pucch_cfg_t* cfg,
bool group_hopping_en);
2017-08-24 06:16:13 -07:00
SRSLTE_API void srslte_pucch_set_threshold(srslte_pucch_t *q,
float format1_threshold);
2016-10-18 01:39:49 -07:00
SRSLTE_API int srslte_pucch_set_crnti(srslte_pucch_t *q,
uint16_t c_rnti);
2015-03-17 10:26:23 -07:00
2017-03-28 00:13:24 -07:00
SRSLTE_API void srslte_pucch_clear_rnti(srslte_pucch_t *q,
uint16_t rnti);
SRSLTE_API uint32_t srslte_pucch_nof_symbols(srslte_pucch_cfg_t *cfg,
2015-06-14 13:11:49 -07:00
srslte_pucch_format_t format,
bool shortened);
SRSLTE_API float srslte_pucch_get_last_corr(srslte_pucch_t* q);
2015-03-18 11:14:24 -07:00
SRSLTE_API int srslte_pucch_encode(srslte_pucch_t *q,
srslte_pucch_format_t format,
uint32_t n_pucch, // n_pucch_1 or n_pucch_2 depending on format
2015-04-15 01:06:40 -07:00
uint32_t sf_idx,
2017-03-28 00:13:24 -07:00
uint16_t rnti,
2015-03-18 11:14:24 -07:00
uint8_t bits[SRSLTE_PUCCH_MAX_BITS],
cf_t *sf_symbols);
2015-03-17 10:26:23 -07:00
2016-10-18 01:39:49 -07:00
SRSLTE_API int srslte_pucch_decode(srslte_pucch_t *q,
srslte_pucch_format_t format,
uint32_t n_pucch, // n_pucch_1 or n_pucch_2 depending on format
uint32_t sf_idx,
2017-03-28 00:13:24 -07:00
uint16_t rnti,
2016-10-18 01:39:49 -07:00
cf_t *sf_symbols,
cf_t *ce,
float noise_estimate,
uint8_t bits[SRSLTE_PUCCH_MAX_BITS],
uint32_t nof_bits);
2016-10-18 01:39:49 -07:00
SRSLTE_API float srslte_pucch_alpha_format1(uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CP_NORM_NSYMB],
srslte_pucch_cfg_t *cfg,
uint32_t n_pucch,
srslte_cp_t cp,
bool is_dmrs,
uint32_t ns,
uint32_t l,
uint32_t *n_oc,
uint32_t *n_prime_ns);
SRSLTE_API float srslte_pucch_alpha_format2(uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CP_NORM_NSYMB],
srslte_pucch_cfg_t *cfg,
uint32_t n_pucch,
uint32_t ns,
uint32_t l);
2015-04-15 01:06:40 -07:00
SRSLTE_API uint32_t srslte_pucch_m(srslte_pucch_cfg_t *cfg,
srslte_pucch_format_t format,
uint32_t n_pucch,
2015-04-15 01:06:40 -07:00
srslte_cp_t cp);
2016-10-20 08:49:51 -07:00
SRSLTE_API srslte_pucch_format_t srslte_pucch_get_format(srslte_uci_data_t *uci_data,
srslte_cp_t cp);
SRSLTE_API uint32_t srslte_pucch_get_npucch(uint32_t n_cce,
srslte_pucch_format_t format,
bool has_scheduling_request,
srslte_pucch_sched_t *pucch_sched);
2016-10-18 01:39:49 -07:00
SRSLTE_API uint32_t srslte_pucch_n_prb(srslte_pucch_cfg_t *cfg,
srslte_pucch_format_t format,
uint32_t n_pucch,
uint32_t nof_prb,
srslte_cp_t cp,
uint32_t ns);
2015-04-15 01:06:40 -07:00
SRSLTE_API int srslte_pucch_n_cs_cell(srslte_cell_t cell,
uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CP_NORM_NSYMB]);
2015-03-17 10:26:23 -07:00
SRSLTE_API int srslte_pucch_format2ab_mod_bits(srslte_pucch_format_t format,
uint8_t bits[2],
cf_t *d_10);
2015-03-17 10:26:23 -07:00
SRSLTE_API bool srslte_pucch_cfg_isvalid(srslte_pucch_cfg_t *cfg,
uint32_t nof_prb);
SRSLTE_API bool srslte_n_pucch_isvalid(srslte_pucch_t *q,
uint32_t n_pucch);
SRSLTE_API void srslte_pucch_cfg_default(srslte_pucch_cfg_t *cfg);
2015-03-17 10:26:23 -07:00
2018-03-31 10:04:04 -07:00
#endif // SRSLTE_PUCCH_H