|
|
|
@ -174,6 +174,17 @@ int srslte_pucch_nr_init(srslte_pucch_nr_t* q, const srslte_pucch_nr_args_t* arg
|
|
|
|
|
return SRSLTE_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int srslte_pucch_nr_set_carrier(srslte_pucch_nr_t* q, const srslte_carrier_nr_t* carrier)
|
|
|
|
|
{
|
|
|
|
|
if (q == NULL || carrier == NULL) {
|
|
|
|
|
return SRSLTE_ERROR_INVALID_INPUTS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
q->carrier = *carrier;
|
|
|
|
|
|
|
|
|
|
return SRSLTE_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void srslte_pucch_nr_free(srslte_pucch_nr_t* q)
|
|
|
|
|
{
|
|
|
|
|
if (q == NULL) {
|
|
|
|
@ -201,14 +212,13 @@ void srslte_pucch_nr_free(srslte_pucch_nr_t* q)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int srslte_pucch_nr_format0_encode(const srslte_pucch_nr_t* q,
|
|
|
|
|
const srslte_carrier_nr_t* carrier,
|
|
|
|
|
const srslte_pucch_nr_common_cfg_t* cfg,
|
|
|
|
|
const srslte_slot_cfg_t* slot,
|
|
|
|
|
srslte_pucch_nr_resource_t* resource,
|
|
|
|
|
uint32_t m_cs,
|
|
|
|
|
cf_t* slot_symbols)
|
|
|
|
|
{
|
|
|
|
|
if (carrier == NULL || cfg == NULL || slot == NULL || resource == NULL || slot_symbols == NULL) {
|
|
|
|
|
if (cfg == NULL || slot == NULL || resource == NULL || slot_symbols == NULL) {
|
|
|
|
|
return SRSLTE_ERROR_INVALID_INPUTS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -219,7 +229,7 @@ int srslte_pucch_nr_format0_encode(const srslte_pucch_nr_t* q,
|
|
|
|
|
|
|
|
|
|
uint32_t u = 0;
|
|
|
|
|
uint32_t v = 0;
|
|
|
|
|
if (srslte_pucch_nr_group_sequence(carrier, cfg, &u, &v) < SRSLTE_SUCCESS) {
|
|
|
|
|
if (srslte_pucch_nr_group_sequence(&q->carrier, cfg, &u, &v) < SRSLTE_SUCCESS) {
|
|
|
|
|
ERROR("Error getting group sequence");
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
@ -228,8 +238,8 @@ int srslte_pucch_nr_format0_encode(const srslte_pucch_nr_t* q,
|
|
|
|
|
for (uint32_t l = 0; l < resource->nof_symbols; l++) {
|
|
|
|
|
// Get Alpha index
|
|
|
|
|
uint32_t alpha_idx = 0;
|
|
|
|
|
if (srslte_pucch_nr_alpha_idx(carrier, cfg, slot, l, l_prime, resource->initial_cyclic_shift, m_cs, &alpha_idx) <
|
|
|
|
|
SRSLTE_SUCCESS) {
|
|
|
|
|
if (srslte_pucch_nr_alpha_idx(
|
|
|
|
|
&q->carrier, cfg, slot, l, l_prime, resource->initial_cyclic_shift, m_cs, &alpha_idx) < SRSLTE_SUCCESS) {
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -241,7 +251,7 @@ int srslte_pucch_nr_format0_encode(const srslte_pucch_nr_t* q,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get start of the sequence in resource grid
|
|
|
|
|
cf_t* slot_symbols_ptr = &slot_symbols[(carrier->nof_prb * (l + l_prime) + resource->starting_prb) * SRSLTE_NRE];
|
|
|
|
|
cf_t* slot_symbols_ptr = &slot_symbols[(q->carrier.nof_prb * (l + l_prime) + resource->starting_prb) * SRSLTE_NRE];
|
|
|
|
|
|
|
|
|
|
// Copy sequence in grid
|
|
|
|
|
srslte_vec_cf_copy(slot_symbols_ptr, r_uv, SRSLTE_NRE);
|
|
|
|
@ -251,7 +261,6 @@ int srslte_pucch_nr_format0_encode(const srslte_pucch_nr_t* q,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int srslte_pucch_nr_format0_measure(const srslte_pucch_nr_t* q,
|
|
|
|
|
const srslte_carrier_nr_t* carrier,
|
|
|
|
|
const srslte_pucch_nr_common_cfg_t* cfg,
|
|
|
|
|
const srslte_slot_cfg_t* slot,
|
|
|
|
|
srslte_pucch_nr_resource_t* resource,
|
|
|
|
@ -259,7 +268,7 @@ int srslte_pucch_nr_format0_measure(const srslte_pucch_nr_t* q,
|
|
|
|
|
const cf_t* slot_symbols,
|
|
|
|
|
srslte_pucch_nr_measure_t* measure)
|
|
|
|
|
{
|
|
|
|
|
if (carrier == NULL || cfg == NULL || slot == NULL || resource == NULL || slot_symbols == NULL || measure == NULL) {
|
|
|
|
|
if (cfg == NULL || slot == NULL || resource == NULL || slot_symbols == NULL || measure == NULL) {
|
|
|
|
|
return SRSLTE_ERROR_INVALID_INPUTS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -270,7 +279,7 @@ int srslte_pucch_nr_format0_measure(const srslte_pucch_nr_t* q,
|
|
|
|
|
|
|
|
|
|
uint32_t u = 0;
|
|
|
|
|
uint32_t v = 0;
|
|
|
|
|
if (srslte_pucch_nr_group_sequence(carrier, cfg, &u, &v) < SRSLTE_SUCCESS) {
|
|
|
|
|
if (srslte_pucch_nr_group_sequence(&q->carrier, cfg, &u, &v) < SRSLTE_SUCCESS) {
|
|
|
|
|
ERROR("Error getting group sequence");
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
@ -281,8 +290,8 @@ int srslte_pucch_nr_format0_measure(const srslte_pucch_nr_t* q,
|
|
|
|
|
for (uint32_t l = 0; l < resource->nof_symbols; l++) {
|
|
|
|
|
// Get Alpha index
|
|
|
|
|
uint32_t alpha_idx = 0;
|
|
|
|
|
if (srslte_pucch_nr_alpha_idx(carrier, cfg, slot, l, l_prime, resource->initial_cyclic_shift, m_cs, &alpha_idx) <
|
|
|
|
|
SRSLTE_SUCCESS) {
|
|
|
|
|
if (srslte_pucch_nr_alpha_idx(
|
|
|
|
|
&q->carrier, cfg, slot, l, l_prime, resource->initial_cyclic_shift, m_cs, &alpha_idx) < SRSLTE_SUCCESS) {
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -295,7 +304,7 @@ int srslte_pucch_nr_format0_measure(const srslte_pucch_nr_t* q,
|
|
|
|
|
|
|
|
|
|
// Get start of the sequence in resource grid
|
|
|
|
|
const cf_t* slot_symbols_ptr =
|
|
|
|
|
&slot_symbols[(carrier->nof_prb * (l + l_prime) + resource->starting_prb) * SRSLTE_NRE];
|
|
|
|
|
&slot_symbols[(q->carrier.nof_prb * (l + l_prime) + resource->starting_prb) * SRSLTE_NRE];
|
|
|
|
|
|
|
|
|
|
// Measure EPRE and average
|
|
|
|
|
epre += srslte_vec_avg_power_cf(slot_symbols_ptr, SRSLTE_NRE) / resource->nof_symbols;
|
|
|
|
@ -360,7 +369,6 @@ cf_t srslte_pucch_nr_format1_w(const srslte_pucch_nr_t* q, uint32_t n_pucch, uin
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int srslte_pucch_nr_format1_encode(const srslte_pucch_nr_t* q,
|
|
|
|
|
const srslte_carrier_nr_t* carrier,
|
|
|
|
|
const srslte_pucch_nr_common_cfg_t* cfg,
|
|
|
|
|
const srslte_slot_cfg_t* slot,
|
|
|
|
|
const srslte_pucch_nr_resource_t* resource,
|
|
|
|
@ -368,7 +376,7 @@ int srslte_pucch_nr_format1_encode(const srslte_pucch_nr_t* q,
|
|
|
|
|
uint32_t nof_bits,
|
|
|
|
|
cf_t* slot_symbols)
|
|
|
|
|
{
|
|
|
|
|
if (carrier == NULL || cfg == NULL || slot == NULL || resource == NULL || b == NULL || slot_symbols == NULL) {
|
|
|
|
|
if (q == NULL || cfg == NULL || slot == NULL || resource == NULL || b == NULL || slot_symbols == NULL) {
|
|
|
|
|
return SRSLTE_ERROR_INVALID_INPUTS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -393,7 +401,7 @@ int srslte_pucch_nr_format1_encode(const srslte_pucch_nr_t* q,
|
|
|
|
|
// Get group sequence
|
|
|
|
|
uint32_t u = 0;
|
|
|
|
|
uint32_t v = 0;
|
|
|
|
|
if (srslte_pucch_nr_group_sequence(carrier, cfg, &u, &v) < SRSLTE_SUCCESS) {
|
|
|
|
|
if (srslte_pucch_nr_group_sequence(&q->carrier, cfg, &u, &v) < SRSLTE_SUCCESS) {
|
|
|
|
|
ERROR("Error getting group sequence");
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
@ -404,11 +412,11 @@ int srslte_pucch_nr_format1_encode(const srslte_pucch_nr_t* q,
|
|
|
|
|
uint32_t l_prime = resource->start_symbol_idx;
|
|
|
|
|
for (uint32_t l = 1, m = 0; l < resource->nof_symbols; l += 2, m++) {
|
|
|
|
|
// Get start of the sequence in resource grid
|
|
|
|
|
cf_t* slot_symbols_ptr = &slot_symbols[(carrier->nof_prb * (l + l_prime) + resource->starting_prb) * SRSLTE_NRE];
|
|
|
|
|
cf_t* slot_symbols_ptr = &slot_symbols[(q->carrier.nof_prb * (l + l_prime) + resource->starting_prb) * SRSLTE_NRE];
|
|
|
|
|
|
|
|
|
|
// Get Alpha index
|
|
|
|
|
uint32_t alpha_idx = 0;
|
|
|
|
|
if (srslte_pucch_nr_alpha_idx(carrier, cfg, slot, l, l_prime, resource->initial_cyclic_shift, 0, &alpha_idx) <
|
|
|
|
|
if (srslte_pucch_nr_alpha_idx(&q->carrier, cfg, slot, l, l_prime, resource->initial_cyclic_shift, 0, &alpha_idx) <
|
|
|
|
|
SRSLTE_SUCCESS) {
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
@ -439,7 +447,6 @@ int srslte_pucch_nr_format1_encode(const srslte_pucch_nr_t* q,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int srslte_pucch_nr_format1_decode(srslte_pucch_nr_t* q,
|
|
|
|
|
const srslte_carrier_nr_t* carrier,
|
|
|
|
|
const srslte_pucch_nr_common_cfg_t* cfg,
|
|
|
|
|
const srslte_slot_cfg_t* slot,
|
|
|
|
|
const srslte_pucch_nr_resource_t* resource,
|
|
|
|
@ -450,6 +457,11 @@ int srslte_pucch_nr_format1_decode(srslte_pucch_nr_t* q,
|
|
|
|
|
{
|
|
|
|
|
uint32_t m_cs = 0;
|
|
|
|
|
|
|
|
|
|
if (q == NULL || cfg == NULL || slot == NULL || resource == NULL || chest_res == NULL || b == NULL ||
|
|
|
|
|
slot_symbols == NULL) {
|
|
|
|
|
return SRSLTE_ERROR_INVALID_INPUTS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) {
|
|
|
|
|
ERROR("Invalid PUCCH format 1 resource");
|
|
|
|
|
return SRSLTE_SUCCESS;
|
|
|
|
@ -466,7 +478,7 @@ int srslte_pucch_nr_format1_decode(srslte_pucch_nr_t* q,
|
|
|
|
|
// Get group sequence
|
|
|
|
|
uint32_t u = 0;
|
|
|
|
|
uint32_t v = 0;
|
|
|
|
|
if (srslte_pucch_nr_group_sequence(carrier, cfg, &u, &v) < SRSLTE_SUCCESS) {
|
|
|
|
|
if (srslte_pucch_nr_group_sequence(&q->carrier, cfg, &u, &v) < SRSLTE_SUCCESS) {
|
|
|
|
|
ERROR("Error getting group sequence");
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
@ -477,8 +489,8 @@ int srslte_pucch_nr_format1_decode(srslte_pucch_nr_t* q,
|
|
|
|
|
uint32_t l_prime = resource->start_symbol_idx;
|
|
|
|
|
for (uint32_t l = 1, m = 0; l < resource->nof_symbols; l += 2, m++) {
|
|
|
|
|
// Get start of the sequence in resource grid
|
|
|
|
|
cf_t* slot_symbols_ptr = &slot_symbols[(carrier->nof_prb * (l + l_prime) + resource->starting_prb) * SRSLTE_NRE];
|
|
|
|
|
cf_t* ce_ptr = &chest_res->ce[(carrier->nof_prb * (l + l_prime) + resource->starting_prb) * SRSLTE_NRE];
|
|
|
|
|
cf_t* slot_symbols_ptr = &slot_symbols[(q->carrier.nof_prb * (l + l_prime) + resource->starting_prb) * SRSLTE_NRE];
|
|
|
|
|
cf_t* ce_ptr = &chest_res->ce[(q->carrier.nof_prb * (l + l_prime) + resource->starting_prb) * SRSLTE_NRE];
|
|
|
|
|
|
|
|
|
|
// Equalise x = w(i) * d' * r_uv(n)
|
|
|
|
|
cf_t x[SRSLTE_NRE];
|
|
|
|
@ -486,8 +498,8 @@ int srslte_pucch_nr_format1_decode(srslte_pucch_nr_t* q,
|
|
|
|
|
|
|
|
|
|
// Get Alpha index
|
|
|
|
|
uint32_t alpha_idx = 0;
|
|
|
|
|
if (srslte_pucch_nr_alpha_idx(carrier, cfg, slot, l, l_prime, resource->initial_cyclic_shift, m_cs, &alpha_idx) <
|
|
|
|
|
SRSLTE_SUCCESS) {
|
|
|
|
|
if (srslte_pucch_nr_alpha_idx(
|
|
|
|
|
&q->carrier, cfg, slot, l, l_prime, resource->initial_cyclic_shift, m_cs, &alpha_idx) < SRSLTE_SUCCESS) {
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -630,7 +642,6 @@ static int pucch_nr_format2_decode(srslte_pucch_nr_t* q,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int srslte_pucch_nr_format_2_3_4_encode(srslte_pucch_nr_t* q,
|
|
|
|
|
const srslte_carrier_nr_t* carrier,
|
|
|
|
|
const srslte_pucch_nr_common_cfg_t* cfg,
|
|
|
|
|
const srslte_slot_cfg_t* slot,
|
|
|
|
|
const srslte_pucch_nr_resource_t* resource,
|
|
|
|
@ -639,8 +650,8 @@ int srslte_pucch_nr_format_2_3_4_encode(srslte_pucch_nr_t* q,
|
|
|
|
|
cf_t* slot_symbols)
|
|
|
|
|
{
|
|
|
|
|
// Validate input pointers
|
|
|
|
|
if (q == NULL || carrier == NULL || cfg == NULL || slot == NULL || resource == NULL || uci_cfg == NULL ||
|
|
|
|
|
uci_value == NULL || slot_symbols == NULL) {
|
|
|
|
|
if (q == NULL || cfg == NULL || slot == NULL || resource == NULL || uci_cfg == NULL || uci_value == NULL ||
|
|
|
|
|
slot_symbols == NULL) {
|
|
|
|
|
return SRSLTE_ERROR_INVALID_INPUTS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -653,7 +664,7 @@ int srslte_pucch_nr_format_2_3_4_encode(srslte_pucch_nr_t* q,
|
|
|
|
|
// Modulate PUCCH
|
|
|
|
|
switch (resource->format) {
|
|
|
|
|
case SRSLTE_PUCCH_NR_FORMAT_2:
|
|
|
|
|
return pucch_nr_format2_encode(q, carrier, cfg, resource, uci_cfg, slot_symbols);
|
|
|
|
|
return pucch_nr_format2_encode(q, &q->carrier, cfg, resource, uci_cfg, slot_symbols);
|
|
|
|
|
case SRSLTE_PUCCH_NR_FORMAT_3:
|
|
|
|
|
case SRSLTE_PUCCH_NR_FORMAT_4:
|
|
|
|
|
ERROR("Not implemented");
|
|
|
|
@ -667,7 +678,6 @@ int srslte_pucch_nr_format_2_3_4_encode(srslte_pucch_nr_t* q,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int srslte_pucch_nr_format_2_3_4_decode(srslte_pucch_nr_t* q,
|
|
|
|
|
const srslte_carrier_nr_t* carrier,
|
|
|
|
|
const srslte_pucch_nr_common_cfg_t* cfg,
|
|
|
|
|
const srslte_slot_cfg_t* slot,
|
|
|
|
|
const srslte_pucch_nr_resource_t* resource,
|
|
|
|
@ -677,8 +687,8 @@ int srslte_pucch_nr_format_2_3_4_decode(srslte_pucch_nr_t* q,
|
|
|
|
|
srslte_uci_value_nr_t* uci_value)
|
|
|
|
|
{
|
|
|
|
|
// Validate input pointers
|
|
|
|
|
if (q == NULL || carrier == NULL || cfg == NULL || slot == NULL || resource == NULL || uci_cfg == NULL ||
|
|
|
|
|
chest_res == NULL || uci_value == NULL || slot_symbols == NULL) {
|
|
|
|
|
if (q == NULL || cfg == NULL || slot == NULL || resource == NULL || uci_cfg == NULL || chest_res == NULL ||
|
|
|
|
|
uci_value == NULL || slot_symbols == NULL) {
|
|
|
|
|
return SRSLTE_ERROR_INVALID_INPUTS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -686,7 +696,8 @@ int srslte_pucch_nr_format_2_3_4_decode(srslte_pucch_nr_t* q,
|
|
|
|
|
int8_t* llr = (int8_t*)q->b;
|
|
|
|
|
switch (resource->format) {
|
|
|
|
|
case SRSLTE_PUCCH_NR_FORMAT_2:
|
|
|
|
|
if (pucch_nr_format2_decode(q, carrier, cfg, resource, uci_cfg, chest_res, slot_symbols, llr) < SRSLTE_SUCCESS) {
|
|
|
|
|
if (pucch_nr_format2_decode(q, &q->carrier, cfg, resource, uci_cfg, chest_res, slot_symbols, llr) <
|
|
|
|
|
SRSLTE_SUCCESS) {
|
|
|
|
|
ERROR("Demodulating PUCCH format 2");
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
|