Phy: added ue_ul normalization mode parameter

master
Xavier Arteaga 5 years ago committed by Ismael Gomez
parent 20823e191d
commit aa6652155c

@ -73,13 +73,18 @@ typedef struct SRSLTE_API {
srslte_refsignal_srs_cfg_t srs;
} srslte_ul_cfg_t;
typedef enum {
SRSLTE_UE_UL_NORMALIZE_MODE_AUTO = 0,
SRSLTE_UE_UL_NORMALIZE_MODE_FORCE_AMPLITUDE
} srslte_ue_ul_normalize_mode_t;
typedef struct SRSLTE_API {
srslte_ul_cfg_t ul_cfg;
bool grant_available;
uint32_t cc_idx;
bool normalize_en;
srslte_ue_ul_normalize_mode_t normalize_mode;
float force_peak_amplitude;
bool cfo_en;
float cfo_tol;

@ -249,25 +249,33 @@ static void apply_cfo(srslte_ue_ul_t* q, srslte_ue_ul_cfg_t* cfg)
static void apply_norm(srslte_ue_ul_t* q, srslte_ue_ul_cfg_t* cfg, float norm_factor)
{
uint32_t sf_len = SRSLTE_SF_LEN_PRB(q->cell.nof_prb);
float* buf = NULL;
float force_peak_amplitude = cfg->force_peak_amplitude > 0 ? cfg->force_peak_amplitude : 1.0f;
switch (cfg->normalize_mode) {
case SRSLTE_UE_UL_NORMALIZE_MODE_AUTO:
default:
// Automatic normalization (default)
norm_factor = limit_norm_factor(q, norm_factor, q->out_buffer);
srslte_vec_sc_prod_cfc(q->out_buffer, norm_factor, q->out_buffer, sf_len);
break;
case SRSLTE_UE_UL_NORMALIZE_MODE_FORCE_AMPLITUDE:
// Force amplitude
// Typecast buffer
buf = (float*)q->out_buffer;
if (cfg->normalize_en) {
norm_factor = limit_norm_factor(q, norm_factor, q->out_buffer);
srslte_vec_sc_prod_cfc(q->out_buffer, norm_factor, q->out_buffer, sf_len);
} else if (cfg->force_peak_amplitude > 0.0f) {
// Typecast buffer
float* buf = (float*)q->out_buffer;
// Get index of maximum absolute sample
uint32_t idx = srslte_vec_max_abs_fi(buf, sf_len * 2);
// Get index of maximum absolute sample
uint32_t idx = srslte_vec_max_abs_fi(buf, sf_len * 2);
// Get maximum value
float scale = fabsf(buf[idx]);
// Get maximum value
float scale = fabsf(buf[idx]);
// Avoid zero division
if (scale != 0.0f && scale != INFINITY) {
// Apply maximum peak amplitude
srslte_vec_sc_prod_cfc(q->out_buffer, cfg->force_peak_amplitude / scale, q->out_buffer, sf_len);
}
// Avoid zero division
if (scale != 0.0f && scale != INFINITY) {
// Apply maximum peak amplitude
srslte_vec_sc_prod_cfc(q->out_buffer, force_peak_amplitude / scale, q->out_buffer, sf_len);
}
break;
}
}

@ -180,9 +180,9 @@ void phy_common::set_ue_ul_cfg(srslte_ue_ul_cfg_t* ue_ul_cfg)
ue_ul_cfg->cfo_en = true;
if (args->force_ul_amplitude > 0.0f) {
ue_ul_cfg->force_peak_amplitude = args->force_ul_amplitude;
ue_ul_cfg->normalize_en = false;
ue_ul_cfg->normalize_mode = SRSLTE_UE_UL_NORMALIZE_MODE_FORCE_AMPLITUDE;
} else {
ue_ul_cfg->normalize_en = true;
ue_ul_cfg->normalize_mode = SRSLTE_UE_UL_NORMALIZE_MODE_AUTO;
}
ue_ul_cfg->ul_cfg.pucch.ack_nack_feedback_mode = SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL;
}

Loading…
Cancel
Save