Port lib/phy to srslog (#2298)

* - Ported the channel class to srslog.
- Removed all newlines of log messages in lib/phy.

* Remove more newlines that use the C debug macros.
master
faluco 4 years ago committed by GitHub
parent 7ac0c3a8e0
commit 9d15a44c73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -60,14 +60,14 @@ public:
uint32_t rlf_t_off_ms = 2000; uint32_t rlf_t_off_ms = 2000;
} args_t; } args_t;
channel(const args_t& channel_args, uint32_t _nof_channels); channel(const args_t& channel_args, uint32_t _nof_channels, srslog::basic_logger& logger);
~channel(); ~channel();
void set_logger(log_filter* _log_h);
void set_srate(uint32_t srate); void set_srate(uint32_t srate);
void set_signal_power_dBfs(float power_dBfs); void set_signal_power_dBfs(float power_dBfs);
void run(cf_t* in[SRSLTE_MAX_CHANNELS], cf_t* out[SRSLTE_MAX_CHANNELS], uint32_t len, const srslte_timestamp_t& t); void run(cf_t* in[SRSLTE_MAX_CHANNELS], cf_t* out[SRSLTE_MAX_CHANNELS], uint32_t len, const srslte_timestamp_t& t);
private: private:
srslog::basic_logger& logger;
float hst_init_phase = 0.0f; float hst_init_phase = 0.0f;
srslte_channel_fading_t* fading[SRSLTE_MAX_CHANNELS] = {}; srslte_channel_fading_t* fading[SRSLTE_MAX_CHANNELS] = {};
srslte_channel_delay_t* delay[SRSLTE_MAX_CHANNELS] = {}; srslte_channel_delay_t* delay[SRSLTE_MAX_CHANNELS] = {};
@ -76,7 +76,6 @@ private:
srslte_channel_rlf_t* rlf = nullptr; srslte_channel_rlf_t* rlf = nullptr;
cf_t* buffer_in = nullptr; cf_t* buffer_in = nullptr;
cf_t* buffer_out = nullptr; cf_t* buffer_out = nullptr;
log_filter* log_h = nullptr;
uint32_t nof_channels = 0; uint32_t nof_channels = 0;
uint32_t current_srate = 0; uint32_t current_srate = 0;
args_t args = {}; args_t args = {};

@ -351,7 +351,7 @@ static inline const uint16_t* get_mother_code(uint8_t n)
return mother_code_10; return mother_code_10;
break; break;
default: default:
ERROR("Wrong code_size_log\n"); ERROR("Wrong code_size_log");
return NULL; return NULL;
} }
} }
@ -381,7 +381,7 @@ static inline const uint16_t* get_blk_interleaver(uint8_t n)
return blk_interleaver_10; return blk_interleaver_10;
break; break;
default: default:
ERROR("Wrong code_size_log (%d)\n", n); ERROR("Wrong code_size_log (%d)", n);
return NULL; return NULL;
} }
} }

@ -130,7 +130,7 @@ void MAKE_CALL(run_tdec_iteration)(srslte_tdec_t* h, llr_t* input)
h->n_iter++; h->n_iter++;
} else { } else {
ERROR("Error CB index not set (call srslte_tdec_new_cb() first\n"); ERROR("Error CB index not set (call srslte_tdec_new_cb() first");
} }
} }

@ -174,7 +174,7 @@ static inline void srslte_evm_buffer_resize(srslte_evm_buffer_t* q, uint32_t new
\ \
/* Return NAN if EVM buffers, modem table, LLR, symbols or bits missing*/ \ /* Return NAN if EVM buffers, modem table, LLR, symbols or bits missing*/ \
if (!q || !modem_table || !modem_table->nbits_x_symbol || !llr || !symbols || !nof_bits) { \ if (!q || !modem_table || !modem_table->nbits_x_symbol || !llr || !symbols || !nof_bits) { \
ERROR("Invalid inputs %p %p %p %p %d\n", q, modem_table, llr, symbols, nof_bits); \ ERROR("Invalid inputs %p %p %p %p %d", q, modem_table, llr, symbols, nof_bits); \
return evm_rms; \ return evm_rms; \
} \ } \
\ \

@ -48,7 +48,7 @@ SRSLTE_API extern int handler_registered;
#define DEBUG(_fmt, ...) \ #define DEBUG(_fmt, ...) \
do { \ do { \
if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) { \ if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) { \
fprintf(stdout, "[DEBUG]: " _fmt, ##__VA_ARGS__); \ fprintf(stdout, "[DEBUG]: " _fmt "\n", ##__VA_ARGS__); \
} else { \ } else { \
srslte_phy_log_print(LOG_LEVEL_DEBUG_S, _fmt, ##__VA_ARGS__); \ srslte_phy_log_print(LOG_LEVEL_DEBUG_S, _fmt, ##__VA_ARGS__); \
} \ } \
@ -57,7 +57,7 @@ SRSLTE_API extern int handler_registered;
#define INFO(_fmt, ...) \ #define INFO(_fmt, ...) \
do { \ do { \
if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { \ if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { \
fprintf(stdout, "[INFO]: " _fmt, ##__VA_ARGS__); \ fprintf(stdout, "[INFO]: " _fmt "\n", ##__VA_ARGS__); \
} else { \ } else { \
srslte_phy_log_print(LOG_LEVEL_INFO_S, _fmt, ##__VA_ARGS__); \ srslte_phy_log_print(LOG_LEVEL_INFO_S, _fmt, ##__VA_ARGS__); \
} \ } \

@ -97,13 +97,13 @@ static inline void agc_enter_state_hold(srslte_agc_t* q)
float gain_db = q->gain_db + q->gain_offset_db; float gain_db = q->gain_db + q->gain_offset_db;
if (gain_db < q->min_gain_db) { if (gain_db < q->min_gain_db) {
gain_db = q->min_gain_db; gain_db = q->min_gain_db;
INFO("Warning: Rx signal strength is too high. Forcing minimum Rx gain %.2fdB\n", gain_db); INFO("Warning: Rx signal strength is too high. Forcing minimum Rx gain %.2fdB", gain_db);
} else if (gain_db > q->max_gain_db) { } else if (gain_db > q->max_gain_db) {
gain_db = q->max_gain_db; gain_db = q->max_gain_db;
INFO("Warning: Rx signal strength is too weak. Forcing maximum Rx gain %.2fdB\n", gain_db); INFO("Warning: Rx signal strength is too weak. Forcing maximum Rx gain %.2fdB", gain_db);
} else if (isinf(gain_db) || isnan(gain_db)) { } else if (isinf(gain_db) || isnan(gain_db)) {
gain_db = q->default_gain_db; gain_db = q->default_gain_db;
INFO("Warning: AGC went to an unknown state. Setting Rx gain to %.2fdB\n", gain_db); INFO("Warning: AGC went to an unknown state. Setting Rx gain to %.2fdB", gain_db);
} }
// Set gain // Set gain
@ -132,7 +132,6 @@ static inline void agc_run_state_init(srslte_agc_t* q)
static inline void agc_run_state_measure(srslte_agc_t* q, cf_t* signal, uint32_t len) static inline void agc_run_state_measure(srslte_agc_t* q, cf_t* signal, uint32_t len)
{ {
// Perform measurement of the frame // Perform measurement of the frame
float y = 0; float y = 0;
float* t; float* t;
@ -145,7 +144,7 @@ static inline void agc_run_state_measure(srslte_agc_t* q, cf_t* signal, uint32_t
y = t[srslte_vec_max_fi(t, 2 * len)]; // take only positive max to avoid abs() (should be similar) y = t[srslte_vec_max_fi(t, 2 * len)]; // take only positive max to avoid abs() (should be similar)
break; break;
default: default:
ERROR("Unsupported AGC mode\n"); ERROR("Unsupported AGC mode");
return; return;
} }
@ -162,7 +161,7 @@ static inline void agc_run_state_measure(srslte_agc_t* q, cf_t* signal, uint32_t
y = q->y_tmp[srslte_vec_max_fi(q->y_tmp, q->nof_frames)]; y = q->y_tmp[srslte_vec_max_fi(q->y_tmp, q->nof_frames)];
break; break;
default: default:
ERROR("Unsupported AGC mode\n"); ERROR("Unsupported AGC mode");
return; return;
} }
} }
@ -177,7 +176,7 @@ static inline void agc_run_state_measure(srslte_agc_t* q, cf_t* signal, uint32_t
if (q->frame_cnt == 0) { if (q->frame_cnt == 0) {
q->y_out = SRSLTE_VEC_EMA(y, q->y_out, q->bandwidth); q->y_out = SRSLTE_VEC_EMA(y, q->y_out, q->bandwidth);
q->gain_offset_db = srslte_convert_amplitude_to_dB(q->target) - srslte_convert_amplitude_to_dB(q->y_out); q->gain_offset_db = srslte_convert_amplitude_to_dB(q->target) - srslte_convert_amplitude_to_dB(q->y_out);
INFO("AGC gain offset: %.2f y_out=%.3f, y=%.3f target=%.1f\n", q->gain_offset_db, q->y_out, y, q->target); INFO("AGC gain offset: %.2f y_out=%.3f, y=%.3f target=%.1f", q->gain_offset_db, q->y_out, y, q->target);
} }
} }

@ -29,7 +29,6 @@
#ifdef DEFAULT_FILTER_LEN #ifdef DEFAULT_FILTER_LEN
static void set_default_filter(srslte_chest_dl_t* q, int filter_len) static void set_default_filter(srslte_chest_dl_t* q, int filter_len)
{ {
float fil[SRSLTE_CHEST_DL_MAX_SMOOTH_FIL_LEN]; float fil[SRSLTE_CHEST_DL_MAX_SMOOTH_FIL_LEN];
for (int i = 0; i < filter_len / 2; i++) { for (int i = 0; i < filter_len / 2; i++) {
@ -66,13 +65,13 @@ int srslte_chest_dl_init(srslte_chest_dl_t* q, uint32_t max_prb, uint32_t nof_rx
ret = srslte_refsignal_cs_init(&q->csr_refs, max_prb); ret = srslte_refsignal_cs_init(&q->csr_refs, max_prb);
if (ret != SRSLTE_SUCCESS) { if (ret != SRSLTE_SUCCESS) {
ERROR("Error initializing CSR signal (%d)\n", ret); ERROR("Error initializing CSR signal (%d)", ret);
goto clean_exit; goto clean_exit;
} }
q->mbsfn_refs = calloc(SRSLTE_MAX_MBSFN_AREA_IDS, sizeof(srslte_refsignal_t*)); q->mbsfn_refs = calloc(SRSLTE_MAX_MBSFN_AREA_IDS, sizeof(srslte_refsignal_t*));
if (!q->mbsfn_refs) { if (!q->mbsfn_refs) {
ERROR("Calloc error initializing mbsfn_refs (%d)\n", ret); ERROR("Calloc error initializing mbsfn_refs (%d)", ret);
goto clean_exit; goto clean_exit;
} }
@ -114,22 +113,22 @@ int srslte_chest_dl_init(srslte_chest_dl_t* q, uint32_t max_prb, uint32_t nof_rx
} }
if (srslte_interp_linear_vector_init(&q->srslte_interp_linvec, SRSLTE_NRE * max_prb)) { if (srslte_interp_linear_vector_init(&q->srslte_interp_linvec, SRSLTE_NRE * max_prb)) {
ERROR("Error initializing vector interpolator\n"); ERROR("Error initializing vector interpolator");
goto clean_exit; goto clean_exit;
} }
if (srslte_interp_linear_init(&q->srslte_interp_lin, 2 * max_prb, SRSLTE_NRE / 2)) { if (srslte_interp_linear_init(&q->srslte_interp_lin, 2 * max_prb, SRSLTE_NRE / 2)) {
ERROR("Error initializing interpolator\n"); ERROR("Error initializing interpolator");
goto clean_exit; goto clean_exit;
} }
if (srslte_interp_linear_init(&q->srslte_interp_lin_3, 4 * max_prb, SRSLTE_NRE / 4)) { if (srslte_interp_linear_init(&q->srslte_interp_lin_3, 4 * max_prb, SRSLTE_NRE / 4)) {
ERROR("Error initializing interpolator\n"); ERROR("Error initializing interpolator");
goto clean_exit; goto clean_exit;
} }
if (srslte_interp_linear_init(&q->srslte_interp_lin_mbsfn, 6 * max_prb, SRSLTE_NRE / 6)) { if (srslte_interp_linear_init(&q->srslte_interp_lin_mbsfn, 6 * max_prb, SRSLTE_NRE / 6)) {
ERROR("Error initializing interpolator\n"); ERROR("Error initializing interpolator");
goto clean_exit; goto clean_exit;
} }
@ -137,7 +136,7 @@ int srslte_chest_dl_init(srslte_chest_dl_t* q, uint32_t max_prb, uint32_t nof_rx
if (q->wiener_dl) { if (q->wiener_dl) {
srslte_wiener_dl_init(q->wiener_dl, max_prb, 2, nof_rx_antennas); srslte_wiener_dl_init(q->wiener_dl, max_prb, 2, nof_rx_antennas);
} else { } else {
ERROR("Error allocating wiener filter\n"); ERROR("Error allocating wiener filter");
goto clean_exit; goto clean_exit;
} }
@ -277,25 +276,25 @@ int srslte_chest_dl_set_cell(srslte_chest_dl_t* q, srslte_cell_t cell)
q->cell = cell; q->cell = cell;
ret = srslte_refsignal_cs_set_cell(&q->csr_refs, cell); ret = srslte_refsignal_cs_set_cell(&q->csr_refs, cell);
if (ret != SRSLTE_SUCCESS) { if (ret != SRSLTE_SUCCESS) {
ERROR("Error initializing CSR signal (%d)\n", ret); ERROR("Error initializing CSR signal (%d)", ret);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_pss_generate(q->pss_signal, cell.id % 3)) { if (srslte_pss_generate(q->pss_signal, cell.id % 3)) {
ERROR("Error initializing PSS signal for noise estimation\n"); ERROR("Error initializing PSS signal for noise estimation");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_interp_linear_vector_resize(&q->srslte_interp_linvec, SRSLTE_NRE * q->cell.nof_prb)) { if (srslte_interp_linear_vector_resize(&q->srslte_interp_linvec, SRSLTE_NRE * q->cell.nof_prb)) {
ERROR("Error initializing vector interpolator\n"); ERROR("Error initializing vector interpolator");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_interp_linear_resize(&q->srslte_interp_lin, 2 * q->cell.nof_prb, SRSLTE_NRE / 2)) { if (srslte_interp_linear_resize(&q->srslte_interp_lin, 2 * q->cell.nof_prb, SRSLTE_NRE / 2)) {
ERROR("Error initializing interpolator\n"); ERROR("Error initializing interpolator");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_interp_linear_resize(&q->srslte_interp_lin_3, 4 * q->cell.nof_prb, SRSLTE_NRE / 4)) { if (srslte_interp_linear_resize(&q->srslte_interp_lin_3, 4 * q->cell.nof_prb, SRSLTE_NRE / 4)) {
ERROR("Error initializing interpolator\n"); ERROR("Error initializing interpolator");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_interp_linear_resize(&q->srslte_interp_lin_mbsfn, 6 * q->cell.nof_prb, SRSLTE_NRE / 6)) { if (srslte_interp_linear_resize(&q->srslte_interp_lin_mbsfn, 6 * q->cell.nof_prb, SRSLTE_NRE / 6)) {
@ -622,7 +621,6 @@ static void chest_interpolate_noise_est(srslte_chest_dl_t* q,
uint32_t port_id, uint32_t port_id,
uint32_t rxant_id) uint32_t rxant_id)
{ {
float filter[SRSLTE_CHEST_MAX_SMOOTH_FIL_LEN]; float filter[SRSLTE_CHEST_MAX_SMOOTH_FIL_LEN];
uint32_t filter_len = 0; uint32_t filter_len = 0;
uint32_t sf_idx = sf->tti % 10; uint32_t sf_idx = sf->tti % 10;
@ -635,7 +633,7 @@ static void chest_interpolate_noise_est(srslte_chest_dl_t* q,
/* Estimate noise */ /* Estimate noise */
if (cfg->noise_alg == SRSLTE_NOISE_ALG_REFS) { if (cfg->noise_alg == SRSLTE_NOISE_ALG_REFS) {
if (ch_mode == SRSLTE_SF_MBSFN) { if (ch_mode == SRSLTE_SF_MBSFN) {
ERROR("Warning: REFS noise estimation algorithm not supported in MBSFN subframes\n"); ERROR("Warning: REFS noise estimation algorithm not supported in MBSFN subframes");
} }
q->noise_estimate[rxant_id][port_id] = estimate_noise_pilots(q, sf, port_id); q->noise_estimate[rxant_id][port_id] = estimate_noise_pilots(q, sf, port_id);
@ -674,11 +672,10 @@ static void chest_interpolate_noise_est(srslte_chest_dl_t* q,
} }
if (ce != NULL) { if (ce != NULL) {
switch (cfg->filter_type) { switch (cfg->filter_type) {
case SRSLTE_CHEST_FILTER_GAUSS: case SRSLTE_CHEST_FILTER_GAUSS:
if (ch_mode == SRSLTE_SF_MBSFN) { if (ch_mode == SRSLTE_SF_MBSFN) {
ERROR("Warning: Gauss filter not supported in MBSFN subframes\n"); ERROR("Warning: Gauss filter not supported in MBSFN subframes");
} }
if (cfg->filter_coef[0] <= 0) { if (cfg->filter_coef[0] <= 0) {
filter_len = srslte_chest_set_smooth_filter_gauss(filter, 4, q->noise_estimate[rxant_id][port_id] * 200.0f); filter_len = srslte_chest_set_smooth_filter_gauss(filter, 4, q->noise_estimate[rxant_id][port_id] * 200.0f);
@ -694,7 +691,7 @@ static void chest_interpolate_noise_est(srslte_chest_dl_t* q,
} }
if (cfg->estimator_alg != SRSLTE_ESTIMATOR_ALG_INTERPOLATE && ch_mode == SRSLTE_SF_MBSFN) { if (cfg->estimator_alg != SRSLTE_ESTIMATOR_ALG_INTERPOLATE && ch_mode == SRSLTE_SF_MBSFN) {
ERROR("Warning: Subframe interpolation must be enabled in MBSFN subframes\n"); ERROR("Warning: Subframe interpolation must be enabled in MBSFN subframes");
} }
/* Smooth estimates (if applicable) and interpolate */ /* Smooth estimates (if applicable) and interpolate */
@ -731,7 +728,6 @@ chest_dl_estimate_correct_sync_error(srslte_chest_dl_t* q, srslte_dl_sf_cfg_t* s
// For each cell port... // For each cell port...
for (uint32_t cell_port_id = 0; cell_port_id < q->cell.nof_ports; cell_port_id++) { for (uint32_t cell_port_id = 0; cell_port_id < q->cell.nof_ports; cell_port_id++) {
uint32_t npilots = srslte_refsignal_cs_nof_re(&q->csr_refs, sf, cell_port_id); uint32_t npilots = srslte_refsignal_cs_nof_re(&q->csr_refs, sf, cell_port_id);
uint32_t nsymb = srslte_refsignal_cs_nof_symbols(&q->csr_refs, sf, cell_port_id); uint32_t nsymb = srslte_refsignal_cs_nof_symbols(&q->csr_refs, sf, cell_port_id);
@ -823,7 +819,7 @@ static int estimate_port_mbsfn(srslte_chest_dl_t* q,
uint16_t mbsfn_area_id = cfg->mbsfn_area_id; uint16_t mbsfn_area_id = cfg->mbsfn_area_id;
if (!q->mbsfn_refs[mbsfn_area_id]) { if (!q->mbsfn_refs[mbsfn_area_id]) {
ERROR("Error in chest_dl: MBSFN area id=%d not initialized\n", cfg->mbsfn_area_id); ERROR("Error in chest_dl: MBSFN area id=%d not initialized", cfg->mbsfn_area_id);
} }
/* Use the known CSR signal to compute Least-squares estimates */ /* Use the known CSR signal to compute Least-squares estimates */
@ -984,7 +980,6 @@ int srslte_chest_dl_estimate_cfg(srslte_chest_dl_t* q,
cf_t* input[SRSLTE_MAX_PORTS], cf_t* input[SRSLTE_MAX_PORTS],
srslte_chest_dl_res_t* res) srslte_chest_dl_res_t* res)
{ {
for (uint32_t rxant_id = 0; rxant_id < q->nof_rx_antennas; rxant_id++) { for (uint32_t rxant_id = 0; rxant_id < q->nof_rx_antennas; rxant_id++) {
// Estimate and correct synchronization error if enabled // Estimate and correct synchronization error if enabled
if (cfg->sync_error_enable) { if (cfg->sync_error_enable) {

@ -169,13 +169,13 @@ static void interpolate_pilots(srslte_chest_dl_nbiot_t* q, cf_t* pilot_estimates
cf_t ce_avg[2][num_ces]; cf_t ce_avg[2][num_ces];
// interpolate the symbols with references in the freq domain // interpolate the symbols with references in the freq domain
DEBUG("Interpolating %d pilots in %d symbols at port %d.\n", nsymbols * 2, nsymbols, port_id); DEBUG("Interpolating %d pilots in %d symbols at port %d.", nsymbols * 2, nsymbols, port_id);
for (int l = 0; l < nsymbols; l++) { for (int l = 0; l < nsymbols; l++) {
uint32_t fidx_offset = srslte_refsignal_dl_nbiot_fidx(q->cell, l, port_id, 0); uint32_t fidx_offset = srslte_refsignal_dl_nbiot_fidx(q->cell, l, port_id, 0);
// points to the RE of the beginning of the l'th symbol containing a ref // points to the RE of the beginning of the l'th symbol containing a ref
uint32_t ce_idx = srslte_refsignal_nrs_nsymbol(l) * q->cell.base.nof_prb * SRSLTE_NRE; uint32_t ce_idx = srslte_refsignal_nrs_nsymbol(l) * q->cell.base.nof_prb * SRSLTE_NRE;
ce_idx += q->cell.nbiot_prb * SRSLTE_NRE; ce_idx += q->cell.nbiot_prb * SRSLTE_NRE;
DEBUG(" - freq.-dmn interp. in sym %d at RE %d\n", srslte_refsignal_nrs_nsymbol(l), ce_idx + fidx_offset); DEBUG(" - freq.-dmn interp. in sym %d at RE %d", srslte_refsignal_nrs_nsymbol(l), ce_idx + fidx_offset);
srslte_interp_linear_offset( srslte_interp_linear_offset(
&q->srslte_interp_lin, &pilot_estimates[2 * l], &ce[ce_idx], fidx_offset, SRSLTE_NRE / 2 - fidx_offset); &q->srslte_interp_lin, &pilot_estimates[2 * l], &ce[ce_idx], fidx_offset, SRSLTE_NRE / 2 - fidx_offset);
} }
@ -256,7 +256,7 @@ int srslte_chest_dl_nbiot_estimate_port(srslte_chest_dl_nbiot_t* q,
uint32_t sf_idx, uint32_t sf_idx,
uint32_t port_id) uint32_t port_id)
{ {
DEBUG("x.%d: Estimating DL channel on port %d.\n", sf_idx, port_id); DEBUG("x.%d: Estimating DL channel on port %d.", sf_idx, port_id);
int nref = srslte_refsignal_nbiot_cs_nof_re(&q->cell, port_id); int nref = srslte_refsignal_nbiot_cs_nof_re(&q->cell, port_id);
// Get references from the input signal // Get references from the input signal

@ -195,7 +195,7 @@ static void interpolate_pilots_sl_psbch(srslte_chest_sl_t* q)
// make sure l_idx is at least 2 to avoid accessing array at negative index below // make sure l_idx is at least 2 to avoid accessing array at negative index below
if (l_idx < 2) { if (l_idx < 2) {
ERROR("Couldn't interpolate PSBCH pilots. Invalid number of reference symbols.\n"); ERROR("Couldn't interpolate PSBCH pilots. Invalid number of reference symbols.");
return; return;
} }
@ -240,7 +240,6 @@ static void interpolate_pilots_sl_psbch(srslte_chest_sl_t* q)
static void chest_sl_psbch_ls_estimate(srslte_chest_sl_t* q, cf_t* sf_buffer) static void chest_sl_psbch_ls_estimate(srslte_chest_sl_t* q, cf_t* sf_buffer)
{ {
uint32_t dmrs_index = 0; uint32_t dmrs_index = 0;
uint32_t k = q->cell.nof_prb * SRSLTE_NRE / 2 - 36; uint32_t k = q->cell.nof_prb * SRSLTE_NRE / 2 - 36;
uint32_t sf_nsymbols = srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); uint32_t sf_nsymbols = srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp);
@ -387,7 +386,7 @@ static void interpolate_pilots_sl_pscch(srslte_chest_sl_t* q)
// make sure l_idx is at least 2 to avoid accessing array at negative index below // make sure l_idx is at least 2 to avoid accessing array at negative index below
if (l_idx < 2) { if (l_idx < 2) {
ERROR("Couldn't interpolate PSCCH pilots. Invalid number of reference symbols.\n"); ERROR("Couldn't interpolate PSCCH pilots. Invalid number of reference symbols.");
return; return;
} }
@ -545,7 +544,6 @@ static int chest_sl_pssch_put_dmrs(srslte_chest_sl_t* q, cf_t* sf_buffer)
// Mapping to physical resources // Mapping to physical resources
for (int i = 0; i < srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { for (int i = 0; i < srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) {
if (srslte_pssch_is_symbol(SRSLTE_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { if (srslte_pssch_is_symbol(SRSLTE_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) {
if (q->cell.tm == SRSLTE_SIDELINK_TM1 || q->cell.tm == SRSLTE_SIDELINK_TM2) { if (q->cell.tm == SRSLTE_SIDELINK_TM1 || q->cell.tm == SRSLTE_SIDELINK_TM2) {
if (q->chest_sl_cfg.nof_prb <= q->sl_comm_resource_pool.prb_num) { if (q->chest_sl_cfg.nof_prb <= q->sl_comm_resource_pool.prb_num) {
memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE],
@ -588,7 +586,6 @@ static int chest_sl_pssch_get_dmrs(srslte_chest_sl_t* q, cf_t* sf_buffer, cf_t**
// Mapping to physical resources // Mapping to physical resources
for (int i = 0; i < srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { for (int i = 0; i < srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) {
if (srslte_pssch_is_symbol(SRSLTE_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { if (srslte_pssch_is_symbol(SRSLTE_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) {
if (q->cell.tm == SRSLTE_SIDELINK_TM1 || q->cell.tm == SRSLTE_SIDELINK_TM2) { if (q->cell.tm == SRSLTE_SIDELINK_TM1 || q->cell.tm == SRSLTE_SIDELINK_TM2) {
if (q->chest_sl_cfg.nof_prb <= q->sl_comm_resource_pool.prb_num) { if (q->chest_sl_cfg.nof_prb <= q->sl_comm_resource_pool.prb_num) {
memcpy(dmrs_received[dmrs_idx], memcpy(dmrs_received[dmrs_idx],
@ -643,7 +640,7 @@ static void interpolate_pilots_sl_pssch(srslte_chest_sl_t* q)
// make sure l_idx is at least 2 to avoid accessing array at negative index below // make sure l_idx is at least 2 to avoid accessing array at negative index below
if (l_idx < 2) { if (l_idx < 2) {
ERROR("Couldn't interpolate PSSCH pilots. Invalid number of reference symbols.\n"); ERROR("Couldn't interpolate PSSCH pilots. Invalid number of reference symbols.");
return; return;
} }
@ -652,9 +649,7 @@ static void interpolate_pilots_sl_pssch(srslte_chest_sl_t* q)
} }
if (q->cell.tm == SRSLTE_SIDELINK_TM1 || q->cell.tm == SRSLTE_SIDELINK_TM2) { if (q->cell.tm == SRSLTE_SIDELINK_TM1 || q->cell.tm == SRSLTE_SIDELINK_TM2) {
if (q->chest_sl_cfg.nof_prb <= q->sl_comm_resource_pool.prb_num) { if (q->chest_sl_cfg.nof_prb <= q->sl_comm_resource_pool.prb_num) {
k = q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE; k = q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE;
srslte_interp_linear_vector3(&q->lin_vec_sl, srslte_interp_linear_vector3(&q->lin_vec_sl,
@ -690,7 +685,6 @@ static void interpolate_pilots_sl_pssch(srslte_chest_sl_t* q)
q->chest_sl_cfg.nof_prb * SRSLTE_NRE); q->chest_sl_cfg.nof_prb * SRSLTE_NRE);
} else { } else {
// First band // First band
k = q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE; k = q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE;
@ -768,7 +762,6 @@ static void interpolate_pilots_sl_pssch(srslte_chest_sl_t* q)
} }
} else if (q->cell.tm == SRSLTE_SIDELINK_TM3 || q->cell.tm == SRSLTE_SIDELINK_TM4) { } else if (q->cell.tm == SRSLTE_SIDELINK_TM3 || q->cell.tm == SRSLTE_SIDELINK_TM4) {
k = q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE; k = q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE;
srslte_interp_linear_vector3(&q->lin_vec_sl, srslte_interp_linear_vector3(&q->lin_vec_sl,
@ -813,7 +806,6 @@ static void chest_sl_pssch_ls_estimate(srslte_chest_sl_t* q, cf_t* sf_buffer)
srslte_vec_cf_zero(q->ce, q->sf_n_re); srslte_vec_cf_zero(q->ce, q->sf_n_re);
for (int i = 0; i < srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { for (int i = 0; i < srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) {
if (srslte_pssch_is_symbol(SRSLTE_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { if (srslte_pssch_is_symbol(SRSLTE_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) {
if (q->cell.tm == SRSLTE_SIDELINK_TM1 || q->cell.tm == SRSLTE_SIDELINK_TM2) { if (q->cell.tm == SRSLTE_SIDELINK_TM1 || q->cell.tm == SRSLTE_SIDELINK_TM2) {
if (q->chest_sl_cfg.nof_prb <= q->sl_comm_resource_pool.prb_num) { if (q->chest_sl_cfg.nof_prb <= q->sl_comm_resource_pool.prb_num) {
srslte_vec_prod_conj_ccc(&sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], srslte_vec_prod_conj_ccc(&sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE],
@ -886,7 +878,7 @@ float srslte_chest_sl_estimate_noise(srslte_chest_sl_t* q)
{ {
uint32_t sf_nsymbols = srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); uint32_t sf_nsymbols = srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp);
if (sf_nsymbols == 0) { if (sf_nsymbols == 0) {
ERROR("Error estimating channel noise. Invalid number of OFDM symbols.\n"); ERROR("Error estimating channel noise. Invalid number of OFDM symbols.");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }

@ -76,7 +76,7 @@ int srslte_chest_ul_init(srslte_chest_ul_t* q, uint32_t max_prb)
} }
if (srslte_interp_linear_vector_init(&q->srslte_interp_linvec, MAX_REFS_SYM)) { if (srslte_interp_linear_vector_init(&q->srslte_interp_linvec, MAX_REFS_SYM)) {
ERROR("Error initializing vector interpolator\n"); ERROR("Error initializing vector interpolator");
goto clean_exit; goto clean_exit;
} }
@ -86,7 +86,7 @@ int srslte_chest_ul_init(srslte_chest_ul_t* q, uint32_t max_prb)
q->dmrs_signal_configured = false; q->dmrs_signal_configured = false;
if (srslte_refsignal_dmrs_pusch_pregen_init(&q->dmrs_pregen, max_prb)) { if (srslte_refsignal_dmrs_pusch_pregen_init(&q->dmrs_pregen, max_prb)) {
ERROR("Error allocating memory for pregenerated signals\n"); ERROR("Error allocating memory for pregenerated signals");
goto clean_exit; goto clean_exit;
} }
} }
@ -160,12 +160,12 @@ int srslte_chest_ul_set_cell(srslte_chest_ul_t* q, srslte_cell_t cell)
q->cell = cell; q->cell = cell;
ret = srslte_refsignal_ul_set_cell(&q->dmrs_signal, cell); ret = srslte_refsignal_ul_set_cell(&q->dmrs_signal, cell);
if (ret != SRSLTE_SUCCESS) { if (ret != SRSLTE_SUCCESS) {
ERROR("Error initializing CSR signal (%d)\n", ret); ERROR("Error initializing CSR signal (%d)", ret);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_interp_linear_vector_resize(&q->srslte_interp_linvec, NOF_REFS_SYM)) { if (srslte_interp_linear_vector_resize(&q->srslte_interp_linvec, NOF_REFS_SYM)) {
ERROR("Error initializing vector interpolator\n"); ERROR("Error initializing vector interpolator");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -190,7 +190,6 @@ void srslte_chest_ul_pregen(srslte_chest_ul_t* q,
/* Uses the difference between the averaged and non-averaged pilot estimates */ /* Uses the difference between the averaged and non-averaged pilot estimates */
static float estimate_noise_pilots(srslte_chest_ul_t* q, cf_t* ce, uint32_t nslots, uint32_t nrefs, uint32_t n_prb[2]) static float estimate_noise_pilots(srslte_chest_ul_t* q, cf_t* ce, uint32_t nslots, uint32_t nrefs, uint32_t n_prb[2])
{ {
float power = 0; float power = 0;
for (int i = 0; i < nslots; i++) { for (int i = 0; i < nslots; i++) {
power += srslte_chest_estimate_noise_pilots( power += srslte_chest_estimate_noise_pilots(
@ -310,7 +309,7 @@ static void chest_ul_estimate(srslte_chest_ul_t* q,
// Check if intra-subframe frequency hopping is enabled // Check if intra-subframe frequency hopping is enabled
if (n_prb[0] != n_prb[1]) { if (n_prb[0] != n_prb[1]) {
ERROR("ERROR: intra-subframe frequency hopping not supported in the estimator!!\n"); ERROR("ERROR: intra-subframe frequency hopping not supported in the estimator!!");
} }
if (res->ce != NULL) { if (res->ce != NULL) {
@ -357,14 +356,14 @@ int srslte_chest_ul_estimate_pusch(srslte_chest_ul_t* q,
srslte_chest_ul_res_t* res) srslte_chest_ul_res_t* res)
{ {
if (!q->dmrs_signal_configured) { if (!q->dmrs_signal_configured) {
ERROR("Error must call srslte_chest_ul_set_cfg() before using the UL estimator\n"); ERROR("Error must call srslte_chest_ul_set_cfg() before using the UL estimator");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
uint32_t nof_prb = cfg->grant.L_prb; uint32_t nof_prb = cfg->grant.L_prb;
if (!srslte_dft_precoding_valid_prb(nof_prb)) { if (!srslte_dft_precoding_valid_prb(nof_prb)) {
ERROR("Error invalid nof_prb=%d\n", nof_prb); ERROR("Error invalid nof_prb=%d", nof_prb);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
@ -389,7 +388,6 @@ int srslte_chest_ul_estimate_pusch(srslte_chest_ul_t* q,
static float static float
estimate_noise_pilots_pucch(srslte_chest_ul_t* q, cf_t* ce, uint32_t n_rs, uint32_t n_prb[SRSLTE_NOF_SLOTS_PER_SF]) estimate_noise_pilots_pucch(srslte_chest_ul_t* q, cf_t* ce, uint32_t n_rs, uint32_t n_prb[SRSLTE_NOF_SLOTS_PER_SF])
{ {
float power = 0; float power = 0;
for (int ns = 0; ns < SRSLTE_NOF_SLOTS_PER_SF; ns++) { for (int ns = 0; ns < SRSLTE_NOF_SLOTS_PER_SF; ns++) {
for (int i = 0; i < n_rs; i++) { for (int i = 0; i < n_rs; i++) {
@ -422,7 +420,7 @@ int srslte_chest_ul_estimate_pucch(srslte_chest_ul_t* q,
{ {
int n_rs = srslte_refsignal_dmrs_N_rs(cfg->format, q->cell.cp); int n_rs = srslte_refsignal_dmrs_N_rs(cfg->format, q->cell.cp);
if (!n_rs) { if (!n_rs) {
ERROR("Error computing N_rs\n"); ERROR("Error computing N_rs");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
int nrefs_sf = SRSLTE_NRE * n_rs * SRSLTE_NOF_SLOTS_PER_SF; int nrefs_sf = SRSLTE_NRE * n_rs * SRSLTE_NOF_SLOTS_PER_SF;

@ -125,12 +125,12 @@ int srslte_dmrs_pdcch_put(const srslte_carrier_nr_t* carrier,
} }
if (coreset->mapping_type == srslte_coreset_mapping_type_interleaved) { if (coreset->mapping_type == srslte_coreset_mapping_type_interleaved) {
ERROR("Error interleaved CORESET mapping is not currently implemented\n"); ERROR("Error interleaved CORESET mapping is not currently implemented");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (coreset->duration < SRSLTE_CORESET_DURATION_MIN || coreset->duration > SRSLTE_CORESET_DURATION_MAX) { if (coreset->duration < SRSLTE_CORESET_DURATION_MIN || coreset->duration > SRSLTE_CORESET_DURATION_MAX) {
ERROR("Error CORESET duration %d is out-of-bounds (%d,%d)\n", ERROR("Error CORESET duration %d is out-of-bounds (%d,%d)",
coreset->duration, coreset->duration,
SRSLTE_CORESET_DURATION_MIN, SRSLTE_CORESET_DURATION_MIN,
SRSLTE_CORESET_DURATION_MAX); SRSLTE_CORESET_DURATION_MAX);
@ -150,7 +150,7 @@ int srslte_dmrs_pdcch_put(const srslte_carrier_nr_t* carrier,
// Get Cin // Get Cin
uint32_t cinit = dmrs_pdcch_get_cinit(slot_idx, l, n_id); uint32_t cinit = dmrs_pdcch_get_cinit(slot_idx, l, n_id);
DMRS_PDCCH_INFO_TX("n=%d; l=%d; cinit=%08x\n", slot_idx, l, cinit); DMRS_PDCCH_INFO_TX("n=%d; l=%d; cinit=%08x", slot_idx, l, cinit);
// Put data // Put data
dmrs_pdcch_put_symbol_noninterleaved( dmrs_pdcch_put_symbol_noninterleaved(
@ -169,7 +169,7 @@ int srslte_dmrs_pdcch_estimator_init(srslte_dmrs_pdcch_estimator_t* q,
} }
if (coreset->duration < SRSLTE_CORESET_DURATION_MIN || coreset->duration > SRSLTE_CORESET_DURATION_MAX) { if (coreset->duration < SRSLTE_CORESET_DURATION_MIN || coreset->duration > SRSLTE_CORESET_DURATION_MAX) {
ERROR("Error CORESET duration %d is out-of-bounds (%d,%d)\n", ERROR("Error CORESET duration %d is out-of-bounds (%d,%d)",
coreset->duration, coreset->duration,
SRSLTE_CORESET_DURATION_MIN, SRSLTE_CORESET_DURATION_MIN,
SRSLTE_CORESET_DURATION_MAX); SRSLTE_CORESET_DURATION_MAX);
@ -201,7 +201,7 @@ int srslte_dmrs_pdcch_estimator_init(srslte_dmrs_pdcch_estimator_t* q,
#else #else
if (srslte_interp_linear_init(&q->interpolator, coreset_bw * 3, 4)) { if (srslte_interp_linear_init(&q->interpolator, coreset_bw * 3, 4)) {
#endif #endif
ERROR("Initiating interpolator\n"); ERROR("Initiating interpolator");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -347,7 +347,7 @@ int srslte_dmrs_pdcch_estimate(srslte_dmrs_pdcch_estimator_t* q,
// Calculate PRN sequence initial state // Calculate PRN sequence initial state
uint32_t cinit = dmrs_pdcch_get_cinit(slot_idx, l, n_id); uint32_t cinit = dmrs_pdcch_get_cinit(slot_idx, l, n_id);
DMRS_PDCCH_INFO_RX("n=%d; l=%d; cinit=%08x\n", slot_idx, l, cinit); DMRS_PDCCH_INFO_RX("n=%d; l=%d; cinit=%08x", slot_idx, l, cinit);
// Extract pilots least square estimates // Extract pilots least square estimates
srslte_dmrs_pdcch_extract(q, cinit, &sf_symbols[l * q->carrier.nof_prb * SRSLTE_NRE], q->lse[l]); srslte_dmrs_pdcch_extract(q, cinit, &sf_symbols[l * q->carrier.nof_prb * SRSLTE_NRE], q->lse[l]);
@ -390,13 +390,13 @@ int srslte_dmrs_pdcch_get_measure(const srslte_dmrs_pdcch_estimator_t* q,
uint32_t L = 1U << dci_location->L; uint32_t L = 1U << dci_location->L;
if (q->coreset.mapping_type == srslte_coreset_mapping_type_interleaved) { if (q->coreset.mapping_type == srslte_coreset_mapping_type_interleaved) {
ERROR("Error interleaved mapping not implemented\n"); ERROR("Error interleaved mapping not implemented");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Check that CORESET duration is not less than minimum // Check that CORESET duration is not less than minimum
if (q->coreset.duration < SRSLTE_CORESET_DURATION_MIN) { if (q->coreset.duration < SRSLTE_CORESET_DURATION_MIN) {
ERROR("Invalid CORESET duration\n"); ERROR("Invalid CORESET duration");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -455,7 +455,7 @@ int srslte_dmrs_pdcch_get_measure(const srslte_dmrs_pdcch_estimator_t* q,
measure->norm_corr = 0.0f; measure->norm_corr = 0.0f;
} }
DMRS_PDCCH_INFO_RX("Measure L=%d; ncce=%d; RSRP=%+.1f dBfs; EPRE=%+.1f dBfs; Corr=%.3f\n", DMRS_PDCCH_INFO_RX("Measure L=%d; ncce=%d; RSRP=%+.1f dBfs; EPRE=%+.1f dBfs; Corr=%.3f",
dci_location->L, dci_location->L,
dci_location->ncce, dci_location->ncce,
measure->rsrp_dBfs, measure->rsrp_dBfs,
@ -475,13 +475,13 @@ int srslte_dmrs_pdcch_get_ce(const srslte_dmrs_pdcch_estimator_t* q,
uint32_t L = 1U << dci_location->L; uint32_t L = 1U << dci_location->L;
if (q->coreset.mapping_type == srslte_coreset_mapping_type_interleaved) { if (q->coreset.mapping_type == srslte_coreset_mapping_type_interleaved) {
ERROR("Error interleaved mapping not implemented\n"); ERROR("Error interleaved mapping not implemented");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Check that CORESET duration is not less than minimum // Check that CORESET duration is not less than minimum
if (q->coreset.duration < SRSLTE_CORESET_DURATION_MIN) { if (q->coreset.duration < SRSLTE_CORESET_DURATION_MIN) {
ERROR("Invalid CORESET duration\n"); ERROR("Invalid CORESET duration");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -502,7 +502,7 @@ int srslte_dmrs_pdcch_get_ce(const srslte_dmrs_pdcch_estimator_t* q,
// Double check extracted RE match ideal count // Double check extracted RE match ideal count
ce->nof_re = (SRSLTE_NRE - 3) * 6 * L; ce->nof_re = (SRSLTE_NRE - 3) * 6 * L;
if (count != ce->nof_re) { if (count != ce->nof_re) {
ERROR("Incorrect number of extracted resources (%d != %d)\n", count, ce->nof_re); ERROR("Incorrect number of extracted resources (%d != %d)", count, ce->nof_re);
} }
// At the moment Noise is not calculated // At the moment Noise is not calculated

@ -81,7 +81,7 @@ static uint32_t dmrs_pucch_format1_n_pucch(const srslte_pucch_nr_resource_t* res
} }
} }
ERROR("Invalid case nof_symbols=%d and m_prime=%d\n", resource->nof_symbols, m_prime); ERROR("Invalid case nof_symbols=%d and m_prime=%d", resource->nof_symbols, m_prime);
return 0; return 0;
} }
@ -97,7 +97,7 @@ int srslte_dmrs_pucch_format1_put(const srslte_pucch_nr_t* q,
} }
if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) { if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) {
ERROR("Invalid PUCCH format 1 resource\n"); ERROR("Invalid PUCCH format 1 resource");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -105,13 +105,13 @@ int srslte_dmrs_pucch_format1_put(const srslte_pucch_nr_t* q,
uint32_t u = 0; uint32_t u = 0;
uint32_t v = 0; uint32_t v = 0;
if (srslte_pucch_nr_group_sequence(carrier, cfg, &u, &v) < SRSLTE_SUCCESS) { if (srslte_pucch_nr_group_sequence(carrier, cfg, &u, &v) < SRSLTE_SUCCESS) {
ERROR("Error getting group sequence\n"); ERROR("Error getting group sequence");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
uint32_t n_pucch = dmrs_pucch_format1_n_pucch(resource, 0); uint32_t n_pucch = dmrs_pucch_format1_n_pucch(resource, 0);
if (n_pucch == 0) { if (n_pucch == 0) {
ERROR("Error getting number of symbols\n"); ERROR("Error getting number of symbols");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -127,13 +127,13 @@ int srslte_dmrs_pucch_format1_put(const srslte_pucch_nr_t* q,
uint32_t alpha_idx = 0; 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(carrier, cfg, slot, l, l_prime, resource->initial_cyclic_shift, 0, &alpha_idx) <
SRSLTE_SUCCESS) { SRSLTE_SUCCESS) {
ERROR("Calculating alpha\n"); ERROR("Calculating alpha");
} }
// get r_uv sequence from LUT object // get r_uv sequence from LUT object
const cf_t* r_uv = srslte_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx); const cf_t* r_uv = srslte_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx);
if (r_uv == NULL) { if (r_uv == NULL) {
ERROR("Getting r_uv sequence\n"); ERROR("Getting r_uv sequence");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -165,7 +165,7 @@ int srslte_dmrs_pucch_format1_estimate(const srslte_pucch_nr_t* q,
} }
if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) { if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) {
ERROR("Invalid PUCCH format 1 resource\n"); ERROR("Invalid PUCCH format 1 resource");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -173,13 +173,13 @@ int srslte_dmrs_pucch_format1_estimate(const srslte_pucch_nr_t* q,
uint32_t u = 0; uint32_t u = 0;
uint32_t v = 0; uint32_t v = 0;
if (srslte_pucch_nr_group_sequence(carrier, cfg, &u, &v) < SRSLTE_SUCCESS) { if (srslte_pucch_nr_group_sequence(carrier, cfg, &u, &v) < SRSLTE_SUCCESS) {
ERROR("Error getting group sequence\n"); ERROR("Error getting group sequence");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
uint32_t n_pucch = dmrs_pucch_format1_n_pucch(resource, 0); uint32_t n_pucch = dmrs_pucch_format1_n_pucch(resource, 0);
if (n_pucch == 0) { if (n_pucch == 0) {
ERROR("Error getting number of symbols\n"); ERROR("Error getting number of symbols");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -197,13 +197,13 @@ int srslte_dmrs_pucch_format1_estimate(const srslte_pucch_nr_t* q,
uint32_t alpha_idx = 0; 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(carrier, cfg, slot, l, l_prime, resource->initial_cyclic_shift, 0, &alpha_idx) <
SRSLTE_SUCCESS) { SRSLTE_SUCCESS) {
ERROR("Calculating alpha\n"); ERROR("Calculating alpha");
} }
// get r_uv sequence from LUT object // get r_uv sequence from LUT object
const cf_t* r_uv = srslte_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx); const cf_t* r_uv = srslte_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx);
if (r_uv == NULL) { if (r_uv == NULL) {
ERROR("Getting r_uv sequence\n"); ERROR("Getting r_uv sequence");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -307,7 +307,7 @@ int srslte_dmrs_pucch_format2_put(const srslte_pucch_nr_t* q,
} }
if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) { if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) {
ERROR("Invalid PUCCH format 1 resource\n"); ERROR("Invalid PUCCH format 1 resource");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -350,7 +350,7 @@ int srslte_dmrs_pucch_format2_estimate(const srslte_pucch_nr_t* q,
} }
if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) { if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) {
ERROR("Invalid PUCCH format 1 resource\n"); ERROR("Invalid PUCCH format 1 resource");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -521,7 +521,7 @@ int srslte_dmrs_pucch_format_3_4_get_symbol_idx(const srslte_pucch_nr_resource_t
} }
break; break;
default: default:
ERROR("Invalid case (%d)\n", resource->nof_symbols); ERROR("Invalid case (%d)", resource->nof_symbols);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }

@ -113,7 +113,7 @@ free_and_exit:
int srslte_refsignal_dl_nbiot_set_cell(srslte_refsignal_dl_nbiot_t* q, srslte_nbiot_cell_t cell) int srslte_refsignal_dl_nbiot_set_cell(srslte_refsignal_dl_nbiot_t* q, srslte_nbiot_cell_t cell)
{ {
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
INFO("Generating NRS for n_id_ncell=%d\n", cell.n_id_ncell); INFO("Generating NRS for n_id_ncell=%d", cell.n_id_ncell);
if (q != NULL && srslte_nbiot_cell_isvalid(&cell)) { if (q != NULL && srslte_nbiot_cell_isvalid(&cell)) {
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
@ -144,7 +144,7 @@ int srslte_refsignal_dl_nbiot_set_cell(srslte_refsignal_dl_nbiot_t* q, srslte_nb
/* save signal */ /* save signal */
int idx = int idx =
SRSLTE_NBIOT_REFSIGNAL_PILOT_IDX(i, (ns % 2) * nsymbols + l, SRSLTE_NBIOT_DEFAULT_NUM_PRB_BASECELL); SRSLTE_NBIOT_REFSIGNAL_PILOT_IDX(i, (ns % 2) * nsymbols + l, SRSLTE_NBIOT_DEFAULT_NUM_PRB_BASECELL);
DEBUG("Ref port=%d, lp=%d, ns=%d, ns/2=%d, idx=%d, i=%d, nsymbols=%d, l=%d\n", DEBUG("Ref port=%d, lp=%d, ns=%d, ns/2=%d, idx=%d, i=%d, nsymbols=%d, l=%d",
p, p,
lp, lp,
ns, ns,
@ -207,7 +207,7 @@ int srslte_refsignal_nrs_put_sf(srslte_nbiot_cell_t cell, uint32_t port_id, cf_t
uint32_t fidx = srslte_refsignal_dl_nbiot_fidx(cell, l, port_id, m) + cell.nbiot_prb * SRSLTE_NRE; uint32_t fidx = srslte_refsignal_dl_nbiot_fidx(cell, l, port_id, m) + cell.nbiot_prb * SRSLTE_NRE;
sf_symbols[SRSLTE_RE_IDX(cell.base.nof_prb, nsymbol, fidx)] = pilots[SRSLTE_NBIOT_REFSIGNAL_PILOT_IDX(m, l, 1)]; sf_symbols[SRSLTE_RE_IDX(cell.base.nof_prb, nsymbol, fidx)] = pilots[SRSLTE_NBIOT_REFSIGNAL_PILOT_IDX(m, l, 1)];
#if EXTRA_DEBUG #if EXTRA_DEBUG
DEBUG("port: %d, re_idx: %d, pilot_idx: %d, %+2.2f%+2.2fi\n", DEBUG("port: %d, re_idx: %d, pilot_idx: %d, %+2.2f%+2.2fi",
port_id, port_id,
SRSLTE_RE_IDX(cell.base.nof_prb, nsymbol, fidx), SRSLTE_RE_IDX(cell.base.nof_prb, nsymbol, fidx),
SRSLTE_NBIOT_REFSIGNAL_PILOT_IDX(i, l, 1), SRSLTE_NBIOT_REFSIGNAL_PILOT_IDX(i, l, 1),
@ -219,7 +219,7 @@ int srslte_refsignal_nrs_put_sf(srslte_nbiot_cell_t cell, uint32_t port_id, cf_t
#if EXTRA_DEBUG #if EXTRA_DEBUG
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE chest_nbiot_tx_after_mapping.bin: NRS after mapping\n", 0); DEBUG("SAVED FILE chest_nbiot_tx_after_mapping.bin: NRS after mapping", 0);
srslte_vec_save_file( srslte_vec_save_file(
"chest_nbiot_tx_after_mapping.bin", pilots, SRSLTE_REFSIGNAL_NUM_SF(1, port_id) * sizeof(cf_t)); "chest_nbiot_tx_after_mapping.bin", pilots, SRSLTE_REFSIGNAL_NUM_SF(1, port_id) * sizeof(cf_t));
} }
@ -241,7 +241,7 @@ int srslte_refsignal_nrs_get_sf(srslte_nbiot_cell_t cell, uint32_t port_id, cf_t
uint32_t fidx = srslte_refsignal_dl_nbiot_fidx(cell, l, port_id, m) + cell.nbiot_prb * SRSLTE_NRE; uint32_t fidx = srslte_refsignal_dl_nbiot_fidx(cell, l, port_id, m) + cell.nbiot_prb * SRSLTE_NRE;
pilots[SRSLTE_NBIOT_REFSIGNAL_PILOT_IDX(m, l, 1)] = sf_symbols[SRSLTE_RE_IDX(cell.base.nof_prb, nsymbol, fidx)]; pilots[SRSLTE_NBIOT_REFSIGNAL_PILOT_IDX(m, l, 1)] = sf_symbols[SRSLTE_RE_IDX(cell.base.nof_prb, nsymbol, fidx)];
#if EXTRA_DEBUG #if EXTRA_DEBUG
DEBUG("port: %d, pilot_idx: %d, re_idx: %d, %+2.2f%+2.2fi\n", DEBUG("port: %d, pilot_idx: %d, re_idx: %d, %+2.2f%+2.2fi",
port_id, port_id,
SRSLTE_NBIOT_REFSIGNAL_PILOT_IDX(m, l, 1), SRSLTE_NBIOT_REFSIGNAL_PILOT_IDX(m, l, 1),
SRSLTE_RE_IDX(cell.base.nof_prb, nsymbol, fidx), SRSLTE_RE_IDX(cell.base.nof_prb, nsymbol, fidx),
@ -253,7 +253,7 @@ int srslte_refsignal_nrs_get_sf(srslte_nbiot_cell_t cell, uint32_t port_id, cf_t
#if EXTRA_DEBUG #if EXTRA_DEBUG
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE chest_nbiot_rx_after_demapping.bin: NRS after demapping\n", 0); DEBUG("SAVED FILE chest_nbiot_rx_after_demapping.bin: NRS after demapping", 0);
srslte_vec_save_file( srslte_vec_save_file(
"chest_nbiot_rx_after_demapping.bin", pilots, SRSLTE_REFSIGNAL_NUM_SF(1, port_id) * sizeof(cf_t)); "chest_nbiot_rx_after_demapping.bin", pilots, SRSLTE_REFSIGNAL_NUM_SF(1, port_id) * sizeof(cf_t));
} }

@ -129,11 +129,9 @@ static int generate_srslte_sequence_hopping_v(srslte_refsignal_ul_t* q)
*/ */
int srslte_refsignal_ul_set_cell(srslte_refsignal_ul_t* q, srslte_cell_t cell) int srslte_refsignal_ul_set_cell(srslte_refsignal_ul_t* q, srslte_cell_t cell)
{ {
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL && srslte_cell_isvalid(&cell)) { if (q != NULL && srslte_cell_isvalid(&cell)) {
if (cell.id != q->cell.id || q->cell.nof_prb == 0) { if (cell.id != q->cell.id || q->cell.nof_prb == 0) {
q->cell = cell; q->cell = cell;
@ -188,7 +186,7 @@ void srslte_refsignal_dmrs_pusch_put(srslte_refsignal_ul_t* q,
cf_t* sf_symbols) cf_t* sf_symbols)
{ {
for (uint32_t ns_idx = 0; ns_idx < 2; ns_idx++) { for (uint32_t ns_idx = 0; ns_idx < 2; ns_idx++) {
INFO("Putting DMRS to n_prb: %d, L: %d, ns_idx: %d\n", INFO("Putting DMRS to n_prb: %d, L: %d, ns_idx: %d",
pusch_cfg->grant.n_prb_tilde[ns_idx], pusch_cfg->grant.n_prb_tilde[ns_idx],
pusch_cfg->grant.L_prb, pusch_cfg->grant.L_prb,
ns_idx); ns_idx);
@ -205,7 +203,7 @@ void srslte_refsignal_dmrs_pusch_get(srslte_refsignal_ul_t* q,
cf_t* r_pusch) cf_t* r_pusch)
{ {
for (uint32_t ns_idx = 0; ns_idx < 2; ns_idx++) { for (uint32_t ns_idx = 0; ns_idx < 2; ns_idx++) {
INFO("Getting DMRS from n_prb: %d, L: %d, ns_idx: %d\n", INFO("Getting DMRS from n_prb: %d, L: %d, ns_idx: %d",
pusch_cfg->grant.n_prb_tilde[ns_idx], pusch_cfg->grant.n_prb_tilde[ns_idx],
pusch_cfg->grant.L_prb, pusch_cfg->grant.L_prb,
ns_idx); ns_idx);
@ -334,7 +332,6 @@ int srslte_refsignal_dmrs_pusch_gen(srslte_refsignal_ul_t* q,
uint32_t cyclic_shift_for_dmrs, uint32_t cyclic_shift_for_dmrs,
cf_t* r_pusch) cf_t* r_pusch)
{ {
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (pusch_cfg_isvalid(q, cfg, nof_prb)) { if (pusch_cfg_isvalid(q, cfg, nof_prb)) {
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
@ -373,7 +370,7 @@ uint32_t srslte_refsignal_dmrs_N_rs(srslte_pucch_format_t format, srslte_cp_t cp
case SRSLTE_PUCCH_FORMAT_2B: case SRSLTE_PUCCH_FORMAT_2B:
return 2; return 2;
default: default:
ERROR("DMRS Nof RS: Unsupported format %d\n", format); ERROR("DMRS Nof RS: Unsupported format %d", format);
return 0; return 0;
} }
return 0; return 0;
@ -415,7 +412,7 @@ uint32_t srslte_refsignal_dmrs_pucch_symbol(uint32_t m, srslte_pucch_format_t fo
} }
break; break;
default: default:
ERROR("DMRS Symbol indexes: Unsupported format %d\n", format); ERROR("DMRS Symbol indexes: Unsupported format %d", format);
return 0; return 0;
} }
return 0; return 0;
@ -485,7 +482,7 @@ int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t* q,
w = w_arg_pucch_format2_cpnorm; w = w_arg_pucch_format2_cpnorm;
break; break;
default: default:
ERROR("DMRS Generator: Unsupported format %d\n", cfg->format); ERROR("DMRS Generator: Unsupported format %d", cfg->format);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -512,12 +509,10 @@ int srslte_refsignal_dmrs_pucch_cp(srslte_refsignal_ul_t* q,
{ {
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q && source && dest) { if (q && source && dest) {
uint32_t nsymbols = SRSLTE_CP_ISNORM(q->cell.cp) ? SRSLTE_CP_NORM_NSYMB : SRSLTE_CP_EXT_NSYMB; uint32_t nsymbols = SRSLTE_CP_ISNORM(q->cell.cp) ? SRSLTE_CP_NORM_NSYMB : SRSLTE_CP_EXT_NSYMB;
uint32_t N_rs = srslte_refsignal_dmrs_N_rs(cfg->format, q->cell.cp); uint32_t N_rs = srslte_refsignal_dmrs_N_rs(cfg->format, q->cell.cp);
for (uint32_t ns = 0; ns < 2; ns++) { for (uint32_t ns = 0; ns < 2; ns++) {
// Determine n_prb // Determine n_prb
uint32_t n_prb = srslte_pucch_n_prb(&q->cell, cfg, ns); uint32_t n_prb = srslte_pucch_n_prb(&q->cell, cfg, ns);
@ -799,7 +794,6 @@ static uint32_t srs_Fb(srslte_refsignal_srs_cfg_t* cfg, uint32_t b, uint32_t nof
/* Returns k0: frequency-domain starting position for ue-specific SRS */ /* Returns k0: frequency-domain starting position for ue-specific SRS */
static uint32_t srs_k0_ue(srslte_refsignal_srs_cfg_t* cfg, uint32_t nof_prb, uint32_t tti) static uint32_t srs_k0_ue(srslte_refsignal_srs_cfg_t* cfg, uint32_t nof_prb, uint32_t tti)
{ {
if (cfg->bw_cfg < 8 && cfg->B < 4 && cfg->k_tc < 2) { if (cfg->bw_cfg < 8 && cfg->B < 4 && cfg->k_tc < 2) {
uint32_t k0p = srslte_refsignal_srs_rb_start_cs(cfg->bw_cfg, nof_prb) * SRSLTE_NRE + cfg->k_tc; uint32_t k0p = srslte_refsignal_srs_rb_start_cs(cfg->bw_cfg, nof_prb) * SRSLTE_NRE + cfg->k_tc;
uint32_t k0 = k0p; uint32_t k0 = k0p;
@ -875,7 +869,6 @@ int srslte_refsignal_srs_gen(srslte_refsignal_ul_t* q,
uint32_t M_sc = srslte_refsignal_srs_M_sc(q, cfg); uint32_t M_sc = srslte_refsignal_srs_M_sc(q, cfg);
for (uint32_t ns = 2 * sf_idx; ns < 2 * (sf_idx + 1); ns++) { for (uint32_t ns = 2 * sf_idx; ns < 2 * (sf_idx + 1); ns++) {
float alpha = 2 * M_PI * cfg->n_srs / 8; float alpha = 2 * M_PI * cfg->n_srs / 8;
compute_r(q, pusch_cfg, M_sc / SRSLTE_NRE, ns, 0, alpha, &r_srs[(ns % 2) * M_sc]); compute_r(q, pusch_cfg, M_sc / SRSLTE_NRE, ns, 0, alpha, &r_srs[(ns % 2) * M_sc]);
} }

@ -128,7 +128,7 @@ int main(int argc, char** argv)
} }
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE chest_start.bin: channel estimates start\n"); DEBUG("SAVED FILE chest_start.bin: channel estimates start");
srslte_vec_save_file("chest_start.bin", ce, num_re * sizeof(cf_t)); srslte_vec_save_file("chest_start.bin", ce, num_re * sizeof(cf_t));
} }
@ -189,10 +189,10 @@ int main(int argc, char** argv)
float rsrp = srslte_chest_dl_nbiot_get_rsrp(&est); float rsrp = srslte_chest_dl_nbiot_get_rsrp(&est);
float noise = srslte_chest_dl_nbiot_get_noise_estimate(&est); float noise = srslte_chest_dl_nbiot_get_noise_estimate(&est);
float snr = srslte_chest_dl_nbiot_get_snr(&est); float snr = srslte_chest_dl_nbiot_get_snr(&est);
DEBUG("rsrq=%4.2f, rsrp=%4.2f, noise=%4.2f, snr=%4.2f\n", rsrq, rsrp, noise, snr); DEBUG("rsrq=%4.2f, rsrp=%4.2f, noise=%4.2f, snr=%4.2f", rsrq, rsrp, noise, snr);
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE chest_final.bin: channel after estimation\n"); DEBUG("SAVED FILE chest_final.bin: channel after estimation");
srslte_vec_save_file("chest_final.bin", ce, num_re * sizeof(cf_t)); srslte_vec_save_file("chest_final.bin", ce, num_re * sizeof(cf_t));
} }

@ -119,13 +119,13 @@ int main(int argc, char** argv)
max_cid = cell.id; max_cid = cell.id;
} }
if (srslte_chest_dl_init(&est, cell.nof_prb, 1)) { if (srslte_chest_dl_init(&est, cell.nof_prb, 1)) {
ERROR("Error initializing equalizer\n"); ERROR("Error initializing equalizer");
goto do_exit; goto do_exit;
} }
while (cid <= max_cid) { while (cid <= max_cid) {
cell.id = cid; cell.id = cid;
if (srslte_chest_dl_set_cell(&est, cell)) { if (srslte_chest_dl_set_cell(&est, cell)) {
ERROR("Error initializing equalizer\n"); ERROR("Error initializing equalizer");
goto do_exit; goto do_exit;
} }
@ -135,7 +135,6 @@ int main(int argc, char** argv)
sf_cfg.tti = sf_idx; sf_cfg.tti = sf_idx;
for (uint32_t n_port = 0; n_port < cell.nof_ports; n_port++) { for (uint32_t n_port = 0; n_port < cell.nof_ports; n_port++) {
srslte_vec_cf_zero(input, num_re); srslte_vec_cf_zero(input, num_re);
for (i = 0; i < num_re; i++) { for (i = 0; i < num_re; i++) {
input[i] = 0.5 - rand() / RAND_MAX + I * (0.5 - rand() / RAND_MAX); input[i] = 0.5 - rand() / RAND_MAX + I * (0.5 - rand() / RAND_MAX);
@ -218,7 +217,7 @@ int main(int argc, char** argv)
} }
} }
cid += 10; cid += 10;
INFO("cid=%d\n", cid); INFO("cid=%d", cid);
} }
srslte_chest_dl_free(&est); srslte_chest_dl_free(&est);
ret = 0; ret = 0;

@ -117,7 +117,7 @@ int srs_test_context_run(srs_test_context_t* q)
{ {
srslte_ul_sf_cfg_t ul_sf_cfg = {}; srslte_ul_sf_cfg_t ul_sf_cfg = {};
INFO(" TEST: bw_cfg=%d; sf_cfg=%d; B=%d; b_hops=%d; n_srs=%d; I_srs=%d;\n", INFO(" TEST: bw_cfg=%d; sf_cfg=%d; B=%d; b_hops=%d; n_srs=%d; I_srs=%d;",
srs_cfg.bw_cfg, srs_cfg.bw_cfg,
srs_cfg.subframe_config, srs_cfg.subframe_config,
srs_cfg.B, srs_cfg.B,
@ -147,7 +147,7 @@ int srs_test_context_run(srs_test_context_t* q)
&q->chest_ul, &ul_sf_cfg, &srs_cfg, &dmrs_pusch_cfg, q->sf_symbols, &q->chest_ul_res) == &q->chest_ul, &ul_sf_cfg, &srs_cfg, &dmrs_pusch_cfg, q->sf_symbols, &q->chest_ul_res) ==
SRSLTE_SUCCESS); SRSLTE_SUCCESS);
INFO("RESULTS: tti=%d; snr_db=%+.1f; noise_estimate_dbm=%+.1f; ta_us=%+.1f;\n", INFO("RESULTS: tti=%d; snr_db=%+.1f; noise_estimate_dbm=%+.1f; ta_us=%+.1f;",
ul_sf_cfg.tti, ul_sf_cfg.tti,
q->chest_ul_res.snr_db, q->chest_ul_res.snr_db,
q->chest_ul_res.noise_estimate_dbm, q->chest_ul_res.noise_estimate_dbm,
@ -187,7 +187,6 @@ void parse_args(int argc, char** argv)
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
srs_test_context_t context = {}; srs_test_context_t context = {};
int ret = SRSLTE_SUCCESS; int ret = SRSLTE_SUCCESS;

@ -118,13 +118,13 @@ int main(int argc, char** argv)
} }
printf("max_cid=%d, cid=%d, cell.id=%d\n", max_cid, cid, cell.id); printf("max_cid=%d, cid=%d, cell.id=%d\n", max_cid, cid, cell.id);
if (srslte_chest_ul_init(&est, cell.nof_prb)) { if (srslte_chest_ul_init(&est, cell.nof_prb)) {
ERROR("Error initializing equalizer\n"); ERROR("Error initializing equalizer");
goto do_exit; goto do_exit;
} }
while (cid <= max_cid) { while (cid <= max_cid) {
cell.id = cid; cell.id = cid;
if (srslte_chest_ul_set_cell(&est, cell)) { if (srslte_chest_ul_set_cell(&est, cell)) {
ERROR("Error initializing equalizer\n"); ERROR("Error initializing equalizer");
goto do_exit; goto do_exit;
} }
@ -133,7 +133,6 @@ int main(int argc, char** argv)
for (int delta_ss = 29; delta_ss < SRSLTE_NOF_DELTA_SS; delta_ss++) { for (int delta_ss = 29; delta_ss < SRSLTE_NOF_DELTA_SS; delta_ss++) {
for (int cshift = 7; cshift < SRSLTE_NOF_CSHIFT; cshift++) { for (int cshift = 7; cshift < SRSLTE_NOF_CSHIFT; cshift++) {
for (int t = 2; t < 3; t++) { for (int t = 2; t < 3; t++) {
/* Setup and pregen DMRS reference signals */ /* Setup and pregen DMRS reference signals */
srslte_refsignal_dmrs_pusch_cfg_t pusch_cfg; srslte_refsignal_dmrs_pusch_cfg_t pusch_cfg;
@ -161,7 +160,6 @@ int main(int argc, char** argv)
for (int sf_idx = 0; sf_idx < 10; sf_idx += 3) { for (int sf_idx = 0; sf_idx < 10; sf_idx += 3) {
for (int cshift_dmrs = 0; cshift_dmrs < SRSLTE_NOF_CSHIFT; cshift_dmrs += 5) { for (int cshift_dmrs = 0; cshift_dmrs < SRSLTE_NOF_CSHIFT; cshift_dmrs += 5) {
if (SRSLTE_VERBOSE_ISINFO()) { if (SRSLTE_VERBOSE_ISINFO()) {
printf("nof_prb: %d, ", nof_prb); printf("nof_prb: %d, ", nof_prb);
printf("cyclic_shift: %d, ", pusch_cfg.cyclic_shift); printf("cyclic_shift: %d, ", pusch_cfg.cyclic_shift);
@ -210,7 +208,7 @@ int main(int argc, char** argv)
mse += cabsf(ce[i] - h[i]); mse += cabsf(ce[i] - h[i]);
} }
mse /= num_re; mse /= num_re;
INFO("MSE: %f\n", mse); INFO("MSE: %f", mse);
if (mse > 4) { if (mse > 4) {
goto do_exit; goto do_exit;
} }

@ -55,7 +55,7 @@ static int test(const srslte_slot_cfg_t* slot_cfg,
if (srslte_verbose >= SRSLTE_VERBOSE_INFO) { if (srslte_verbose >= SRSLTE_VERBOSE_INFO) {
char str[128] = {}; char str[128] = {};
srslte_csi_rs_measure_info(&measure, str, sizeof(str)); srslte_csi_rs_measure_info(&measure, str, sizeof(str));
INFO("Measure: %s\n", str); INFO("Measure: %s", str);
} }
TESTASSERT(fabsf(measure.rsrp_dB - rsrp_dB_gold) < 1.0f); TESTASSERT(fabsf(measure.rsrp_dB - rsrp_dB_gold) < 1.0f);
@ -126,12 +126,12 @@ int main(int argc, char** argv)
cf_t* grid = srslte_vec_cf_malloc(SRSLTE_SLOT_LEN_RE_NR(carrier.nof_prb)); cf_t* grid = srslte_vec_cf_malloc(SRSLTE_SLOT_LEN_RE_NR(carrier.nof_prb));
if (grid == NULL) { if (grid == NULL) {
ERROR("Alloc\n"); ERROR("Alloc");
goto clean_exit; goto clean_exit;
} }
if (srslte_channel_awgn_init(&awgn, 1234) < SRSLTE_SUCCESS) { if (srslte_channel_awgn_init(&awgn, 1234) < SRSLTE_SUCCESS) {
ERROR("AWGN Init\n"); ERROR("AWGN Init");
goto clean_exit; goto clean_exit;
} }

@ -156,7 +156,7 @@ int main(int argc, char** argv)
srslte_dmrs_pdcch_estimator_init(&estimator, &carrier, &coreset); srslte_dmrs_pdcch_estimator_init(&estimator, &carrier, &coreset);
if (run_test(&estimator, &coreset, &search_space, aggregation_level, sf_symbols, &pdcch_ce)) { if (run_test(&estimator, &coreset, &search_space, aggregation_level, sf_symbols, &pdcch_ce)) {
ERROR("Test %d failed\n", test_counter); ERROR("Test %d failed", test_counter);
} else { } else {
test_passed++; test_passed++;
} }

@ -254,18 +254,18 @@ int main(int argc, char** argv)
// Initialise object DMRS for PDSCH // Initialise object DMRS for PDSCH
if (srslte_dmrs_sch_init(&dmrs_pdsch, true) != SRSLTE_SUCCESS) { if (srslte_dmrs_sch_init(&dmrs_pdsch, true) != SRSLTE_SUCCESS) {
ERROR("Init\n"); ERROR("Init");
goto clean_exit; goto clean_exit;
} }
// Set carrier configuration // Set carrier configuration
if (srslte_dmrs_sch_set_carrier(&dmrs_pdsch, &carrier) != SRSLTE_SUCCESS) { if (srslte_dmrs_sch_set_carrier(&dmrs_pdsch, &carrier) != SRSLTE_SUCCESS) {
ERROR("Setting carrier\n"); ERROR("Setting carrier");
goto clean_exit; goto clean_exit;
} }
if (srslte_chest_dl_res_init(&chest_dl_res, carrier.nof_prb) != SRSLTE_SUCCESS) { if (srslte_chest_dl_res_init(&chest_dl_res, carrier.nof_prb) != SRSLTE_SUCCESS) {
ERROR("Initiating channel estimation result\n"); ERROR("Initiating channel estimation result");
goto clean_exit; goto clean_exit;
} }
@ -317,7 +317,7 @@ int main(int argc, char** argv)
char str[64] = {}; char str[64] = {};
srslte_dmrs_sch_cfg_to_str(&pdsch_cfg.dmrs, str, 64); srslte_dmrs_sch_cfg_to_str(&pdsch_cfg.dmrs, str, 64);
ERROR("Test %d failed. %s.\n", test_counter, str); ERROR("Test %d failed. %s.", test_counter, str);
} }
test_counter++; test_counter++;

@ -76,7 +76,7 @@ int main(int argc, char** argv)
parse_args(argc, argv); parse_args(argc, argv);
if (srslte_refsignal_ul_set_cell(&refs, cell)) { if (srslte_refsignal_ul_set_cell(&refs, cell)) {
ERROR("Error initializing UL reference signal\n"); ERROR("Error initializing UL reference signal");
goto do_exit; goto do_exit;
} }
@ -93,7 +93,6 @@ int main(int argc, char** argv)
for (int h = 0; h < 3; h++) { for (int h = 0; h < 3; h++) {
for (int sf_idx = 0; sf_idx < 10; sf_idx++) { for (int sf_idx = 0; sf_idx < 10; sf_idx++) {
for (int cshift_dmrs = 0; cshift_dmrs < SRSLTE_NOF_CSHIFT; cshift_dmrs++) { for (int cshift_dmrs = 0; cshift_dmrs < SRSLTE_NOF_CSHIFT; cshift_dmrs++) {
uint32_t nof_prb = n; uint32_t nof_prb = n;
pusch_cfg.cyclic_shift = cshift; pusch_cfg.cyclic_shift = cshift;
pusch_cfg.delta_ss = delta_ss; pusch_cfg.delta_ss = delta_ss;

@ -69,7 +69,7 @@ int srslte_channel_awgn_init(srslte_channel_awgn_t* q, uint32_t seed)
q->table_cos = srslte_vec_f_malloc(AWGN_TABLE_ALLOC_SIZE); q->table_cos = srslte_vec_f_malloc(AWGN_TABLE_ALLOC_SIZE);
q->table_log = srslte_vec_f_malloc(AWGN_TABLE_ALLOC_SIZE); q->table_log = srslte_vec_f_malloc(AWGN_TABLE_ALLOC_SIZE);
if (!q->table_cos || !q->table_log) { if (!q->table_cos || !q->table_log) {
ERROR("Malloc\n"); ERROR("Malloc");
} }
// Fill tables // Fill tables

@ -16,7 +16,8 @@
using namespace srslte; using namespace srslte;
channel::channel(const channel::args_t& channel_args, uint32_t _nof_channels) channel::channel(const channel::args_t& channel_args, uint32_t _nof_channels, srslog::basic_logger& logger) :
logger(logger)
{ {
int ret = SRSLTE_SUCCESS; int ret = SRSLTE_SUCCESS;
uint32_t srate_max = (uint32_t)srslte_symbol_sz(SRSLTE_MAX_PRB) * 15000; uint32_t srate_max = (uint32_t)srslte_symbol_sz(SRSLTE_MAX_PRB) * 15000;
@ -137,11 +138,6 @@ static inline cf_t local_cexpf(float phase)
} }
} }
void channel::set_logger(log_filter* _log_h)
{
log_h = _log_h;
}
void channel::run(cf_t* in[SRSLTE_MAX_CHANNELS], void channel::run(cf_t* in[SRSLTE_MAX_CHANNELS],
cf_t* out[SRSLTE_MAX_CHANNELS], cf_t* out[SRSLTE_MAX_CHANNELS],
uint32_t len, uint32_t len,
@ -214,22 +210,16 @@ void channel::run(cf_t* in[SRSLTE_MAX_CHANNELS],
} }
} }
if (log_h) { // Logging
// Logging std::stringstream str;
std::stringstream str; str << "t=" << t.full_secs + t.frac_secs << "s; ";
if (delay[0]) {
str << "t=" << t.full_secs + t.frac_secs << "s; "; str << "delay=" << delay[0]->delay_us << "us; ";
}
if (delay[0]) { if (hst) {
str << "delay=" << delay[0]->delay_us << "us; "; str << "hst=" << hst->fs_hz << "Hz; ";
}
if (hst) {
str << "hst=" << hst->fs_hz << "Hz; ";
}
log_h->debug("%s\n", str.str().c_str());
} }
logger.debug("%s", str.str().c_str());
} }
void channel::set_srate(uint32_t srate) void channel::set_srate(uint32_t srate)

@ -83,7 +83,7 @@ int main(int argc, char** argv)
output_buffer = srslte_vec_cf_malloc(nof_samples); output_buffer = srslte_vec_cf_malloc(nof_samples);
if (!input_buffer || !output_buffer) { if (!input_buffer || !output_buffer) {
ERROR("Error: Allocating memory\n"); ERROR("Error: Allocating memory");
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
} }
@ -93,7 +93,7 @@ int main(int argc, char** argv)
#ifdef ENABLE_GUI #ifdef ENABLE_GUI
sdrgui_init(); sdrgui_init();
sdrgui_init_title("SRS AWGN Channel"); sdrgui_init_title("SRS AWGN Channel");
plot_real_t plot_fft = NULL; plot_real_t plot_fft = NULL;
plot_scatter_t plot_scatter = NULL; plot_scatter_t plot_scatter = NULL;
plot_real_init(&plot_fft); plot_real_init(&plot_fft);
@ -107,7 +107,7 @@ int main(int argc, char** argv)
cf_t* fft_out = srslte_vec_cf_malloc(nof_samples); cf_t* fft_out = srslte_vec_cf_malloc(nof_samples);
srslte_dft_plan_t fft = {}; srslte_dft_plan_t fft = {};
if (srslte_dft_plan_c(&fft, nof_samples, SRSLTE_DFT_FORWARD)) { if (srslte_dft_plan_c(&fft, nof_samples, SRSLTE_DFT_FORWARD)) {
ERROR("Error: init DFT\n"); ERROR("Error: init DFT");
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
} }
#endif /* ENABLE_GUI */ #endif /* ENABLE_GUI */

@ -282,7 +282,6 @@ char* srslte_cp_string(srslte_cp_t cp)
/* Returns the new time advance N_ta_new as specified in Section 4.2.3 of 36.213 */ /* Returns the new time advance N_ta_new as specified in Section 4.2.3 of 36.213 */
uint32_t srslte_N_ta_new(uint32_t N_ta_old, uint32_t ta) uint32_t srslte_N_ta_new(uint32_t N_ta_old, uint32_t ta)
{ {
ta &= 63; ta &= 63;
int n_ta_new = N_ta_old + ((float)ta - 31) * 16; int n_ta_new = N_ta_old + ((float)ta - 31) * 16;
if (n_ta_new < 0) { if (n_ta_new < 0) {
@ -643,7 +642,7 @@ bool srslte_band_is_tdd(uint32_t band)
i++; i++;
} }
if (i == SRSLTE_NOF_LTE_BANDS) { if (i == SRSLTE_NOF_LTE_BANDS) {
ERROR("Invalid Band %d\n", band); ERROR("Invalid Band %d", band);
return false; return false;
} }
return lte_bands[i].ul_earfcn_offset == 0; return lte_bands[i].ul_earfcn_offset == 0;
@ -653,7 +652,7 @@ uint8_t srslte_band_get_band(uint32_t dl_earfcn)
{ {
uint32_t i = SRSLTE_NOF_LTE_BANDS - 1; uint32_t i = SRSLTE_NOF_LTE_BANDS - 1;
if (dl_earfcn > lte_bands[i].dl_earfcn_offset) { if (dl_earfcn > lte_bands[i].dl_earfcn_offset) {
ERROR("Invalid DL_EARFCN=%d\n", dl_earfcn); ERROR("Invalid DL_EARFCN=%d", dl_earfcn);
} }
i--; i--;
while (i > 0 && lte_bands[i].dl_earfcn_offset > dl_earfcn) { while (i > 0 && lte_bands[i].dl_earfcn_offset > dl_earfcn) {
@ -666,7 +665,7 @@ double srslte_band_fd(uint32_t dl_earfcn)
{ {
uint32_t i = SRSLTE_NOF_LTE_BANDS - 1; uint32_t i = SRSLTE_NOF_LTE_BANDS - 1;
if (dl_earfcn > lte_bands[i].dl_earfcn_offset) { if (dl_earfcn > lte_bands[i].dl_earfcn_offset) {
ERROR("Invalid DL_EARFCN=%d\n", dl_earfcn); ERROR("Invalid DL_EARFCN=%d", dl_earfcn);
} }
i--; i--;
while (i > 0 && lte_bands[i].dl_earfcn_offset > dl_earfcn) { while (i > 0 && lte_bands[i].dl_earfcn_offset > dl_earfcn) {
@ -679,7 +678,7 @@ double srslte_band_fu(uint32_t ul_earfcn)
{ {
uint32_t i = SRSLTE_NOF_LTE_BANDS - 1; uint32_t i = SRSLTE_NOF_LTE_BANDS - 1;
if (ul_earfcn > lte_bands[i].ul_earfcn_offset) { if (ul_earfcn > lte_bands[i].ul_earfcn_offset) {
ERROR("Invalid UL_EARFCN=%d\n", ul_earfcn); ERROR("Invalid UL_EARFCN=%d", ul_earfcn);
} }
i--; i--;
while (i > 0 && (lte_bands[i].ul_earfcn_offset > ul_earfcn || lte_bands[i].ul_earfcn_offset == 0)) { while (i > 0 && (lte_bands[i].ul_earfcn_offset > ul_earfcn || lte_bands[i].ul_earfcn_offset == 0)) {
@ -692,7 +691,7 @@ uint32_t srslte_band_ul_earfcn(uint32_t dl_earfcn)
{ {
uint32_t i = SRSLTE_NOF_LTE_BANDS - 1; uint32_t i = SRSLTE_NOF_LTE_BANDS - 1;
if (dl_earfcn > lte_bands[i].dl_earfcn_offset) { if (dl_earfcn > lte_bands[i].dl_earfcn_offset) {
ERROR("Invalid DL_EARFCN=%d\n", dl_earfcn); ERROR("Invalid DL_EARFCN=%d", dl_earfcn);
} }
i--; i--;
while (i > 0 && lte_bands[i].dl_earfcn_offset > dl_earfcn) { while (i > 0 && lte_bands[i].dl_earfcn_offset > dl_earfcn) {
@ -719,14 +718,14 @@ int srslte_band_get_fd_band(uint32_t band,
i++; i++;
} }
if (i >= SRSLTE_NOF_LTE_BANDS - 1) { if (i >= SRSLTE_NOF_LTE_BANDS - 1) {
ERROR("Error: Invalid band %d\n", band); ERROR("Error: Invalid band %d", band);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (end_earfcn == -1) { if (end_earfcn == -1) {
end_earfcn = lte_bands[i + 1].dl_earfcn_offset - 1; end_earfcn = lte_bands[i + 1].dl_earfcn_offset - 1;
} else { } else {
if (end_earfcn > lte_bands[i + 1].dl_earfcn_offset - 1) { if (end_earfcn > lte_bands[i + 1].dl_earfcn_offset - 1) {
ERROR("Error: Invalid end earfcn %d. Max is %d\n", end_earfcn, lte_bands[i + 1].dl_earfcn_offset - 1); ERROR("Error: Invalid end earfcn %d. Max is %d", end_earfcn, lte_bands[i + 1].dl_earfcn_offset - 1);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -734,7 +733,7 @@ int srslte_band_get_fd_band(uint32_t band,
start_earfcn = lte_bands[i].dl_earfcn_offset; start_earfcn = lte_bands[i].dl_earfcn_offset;
} else { } else {
if (start_earfcn < lte_bands[i].dl_earfcn_offset) { if (start_earfcn < lte_bands[i].dl_earfcn_offset) {
ERROR("Error: Invalid start earfcn %d. Min is %d\n", start_earfcn, lte_bands[i].dl_earfcn_offset); ERROR("Error: Invalid start earfcn %d. Min is %d", start_earfcn, lte_bands[i].dl_earfcn_offset);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -794,11 +793,11 @@ uint32_t srslte_print_check(char* s, size_t max_len, uint32_t cur_len, const cha
cur_len += ret; cur_len += ret;
} else { } else {
// Formatting error detected // Formatting error detected
ERROR("Formatting error when printing string\n"); ERROR("Formatting error when printing string");
exit(-1); exit(-1);
} }
} else { } else {
ERROR("Buffer full when printing string\n"); ERROR("Buffer full when printing string");
exit(-1); exit(-1);
} }
return cur_len; return cur_len;

@ -99,10 +99,10 @@ uint32_t srslte_sl_get_num_symbols(srslte_sl_tm_t tm, srslte_cp_t cp)
if (cp == SRSLTE_CP_NORM) { if (cp == SRSLTE_CP_NORM) {
return SRSLTE_CP_NORM_SF_NSYMB; return SRSLTE_CP_NORM_SF_NSYMB;
} else { } else {
ERROR("Invalid CP\n"); ERROR("Invalid CP");
} }
} else { } else {
ERROR("Invalid TM\n"); ERROR("Invalid TM");
} }
return 0; // Calling function may use return value for loop termination return 0; // Calling function may use return value for loop termination
} }

@ -287,7 +287,7 @@ void srslte_sequence_state_advance(srslte_sequence_state_t* s, uint32_t length)
int srslte_sequence_set_LTE_pr(srslte_sequence_t* q, uint32_t len, uint32_t seed) int srslte_sequence_set_LTE_pr(srslte_sequence_t* q, uint32_t len, uint32_t seed)
{ {
if (len > q->max_len) { if (len > q->max_len) {
ERROR("Error generating pseudo-random sequence: len %d is greater than allocated len %d\n", len, q->max_len); ERROR("Error generating pseudo-random sequence: len %d is greater than allocated len %d", len, q->max_len);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }

@ -231,7 +231,7 @@ static int zc_sequence_lte_r_uv_arg(uint32_t M_zc, uint32_t u, uint32_t v, cf_t*
} else if (M_zc >= 36) { } else if (M_zc >= 36) {
zc_sequence_r_uv_arg_mprb(M_zc, u, v, tmp_arg); zc_sequence_r_uv_arg_mprb(M_zc, u, v, tmp_arg);
} else { } else {
ERROR("Invalid M_zc (%d)\n", M_zc); ERROR("Invalid M_zc (%d)", M_zc);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -251,7 +251,7 @@ static int zc_sequence_nr_r_uv_arg(uint32_t M_zc, uint32_t u, uint32_t v, cf_t*
} else if (M_zc >= 36) { } else if (M_zc >= 36) {
zc_sequence_r_uv_arg_mprb(M_zc, u, v, tmp_arg); zc_sequence_r_uv_arg_mprb(M_zc, u, v, tmp_arg);
} else { } else {
ERROR("Invalid M_zc (%d)\n", M_zc); ERROR("Invalid M_zc (%d)", M_zc);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -274,7 +274,7 @@ int srslte_zc_sequence_generate_lte(uint32_t u, uint32_t v, float alpha, uint32_
// Check U and V // Check U and V
if (u >= SRSLTE_ZC_SEQUENCE_NOF_GROUPS || v >= SRSLTE_ZC_SEQUENCE_NOF_BASE) { if (u >= SRSLTE_ZC_SEQUENCE_NOF_GROUPS || v >= SRSLTE_ZC_SEQUENCE_NOF_BASE) {
ERROR("Invalid u (%d) or v (%d)\n", u, v); ERROR("Invalid u (%d) or v (%d)", u, v);
return SRSLTE_ERROR_OUT_OF_BOUNDS; return SRSLTE_ERROR_OUT_OF_BOUNDS;
} }
@ -301,7 +301,7 @@ int srslte_zc_sequence_generate_nr(uint32_t u, uint32_t v, float alpha, uint32_t
// Check U and V // Check U and V
if (u >= SRSLTE_ZC_SEQUENCE_NOF_GROUPS || v >= SRSLTE_ZC_SEQUENCE_NOF_BASE) { if (u >= SRSLTE_ZC_SEQUENCE_NOF_GROUPS || v >= SRSLTE_ZC_SEQUENCE_NOF_BASE) {
ERROR("Invalid u (%d) or v (%d)\n", u, v); ERROR("Invalid u (%d) or v (%d)", u, v);
return SRSLTE_ERROR_OUT_OF_BOUNDS; return SRSLTE_ERROR_OUT_OF_BOUNDS;
} }
@ -341,7 +341,7 @@ int srslte_zc_sequence_lut_init_nr(srslte_zc_sequence_lut_t* q,
// Allocate sequence // Allocate sequence
q->sequence[u][v] = srslte_vec_cf_malloc(nof_alphas * q->M_zc); q->sequence[u][v] = srslte_vec_cf_malloc(nof_alphas * q->M_zc);
if (q->sequence[u][v] == NULL) { if (q->sequence[u][v] == NULL) {
ERROR("Malloc\n"); ERROR("Malloc");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -349,7 +349,7 @@ int srslte_zc_sequence_lut_init_nr(srslte_zc_sequence_lut_t* q,
for (uint32_t alpha_idx = 0; alpha_idx < nof_alphas; alpha_idx++) { for (uint32_t alpha_idx = 0; alpha_idx < nof_alphas; alpha_idx++) {
if (srslte_zc_sequence_generate_nr(u, v, alphas[alpha_idx], m, delta, &q->sequence[u][v][alpha_idx * q->M_zc]) < if (srslte_zc_sequence_generate_nr(u, v, alphas[alpha_idx], m, delta, &q->sequence[u][v][alpha_idx * q->M_zc]) <
SRSLTE_SUCCESS) { SRSLTE_SUCCESS) {
ERROR("Generating sequence\n"); ERROR("Generating sequence");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }

@ -344,7 +344,7 @@ void srslte_dft_run_guru_c(srslte_dft_plan_t* plan)
if (plan->is_guru == true) { if (plan->is_guru == true) {
fftwf_execute(plan->p); fftwf_execute(plan->p);
} else { } else {
ERROR("srslte_dft_run_guru_c: the selected plan is not guru!\n"); ERROR("srslte_dft_run_guru_c: the selected plan is not guru!");
} }
} }

@ -36,9 +36,9 @@ int srslte_dft_precoding_init(srslte_dft_precoding_t* q, uint32_t max_prb, bool
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
for (uint32_t i = 1; i <= max_prb; i++) { for (uint32_t i = 1; i <= max_prb; i++) {
if (srslte_dft_precoding_valid_prb(i)) { if (srslte_dft_precoding_valid_prb(i)) {
DEBUG("Initiating DFT precoding plan for %d PRBs\n", i); DEBUG("Initiating DFT precoding plan for %d PRBs", i);
if (srslte_dft_plan_c(&q->dft_plan[i], i * SRSLTE_NRE, is_tx ? SRSLTE_DFT_FORWARD : SRSLTE_DFT_BACKWARD)) { if (srslte_dft_plan_c(&q->dft_plan[i], i * SRSLTE_NRE, is_tx ? SRSLTE_DFT_FORWARD : SRSLTE_DFT_BACKWARD)) {
ERROR("Error: Creating DFT plan %d\n", i); ERROR("Error: Creating DFT plan %d", i);
goto clean_exit; goto clean_exit;
} }
srslte_dft_plan_set_norm(&q->dft_plan[i], true); srslte_dft_plan_set_norm(&q->dft_plan[i], true);
@ -104,9 +104,8 @@ uint32_t srslte_dft_precoding_get_valid_prb(uint32_t nof_prb)
int srslte_dft_precoding(srslte_dft_precoding_t* q, cf_t* input, cf_t* output, uint32_t nof_prb, uint32_t nof_symbols) int srslte_dft_precoding(srslte_dft_precoding_t* q, cf_t* input, cf_t* output, uint32_t nof_prb, uint32_t nof_symbols)
{ {
if (!srslte_dft_precoding_valid_prb(nof_prb) && nof_prb <= q->max_prb) { if (!srslte_dft_precoding_valid_prb(nof_prb) && nof_prb <= q->max_prb) {
ERROR("Error invalid number of PRB (%d)\n", nof_prb); ERROR("Error invalid number of PRB (%d)", nof_prb);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }

@ -28,12 +28,11 @@
static int ofdm_init_mbsfn_(srslte_ofdm_t* q, srslte_ofdm_cfg_t* cfg, srslte_dft_dir_t dir) static int ofdm_init_mbsfn_(srslte_ofdm_t* q, srslte_ofdm_cfg_t* cfg, srslte_dft_dir_t dir)
{ {
// If the symbol size is not given, calculate in function of the number of resource blocks // If the symbol size is not given, calculate in function of the number of resource blocks
if (cfg->symbol_sz == 0) { if (cfg->symbol_sz == 0) {
int symbol_sz_err = srslte_symbol_sz(cfg->nof_prb); int symbol_sz_err = srslte_symbol_sz(cfg->nof_prb);
if (symbol_sz_err <= SRSLTE_SUCCESS) { if (symbol_sz_err <= SRSLTE_SUCCESS) {
ERROR("Invalid number of PRB %d\n", cfg->nof_prb); ERROR("Invalid number of PRB %d", cfg->nof_prb);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
cfg->symbol_sz = (uint32_t)symbol_sz_err; cfg->symbol_sz = (uint32_t)symbol_sz_err;
@ -65,13 +64,13 @@ static int ofdm_init_mbsfn_(srslte_ofdm_t* q, srslte_ofdm_cfg_t* cfg, srslte_dft
if (q->fft_plan.size) { if (q->fft_plan.size) {
// Replan if it was initialised previously // Replan if it was initialised previously
if (srslte_dft_replan(&q->fft_plan, q->cfg.symbol_sz)) { if (srslte_dft_replan(&q->fft_plan, q->cfg.symbol_sz)) {
ERROR("Reeplaning DFT plan\n"); ERROR("Reeplaning DFT plan");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} else { } else {
// Create plan from zero otherwise // Create plan from zero otherwise
if (srslte_dft_plan_c(&q->fft_plan, symbol_sz, dir)) { if (srslte_dft_plan_c(&q->fft_plan, symbol_sz, dir)) {
ERROR("Creating DFT plan\n"); ERROR("Creating DFT plan");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -156,7 +155,7 @@ static int ofdm_init_mbsfn_(srslte_ofdm_t* q, srslte_ofdm_cfg_t* cfg, srslte_dft
SRSLTE_CP_NSYMB(cp), SRSLTE_CP_NSYMB(cp),
symbol_sz + cp2, symbol_sz + cp2,
symbol_sz)) { symbol_sz)) {
ERROR("Creating Guru DFT plan (%d)\n", slot); ERROR("Creating Guru DFT plan (%d)", slot);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} else { } else {
@ -170,7 +169,7 @@ static int ofdm_init_mbsfn_(srslte_ofdm_t* q, srslte_ofdm_cfg_t* cfg, srslte_dft
SRSLTE_CP_NSYMB(cp), SRSLTE_CP_NSYMB(cp),
symbol_sz, symbol_sz,
symbol_sz + cp2)) { symbol_sz + cp2)) {
ERROR("Creating Guru inverse-DFT plan (%d)\n", slot); ERROR("Creating Guru inverse-DFT plan (%d)", slot);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -179,7 +178,7 @@ static int ofdm_init_mbsfn_(srslte_ofdm_t* q, srslte_ofdm_cfg_t* cfg, srslte_dft
srslte_dft_plan_set_mirror(&q->fft_plan, true); srslte_dft_plan_set_mirror(&q->fft_plan, true);
DEBUG("Init %s symbol_sz=%d, nof_symbols=%d, cp=%s, nof_re=%d, nof_guards=%d\n", DEBUG("Init %s symbol_sz=%d, nof_symbols=%d, cp=%s, nof_re=%d, nof_guards=%d",
dir == SRSLTE_DFT_FORWARD ? "FFT" : "iFFT", dir == SRSLTE_DFT_FORWARD ? "FFT" : "iFFT",
q->cfg.symbol_sz, q->cfg.symbol_sz,
q->nof_symbols, q->nof_symbols,

@ -122,7 +122,7 @@ int main(int argc, char** argv)
ofdm_cfg.freq_shift_f = freq_shift_f; ofdm_cfg.freq_shift_f = freq_shift_f;
ofdm_cfg.normalize = true; ofdm_cfg.normalize = true;
if (srslte_ofdm_tx_init_cfg(&ifft, &ofdm_cfg)) { if (srslte_ofdm_tx_init_cfg(&ifft, &ofdm_cfg)) {
ERROR("Error initializing iFFT\n"); ERROR("Error initializing iFFT");
exit(-1); exit(-1);
} }
@ -131,7 +131,7 @@ int main(int argc, char** argv)
ofdm_cfg.rx_window_offset = rx_window_offset; ofdm_cfg.rx_window_offset = rx_window_offset;
ofdm_cfg.freq_shift_f = -freq_shift_f; ofdm_cfg.freq_shift_f = -freq_shift_f;
if (srslte_ofdm_rx_init_cfg(&fft, &ofdm_cfg)) { if (srslte_ofdm_rx_init_cfg(&fft, &ofdm_cfg)) {
ERROR("Error initializing FFT\n"); ERROR("Error initializing FFT");
exit(-1); exit(-1);
} }

@ -51,7 +51,7 @@ int srslte_enb_dl_init(srslte_enb_dl_t* q, cf_t* out_buffer[SRSLTE_MAX_PORTS], u
ofdm_cfg.out_buffer = out_buffer[i]; ofdm_cfg.out_buffer = out_buffer[i];
ofdm_cfg.sf_type = SRSLTE_SF_NORM; ofdm_cfg.sf_type = SRSLTE_SF_NORM;
if (srslte_ofdm_tx_init_cfg(&q->ifft[i], &ofdm_cfg)) { if (srslte_ofdm_tx_init_cfg(&q->ifft[i], &ofdm_cfg)) {
ERROR("Error initiating FFT (%d)\n", i); ERROR("Error initiating FFT (%d)", i);
goto clean_exit; goto clean_exit;
} }
} }
@ -60,52 +60,52 @@ int srslte_enb_dl_init(srslte_enb_dl_t* q, cf_t* out_buffer[SRSLTE_MAX_PORTS], u
ofdm_cfg.out_buffer = out_buffer[0]; ofdm_cfg.out_buffer = out_buffer[0];
ofdm_cfg.sf_type = SRSLTE_SF_MBSFN; ofdm_cfg.sf_type = SRSLTE_SF_MBSFN;
if (srslte_ofdm_tx_init_cfg(&q->ifft_mbsfn, &ofdm_cfg)) { if (srslte_ofdm_tx_init_cfg(&q->ifft_mbsfn, &ofdm_cfg)) {
ERROR("Error initiating FFT \n"); ERROR("Error initiating FFT");
goto clean_exit; goto clean_exit;
} }
if (srslte_pbch_init(&q->pbch)) { if (srslte_pbch_init(&q->pbch)) {
ERROR("Error creating PBCH object\n"); ERROR("Error creating PBCH object");
goto clean_exit; goto clean_exit;
} }
if (srslte_pcfich_init(&q->pcfich, 0)) { if (srslte_pcfich_init(&q->pcfich, 0)) {
ERROR("Error creating PCFICH object\n"); ERROR("Error creating PCFICH object");
goto clean_exit; goto clean_exit;
} }
if (srslte_phich_init(&q->phich, 0)) { if (srslte_phich_init(&q->phich, 0)) {
ERROR("Error creating PHICH object\n"); ERROR("Error creating PHICH object");
goto clean_exit; goto clean_exit;
} }
int mbsfn_area_id = 1; int mbsfn_area_id = 1;
if (srslte_pmch_init(&q->pmch, max_prb, 1)) { if (srslte_pmch_init(&q->pmch, max_prb, 1)) {
ERROR("Error creating PMCH object\n"); ERROR("Error creating PMCH object");
} }
srslte_pmch_set_area_id(&q->pmch, mbsfn_area_id); srslte_pmch_set_area_id(&q->pmch, mbsfn_area_id);
if (srslte_pdcch_init_enb(&q->pdcch, max_prb)) { if (srslte_pdcch_init_enb(&q->pdcch, max_prb)) {
ERROR("Error creating PDCCH object\n"); ERROR("Error creating PDCCH object");
goto clean_exit; goto clean_exit;
} }
if (srslte_pdsch_init_enb(&q->pdsch, max_prb)) { if (srslte_pdsch_init_enb(&q->pdsch, max_prb)) {
ERROR("Error creating PDSCH object\n"); ERROR("Error creating PDSCH object");
goto clean_exit; goto clean_exit;
} }
if (srslte_refsignal_cs_init(&q->csr_signal, max_prb)) { if (srslte_refsignal_cs_init(&q->csr_signal, max_prb)) {
ERROR("Error initializing CSR signal (%d)\n", ret); ERROR("Error initializing CSR signal (%d)", ret);
goto clean_exit; goto clean_exit;
} }
if (srslte_refsignal_mbsfn_init(&q->mbsfnr_signal, max_prb)) { if (srslte_refsignal_mbsfn_init(&q->mbsfnr_signal, max_prb)) {
ERROR("Error initializing CSR signal (%d)\n", ret); ERROR("Error initializing CSR signal (%d)", ret);
goto clean_exit; goto clean_exit;
} }
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;
} else { } else {
ERROR("Invalid parameters\n"); ERROR("Invalid parameters");
} }
clean_exit: clean_exit:
@ -151,58 +151,58 @@ int srslte_enb_dl_set_cell(srslte_enb_dl_t* q, srslte_cell_t cell)
} }
q->cell = cell; q->cell = cell;
if (srslte_regs_init(&q->regs, q->cell)) { if (srslte_regs_init(&q->regs, q->cell)) {
ERROR("Error resizing REGs\n"); ERROR("Error resizing REGs");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
for (int i = 0; i < q->cell.nof_ports; i++) { for (int i = 0; i < q->cell.nof_ports; i++) {
if (srslte_ofdm_tx_set_prb(&q->ifft[i], q->cell.cp, q->cell.nof_prb)) { if (srslte_ofdm_tx_set_prb(&q->ifft[i], q->cell.cp, q->cell.nof_prb)) {
ERROR("Error re-planning iFFT (%d)\n", i); ERROR("Error re-planning iFFT (%d)", i);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
if (srslte_ofdm_tx_set_prb(&q->ifft_mbsfn, SRSLTE_CP_EXT, q->cell.nof_prb)) { if (srslte_ofdm_tx_set_prb(&q->ifft_mbsfn, SRSLTE_CP_EXT, q->cell.nof_prb)) {
ERROR("Error re-planning ifft_mbsfn\n"); ERROR("Error re-planning ifft_mbsfn");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
srslte_ofdm_set_non_mbsfn_region(&q->ifft_mbsfn, 2); srslte_ofdm_set_non_mbsfn_region(&q->ifft_mbsfn, 2);
if (srslte_pbch_set_cell(&q->pbch, q->cell)) { if (srslte_pbch_set_cell(&q->pbch, q->cell)) {
ERROR("Error creating PBCH object\n"); ERROR("Error creating PBCH object");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_pcfich_set_cell(&q->pcfich, &q->regs, q->cell)) { if (srslte_pcfich_set_cell(&q->pcfich, &q->regs, q->cell)) {
ERROR("Error creating PCFICH object\n"); ERROR("Error creating PCFICH object");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_phich_set_cell(&q->phich, &q->regs, q->cell)) { if (srslte_phich_set_cell(&q->phich, &q->regs, q->cell)) {
ERROR("Error creating PHICH object\n"); ERROR("Error creating PHICH object");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_pdcch_set_cell(&q->pdcch, &q->regs, q->cell)) { if (srslte_pdcch_set_cell(&q->pdcch, &q->regs, q->cell)) {
ERROR("Error creating PDCCH object\n"); ERROR("Error creating PDCCH object");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_pdsch_set_cell(&q->pdsch, q->cell)) { if (srslte_pdsch_set_cell(&q->pdsch, q->cell)) {
ERROR("Error creating PDSCH object\n"); ERROR("Error creating PDSCH object");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_pmch_set_cell(&q->pmch, q->cell)) { if (srslte_pmch_set_cell(&q->pmch, q->cell)) {
ERROR("Error creating PMCH object\n"); ERROR("Error creating PMCH object");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_refsignal_cs_set_cell(&q->csr_signal, q->cell)) { if (srslte_refsignal_cs_set_cell(&q->csr_signal, q->cell)) {
ERROR("Error initializing CSR signal (%d)\n", ret); ERROR("Error initializing CSR signal (%d)", ret);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
int mbsfn_area_id = 1; int mbsfn_area_id = 1;
if (srslte_refsignal_mbsfn_set_cell(&q->mbsfnr_signal, q->cell, mbsfn_area_id)) { if (srslte_refsignal_mbsfn_set_cell(&q->mbsfnr_signal, q->cell, mbsfn_area_id)) {
ERROR("Error initializing MBSFNR signal (%d)\n", ret); ERROR("Error initializing MBSFNR signal (%d)", ret);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
/* Generate PSS/SSS signals */ /* Generate PSS/SSS signals */
@ -218,7 +218,7 @@ int srslte_enb_dl_set_cell(srslte_enb_dl_t* q, srslte_cell_t cell)
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;
} else { } else {
ERROR("Invalid cell properties: Id=%d, Ports=%d, PRBs=%d\n", cell.id, cell.nof_ports, cell.nof_prb); ERROR("Invalid cell properties: Id=%d, Ports=%d, PRBs=%d", cell.id, cell.nof_ports, cell.nof_prb);
} }
return ret; return ret;
} }
@ -376,10 +376,10 @@ int srslte_enb_dl_put_pdcch_dl(srslte_enb_dl_t* q, srslte_dci_cfg_t* dci_cfg, sr
ZERO_OBJECT(dci_msg); ZERO_OBJECT(dci_msg);
if (srslte_dci_msg_pack_pdsch(&q->cell, &q->dl_sf, dci_cfg, dci_dl, &dci_msg)) { if (srslte_dci_msg_pack_pdsch(&q->cell, &q->dl_sf, dci_cfg, dci_dl, &dci_msg)) {
ERROR("Error packing DL DCI\n"); ERROR("Error packing DL DCI");
} }
if (srslte_pdcch_encode(&q->pdcch, &q->dl_sf, &dci_msg, q->sf_symbols)) { if (srslte_pdcch_encode(&q->pdcch, &q->dl_sf, &dci_msg, q->sf_symbols)) {
ERROR("Error encoding DL DCI message\n"); ERROR("Error encoding DL DCI message");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -392,10 +392,10 @@ int srslte_enb_dl_put_pdcch_ul(srslte_enb_dl_t* q, srslte_dci_cfg_t* dci_cfg, sr
ZERO_OBJECT(dci_msg); ZERO_OBJECT(dci_msg);
if (srslte_dci_msg_pack_pusch(&q->cell, &q->dl_sf, dci_cfg, dci_ul, &dci_msg)) { if (srslte_dci_msg_pack_pusch(&q->cell, &q->dl_sf, dci_cfg, dci_ul, &dci_msg)) {
ERROR("Error packing UL DCI\n"); ERROR("Error packing UL DCI");
} }
if (srslte_pdcch_encode(&q->pdcch, &q->dl_sf, &dci_msg, q->sf_symbols)) { if (srslte_pdcch_encode(&q->pdcch, &q->dl_sf, &dci_msg, q->sf_symbols)) {
ERROR("Error encoding UL DCI message\n"); ERROR("Error encoding UL DCI message");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -596,7 +596,6 @@ get_ack_fdd(const srslte_uci_cfg_t* uci_cfg, const srslte_uci_value_t* uci_value
bool csi_report = uci_cfg->cqi.data_enable || uci_cfg->cqi.ri_len; bool csi_report = uci_cfg->cqi.data_enable || uci_cfg->cqi.ri_len;
switch (pdsch_ack->ack_nack_feedback_mode) { switch (pdsch_ack->ack_nack_feedback_mode) {
case SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL: case SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL:
// Get ACK from PCell only, skipping DRX // Get ACK from PCell only, skipping DRX
enb_dl_get_ack_fdd_pcell_skip_drx(uci_value, pdsch_ack, nof_tb); enb_dl_get_ack_fdd_pcell_skip_drx(uci_value, pdsch_ack, nof_tb);
@ -646,7 +645,7 @@ void srslte_enb_dl_get_ack(const srslte_cell_t* cell,
if (cell->frame_type == SRSLTE_FDD) { if (cell->frame_type == SRSLTE_FDD) {
get_ack_fdd(uci_cfg, uci_value, pdsch_ack); get_ack_fdd(uci_cfg, uci_value, pdsch_ack);
} else { } else {
ERROR("Not implemented for TDD\n"); ERROR("Not implemented for TDD");
} }
} }

@ -25,7 +25,7 @@ static int enb_dl_alloc_prb(srslte_enb_dl_nr_t* q, uint32_t new_nof_prb)
q->sf_symbols[i] = srslte_vec_cf_malloc(SRSLTE_SLOT_LEN_RE_NR(q->max_prb)); q->sf_symbols[i] = srslte_vec_cf_malloc(SRSLTE_SLOT_LEN_RE_NR(q->max_prb));
if (q->sf_symbols[i] == NULL) { if (q->sf_symbols[i] == NULL) {
ERROR("Malloc\n"); ERROR("Malloc");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -41,7 +41,7 @@ int srslte_enb_dl_nr_init(srslte_enb_dl_nr_t* q, cf_t* output[SRSLTE_MAX_PORTS],
} }
if (args->nof_tx_antennas == 0) { if (args->nof_tx_antennas == 0) {
ERROR("Error invalid number of antennas (%d)\n", args->nof_tx_antennas); ERROR("Error invalid number of antennas (%d)", args->nof_tx_antennas);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -52,7 +52,7 @@ int srslte_enb_dl_nr_init(srslte_enb_dl_nr_t* q, cf_t* output[SRSLTE_MAX_PORTS],
} }
if (enb_dl_alloc_prb(q, args->nof_max_prb) < SRSLTE_SUCCESS) { if (enb_dl_alloc_prb(q, args->nof_max_prb) < SRSLTE_SUCCESS) {
ERROR("Error allocating\n"); ERROR("Error allocating");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -68,12 +68,12 @@ int srslte_enb_dl_nr_init(srslte_enb_dl_nr_t* q, cf_t* output[SRSLTE_MAX_PORTS],
} }
if (srslte_dmrs_sch_init(&q->dmrs, false) < SRSLTE_SUCCESS) { if (srslte_dmrs_sch_init(&q->dmrs, false) < SRSLTE_SUCCESS) {
ERROR("Error DMRS\n"); ERROR("Error DMRS");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_pdcch_nr_init_tx(&q->pdcch, &args->pdcch) < SRSLTE_SUCCESS) { if (srslte_pdcch_nr_init_tx(&q->pdcch, &args->pdcch) < SRSLTE_SUCCESS) {
ERROR("Error PDCCH\n"); ERROR("Error PDCCH");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -109,12 +109,12 @@ int srslte_enb_dl_nr_set_carrier(srslte_enb_dl_nr_t* q, const srslte_carrier_nr_
} }
if (srslte_dmrs_sch_set_carrier(&q->dmrs, carrier) < SRSLTE_SUCCESS) { if (srslte_dmrs_sch_set_carrier(&q->dmrs, carrier) < SRSLTE_SUCCESS) {
ERROR("Error DMRS\n"); ERROR("Error DMRS");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (enb_dl_alloc_prb(q, carrier->nof_prb) < SRSLTE_SUCCESS) { if (enb_dl_alloc_prb(q, carrier->nof_prb) < SRSLTE_SUCCESS) {
ERROR("Error allocating\n"); ERROR("Error allocating");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -195,24 +195,24 @@ int srslte_enb_dl_nr_pdcch_put(srslte_enb_dl_nr_t* q,
// Put DMRS // Put DMRS
if (srslte_dmrs_pdcch_put(&q->carrier, &q->coreset, slot_cfg, &dci_dl->location, q->sf_symbols[0]) < SRSLTE_SUCCESS) { if (srslte_dmrs_pdcch_put(&q->carrier, &q->coreset, slot_cfg, &dci_dl->location, q->sf_symbols[0]) < SRSLTE_SUCCESS) {
ERROR("Error putting PDCCH DMRS\n"); ERROR("Error putting PDCCH DMRS");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Pack DCI // Pack DCI
srslte_dci_msg_nr_t dci_msg = {}; srslte_dci_msg_nr_t dci_msg = {};
if (srslte_dci_nr_pack(&q->carrier, &q->coreset, dci_dl, &dci_msg) < SRSLTE_SUCCESS) { if (srslte_dci_nr_pack(&q->carrier, &q->coreset, dci_dl, &dci_msg) < SRSLTE_SUCCESS) {
ERROR("Error packing DL DCI\n"); ERROR("Error packing DL DCI");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// PDCCH Encode // PDCCH Encode
if (srslte_pdcch_nr_encode(&q->pdcch, &dci_msg, q->sf_symbols[0]) < SRSLTE_SUCCESS) { if (srslte_pdcch_nr_encode(&q->pdcch, &dci_msg, q->sf_symbols[0]) < SRSLTE_SUCCESS) {
ERROR("Error encoding PDCCH\n"); ERROR("Error encoding PDCCH");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
INFO("DCI DL NR: L=%d; ncce=%d;\n", dci_dl->location.L, dci_dl->location.ncce); INFO("DCI DL NR: L=%d; ncce=%d;", dci_dl->location.L, dci_dl->location.ncce);
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }

@ -47,29 +47,29 @@ int srslte_enb_ul_init(srslte_enb_ul_t* q, cf_t* in_buffer, uint32_t max_prb)
ofdm_cfg.normalize = false; ofdm_cfg.normalize = false;
ofdm_cfg.rx_window_offset = 0.5f; ofdm_cfg.rx_window_offset = 0.5f;
if (srslte_ofdm_rx_init_cfg(&q->fft, &ofdm_cfg)) { if (srslte_ofdm_rx_init_cfg(&q->fft, &ofdm_cfg)) {
ERROR("Error initiating FFT\n"); ERROR("Error initiating FFT");
goto clean_exit; goto clean_exit;
} }
if (srslte_pucch_init_enb(&q->pucch)) { if (srslte_pucch_init_enb(&q->pucch)) {
ERROR("Error creating PUCCH object\n"); ERROR("Error creating PUCCH object");
goto clean_exit; goto clean_exit;
} }
if (srslte_pusch_init_enb(&q->pusch, max_prb)) { if (srslte_pusch_init_enb(&q->pusch, max_prb)) {
ERROR("Error creating PUSCH object\n"); ERROR("Error creating PUSCH object");
goto clean_exit; goto clean_exit;
} }
if (srslte_chest_ul_init(&q->chest, max_prb)) { if (srslte_chest_ul_init(&q->chest, max_prb)) {
ERROR("Error initiating channel estimator\n"); ERROR("Error initiating channel estimator");
goto clean_exit; goto clean_exit;
} }
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;
} else { } else {
ERROR("Invalid parameters\n"); ERROR("Invalid parameters");
} }
clean_exit: clean_exit:
@ -82,7 +82,6 @@ clean_exit:
void srslte_enb_ul_free(srslte_enb_ul_t* q) void srslte_enb_ul_free(srslte_enb_ul_t* q)
{ {
if (q) { if (q) {
srslte_ofdm_rx_free(&q->fft); srslte_ofdm_rx_free(&q->fft);
srslte_pucch_free(&q->pucch); srslte_pucch_free(&q->pucch);
srslte_pusch_free(&q->pusch); srslte_pusch_free(&q->pusch);
@ -110,22 +109,22 @@ int srslte_enb_ul_set_cell(srslte_enb_ul_t* q,
q->cell = cell; q->cell = cell;
if (srslte_ofdm_rx_set_prb(&q->fft, q->cell.cp, q->cell.nof_prb)) { if (srslte_ofdm_rx_set_prb(&q->fft, q->cell.cp, q->cell.nof_prb)) {
ERROR("Error initiating FFT\n"); ERROR("Error initiating FFT");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_pucch_set_cell(&q->pucch, q->cell)) { if (srslte_pucch_set_cell(&q->pucch, q->cell)) {
ERROR("Error creating PUCCH object\n"); ERROR("Error creating PUCCH object");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_pusch_set_cell(&q->pusch, q->cell)) { if (srslte_pusch_set_cell(&q->pusch, q->cell)) {
ERROR("Error creating PUSCH object\n"); ERROR("Error creating PUSCH object");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_chest_ul_set_cell(&q->chest, cell)) { if (srslte_chest_ul_set_cell(&q->chest, cell)) {
ERROR("Error initiating channel estimator\n"); ERROR("Error initiating channel estimator");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -135,7 +134,7 @@ int srslte_enb_ul_set_cell(srslte_enb_ul_t* q,
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;
} }
} else { } else {
ERROR("Invalid cell properties: Id=%d, Ports=%d, PRBs=%d\n", cell.id, cell.nof_ports, cell.nof_prb); ERROR("Invalid cell properties: Id=%d, Ports=%d, PRBs=%d", cell.id, cell.nof_ports, cell.nof_prb);
} }
return ret; return ret;
} }
@ -143,11 +142,11 @@ int srslte_enb_ul_set_cell(srslte_enb_ul_t* q,
int srslte_enb_ul_add_rnti(srslte_enb_ul_t* q, uint16_t rnti) int srslte_enb_ul_add_rnti(srslte_enb_ul_t* q, uint16_t rnti)
{ {
if (srslte_pucch_set_rnti(&q->pucch, rnti)) { if (srslte_pucch_set_rnti(&q->pucch, rnti)) {
ERROR("Error setting PUCCH rnti\n"); ERROR("Error setting PUCCH rnti");
return -1; return -1;
} }
if (srslte_pusch_set_rnti(&q->pusch, rnti)) { if (srslte_pusch_set_rnti(&q->pusch, rnti)) {
ERROR("Error setting PUSCH rnti\n"); ERROR("Error setting PUSCH rnti");
return -1; return -1;
} }
return 0; return 0;
@ -178,14 +177,14 @@ static int get_pucch(srslte_enb_ul_t* q, srslte_ul_sf_cfg_t* ul_sf, srslte_pucch
// Select format // Select format
cfg->format = srslte_pucch_proc_select_format(&q->cell, cfg, &cfg->uci_cfg, NULL); cfg->format = srslte_pucch_proc_select_format(&q->cell, cfg, &cfg->uci_cfg, NULL);
if (cfg->format == SRSLTE_PUCCH_FORMAT_ERROR) { if (cfg->format == SRSLTE_PUCCH_FORMAT_ERROR) {
ERROR("Returned Error while selecting PUCCH format\n"); ERROR("Returned Error while selecting PUCCH format");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Get possible resources // Get possible resources
int nof_resources = srslte_pucch_proc_get_resources(&q->cell, cfg, &cfg->uci_cfg, NULL, n_pucch_i); int nof_resources = srslte_pucch_proc_get_resources(&q->cell, cfg, &cfg->uci_cfg, NULL, n_pucch_i);
if (nof_resources < 1 || nof_resources > SRSLTE_PUCCH_CS_MAX_ACK) { if (nof_resources < 1 || nof_resources > SRSLTE_PUCCH_CS_MAX_ACK) {
ERROR("No PUCCH resource could be calculated (%d)\n", nof_resources); ERROR("No PUCCH resource could be calculated (%d)", nof_resources);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -201,16 +200,15 @@ static int get_pucch(srslte_enb_ul_t* q, srslte_ul_sf_cfg_t* ul_sf, srslte_pucch
// Prepare configuration // Prepare configuration
if (srslte_chest_ul_estimate_pucch(&q->chest, ul_sf, cfg, q->sf_symbols, &q->chest_res)) { if (srslte_chest_ul_estimate_pucch(&q->chest, ul_sf, cfg, q->sf_symbols, &q->chest_res)) {
ERROR("Error estimating PUCCH DMRS\n"); ERROR("Error estimating PUCCH DMRS");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
pucch_res.snr_db = q->chest_res.snr_db; pucch_res.snr_db = q->chest_res.snr_db;
ret = srslte_pucch_decode(&q->pucch, ul_sf, cfg, &q->chest_res, q->sf_symbols, &pucch_res); ret = srslte_pucch_decode(&q->pucch, ul_sf, cfg, &q->chest_res, q->sf_symbols, &pucch_res);
if (ret < SRSLTE_SUCCESS) { if (ret < SRSLTE_SUCCESS) {
ERROR("Error decoding PUCCH\n"); ERROR("Error decoding PUCCH");
} else { } else {
// Get PUCCH Format 1b with channel selection if: // Get PUCCH Format 1b with channel selection if:
// - At least one ACK bit needs to be received; and // - At least one ACK bit needs to be received; and
// - PUCCH Format 1b was used; and // - PUCCH Format 1b was used; and
@ -245,9 +243,8 @@ int srslte_enb_ul_get_pucch(srslte_enb_ul_t* q,
srslte_pucch_cfg_t* cfg, srslte_pucch_cfg_t* cfg,
srslte_pucch_res_t* res) srslte_pucch_res_t* res)
{ {
if (!srslte_pucch_cfg_isvalid(cfg, q->cell.nof_prb)) { if (!srslte_pucch_cfg_isvalid(cfg, q->cell.nof_prb)) {
ERROR("Invalid PUCCH configuration\n"); ERROR("Invalid PUCCH configuration");
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }

@ -69,7 +69,7 @@ __attribute__((constructor)) static void srslte_block_init()
void srslte_block_encode(const uint8_t* input, uint32_t input_len, uint8_t* output, uint32_t output_len) void srslte_block_encode(const uint8_t* input, uint32_t input_len, uint8_t* output, uint32_t output_len)
{ {
if (!input || !output) { if (!input || !output) {
ERROR("Invalid inputs\n"); ERROR("Invalid inputs");
return; return;
} }
@ -148,7 +148,7 @@ int32_t srslte_block_decode_i8(const int8_t* llr, uint32_t nof_llr, uint8_t* dat
// Return invalid inputs if data is not provided // Return invalid inputs if data is not provided
if (!llr || !data) { if (!llr || !data) {
ERROR("Invalid inputs\n"); ERROR("Invalid inputs");
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
@ -166,7 +166,7 @@ int32_t srslte_block_decode_i16(const int16_t* llr, uint32_t nof_llr, uint8_t* d
// Return invalid inputs if data is not provided // Return invalid inputs if data is not provided
if (!llr || !data) { if (!llr || !data) {
ERROR("Invalid inputs\n"); ERROR("Invalid inputs");
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }

@ -109,7 +109,7 @@ int test(uint32_t block_size)
double total_bits = (double)(block_size * nof_repetitions); double total_bits = (double)(block_size * nof_repetitions);
INFO("Block size %d PASSED! Encoder: %.1f us / %.1f Mbps; 16 bit Decoder: %.1f us / %.2f Mbps; 8 bit decoder: %.1f / " INFO("Block size %d PASSED! Encoder: %.1f us / %.1f Mbps; 16 bit Decoder: %.1f us / %.2f Mbps; 8 bit decoder: %.1f / "
"%.2f Mbps\n", "%.2f Mbps",
block_size, block_size,
t_encode_us / (double)nof_repetitions, t_encode_us / (double)nof_repetitions,
total_bits / (double)t_encode_us, total_bits / (double)t_encode_us,

@ -91,7 +91,7 @@ int srslte_cbsegm(srslte_cbsegm_t* s, uint32_t tbs)
s->L_tb = 24; // 24 bit CRC always s->L_tb = 24; // 24 bit CRC always
s->L_cb = 24; // 24 bit CRC always s->L_cb = 24; // 24 bit CRC always
s->F = s->C1 * s->K1 + s->C2 * s->K2 - Bp; s->F = s->C1 * s->K1 + s->C2 * s->K2 - Bp;
INFO("CB Segmentation: TBS: %d, C=%d, C+=%d K+=%d, C-=%d, K-=%d, F=%d, Bp=%d\n", INFO("CB Segmentation: TBS: %d, C=%d, C+=%d K+=%d, C-=%d, K-=%d, F=%d, Bp=%d",
tbs, tbs,
s->C, s->C,
s->C1, s->C1,
@ -162,7 +162,6 @@ static int cbsegm_ldpc_select_ls(uint32_t Kp, uint32_t K_b, uint32_t* Z_c, uint8
// If the lifting index is valid, save outputs and return // If the lifting index is valid, save outputs and return
if (i != VOID_LIFTSIZE) { if (i != VOID_LIFTSIZE) {
if (i_ls) { if (i_ls) {
*i_ls = i; *i_ls = i;
} }
@ -262,7 +261,7 @@ static int srslte_cbsegm_ldpc(srslte_cbsegm_t* s, srslte_basegraph_t bg, uint32_
s->K2 = 0; s->K2 = 0;
s->K2_idx = 0; s->K2_idx = 0;
INFO("LDPC CB Segmentation: TBS: %d, C=%d, K=%d, F=%d, Bp=%d\n", tbs, s->C, s->K1, s->F, Bp); INFO("LDPC CB Segmentation: TBS: %d, C=%d, K=%d, F=%d, Bp=%d", tbs, s->C, s->K1, s->F, Bp);
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }

@ -201,7 +201,6 @@ int main(int argc, char** argv)
errors_f = 0; errors_f = 0;
errors_sse = 0; errors_sse = 0;
while (frame_cnt < nof_frames) { while (frame_cnt < nof_frames) {
/* generate data_tx */ /* generate data_tx */
srslte_random_t random_gen = srslte_random_init(0); srslte_random_t random_gen = srslte_random_init(0);
for (int j = 0; j < frame_length; j++) { for (int j = 0; j < frame_length; j++) {
@ -283,7 +282,7 @@ int main(int argc, char** argv)
if (snr_points == 1) { if (snr_points == 1) {
int expected_e = get_expected_errors(nof_frames, seed, frame_length, tail_biting, ebno_db); int expected_e = get_expected_errors(nof_frames, seed, frame_length, tail_biting, ebno_db);
if (expected_e == -1) { if (expected_e == -1) {
ERROR("Test parameters not defined in test_results.h\n"); ERROR("Test parameters not defined in test_results.h");
exit(-1); exit(-1);
} else { } else {
printf( printf(

@ -216,7 +216,7 @@ int decode37_neon(void* o, uint8_t* symbols, uint8_t* data, uint32_t frame_lengt
uint32_t best_state; uint32_t best_state;
if (frame_length > q->framebits) { if (frame_length > q->framebits) {
ERROR("Initialized decoder for max frame length %d bits\n", q->framebits); ERROR("Initialized decoder for max frame length %d bits", q->framebits);
return -1; return -1;
} }
@ -294,7 +294,7 @@ int init37(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_bitin
} }
if ((q->ptr = create_viterbi37_port(poly, TB_ITER * framebits)) == NULL) { if ((q->ptr = create_viterbi37_port(poly, TB_ITER * framebits)) == NULL) {
ERROR("create_viterbi37 failed\n"); ERROR("create_viterbi37 failed");
free37(q); free37(q);
return -1; return -1;
} else { } else {
@ -338,7 +338,7 @@ int init37_sse(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_b
} }
if ((q->ptr = create_viterbi37_sse(poly, TB_ITER * framebits)) == NULL) { if ((q->ptr = create_viterbi37_sse(poly, TB_ITER * framebits)) == NULL) {
ERROR("create_viterbi37 failed\n"); ERROR("create_viterbi37 failed");
free37(q); free37(q);
return -1; return -1;
} else { } else {
@ -376,7 +376,7 @@ int init37_neon(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_
} }
if ((q->ptr = create_viterbi37_neon(poly, TB_ITER * framebits)) == NULL) { if ((q->ptr = create_viterbi37_neon(poly, TB_ITER * framebits)) == NULL) {
ERROR("create_viterbi37 failed\n"); ERROR("create_viterbi37 failed");
free37(q); free37(q);
return -1; return -1;
} else { } else {
@ -414,7 +414,7 @@ int init37_avx2(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_
} }
if ((q->ptr = create_viterbi37_avx2(poly, TB_ITER * framebits)) == NULL) { if ((q->ptr = create_viterbi37_avx2(poly, TB_ITER * framebits)) == NULL) {
ERROR("create_viterbi37 failed\n"); ERROR("create_viterbi37 failed");
free37(q); free37(q);
return -1; return -1;
} else { } else {
@ -452,7 +452,7 @@ int init37_avx2_16bit(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool
} }
// printf("pt0\n"); // printf("pt0\n");
if ((q->ptr = create_viterbi37_avx2_16bit(poly, TB_ITER * framebits)) == NULL) { if ((q->ptr = create_viterbi37_avx2_16bit(poly, TB_ITER * framebits)) == NULL) {
ERROR("create_viterbi37 failed\n"); ERROR("create_viterbi37 failed");
free37(q); free37(q);
return -1; return -1;
} else { } else {
@ -500,7 +500,7 @@ int srslte_viterbi_init(srslte_viterbi_t* q,
#endif #endif
#endif #endif
default: default:
ERROR("Decoder not implemented\n"); ERROR("Decoder not implemented");
return -1; return -1;
} }
} }
@ -540,7 +540,7 @@ int srslte_viterbi_decode_f(srslte_viterbi_t* q, float* symbols, uint8_t* data,
{ {
uint32_t len; uint32_t len;
if (frame_length > q->framebits) { if (frame_length > q->framebits) {
ERROR("Initialized decoder for max frame length %d bits\n", q->framebits); ERROR("Initialized decoder for max frame length %d bits", q->framebits);
return -1; return -1;
} }
if (q->tail_biting) { if (q->tail_biting) {
@ -572,7 +572,7 @@ int srslte_viterbi_decode_s(srslte_viterbi_t* q, int16_t* symbols, uint8_t* data
{ {
uint32_t len; uint32_t len;
if (frame_length > q->framebits) { if (frame_length > q->framebits) {
ERROR("Initialized decoder for max frame length %d bits\n", q->framebits); ERROR("Initialized decoder for max frame length %d bits", q->framebits);
return -1; return -1;
} }
if (q->tail_biting) { if (q->tail_biting) {

@ -36,7 +36,6 @@ static void gen_crc_table(srslte_crc_t* h)
uint64_t reversecrcbit(uint32_t crc, int nbits, srslte_crc_t* h) uint64_t reversecrcbit(uint32_t crc, int nbits, srslte_crc_t* h)
{ {
uint64_t m, rmask = 0x1; uint64_t m, rmask = 0x1;
for (m = 0; m < nbits; m++) { for (m = 0; m < nbits; m++) {
@ -50,7 +49,6 @@ uint64_t reversecrcbit(uint32_t crc, int nbits, srslte_crc_t* h)
int srslte_crc_set_init(srslte_crc_t* crc_par, uint64_t crc_init_value) int srslte_crc_set_init(srslte_crc_t* crc_par, uint64_t crc_init_value)
{ {
crc_par->crcinit = crc_init_value; crc_par->crcinit = crc_init_value;
if (crc_par->crcinit != (crc_par->crcinit & crc_par->crcmask)) { if (crc_par->crcinit != (crc_par->crcinit & crc_par->crcmask)) {
printf("ERROR(invalid crcinit in crc_set_init().\n"); printf("ERROR(invalid crcinit in crc_set_init().\n");
@ -61,7 +59,6 @@ int srslte_crc_set_init(srslte_crc_t* crc_par, uint64_t crc_init_value)
int srslte_crc_init(srslte_crc_t* h, uint32_t crc_poly, int crc_order) int srslte_crc_init(srslte_crc_t* h, uint32_t crc_poly, int crc_order)
{ {
// Set crc working default parameters // Set crc working default parameters
h->polynom = crc_poly; h->polynom = crc_poly;
h->order = crc_order; h->order = crc_order;
@ -72,7 +69,7 @@ int srslte_crc_init(srslte_crc_t* h, uint32_t crc_poly, int crc_order)
h->crchighbit = (uint64_t)1 << (h->order - 1); h->crchighbit = (uint64_t)1 << (h->order - 1);
if (srslte_crc_set_init(h, h->crcinit)) { if (srslte_crc_set_init(h, h->crcinit)) {
ERROR("Error setting CRC init word\n"); ERROR("Error setting CRC init word");
return -1; return -1;
} }

@ -4469,7 +4469,7 @@ int create_compact_pcm(uint16_t* pcm, int8_t (*positions)[MAX_CNCT], srslte_base
ls_index = get_ls_index(ls); ls_index = get_ls_index(ls);
if (ls_index == VOID_LIFTSIZE) { if (ls_index == VOID_LIFTSIZE) {
ERROR("Invalid lifting size %d\n", ls); ERROR("Invalid lifting size %d", ls);
return -1; return -1;
} }
const uint16_t* tmp = get_cnct_matrix(bg, ls_index); const uint16_t* tmp = get_cnct_matrix(bg, ls_index);

@ -55,13 +55,13 @@ static int decode_f(void* o, const float* llrs, uint8_t* message, uint32_t cdwd_
// We need at least q->bgK + 4 variable nodes to cover the high-rate region. However, // We need at least q->bgK + 4 variable nodes to cover the high-rate region. However,
// 2 variable nodes are systematically punctured by the encoder. // 2 variable nodes are systematically punctured by the encoder.
if (cdwd_rm_length < (q->bgK + 2) * q->ls) { if (cdwd_rm_length < (q->bgK + 2) * q->ls) {
// ERROR("The rate-matched codeword should have a length at least equal to the high-rate region.\n"); // ERROR("The rate-matched codeword should have a length at least equal to the high-rate region.");
cdwd_rm_length = (q->bgK + 2) * q->ls; cdwd_rm_length = (q->bgK + 2) * q->ls;
// return -1; // return -1;
} }
if (cdwd_rm_length % q->ls) { if (cdwd_rm_length % q->ls) {
cdwd_rm_length = (cdwd_rm_length / q->ls + 1) * q->ls; cdwd_rm_length = (cdwd_rm_length / q->ls + 1) * q->ls;
// ERROR("The rate-matched codeword length should be a multiple of the lifting size.\n"); // ERROR("The rate-matched codeword length should be a multiple of the lifting size.");
// return -1; // return -1;
} }
@ -98,7 +98,7 @@ static int init_f(srslte_ldpc_decoder_t* q)
q->free = free_dec_f; q->free = free_dec_f;
if ((q->ptr = create_ldpc_dec_f(q->bgN, q->bgM, q->ls, q->scaling_fctr)) == NULL) { if ((q->ptr = create_ldpc_dec_f(q->bgN, q->bgM, q->ls, q->scaling_fctr)) == NULL) {
ERROR("Create_ldpc_dec failed\n"); ERROR("Create_ldpc_dec failed");
free_dec_f(q); free_dec_f(q);
return -1; return -1;
} }
@ -133,13 +133,13 @@ static int decode_s(void* o, const int16_t* llrs, uint8_t* message, uint32_t cdw
// We need at least q->bgK + 4 variable nodes to cover the high-rate region. However, // We need at least q->bgK + 4 variable nodes to cover the high-rate region. However,
// 2 variable nodes are systematically punctured by the encoder. // 2 variable nodes are systematically punctured by the encoder.
if (cdwd_rm_length < (q->bgK + 2) * q->ls) { if (cdwd_rm_length < (q->bgK + 2) * q->ls) {
// ERROR("The rate-matched codeword should have a length at least equal to the high-rate region.\n"); // ERROR("The rate-matched codeword should have a length at least equal to the high-rate region.");
cdwd_rm_length = (q->bgK + 2) * q->ls; cdwd_rm_length = (q->bgK + 2) * q->ls;
// return -1; // return -1;
} }
if (cdwd_rm_length % q->ls) { if (cdwd_rm_length % q->ls) {
cdwd_rm_length = (cdwd_rm_length / q->ls + 1) * q->ls; cdwd_rm_length = (cdwd_rm_length / q->ls + 1) * q->ls;
// ERROR("The rate-matched codeword length should be a multiple of the lifting size.\n"); // ERROR("The rate-matched codeword length should be a multiple of the lifting size.");
// return -1; // return -1;
} }
@ -176,7 +176,7 @@ static int init_s(srslte_ldpc_decoder_t* q)
q->free = free_dec_s; q->free = free_dec_s;
if ((q->ptr = create_ldpc_dec_s(q->bgN, q->bgM, q->ls, q->scaling_fctr)) == NULL) { if ((q->ptr = create_ldpc_dec_s(q->bgN, q->bgM, q->ls, q->scaling_fctr)) == NULL) {
ERROR("Create_ldpc_dec failed\n"); ERROR("Create_ldpc_dec failed");
free_dec_s(q); free_dec_s(q);
return -1; return -1;
} }
@ -211,13 +211,13 @@ static int decode_c(void* o, const int8_t* llrs, uint8_t* message, uint32_t cdwd
// We need at least q->bgK + 4 variable nodes to cover the high-rate region. However, // We need at least q->bgK + 4 variable nodes to cover the high-rate region. However,
// 2 variable nodes are systematically punctured by the encoder. // 2 variable nodes are systematically punctured by the encoder.
if (cdwd_rm_length < (q->bgK + 2) * q->ls) { if (cdwd_rm_length < (q->bgK + 2) * q->ls) {
// ERROR("The rate-matched codeword should have a length at least equal to the high-rate region.\n"); // ERROR("The rate-matched codeword should have a length at least equal to the high-rate region.");
cdwd_rm_length = (q->bgK + 2) * q->ls; cdwd_rm_length = (q->bgK + 2) * q->ls;
// return -1; // return -1;
} }
if (cdwd_rm_length % q->ls) { if (cdwd_rm_length % q->ls) {
cdwd_rm_length = (cdwd_rm_length / q->ls + 1) * q->ls; cdwd_rm_length = (cdwd_rm_length / q->ls + 1) * q->ls;
// ERROR("The rate-matched codeword length should be a multiple of the lifting size.\n"); // ERROR("The rate-matched codeword length should be a multiple of the lifting size.");
// return -1; // return -1;
} }
@ -254,7 +254,7 @@ static int init_c(srslte_ldpc_decoder_t* q)
q->free = free_dec_c; q->free = free_dec_c;
if ((q->ptr = create_ldpc_dec_c(q->bgN, q->bgM, q->ls, q->scaling_fctr)) == NULL) { if ((q->ptr = create_ldpc_dec_c(q->bgN, q->bgM, q->ls, q->scaling_fctr)) == NULL) {
ERROR("Create_ldpc_dec failed\n"); ERROR("Create_ldpc_dec failed");
free_dec_c(q); free_dec_c(q);
return -1; return -1;
} }
@ -289,13 +289,13 @@ static int decode_c_flood(void* o, const int8_t* llrs, uint8_t* message, uint32_
// We need at least q->bgK + 4 variable nodes to cover the high-rate region. However, // We need at least q->bgK + 4 variable nodes to cover the high-rate region. However,
// 2 variable nodes are systematically punctured by the encoder. // 2 variable nodes are systematically punctured by the encoder.
if (cdwd_rm_length < (q->bgK + 2) * q->ls) { if (cdwd_rm_length < (q->bgK + 2) * q->ls) {
// ERROR("The rate-matched codeword should have a length at least equal to the high-rate region.\n"); // ERROR("The rate-matched codeword should have a length at least equal to the high-rate region.");
cdwd_rm_length = (q->bgK + 2) * q->ls; cdwd_rm_length = (q->bgK + 2) * q->ls;
// return -1; // return -1;
} }
if (cdwd_rm_length % q->ls) { if (cdwd_rm_length % q->ls) {
cdwd_rm_length = (cdwd_rm_length / q->ls + 1) * q->ls; cdwd_rm_length = (cdwd_rm_length / q->ls + 1) * q->ls;
// ERROR("The rate-matched codeword length should be a multiple of the lifting size.\n"); // ERROR("The rate-matched codeword length should be a multiple of the lifting size.");
// return -1; // return -1;
} }
init_ldpc_dec_c_flood(q->ptr, llrs, q->ls); init_ldpc_dec_c_flood(q->ptr, llrs, q->ls);
@ -332,7 +332,7 @@ static int init_c_flood(srslte_ldpc_decoder_t* q)
q->free = free_dec_c_flood; q->free = free_dec_c_flood;
if ((q->ptr = create_ldpc_dec_c_flood(q->bgN, q->bgM, q->ls, q->scaling_fctr)) == NULL) { if ((q->ptr = create_ldpc_dec_c_flood(q->bgN, q->bgM, q->ls, q->scaling_fctr)) == NULL) {
ERROR("Create_ldpc_dec failed\n"); ERROR("Create_ldpc_dec failed");
free_dec_c_flood(q); free_dec_c_flood(q);
return -1; return -1;
} }
@ -368,13 +368,13 @@ static int decode_c_avx2(void* o, const int8_t* llrs, uint8_t* message, uint32_t
// We need at least q->bgK + 4 variable nodes to cover the high-rate region. However, // We need at least q->bgK + 4 variable nodes to cover the high-rate region. However,
// 2 variable nodes are systematically punctured by the encoder. // 2 variable nodes are systematically punctured by the encoder.
if (cdwd_rm_length < (q->bgK + 2) * q->ls) { if (cdwd_rm_length < (q->bgK + 2) * q->ls) {
// ERROR("The rate-matched codeword should have a length at least equal to the high-rate region.\n"); // ERROR("The rate-matched codeword should have a length at least equal to the high-rate region.");
cdwd_rm_length = (q->bgK + 2) * q->ls; cdwd_rm_length = (q->bgK + 2) * q->ls;
// return -1; // return -1;
} }
if (cdwd_rm_length % q->ls) { if (cdwd_rm_length % q->ls) {
cdwd_rm_length = (cdwd_rm_length / q->ls + 1) * q->ls; cdwd_rm_length = (cdwd_rm_length / q->ls + 1) * q->ls;
// ERROR("The rate-matched codeword length should be a multiple of the lifting size.\n"); // ERROR("The rate-matched codeword length should be a multiple of the lifting size.");
// return -1; // return -1;
} }
init_ldpc_dec_c_avx2(q->ptr, llrs, q->ls); init_ldpc_dec_c_avx2(q->ptr, llrs, q->ls);
@ -410,7 +410,7 @@ static int init_c_avx2(srslte_ldpc_decoder_t* q)
q->free = free_dec_c_avx2; q->free = free_dec_c_avx2;
if ((q->ptr = create_ldpc_dec_c_avx2(q->bgN, q->bgM, q->ls, q->scaling_fctr)) == NULL) { if ((q->ptr = create_ldpc_dec_c_avx2(q->bgN, q->bgM, q->ls, q->scaling_fctr)) == NULL) {
ERROR("Create_ldpc_dec failed\n"); ERROR("Create_ldpc_dec failed");
free_dec_c_avx2(q); free_dec_c_avx2(q);
return -1; return -1;
} }
@ -446,13 +446,13 @@ static int decode_c_avx2long(void* o, const int8_t* llrs, uint8_t* message, uint
// We need at least q->bgK + 4 variable nodes to cover the high-rate region. However, // We need at least q->bgK + 4 variable nodes to cover the high-rate region. However,
// 2 variable nodes are systematically punctured by the encoder. // 2 variable nodes are systematically punctured by the encoder.
if (cdwd_rm_length < (q->bgK + 2) * q->ls) { if (cdwd_rm_length < (q->bgK + 2) * q->ls) {
// ERROR("The rate-matched codeword should have a length at least equal to the high-rate region.\n"); // ERROR("The rate-matched codeword should have a length at least equal to the high-rate region.");
cdwd_rm_length = (q->bgK + 2) * q->ls; cdwd_rm_length = (q->bgK + 2) * q->ls;
// return -1; // return -1;
} }
if (cdwd_rm_length % q->ls) { if (cdwd_rm_length % q->ls) {
cdwd_rm_length = (cdwd_rm_length / q->ls + 1) * q->ls; cdwd_rm_length = (cdwd_rm_length / q->ls + 1) * q->ls;
// ERROR("The rate-matched codeword length should be a multiple of the lifting size.\n"); // ERROR("The rate-matched codeword length should be a multiple of the lifting size.");
// return -1; // return -1;
} }
init_ldpc_dec_c_avx2long(q->ptr, llrs, q->ls); init_ldpc_dec_c_avx2long(q->ptr, llrs, q->ls);
@ -488,7 +488,7 @@ static int init_c_avx2long(srslte_ldpc_decoder_t* q)
q->free = free_dec_c_avx2long; q->free = free_dec_c_avx2long;
if ((q->ptr = create_ldpc_dec_c_avx2long(q->bgN, q->bgM, q->ls, q->scaling_fctr)) == NULL) { if ((q->ptr = create_ldpc_dec_c_avx2long(q->bgN, q->bgM, q->ls, q->scaling_fctr)) == NULL) {
ERROR("Create_ldpc_dec failed\n"); ERROR("Create_ldpc_dec failed");
free_dec_c_avx2long(q); free_dec_c_avx2long(q);
return -1; return -1;
} }
@ -524,13 +524,13 @@ static int decode_c_avx2_flood(void* o, const int8_t* llrs, uint8_t* message, ui
// We need at least q->bgK + 4 variable nodes to cover the high-rate region. However, // We need at least q->bgK + 4 variable nodes to cover the high-rate region. However,
// 2 variable nodes are systematically punctured by the encoder. // 2 variable nodes are systematically punctured by the encoder.
if (cdwd_rm_length < (q->bgK + 2) * q->ls) { if (cdwd_rm_length < (q->bgK + 2) * q->ls) {
// ERROR("The rate-matched codeword should have a length at least equal to the high-rate region.\n"); // ERROR("The rate-matched codeword should have a length at least equal to the high-rate region.");
cdwd_rm_length = (q->bgK + 2) * q->ls; cdwd_rm_length = (q->bgK + 2) * q->ls;
// return -1; // return -1;
} }
if (cdwd_rm_length % q->ls) { if (cdwd_rm_length % q->ls) {
cdwd_rm_length = (cdwd_rm_length / q->ls + 1) * q->ls; cdwd_rm_length = (cdwd_rm_length / q->ls + 1) * q->ls;
// ERROR("The rate-matched codeword length should be a multiple of the lifting size.\n"); // ERROR("The rate-matched codeword length should be a multiple of the lifting size.");
// return -1; // return -1;
} }
init_ldpc_dec_c_avx2_flood(q->ptr, llrs, q->ls); init_ldpc_dec_c_avx2_flood(q->ptr, llrs, q->ls);
@ -567,7 +567,7 @@ static int init_c_avx2_flood(srslte_ldpc_decoder_t* q)
q->free = free_dec_c_avx2_flood; q->free = free_dec_c_avx2_flood;
if ((q->ptr = create_ldpc_dec_c_avx2_flood(q->bgN, q->bgM, q->ls, q->scaling_fctr)) == NULL) { if ((q->ptr = create_ldpc_dec_c_avx2_flood(q->bgN, q->bgM, q->ls, q->scaling_fctr)) == NULL) {
ERROR("Create_ldpc_dec failed\n"); ERROR("Create_ldpc_dec failed");
free_dec_c_avx2_flood(q); free_dec_c_avx2_flood(q);
return -1; return -1;
} }
@ -604,13 +604,13 @@ static int decode_c_avx2long_flood(void* o, const int8_t* llrs, uint8_t* message
// We need at least q->bgK + 4 variable nodes to cover the high-rate region. However, // We need at least q->bgK + 4 variable nodes to cover the high-rate region. However,
// 2 variable nodes are systematically punctured by the encoder. // 2 variable nodes are systematically punctured by the encoder.
if (cdwd_rm_length < (q->bgK + 2) * q->ls) { if (cdwd_rm_length < (q->bgK + 2) * q->ls) {
// ERROR("The rate-matched codeword should have a length at least equal to the high-rate region.\n"); // ERROR("The rate-matched codeword should have a length at least equal to the high-rate region.");
cdwd_rm_length = (q->bgK + 2) * q->ls; cdwd_rm_length = (q->bgK + 2) * q->ls;
// return -1; // return -1;
} }
if (cdwd_rm_length % q->ls) { if (cdwd_rm_length % q->ls) {
cdwd_rm_length = (cdwd_rm_length / q->ls + 1) * q->ls; cdwd_rm_length = (cdwd_rm_length / q->ls + 1) * q->ls;
// ERROR("The rate-matched codeword length should be a multiple of the lifting size.\n"); // ERROR("The rate-matched codeword length should be a multiple of the lifting size.");
// return -1; // return -1;
} }
init_ldpc_dec_c_avx2long_flood(q->ptr, llrs, q->ls); init_ldpc_dec_c_avx2long_flood(q->ptr, llrs, q->ls);
@ -649,7 +649,7 @@ static int init_c_avx2long_flood(srslte_ldpc_decoder_t* q)
q->free = free_dec_c_avx2long_flood; q->free = free_dec_c_avx2long_flood;
if ((q->ptr = create_ldpc_dec_c_avx2long_flood(q->bgN, q->bgM, q->ls, q->scaling_fctr)) == NULL) { if ((q->ptr = create_ldpc_dec_c_avx2long_flood(q->bgN, q->bgM, q->ls, q->scaling_fctr)) == NULL) {
ERROR("Create_ldpc_dec failed\n"); ERROR("Create_ldpc_dec failed");
free_dec_c_avx2long(q); free_dec_c_avx2long(q);
return -1; return -1;
} }
@ -669,7 +669,7 @@ int srslte_ldpc_decoder_init(srslte_ldpc_decoder_t* q,
int ls_index = get_ls_index(ls); int ls_index = get_ls_index(ls);
if (ls_index == VOID_LIFTSIZE) { if (ls_index == VOID_LIFTSIZE) {
ERROR("Invalid lifting size %d\n", ls); ERROR("Invalid lifting size %d", ls);
return -1; return -1;
} }
@ -683,7 +683,7 @@ int srslte_ldpc_decoder_init(srslte_ldpc_decoder_t* q,
q->bgM = BG2M; q->bgM = BG2M;
break; break;
default: default:
ERROR("Base Graph BG%d does not exist\n", bg + 1); ERROR("Base Graph BG%d does not exist", bg + 1);
return -1; return -1;
} }
q->bg = bg; q->bg = bg;
@ -746,7 +746,7 @@ int srslte_ldpc_decoder_init(srslte_ldpc_decoder_t* q,
} }
#endif // LV_HAVE_AVX2 #endif // LV_HAVE_AVX2
default: default:
ERROR("Unknown decoder.\n"); ERROR("Unknown decoder.");
return -1; return -1;
} }
} }

@ -57,13 +57,13 @@ static int encode_c(void* o, const uint8_t* input, uint8_t* output, uint32_t inp
// We need at least q->bgK + 4 variable nodes to cover the high-rate region. However, // We need at least q->bgK + 4 variable nodes to cover the high-rate region. However,
// 2 variable nodes are systematically punctured by the encoder. // 2 variable nodes are systematically punctured by the encoder.
if (cdwd_rm_length < (q->bgK + 2) * q->ls) { if (cdwd_rm_length < (q->bgK + 2) * q->ls) {
// ERROR("The rate-matched codeword should have a length at least equal to the high-rate region.\n"); // ERROR("The rate-matched codeword should have a length at least equal to the high-rate region.");
cdwd_rm_length = (q->bgK + 2) * q->ls; cdwd_rm_length = (q->bgK + 2) * q->ls;
// return -1; // return -1;
} }
if (cdwd_rm_length % q->ls) { if (cdwd_rm_length % q->ls) {
cdwd_rm_length = (cdwd_rm_length / q->ls + 1) * q->ls; cdwd_rm_length = (cdwd_rm_length / q->ls + 1) * q->ls;
// ERROR("The rate-matched codeword length should be a multiple of the lifting size.\n"); // ERROR("The rate-matched codeword length should be a multiple of the lifting size.");
// return -1; // return -1;
} }
@ -92,7 +92,7 @@ static int init_c(srslte_ldpc_encoder_t* q)
int ls_index = get_ls_index(q->ls); int ls_index = get_ls_index(q->ls);
if (ls_index == VOID_LIFTSIZE) { if (ls_index == VOID_LIFTSIZE) {
ERROR("Invalid lifting size %d\n", q->ls); ERROR("Invalid lifting size %d", q->ls);
return -1; return -1;
} }
@ -105,7 +105,7 @@ static int init_c(srslte_ldpc_encoder_t* q)
} else if (q->bg == BG2 && (ls_index == 3 || ls_index == 7)) { } else if (q->bg == BG2 && (ls_index == 3 || ls_index == 7)) {
q->encode_high_rate = encode_high_rate_case4; q->encode_high_rate = encode_high_rate_case4;
} else { } else {
ERROR("Invalid lifting size %d and/or Base Graph %d\n", q->ls, q->bg + 1); ERROR("Invalid lifting size %d and/or Base Graph %d", q->ls, q->bg + 1);
return -1; return -1;
} }
@ -153,13 +153,13 @@ static int encode_avx2(void* o, const uint8_t* input, uint8_t* output, uint32_t
// We need at least q->bgK + 4 variable nodes to cover the high-rate region. However, // We need at least q->bgK + 4 variable nodes to cover the high-rate region. However,
// 2 variable nodes are systematically punctured by the encoder. // 2 variable nodes are systematically punctured by the encoder.
if (cdwd_rm_length < (q->bgK + 2) * q->ls) { if (cdwd_rm_length < (q->bgK + 2) * q->ls) {
// ERROR("The rate-matched codeword should have a length at least equal to the high-rate region.\n"); // ERROR("The rate-matched codeword should have a length at least equal to the high-rate region.");
cdwd_rm_length = (q->bgK + 2) * q->ls; cdwd_rm_length = (q->bgK + 2) * q->ls;
// return -1; // return -1;
} }
if (cdwd_rm_length % q->ls) { if (cdwd_rm_length % q->ls) {
cdwd_rm_length = (cdwd_rm_length / q->ls + 1) * q->ls; cdwd_rm_length = (cdwd_rm_length / q->ls + 1) * q->ls;
// ERROR("The rate-matched codeword length should be a multiple of the lifting size.\n"); // ERROR("The rate-matched codeword length should be a multiple of the lifting size.");
// return -1; // return -1;
} }
@ -186,7 +186,7 @@ static int init_avx2(srslte_ldpc_encoder_t* q)
int ls_index = get_ls_index(q->ls); int ls_index = get_ls_index(q->ls);
if (ls_index == VOID_LIFTSIZE) { if (ls_index == VOID_LIFTSIZE) {
ERROR("Invalid lifting size %d\n", q->ls); ERROR("Invalid lifting size %d", q->ls);
return -1; return -1;
} }
@ -199,7 +199,7 @@ static int init_avx2(srslte_ldpc_encoder_t* q)
} else if (q->bg == BG2 && (ls_index == 3 || ls_index == 7)) { } else if (q->bg == BG2 && (ls_index == 3 || ls_index == 7)) {
q->encode_high_rate_avx2 = encode_high_rate_case4_avx2; q->encode_high_rate_avx2 = encode_high_rate_case4_avx2;
} else { } else {
ERROR("Invalid lifting size %d and/or Base Graph %d\n", q->ls, q->bg + 1); ERROR("Invalid lifting size %d and/or Base Graph %d", q->ls, q->bg + 1);
return -1; return -1;
} }
@ -246,13 +246,13 @@ encode_avx2long(void* o, const uint8_t* input, uint8_t* output, uint32_t input_l
// We need at least q->bgK + 4 variable nodes to cover the high-rate region. However, // We need at least q->bgK + 4 variable nodes to cover the high-rate region. However,
// 2 variable nodes are systematically punctured by the encoder. // 2 variable nodes are systematically punctured by the encoder.
if (cdwd_rm_length < (q->bgK + 2) * q->ls) { if (cdwd_rm_length < (q->bgK + 2) * q->ls) {
// ERROR("The rate-matched codeword should have a length at least equal to the high-rate region.\n"); // ERROR("The rate-matched codeword should have a length at least equal to the high-rate region.");
cdwd_rm_length = (q->bgK + 2) * q->ls; cdwd_rm_length = (q->bgK + 2) * q->ls;
// return -1; // return -1;
} }
if (cdwd_rm_length % q->ls) { if (cdwd_rm_length % q->ls) {
cdwd_rm_length = (cdwd_rm_length / q->ls + 1) * q->ls; cdwd_rm_length = (cdwd_rm_length / q->ls + 1) * q->ls;
// ERROR("The rate-matched codeword length should be a multiple of the lifting size.\n"); // ERROR("The rate-matched codeword length should be a multiple of the lifting size.");
// return -1; // return -1;
} }
load_avx2long(q->ptr, input, q->bgK, q->bgN, q->ls); load_avx2long(q->ptr, input, q->bgK, q->bgN, q->ls);
@ -278,7 +278,7 @@ static int init_avx2long(srslte_ldpc_encoder_t* q)
int ls_index = get_ls_index(q->ls); int ls_index = get_ls_index(q->ls);
if (ls_index == VOID_LIFTSIZE) { if (ls_index == VOID_LIFTSIZE) {
ERROR("Invalid lifting size %d\n", q->ls); ERROR("Invalid lifting size %d", q->ls);
return -1; return -1;
} }
@ -291,7 +291,7 @@ static int init_avx2long(srslte_ldpc_encoder_t* q)
} else if (q->bg == BG2 && (ls_index == 3 || ls_index == 7)) { } else if (q->bg == BG2 && (ls_index == 3 || ls_index == 7)) {
q->encode_high_rate_avx2 = encode_high_rate_case4_avx2long; q->encode_high_rate_avx2 = encode_high_rate_case4_avx2long;
} else { } else {
ERROR("Invalid lifting size %d and/or Base Graph %d\n", q->ls, q->bg + 1); ERROR("Invalid lifting size %d and/or Base Graph %d", q->ls, q->bg + 1);
return -1; return -1;
} }
@ -315,7 +315,6 @@ int srslte_ldpc_encoder_init(srslte_ldpc_encoder_t* q,
srslte_basegraph_t bg, srslte_basegraph_t bg,
uint16_t ls) uint16_t ls)
{ {
switch (bg) { switch (bg) {
case BG1: case BG1:
q->bgN = BG1Nfull; q->bgN = BG1Nfull;
@ -326,7 +325,7 @@ int srslte_ldpc_encoder_init(srslte_ldpc_encoder_t* q,
q->bgM = BG2M; q->bgM = BG2M;
break; break;
default: default:
ERROR("Base Graph BG%d does not exist\n", bg + 1); ERROR("Base Graph BG%d does not exist", bg + 1);
return -1; return -1;
} }
q->bg = bg; q->bg = bg;

@ -121,13 +121,13 @@ static int init_rm(srslte_ldpc_rm_t* p,
// check E smaller than MAXE // check E smaller than MAXE
if ((E > MAXE) != 0) { // if ((E > MAXE) != 0) { //
ERROR("Wrong RM codeword length (E) = %d. It must be smaller than %d for base graph %d\n", E, MAXE, bg + 1); ERROR("Wrong RM codeword length (E) = %d. It must be smaller than %d for base graph %d", E, MAXE, bg + 1);
return -1; return -1;
} }
// check out_len is multiple of mod_order // check out_len is multiple of mod_order
if ((E % mod_order) != 0) { // N can only be a multiple of either BASEN[0] or BASEN[1], but not both if ((E % mod_order) != 0) { // N can only be a multiple of either BASEN[0] or BASEN[1], but not both
ERROR("Wrong RM codeword length (E) = %d. It must be a multiple of modulation order = %d\n", E, mod_order); ERROR("Wrong RM codeword length (E) = %d. It must be a multiple of modulation order = %d", E, mod_order);
return -1; return -1;
} }
@ -420,7 +420,6 @@ int srslte_ldpc_rm_tx_init(srslte_ldpc_rm_t* p)
int srslte_ldpc_rm_rx_init_f(srslte_ldpc_rm_t* p) int srslte_ldpc_rm_rx_init_f(srslte_ldpc_rm_t* p)
{ {
if (p == NULL) { if (p == NULL) {
return -1; return -1;
} }
@ -606,7 +605,6 @@ int srslte_ldpc_rm_rx_f(srslte_ldpc_rm_t* q,
const srslte_mod_t mod_type, const srslte_mod_t mod_type,
const uint32_t Nref) const uint32_t Nref)
{ {
if (init_rm(q, E, F, bg, ls, rv, mod_type, Nref) != 0) { if (init_rm(q, E, F, bg, ls, rv, mod_type, Nref) != 0) {
perror("rate matcher init"); perror("rate matcher init");
exit(-1); exit(-1);
@ -638,7 +636,6 @@ int srslte_ldpc_rm_rx_s(srslte_ldpc_rm_t* q,
const srslte_mod_t mod_type, const srslte_mod_t mod_type,
const uint32_t Nref) const uint32_t Nref)
{ {
if (init_rm(q, E, F, bg, ls, rv, mod_type, Nref) != 0) { if (init_rm(q, E, F, bg, ls, rv, mod_type, Nref) != 0) {
perror("rate matcher init"); perror("rate matcher init");
exit(-1); exit(-1);
@ -671,7 +668,6 @@ int srslte_ldpc_rm_rx_c(srslte_ldpc_rm_t* q,
const srslte_mod_t mod_type, const srslte_mod_t mod_type,
const uint32_t Nref) const uint32_t Nref)
{ {
if (init_rm(q, E, F, bg, ls, rv, mod_type, Nref) != 0) { if (init_rm(q, E, F, bg, ls, rv, mod_type, Nref) != 0) {
perror("rate matcher init"); perror("rate matcher init");
exit(-1); exit(-1);

@ -74,7 +74,6 @@ int cmpfunc(const void* a, const void* b)
return -1; return -1;
} }
if (ai > bi) { if (ai > bi) {
return 1; return 1;
} }
@ -87,17 +86,16 @@ int cmpfunc(const void* a, const void* b)
*/ */
int get_code_params(srslte_polar_code_t* c, const uint16_t K, const uint16_t E, const uint8_t nMax) int get_code_params(srslte_polar_code_t* c, const uint16_t K, const uint16_t E, const uint8_t nMax)
{ {
// include here also npc and nwmPC computatoins // include here also npc and nwmPC computatoins
if (E > EMAX) { if (E > EMAX) {
ERROR("Rate-matched codeword size (E) not supported. Chose E<=8192\n"); ERROR("Rate-matched codeword size (E) not supported. Chose E<=8192");
return -1; return -1;
} }
switch (nMax) { switch (nMax) {
case 9: // downlink case 9: // downlink
// iil = true // iil = true
if (K < 36 || K > 164) { if (K < 36 || K > 164) {
ERROR("Codeblock length (K=%d) not supported for downlink transmission, choose 165 > K > 35\n", K); ERROR("Codeblock length (K=%d) not supported for downlink transmission, choose 165 > K > 35", K);
return -1; return -1;
} }
break; break;
@ -105,13 +103,13 @@ int get_code_params(srslte_polar_code_t* c, const uint16_t K, const uint16_t E,
// iil = false // iil = false
if (K < 18 || (K > 25 && K < 31) || K > 1023) { if (K < 18 || (K > 25 && K < 31) || K > 1023) {
ERROR("Codeblock length (K=%d) not supported for uplink transmission, choose K > 17 and K < 1024, " ERROR("Codeblock length (K=%d) not supported for uplink transmission, choose K > 17 and K < 1024, "
"excluding 31 > K > 25\n", "excluding 31 > K > 25",
K); K);
return -1; return -1;
} }
break; break;
default: default:
ERROR("nMax not supported choose 9 for downlink and 10 for uplink transmissions\n"); ERROR("nMax not supported choose 9 for downlink and 10 for uplink transmissions");
return -1; return -1;
} }
// number of parity check bits (nPC) and parity check bits of minimum bandwidth nWmPC // number of parity check bits (nPC) and parity check bits of minimum bandwidth nWmPC
@ -125,7 +123,7 @@ int get_code_params(srslte_polar_code_t* c, const uint16_t K, const uint16_t E,
} }
if (K + nPC >= E) { if (K + nPC >= E) {
ERROR(" Rate-matched codeword length (E) not supported, choose E > %d\n", K + nPC); ERROR(" Rate-matched codeword length (E) not supported, choose E > %d", K + nPC);
return -1; return -1;
} }
@ -173,7 +171,7 @@ int get_code_params(srslte_polar_code_t* c, const uint16_t K, const uint16_t E,
uint16_t N = (1U << n); uint16_t N = (1U << n);
if (K >= N) { if (K >= N) {
ERROR("Codeblock length (K) not supported, choose K < N\n"); ERROR("Codeblock length (K) not supported, choose K < N");
return -1; return -1;
} }
@ -213,7 +211,6 @@ int srslte_polar_code_init(srslte_polar_code_t* c)
int srslte_polar_code_get(srslte_polar_code_t* c, uint16_t K, uint16_t E, uint8_t nMax) int srslte_polar_code_get(srslte_polar_code_t* c, uint16_t K, uint16_t E, uint8_t nMax)
{ {
if (c == NULL) { if (c == NULL) {
return -1; return -1;
} }

@ -142,7 +142,7 @@ static int init_ssc_f(srslte_polar_decoder_t* q)
q->free = free_ssc_f; q->free = free_ssc_f;
if ((q->ptr = create_polar_decoder_ssc_f(q->nMax)) == NULL) { if ((q->ptr = create_polar_decoder_ssc_f(q->nMax)) == NULL) {
ERROR("create_polar_decoder_ssc_f failed\n"); ERROR("create_polar_decoder_ssc_f failed");
free_ssc_f(q); free_ssc_f(q);
return -1; return -1;
} }
@ -156,7 +156,7 @@ static int init_ssc_s(srslte_polar_decoder_t* q)
q->free = free_ssc_s; q->free = free_ssc_s;
if ((q->ptr = create_polar_decoder_ssc_s(q->nMax)) == NULL) { if ((q->ptr = create_polar_decoder_ssc_s(q->nMax)) == NULL) {
ERROR("create_polar_decoder_ssc_s failed\n"); ERROR("create_polar_decoder_ssc_s failed");
free_ssc_s(q); free_ssc_s(q);
return -1; return -1;
} }
@ -170,7 +170,7 @@ static int init_ssc_c(srslte_polar_decoder_t* q)
q->free = free_ssc_c; q->free = free_ssc_c;
if ((q->ptr = create_polar_decoder_ssc_c(q->nMax)) == NULL) { if ((q->ptr = create_polar_decoder_ssc_c(q->nMax)) == NULL) {
ERROR("create_polar_decoder_ssc_c failed\n"); ERROR("create_polar_decoder_ssc_c failed");
free_ssc_c(q); free_ssc_c(q);
return -1; return -1;
} }
@ -186,7 +186,7 @@ static int init_ssc_c_avx2(srslte_polar_decoder_t* q)
q->free = free_ssc_c_avx2; q->free = free_ssc_c_avx2;
if ((q->ptr = create_polar_decoder_ssc_c_avx2(q->nMax)) == NULL) { if ((q->ptr = create_polar_decoder_ssc_c_avx2(q->nMax)) == NULL) {
ERROR("create_polar_decoder_ssc_c failed\n"); ERROR("create_polar_decoder_ssc_c failed");
free_ssc_c_avx2(q); free_ssc_c_avx2(q);
return -1; return -1;
} }
@ -209,7 +209,7 @@ int srslte_polar_decoder_init(srslte_polar_decoder_t* q, srslte_polar_decoder_ty
return init_ssc_c_avx2(q); return init_ssc_c_avx2(q);
#endif #endif
default: default:
ERROR("Decoder not implemented\n"); ERROR("Decoder not implemented");
return -1; return -1;
} }
return 0; return 0;

@ -100,13 +100,13 @@ int main(int argc, char** argv)
// generate CRC word // generate CRC word
crc_word = srslte_crc_checksum(&crc_p, data, num_bits); crc_word = srslte_crc_checksum(&crc_p, data, num_bits);
INFO("checksum=%x\n", crc_word); INFO("checksum=%x", crc_word);
free(data); free(data);
// check if generated word is as expected // check if generated word is as expected
if (get_expected_word(num_bits, crc_length, crc_poly, seed, &expected_word)) { if (get_expected_word(num_bits, crc_length, crc_poly, seed, &expected_word)) {
ERROR("Test parameters not defined in test_results.h\n"); ERROR("Test parameters not defined in test_results.h");
exit(-1); exit(-1);
} }
exit(expected_word != crc_word); exit(expected_word != crc_word);

@ -33,7 +33,6 @@ uint8_t RM_PERM_CC_INV[NCOLS] = {16, 0, 24, 8, 20, 4, 28, 12, 18, 2, 26, 10, 22,
*/ */
int srslte_rm_conv_tx(uint8_t* input, uint32_t in_len, uint8_t* output, uint32_t out_len) int srslte_rm_conv_tx(uint8_t* input, uint32_t in_len, uint8_t* output, uint32_t out_len)
{ {
uint8_t tmp[3 * NCOLS * NROWS_MAX]; uint8_t tmp[3 * NCOLS * NROWS_MAX];
int nrows, ndummy, K_p; int nrows, ndummy, K_p;
@ -41,7 +40,7 @@ int srslte_rm_conv_tx(uint8_t* input, uint32_t in_len, uint8_t* output, uint32_t
nrows = (uint32_t)(in_len / 3 - 1) / NCOLS + 1; nrows = (uint32_t)(in_len / 3 - 1) / NCOLS + 1;
if (nrows > NROWS_MAX) { if (nrows > NROWS_MAX) {
ERROR("Input too large. Max input length is %d\n", 3 * NCOLS * NROWS_MAX); ERROR("Input too large. Max input length is %d", 3 * NCOLS * NROWS_MAX);
return -1; return -1;
} }
K_p = nrows * NCOLS; K_p = nrows * NCOLS;
@ -84,7 +83,6 @@ int srslte_rm_conv_tx(uint8_t* input, uint32_t in_len, uint8_t* output, uint32_t
*/ */
int srslte_rm_conv_rx(float* input, uint32_t in_len, float* output, uint32_t out_len) int srslte_rm_conv_rx(float* input, uint32_t in_len, float* output, uint32_t out_len)
{ {
int nrows, ndummy, K_p; int nrows, ndummy, K_p;
int i, j, k; int i, j, k;
int d_i, d_j; int d_i, d_j;
@ -93,7 +91,7 @@ int srslte_rm_conv_rx(float* input, uint32_t in_len, float* output, uint32_t out
nrows = (uint32_t)(out_len / 3 - 1) / NCOLS + 1; nrows = (uint32_t)(out_len / 3 - 1) / NCOLS + 1;
if (nrows > NROWS_MAX) { if (nrows > NROWS_MAX) {
ERROR("Output too large. Max output length is %d\n", 3 * NCOLS * NROWS_MAX); ERROR("Output too large. Max output length is %d", 3 * NCOLS * NROWS_MAX);
return -1; return -1;
} }
K_p = nrows * NCOLS; K_p = nrows * NCOLS;
@ -151,7 +149,6 @@ int srslte_rm_conv_rx(float* input, uint32_t in_len, float* output, uint32_t out
*/ */
int srslte_rm_conv_rx_s(int16_t* input, uint32_t in_len, int16_t* output, uint32_t out_len) int srslte_rm_conv_rx_s(int16_t* input, uint32_t in_len, int16_t* output, uint32_t out_len)
{ {
int nrows, ndummy, K_p; int nrows, ndummy, K_p;
int i, j, k; int i, j, k;
int d_i, d_j; int d_i, d_j;
@ -160,7 +157,7 @@ int srslte_rm_conv_rx_s(int16_t* input, uint32_t in_len, int16_t* output, uint32
nrows = (uint32_t)(out_len / 3 - 1) / NCOLS + 1; nrows = (uint32_t)(out_len / 3 - 1) / NCOLS + 1;
if (nrows > NROWS_MAX) { if (nrows > NROWS_MAX) {
ERROR("Output too large. Max output length is %d\n", 3 * NCOLS * NROWS_MAX); ERROR("Output too large. Max output length is %d", 3 * NCOLS * NROWS_MAX);
return -1; return -1;
} }
K_p = nrows * NCOLS; K_p = nrows * NCOLS;

@ -84,7 +84,7 @@ int deinter_table_idx_from_sb_len(uint32_t nof_subblocks)
} }
} }
if (nof_subblocks != 0) { if (nof_subblocks != 0) {
ERROR("Error number of sub-blocks %d not supported in RM\n", nof_subblocks); ERROR("Error number of sub-blocks %d not supported in RM", nof_subblocks);
} }
return -1; return -1;
} }
@ -95,7 +95,6 @@ static uint16_t temp_table1[3 * 6176], temp_table2[3 * 6176];
static void srslte_rm_turbo_gentable_systematic(uint16_t* table_bits, int k0_vec_[4][2], uint32_t nrows, int ndummy) static void srslte_rm_turbo_gentable_systematic(uint16_t* table_bits, int k0_vec_[4][2], uint32_t nrows, int ndummy)
{ {
bool last_is_null = true; bool last_is_null = true;
int k_b = 0, buff_idx = 0; int k_b = 0, buff_idx = 0;
for (int j = 0; j < NCOLS; j++) { for (int j = 0; j < NCOLS; j++) {
@ -122,7 +121,6 @@ static void srslte_rm_turbo_gentable_systematic(uint16_t* table_bits, int k0_vec
static void static void
srslte_rm_turbo_gentable_parity(uint16_t* table_parity, int k0_vec_[4][2], int offset, uint16_t nrows, int ndummy) srslte_rm_turbo_gentable_parity(uint16_t* table_parity, int k0_vec_[4][2], int offset, uint16_t nrows, int ndummy)
{ {
bool last_is_null = true; bool last_is_null = true;
int k_b = 0, buff_idx0 = 0; int k_b = 0, buff_idx0 = 0;
int K_p = nrows * NCOLS; int K_p = nrows * NCOLS;
@ -167,7 +165,6 @@ srslte_rm_turbo_gentable_parity(uint16_t* table_parity, int k0_vec_[4][2], int o
static void srslte_rm_turbo_gentable_receive(uint16_t* table, uint32_t cb_len, uint32_t rv_idx) static void srslte_rm_turbo_gentable_receive(uint16_t* table, uint32_t cb_len, uint32_t rv_idx)
{ {
int nrows = (uint32_t)(cb_len / 3 - 1) / NCOLS + 1; int nrows = (uint32_t)(cb_len / 3 - 1) / NCOLS + 1;
int ndummy = nrows * NCOLS - cb_len / 3; int ndummy = nrows * NCOLS - cb_len / 3;
if (ndummy < 0) { if (ndummy < 0) {
@ -258,7 +255,6 @@ static void interleave_table_sb(uint16_t* in, uint16_t* out, uint32_t cb_idx, ui
for (int i = 0; i < out_len; i++) { for (int i = 0; i < out_len; i++) {
// Do not change tail bit order // Do not change tail bit order
if (in[i] < 3 * long_cb) { if (in[i] < 3 * long_cb) {
// align to 32 bytes (warning: must be same alignment as in rm_turbo.c) // align to 32 bytes (warning: must be same alignment as in rm_turbo.c)
out[i] = (in[i] % 3) * (long_cb + 32) + inter(in[i] / 3, nof_sb); out[i] = (in[i] % 3) * (long_cb + 32) + inter(in[i] / 3, nof_sb);
} else { } else {
@ -346,14 +342,11 @@ int srslte_rm_turbo_tx_lut(uint8_t* w_buff,
uint32_t w_offset, uint32_t w_offset,
uint32_t rv_idx) uint32_t rv_idx)
{ {
if (rv_idx < 4 && cb_idx < SRSLTE_NOF_TC_CB_SIZES) { if (rv_idx < 4 && cb_idx < SRSLTE_NOF_TC_CB_SIZES) {
int in_len = 3 * srslte_cbsegm_cbsize(cb_idx) + 12; int in_len = 3 * srslte_cbsegm_cbsize(cb_idx) + 12;
/* Sub-block interleaver (5.1.4.1.1) and bit collection */ /* Sub-block interleaver (5.1.4.1.1) and bit collection */
if (rv_idx == 0) { if (rv_idx == 0) {
// Systematic bits // Systematic bits
// srslte_bit_interleave(systematic, w_buff, interleaver_systematic_bits[cb_idx], in_len/3); // srslte_bit_interleave(systematic, w_buff, interleaver_systematic_bits[cb_idx], in_len/3);
srslte_bit_interleaver_run(&bit_interleavers_systematic_bits[cb_idx], systematic, w_buff, 0); srslte_bit_interleaver_run(&bit_interleavers_systematic_bits[cb_idx], systematic, w_buff, 0);
@ -405,9 +398,7 @@ int srslte_rm_turbo_rx_lut_(int16_t* input,
uint32_t rv_idx, uint32_t rv_idx,
bool enable_input_tdec) bool enable_input_tdec)
{ {
if (rv_idx < 4 && cb_idx < SRSLTE_NOF_TC_CB_SIZES) { if (rv_idx < 4 && cb_idx < SRSLTE_NOF_TC_CB_SIZES) {
#if SRSLTE_TDEC_EXPECT_INPUT_SB == 1 #if SRSLTE_TDEC_EXPECT_INPUT_SB == 1
int cb_len = srslte_cbsegm_cbsize(cb_idx); int cb_len = srslte_cbsegm_cbsize(cb_idx);
int idx = deinter_table_idx_from_sb_len(srslte_tdec_autoimp_get_subblocks(cb_len)); int idx = deinter_table_idx_from_sb_len(srslte_tdec_autoimp_get_subblocks(cb_len));
@ -417,7 +408,7 @@ int srslte_rm_turbo_rx_lut_(int16_t* input,
} else if (idx < NOF_DEINTER_TABLE_SB_IDX) { } else if (idx < NOF_DEINTER_TABLE_SB_IDX) {
deinter = deinterleaver_sb[idx][cb_idx][rv_idx]; deinter = deinterleaver_sb[idx][cb_idx][rv_idx];
} else { } else {
ERROR("Sub-block size index %d not supported in srslte_rm_turbo_rx_lut()\n", idx); ERROR("Sub-block size index %d not supported in srslte_rm_turbo_rx_lut()", idx);
return -1; return -1;
} }
#else #else
@ -447,7 +438,6 @@ int srslte_rm_turbo_rx_lut_(int16_t* input,
int srslte_rm_turbo_rx_lut_8bit(int8_t* input, int8_t* output, uint32_t in_len, uint32_t cb_idx, uint32_t rv_idx) int srslte_rm_turbo_rx_lut_8bit(int8_t* input, int8_t* output, uint32_t in_len, uint32_t cb_idx, uint32_t rv_idx)
{ {
if (rv_idx < 4 && cb_idx < SRSLTE_NOF_TC_CB_SIZES) { if (rv_idx < 4 && cb_idx < SRSLTE_NOF_TC_CB_SIZES) {
#if SRSLTE_TDEC_EXPECT_INPUT_SB == 1 #if SRSLTE_TDEC_EXPECT_INPUT_SB == 1
int cb_len = srslte_cbsegm_cbsize(cb_idx); int cb_len = srslte_cbsegm_cbsize(cb_idx);
int idx = deinter_table_idx_from_sb_len(srslte_tdec_autoimp_get_subblocks_8bit(cb_len)); int idx = deinter_table_idx_from_sb_len(srslte_tdec_autoimp_get_subblocks_8bit(cb_len));
@ -457,7 +447,7 @@ int srslte_rm_turbo_rx_lut_8bit(int8_t* input, int8_t* output, uint32_t in_len,
} else if (idx < NOF_DEINTER_TABLE_SB_IDX) { } else if (idx < NOF_DEINTER_TABLE_SB_IDX) {
deinter = deinterleaver_sb[idx][cb_idx][rv_idx]; deinter = deinterleaver_sb[idx][cb_idx][rv_idx];
} else { } else {
ERROR("Sub-block size index %d not supported in srslte_rm_turbo_rx_lut()\n", idx); ERROR("Sub-block size index %d not supported in srslte_rm_turbo_rx_lut()", idx);
return -1; return -1;
} }
#else #else
@ -987,7 +977,6 @@ int srslte_rm_turbo_tx(uint8_t* w_buff,
uint32_t out_len, uint32_t out_len,
uint32_t rv_idx) uint32_t rv_idx)
{ {
int ndummy, kidx; int ndummy, kidx;
int nrows, K_p; int nrows, K_p;
@ -1078,7 +1067,6 @@ int srslte_rm_turbo_rx(float* w_buff,
uint32_t rv_idx, uint32_t rv_idx,
uint32_t nof_filler_bits) uint32_t nof_filler_bits)
{ {
int nrows, ndummy, K_p, k0, N_cb, jp, kidx; int nrows, ndummy, K_p, k0, N_cb, jp, kidx;
int i, j, k; int i, j, k;
int d_i, d_j; int d_i, d_j;
@ -1087,7 +1075,7 @@ int srslte_rm_turbo_rx(float* w_buff,
nrows = (uint16_t)(out_len / 3 - 1) / NCOLS + 1; nrows = (uint16_t)(out_len / 3 - 1) / NCOLS + 1;
K_p = nrows * NCOLS; K_p = nrows * NCOLS;
if (3 * K_p > w_buff_len) { if (3 * K_p > w_buff_len) {
ERROR("Output too large. Max output length including dummy bits is %d (3x%dx32, in_len %d)\n", ERROR("Output too large. Max output length including dummy bits is %d (3x%dx32, in_len %d)",
w_buff_len, w_buff_len,
nrows, nrows,
out_len); out_len);
@ -1095,7 +1083,7 @@ int srslte_rm_turbo_rx(float* w_buff,
} }
if (out_len < 3) { if (out_len < 3) {
ERROR("Error minimum input length for rate matching is 3\n"); ERROR("Error minimum input length for rate matching is 3");
return -1; return -1;
} }

@ -63,13 +63,13 @@ int srslte_tc_interl_LTE_gen_interl(srslte_tc_interl_t* h, uint32_t long_cb, uin
uint64_t i, j; uint64_t i, j;
if (long_cb > h->max_long_cb) { if (long_cb > h->max_long_cb) {
ERROR("Interleaver initiated for max_long_cb=%d\n", h->max_long_cb); ERROR("Interleaver initiated for max_long_cb=%d", h->max_long_cb);
return -1; return -1;
} }
cb_table_idx = srslte_cbsegm_cbindex(long_cb); cb_table_idx = srslte_cbsegm_cbindex(long_cb);
if (cb_table_idx == -1) { if (cb_table_idx == -1) {
ERROR("Can't find long_cb=%d in valid TC CB table\n", long_cb); ERROR("Can't find long_cb=%d in valid TC CB table", long_cb);
return -1; return -1;
} }

@ -88,7 +88,7 @@ int srslte_tc_interl_UMTS_gen(srslte_tc_interl_t* h, uint32_t long_cb)
M_long = long_cb; M_long = long_cb;
if (long_cb > h->max_long_cb) { if (long_cb > h->max_long_cb) {
ERROR("Interleaver initiated for max_long_cb=%d\n", h->max_long_cb); ERROR("Interleaver initiated for max_long_cb=%d", h->max_long_cb);
return -1; return -1;
} }

@ -180,7 +180,7 @@ int main(int argc, char** argv)
} }
if (srslte_tcod_init(&tcod, frame_length)) { if (srslte_tcod_init(&tcod, frame_length)) {
ERROR("Error initiating Turbo coder\n"); ERROR("Error initiating Turbo coder");
exit(-1); exit(-1);
} }
@ -190,7 +190,7 @@ int main(int argc, char** argv)
// tdec_type = SRSLTE_TDEC_SSE_WINDOW; // tdec_type = SRSLTE_TDEC_SSE_WINDOW;
#endif #endif
if (srslte_tdec_init_manual(&tdec, frame_length, tdec_type)) { if (srslte_tdec_init_manual(&tdec, frame_length, tdec_type)) {
ERROR("Error initiating Turbo decoder\n"); ERROR("Error initiating Turbo decoder");
exit(-1); exit(-1);
} }
@ -211,7 +211,6 @@ int main(int argc, char** argv)
snr_points = 1; snr_points = 1;
} }
for (i = 0; i < snr_points; i++) { for (i = 0; i < snr_points; i++) {
mean_usec = 0; mean_usec = 0;
errors = 0; errors = 0;
frame_cnt = 0; frame_cnt = 0;

@ -39,7 +39,6 @@ static bool table_initiated = false;
int srslte_tcod_init(srslte_tcod_t* h, uint32_t max_long_cb) int srslte_tcod_init(srslte_tcod_t* h, uint32_t max_long_cb)
{ {
h->max_long_cb = max_long_cb; h->max_long_cb = max_long_cb;
h->temp = srslte_vec_malloc(max_long_cb / 8); h->temp = srslte_vec_malloc(max_long_cb / 8);
@ -68,7 +67,6 @@ void srslte_tcod_free(srslte_tcod_t* h)
/* Expects bits (1 byte = 1 bit) and produces bits. The systematic and parity bits are interlaced in the output */ /* Expects bits (1 byte = 1 bit) and produces bits. The systematic and parity bits are interlaced in the output */
int srslte_tcod_encode(srslte_tcod_t* h, uint8_t* input, uint8_t* output, uint32_t long_cb) int srslte_tcod_encode(srslte_tcod_t* h, uint8_t* input, uint8_t* output, uint32_t long_cb)
{ {
uint8_t reg1_0, reg1_1, reg1_2, reg2_0, reg2_1, reg2_2; uint8_t reg1_0, reg1_1, reg1_2, reg2_0, reg2_1, reg2_2;
uint32_t i, k = 0, j; uint32_t i, k = 0, j;
uint8_t bit; uint8_t bit;
@ -76,13 +74,13 @@ int srslte_tcod_encode(srslte_tcod_t* h, uint8_t* input, uint8_t* output, uint32
uint16_t* per; uint16_t* per;
if (long_cb > h->max_long_cb) { if (long_cb > h->max_long_cb) {
ERROR("Turbo coder initiated for max_long_cb=%d\n", h->max_long_cb); ERROR("Turbo coder initiated for max_long_cb=%d", h->max_long_cb);
return -1; return -1;
} }
int longcb_idx = srslte_cbsegm_cbindex(long_cb); int longcb_idx = srslte_cbsegm_cbindex(long_cb);
if (longcb_idx < 0) { if (longcb_idx < 0) {
ERROR("Invalid CB size %d\n", long_cb); ERROR("Invalid CB size %d", long_cb);
return -1; return -1;
} }
@ -190,7 +188,7 @@ int srslte_tcod_encode_lut(srslte_tcod_t* h,
uint32_t long_cb = (uint32_t)srslte_cbsegm_cbsize(cblen_idx); uint32_t long_cb = (uint32_t)srslte_cbsegm_cbsize(cblen_idx);
if (long_cb % 8) { if (long_cb % 8) {
ERROR("Turbo coder LUT implementation long_cb must be multiple of 8\n"); ERROR("Turbo coder LUT implementation long_cb must be multiple of 8");
return -1; return -1;
} }
@ -367,14 +365,14 @@ void srslte_tcod_gentable()
srslte_tc_interl_t interl; srslte_tc_interl_t interl;
if (srslte_tc_interl_init(&interl, 6144)) { if (srslte_tc_interl_init(&interl, 6144)) {
ERROR("Error initiating interleave\n"); ERROR("Error initiating interleave");
return; return;
} }
for (uint32_t len = 0; len < 188; len++) { for (uint32_t len = 0; len < 188; len++) {
uint32_t long_cb = srslte_cbsegm_cbsize(len); uint32_t long_cb = srslte_cbsegm_cbsize(len);
if (srslte_tc_interl_LTE_gen(&interl, long_cb)) { if (srslte_tc_interl_LTE_gen(&interl, long_cb)) {
ERROR("Error initiating TC interleaver for long_cb=%d\n", long_cb); ERROR("Error initiating TC interleaver for long_cb=%d", long_cb);
return; return;
} }
// Save fw/bw permutation tables // Save fw/bw permutation tables
@ -389,7 +387,6 @@ void srslte_tcod_gentable()
// Compute state transitions // Compute state transitions
for (uint32_t state = 0; state < 8; state++) { for (uint32_t state = 0; state < 8; state++) {
for (uint32_t data = 0; data < 256; data++) { for (uint32_t data = 0; data < 256; data++) {
uint8_t reg_0, reg_1, reg_2; uint8_t reg_0, reg_1, reg_2;
reg_0 = (state & 4) >> 2; reg_0 = (state & 4) >> 2;
reg_1 = (state & 2) >> 1; reg_1 = (state & 2) >> 1;

@ -187,7 +187,7 @@ int srslte_tdec_init_manual(srslte_tdec_t* h, uint32_t max_long_cb, srslte_tdec_
break; break;
#endif /* LV_HAVE_AVX2 */ #endif /* LV_HAVE_AVX2 */
default: default:
ERROR("Error decoder %d not supported\n", dec_type); ERROR("Error decoder %d not supported", dec_type);
goto clean_and_exit; goto clean_and_exit;
} }
@ -394,7 +394,7 @@ static int tdec_sb_idx(uint32_t long_cb)
case 0: case 0:
return AUTO_16_SSE; return AUTO_16_SSE;
} }
ERROR("Error in tdec_sb_idx() invalid nof_sb=%d\n", nof_sb); ERROR("Error in tdec_sb_idx() invalid nof_sb=%d", nof_sb);
return 0; return 0;
} }
@ -427,7 +427,7 @@ static int tdec_sb_idx_8(uint32_t long_cb)
case 0: case 0:
return 10 + AUTO_16_SSE; return 10 + AUTO_16_SSE;
} }
ERROR("Error in tdec_sb_idx_8() invalid nof_sb=%d\n", nof_sb); ERROR("Error in tdec_sb_idx_8() invalid nof_sb=%d", nof_sb);
return 0; return 0;
} }
@ -486,7 +486,6 @@ static void tdec_iteration_16(srslte_tdec_t* h, int16_t* input)
h->current_inter_idx = interleaver_idx(h->nof_blocks16[h->current_dec]); h->current_inter_idx = interleaver_idx(h->nof_blocks16[h->current_dec]);
if (h->current_llr_type == SRSLTE_TDEC_8) { if (h->current_llr_type == SRSLTE_TDEC_8) {
h->current_inter_idx = interleaver_idx(h->nof_blocks8[h->current_dec]); h->current_inter_idx = interleaver_idx(h->nof_blocks8[h->current_dec]);
if (!h->n_iter) { if (!h->n_iter) {
@ -502,7 +501,7 @@ static void tdec_iteration_16(srslte_tdec_t* h, int16_t* input)
int srslte_tdec_new_cb(srslte_tdec_t* h, uint32_t long_cb) int srslte_tdec_new_cb(srslte_tdec_t* h, uint32_t long_cb)
{ {
if (long_cb > h->max_long_cb) { if (long_cb > h->max_long_cb) {
ERROR("TDEC was initialized for max_long_cb=%d\n", h->max_long_cb); ERROR("TDEC was initialized for max_long_cb=%d", h->max_long_cb);
return -1; return -1;
} }
@ -510,7 +509,7 @@ int srslte_tdec_new_cb(srslte_tdec_t* h, uint32_t long_cb)
h->current_long_cb = long_cb; h->current_long_cb = long_cb;
h->current_cbidx = srslte_cbsegm_cbindex(long_cb); h->current_cbidx = srslte_cbsegm_cbindex(long_cb);
if (h->current_cbidx < 0) { if (h->current_cbidx < 0) {
ERROR("Invalid CB length %d\n", long_cb); ERROR("Invalid CB length %d", long_cb);
return -1; return -1;
} }
return 0; return 0;

@ -55,13 +55,12 @@ int srslte_layermap_multiplex(cf_t* d[SRSLTE_MAX_CODEWORDS],
n[0] = nof_layers / nof_cw; n[0] = nof_layers / nof_cw;
n[1] = nof_layers - n[0]; n[1] = nof_layers - n[0];
if (nof_symbols[0] / n[0] == nof_symbols[1] / n[1]) { if (nof_symbols[0] / n[0] == nof_symbols[1] / n[1]) {
srslte_layermap_diversity(d[0], x, n[0], nof_symbols[0]); srslte_layermap_diversity(d[0], x, n[0], nof_symbols[0]);
srslte_layermap_diversity(d[1], &x[n[0]], n[1], nof_symbols[1]); srslte_layermap_diversity(d[1], &x[n[0]], n[1], nof_symbols[1]);
return nof_symbols[0] / n[0]; return nof_symbols[0] / n[0];
} else { } else {
ERROR("Number of symbols in codewords 0 and 1 is not consistent (%d, %d)\n", nof_symbols[0], nof_symbols[1]); ERROR("Number of symbols in codewords 0 and 1 is not consistent (%d, %d)", nof_symbols[0], nof_symbols[1]);
return -1; return -1;
} }
} }
@ -79,17 +78,16 @@ int srslte_layermap_type(cf_t* d[SRSLTE_MAX_CODEWORDS],
int nof_symbols[SRSLTE_MAX_CODEWORDS], int nof_symbols[SRSLTE_MAX_CODEWORDS],
srslte_tx_scheme_t type) srslte_tx_scheme_t type)
{ {
if (nof_cw > SRSLTE_MAX_CODEWORDS) { if (nof_cw > SRSLTE_MAX_CODEWORDS) {
ERROR("Maximum number of codewords is %d (nof_cw=%d)\n", SRSLTE_MAX_CODEWORDS, nof_cw); ERROR("Maximum number of codewords is %d (nof_cw=%d)", SRSLTE_MAX_CODEWORDS, nof_cw);
return -1; return -1;
} }
if (nof_layers > SRSLTE_MAX_LAYERS) { if (nof_layers > SRSLTE_MAX_LAYERS) {
ERROR("Maximum number of layers is %d (nof_layers=%d)\n", SRSLTE_MAX_LAYERS, nof_layers); ERROR("Maximum number of layers is %d (nof_layers=%d)", SRSLTE_MAX_LAYERS, nof_layers);
return -1; return -1;
} }
if (nof_layers < nof_cw) { if (nof_layers < nof_cw) {
ERROR("Number of codewords must be lower or equal than number of layers\n"); ERROR("Number of codewords must be lower or equal than number of layers");
return -1; return -1;
} }
@ -98,7 +96,7 @@ int srslte_layermap_type(cf_t* d[SRSLTE_MAX_CODEWORDS],
if (nof_cw == 1 && nof_layers == 1) { if (nof_cw == 1 && nof_layers == 1) {
return srslte_layermap_single(d[0], x[0], nof_symbols[0]); return srslte_layermap_single(d[0], x[0], nof_symbols[0]);
} else { } else {
ERROR("Number of codewords and layers must be 1 for transmission on single antenna ports\n"); ERROR("Number of codewords and layers must be 1 for transmission on single antenna ports");
return -1; return -1;
} }
break; break;
@ -107,11 +105,11 @@ int srslte_layermap_type(cf_t* d[SRSLTE_MAX_CODEWORDS],
if (nof_layers == 2 || nof_layers == 4) { if (nof_layers == 2 || nof_layers == 4) {
return srslte_layermap_diversity(d[0], x, nof_layers, nof_symbols[0]); return srslte_layermap_diversity(d[0], x, nof_layers, nof_symbols[0]);
} else { } else {
ERROR("Number of layers must be 2 or 4 for transmit diversity\n"); ERROR("Number of layers must be 2 or 4 for transmit diversity");
return -1; return -1;
} }
} else { } else {
ERROR("Number of codewords must be 1 for transmit diversity\n"); ERROR("Number of codewords must be 1 for transmit diversity");
return -1; return -1;
} }
break; break;
@ -174,17 +172,16 @@ int srslte_layerdemap_type(cf_t* x[SRSLTE_MAX_LAYERS],
int nof_symbols[SRSLTE_MAX_CODEWORDS], int nof_symbols[SRSLTE_MAX_CODEWORDS],
srslte_tx_scheme_t type) srslte_tx_scheme_t type)
{ {
if (nof_cw > SRSLTE_MAX_CODEWORDS) { if (nof_cw > SRSLTE_MAX_CODEWORDS) {
ERROR("Maximum number of codewords is %d (nof_cw=%d)\n", SRSLTE_MAX_CODEWORDS, nof_cw); ERROR("Maximum number of codewords is %d (nof_cw=%d)", SRSLTE_MAX_CODEWORDS, nof_cw);
return -1; return -1;
} }
if (nof_layers > SRSLTE_MAX_LAYERS) { if (nof_layers > SRSLTE_MAX_LAYERS) {
ERROR("Maximum number of layers is %d (nof_layers=%d)\n", SRSLTE_MAX_LAYERS, nof_layers); ERROR("Maximum number of layers is %d (nof_layers=%d)", SRSLTE_MAX_LAYERS, nof_layers);
return -1; return -1;
} }
if (nof_layers < nof_cw) { if (nof_layers < nof_cw) {
ERROR("Number of codewords must be lower or equal than number of layers\n"); ERROR("Number of codewords must be lower or equal than number of layers");
return -1; return -1;
} }
@ -194,7 +191,7 @@ int srslte_layerdemap_type(cf_t* x[SRSLTE_MAX_LAYERS],
nof_symbols[0] = srslte_layerdemap_single(x[0], d[0], nof_layer_symbols); nof_symbols[0] = srslte_layerdemap_single(x[0], d[0], nof_layer_symbols);
nof_symbols[1] = 0; nof_symbols[1] = 0;
} else { } else {
ERROR("Number of codewords and layers must be 1 for transmission on single antenna ports\n"); ERROR("Number of codewords and layers must be 1 for transmission on single antenna ports");
return -1; return -1;
} }
break; break;
@ -204,11 +201,11 @@ int srslte_layerdemap_type(cf_t* x[SRSLTE_MAX_LAYERS],
nof_symbols[0] = srslte_layerdemap_diversity(x, d[0], nof_layers, nof_layer_symbols); nof_symbols[0] = srslte_layerdemap_diversity(x, d[0], nof_layers, nof_layer_symbols);
nof_symbols[1] = 0; nof_symbols[1] = 0;
} else { } else {
ERROR("Number of layers must be 2 or 4 for transmit diversity\n"); ERROR("Number of layers must be 2 or 4 for transmit diversity");
return -1; return -1;
} }
} else { } else {
ERROR("Number of codewords must be 1 for transmit diversity\n"); ERROR("Number of codewords must be 1 for transmit diversity");
return -1; return -1;
} }
break; break;
@ -249,7 +246,7 @@ int srslte_layermap_nr(cf_t** d, int nof_cw, cf_t** x, int nof_layers, uint32_t
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
ERROR("Error. Incompatible number of layers (%d) and codewords (%d)\n", nof_layers, nof_cw); ERROR("Error. Incompatible number of layers (%d) and codewords (%d)", nof_layers, nof_cw);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -282,6 +279,6 @@ int srslte_layerdemap_nr(cf_t** d, int nof_cw, cf_t** x, int nof_layers, uint32_
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
ERROR("Error. Incompatible number of layers (%d) and codewords (%d)\n", nof_layers, nof_cw); ERROR("Error. Incompatible number of layers (%d) and codewords (%d)", nof_layers, nof_cw);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }

@ -72,7 +72,6 @@ int srslte_predecoding_single_sse(cf_t* y[SRSLTE_MAX_PORTS],
float scaling, float scaling,
float noise_estimate) float noise_estimate)
{ {
float* xPtr = (float*)x; float* xPtr = (float*)x;
const float* hPtr1 = (const float*)h[0]; const float* hPtr1 = (const float*)h[0];
const float* yPtr1 = (const float*)y[0]; const float* yPtr1 = (const float*)y[0];
@ -179,7 +178,6 @@ int srslte_predecoding_single_avx(cf_t* y[SRSLTE_MAX_PORTS],
float scaling, float scaling,
float noise_estimate) float noise_estimate)
{ {
float* xPtr = (float*)x; float* xPtr = (float*)x;
const float* hPtr1 = (const float*)h[0]; const float* hPtr1 = (const float*)h[0];
const float* yPtr1 = (const float*)y[0]; const float* yPtr1 = (const float*)y[0];
@ -355,7 +353,6 @@ int srslte_predecoding_single(cf_t* y_,
float scaling, float scaling,
float noise_estimate) float noise_estimate)
{ {
cf_t* y[SRSLTE_MAX_PORTS]; cf_t* y[SRSLTE_MAX_PORTS];
cf_t* h[SRSLTE_MAX_PORTS]; cf_t* h[SRSLTE_MAX_PORTS];
y[0] = y_; y[0] = y_;
@ -491,7 +488,7 @@ int srslte_predecoding_diversity_gen_(cf_t* y[SRSLTE_MAX_PORTS],
} }
return i; return i;
} else { } else {
ERROR("Number of ports must be 2 or 4 for transmit diversity (nof_ports=%d)\n", nof_ports); ERROR("Number of ports must be 2 or 4 for transmit diversity (nof_ports=%d)", nof_ports);
return -1; return -1;
} }
} }
@ -536,7 +533,6 @@ int srslte_predecoding_diversity2_sse(cf_t* y[SRSLTE_MAX_PORTS],
__m128 x0, x1; __m128 x0, x1;
for (int i = 0; i < nof_symbols / 4; i++) { for (int i = 0; i < nof_symbols / 4; i++) {
h0Val_00 = _mm_load_ps(h0Ptr0); h0Val_00 = _mm_load_ps(h0Ptr0);
h0Ptr0 += 4; h0Ptr0 += 4;
h0Val_10 = _mm_load_ps(h0Ptr0); h0Val_10 = _mm_load_ps(h0Ptr0);
@ -767,7 +763,7 @@ int srslte_predecoding_diversity_csi(cf_t* y[SRSLTE_MAX_PORTS],
} }
return i; return i;
} else { } else {
ERROR("Number of ports must be 2 or 4 for transmit diversity (nof_ports=%d)\n", nof_ports); ERROR("Number of ports must be 2 or 4 for transmit diversity (nof_ports=%d)", nof_ports);
return -1; return -1;
} }
} }
@ -804,11 +800,9 @@ int srslte_precoding_mimo_2x2_gen(cf_t W[2][2],
float scaling, float scaling,
float noise_estimate) float noise_estimate)
{ {
cf_t G[2][2], Gx[2][2]; cf_t G[2][2], Gx[2][2];
for (int i = 0; i < nof_symbols; i++) { for (int i = 0; i < nof_symbols; i++) {
// G=H*W // G=H*W
G[0][0] = h[0][0][i] * W[0][0] + h[0][1][i] * W[1][0]; G[0][0] = h[0][0][i] * W[0][0] + h[0][1][i] * W[1][0];
G[0][1] = h[0][0][i] * W[1][0] + h[0][1][i] * W[1][1]; G[0][1] = h[0][0][i] * W[1][0] + h[0][1][i] * W[1][1];
@ -823,7 +817,7 @@ int srslte_precoding_mimo_2x2_gen(cf_t W[2][2],
Gx[1][1] = conjf(G[1][1]); Gx[1][1] = conjf(G[1][1]);
} else { } else {
// MMSE equalizer: Gx = (G'G+I) // MMSE equalizer: Gx = (G'G+I)
ERROR("MMSE MIMO decoder not implemented\n"); ERROR("MMSE MIMO decoder not implemented");
return -1; return -1;
} }
@ -894,7 +888,6 @@ static int srslte_predecoding_ccd_2x2_zf_csi(cf_t* y[SRSLTE_MAX_PORTS],
cf_t h00, h01, h10, h11, det; cf_t h00, h01, h10, h11, det;
for (; i < nof_symbols; i++) { for (; i < nof_symbols; i++) {
// Even precoder // Even precoder
h00 = +h[0][0][i] + h[1][0][i]; h00 = +h[0][0][i] + h[1][0][i];
h10 = +h[0][1][i] + h[1][1][i]; h10 = +h[0][1][i] + h[1][1][i];
@ -982,7 +975,6 @@ static int srslte_predecoding_ccd_2x2_zf(cf_t* y[SRSLTE_MAX_PORTS],
cf_t h00, h01, h10, h11, det; cf_t h00, h01, h10, h11, det;
for (; i < nof_symbols; i++) { for (; i < nof_symbols; i++) {
// Even precoder // Even precoder
h00 = +h[0][0][i] + h[1][0][i]; h00 = +h[0][0][i] + h[1][0][i];
h10 = +h[0][1][i] + h[1][1][i]; h10 = +h[0][1][i] + h[1][1][i];
@ -1028,13 +1020,13 @@ static int srslte_predecoding_ccd_zf(cf_t* y[SRSLTE_MAX_PORTS],
return srslte_predecoding_ccd_2x2_zf(y, h, x, nof_symbols, scaling); return srslte_predecoding_ccd_2x2_zf(y, h, x, nof_symbols, scaling);
} }
} else { } else {
ERROR("Error predecoding CCD: Invalid number of layers %d\n", nof_layers); ERROR("Error predecoding CCD: Invalid number of layers %d", nof_layers);
return -1; return -1;
} }
} else if (nof_ports == 4) { } else if (nof_ports == 4) {
ERROR("Error predecoding CCD: Only 2 ports supported\n"); ERROR("Error predecoding CCD: Only 2 ports supported");
} else { } else {
ERROR("Error predecoding CCD: Invalid combination of ports %d and rx antennax %d\n", nof_ports, nof_rxant); ERROR("Error predecoding CCD: Invalid combination of ports %d and rx antennax %d", nof_ports, nof_rxant);
} }
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1099,7 +1091,6 @@ static int srslte_predecoding_ccd_2x2_mmse_csi(cf_t* y[SRSLTE_MAX_PORTS],
cf_t h00, h01, h10, h11; cf_t h00, h01, h10, h11;
for (; i < nof_symbols; i++) { for (; i < nof_symbols; i++) {
// Even precoder // Even precoder
h00 = +h[0][0][i] + h[1][0][i]; h00 = +h[0][0][i] + h[1][0][i];
h10 = +h[0][1][i] + h[1][1][i]; h10 = +h[0][1][i] + h[1][1][i];
@ -1174,7 +1165,6 @@ static int srslte_predecoding_ccd_2x2_mmse(cf_t* y[SRSLTE_MAX_PORTS],
cf_t h00, h01, h10, h11; cf_t h00, h01, h10, h11;
for (; i < nof_symbols; i++) { for (; i < nof_symbols; i++) {
// Even precoder // Even precoder
h00 = +h[0][0][i] + h[1][0][i]; h00 = +h[0][0][i] + h[1][0][i];
h10 = +h[0][1][i] + h[1][1][i]; h10 = +h[0][1][i] + h[1][1][i];
@ -1213,13 +1203,13 @@ int srslte_predecoding_ccd_mmse(cf_t* y[SRSLTE_MAX_PORTS],
return srslte_predecoding_ccd_2x2_mmse(y, h, x, nof_symbols, scaling, noise_estimate); return srslte_predecoding_ccd_2x2_mmse(y, h, x, nof_symbols, scaling, noise_estimate);
} }
} else { } else {
ERROR("Error predecoding CCD: Invalid number of layers %d\n", nof_layers); ERROR("Error predecoding CCD: Invalid number of layers %d", nof_layers);
return -1; return -1;
} }
} else if (nof_ports == 4) { } else if (nof_ports == 4) {
ERROR("Error predecoding CCD: Only 2 ports supported\n"); ERROR("Error predecoding CCD: Only 2 ports supported");
} else { } else {
ERROR("Error predecoding CCD: Invalid combination of ports %d and rx antennax %d\n", nof_ports, nof_rxant); ERROR("Error predecoding CCD: Invalid combination of ports %d and rx antennax %d", nof_ports, nof_rxant);
} }
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1276,7 +1266,7 @@ static int srslte_predecoding_multiplex_2x2_zf_csi(cf_t* y[SRSLTE_MAX_PORTS],
h11 = srslte_simd_cf_sub(h01i, srslte_simd_cf_mulj(h11i)); h11 = srslte_simd_cf_sub(h01i, srslte_simd_cf_mulj(h11i));
break; break;
default: default:
ERROR("Wrong codebook_idx=%d\n", codebook_idx); ERROR("Wrong codebook_idx=%d", codebook_idx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1318,7 +1308,7 @@ static int srslte_predecoding_multiplex_2x2_zf_csi(cf_t* y[SRSLTE_MAX_PORTS],
h11 = h[0][1][i] - _Complex_I * h[1][1][i]; h11 = h[0][1][i] - _Complex_I * h[1][1][i];
break; break;
default: default:
ERROR("Wrong codebook_idx=%d\n", codebook_idx); ERROR("Wrong codebook_idx=%d", codebook_idx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1386,7 +1376,7 @@ static int srslte_predecoding_multiplex_2x2_zf(cf_t* y[SRSLTE_MAX_PORTS],
h11 = srslte_simd_cf_sub(h01i, srslte_simd_cf_mulj(h11i)); h11 = srslte_simd_cf_sub(h01i, srslte_simd_cf_mulj(h11i));
break; break;
default: default:
ERROR("Wrong codebook_idx=%d\n", codebook_idx); ERROR("Wrong codebook_idx=%d", codebook_idx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1425,7 +1415,7 @@ static int srslte_predecoding_multiplex_2x2_zf(cf_t* y[SRSLTE_MAX_PORTS],
h11 = h[0][1][i] - _Complex_I * h[1][1][i]; h11 = h[0][1][i] - _Complex_I * h[1][1][i];
break; break;
default: default:
ERROR("Wrong codebook_idx=%d\n", codebook_idx); ERROR("Wrong codebook_idx=%d", codebook_idx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1488,7 +1478,7 @@ static int srslte_predecoding_multiplex_2x2_mmse_csi(cf_t* y[SRSLTE_MAX_PORTS],
h11 = srslte_simd_cf_sub(h01i, srslte_simd_cf_mulj(h11i)); h11 = srslte_simd_cf_sub(h01i, srslte_simd_cf_mulj(h11i));
break; break;
default: default:
ERROR("Wrong codebook_idx=%d\n", codebook_idx); ERROR("Wrong codebook_idx=%d", codebook_idx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1530,7 +1520,7 @@ static int srslte_predecoding_multiplex_2x2_mmse_csi(cf_t* y[SRSLTE_MAX_PORTS],
h11 = h[0][1][i] - _Complex_I * h[1][1][i]; h11 = h[0][1][i] - _Complex_I * h[1][1][i];
break; break;
default: default:
ERROR("Wrong codebook_idx=%d\n", codebook_idx); ERROR("Wrong codebook_idx=%d", codebook_idx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1592,7 +1582,7 @@ static int srslte_predecoding_multiplex_2x2_mmse(cf_t* y[SRSLTE_MAX_PORTS],
h11 = srslte_simd_cf_sub(h01i, srslte_simd_cf_mulj(h11i)); h11 = srslte_simd_cf_sub(h01i, srslte_simd_cf_mulj(h11i));
break; break;
default: default:
ERROR("Wrong codebook_idx=%d\n", codebook_idx); ERROR("Wrong codebook_idx=%d", codebook_idx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1631,7 +1621,7 @@ static int srslte_predecoding_multiplex_2x2_mmse(cf_t* y[SRSLTE_MAX_PORTS],
h11 = h[0][1][i] - _Complex_I * h[1][1][i]; h11 = h[0][1][i] - _Complex_I * h[1][1][i];
break; break;
default: default:
ERROR("Wrong codebook_idx=%d\n", codebook_idx); ERROR("Wrong codebook_idx=%d", codebook_idx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1678,7 +1668,7 @@ static int srslte_predecoding_multiplex_2x1_mrc(cf_t* y[SRSLTE_MAX_PORTS],
hx = srslte_simd_cf_sub(h0xi, srslte_simd_cf_mulj(h1xi)); hx = srslte_simd_cf_sub(h0xi, srslte_simd_cf_mulj(h1xi));
break; break;
default: default:
ERROR("Wrong codebook_idx=%d\n", codebook_idx); ERROR("Wrong codebook_idx=%d", codebook_idx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1713,7 +1703,7 @@ static int srslte_predecoding_multiplex_2x1_mrc(cf_t* y[SRSLTE_MAX_PORTS],
h1 = h[0][1][i] - _Complex_I * h[1][1][i]; h1 = h[0][1][i] - _Complex_I * h[1][1][i];
break; break;
default: default:
ERROR("Wrong codebook_idx=%d\n", codebook_idx); ERROR("Wrong codebook_idx=%d", codebook_idx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1763,7 +1753,7 @@ static int srslte_predecoding_multiplex_2x1_mrc_csi(cf_t* y[SRSLTE_MAX_PORTS],
hx = srslte_simd_cf_sub(h0xi, srslte_simd_cf_mulj(h1xi)); hx = srslte_simd_cf_sub(h0xi, srslte_simd_cf_mulj(h1xi));
break; break;
default: default:
ERROR("Wrong codebook_idx=%d\n", codebook_idx); ERROR("Wrong codebook_idx=%d", codebook_idx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1799,7 +1789,7 @@ static int srslte_predecoding_multiplex_2x1_mrc_csi(cf_t* y[SRSLTE_MAX_PORTS],
h1 = h[0][1][i] - _Complex_I * h[1][1][i]; h1 = h[0][1][i] - _Complex_I * h[1][1][i];
break; break;
default: default:
ERROR("Wrong codebook_idx=%d\n", codebook_idx); ERROR("Wrong codebook_idx=%d", codebook_idx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1853,7 +1843,7 @@ static int srslte_predecoding_multiplex(cf_t* y[SRSLTE_MAX_PORTS],
} else if (nof_ports == 4) { } else if (nof_ports == 4) {
ERROR("Error predecoding multiplex: not implemented for %d Tx ports", nof_ports); ERROR("Error predecoding multiplex: not implemented for %d Tx ports", nof_ports);
} else { } else {
ERROR("Error predecoding multiplex: Invalid combination of ports %d and rx antennas %d\n", nof_ports, nof_rxant); ERROR("Error predecoding multiplex: Invalid combination of ports %d and rx antennas %d", nof_ports, nof_rxant);
} }
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1877,13 +1867,12 @@ int srslte_predecoding_type(cf_t* y[SRSLTE_MAX_PORTS],
float scaling, float scaling,
float noise_estimate) float noise_estimate)
{ {
if (nof_ports > SRSLTE_MAX_PORTS) { if (nof_ports > SRSLTE_MAX_PORTS) {
ERROR("Maximum number of ports is %d (nof_ports=%d)\n", SRSLTE_MAX_PORTS, nof_ports); ERROR("Maximum number of ports is %d (nof_ports=%d)", SRSLTE_MAX_PORTS, nof_ports);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (nof_layers > SRSLTE_MAX_LAYERS) { if (nof_layers > SRSLTE_MAX_LAYERS) {
ERROR("Maximum number of layers is %d (nof_layers=%d)\n", SRSLTE_MAX_LAYERS, nof_layers); ERROR("Maximum number of layers is %d (nof_layers=%d)", SRSLTE_MAX_LAYERS, nof_layers);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1898,7 +1887,7 @@ int srslte_predecoding_type(cf_t* y[SRSLTE_MAX_PORTS],
y, h, x, csi, nof_rxant, nof_ports, nof_layers, nof_symbols, scaling, noise_estimate); y, h, x, csi, nof_rxant, nof_ports, nof_layers, nof_symbols, scaling, noise_estimate);
} }
} else { } else {
ERROR("Invalid number of layers %d\n", nof_layers); ERROR("Invalid number of layers %d", nof_layers);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
return SRSLTE_ERROR; return SRSLTE_ERROR;
@ -1906,7 +1895,7 @@ int srslte_predecoding_type(cf_t* y[SRSLTE_MAX_PORTS],
if (nof_ports == 1 && nof_layers == 1) { if (nof_ports == 1 && nof_layers == 1) {
return srslte_predecoding_single_multi(y, h[0], x[0], csi, nof_rxant, nof_symbols, scaling, noise_estimate); return srslte_predecoding_single_multi(y, h[0], x[0], csi, nof_rxant, nof_symbols, scaling, noise_estimate);
} else { } else {
ERROR("Number of ports and layers must be 1 for transmission on single antenna ports (%d, %d)\n", ERROR("Number of ports and layers must be 1 for transmission on single antenna ports (%d, %d)",
nof_ports, nof_ports,
nof_layers); nof_layers);
return SRSLTE_ERROR; return SRSLTE_ERROR;
@ -1915,14 +1904,14 @@ int srslte_predecoding_type(cf_t* y[SRSLTE_MAX_PORTS],
if (nof_ports == nof_layers) { if (nof_ports == nof_layers) {
return srslte_predecoding_diversity_multi(y, h, x, csi, nof_rxant, nof_ports, nof_symbols, scaling); return srslte_predecoding_diversity_multi(y, h, x, csi, nof_rxant, nof_ports, nof_symbols, scaling);
} else { } else {
ERROR("Error number of layers must equal number of ports in transmit diversity\n"); ERROR("Error number of layers must equal number of ports in transmit diversity");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
case SRSLTE_TXSCHEME_SPATIALMUX: case SRSLTE_TXSCHEME_SPATIALMUX:
return srslte_predecoding_multiplex( return srslte_predecoding_multiplex(
y, h, x, csi, nof_rxant, nof_ports, nof_layers, codebook_idx, nof_symbols, scaling, noise_estimate); y, h, x, csi, nof_rxant, nof_ports, nof_layers, codebook_idx, nof_symbols, scaling, noise_estimate);
default: default:
ERROR("Invalid Txscheme=%d\n", type); ERROR("Invalid Txscheme=%d", type);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -1988,7 +1977,7 @@ int srslte_precoding_diversity(cf_t* x[SRSLTE_MAX_LAYERS],
} }
return 4 * i; return 4 * i;
} else { } else {
ERROR("Number of ports must be 2 or 4 for transmit diversity (nof_ports=%d)\n", nof_ports); ERROR("Number of ports must be 2 or 4 for transmit diversity (nof_ports=%d)", nof_ports);
return -1; return -1;
} }
} }
@ -2065,7 +2054,7 @@ int srslte_precoding_cdd(cf_t* x[SRSLTE_MAX_LAYERS],
{ {
if (nof_ports == 2) { if (nof_ports == 2) {
if (nof_layers != 2) { if (nof_layers != 2) {
ERROR("Invalid number of layers %d for 2 ports\n", nof_layers); ERROR("Invalid number of layers %d for 2 ports", nof_layers);
return -1; return -1;
} }
#ifdef LV_HAVE_AVX #ifdef LV_HAVE_AVX
@ -2078,10 +2067,10 @@ int srslte_precoding_cdd(cf_t* x[SRSLTE_MAX_LAYERS],
#endif /* LV_HAVE_SSE */ #endif /* LV_HAVE_SSE */
#endif /* LV_HAVE_AVX */ #endif /* LV_HAVE_AVX */
} else if (nof_ports == 4) { } else if (nof_ports == 4) {
ERROR("Not implemented\n"); ERROR("Not implemented");
return -1; return -1;
} else { } else {
ERROR("Number of ports must be 2 or 4 for transmit diversity (nof_ports=%d)\n", nof_ports); ERROR("Number of ports must be 2 or 4 for transmit diversity (nof_ports=%d)", nof_ports);
return -1; return -1;
} }
} }
@ -2116,7 +2105,7 @@ int srslte_precoding_multiplex(cf_t* x[SRSLTE_MAX_LAYERS],
srslte_vec_sc_prod_ccc(x[0], -_Complex_I * scaling, y[1], nof_symbols); srslte_vec_sc_prod_ccc(x[0], -_Complex_I * scaling, y[1], nof_symbols);
break; break;
default: default:
ERROR("Invalid multiplex combination: codebook_idx=%d, nof_layers=%d, nof_ports=%d\n", ERROR("Invalid multiplex combination: codebook_idx=%d, nof_layers=%d, nof_ports=%d",
codebook_idx, codebook_idx,
nof_layers, nof_layers,
nof_ports); nof_ports);
@ -2197,7 +2186,7 @@ int srslte_precoding_multiplex(cf_t* x[SRSLTE_MAX_LAYERS],
break; break;
case 3: case 3:
default: default:
ERROR("Invalid multiplex combination: codebook_idx=%d, nof_layers=%d, nof_ports=%d\n", ERROR("Invalid multiplex combination: codebook_idx=%d, nof_layers=%d, nof_ports=%d",
codebook_idx, codebook_idx,
nof_layers, nof_layers,
nof_ports); nof_ports);
@ -2222,13 +2211,12 @@ int srslte_precoding_type(cf_t* x[SRSLTE_MAX_LAYERS],
float scaling, float scaling,
srslte_tx_scheme_t type) srslte_tx_scheme_t type)
{ {
if (nof_ports > SRSLTE_MAX_PORTS) { if (nof_ports > SRSLTE_MAX_PORTS) {
ERROR("Maximum number of ports is %d (nof_ports=%d)\n", SRSLTE_MAX_PORTS, nof_ports); ERROR("Maximum number of ports is %d (nof_ports=%d)", SRSLTE_MAX_PORTS, nof_ports);
return -1; return -1;
} }
if (nof_layers > SRSLTE_MAX_LAYERS) { if (nof_layers > SRSLTE_MAX_LAYERS) {
ERROR("Maximum number of layers is %d (nof_layers=%d)\n", SRSLTE_MAX_LAYERS, nof_layers); ERROR("Maximum number of layers is %d (nof_layers=%d)", SRSLTE_MAX_LAYERS, nof_layers);
return -1; return -1;
} }
@ -2239,7 +2227,7 @@ int srslte_precoding_type(cf_t* x[SRSLTE_MAX_LAYERS],
if (nof_ports == 1 && nof_layers == 1) { if (nof_ports == 1 && nof_layers == 1) {
return srslte_precoding_single(x[0], y[0], nof_symbols, scaling); return srslte_precoding_single(x[0], y[0], nof_symbols, scaling);
} else { } else {
ERROR("Number of ports and layers must be 1 for transmission on single antenna ports\n"); ERROR("Number of ports and layers must be 1 for transmission on single antenna ports");
return -1; return -1;
} }
break; break;
@ -2247,7 +2235,7 @@ int srslte_precoding_type(cf_t* x[SRSLTE_MAX_LAYERS],
if (nof_ports == nof_layers) { if (nof_ports == nof_layers) {
return srslte_precoding_diversity(x, y, nof_ports, nof_symbols, scaling); return srslte_precoding_diversity(x, y, nof_ports, nof_symbols, scaling);
} else { } else {
ERROR("Error number of layers must equal number of ports in transmit diversity\n"); ERROR("Error number of layers must equal number of ports in transmit diversity");
return -1; return -1;
} }
case SRSLTE_TXSCHEME_SPATIALMUX: case SRSLTE_TXSCHEME_SPATIALMUX:
@ -2267,7 +2255,6 @@ int srslte_precoding_pmi_select_1l_gen(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_
uint32_t* pmi, uint32_t* pmi,
float sinr_list[SRSLTE_MAX_CODEBOOKS]) float sinr_list[SRSLTE_MAX_CODEBOOKS])
{ {
#define SQRT1_2 ((float)M_SQRT1_2) #define SQRT1_2 ((float)M_SQRT1_2)
float max_sinr = 0.0; float max_sinr = 0.0;
uint32_t i, count; uint32_t i, count;
@ -2482,7 +2469,7 @@ int srslte_precoding_pmi_select_1l(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORT
#else #else
ret = srslte_precoding_pmi_select_1l_gen(h, nof_symbols, noise_estimate, pmi, sinr_list); ret = srslte_precoding_pmi_select_1l_gen(h, nof_symbols, noise_estimate, pmi, sinr_list);
#endif /* SRSLTE_SIMD_CF_SIZE != 0 */ #endif /* SRSLTE_SIMD_CF_SIZE != 0 */
INFO("Precoder PMI Select for 1 layer SINR=[%.1fdB; %.1fdB; %.1fdB; %.1fdB] PMI=%d\n", INFO("Precoder PMI Select for 1 layer SINR=[%.1fdB; %.1fdB; %.1fdB; %.1fdB] PMI=%d",
srslte_convert_power_to_dB(sinr_list[0]), srslte_convert_power_to_dB(sinr_list[0]),
srslte_convert_power_to_dB(sinr_list[1]), srslte_convert_power_to_dB(sinr_list[1]),
srslte_convert_power_to_dB(sinr_list[2]), srslte_convert_power_to_dB(sinr_list[2]),
@ -2498,7 +2485,6 @@ int srslte_precoding_pmi_select_2l_gen(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_
uint32_t* pmi, uint32_t* pmi,
float sinr_list[SRSLTE_MAX_CODEBOOKS]) float sinr_list[SRSLTE_MAX_CODEBOOKS])
{ {
float max_sinr = 0.0; float max_sinr = 0.0;
uint32_t i, count; uint32_t i, count;
@ -2758,7 +2744,6 @@ int srslte_precoding_pmi_select_2l(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORT
uint32_t* pmi, uint32_t* pmi,
float sinr_list[SRSLTE_MAX_CODEBOOKS]) float sinr_list[SRSLTE_MAX_CODEBOOKS])
{ {
int ret; int ret;
#if SRSLTE_SIMD_CF_SIZE != 0 #if SRSLTE_SIMD_CF_SIZE != 0
ret = srslte_precoding_pmi_select_2l_simd(h, nof_symbols, noise_estimate, pmi, sinr_list); ret = srslte_precoding_pmi_select_2l_simd(h, nof_symbols, noise_estimate, pmi, sinr_list);
@ -2766,7 +2751,7 @@ int srslte_precoding_pmi_select_2l(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORT
ret = srslte_precoding_pmi_select_2l_gen(h, nof_symbols, noise_estimate, pmi, sinr_list); ret = srslte_precoding_pmi_select_2l_gen(h, nof_symbols, noise_estimate, pmi, sinr_list);
#endif /* SRSLTE_SIMD_CF_SIZE != 0 */ #endif /* SRSLTE_SIMD_CF_SIZE != 0 */
INFO("Precoder PMI Select for 2 layers SINR=[%.1fdB; %.1fdB] PMI=%d\n", INFO("Precoder PMI Select for 2 layers SINR=[%.1fdB; %.1fdB] PMI=%d",
srslte_convert_power_to_dB(sinr_list[0]), srslte_convert_power_to_dB(sinr_list[0]),
srslte_convert_power_to_dB(sinr_list[1]), srslte_convert_power_to_dB(sinr_list[1]),
*pmi); *pmi);
@ -2839,7 +2824,7 @@ int srslte_precoding_cn(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS],
*cn = srslte_precoding_2x2_cn_gen(h, nof_symbols); *cn = srslte_precoding_2x2_cn_gen(h, nof_symbols);
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} else { } else {
ERROR("MIMO Condition Number calculation not implemented for %d×%d\n", nof_tx_antennas, nof_rx_antennas); ERROR("MIMO Condition Number calculation not implemented for %d×%d", nof_tx_antennas, nof_rx_antennas);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }

@ -77,7 +77,7 @@ int main(int argc, char** argv)
parse_args(argc, argv); parse_args(argc, argv);
if (srslte_str2mimotype(mimo_type_name, &type)) { if (srslte_str2mimotype(mimo_type_name, &type)) {
ERROR("Invalid MIMO type %s\n", mimo_type_name); ERROR("Invalid MIMO type %s", mimo_type_name);
exit(-1); exit(-1);
} }
@ -120,13 +120,13 @@ int main(int argc, char** argv)
/* layer mapping */ /* layer mapping */
if ((symbols_layer = srslte_layermap_type(d, x, nof_cw, nof_layers, nof_symb_cw, type)) < 0) { if ((symbols_layer = srslte_layermap_type(d, x, nof_cw, nof_layers, nof_symb_cw, type)) < 0) {
ERROR("Error layer mapper encoder\n"); ERROR("Error layer mapper encoder");
exit(-1); exit(-1);
} }
/* layer de-mapping */ /* layer de-mapping */
if (srslte_layerdemap_type(x, dp, nof_layers, nof_cw, nof_symbols / nof_layers, nof_symb_cw, type) < 0) { if (srslte_layerdemap_type(x, dp, nof_layers, nof_cw, nof_symbols / nof_layers, nof_symb_cw, type) < 0) {
ERROR("Error layer mapper encoder\n"); ERROR("Error layer mapper encoder");
exit(-1); exit(-1);
} }

@ -81,7 +81,7 @@ int main(int argc, char** argv)
} }
if (err > 0.1f) { if (err > 0.1f) {
ERROR("Test case %d failed computing 1 layer SINR for codebook %d (test=%.2f; gold=%.2f)\n", ERROR("Test case %d failed computing 1 layer SINR for codebook %d (test=%.2f; gold=%.2f)",
c + 1, c + 1,
i, i,
sinr_1l[i], sinr_1l[i],
@ -92,7 +92,7 @@ int main(int argc, char** argv)
/* Check PMI select for 1 layer*/ /* Check PMI select for 1 layer*/
if (pmi[0] != gold->pmi[0]) { if (pmi[0] != gold->pmi[0]) {
ERROR("Test case %d failed computing 1 layer PMI (test=%d; gold=%d)\n", c + 1, pmi[0], gold->pmi[0]); ERROR("Test case %d failed computing 1 layer PMI (test=%d; gold=%d)", c + 1, pmi[0], gold->pmi[0]);
goto clean; goto clean;
} }
@ -113,7 +113,7 @@ int main(int argc, char** argv)
} }
if (err > 0.1f) { if (err > 0.1f) {
ERROR("Test case %d failed computing 2 layer SINR for codebook %d (test=%.2f; gold=%.2f)\n", ERROR("Test case %d failed computing 2 layer SINR for codebook %d (test=%.2f; gold=%.2f)",
c + 1, c + 1,
i, i,
sinr_2l[i], sinr_2l[i],
@ -124,19 +124,19 @@ int main(int argc, char** argv)
/* Check PMI select for 2 layer*/ /* Check PMI select for 2 layer*/
if (pmi[1] != gold->pmi[1]) { if (pmi[1] != gold->pmi[1]) {
ERROR("Test case %d failed computing 2 layer PMI (test=%d; gold=%d)\n", c + 1, pmi[1], gold->pmi[1]); ERROR("Test case %d failed computing 2 layer PMI (test=%d; gold=%d)", c + 1, pmi[1], gold->pmi[1]);
goto clean; goto clean;
} }
/* Condition number */ /* Condition number */
if (srslte_precoding_cn(h, 2, 2, nof_symbols, &cn)) { if (srslte_precoding_cn(h, 2, 2, nof_symbols, &cn)) {
ERROR("Test case %d condition number returned error\n", c + 1); ERROR("Test case %d condition number returned error", c + 1);
goto clean; goto clean;
} }
/* Check condition number */ /* Check condition number */
if (fabsf(gold->k - cn) > 0.1) { if (fabsf(gold->k - cn) > 0.1) {
ERROR("Test case %d failed computing condition number (test=%.2f; gold=%.2f)\n", c + 1, cn, gold->k); ERROR("Test case %d failed computing condition number (test=%.2f; gold=%.2f)", c + 1, cn, gold->k);
goto clean; goto clean;
} }
} }

@ -173,13 +173,13 @@ int main(int argc, char** argv)
/* Check input ranges */ /* Check input ranges */
if (nof_tx_ports > SRSLTE_MAX_PORTS || nof_rx_ports > SRSLTE_MAX_PORTS || nof_layers > SRSLTE_MAX_LAYERS) { if (nof_tx_ports > SRSLTE_MAX_PORTS || nof_rx_ports > SRSLTE_MAX_PORTS || nof_layers > SRSLTE_MAX_LAYERS) {
ERROR("Invalid number of layers or ports\n"); ERROR("Invalid number of layers or ports");
exit(-1); exit(-1);
} }
/* Parse MIMO Type */ /* Parse MIMO Type */
if (srslte_str2mimotype(mimo_type_name, &type)) { if (srslte_str2mimotype(mimo_type_name, &type)) {
ERROR("Invalid MIMO type %s\n", mimo_type_name); ERROR("Invalid MIMO type %s", mimo_type_name);
exit(-1); exit(-1);
} }
@ -194,7 +194,7 @@ int main(int argc, char** argv)
case SRSLTE_TXSCHEME_CDD: case SRSLTE_TXSCHEME_CDD:
nof_re = nof_symbols * nof_tx_ports / nof_layers; nof_re = nof_symbols * nof_tx_ports / nof_layers;
if (nof_rx_ports != 2 || nof_tx_ports != 2) { if (nof_rx_ports != 2 || nof_tx_ports != 2) {
ERROR("CDD nof_tx_ports=%d nof_rx_ports=%d is not currently supported\n", nof_tx_ports, nof_rx_ports); ERROR("CDD nof_tx_ports=%d nof_rx_ports=%d is not currently supported", nof_tx_ports, nof_rx_ports);
exit(-1); exit(-1);
} }
break; break;
@ -259,7 +259,7 @@ int main(int argc, char** argv)
/* Execute Precoding (Tx) */ /* Execute Precoding (Tx) */
if (srslte_precoding_type(x, y, nof_layers, nof_tx_ports, codebook_idx, nof_symbols, scaling, type) < 0) { if (srslte_precoding_type(x, y, nof_layers, nof_tx_ports, codebook_idx, nof_symbols, scaling, type) < 0) {
ERROR("Error layer mapper encoder\n"); ERROR("Error layer mapper encoder");
exit(-1); exit(-1);
} }

@ -214,7 +214,6 @@ void demod_16qam_lte_b_neon(const cf_t* symbols, int8_t* llr, int nsymbols)
result1n = vdupq_n_s8(0); result1n = vdupq_n_s8(0);
result2n = vdupq_n_s8(0); result2n = vdupq_n_s8(0);
for (int i = 0; i < nsymbols / 8; i++) { for (int i = 0; i < nsymbols / 8; i++) {
symbol1 = vld1q_f32(symbolsPtr); symbol1 = vld1q_f32(symbolsPtr);
symbolsPtr += 4; symbolsPtr += 4;
symbol2 = vld1q_f32(symbolsPtr); symbol2 = vld1q_f32(symbolsPtr);
@ -448,7 +447,6 @@ void demod_64qam_lte_s_neon(const cf_t* symbols, short* llr, int nsymbols)
int16x8_t result31 = vdupq_n_s16(0); int16x8_t result31 = vdupq_n_s16(0);
for (int i = 0; i < nsymbols / 4; i++) { for (int i = 0; i < nsymbols / 4; i++) {
symbol1 = vld1q_f32(symbolsPtr); symbol1 = vld1q_f32(symbolsPtr);
symbolsPtr += 4; symbolsPtr += 4;
symbol2 = vld1q_f32(symbolsPtr); symbol2 = vld1q_f32(symbolsPtr);
@ -511,7 +509,6 @@ void demod_64qam_lte_b_neon(const cf_t* symbols, int8_t* llr, int nsymbols)
int8x16_t result31 = vdupq_n_s8(0); int8x16_t result31 = vdupq_n_s8(0);
for (int i = 0; i < nsymbols / 8; i++) { for (int i = 0; i < nsymbols / 8; i++) {
symbol1 = vld1q_f32(symbolsPtr); symbol1 = vld1q_f32(symbolsPtr);
symbolsPtr += 4; symbolsPtr += 4;
symbol2 = vld1q_f32(symbolsPtr); symbol2 = vld1q_f32(symbolsPtr);
@ -878,7 +875,7 @@ int srslte_demod_soft_demodulate(srslte_mod_t modulation, const cf_t* symbols, f
demod_256qam_lte(symbols, llr, nsymbols); demod_256qam_lte(symbols, llr, nsymbols);
break; break;
default: default:
ERROR("Invalid modulation %d\n", modulation); ERROR("Invalid modulation %d", modulation);
return -1; return -1;
} }
return 0; return 0;
@ -903,7 +900,7 @@ int srslte_demod_soft_demodulate_s(srslte_mod_t modulation, const cf_t* symbols,
demod_256qam_lte_s(symbols, llr, nsymbols); demod_256qam_lte_s(symbols, llr, nsymbols);
break; break;
default: default:
ERROR("Invalid modulation %d\n", modulation); ERROR("Invalid modulation %d", modulation);
return -1; return -1;
} }
return 0; return 0;
@ -928,7 +925,7 @@ int srslte_demod_soft_demodulate_b(srslte_mod_t modulation, const cf_t* symbols,
demod_256qam_lte_b(symbols, llr, nsymbols); demod_256qam_lte_b(symbols, llr, nsymbols);
break; break;
default: default:
ERROR("Invalid modulation %d\n", modulation); ERROR("Invalid modulation %d", modulation);
return -1; return -1;
} }
return 0; return 0;

@ -125,13 +125,12 @@ static void mod_256qam_bytes(const srslte_modem_table_t* q, const uint8_t* bits,
/* Assumes packet bits as input */ /* Assumes packet bits as input */
int srslte_mod_modulate_bytes(const srslte_modem_table_t* q, const uint8_t* bits, cf_t* symbols, uint32_t nbits) int srslte_mod_modulate_bytes(const srslte_modem_table_t* q, const uint8_t* bits, cf_t* symbols, uint32_t nbits)
{ {
if (!q->byte_tables_init) { if (!q->byte_tables_init) {
ERROR("Error need to initiated modem tables for packeted bits before calling srslte_mod_modulate_bytes()\n"); ERROR("Error need to initiated modem tables for packeted bits before calling srslte_mod_modulate_bytes()");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (nbits % q->nbits_x_symbol) { if (nbits % q->nbits_x_symbol) {
ERROR("Error modulator expects number of bits (%d) to be multiple of %d\n", nbits, q->nbits_x_symbol); ERROR("Error modulator expects number of bits (%d) to be multiple of %d", nbits, q->nbits_x_symbol);
return -1; return -1;
} }
switch (q->nbits_x_symbol) { switch (q->nbits_x_symbol) {
@ -151,7 +150,7 @@ int srslte_mod_modulate_bytes(const srslte_modem_table_t* q, const uint8_t* bits
mod_256qam_bytes(q, bits, symbols, nbits); mod_256qam_bytes(q, bits, symbols, nbits);
break; break;
default: default:
ERROR("srslte_mod_modulate_bytes() accepts QPSK/16QAM/64QAM modulations only\n"); ERROR("srslte_mod_modulate_bytes() accepts QPSK/16QAM/64QAM modulations only");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
return nbits / q->nbits_x_symbol; return nbits / q->nbits_x_symbol;

@ -86,7 +86,7 @@ int main(int argc, char** argv)
/* initialize objects */ /* initialize objects */
if (srslte_modem_table_lte(&mod, modulation)) { if (srslte_modem_table_lte(&mod, modulation)) {
ERROR("Error initializing modem table\n"); ERROR("Error initializing modem table");
exit(-1); exit(-1);
} }
@ -94,7 +94,7 @@ int main(int argc, char** argv)
/* check that num_bits is multiple of num_bits x symbol */ /* check that num_bits is multiple of num_bits x symbol */
if (num_bits % mod.nbits_x_symbol) { if (num_bits % mod.nbits_x_symbol) {
ERROR("Error num_bits must be multiple of %d\n", mod.nbits_x_symbol); ERROR("Error num_bits must be multiple of %d", mod.nbits_x_symbol);
exit(-1); exit(-1);
} }
@ -180,7 +180,7 @@ int main(int argc, char** argv)
/* check errors */ /* check errors */
for (i = 0; i < num_bits && ret == SRSLTE_SUCCESS; i++) { for (i = 0; i < num_bits && ret == SRSLTE_SUCCESS; i++) {
if (input[i] != output[i]) { if (input[i] != output[i]) {
ERROR("Error in bit %d\n", i); ERROR("Error in bit %d", i);
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
} }
} }

@ -66,7 +66,7 @@ void parse_args(int argc, char** argv)
break; break;
default: default:
ERROR("Invalid modulation %d. Possible values: " ERROR("Invalid modulation %d. Possible values: "
"(1: BPSK, 2: QPSK, 4: QAM16, 6: QAM64)\n", "(1: BPSK, 2: QPSK, 4: QAM16, 6: QAM64)",
(int)strtol(argv[optind], NULL, 10)); (int)strtol(argv[optind], NULL, 10));
break; break;
} }
@ -114,7 +114,7 @@ int main(int argc, char** argv)
/* initialize objects */ /* initialize objects */
if (srslte_modem_table_lte(&mod, modulation)) { if (srslte_modem_table_lte(&mod, modulation)) {
ERROR("Error initializing modem table\n"); ERROR("Error initializing modem table");
exit(-1); exit(-1);
} }

@ -63,7 +63,7 @@ int srslte_dci_rar_to_ul_dci(srslte_cell_t* cell, srslte_dci_rar_grant_t* rar, s
if (!rar->hopping_flag) { if (!rar->hopping_flag) {
dci_ul->freq_hop_fl = SRSLTE_RA_PUSCH_HOP_DISABLED; dci_ul->freq_hop_fl = SRSLTE_RA_PUSCH_HOP_DISABLED;
} else { } else {
ERROR("TODO: Frequency hopping in RAR not implemented\n"); ERROR("TODO: Frequency hopping in RAR not implemented");
dci_ul->freq_hop_fl = 1; dci_ul->freq_hop_fl = 1;
} }
uint32_t riv = rar->rba; uint32_t riv = rar->rba;
@ -204,7 +204,6 @@ static uint32_t dci_format0_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t
static uint32_t dci_format1_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg) static uint32_t dci_format1_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg)
{ {
uint32_t n = (uint32_t)ceilf((float)cell->nof_prb / srslte_ra_type0_P(cell->nof_prb)) + 5 + HARQ_PID_LEN + 1 + 2 + 2 + uint32_t n = (uint32_t)ceilf((float)cell->nof_prb / srslte_ra_type0_P(cell->nof_prb)) + 5 + HARQ_PID_LEN + 1 + 2 + 2 +
(cfg->cif_enabled ? 3 : 0) + (IS_TDD ? 2 : 0); (cfg->cif_enabled ? 3 : 0) + (IS_TDD ? 2 : 0);
if (cell->nof_prb > 10) { if (cell->nof_prb > 10) {
@ -410,7 +409,6 @@ static int dci_format0_pack(srslte_cell_t* cell,
srslte_dci_ul_t* dci, srslte_dci_ul_t* dci,
srslte_dci_msg_t* msg) srslte_dci_msg_t* msg)
{ {
/* pack bits */ /* pack bits */
uint8_t* y = msg->payload; uint8_t* y = msg->payload;
uint32_t n_ul_hop; uint32_t n_ul_hop;
@ -488,7 +486,6 @@ static int dci_format0_unpack(srslte_cell_t* cell,
srslte_dci_msg_t* msg, srslte_dci_msg_t* msg,
srslte_dci_ul_t* dci) srslte_dci_ul_t* dci)
{ {
/* pack bits */ /* pack bits */
uint8_t* y = msg->payload; uint8_t* y = msg->payload;
uint32_t n_ul_hop; uint32_t n_ul_hop;
@ -499,7 +496,7 @@ static int dci_format0_unpack(srslte_cell_t* cell,
} }
if (*y++ != 0) { if (*y++ != 0) {
INFO("DCI message is Format1A\n"); INFO("DCI message is Format1A");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -602,7 +599,7 @@ static int dci_format1_pack(srslte_cell_t* cell,
srslte_bit_unpack((uint32_t)dci->type1_alloc.vrb_bitmask, &y, alloc_size - (int)ceilf(log2f(P)) - 1); srslte_bit_unpack((uint32_t)dci->type1_alloc.vrb_bitmask, &y, alloc_size - (int)ceilf(log2f(P)) - 1);
break; break;
default: default:
ERROR("Format 1 accepts type0 or type1 resource allocation only\n"); ERROR("Format 1 accepts type0 or type1 resource allocation only");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
/* pack MCS */ /* pack MCS */
@ -626,7 +623,7 @@ static int dci_format1_pack(srslte_cell_t* cell,
msg->nof_bits = (y - msg->payload); msg->nof_bits = (y - msg->payload);
if (msg->nof_bits != dci_format1_sizeof(cell, sf, cfg)) { if (msg->nof_bits != dci_format1_sizeof(cell, sf, cfg)) {
ERROR("Invalid message length for format 1 (Cross scheduling %s)\n", dci->cif_present ? "enabled" : "disabled"); ERROR("Invalid message length for format 1 (Cross scheduling %s)", dci->cif_present ? "enabled" : "disabled");
} }
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
@ -638,14 +635,13 @@ static int dci_format1_unpack(srslte_cell_t* cell,
srslte_dci_msg_t* msg, srslte_dci_msg_t* msg,
srslte_dci_dl_t* dci) srslte_dci_dl_t* dci)
{ {
/* pack bits */ /* pack bits */
uint8_t* y = msg->payload; uint8_t* y = msg->payload;
/* Make sure it's a SRSLTE_DCI_FORMAT1 message */ /* Make sure it's a SRSLTE_DCI_FORMAT1 message */
uint32_t msg_len = srslte_dci_format_sizeof(cell, sf, cfg, SRSLTE_DCI_FORMAT1); uint32_t msg_len = srslte_dci_format_sizeof(cell, sf, cfg, SRSLTE_DCI_FORMAT1);
if (msg->nof_bits != msg_len) { if (msg->nof_bits != msg_len) {
ERROR("Invalid message length (%d!=%d) for format 1\n", msg->nof_bits, msg_len); ERROR("Invalid message length (%d!=%d) for format 1", msg->nof_bits, msg_len);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -673,7 +669,7 @@ static int dci_format1_unpack(srslte_cell_t* cell,
dci->type1_alloc.vrb_bitmask = srslte_bit_pack(&y, alloc_size - (int)ceilf(log2f(P)) - 1); dci->type1_alloc.vrb_bitmask = srslte_bit_pack(&y, alloc_size - (int)ceilf(log2f(P)) - 1);
break; break;
default: default:
ERROR("Format 1 accepts type0 or type1 resource allocation only\n"); ERROR("Format 1 accepts type0 or type1 resource allocation only");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
/* unpack MCS according to 7.1.7 of 36.213 */ /* unpack MCS according to 7.1.7 of 36.213 */
@ -719,7 +715,7 @@ static int dci_format1As_pack(srslte_cell_t* cell,
*y++ = 1; // format differentiation *y++ = 1; // format differentiation
if (dci->alloc_type != SRSLTE_RA_ALLOC_TYPE2) { if (dci->alloc_type != SRSLTE_RA_ALLOC_TYPE2) {
ERROR("Format 1A accepts type2 resource allocation only\n"); ERROR("Format 1A accepts type2 resource allocation only");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -780,7 +776,6 @@ static int dci_format1As_unpack(srslte_cell_t* cell,
srslte_dci_msg_t* msg, srslte_dci_msg_t* msg,
srslte_dci_dl_t* dci) srslte_dci_dl_t* dci)
{ {
/* pack bits */ /* pack bits */
uint8_t* y = msg->payload; uint8_t* y = msg->payload;
@ -790,7 +785,7 @@ static int dci_format1As_unpack(srslte_cell_t* cell,
} }
if (*y++ != 1) { if (*y++ != 1) {
INFO("DCI message is Format0\n"); INFO("DCI message is Format0");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -883,7 +878,6 @@ static int dci_format1B_unpack(srslte_cell_t* cell,
srslte_dci_msg_t* msg, srslte_dci_msg_t* msg,
srslte_dci_dl_t* dci) srslte_dci_dl_t* dci)
{ {
/* pack bits */ /* pack bits */
uint8_t* y = msg->payload; uint8_t* y = msg->payload;
@ -937,7 +931,6 @@ static int dci_format1Cs_pack(srslte_cell_t* cell,
srslte_dci_dl_t* dci, srslte_dci_dl_t* dci,
srslte_dci_msg_t* msg) srslte_dci_msg_t* msg)
{ {
uint32_t nof_prb = cell->nof_prb; uint32_t nof_prb = cell->nof_prb;
/* pack bits */ /* pack bits */
@ -948,7 +941,7 @@ static int dci_format1Cs_pack(srslte_cell_t* cell,
} }
if (dci->alloc_type != SRSLTE_RA_ALLOC_TYPE2 || dci->type2_alloc.mode != SRSLTE_RA_TYPE2_DIST) { if (dci->alloc_type != SRSLTE_RA_ALLOC_TYPE2 || dci->type2_alloc.mode != SRSLTE_RA_TYPE2_DIST) {
ERROR("Format 1C accepts distributed type2 resource allocation only\n"); ERROR("Format 1C accepts distributed type2 resource allocation only");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -980,7 +973,7 @@ static int dci_format1Cs_unpack(srslte_cell_t* cell,
uint8_t* y = msg->payload; uint8_t* y = msg->payload;
if (msg->nof_bits != srslte_dci_format_sizeof(cell, sf, cfg, SRSLTE_DCI_FORMAT1C)) { if (msg->nof_bits != srslte_dci_format_sizeof(cell, sf, cfg, SRSLTE_DCI_FORMAT1C)) {
ERROR("Invalid message length for format 1C\n"); ERROR("Invalid message length for format 1C");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1011,7 +1004,6 @@ static int dci_format1D_unpack(srslte_cell_t* cell,
srslte_dci_msg_t* msg, srslte_dci_msg_t* msg,
srslte_dci_dl_t* dci) srslte_dci_dl_t* dci)
{ {
/* pack bits */ /* pack bits */
uint8_t* y = msg->payload; uint8_t* y = msg->payload;
@ -1063,7 +1055,6 @@ static int dci_format2AB_pack(srslte_cell_t* cell,
srslte_dci_dl_t* dci, srslte_dci_dl_t* dci,
srslte_dci_msg_t* msg) srslte_dci_msg_t* msg)
{ {
uint32_t nof_prb = cell->nof_prb; uint32_t nof_prb = cell->nof_prb;
uint32_t nof_ports = cell->nof_ports; uint32_t nof_ports = cell->nof_ports;
@ -1091,7 +1082,7 @@ static int dci_format2AB_pack(srslte_cell_t* cell,
srslte_bit_unpack((uint32_t)dci->type1_alloc.vrb_bitmask, &y, alloc_size - (int)ceilf(log2f(P)) - 1); srslte_bit_unpack((uint32_t)dci->type1_alloc.vrb_bitmask, &y, alloc_size - (int)ceilf(log2f(P)) - 1);
break; break;
default: default:
ERROR("Format 1 accepts type0 or type1 resource allocation only\n"); ERROR("Format 1 accepts type0 or type1 resource allocation only");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1141,7 +1132,6 @@ static int dci_format2AB_unpack(srslte_cell_t* cell,
srslte_dci_msg_t* msg, srslte_dci_msg_t* msg,
srslte_dci_dl_t* dci) srslte_dci_dl_t* dci)
{ {
/* pack bits */ /* pack bits */
uint8_t* y = msg->payload; uint8_t* y = msg->payload;
@ -1169,7 +1159,7 @@ static int dci_format2AB_unpack(srslte_cell_t* cell,
dci->type1_alloc.vrb_bitmask = srslte_bit_pack(&y, alloc_size - (int)ceilf(log2f(P)) - 1); dci->type1_alloc.vrb_bitmask = srslte_bit_pack(&y, alloc_size - (int)ceilf(log2f(P)) - 1);
break; break;
default: default:
ERROR("Format2 accepts type0 or type1 resource allocation only\n"); ERROR("Format2 accepts type0 or type1 resource allocation only");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1260,7 +1250,7 @@ int srslte_dci_msg_pack_pdsch(srslte_cell_t* cell,
ret = dci_format2AB_pack(cell, sf, cfg, dci, msg); ret = dci_format2AB_pack(cell, sf, cfg, dci, msg);
break; break;
default: default:
ERROR("DCI pack pdsch: Invalid DCI format %s\n", srslte_dci_format_string(msg->format)); ERROR("DCI pack pdsch: Invalid DCI format %s", srslte_dci_format_string(msg->format));
} }
#if SRSLTE_DCI_HEXDEBUG #if SRSLTE_DCI_HEXDEBUG
@ -1320,7 +1310,7 @@ int srslte_dci_msg_unpack_pdsch(srslte_cell_t* cell,
case SRSLTE_DCI_FORMAT2B: case SRSLTE_DCI_FORMAT2B:
return dci_format2AB_unpack(cell, sf, cfg, msg, dci); return dci_format2AB_unpack(cell, sf, cfg, msg, dci);
default: default:
ERROR("DCI unpack pdsch: Invalid DCI format %s\n", srslte_dci_format_string(msg->format)); ERROR("DCI unpack pdsch: Invalid DCI format %s", srslte_dci_format_string(msg->format));
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -1411,13 +1401,13 @@ int srslte_dci_location_set(srslte_dci_location_t* c, uint32_t L, uint32_t nCCE)
if (L <= 3) { if (L <= 3) {
c->L = L; c->L = L;
} else { } else {
ERROR("Invalid L %d\n", L); ERROR("Invalid L %d", L);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (nCCE <= 87) { if (nCCE <= 87) {
c->ncce = nCCE; c->ncce = nCCE;
} else { } else {
ERROR("Invalid nCCE %d\n", nCCE); ERROR("Invalid nCCE %d", nCCE);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;

@ -282,7 +282,7 @@ int srslte_npbch_encode(srslte_npbch_t* q,
// generate new BCH message every 64 frames // generate new BCH message every 64 frames
if ((frame_idx % SRSLTE_NPBCH_NUM_FRAMES) == 0) { if ((frame_idx % SRSLTE_NPBCH_NUM_FRAMES) == 0) {
INFO("Encoding new NPBCH signal in frame %d.\n", frame_idx); INFO("Encoding new NPBCH signal in frame %d.", frame_idx);
memcpy(q->data, bch_payload, sizeof(uint8_t) * SRSLTE_MIB_NB_LEN); memcpy(q->data, bch_payload, sizeof(uint8_t) * SRSLTE_MIB_NB_LEN);
@ -297,7 +297,7 @@ int srslte_npbch_encode(srslte_npbch_t* q,
// Scramble and modulate a new block every 8 frames // Scramble and modulate a new block every 8 frames
if (frame_idx % SRSLTE_NPBCH_NUM_REP == 0) { if (frame_idx % SRSLTE_NPBCH_NUM_REP == 0) {
INFO("Modulating MIB-NB block %d in frame %d.\n", block_idx, frame_idx); INFO("Modulating MIB-NB block %d in frame %d.", block_idx, frame_idx);
srslte_scrambling_b_offset(&q->seq, &q->rm_b[block_idx * nof_bits], block_idx * nof_bits, nof_bits); srslte_scrambling_b_offset(&q->seq, &q->rm_b[block_idx * nof_bits], block_idx * nof_bits, nof_bits);
srslte_mod_modulate(&q->mod, &q->rm_b[block_idx * nof_bits], q->d, nof_bits); srslte_mod_modulate(&q->mod, &q->rm_b[block_idx * nof_bits], q->d, nof_bits);
@ -313,12 +313,12 @@ int srslte_npbch_encode(srslte_npbch_t* q,
// Write exactly SRSLTE_NPBCH_NUM_RE (assumes symbols have been modulated before) // Write exactly SRSLTE_NPBCH_NUM_RE (assumes symbols have been modulated before)
for (int i = 0; i < q->cell.nof_ports; i++) { for (int i = 0; i < q->cell.nof_ports; i++) {
if (q->cell.is_r14) { if (q->cell.is_r14) {
DEBUG("Applying phase rotation on port %d in frame %d.\n", i, frame_idx); DEBUG("Applying phase rotation on port %d in frame %d.", i, frame_idx);
srslte_npbch_rotate(q, frame_idx, q->symbols[i], q->symbols[i], q->nof_symbols, false); srslte_npbch_rotate(q, frame_idx, q->symbols[i], q->symbols[i], q->nof_symbols, false);
} }
DEBUG("Putting MIB-NB block %d on port %d in frame %d.\n", block_idx, i, frame_idx); DEBUG("Putting MIB-NB block %d on port %d in frame %d.", block_idx, i, frame_idx);
if (srslte_npbch_cp(q->symbols[i], sf[i], q->cell, true) != SRSLTE_NPBCH_NUM_RE) { if (srslte_npbch_cp(q->symbols[i], sf[i], q->cell, true) != SRSLTE_NPBCH_NUM_RE) {
INFO("Error while mapping NPBCH symbols.\n"); INFO("Error while mapping NPBCH symbols.");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -337,7 +337,7 @@ int srslte_npbch_rotate(srslte_npbch_t* q,
bool back) bool back)
{ {
// Generate frame specific scrambling sequence for symbol rotation // Generate frame specific scrambling sequence for symbol rotation
DEBUG("%sotating NPBCH in SFN=%d\n", back ? "De-R" : "R", nf); DEBUG("%sotating NPBCH in SFN=%d", back ? "De-R" : "R", nf);
for (int i = 0; i < num_samples; i++) { for (int i = 0; i < num_samples; i++) {
int c_2i = q->seq_r14[nf % 8].c[2 * i]; int c_2i = q->seq_r14[nf % 8].c[2 * i];
@ -443,7 +443,7 @@ int srslte_npbch_decode_nf(srslte_npbch_t* q,
} }
do { do {
if (nant != 3) { if (nant != 3) {
DEBUG("Trying %d TX antennas with %d frames\n", nant, q->frame_idx); DEBUG("Trying %d TX antennas with %d frames", nant, q->frame_idx);
// in control channels, only diversity is supported // in control channels, only diversity is supported
if (nant == 1) { if (nant == 1) {
@ -458,7 +458,7 @@ int srslte_npbch_decode_nf(srslte_npbch_t* q,
srslte_demod_soft_demodulate(SRSLTE_MOD_QPSK, q->d, &q->llr[nof_bits * (q->frame_idx - 1)], q->nof_symbols); srslte_demod_soft_demodulate(SRSLTE_MOD_QPSK, q->d, &q->llr[nof_bits * (q->frame_idx - 1)], q->nof_symbols);
// only one subframe // only one subframe
DEBUG("Trying to decode NPBCH ..\n"); DEBUG("Trying to decode NPBCH ..");
// TODO: simplified decoding only using first MIB block // TODO: simplified decoding only using first MIB block
ret = srslte_npbch_decode_frame(q, 0, nf, 1, nof_bits, nant); ret = srslte_npbch_decode_frame(q, 0, nf, 1, nof_bits, nant);
@ -472,7 +472,7 @@ int srslte_npbch_decode_nf(srslte_npbch_t* q,
if (bch_payload) { if (bch_payload) {
memcpy(bch_payload, q->data, sizeof(uint8_t) * SRSLTE_MIB_NB_LEN); memcpy(bch_payload, q->data, sizeof(uint8_t) * SRSLTE_MIB_NB_LEN);
} }
INFO("Successfully decoded NPBCH sfn_offset=%d\n", q->frame_idx - 1); INFO("Successfully decoded NPBCH sfn_offset=%d", q->frame_idx - 1);
q->frame_idx = 0; q->frame_idx = 0;
return ret; return ret;
} }

@ -43,7 +43,7 @@ int srslte_npdcch_init(srslte_npdcch_t* q)
q->max_bits = SRSLTE_CP_NORM_SF_NSYMB * SRSLTE_NRE * 2; q->max_bits = SRSLTE_CP_NORM_SF_NSYMB * SRSLTE_NRE * 2;
q->ncce_bits = q->max_bits / 2; q->ncce_bits = q->max_bits / 2;
INFO("Init NPDCCH: Max bits: %d, %d ports.\n", q->max_bits, q->cell.nof_ports); INFO("Init NPDCCH: Max bits: %d, %d ports.", q->max_bits, q->cell.nof_ports);
if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_QPSK)) { if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_QPSK)) {
goto clean; goto clean;
@ -239,7 +239,7 @@ int srslte_npdcch_decode_msg(srslte_npdcch_t* q,
// Get the right softbits for this aggregation level // Get the right softbits for this aggregation level
float* llr = (location->L == 1) ? q->llr[0] : q->llr[1]; float* llr = (location->L == 1) ? q->llr[0] : q->llr[1];
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("LLR:\n"); DEBUG("LLR:");
srslte_vec_fprint_f(stdout, llr, q->max_bits); srslte_vec_fprint_f(stdout, llr, q->max_bits);
} }
@ -263,7 +263,7 @@ int srslte_npdcch_decode_msg(srslte_npdcch_t* q,
fprintf(stderr, "Error calling npdcch_dci_decode\n"); fprintf(stderr, "Error calling npdcch_dci_decode\n");
} }
if (crc_rem) { if (crc_rem) {
DEBUG("Decoded DCI: nCCE=%d, L=%d, format=%s, msg_len=%d, mean=%f, crc_rem=0x%x\n", DEBUG("Decoded DCI: nCCE=%d, L=%d, format=%s, msg_len=%d, mean=%f, crc_rem=0x%x",
location->ncce, location->ncce,
location->L, location->L,
srslte_dci_format_string(msg->format), srslte_dci_format_string(msg->format),
@ -272,7 +272,7 @@ int srslte_npdcch_decode_msg(srslte_npdcch_t* q,
*crc_rem); *crc_rem);
} }
} else { } else {
DEBUG("Skipping DCI: nCCE=%d, L=%d, msg_len=%d, mean=%f\n", location->ncce, location->L, nof_bits, mean); DEBUG("Skipping DCI: nCCE=%d, L=%d, msg_len=%d, mean=%f", location->ncce, location->L, nof_bits, mean);
} }
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;
} else { } else {
@ -324,7 +324,7 @@ int srslte_npdcch_extract_llr(srslte_npdcch_t* q,
} }
num_symbols = e_bits / 2; num_symbols = e_bits / 2;
DEBUG("Extracting LLRs for NPDCCH %s: E: %d, SF: %d\n", srslte_npdcch_format_text[i], e_bits, sf_idx); DEBUG("Extracting LLRs for NPDCCH %s: E: %d, SF: %d", srslte_npdcch_format_text[i], e_bits, sf_idx);
if (i != SRSLTE_NPDCCH_FORMAT0_UPPER_HALF) { if (i != SRSLTE_NPDCCH_FORMAT0_UPPER_HALF) {
// don't overwrite lower half LLRs // don't overwrite lower half LLRs
@ -346,7 +346,7 @@ int srslte_npdcch_extract_llr(srslte_npdcch_t* q,
#if DUMP_SIGNALS #if DUMP_SIGNALS
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE npdcch_rx_mapping_output.bin: NPDCCH after extracting symbols\n"); DEBUG("SAVED FILE npdcch_rx_mapping_output.bin: NPDCCH after extracting symbols");
srslte_vec_save_file("npdcch_rx_mapping_output.bin", q->symbols[0], n * sizeof(cf_t)); srslte_vec_save_file("npdcch_rx_mapping_output.bin", q->symbols[0], n * sizeof(cf_t));
} }
#endif #endif
@ -371,7 +371,7 @@ int srslte_npdcch_extract_llr(srslte_npdcch_t* q,
#if DUMP_SIGNALS #if DUMP_SIGNALS
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE npdcch_rx_predecode_output.bin: NPDCCH after predecoding symbols\n"); DEBUG("SAVED FILE npdcch_rx_predecode_output.bin: NPDCCH after predecoding symbols");
srslte_vec_save_file("npdcch_rx_predecode_output.bin", q->d, q->num_decoded_symbols * sizeof(cf_t)); srslte_vec_save_file("npdcch_rx_predecode_output.bin", q->d, q->num_decoded_symbols * sizeof(cf_t));
} }
#endif #endif
@ -384,7 +384,7 @@ int srslte_npdcch_extract_llr(srslte_npdcch_t* q,
#if DUMP_SIGNALS #if DUMP_SIGNALS
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE npdcch_rx_descramble_output.bin: NPDCCH after de-scrambling\n"); DEBUG("SAVED FILE npdcch_rx_descramble_output.bin: NPDCCH after de-scrambling");
srslte_vec_save_file("npdcch_rx_descramble_output.bin", llr, e_bits); srslte_vec_save_file("npdcch_rx_descramble_output.bin", llr, e_bits);
} }
#endif #endif
@ -398,9 +398,9 @@ int srslte_npdcch_extract_llr(srslte_npdcch_t* q,
static void crc_set_mask_rnti(uint8_t* crc, uint16_t rnti) static void crc_set_mask_rnti(uint8_t* crc, uint16_t rnti)
{ {
uint8_t mask[16] = {}; uint8_t mask[16] = {};
uint8_t* r = mask; uint8_t* r = mask;
DEBUG("Mask CRC with RNTI 0x%x\n", rnti); DEBUG("Mask CRC with RNTI 0x%x", rnti);
srslte_bit_unpack(rnti, &r, 16); srslte_bit_unpack(rnti, &r, 16);
for (uint32_t i = 0; i < 16; i++) { for (uint32_t i = 0; i < 16; i++) {
@ -426,7 +426,7 @@ void srslte_npdcch_dci_encode_conv(srslte_npdcch_t* q,
#if DUMP_SIGNALS #if DUMP_SIGNALS
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE npdcch_tx_convcoder_input.bin: NPDCCH before convolution coding\n"); DEBUG("SAVED FILE npdcch_tx_convcoder_input.bin: NPDCCH before convolution coding");
srslte_vec_save_file("npdcch_tx_convcoder_input.bin", data, nof_bits + 16); srslte_vec_save_file("npdcch_tx_convcoder_input.bin", data, nof_bits + 16);
} }
#endif #endif
@ -472,12 +472,12 @@ int srslte_npdcch_encode(srslte_npdcch_t* q,
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL && sf_symbols != NULL && nsubframe < 10 && srslte_nbiot_dci_location_isvalid(&location)) { if (q != NULL && sf_symbols != NULL && nsubframe < 10 && srslte_nbiot_dci_location_isvalid(&location)) {
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
uint32_t e_bits = q->nof_cce * q->ncce_bits; uint32_t e_bits = q->nof_cce * q->ncce_bits;
uint32_t nof_symbols = e_bits / 2; uint32_t nof_symbols = e_bits / 2;
if (msg->nof_bits < SRSLTE_DCI_MAX_BITS - 16) { if (msg->nof_bits < SRSLTE_DCI_MAX_BITS - 16) {
DEBUG("Encoding DCI: Nbits: %d, E: %d, nCCE: %d, L: %d, RNTI: 0x%x, sf_idx: %d\n", DEBUG("Encoding DCI: Nbits: %d, E: %d, nCCE: %d, L: %d, RNTI: 0x%x, sf_idx: %d",
msg->nof_bits, msg->nof_bits,
e_bits, e_bits,
location.ncce, location.ncce,
@ -499,7 +499,7 @@ int srslte_npdcch_encode(srslte_npdcch_t* q,
#if DUMP_SIGNALS #if DUMP_SIGNALS
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE npdcch_tx_scramble_input.bin: NPDCCH before scrambling\n"); DEBUG("SAVED FILE npdcch_tx_scramble_input.bin: NPDCCH before scrambling");
srslte_vec_save_file("npdcch_tx_scramble_input.bin", q->e, e_bits); srslte_vec_save_file("npdcch_tx_scramble_input.bin", q->e, e_bits);
} }
#endif #endif
@ -508,7 +508,7 @@ int srslte_npdcch_encode(srslte_npdcch_t* q,
#if DUMP_SIGNALS #if DUMP_SIGNALS
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE npdcch_tx_mod_input.bin: NPDCCH before modulation\n"); DEBUG("SAVED FILE npdcch_tx_mod_input.bin: NPDCCH before modulation");
srslte_vec_save_file("npdcch_tx_mod_input.bin", q->e, e_bits); srslte_vec_save_file("npdcch_tx_mod_input.bin", q->e, e_bits);
} }
#endif #endif
@ -517,7 +517,7 @@ int srslte_npdcch_encode(srslte_npdcch_t* q,
#if DUMP_SIGNALS #if DUMP_SIGNALS
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE npdcch_tx_precode_input.bin: NPDCCH before precoding symbols\n"); DEBUG("SAVED FILE npdcch_tx_precode_input.bin: NPDCCH before precoding symbols");
srslte_vec_save_file("npdcch_tx_precode_input.bin", q->d, nof_symbols * sizeof(cf_t)); srslte_vec_save_file("npdcch_tx_precode_input.bin", q->d, nof_symbols * sizeof(cf_t));
} }
#endif #endif
@ -532,7 +532,7 @@ int srslte_npdcch_encode(srslte_npdcch_t* q,
#if DUMP_SIGNALS #if DUMP_SIGNALS
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE npdcch_tx_mapping_input.bin: NPDCCH before mapping to resource elements\n"); DEBUG("SAVED FILE npdcch_tx_mapping_input.bin: NPDCCH before mapping to resource elements");
srslte_vec_save_file("npdcch_tx_mapping_input.bin", q->symbols[0], nof_symbols * sizeof(cf_t)); srslte_vec_save_file("npdcch_tx_mapping_input.bin", q->symbols[0], nof_symbols * sizeof(cf_t));
} }
#endif #endif

@ -182,7 +182,7 @@ int srslte_npdsch_init(srslte_npdsch_t* q)
q->max_re = SRSLTE_NPDSCH_MAX_RE * SRSLTE_NPDSCH_MAX_NOF_SF; q->max_re = SRSLTE_NPDSCH_MAX_RE * SRSLTE_NPDSCH_MAX_NOF_SF;
q->rnti_is_set = false; q->rnti_is_set = false;
INFO("Init NPDSCH: max_re's: %d\n", q->max_re); INFO("Init NPDSCH: max_re's: %d", q->max_re);
if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_QPSK)) { if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_QPSK)) {
goto clean; goto clean;
@ -292,7 +292,7 @@ int srslte_npdsch_set_cell(srslte_npdsch_t* q, srslte_nbiot_cell_t cell)
if (q != NULL && srslte_nbiot_cell_isvalid(&cell)) { if (q != NULL && srslte_nbiot_cell_isvalid(&cell)) {
q->cell = cell; q->cell = cell;
INFO("NPDSCH: Cell config n_id_ncell=%d, %d ports, %d PRBs base cell, max_symbols: %d\n", INFO("NPDSCH: Cell config n_id_ncell=%d, %d ports, %d PRBs base cell, max_symbols: %d",
q->cell.n_id_ncell, q->cell.n_id_ncell,
q->cell.nof_ports, q->cell.nof_ports,
q->cell.base.nof_prb, q->cell.base.nof_prb,
@ -367,7 +367,7 @@ int srslte_npdsch_decode_rnti(srslte_npdsch_t* q,
cf_t* x[SRSLTE_MAX_LAYERS]; cf_t* x[SRSLTE_MAX_LAYERS];
if (q != NULL && sf_symbols != NULL && data != NULL && cfg != NULL) { if (q != NULL && sf_symbols != NULL && data != NULL && cfg != NULL) {
INFO("%d.x: Decoding NPDSCH: RNTI: 0x%x, Mod %s, TBS: %d, NofSymbols: %d * %d, NofBitsE: %d * %d\n", INFO("%d.x: Decoding NPDSCH: RNTI: 0x%x, Mod %s, TBS: %d, NofSymbols: %d * %d, NofBitsE: %d * %d",
sfn, sfn,
rnti, rnti,
srslte_mod_string(cfg->grant.mcs[0].mod), srslte_mod_string(cfg->grant.mcs[0].mod),
@ -411,7 +411,7 @@ int srslte_npdsch_decode_rnti(srslte_npdsch_t* q,
#if DUMP_SIGNALS #if DUMP_SIGNALS
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE npdsch_rx_mapping_output.bin: NPDSCH after extracting symbols\n", 0); DEBUG("SAVED FILE npdsch_rx_mapping_output.bin: NPDSCH after extracting symbols", 0);
srslte_vec_save_file( srslte_vec_save_file(
"npdsch_rx_mapping_output.bin", q->symbols[0], cfg->grant.nof_sf * cfg->nbits.nof_re * sizeof(cf_t)); "npdsch_rx_mapping_output.bin", q->symbols[0], cfg->grant.nof_sf * cfg->nbits.nof_re * sizeof(cf_t));
} }
@ -431,7 +431,7 @@ int srslte_npdsch_decode_rnti(srslte_npdsch_t* q,
#if DUMP_SIGNALS #if DUMP_SIGNALS
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE npdsch_rx_predecode_output.bin: NPDSCH after predecoding symbols\n", 0); DEBUG("SAVED FILE npdsch_rx_predecode_output.bin: NPDSCH after predecoding symbols", 0);
srslte_vec_save_file( srslte_vec_save_file(
"npdsch_rx_predecode_output.bin", q->d, cfg->grant.nof_sf * cfg->nbits.nof_re * sizeof(cf_t)); "npdsch_rx_predecode_output.bin", q->d, cfg->grant.nof_sf * cfg->nbits.nof_re * sizeof(cf_t));
} }
@ -442,10 +442,10 @@ int srslte_npdsch_decode_rnti(srslte_npdsch_t* q,
#if DUMP_SIGNALS #if DUMP_SIGNALS
uint8_t demodbuf[320]; uint8_t demodbuf[320];
hard_qpsk_demod(q->d,demodbuf,cfg->nbits.nof_re); hard_qpsk_demod(q->d, demodbuf, cfg->nbits.nof_re);
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE npdsch_rx_demod_output.bin: NPDSCH after (hard) de-modulation\n",0); DEBUG("SAVED FILE npdsch_rx_demod_output.bin: NPDSCH after (hard) de-modulation", 0);
srslte_vec_save_file("npdsch_rx_demod_output.bin", demodbuf, cfg->nbits.nof_bits); srslte_vec_save_file("npdsch_rx_demod_output.bin", demodbuf, cfg->nbits.nof_bits);
} }
#endif #endif
@ -482,7 +482,7 @@ int srslte_npdsch_decode_rnti(srslte_npdsch_t* q,
#if DUMP_SIGNALS #if DUMP_SIGNALS
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE npdsch_rx_descramble_output.bin: NPDSCH after de-scrambling\n", 0); DEBUG("SAVED FILE npdsch_rx_descramble_output.bin: NPDSCH after de-scrambling", 0);
srslte_vec_save_file("npdsch_rx_descramble_output.bin", q->llr, cfg->nbits.nof_bits); srslte_vec_save_file("npdsch_rx_descramble_output.bin", q->llr, cfg->nbits.nof_bits);
} }
#endif #endif
@ -509,7 +509,7 @@ int srslte_npdsch_rm_and_decode(srslte_npdsch_t* q, srslte_npdsch_cfg_t* cfg, fl
#if DUMP_SIGNALS #if DUMP_SIGNALS
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE npdsch_rx_viterbidecode_output.bin: NPDSCH after viterbi decoding\n", 0); DEBUG("SAVED FILE npdsch_rx_viterbidecode_output.bin: NPDSCH after viterbi decoding", 0);
srslte_vec_save_file("npdsch_rx_viterbidecode_output.bin", q->temp, cfg->grant.mcs[0].tbs + SRSLTE_NPDSCH_CRC_LEN); srslte_vec_save_file("npdsch_rx_viterbidecode_output.bin", q->temp, cfg->grant.mcs[0].tbs + SRSLTE_NPDSCH_CRC_LEN);
} }
#endif #endif
@ -624,7 +624,7 @@ int srslte_npdsch_encode_seq(srslte_npdsch_t* q,
// make sure to run run full NPDSCH procedure only once // make sure to run run full NPDSCH procedure only once
if (!cfg->is_encoded) { if (!cfg->is_encoded) {
INFO("Encoding NPDSCH: Mod %s, NofBits: %d, NofSymbols: %d * %d, NofBitsE: %d * %d\n", INFO("Encoding NPDSCH: Mod %s, NofBits: %d, NofSymbols: %d * %d, NofBitsE: %d * %d",
srslte_mod_string(cfg->grant.mcs[0].mod), srslte_mod_string(cfg->grant.mcs[0].mod),
cfg->grant.mcs[0].tbs, cfg->grant.mcs[0].tbs,
cfg->grant.nof_sf, cfg->grant.nof_sf,
@ -649,7 +649,7 @@ int srslte_npdsch_encode_seq(srslte_npdsch_t* q,
#if DUMP_SIGNALS #if DUMP_SIGNALS
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE npdsch_tx_convcoder_input.bin: NPDSCH before convolution coding\n", 0); DEBUG("SAVED FILE npdsch_tx_convcoder_input.bin: NPDSCH before convolution coding", 0);
srslte_vec_save_file("npdsch_tx_convcoder_input.bin", q->data, len); srslte_vec_save_file("npdsch_tx_convcoder_input.bin", q->data, len);
} }
#endif #endif
@ -664,7 +664,7 @@ int srslte_npdsch_encode_seq(srslte_npdsch_t* q,
#if DUMP_SIGNALS #if DUMP_SIGNALS
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE npdsch_tx_scramble_input.bin: NPDSCH before scrambling\n", 0); DEBUG("SAVED FILE npdsch_tx_scramble_input.bin: NPDSCH before scrambling", 0);
srslte_vec_save_file("npdsch_tx_scramble_input.bin", q->rm_b, len); srslte_vec_save_file("npdsch_tx_scramble_input.bin", q->rm_b, len);
} }
#endif #endif
@ -674,7 +674,7 @@ int srslte_npdsch_encode_seq(srslte_npdsch_t* q,
#if DUMP_SIGNALS #if DUMP_SIGNALS
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE npdsch_tx_mod_input.bin: NPDSCH before modulation\n", 0); DEBUG("SAVED FILE npdsch_tx_mod_input.bin: NPDSCH before modulation", 0);
srslte_vec_save_file("npdsch_tx_mod_input.bin", q->rm_b, len); srslte_vec_save_file("npdsch_tx_mod_input.bin", q->rm_b, len);
} }
#endif #endif
@ -685,7 +685,7 @@ int srslte_npdsch_encode_seq(srslte_npdsch_t* q,
#if DUMP_SIGNALS #if DUMP_SIGNALS
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE npdsch_tx_precode_input.bin: NPDSCH before precoding symbols\n", 0); DEBUG("SAVED FILE npdsch_tx_precode_input.bin: NPDSCH before precoding symbols", 0);
srslte_vec_save_file("npdsch_tx_precode_input.bin", q->d, len * sizeof(cf_t)); srslte_vec_save_file("npdsch_tx_precode_input.bin", q->d, len * sizeof(cf_t));
} }
#endif #endif
@ -700,7 +700,7 @@ int srslte_npdsch_encode_seq(srslte_npdsch_t* q,
#if DUMP_SIGNALS #if DUMP_SIGNALS
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE npdsch_tx_mapping_input.bin: NPDSCH before mapping to resource elements\n", 0); DEBUG("SAVED FILE npdsch_tx_mapping_input.bin: NPDSCH before mapping to resource elements", 0);
srslte_vec_save_file("npdsch_tx_mapping_input.bin", q->tx_syms[0], len * sizeof(cf_t)); srslte_vec_save_file("npdsch_tx_mapping_input.bin", q->tx_syms[0], len * sizeof(cf_t));
} }
#endif #endif
@ -710,7 +710,7 @@ int srslte_npdsch_encode_seq(srslte_npdsch_t* q,
// mapping to resource elements // mapping to resource elements
if (cfg->is_encoded) { if (cfg->is_encoded) {
INFO("Mapping %d NPDSCH REs, sf_idx=%d/%d rep=%d/%d total=%d/%d\n", INFO("Mapping %d NPDSCH REs, sf_idx=%d/%d rep=%d/%d total=%d/%d",
cfg->nbits.nof_re, cfg->nbits.nof_re,
cfg->sf_idx + 1, cfg->sf_idx + 1,
cfg->grant.nof_sf, cfg->grant.nof_sf,

@ -419,7 +419,7 @@ int decode_frame(srslte_pbch_t* q, uint32_t src, uint32_t dst, uint32_t n, uint3
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
} else { } else {
ERROR("Error in PBCH decoder: Invalid frame pointers dst=%d, src=%d, n=%d\n", src, dst, n); ERROR("Error in PBCH decoder: Invalid frame pointers dst=%d, src=%d, n=%d", src, dst, n);
return -1; return -1;
} }
} }
@ -465,14 +465,14 @@ int srslte_pbch_decode(srslte_pbch_t* q,
/* extract symbols */ /* extract symbols */
if (q->nof_symbols != srslte_pbch_get(slot1_symbols, q->symbols[0], q->cell)) { if (q->nof_symbols != srslte_pbch_get(slot1_symbols, q->symbols[0], q->cell)) {
ERROR("There was an error getting the PBCH symbols\n"); ERROR("There was an error getting the PBCH symbols");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
/* extract channel estimates */ /* extract channel estimates */
for (i = 0; i < q->cell.nof_ports; i++) { for (i = 0; i < q->cell.nof_ports; i++) {
if (q->nof_symbols != srslte_pbch_get(ce_slot1[i], q->ce[i], q->cell)) { if (q->nof_symbols != srslte_pbch_get(ce_slot1[i], q->ce[i], q->cell)) {
ERROR("There was an error getting the PBCH symbols\n"); ERROR("There was an error getting the PBCH symbols");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -491,7 +491,7 @@ int srslte_pbch_decode(srslte_pbch_t* q,
do { do {
if (nant != 3) { if (nant != 3) {
DEBUG("Trying %d TX antennas with %d frames\n", nant, frame_idx); DEBUG("Trying %d TX antennas with %d frames", nant, frame_idx);
/* in control channels, only diversity is supported */ /* in control channels, only diversity is supported */
if (nant == 1) { if (nant == 1) {
@ -523,7 +523,7 @@ int srslte_pbch_decode(srslte_pbch_t* q,
if (bch_payload) { if (bch_payload) {
memcpy(bch_payload, q->data, sizeof(uint8_t) * SRSLTE_BCH_PAYLOAD_LEN); memcpy(bch_payload, q->data, sizeof(uint8_t) * SRSLTE_BCH_PAYLOAD_LEN);
} }
INFO("Decoded PBCH: src=%d, dst=%d, nb=%d, sfn_offset=%d\n", INFO("Decoded PBCH: src=%d, dst=%d, nb=%d, sfn_offset=%d",
src, src,
dst, dst,
nb + 1, nb + 1,

@ -150,7 +150,6 @@ int srslte_pcfich_decode(srslte_pcfich_t* q,
cf_t* sf_symbols[SRSLTE_MAX_PORTS], cf_t* sf_symbols[SRSLTE_MAX_PORTS],
float* corr_result) float* corr_result)
{ {
/* Set pointers for layermapping & precoding */ /* Set pointers for layermapping & precoding */
int i; int i;
cf_t* x[SRSLTE_MAX_LAYERS]; cf_t* x[SRSLTE_MAX_LAYERS];
@ -169,7 +168,7 @@ int srslte_pcfich_decode(srslte_pcfich_t* q,
/* extract symbols */ /* extract symbols */
for (int j = 0; j < q->nof_rx_antennas; j++) { for (int j = 0; j < q->nof_rx_antennas; j++) {
if (q->nof_symbols != srslte_regs_pcfich_get(q->regs, sf_symbols[j], q->symbols[j])) { if (q->nof_symbols != srslte_regs_pcfich_get(q->regs, sf_symbols[j], q->symbols[j])) {
ERROR("There was an error getting the PCFICH symbols\n"); ERROR("There was an error getting the PCFICH symbols");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -178,7 +177,7 @@ int srslte_pcfich_decode(srslte_pcfich_t* q,
/* extract channel estimates */ /* extract channel estimates */
for (i = 0; i < q->cell.nof_ports; i++) { for (i = 0; i < q->cell.nof_ports; i++) {
if (q->nof_symbols != srslte_regs_pcfich_get(q->regs, channel->ce[i][j], q->ce[i][j])) { if (q->nof_symbols != srslte_regs_pcfich_get(q->regs, channel->ce[i][j], q->ce[i][j])) {
ERROR("There was an error getting the PCFICH symbols\n"); ERROR("There was an error getting the PCFICH symbols");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q_ce[i][j] = q->ce[i][j]; q_ce[i][j] = q->ce[i][j];
@ -220,7 +219,6 @@ int srslte_pcfich_encode(srslte_pcfich_t* q, srslte_dl_sf_cfg_t* sf, cf_t* slot_
int i; int i;
if (q != NULL && slot_symbols != NULL) { if (q != NULL && slot_symbols != NULL) {
uint32_t sf_idx = sf->tti % 10; uint32_t sf_idx = sf->tti % 10;
/* Set pointers for layermapping & precoding */ /* Set pointers for layermapping & precoding */
@ -254,7 +252,7 @@ int srslte_pcfich_encode(srslte_pcfich_t* q, srslte_dl_sf_cfg_t* sf, cf_t* slot_
/* mapping to resource elements */ /* mapping to resource elements */
for (i = 0; i < q->cell.nof_ports; i++) { for (i = 0; i < q->cell.nof_ports; i++) {
if (srslte_regs_pcfich_put(q->regs, q->symbols[i], slot_symbols[i]) < 0) { if (srslte_regs_pcfich_put(q->regs, q->symbols[i], slot_symbols[i]) < 0) {
ERROR("Error putting PCHICH resource elements\n"); ERROR("Error putting PCHICH resource elements");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }

@ -52,7 +52,7 @@ static int pdcch_init(srslte_pdcch_t* q, uint32_t max_prb, uint32_t nof_rx_anten
/* Allocate memory for the maximum number of PDCCH bits (CFI=3) */ /* Allocate memory for the maximum number of PDCCH bits (CFI=3) */
q->max_bits = max_prb * 3 * 12 * 2; q->max_bits = max_prb * 3 * 12 * 2;
INFO("Init PDCCH: Max bits: %d\n", q->max_bits); INFO("Init PDCCH: Max bits: %d", q->max_bits);
if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_QPSK)) { if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_QPSK)) {
goto clean; goto clean;
@ -123,7 +123,6 @@ int srslte_pdcch_init_ue(srslte_pdcch_t* q, uint32_t max_prb, uint32_t nof_rx_an
void srslte_pdcch_free(srslte_pdcch_t* q) void srslte_pdcch_free(srslte_pdcch_t* q)
{ {
if (q->e) { if (q->e) {
free(q->e); free(q->e);
} }
@ -176,10 +175,9 @@ int srslte_pdcch_set_cell(srslte_pdcch_t* q, srslte_regs_t* regs, srslte_cell_t
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL && regs != NULL && srslte_cell_isvalid(&cell)) { if (q != NULL && regs != NULL && srslte_cell_isvalid(&cell)) {
srslte_pdcch_set_regs(q, regs); srslte_pdcch_set_regs(q, regs);
INFO("PDCCH: Cell config PCI=%d, %d ports.\n", q->cell.id, q->cell.nof_ports); INFO("PDCCH: Cell config PCI=%d, %d ports.", q->cell.id, q->cell.nof_ports);
if (q->cell.id != cell.id || q->cell.nof_prb == 0) { if (q->cell.id != cell.id || q->cell.nof_prb == 0) {
q->cell = cell; q->cell = cell;
@ -227,7 +225,6 @@ uint32_t srslte_pdcch_ue_locations_ncce_L(uint32_t nof_cce,
uint16_t rnti, uint16_t rnti,
int Ls) int Ls)
{ {
int l; // this must be int because of the for(;;--) loop int l; // this must be int because of the for(;;--) loop
uint32_t i, k, L, m; uint32_t i, k, L, m;
uint32_t Yk, ncce; uint32_t Yk, ncce;
@ -265,7 +262,7 @@ uint32_t srslte_pdcch_ue_locations_ncce_L(uint32_t nof_cce,
c[k].L = l; c[k].L = l;
c[k].ncce = ncce; c[k].ncce = ncce;
DEBUG("UE-specific SS Candidate %d: nCCE: %d, L: %d\n", k, c[k].ncce, c[k].L); DEBUG("UE-specific SS Candidate %d: nCCE: %d, L: %d", k, c[k].ncce, c[k].L);
k++; k++;
} }
@ -274,7 +271,7 @@ uint32_t srslte_pdcch_ue_locations_ncce_L(uint32_t nof_cce,
} }
} }
DEBUG("Initiated %d candidate(s) in the UE-specific search space for C-RNTI: 0x%x, sf_idx=%d, nof_cce=%d\n", DEBUG("Initiated %d candidate(s) in the UE-specific search space for C-RNTI: 0x%x, sf_idx=%d, nof_cce=%d",
k, k,
rnti, rnti,
sf_idx, sf_idx,
@ -309,13 +306,13 @@ uint32_t srslte_pdcch_common_locations_ncce(uint32_t nof_cce, srslte_dci_locatio
if (k < max_candidates && ncce + L <= nof_cce) { if (k < max_candidates && ncce + L <= nof_cce) {
c[k].L = l; c[k].L = l;
c[k].ncce = ncce; c[k].ncce = ncce;
DEBUG("Common SS Candidate %d: nCCE: %d/%d, L: %d\n", k, c[k].ncce, nof_cce, c[k].L); DEBUG("Common SS Candidate %d: nCCE: %d/%d, L: %d", k, c[k].ncce, nof_cce, c[k].L);
k++; k++;
} }
} }
} }
INFO("Initiated %d candidate(s) in the Common search space\n", k); INFO("Initiated %d candidate(s) in the Common search space", k);
return k; return k;
} }
@ -328,7 +325,6 @@ uint32_t srslte_pdcch_common_locations_ncce(uint32_t nof_cce, srslte_dci_locatio
*/ */
int srslte_pdcch_dci_decode(srslte_pdcch_t* q, float* e, uint8_t* data, uint32_t E, uint32_t nof_bits, uint16_t* crc) int srslte_pdcch_dci_decode(srslte_pdcch_t* q, float* e, uint8_t* data, uint32_t E, uint32_t nof_bits, uint16_t* crc)
{ {
uint16_t p_bits, crc_res; uint16_t p_bits, crc_res;
uint8_t* x; uint8_t* x;
@ -354,7 +350,7 @@ int srslte_pdcch_dci_decode(srslte_pdcch_t* q, float* e, uint8_t* data, uint32_t
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} else { } else {
ERROR("Invalid parameters: E: %d, max_bits: %d, nof_bits: %d\n", E, q->max_bits, nof_bits); ERROR("Invalid parameters: E: %d, max_bits: %d, nof_bits: %d", E, q->max_bits, nof_bits);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
} else { } else {
@ -373,7 +369,7 @@ int srslte_pdcch_decode_msg(srslte_pdcch_t* q, srslte_dl_sf_cfg_t* sf, srslte_dc
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL && msg != NULL && srslte_dci_location_isvalid(&msg->location)) { if (q != NULL && msg != NULL && srslte_dci_location_isvalid(&msg->location)) {
if (msg->location.ncce * 72 + PDCCH_FORMAT_NOF_BITS(msg->location.L) > NOF_CCE(sf->cfi) * 72) { if (msg->location.ncce * 72 + PDCCH_FORMAT_NOF_BITS(msg->location.L) > NOF_CCE(sf->cfi) * 72) {
ERROR("Invalid location: nCCE: %d, L: %d, NofCCE: %d\n", msg->location.ncce, msg->location.L, NOF_CCE(sf->cfi)); ERROR("Invalid location: nCCE: %d, L: %d, NofCCE: %d", msg->location.ncce, msg->location.L, NOF_CCE(sf->cfi));
} else { } else {
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;
@ -394,9 +390,9 @@ int srslte_pdcch_decode_msg(srslte_pdcch_t* q, srslte_dl_sf_cfg_t* sf, srslte_dc
msg->format = (msg->payload[dci_cfg->cif_enabled ? 3 : 0] == 0) ? SRSLTE_DCI_FORMAT0 : SRSLTE_DCI_FORMAT1A; msg->format = (msg->payload[dci_cfg->cif_enabled ? 3 : 0] == 0) ? SRSLTE_DCI_FORMAT0 : SRSLTE_DCI_FORMAT1A;
} }
} else { } else {
ERROR("Error calling pdcch_dci_decode\n"); ERROR("Error calling pdcch_dci_decode");
} }
INFO("Decoded DCI: nCCE=%d, L=%d, format=%s, msg_len=%d, mean=%f, crc_rem=0x%x\n", INFO("Decoded DCI: nCCE=%d, L=%d, format=%s, msg_len=%d, mean=%f, crc_rem=0x%x",
msg->location.ncce, msg->location.ncce,
msg->location.L, msg->location.L,
srslte_dci_format_string(msg->format), srslte_dci_format_string(msg->format),
@ -404,12 +400,11 @@ int srslte_pdcch_decode_msg(srslte_pdcch_t* q, srslte_dl_sf_cfg_t* sf, srslte_dc
mean, mean,
msg->rnti); msg->rnti);
} else { } else {
INFO( INFO("Skipping DCI: nCCE=%d, L=%d, msg_len=%d, mean=%f", msg->location.ncce, msg->location.L, nof_bits, mean);
"Skipping DCI: nCCE=%d, L=%d, msg_len=%d, mean=%f\n", msg->location.ncce, msg->location.L, nof_bits, mean);
} }
} }
} else { } else {
ERROR("Invalid parameters, location=%d,%d\n", msg->location.ncce, msg->location.L); ERROR("Invalid parameters, location=%d,%d", msg->location.ncce, msg->location.L);
} }
return ret; return ret;
} }
@ -422,7 +417,6 @@ int srslte_pdcch_extract_llr(srslte_pdcch_t* q,
srslte_chest_dl_res_t* channel, srslte_chest_dl_res_t* channel,
cf_t* sf_symbols[SRSLTE_MAX_PORTS]) cf_t* sf_symbols[SRSLTE_MAX_PORTS])
{ {
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
/* Set pointers for layermapping & precoding */ /* Set pointers for layermapping & precoding */
@ -430,13 +424,12 @@ int srslte_pdcch_extract_llr(srslte_pdcch_t* q,
cf_t* x[SRSLTE_MAX_LAYERS]; cf_t* x[SRSLTE_MAX_LAYERS];
if (q != NULL && sf->cfi > 0 && sf->cfi < 4) { if (q != NULL && sf->cfi > 0 && sf->cfi < 4) {
uint32_t e_bits = 72 * NOF_CCE(sf->cfi); uint32_t e_bits = 72 * NOF_CCE(sf->cfi);
nof_symbols = e_bits / 2; nof_symbols = e_bits / 2;
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
srslte_vec_f_zero(q->llr, q->max_bits); srslte_vec_f_zero(q->llr, q->max_bits);
DEBUG("Extracting LLRs: E: %d, SF: %d, CFI: %d\n", e_bits, sf->tti % 10, sf->cfi); DEBUG("Extracting LLRs: E: %d, SF: %d, CFI: %d", e_bits, sf->tti % 10, sf->cfi);
/* number of layers equals number of ports */ /* number of layers equals number of ports */
for (i = 0; i < q->cell.nof_ports; i++) { for (i = 0; i < q->cell.nof_ports; i++) {
@ -448,7 +441,7 @@ int srslte_pdcch_extract_llr(srslte_pdcch_t* q,
for (int j = 0; j < q->nof_rx_antennas; j++) { for (int j = 0; j < q->nof_rx_antennas; j++) {
int n = srslte_regs_pdcch_get(q->regs, sf->cfi, sf_symbols[j], q->symbols[j]); int n = srslte_regs_pdcch_get(q->regs, sf->cfi, sf_symbols[j], q->symbols[j]);
if (nof_symbols != n) { if (nof_symbols != n) {
ERROR("Expected %d PDCCH symbols but got %d symbols\n", nof_symbols, n); ERROR("Expected %d PDCCH symbols but got %d symbols", nof_symbols, n);
return ret; return ret;
} }
@ -456,7 +449,7 @@ int srslte_pdcch_extract_llr(srslte_pdcch_t* q,
for (i = 0; i < q->cell.nof_ports; i++) { for (i = 0; i < q->cell.nof_ports; i++) {
n = srslte_regs_pdcch_get(q->regs, sf->cfi, channel->ce[i][j], q->ce[i][j]); n = srslte_regs_pdcch_get(q->regs, sf->cfi, channel->ce[i][j], q->ce[i][j]);
if (nof_symbols != n) { if (nof_symbols != n) {
ERROR("Expected %d PDCCH symbols but got %d symbols\n", nof_symbols, n); ERROR("Expected %d PDCCH symbols but got %d symbols", nof_symbols, n);
return ret; return ret;
} }
} }
@ -490,7 +483,7 @@ static void crc_set_mask_rnti(uint8_t* crc, uint16_t rnti)
uint8_t mask[16]; uint8_t mask[16];
uint8_t* r = mask; uint8_t* r = mask;
DEBUG("Mask CRC with RNTI 0x%x\n", rnti); DEBUG("Mask CRC with RNTI 0x%x", rnti);
srslte_bit_unpack(rnti, &r, 16); srslte_bit_unpack(rnti, &r, 16);
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
@ -525,7 +518,6 @@ int srslte_pdcch_dci_encode(srslte_pdcch_t* q, uint8_t* data, uint8_t* e, uint32
uint8_t tmp[3 * (SRSLTE_DCI_MAX_BITS + 16)]; uint8_t tmp[3 * (SRSLTE_DCI_MAX_BITS + 16)];
if (q != NULL && data != NULL && e != NULL && nof_bits < SRSLTE_DCI_MAX_BITS && E < q->max_bits) { if (q != NULL && data != NULL && e != NULL && nof_bits < SRSLTE_DCI_MAX_BITS && E < q->max_bits) {
srslte_pdcch_dci_encode_conv(q, data, nof_bits, tmp, rnti); srslte_pdcch_dci_encode_conv(q, data, nof_bits, tmp, rnti);
DEBUG("CConv output: "); DEBUG("CConv output: ");
@ -554,21 +546,19 @@ int srslte_pdcch_encode(srslte_pdcch_t* q,
srslte_dci_msg_t* msg, srslte_dci_msg_t* msg,
cf_t* sf_symbols[SRSLTE_MAX_PORTS]) cf_t* sf_symbols[SRSLTE_MAX_PORTS])
{ {
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
uint32_t i; uint32_t i;
cf_t* x[SRSLTE_MAX_LAYERS]; cf_t* x[SRSLTE_MAX_LAYERS];
uint32_t nof_symbols; uint32_t nof_symbols;
if (q != NULL && sf_symbols != NULL && sf->cfi > 0 && sf->cfi < 4 && srslte_dci_location_isvalid(&msg->location)) { if (q != NULL && sf_symbols != NULL && sf->cfi > 0 && sf->cfi < 4 && srslte_dci_location_isvalid(&msg->location)) {
uint32_t e_bits = PDCCH_FORMAT_NOF_BITS(msg->location.L); uint32_t e_bits = PDCCH_FORMAT_NOF_BITS(msg->location.L);
nof_symbols = e_bits / 2; nof_symbols = e_bits / 2;
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
if (msg->location.ncce + PDCCH_FORMAT_NOF_CCE(msg->location.L) <= NOF_CCE(sf->cfi) && if (msg->location.ncce + PDCCH_FORMAT_NOF_CCE(msg->location.L) <= NOF_CCE(sf->cfi) &&
msg->nof_bits < SRSLTE_DCI_MAX_BITS - 16) { msg->nof_bits < SRSLTE_DCI_MAX_BITS - 16) {
DEBUG("Encoding DCI: Nbits: %d, E: %d, nCCE: %d, L: %d, RNTI: 0x%x\n", DEBUG("Encoding DCI: Nbits: %d, E: %d, nCCE: %d, L: %d, RNTI: 0x%x",
msg->nof_bits, msg->nof_bits,
e_bits, e_bits,
msg->location.ncce, msg->location.ncce,
@ -613,14 +603,14 @@ int srslte_pdcch_encode(srslte_pdcch_t* q,
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;
} else { } else {
ERROR("Illegal DCI message nCCE: %d, L: %d, nof_cce: %d, nof_bits=%d\n", ERROR("Illegal DCI message nCCE: %d, L: %d, nof_cce: %d, nof_bits=%d",
msg->location.ncce, msg->location.ncce,
msg->location.L, msg->location.L,
NOF_CCE(sf->cfi), NOF_CCE(sf->cfi),
msg->nof_bits); msg->nof_bits);
} }
} else { } else {
ERROR("Invalid parameters: cfi=%d, L=%d, nCCE=%d\n", sf->cfi, msg->location.L, msg->location.ncce); ERROR("Invalid parameters: cfi=%d, L=%d, nCCE=%d", sf->cfi, msg->location.L, msg->location.ncce);
} }
return ret; return ret;
} }

@ -53,7 +53,7 @@ static int srslte_pdcch_nr_get_ncce(const srslte_coreset_t* coreset,
uint32_t candidate) uint32_t candidate)
{ {
if (aggregation_level >= SRSLTE_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR) { if (aggregation_level >= SRSLTE_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR) {
ERROR("Invalid aggregation level %d;\n", aggregation_level); ERROR("Invalid aggregation level %d;", aggregation_level);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -63,7 +63,7 @@ static int srslte_pdcch_nr_get_ncce(const srslte_coreset_t* coreset,
uint32_t M = search_space->nof_candidates[aggregation_level]; // Number of aggregation levels uint32_t M = search_space->nof_candidates[aggregation_level]; // Number of aggregation levels
if (M == 0) { if (M == 0) {
ERROR("Invalid number of candidates %d for aggregation level %d\n", M, aggregation_level); ERROR("Invalid number of candidates %d for aggregation level %d", M, aggregation_level);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -72,7 +72,7 @@ static int srslte_pdcch_nr_get_ncce(const srslte_coreset_t* coreset,
uint32_t N_cce = srslte_coreset_get_bw(coreset) * coreset->duration / 6; uint32_t N_cce = srslte_coreset_get_bw(coreset) * coreset->duration / 6;
if (N_cce < L) { if (N_cce < L) {
ERROR("Error number of CCE %d is lower than the aggregation level %d\n", N_cce, L); ERROR("Error number of CCE %d is lower than the aggregation level %d", N_cce, L);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -334,7 +334,6 @@ static uint32_t pdcch_nr_c_init(const srslte_pdcch_nr_t* q, const srslte_dci_msg
int srslte_pdcch_nr_encode(srslte_pdcch_nr_t* q, const srslte_dci_msg_nr_t* dci_msg, cf_t* slot_symbols) int srslte_pdcch_nr_encode(srslte_pdcch_nr_t* q, const srslte_dci_msg_nr_t* dci_msg, cf_t* slot_symbols)
{ {
if (q == NULL || dci_msg == NULL || slot_symbols == NULL) { if (q == NULL || dci_msg == NULL || slot_symbols == NULL) {
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -354,7 +353,7 @@ int srslte_pdcch_nr_encode(srslte_pdcch_nr_t* q, const srslte_dci_msg_nr_t* dci_
if (srslte_polar_code_get(&q->code, q->K, q->E, 9U) < SRSLTE_SUCCESS) { if (srslte_polar_code_get(&q->code, q->K, q->E, 9U) < SRSLTE_SUCCESS) {
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
PDCCH_INFO_TX("K=%d; E=%d; M=%d; n=%d; cinit=%08x;\n", q->K, q->E, q->M, q->code.n, cinit); PDCCH_INFO_TX("K=%d; E=%d; M=%d; n=%d; cinit=%08x;", q->K, q->E, q->M, q->code.n, cinit);
// Set first L bits to ones, c will have an offset of 24 bits // Set first L bits to ones, c will have an offset of 24 bits
uint8_t* c = q->c; uint8_t* c = q->c;
@ -366,7 +365,7 @@ int srslte_pdcch_nr_encode(srslte_pdcch_nr_t* q, const srslte_dci_msg_nr_t* dci_
// Append CRC // Append CRC
srslte_crc_attach(&q->crc24c, q->c, q->K); srslte_crc_attach(&q->crc24c, q->c, q->K);
PDCCH_INFO_TX("Append CRC %06x\n", (uint32_t)srslte_crc_checksum_get(&q->crc24c)); PDCCH_INFO_TX("Append CRC %06x", (uint32_t)srslte_crc_checksum_get(&q->crc24c));
// Unpack RNTI // Unpack RNTI
uint8_t unpacked_rnti[16] = {}; uint8_t unpacked_rnti[16] = {};
@ -414,7 +413,7 @@ int srslte_pdcch_nr_encode(srslte_pdcch_nr_t* q, const srslte_dci_msg_nr_t* dci_
// Put symbols in grid // Put symbols in grid
uint32_t m = pdcch_nr_cp(q, &dci_msg->location, slot_symbols, q->symbols, true); uint32_t m = pdcch_nr_cp(q, &dci_msg->location, slot_symbols, q->symbols, true);
if (q->M != m) { if (q->M != m) {
ERROR("Unmatch number of RE (%d != %d)\n", m, q->M); ERROR("Unmatch number of RE (%d != %d)", m, q->M);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -427,7 +426,7 @@ int srslte_pdcch_nr_encode(srslte_pdcch_nr_t* q, const srslte_dci_msg_nr_t* dci_
if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) {
char str[128] = {}; char str[128] = {};
srslte_pdcch_nr_info(q, NULL, str, sizeof(str)); srslte_pdcch_nr_info(q, NULL, str, sizeof(str));
PDCCH_INFO_TX("%s\n", str); PDCCH_INFO_TX("%s", str);
} }
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
@ -455,7 +454,7 @@ int srslte_pdcch_nr_decode(srslte_pdcch_nr_t* q,
// Check number of estimates is correct // Check number of estimates is correct
if (ce->nof_re != q->M) { if (ce->nof_re != q->M) {
ERROR("Invalid number of channel estimates (%d != %d)\n", q->M, ce->nof_re); ERROR("Invalid number of channel estimates (%d != %d)", q->M, ce->nof_re);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -463,12 +462,12 @@ int srslte_pdcch_nr_decode(srslte_pdcch_nr_t* q,
if (srslte_polar_code_get(&q->code, q->K, q->E, 9U) < SRSLTE_SUCCESS) { if (srslte_polar_code_get(&q->code, q->K, q->E, 9U) < SRSLTE_SUCCESS) {
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
PDCCH_INFO_RX("K=%d; E=%d; M=%d; n=%d;\n", q->K, q->E, q->M, q->code.n); PDCCH_INFO_RX("K=%d; E=%d; M=%d; n=%d;", q->K, q->E, q->M, q->code.n);
// Get symbols from grid // Get symbols from grid
uint32_t m = pdcch_nr_cp(q, &dci_msg->location, slot_symbols, q->symbols, false); uint32_t m = pdcch_nr_cp(q, &dci_msg->location, slot_symbols, q->symbols, false);
if (q->M != m) { if (q->M != m) {
ERROR("Unmatch number of RE (%d != %d)\n", m, q->M); ERROR("Unmatch number of RE (%d != %d)", m, q->M);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -574,7 +573,7 @@ int srslte_pdcch_nr_decode(srslte_pdcch_nr_t* q,
if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) {
char str[128] = {}; char str[128] = {};
srslte_pdcch_nr_info(q, res, str, sizeof(str)); srslte_pdcch_nr_info(q, res, str, sizeof(str));
PDCCH_INFO_RX("%s\n", str); PDCCH_INFO_RX("%s", str);
} }
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;

@ -151,7 +151,6 @@ static int srslte_pdsch_cp(const srslte_pdsch_t* q,
// Iterate over PRB // Iterate over PRB
for (uint32_t n = 0; n < q->cell.nof_prb; n++) { for (uint32_t n = 0; n < q->cell.nof_prb; n++) {
// If this PRB is assigned // If this PRB is assigned
if (grant->prb_idx[s][n]) { if (grant->prb_idx[s][n]) {
bool skip = pdsch_cp_skip_symbol(&q->cell, grant, sf_idx, s, l, n); bool skip = pdsch_cp_skip_symbol(&q->cell, grant, sf_idx, s, l, n);
@ -251,7 +250,6 @@ static int pdsch_init(srslte_pdsch_t* q, uint32_t max_prb, bool is_ue, uint32_t
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL) { if (q != NULL) {
bzero(q, sizeof(srslte_pdsch_t)); bzero(q, sizeof(srslte_pdsch_t));
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
@ -259,7 +257,7 @@ static int pdsch_init(srslte_pdsch_t* q, uint32_t max_prb, bool is_ue, uint32_t
q->is_ue = is_ue; q->is_ue = is_ue;
q->nof_rx_antennas = nof_antennas; q->nof_rx_antennas = nof_antennas;
INFO("Init PDSCH: %d PRBs, max_symbols: %d\n", max_prb, q->max_re); INFO("Init PDSCH: %d PRBs, max_symbols: %d", max_prb, q->max_re);
for (int i = 0; i < SRSLTE_MOD_NITEMS; i++) { for (int i = 0; i < SRSLTE_MOD_NITEMS; i++) {
if (srslte_modem_table_lte(&q->mod[i], modulations[i])) { if (srslte_modem_table_lte(&q->mod[i], modulations[i])) {
@ -289,7 +287,7 @@ static int pdsch_init(srslte_pdsch_t* q, uint32_t max_prb, bool is_ue, uint32_t
if (is_ue) { if (is_ue) {
q->evm_buffer[i] = srslte_evm_buffer_alloc(srslte_ra_tbs_from_idx(SRSLTE_RA_NOF_TBS_IDX - 1, 6)); q->evm_buffer[i] = srslte_evm_buffer_alloc(srslte_ra_tbs_from_idx(SRSLTE_RA_NOF_TBS_IDX - 1, 6));
if (!q->evm_buffer[i]) { if (!q->evm_buffer[i]) {
ERROR("Allocating EVM buffer\n"); ERROR("Allocating EVM buffer");
goto clean; goto clean;
} }
} }
@ -417,7 +415,6 @@ void srslte_pdsch_free(srslte_pdsch_t* q)
srslte_pdsch_disable_coworker(q); srslte_pdsch_disable_coworker(q);
for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) {
if (q->e[i]) { if (q->e[i]) {
free(q->e[i]); free(q->e[i]);
} }
@ -490,7 +487,7 @@ int srslte_pdsch_set_cell(srslte_pdsch_t* q, srslte_cell_t cell)
} }
} }
INFO("PDSCH: Cell config PCI=%d, %d ports, %d PRBs, max_symbols: %d\n", INFO("PDSCH: Cell config PCI=%d, %d ports, %d PRBs, max_symbols: %d",
q->cell.id, q->cell.id,
q->cell.nof_ports, q->cell.nof_ports,
q->cell.nof_prb, q->cell.nof_prb,
@ -513,7 +510,7 @@ int srslte_pdsch_set_rnti(srslte_pdsch_t* q, uint16_t rnti)
// If the sequence is not allocated generate // If the sequence is not allocated generate
q->users[rnti_idx] = calloc(1, sizeof(srslte_pdsch_user_t)); q->users[rnti_idx] = calloc(1, sizeof(srslte_pdsch_user_t));
if (!q->users[rnti_idx]) { if (!q->users[rnti_idx]) {
ERROR("Alocating PDSCH user\n"); ERROR("Alocating PDSCH user");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} else if (q->users[rnti_idx]->sequence_generated && q->users[rnti_idx]->cell_id == q->cell.id && !q->is_ue) { } else if (q->users[rnti_idx]->sequence_generated && q->users[rnti_idx]->cell_id == q->cell.id && !q->is_ue) {
@ -534,7 +531,7 @@ int srslte_pdsch_set_rnti(srslte_pdsch_t* q, uint16_t rnti)
SRSLTE_NOF_SLOTS_PER_SF * sf_idx, SRSLTE_NOF_SLOTS_PER_SF * sf_idx,
q->cell.id, q->cell.id,
q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_256QAM))) { q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_256QAM))) {
ERROR("Error initializing PDSCH scrambling sequence\n"); ERROR("Error initializing PDSCH scrambling sequence");
srslte_pdsch_free_rnti(q, rnti); srslte_pdsch_free_rnti(q, rnti);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -565,7 +562,6 @@ void srslte_pdsch_free_rnti(srslte_pdsch_t* q, uint16_t rnti)
} }
static float apply_power_allocation(srslte_pdsch_t* q, srslte_pdsch_cfg_t* cfg, cf_t* sf_symbols_m[SRSLTE_MAX_PORTS]) static float apply_power_allocation(srslte_pdsch_t* q, srslte_pdsch_cfg_t* cfg, cf_t* sf_symbols_m[SRSLTE_MAX_PORTS])
{ {
uint32_t nof_symbols_slot = cfg->grant.nof_symb_slot[0]; uint32_t nof_symbols_slot = cfg->grant.nof_symb_slot[0];
uint32_t nof_re_symbol = SRSLTE_NRE * q->cell.nof_prb; uint32_t nof_re_symbol = SRSLTE_NRE * q->cell.nof_prb;
@ -618,10 +614,8 @@ get_user_sequence(srslte_pdsch_t* q, uint16_t rnti, uint32_t codeword_idx, uint3
static void csi_correction(srslte_pdsch_t* q, srslte_pdsch_cfg_t* cfg, uint32_t codeword_idx, uint32_t tb_idx, void* e) static void csi_correction(srslte_pdsch_t* q, srslte_pdsch_cfg_t* cfg, uint32_t codeword_idx, uint32_t tb_idx, void* e)
{ {
uint32_t qm = 0; uint32_t qm = 0;
switch (cfg->grant.tb[tb_idx].mod) { switch (cfg->grant.tb[tb_idx].mod) {
case SRSLTE_MOD_BPSK: case SRSLTE_MOD_BPSK:
qm = 1; qm = 1;
break; break;
@ -743,7 +737,7 @@ static void pdsch_decode_debug(srslte_pdsch_t* q,
ERROR("Generating file name"); ERROR("Generating file name");
break; break;
} }
DEBUG("SAVED FILE %s: received subframe symbols\n", filename); DEBUG("SAVED FILE %s: received subframe symbols", filename);
srslte_vec_save_file(filename, sf_symbols[j], SRSLTE_NOF_RE(q->cell) * sizeof(cf_t)); srslte_vec_save_file(filename, sf_symbols[j], SRSLTE_NOF_RE(q->cell) * sizeof(cf_t));
for (int i = 0; i < q->cell.nof_ports; i++) { for (int i = 0; i < q->cell.nof_ports; i++) {
@ -751,7 +745,7 @@ static void pdsch_decode_debug(srslte_pdsch_t* q,
ERROR("Generating file name"); ERROR("Generating file name");
break; break;
} }
DEBUG("SAVED FILE %s: channel estimates for Tx %d and Rx %d\n", filename, j, i); DEBUG("SAVED FILE %s: channel estimates for Tx %d and Rx %d", filename, j, i);
srslte_vec_save_file(filename, ce[i][j], SRSLTE_NOF_RE(q->cell) * sizeof(cf_t)); srslte_vec_save_file(filename, ce[i][j], SRSLTE_NOF_RE(q->cell) * sizeof(cf_t));
} }
} }
@ -760,14 +754,14 @@ static void pdsch_decode_debug(srslte_pdsch_t* q,
ERROR("Generating file name"); ERROR("Generating file name");
break; break;
} }
DEBUG("SAVED FILE %s: symbols after equalization\n", filename); DEBUG("SAVED FILE %s: symbols after equalization", filename);
srslte_vec_save_file(filename, q->d[i], cfg->grant.nof_re * sizeof(cf_t)); srslte_vec_save_file(filename, q->d[i], cfg->grant.nof_re * sizeof(cf_t));
if (snprintf(filename, FILENAME_MAX, "llr_%d.dat", i) < 0) { if (snprintf(filename, FILENAME_MAX, "llr_%d.dat", i) < 0) {
ERROR("Generating file name"); ERROR("Generating file name");
break; break;
} }
DEBUG("SAVED FILE %s: LLR estimates after demodulation and descrambling\n", filename); DEBUG("SAVED FILE %s: LLR estimates after demodulation and descrambling", filename);
srslte_vec_save_file(filename, q->e[i], cfg->grant.tb[0].nof_bits * sizeof(int16_t)); srslte_vec_save_file(filename, q->e[i], cfg->grant.tb[0].nof_bits * sizeof(int16_t));
} }
} }
@ -790,7 +784,7 @@ static int srslte_pdsch_codeword_decode(srslte_pdsch_t* q,
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (softbuffer && data && ack && cfg->grant.tb[tb_idx].nof_bits && cfg->grant.nof_re) { if (softbuffer && data && ack && cfg->grant.tb[tb_idx].nof_bits && cfg->grant.nof_re) {
INFO("Decoding PDSCH SF: %d (CW%d -> TB%d), Mod %s, NofBits: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d\n", INFO("Decoding PDSCH SF: %d (CW%d -> TB%d), Mod %s, NofBits: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d",
sf->tti % 10, sf->tti % 10,
codeword_idx, codeword_idx,
tb_idx, tb_idx,
@ -831,7 +825,7 @@ static int srslte_pdsch_codeword_decode(srslte_pdsch_t* q,
srslte_sequence_t* seq = srslte_sequence_t* seq =
get_user_sequence(q, cfg->rnti, codeword_idx, sf->tti % 10, cfg->grant.tb[tb_idx].nof_bits); get_user_sequence(q, cfg->rnti, codeword_idx, sf->tti % 10, cfg->grant.tb[tb_idx].nof_bits);
if (!seq) { if (!seq) {
ERROR("Error getting user sequence for rnti=0x%x\n", cfg->rnti); ERROR("Error getting user sequence for rnti=0x%x", cfg->rnti);
return -1; return -1;
} }
@ -859,7 +853,7 @@ static int srslte_pdsch_codeword_decode(srslte_pdsch_t* q,
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
} }
} else { } else {
ERROR("Invalid parameters in TB%d &softbuffer=%p &data=%p &ack=%p, nbits=%d, nof_re=%d\n", ERROR("Invalid parameters in TB%d &softbuffer=%p &data=%p &ack=%p, nbits=%d, nof_re=%d",
codeword_idx, codeword_idx,
softbuffer, softbuffer,
(void*)data, (void*)data,
@ -875,7 +869,7 @@ static void* srslte_pdsch_decode_thread(void* arg)
{ {
srslte_pdsch_coworker_t* q = (srslte_pdsch_coworker_t*)arg; srslte_pdsch_coworker_t* q = (srslte_pdsch_coworker_t*)arg;
INFO("[PDSCH Coworker] waiting for data\n"); INFO("[PDSCH Coworker] waiting for data");
sem_wait(&q->start); sem_wait(&q->start);
while (!q->quit) { while (!q->quit) {
@ -902,13 +896,11 @@ int srslte_pdsch_decode(srslte_pdsch_t* q,
cf_t* sf_symbols[SRSLTE_MAX_PORTS], cf_t* sf_symbols[SRSLTE_MAX_PORTS],
srslte_pdsch_res_t data[SRSLTE_MAX_CODEWORDS]) srslte_pdsch_res_t data[SRSLTE_MAX_CODEWORDS])
{ {
/* Set pointers for layermapping & precoding */ /* Set pointers for layermapping & precoding */
uint32_t i; uint32_t i;
cf_t** x; cf_t** x;
if (q != NULL && sf_symbols != NULL && data != NULL && cfg != NULL) { if (q != NULL && sf_symbols != NULL && data != NULL && cfg != NULL) {
struct timeval t[3]; struct timeval t[3];
if (cfg->meas_time_en) { if (cfg->meas_time_en) {
gettimeofday(&t[1], NULL); gettimeofday(&t[1], NULL);
@ -930,7 +922,7 @@ int srslte_pdsch_decode(srslte_pdsch_t* q,
float noise_estimate = cfg->decoder_type == SRSLTE_MIMO_DECODER_ZF ? 0 : channel->noise_estimate; float noise_estimate = cfg->decoder_type == SRSLTE_MIMO_DECODER_ZF ? 0 : channel->noise_estimate;
INFO("Decoding PDSCH SF: %d, RNTI: 0x%x, NofSymbols: %d, C_prb=%d, mod=%s, nof_layers=%d, nof_tb=%d\n", INFO("Decoding PDSCH SF: %d, RNTI: 0x%x, NofSymbols: %d, C_prb=%d, mod=%s, nof_layers=%d, nof_tb=%d",
sf->tti % 10, sf->tti % 10,
cfg->rnti, cfg->rnti,
cfg->grant.nof_re, cfg->grant.nof_re,
@ -944,21 +936,21 @@ int srslte_pdsch_decode(srslte_pdsch_t* q,
for (int j = 0; j < q->nof_rx_antennas; j++) { for (int j = 0; j < q->nof_rx_antennas; j++) {
int n = srslte_pdsch_get(q, sf_symbols[j], q->symbols[j], &cfg->grant, lstart, sf->tti % 10); int n = srslte_pdsch_get(q, sf_symbols[j], q->symbols[j], &cfg->grant, lstart, sf->tti % 10);
if (n != cfg->grant.nof_re) { if (n != cfg->grant.nof_re) {
ERROR("Error expecting %d symbols but got %d\n", cfg->grant.nof_re, n); ERROR("Error expecting %d symbols but got %d", cfg->grant.nof_re, n);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
for (i = 0; i < q->cell.nof_ports; i++) { for (i = 0; i < q->cell.nof_ports; i++) {
n = srslte_pdsch_get(q, channel->ce[i][j], q->ce[i][j], &cfg->grant, lstart, sf->tti % 10); n = srslte_pdsch_get(q, channel->ce[i][j], q->ce[i][j], &cfg->grant, lstart, sf->tti % 10);
if (n != cfg->grant.nof_re) { if (n != cfg->grant.nof_re) {
ERROR("Error expecting %d symbols but got %d\n", cfg->grant.nof_re, n); ERROR("Error expecting %d symbols but got %d", cfg->grant.nof_re, n);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
} }
if (cfg->grant.nof_layers == 0 || cfg->grant.nof_layers > SRSLTE_MAX_LAYERS) { if (cfg->grant.nof_layers == 0 || cfg->grant.nof_layers > SRSLTE_MAX_LAYERS) {
ERROR("PDSCH Number of layers (%d) is out-of-bounds\n", cfg->grant.nof_layers); ERROR("PDSCH Number of layers (%d) is out-of-bounds", cfg->grant.nof_layers);
return SRSLTE_ERROR_OUT_OF_BOUNDS; return SRSLTE_ERROR_OUT_OF_BOUNDS;
} }
@ -989,7 +981,7 @@ int srslte_pdsch_decode(srslte_pdsch_t* q,
cfg->grant.tx_scheme, cfg->grant.tx_scheme,
pdsch_scaling, pdsch_scaling,
noise_estimate) < 0) { noise_estimate) < 0) {
ERROR("Error predecoding\n"); ERROR("Error predecoding");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1000,7 +992,6 @@ int srslte_pdsch_decode(srslte_pdsch_t* q,
/* Codeword decoding: Implementation of 3GPP 36.212 Table 5.3.3.1.5-1 and Table 5.3.3.1.5-2 */ /* Codeword decoding: Implementation of 3GPP 36.212 Table 5.3.3.1.5-1 and Table 5.3.3.1.5-2 */
for (uint32_t tb_idx = 0; tb_idx < SRSLTE_MAX_TB; tb_idx++) { for (uint32_t tb_idx = 0; tb_idx < SRSLTE_MAX_TB; tb_idx++) {
/* Decode only if transport block is enabled and the default ACK is not true */ /* Decode only if transport block is enabled and the default ACK is not true */
if (cfg->grant.tb[tb_idx].enabled) { if (cfg->grant.tb[tb_idx].enabled) {
if (!data[tb_idx].crc) { if (!data[tb_idx].crc) {
@ -1065,7 +1056,7 @@ int srslte_pdsch_decode(srslte_pdsch_t* q,
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} else { } else {
ERROR("Invalid inputs\n"); ERROR("Invalid inputs");
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
} }
@ -1090,7 +1081,7 @@ static int srslte_pdsch_codeword_encode(srslte_pdsch_t* q,
if (cfg->grant.tb[tb_idx].enabled) { if (cfg->grant.tb[tb_idx].enabled) {
if (cfg->rnti != SRSLTE_SIRNTI) { if (cfg->rnti != SRSLTE_SIRNTI) {
INFO("Encoding PDSCH SF: %d (TB%d -> CW%d), Mod %s, NofBits: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d\n", INFO("Encoding PDSCH SF: %d (TB%d -> CW%d), Mod %s, NofBits: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d",
sf->tti % 10, sf->tti % 10,
tb_idx, tb_idx,
codeword_idx, codeword_idx,
@ -1111,7 +1102,7 @@ static int srslte_pdsch_codeword_encode(srslte_pdsch_t* q,
srslte_sequence_t* seq = srslte_sequence_t* seq =
get_user_sequence(q, cfg->rnti, codeword_idx, sf->tti % 10, cfg->grant.tb[tb_idx].nof_bits); get_user_sequence(q, cfg->rnti, codeword_idx, sf->tti % 10, cfg->grant.tb[tb_idx].nof_bits);
if (!seq) { if (!seq) {
ERROR("Error getting user sequence for rnti=0x%x\n", cfg->rnti); ERROR("Error getting user sequence for rnti=0x%x", cfg->rnti);
return -1; return -1;
} }
@ -1135,7 +1126,6 @@ int srslte_pdsch_encode(srslte_pdsch_t* q,
uint8_t* data[SRSLTE_MAX_CODEWORDS], uint8_t* data[SRSLTE_MAX_CODEWORDS],
cf_t* sf_symbols[SRSLTE_MAX_PORTS]) cf_t* sf_symbols[SRSLTE_MAX_PORTS])
{ {
int i; int i;
/* Set pointers for layermapping & precoding */ /* Set pointers for layermapping & precoding */
cf_t* x[SRSLTE_MAX_LAYERS]; cf_t* x[SRSLTE_MAX_LAYERS];
@ -1151,19 +1141,19 @@ int srslte_pdsch_encode(srslte_pdsch_t* q,
for (i = 0; i < q->cell.nof_ports; i++) { for (i = 0; i < q->cell.nof_ports; i++) {
if (sf_symbols[i] == NULL) { if (sf_symbols[i] == NULL) {
ERROR("Error NULL pointer in sf_symbols[%d]\n", i); ERROR("Error NULL pointer in sf_symbols[%d]", i);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
} }
/* If both transport block size is zero return error */ /* If both transport block size is zero return error */
if (!nof_tb) { if (!nof_tb) {
ERROR("Error number of TB is zero\n"); ERROR("Error number of TB is zero");
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
if (cfg->grant.nof_re > q->max_re) { if (cfg->grant.nof_re > q->max_re) {
ERROR("Error too many RE per subframe (%d). PDSCH configured for %d RE (%d PRB)\n", ERROR("Error too many RE per subframe (%d). PDSCH configured for %d RE (%d PRB)",
cfg->grant.nof_re, cfg->grant.nof_re,
q->max_re, q->max_re,
q->cell.nof_prb); q->cell.nof_prb);
@ -1187,7 +1177,7 @@ int srslte_pdsch_encode(srslte_pdsch_t* q,
} }
if (cfg->rnti != SRSLTE_SIRNTI) { if (cfg->rnti != SRSLTE_SIRNTI) {
INFO("Encoding PDSCH SF: %d rho_a=%f, nof_ports=%d, nof_layers=%d, nof_tb=%d, pmi=%d, tx_scheme=%s\n", INFO("Encoding PDSCH SF: %d rho_a=%f, nof_ports=%d, nof_layers=%d, nof_tb=%d, pmi=%d, tx_scheme=%s",
sf->tti % 10, sf->tti % 10,
rho_a, rho_a,
q->cell.nof_ports, q->cell.nof_ports,
@ -1287,7 +1277,6 @@ uint32_t srslte_pdsch_grant_rx_info(srslte_pdsch_grant_t* grant,
char* str, char* str,
uint32_t str_len) uint32_t str_len)
{ {
uint32_t len = srslte_ra_dl_info(grant, str, str_len); uint32_t len = srslte_ra_dl_info(grant, str, str_len);
len = srslte_print_check(str, str_len, len, ", crc={", 0); len = srslte_print_check(str, str_len, len, ", crc={", 0);
@ -1332,7 +1321,7 @@ srslte_pdsch_rx_info(srslte_pdsch_cfg_t* cfg, srslte_pdsch_res_t res[SRSLTE_MAX_
} }
if (cfg->meas_time_en) { if (cfg->meas_time_en) {
len = srslte_print_check(str, str_len, len, ", t=%d us\n", cfg->meas_time_value); len = srslte_print_check(str, str_len, len, ", t=%d us", cfg->meas_time_value);
} }
return len; return len;
@ -1340,7 +1329,6 @@ srslte_pdsch_rx_info(srslte_pdsch_cfg_t* cfg, srslte_pdsch_res_t res[SRSLTE_MAX_
uint32_t srslte_pdsch_tx_info(srslte_pdsch_cfg_t* cfg, char* str, uint32_t str_len) uint32_t srslte_pdsch_tx_info(srslte_pdsch_cfg_t* cfg, char* str, uint32_t str_len)
{ {
uint32_t len = srslte_print_check(str, str_len, 0, "rnti=0x%x", cfg->rnti); uint32_t len = srslte_print_check(str, str_len, 0, "rnti=0x%x", cfg->rnti);
len += srslte_ra_dl_info(&cfg->grant, &str[len], str_len); len += srslte_ra_dl_info(&cfg->grant, &str[len], str_len);

@ -21,7 +21,7 @@ int pdsch_nr_init_common(srslte_pdsch_nr_t* q, const srslte_pdsch_nr_args_t* arg
{ {
for (srslte_mod_t mod = SRSLTE_MOD_BPSK; mod < SRSLTE_MOD_NITEMS; mod++) { for (srslte_mod_t mod = SRSLTE_MOD_BPSK; mod < SRSLTE_MOD_NITEMS; mod++) {
if (srslte_modem_table_lte(&q->modem_tables[mod], mod) < SRSLTE_SUCCESS) { if (srslte_modem_table_lte(&q->modem_tables[mod], mod) < SRSLTE_SUCCESS) {
ERROR("Error initialising modem table for %s\n", srslte_mod_string(mod)); ERROR("Error initialising modem table for %s", srslte_mod_string(mod));
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (args->measure_evm) { if (args->measure_evm) {
@ -43,7 +43,7 @@ int srslte_pdsch_nr_init_enb(srslte_pdsch_nr_t* q, const srslte_pdsch_nr_args_t*
} }
if (srslte_sch_nr_init_tx(&q->sch, &args->sch)) { if (srslte_sch_nr_init_tx(&q->sch, &args->sch)) {
ERROR("Initialising SCH\n"); ERROR("Initialising SCH");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -61,14 +61,14 @@ int srslte_pdsch_nr_init_ue(srslte_pdsch_nr_t* q, const srslte_pdsch_nr_args_t*
} }
if (srslte_sch_nr_init_rx(&q->sch, &args->sch)) { if (srslte_sch_nr_init_rx(&q->sch, &args->sch)) {
ERROR("Initialising SCH\n"); ERROR("Initialising SCH");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (args->measure_evm) { if (args->measure_evm) {
q->evm_buffer = srslte_evm_buffer_alloc(8); q->evm_buffer = srslte_evm_buffer_alloc(8);
if (q->evm_buffer == NULL) { if (q->evm_buffer == NULL) {
ERROR("Initialising EVM\n"); ERROR("Initialising EVM");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -411,7 +411,7 @@ pdsch_nr_cinit(const srslte_carrier_nr_t* carrier, const srslte_sch_cfg_nr_t* cf
} }
uint32_t cinit = (((uint32_t)rnti) << 15U) + (cw_idx << 14U) + n_id; uint32_t cinit = (((uint32_t)rnti) << 15U) + (cw_idx << 14U) + n_id;
INFO("PDSCH: RNTI=%d (0x%x); nid=%d; cinit=%d (0x%x);\n", rnti, rnti, n_id, cinit, cinit); INFO("PDSCH: RNTI=%d (0x%x); nid=%d; cinit=%d (0x%x);", rnti, rnti, n_id, cinit, cinit);
return cinit; return cinit;
} }
@ -429,19 +429,19 @@ static inline int pdsch_nr_encode_codeword(srslte_pdsch_nr_t* q,
// Check codeword index // Check codeword index
if (tb->cw_idx >= q->max_cw) { if (tb->cw_idx >= q->max_cw) {
ERROR("Unsupported codeword index %d\n", tb->cw_idx); ERROR("Unsupported codeword index %d", tb->cw_idx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Check modulation // Check modulation
if (tb->mod >= SRSLTE_MOD_NITEMS) { if (tb->mod >= SRSLTE_MOD_NITEMS) {
ERROR("Invalid modulation %s\n", srslte_mod_string(tb->mod)); ERROR("Invalid modulation %s", srslte_mod_string(tb->mod));
return SRSLTE_ERROR_OUT_OF_BOUNDS; return SRSLTE_ERROR_OUT_OF_BOUNDS;
} }
// Encode SCH // Encode SCH
if (srslte_dlsch_nr_encode(&q->sch, &cfg->sch_cfg, tb, data, q->b[tb->cw_idx]) < SRSLTE_SUCCESS) { if (srslte_dlsch_nr_encode(&q->sch, &cfg->sch_cfg, tb, data, q->b[tb->cw_idx]) < SRSLTE_SUCCESS) {
ERROR("Error in DL-SCH encoding\n"); ERROR("Error in DL-SCH encoding");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -483,7 +483,7 @@ int srslte_pdsch_nr_encode(srslte_pdsch_nr_t* q,
// Check number of layers // Check number of layers
if (q->max_layers < grant->nof_layers) { if (q->max_layers < grant->nof_layers) {
ERROR("Error number of layers (%d) exceeds configured maximum (%d)\n", grant->nof_layers, q->max_layers); ERROR("Error number of layers (%d) exceeds configured maximum (%d)", grant->nof_layers, q->max_layers);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -493,7 +493,7 @@ int srslte_pdsch_nr_encode(srslte_pdsch_nr_t* q,
nof_cw += grant->tb[tb].enabled ? 1 : 0; nof_cw += grant->tb[tb].enabled ? 1 : 0;
if (pdsch_nr_encode_codeword(q, cfg, &grant->tb[tb], data[tb], grant->rnti) < SRSLTE_SUCCESS) { if (pdsch_nr_encode_codeword(q, cfg, &grant->tb[tb], data[tb], grant->rnti) < SRSLTE_SUCCESS) {
ERROR("Error encoding TB %d\n", tb); ERROR("Error encoding TB %d", tb);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -514,12 +514,12 @@ int srslte_pdsch_nr_encode(srslte_pdsch_nr_t* q,
// 7.3.1.6 Mapping from virtual to physical resource blocks // 7.3.1.6 Mapping from virtual to physical resource blocks
int n = srslte_pdsch_nr_put(q, cfg, grant, x[0], sf_symbols[0]); int n = srslte_pdsch_nr_put(q, cfg, grant, x[0], sf_symbols[0]);
if (n < SRSLTE_SUCCESS) { if (n < SRSLTE_SUCCESS) {
ERROR("Putting NR PDSCH resources\n"); ERROR("Putting NR PDSCH resources");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (n != grant->tb[0].nof_re) { if (n != grant->tb[0].nof_re) {
ERROR("Unmatched number of RE (%d != %d)\n", n, grant->tb[0].nof_re); ERROR("Unmatched number of RE (%d != %d)", n, grant->tb[0].nof_re);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -545,13 +545,13 @@ static inline int pdsch_nr_decode_codeword(srslte_pdsch_nr_t* q,
// Check codeword index // Check codeword index
if (tb->cw_idx >= q->max_cw) { if (tb->cw_idx >= q->max_cw) {
ERROR("Unsupported codeword index %d\n", tb->cw_idx); ERROR("Unsupported codeword index %d", tb->cw_idx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Check modulation // Check modulation
if (tb->mod >= SRSLTE_MOD_NITEMS) { if (tb->mod >= SRSLTE_MOD_NITEMS) {
ERROR("Invalid modulation %s\n", srslte_mod_string(tb->mod)); ERROR("Invalid modulation %s", srslte_mod_string(tb->mod));
return SRSLTE_ERROR_OUT_OF_BOUNDS; return SRSLTE_ERROR_OUT_OF_BOUNDS;
} }
@ -586,7 +586,7 @@ static inline int pdsch_nr_decode_codeword(srslte_pdsch_nr_t* q,
// Decode SCH // Decode SCH
if (srslte_dlsch_nr_decode(&q->sch, &cfg->sch_cfg, tb, llr, res->payload, &res->crc) < SRSLTE_SUCCESS) { if (srslte_dlsch_nr_decode(&q->sch, &cfg->sch_cfg, tb, llr, res->payload, &res->crc) < SRSLTE_SUCCESS) {
ERROR("Error in DL-SCH encoding\n"); ERROR("Error in DL-SCH encoding");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -618,14 +618,14 @@ int srslte_pdsch_nr_decode(srslte_pdsch_nr_t* q,
uint32_t nof_re = srslte_ra_dl_nr_slot_nof_re(cfg, grant); uint32_t nof_re = srslte_ra_dl_nr_slot_nof_re(cfg, grant);
if (channel->nof_re != nof_re) { if (channel->nof_re != nof_re) {
ERROR("Inconsistent number of RE (%d!=%d)\n", channel->nof_re, nof_re); ERROR("Inconsistent number of RE (%d!=%d)", channel->nof_re, nof_re);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Demapping from virtual to physical resource blocks // Demapping from virtual to physical resource blocks
uint32_t nof_re_get = srslte_pdsch_nr_get(q, cfg, grant, q->x[0], sf_symbols[0]); uint32_t nof_re_get = srslte_pdsch_nr_get(q, cfg, grant, q->x[0], sf_symbols[0]);
if (nof_re_get != nof_re) { if (nof_re_get != nof_re) {
ERROR("Inconsistent number of RE (%d!=%d)\n", nof_re_get, nof_re); ERROR("Inconsistent number of RE (%d!=%d)", nof_re_get, nof_re);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -654,7 +654,7 @@ int srslte_pdsch_nr_decode(srslte_pdsch_nr_t* q,
nof_cw += grant->tb[tb].enabled ? 1 : 0; nof_cw += grant->tb[tb].enabled ? 1 : 0;
if (pdsch_nr_decode_codeword(q, cfg, &grant->tb[tb], &data[tb], grant->rnti) < SRSLTE_SUCCESS) { if (pdsch_nr_decode_codeword(q, cfg, &grant->tb[tb], &data[tb], grant->rnti) < SRSLTE_SUCCESS) {
ERROR("Error encoding TB %d\n", tb); ERROR("Error encoding TB %d", tb);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -773,7 +773,7 @@ uint32_t srslte_pdsch_nr_tx_info(const srslte_pdsch_nr_t* q,
len += srslte_pdsch_nr_grant_info(cfg, grant, &str[len], str_len - len); len += srslte_pdsch_nr_grant_info(cfg, grant, &str[len], str_len - len);
if (q->meas_time_en) { if (q->meas_time_en) {
len = srslte_print_check(str, str_len, len, ", t=%d us\n", q->meas_time_us); len = srslte_print_check(str, str_len, len, ", t=%d us", q->meas_time_us);
} }
return len; return len;

@ -66,7 +66,6 @@ int srslte_phich_init(srslte_phich_t* q, uint32_t nof_rx_antennas)
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL) { if (q != NULL) {
bzero(q, sizeof(srslte_phich_t)); bzero(q, sizeof(srslte_phich_t));
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
@ -104,7 +103,6 @@ int srslte_phich_set_cell(srslte_phich_t* q, srslte_regs_t* regs, srslte_cell_t
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL && regs != NULL && srslte_cell_isvalid(&cell)) { if (q != NULL && regs != NULL && srslte_cell_isvalid(&cell)) {
q->regs = regs; q->regs = regs;
if (cell.id != q->cell.id || q->cell.nof_prb == 0) { if (cell.id != q->cell.id || q->cell.nof_prb == 0) {
@ -130,7 +128,7 @@ void srslte_phich_calc(srslte_phich_t* q, srslte_phich_grant_t* grant, srslte_ph
n_phich->nseq = ((grant->n_prb_lowest / Ngroups) + grant->n_dmrs) % (2 * srslte_phich_nsf(q)); n_phich->nseq = ((grant->n_prb_lowest / Ngroups) + grant->n_dmrs) % (2 * srslte_phich_nsf(q));
} }
} else { } else {
ERROR("PHICH: Error computing PHICH groups. Ngroups is zero\n"); ERROR("PHICH: Error computing PHICH groups. Ngroups is zero");
} }
} }
@ -151,7 +149,7 @@ uint8_t srslte_phich_ack_decode(float bits[SRSLTE_PHICH_NBITS], float* distance)
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
float corr = srslte_vec_dot_prod_fff(ack_table[i], bits, SRSLTE_PHICH_NBITS) / SRSLTE_PHICH_NBITS; float corr = srslte_vec_dot_prod_fff(ack_table[i], bits, SRSLTE_PHICH_NBITS) / SRSLTE_PHICH_NBITS;
INFO("Corr%d=%f\n", i, corr); INFO("Corr%d=%f", i, corr);
if (corr > max_corr) { if (corr > max_corr) {
max_corr = corr; max_corr = corr;
if (distance) { if (distance) {
@ -178,7 +176,6 @@ int srslte_phich_decode(srslte_phich_t* q,
cf_t* sf_symbols[SRSLTE_MAX_PORTS], cf_t* sf_symbols[SRSLTE_MAX_PORTS],
srslte_phich_res_t* result) srslte_phich_res_t* result)
{ {
/* Set pointers for layermapping & precoding */ /* Set pointers for layermapping & precoding */
int i, j; int i, j;
cf_t* x[SRSLTE_MAX_LAYERS]; cf_t* x[SRSLTE_MAX_LAYERS];
@ -190,27 +187,27 @@ int srslte_phich_decode(srslte_phich_t* q,
uint32_t sf_idx = sf->tti % 10; uint32_t sf_idx = sf->tti % 10;
if (sf_idx >= SRSLTE_NOF_SF_X_FRAME) { if (sf_idx >= SRSLTE_NOF_SF_X_FRAME) {
ERROR("Invalid nslot %d\n", sf_idx); ERROR("Invalid nslot %d", sf_idx);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
if (SRSLTE_CP_ISEXT(q->cell.cp)) { if (SRSLTE_CP_ISEXT(q->cell.cp)) {
if (n_phich.nseq >= SRSLTE_PHICH_EXT_NSEQUENCES) { if (n_phich.nseq >= SRSLTE_PHICH_EXT_NSEQUENCES) {
ERROR("Invalid nseq %d\n", n_phich.nseq); ERROR("Invalid nseq %d", n_phich.nseq);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
} else { } else {
if (n_phich.nseq >= SRSLTE_PHICH_NORM_NSEQUENCES) { if (n_phich.nseq >= SRSLTE_PHICH_NORM_NSEQUENCES) {
ERROR("Invalid nseq %d\n", n_phich.nseq); ERROR("Invalid nseq %d", n_phich.nseq);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
} }
if (n_phich.ngroup >= srslte_regs_phich_ngroups(q->regs)) { if (n_phich.ngroup >= srslte_regs_phich_ngroups(q->regs)) {
ERROR("Invalid ngroup %d\n", n_phich.ngroup); ERROR("Invalid ngroup %d", n_phich.ngroup);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
DEBUG("Decoding PHICH Ngroup: %d, Nseq: %d\n", n_phich.ngroup, n_phich.nseq); DEBUG("Decoding PHICH Ngroup: %d, Nseq: %d", n_phich.ngroup, n_phich.nseq);
/* number of layers equals number of ports */ /* number of layers equals number of ports */
for (i = 0; i < SRSLTE_MAX_PORTS; i++) { for (i = 0; i < SRSLTE_MAX_PORTS; i++) {
@ -223,7 +220,7 @@ int srslte_phich_decode(srslte_phich_t* q,
/* extract symbols */ /* extract symbols */
for (int j = 0; j < q->nof_rx_antennas; j++) { for (int j = 0; j < q->nof_rx_antennas; j++) {
if (SRSLTE_PHICH_MAX_NSYMB != srslte_regs_phich_get(q->regs, sf_symbols[j], q->sf_symbols[j], n_phich.ngroup)) { if (SRSLTE_PHICH_MAX_NSYMB != srslte_regs_phich_get(q->regs, sf_symbols[j], q->sf_symbols[j], n_phich.ngroup)) {
ERROR("There was an error getting the phich symbols\n"); ERROR("There was an error getting the phich symbols");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q_sf_symbols[j] = q->sf_symbols[j]; q_sf_symbols[j] = q->sf_symbols[j];
@ -231,7 +228,7 @@ int srslte_phich_decode(srslte_phich_t* q,
/* extract channel estimates */ /* extract channel estimates */
for (i = 0; i < q->cell.nof_ports; i++) { for (i = 0; i < q->cell.nof_ports; i++) {
if (SRSLTE_PHICH_MAX_NSYMB != srslte_regs_phich_get(q->regs, channel->ce[i][j], q->ce[i][j], n_phich.ngroup)) { if (SRSLTE_PHICH_MAX_NSYMB != srslte_regs_phich_get(q->regs, channel->ce[i][j], q->ce[i][j], n_phich.ngroup)) {
ERROR("There was an error getting the phich symbols\n"); ERROR("There was an error getting the phich symbols");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q_ce[i][j] = q->ce[i][j]; q_ce[i][j] = q->ce[i][j];
@ -248,7 +245,7 @@ int srslte_phich_decode(srslte_phich_t* q,
q_sf_symbols, q_ce, x, NULL, q->nof_rx_antennas, q->cell.nof_ports, SRSLTE_PHICH_MAX_NSYMB, 1.0f); q_sf_symbols, q_ce, x, NULL, q->nof_rx_antennas, q->cell.nof_ports, SRSLTE_PHICH_MAX_NSYMB, 1.0f);
srslte_layerdemap_diversity(x, q->d0, q->cell.nof_ports, SRSLTE_PHICH_MAX_NSYMB / q->cell.nof_ports); srslte_layerdemap_diversity(x, q->d0, q->cell.nof_ports, SRSLTE_PHICH_MAX_NSYMB / q->cell.nof_ports);
} }
DEBUG("Recv!!: \n"); DEBUG("Recv!!: ");
DEBUG("d0: "); DEBUG("d0: ");
if (SRSLTE_VERBOSE_ISDEBUG()) if (SRSLTE_VERBOSE_ISDEBUG())
srslte_vec_fprint_c(stdout, q->d0, SRSLTE_PHICH_MAX_NSYMB); srslte_vec_fprint_c(stdout, q->d0, SRSLTE_PHICH_MAX_NSYMB);
@ -323,23 +320,23 @@ int srslte_phich_encode(srslte_phich_t* q,
uint32_t sf_idx = sf->tti % 10; uint32_t sf_idx = sf->tti % 10;
if (sf_idx >= SRSLTE_NOF_SF_X_FRAME) { if (sf_idx >= SRSLTE_NOF_SF_X_FRAME) {
ERROR("Invalid nslot %d\n", sf_idx); ERROR("Invalid nslot %d", sf_idx);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
if (SRSLTE_CP_ISEXT(q->cell.cp)) { if (SRSLTE_CP_ISEXT(q->cell.cp)) {
if (n_phich.nseq >= SRSLTE_PHICH_EXT_NSEQUENCES) { if (n_phich.nseq >= SRSLTE_PHICH_EXT_NSEQUENCES) {
ERROR("Invalid nseq %d\n", n_phich.nseq); ERROR("Invalid nseq %d", n_phich.nseq);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
} else { } else {
if (n_phich.nseq >= SRSLTE_PHICH_NORM_NSEQUENCES) { if (n_phich.nseq >= SRSLTE_PHICH_NORM_NSEQUENCES) {
ERROR("Invalid nseq %d\n", n_phich.nseq); ERROR("Invalid nseq %d", n_phich.nseq);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
} }
if (n_phich.ngroup >= srslte_regs_phich_ngroups(q->regs)) { if (n_phich.ngroup >= srslte_regs_phich_ngroups(q->regs)) {
ERROR("Invalid ngroup %d\n", n_phich.ngroup); ERROR("Invalid ngroup %d", n_phich.ngroup);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
@ -419,7 +416,7 @@ int srslte_phich_encode(srslte_phich_t* q,
/* mapping to resource elements */ /* mapping to resource elements */
for (i = 0; i < q->cell.nof_ports; i++) { for (i = 0; i < q->cell.nof_ports; i++) {
if (srslte_regs_phich_add(q->regs, q->sf_symbols[i], n_phich.ngroup, sf_symbols[i]) < 0) { if (srslte_regs_phich_add(q->regs, q->sf_symbols[i], n_phich.ngroup, sf_symbols[i]) < 0) {
ERROR("Error putting PCHICH resource elements\n"); ERROR("Error putting PCHICH resource elements");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }

@ -119,7 +119,6 @@ int srslte_pmch_init(srslte_pmch_t* q, uint32_t max_prb, uint32_t nof_rx_antenna
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL && nof_rx_antennas <= SRSLTE_MAX_PORTS) { if (q != NULL && nof_rx_antennas <= SRSLTE_MAX_PORTS) {
bzero(q, sizeof(srslte_pmch_t)); bzero(q, sizeof(srslte_pmch_t));
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
@ -128,7 +127,7 @@ int srslte_pmch_init(srslte_pmch_t* q, uint32_t max_prb, uint32_t nof_rx_antenna
q->max_re = max_prb * MAX_PMCH_RE; q->max_re = max_prb * MAX_PMCH_RE;
q->nof_rx_antennas = nof_rx_antennas; q->nof_rx_antennas = nof_rx_antennas;
INFO("Init PMCH: %d PRBs, max_symbols: %d\n", max_prb, q->max_re); INFO("Init PMCH: %d PRBs, max_symbols: %d", max_prb, q->max_re);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
if (srslte_modem_table_lte(&q->mod[i], modulations[i])) { if (srslte_modem_table_lte(&q->mod[i], modulations[i])) {
@ -232,7 +231,7 @@ int srslte_pmch_set_cell(srslte_pmch_t* q, srslte_cell_t cell)
q->cell = cell; q->cell = cell;
q->max_re = q->cell.nof_prb * MAX_PMCH_RE; q->max_re = q->cell.nof_prb * MAX_PMCH_RE;
INFO("PMCH: Cell config PCI=%d, %d ports, %d PRBs, max_symbols: %d\n", INFO("PMCH: Cell config PCI=%d, %d ports, %d PRBs, max_symbols: %d",
q->cell.nof_ports, q->cell.nof_ports,
q->cell.id, q->cell.id,
q->cell.nof_prb, q->cell.nof_prb,
@ -283,14 +282,13 @@ int srslte_pmch_decode(srslte_pmch_t* q,
cf_t* sf_symbols[SRSLTE_MAX_PORTS], cf_t* sf_symbols[SRSLTE_MAX_PORTS],
srslte_pdsch_res_t* out) srslte_pdsch_res_t* out)
{ {
/* Set pointers for layermapping & precoding */ /* Set pointers for layermapping & precoding */
uint32_t i, n; uint32_t i, n;
cf_t* x[SRSLTE_MAX_LAYERS]; cf_t* x[SRSLTE_MAX_LAYERS];
if (q != NULL && sf_symbols != NULL && out != NULL && cfg != NULL) { if (q != NULL && sf_symbols != NULL && out != NULL && cfg != NULL) {
INFO("Decoding PMCH SF: %d, MBSFN area ID: 0x%x, Mod %s, TBS: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d, " INFO("Decoding PMCH SF: %d, MBSFN area ID: 0x%x, Mod %s, TBS: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d, "
"C_prb=%d, cfi=%d\n", "C_prb=%d, cfi=%d",
sf->tti % 10, sf->tti % 10,
cfg->area_id, cfg->area_id,
srslte_mod_string(cfg->pdsch_cfg.grant.tb[0].mod), srslte_mod_string(cfg->pdsch_cfg.grant.tb[0].mod),
@ -312,8 +310,7 @@ int srslte_pmch_decode(srslte_pmch_t* q,
/* extract symbols */ /* extract symbols */
n = pmch_get(q, sf_symbols[j], q->symbols[j], lstart); n = pmch_get(q, sf_symbols[j], q->symbols[j], lstart);
if (n != cfg->pdsch_cfg.grant.nof_re) { if (n != cfg->pdsch_cfg.grant.nof_re) {
ERROR("PMCH 1 extract symbols error expecting %d symbols but got %d, lstart %d",
ERROR("PMCH 1 extract symbols error expecting %d symbols but got %d, lstart %d\n",
cfg->pdsch_cfg.grant.nof_re, cfg->pdsch_cfg.grant.nof_re,
n, n,
lstart); lstart);
@ -324,7 +321,7 @@ int srslte_pmch_decode(srslte_pmch_t* q,
for (i = 0; i < q->cell.nof_ports; i++) { for (i = 0; i < q->cell.nof_ports; i++) {
n = pmch_get(q, channel->ce[i][j], q->ce[i][j], lstart); n = pmch_get(q, channel->ce[i][j], q->ce[i][j], lstart);
if (n != cfg->pdsch_cfg.grant.nof_re) { if (n != cfg->pdsch_cfg.grant.nof_re) {
ERROR("PMCH 2 extract chest error expecting %d symbols but got %d\n", cfg->pdsch_cfg.grant.nof_re, n); ERROR("PMCH 2 extract chest error expecting %d symbols but got %d", cfg->pdsch_cfg.grant.nof_re, n);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -341,16 +338,16 @@ int srslte_pmch_decode(srslte_pmch_t* q,
channel->noise_estimate); channel->noise_estimate);
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE subframe.dat: received subframe symbols\n"); DEBUG("SAVED FILE subframe.dat: received subframe symbols");
srslte_vec_save_file("subframe2.dat", q->symbols[0], cfg->pdsch_cfg.grant.nof_re * sizeof(cf_t)); srslte_vec_save_file("subframe2.dat", q->symbols[0], cfg->pdsch_cfg.grant.nof_re * sizeof(cf_t));
DEBUG("SAVED FILE hest0.dat: channel estimates for port 4\n"); DEBUG("SAVED FILE hest0.dat: channel estimates for port 4");
printf("nof_prb=%d, cp=%d, nof_re=%d, grant_re=%d\n", printf("nof_prb=%d, cp=%d, nof_re=%d, grant_re=%d\n",
q->cell.nof_prb, q->cell.nof_prb,
q->cell.cp, q->cell.cp,
SRSLTE_NOF_RE(q->cell), SRSLTE_NOF_RE(q->cell),
cfg->pdsch_cfg.grant.nof_re); cfg->pdsch_cfg.grant.nof_re);
srslte_vec_save_file("hest2.dat", channel->ce[0][0], SRSLTE_NOF_RE(q->cell) * sizeof(cf_t)); srslte_vec_save_file("hest2.dat", channel->ce[0][0], SRSLTE_NOF_RE(q->cell) * sizeof(cf_t));
DEBUG("SAVED FILE pmch_symbols.dat: symbols after equalization\n"); DEBUG("SAVED FILE pmch_symbols.dat: symbols after equalization");
srslte_vec_save_file("pmch_symbols.bin", q->d, cfg->pdsch_cfg.grant.nof_re * sizeof(cf_t)); srslte_vec_save_file("pmch_symbols.bin", q->d, cfg->pdsch_cfg.grant.nof_re * sizeof(cf_t));
} }
@ -364,7 +361,7 @@ int srslte_pmch_decode(srslte_pmch_t* q,
srslte_scrambling_s_offset(&q->seqs[cfg->area_id]->seq[sf->tti % 10], q->e, 0, cfg->pdsch_cfg.grant.tb[0].nof_bits); srslte_scrambling_s_offset(&q->seqs[cfg->area_id]->seq[sf->tti % 10], q->e, 0, cfg->pdsch_cfg.grant.tb[0].nof_bits);
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE llr.dat: LLR estimates after demodulation and descrambling\n"); DEBUG("SAVED FILE llr.dat: LLR estimates after demodulation and descrambling");
srslte_vec_save_file("llr.dat", q->e, cfg->pdsch_cfg.grant.tb[0].nof_bits * sizeof(int16_t)); srslte_vec_save_file("llr.dat", q->e, cfg->pdsch_cfg.grant.tb[0].nof_bits * sizeof(int16_t));
} }
out[0].crc = (srslte_dlsch_decode(&q->dl_sch, &cfg->pdsch_cfg, q->e, out[0].payload) == 0); out[0].crc = (srslte_dlsch_decode(&q->dl_sch, &cfg->pdsch_cfg, q->e, out[0].payload) == 0);
@ -403,7 +400,6 @@ int srslte_pmch_encode(srslte_pmch_t* q,
uint8_t* data, uint8_t* data,
cf_t* sf_symbols[SRSLTE_MAX_PORTS]) cf_t* sf_symbols[SRSLTE_MAX_PORTS])
{ {
int i; int i;
/* Set pointers for layermapping & precoding */ /* Set pointers for layermapping & precoding */
cf_t* x[SRSLTE_MAX_LAYERS]; cf_t* x[SRSLTE_MAX_LAYERS];
@ -420,14 +416,14 @@ int srslte_pmch_encode(srslte_pmch_t* q,
} }
if (cfg->pdsch_cfg.grant.nof_re > q->max_re) { if (cfg->pdsch_cfg.grant.nof_re > q->max_re) {
ERROR("Error too many RE per subframe (%d). PMCH configured for %d RE (%d PRB)\n", ERROR("Error too many RE per subframe (%d). PMCH configured for %d RE (%d PRB)",
cfg->pdsch_cfg.grant.nof_re, cfg->pdsch_cfg.grant.nof_re,
q->max_re, q->max_re,
q->cell.nof_prb); q->cell.nof_prb);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
INFO("Encoding PMCH SF: %d, Mod %s, NofBits: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d\n", INFO("Encoding PMCH SF: %d, Mod %s, NofBits: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d",
sf->tti % 10, sf->tti % 10,
srslte_mod_string(cfg->pdsch_cfg.grant.tb[0].mod), srslte_mod_string(cfg->pdsch_cfg.grant.tb[0].mod),
cfg->pdsch_cfg.grant.tb[0].tbs, cfg->pdsch_cfg.grant.tb[0].tbs,
@ -443,7 +439,7 @@ int srslte_pmch_encode(srslte_pmch_t* q,
// TODO: use tb_encode directly // TODO: use tb_encode directly
if (srslte_dlsch_encode(&q->dl_sch, &cfg->pdsch_cfg, data, q->e)) { if (srslte_dlsch_encode(&q->dl_sch, &cfg->pdsch_cfg, data, q->e)) {
ERROR("Error encoding TB\n"); ERROR("Error encoding TB");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }

@ -99,7 +99,7 @@ uint32_t srslte_prach_nof_f_idx_tdd(uint32_t config_idx, uint32_t tdd_ul_dl_conf
if (config_idx < 64 && tdd_ul_dl_config < 7) { if (config_idx < 64 && tdd_ul_dl_config < 7) {
return prach_tdd_loc_table[config_idx][tdd_ul_dl_config].nof_elems; return prach_tdd_loc_table[config_idx][tdd_ul_dl_config].nof_elems;
} else { } else {
ERROR("PRACH: Invalid parmeters config_idx=%d, tdd_ul_config=%d\n", config_idx, tdd_ul_dl_config); ERROR("PRACH: Invalid parmeters config_idx=%d, tdd_ul_config=%d", config_idx, tdd_ul_dl_config);
return 0; return 0;
} }
} }
@ -109,7 +109,7 @@ uint32_t srslte_prach_f_id_tdd(uint32_t config_idx, uint32_t tdd_ul_dl_config, u
if (config_idx < 64 && tdd_ul_dl_config < 7) { if (config_idx < 64 && tdd_ul_dl_config < 7) {
return prach_tdd_loc_table[config_idx][tdd_ul_dl_config].elems[prach_idx].f; return prach_tdd_loc_table[config_idx][tdd_ul_dl_config].elems[prach_idx].f;
} else { } else {
ERROR("PRACH: Invalid parmeters config_idx=%d, tdd_ul_config=%d\n", config_idx, tdd_ul_dl_config); ERROR("PRACH: Invalid parmeters config_idx=%d, tdd_ul_config=%d", config_idx, tdd_ul_dl_config);
return 0; return 0;
} }
} }
@ -121,9 +121,8 @@ uint32_t srslte_prach_f_ra_tdd(uint32_t config_idx,
uint32_t prach_offset, uint32_t prach_offset,
uint32_t n_rb_ul) uint32_t n_rb_ul)
{ {
if (config_idx >= 64 || tdd_ul_dl_config >= 7) { if (config_idx >= 64 || tdd_ul_dl_config >= 7) {
ERROR("PRACH: Invalid parameters config_idx=%d, tdd_ul_config=%d\n", config_idx, tdd_ul_dl_config); ERROR("PRACH: Invalid parameters config_idx=%d, tdd_ul_config=%d", config_idx, tdd_ul_dl_config);
return 0; return 0;
} }
uint32_t f_ra = prach_tdd_loc_table[config_idx][tdd_ul_dl_config].elems[prach_idx].f; uint32_t f_ra = prach_tdd_loc_table[config_idx][tdd_ul_dl_config].elems[prach_idx].f;
@ -160,7 +159,7 @@ bool srslte_prach_tti_opportunity_config_tdd(uint32_t config_idx,
uint32_t* prach_idx) uint32_t* prach_idx)
{ {
if (config_idx >= 64 || tdd_ul_dl_config >= 7) { if (config_idx >= 64 || tdd_ul_dl_config >= 7) {
ERROR("PRACH: Invalid parameters config_idx=%d, tdd_ul_config=%d\n", config_idx, tdd_ul_dl_config); ERROR("PRACH: Invalid parameters config_idx=%d, tdd_ul_config=%d", config_idx, tdd_ul_dl_config);
return 0; return 0;
} }
@ -244,7 +243,6 @@ int srslte_prach_gen_seqs(srslte_prach_t* p)
// Generate our 64 preamble sequences // Generate our 64 preamble sequences
for (int i = 0; i < N_SEQS; i++) { for (int i = 0; i < N_SEQS; i++) {
if (v > v_max) { if (v > v_max) {
// Get a new root sequence // Get a new root sequence
if (4 == p->f) { if (4 == p->f) {
@ -367,20 +365,20 @@ int srslte_prach_init(srslte_prach_t* p, uint32_t max_N_ifft_ul)
p->ifft_in = srslte_vec_cf_malloc(fft_size_alloc); p->ifft_in = srslte_vec_cf_malloc(fft_size_alloc);
p->ifft_out = srslte_vec_cf_malloc(fft_size_alloc); p->ifft_out = srslte_vec_cf_malloc(fft_size_alloc);
if (srslte_dft_plan(&p->ifft, fft_size_alloc, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX)) { if (srslte_dft_plan(&p->ifft, fft_size_alloc, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX)) {
ERROR("Error creating DFT plan\n"); ERROR("Error creating DFT plan");
return -1; return -1;
} }
srslte_dft_plan_set_mirror(&p->ifft, true); srslte_dft_plan_set_mirror(&p->ifft, true);
srslte_dft_plan_set_norm(&p->ifft, true); srslte_dft_plan_set_norm(&p->ifft, true);
if (srslte_dft_plan(&p->fft, fft_size_alloc, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX)) { if (srslte_dft_plan(&p->fft, fft_size_alloc, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX)) {
ERROR("Error creating DFT plan\n"); ERROR("Error creating DFT plan");
return -1; return -1;
} }
p->signal_fft = srslte_vec_cf_malloc(fft_size_alloc); p->signal_fft = srslte_vec_cf_malloc(fft_size_alloc);
if (!p->signal_fft) { if (!p->signal_fft) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return -1; return -1;
} }
@ -389,7 +387,7 @@ int srslte_prach_init(srslte_prach_t* p, uint32_t max_N_ifft_ul)
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;
} else { } else {
ERROR("Invalid parameters\n"); ERROR("Invalid parameters");
} }
return ret; return ret;
@ -403,7 +401,7 @@ int srslte_prach_set_cell_(srslte_prach_t* p,
int ret = SRSLTE_ERROR; int ret = SRSLTE_ERROR;
if (p != NULL && N_ifft_ul < 2049 && cfg->config_idx < 64 && cfg->root_seq_idx < MAX_ROOTS) { if (p != NULL && N_ifft_ul < 2049 && cfg->config_idx < 64 && cfg->root_seq_idx < MAX_ROOTS) {
if (N_ifft_ul > p->max_N_ifft_ul) { if (N_ifft_ul > p->max_N_ifft_ul) {
ERROR("PRACH: Error in set_cell(): N_ifft_ul must be lower or equal max_N_ifft_ul in init()\n"); ERROR("PRACH: Error in set_cell(): N_ifft_ul must be lower or equal max_N_ifft_ul in init()");
return -1; return -1;
} }
@ -433,7 +431,7 @@ int srslte_prach_set_cell_(srslte_prach_t* p,
p->N_zc = 139; p->N_zc = 139;
p->N_cs = prach_Ncs_format4[p->zczc]; p->N_cs = prach_Ncs_format4[p->zczc];
} else { } else {
ERROR("Invalid zeroCorrelationZoneConfig=%d for format4\n", p->zczc); ERROR("Invalid zeroCorrelationZoneConfig=%d for format4", p->zczc);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} else { } else {
@ -442,14 +440,14 @@ int srslte_prach_set_cell_(srslte_prach_t* p,
if (p->zczc < 15) { if (p->zczc < 15) {
p->N_cs = prach_Ncs_restricted[p->zczc]; p->N_cs = prach_Ncs_restricted[p->zczc];
} else { } else {
ERROR("Invalid zeroCorrelationZoneConfig=%d for restricted set\n", p->zczc); ERROR("Invalid zeroCorrelationZoneConfig=%d for restricted set", p->zczc);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} else { } else {
if (p->zczc < 16) { if (p->zczc < 16) {
p->N_cs = prach_Ncs_unrestricted[p->zczc]; p->N_cs = prach_Ncs_unrestricted[p->zczc];
} else { } else {
ERROR("Invalid zeroCorrelationZoneConfig=%d\n", p->zczc); ERROR("Invalid zeroCorrelationZoneConfig=%d", p->zczc);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -492,11 +490,11 @@ int srslte_prach_set_cell_(srslte_prach_t* p,
}*/ }*/
if (srslte_dft_replan(&p->ifft, p->N_ifft_prach)) { if (srslte_dft_replan(&p->ifft, p->N_ifft_prach)) {
ERROR("Error creating DFT plan\n"); ERROR("Error creating DFT plan");
return -1; return -1;
} }
if (srslte_dft_replan(&p->fft, p->N_ifft_prach)) { if (srslte_dft_replan(&p->fft, p->N_ifft_prach)) {
ERROR("Error creating DFT plan\n"); ERROR("Error creating DFT plan");
return -1; return -1;
} }
@ -514,7 +512,7 @@ int srslte_prach_set_cell_(srslte_prach_t* p,
} }
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;
} else { } else {
ERROR("Invalid parameters N_ifft_ul=%d; config_idx=%d; root_seq_idx=%d;\n", ERROR("Invalid parameters N_ifft_ul=%d; config_idx=%d; root_seq_idx=%d;",
N_ifft_ul, N_ifft_ul,
cfg->config_idx, cfg->config_idx,
cfg->root_seq_idx); cfg->root_seq_idx);
@ -534,16 +532,12 @@ int srslte_prach_gen(srslte_prach_t* p, uint32_t seq_index, uint32_t freq_offset
uint32_t begin = PHI + (K * k_0) + (p->is_nr ? 1 : (K / 2)); uint32_t begin = PHI + (K * k_0) + (p->is_nr ? 1 : (K / 2));
if (6 + freq_offset > N_rb_ul) { if (6 + freq_offset > N_rb_ul) {
ERROR("Error no space for PRACH: frequency offset=%d, N_rb_ul=%d\n", freq_offset, N_rb_ul); ERROR("Error no space for PRACH: frequency offset=%d, N_rb_ul=%d", freq_offset, N_rb_ul);
return ret; return ret;
} }
DEBUG("N_zc: %d, N_cp: %d, N_seq: %d, N_ifft_prach=%d begin: %d\n", DEBUG(
p->N_zc, "N_zc: %d, N_cp: %d, N_seq: %d, N_ifft_prach=%d begin: %d", p->N_zc, p->N_cp, p->N_seq, p->N_ifft_prach, begin);
p->N_cp,
p->N_seq,
p->N_ifft_prach,
begin);
// Map dft-precoded sequence to ifft bins // Map dft-precoded sequence to ifft bins
memset(p->ifft_in, 0, begin * sizeof(cf_t)); memset(p->ifft_in, 0, begin * sizeof(cf_t));
@ -753,9 +747,8 @@ int srslte_prach_detect_offset(srslte_prach_t* p,
{ {
int ret = SRSLTE_ERROR; int ret = SRSLTE_ERROR;
if (p != NULL && signal != NULL && sig_len > 0 && indices != NULL) { if (p != NULL && signal != NULL && sig_len > 0 && indices != NULL) {
if (sig_len < p->N_ifft_prach) { if (sig_len < p->N_ifft_prach) {
ERROR("srslte_prach_detect: Signal length is %d and should be %d\n", sig_len, p->N_ifft_prach); ERROR("srslte_prach_detect: Signal length is %d and should be %d", sig_len, p->N_ifft_prach);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
int cancellation_idx = -2; int cancellation_idx = -2;

@ -53,19 +53,19 @@ int srslte_psbch_init(srslte_psbch_t* q, uint32_t nof_prb, uint32_t N_sl_id, srs
q->c = srslte_vec_u8_malloc(q->sl_bch_tb_crc_len); q->c = srslte_vec_u8_malloc(q->sl_bch_tb_crc_len);
if (!q->c) { if (!q->c) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->d = srslte_vec_u8_malloc(q->sl_bch_encoded_len); q->d = srslte_vec_u8_malloc(q->sl_bch_encoded_len);
if (!q->d) { if (!q->d) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->d_16 = srslte_vec_i16_malloc(q->sl_bch_encoded_len); q->d_16 = srslte_vec_i16_malloc(q->sl_bch_encoded_len);
if (!q->d_16) { if (!q->d_16) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -77,7 +77,7 @@ int srslte_psbch_init(srslte_psbch_t* q, uint32_t nof_prb, uint32_t N_sl_id, srs
q->crc_temp = srslte_vec_u8_malloc(SRSLTE_SL_BCH_CRC_LEN); q->crc_temp = srslte_vec_u8_malloc(SRSLTE_SL_BCH_CRC_LEN);
if (!q->crc_temp) { if (!q->crc_temp) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -99,84 +99,84 @@ int srslte_psbch_init(srslte_psbch_t* q, uint32_t nof_prb, uint32_t N_sl_id, srs
q->e = srslte_vec_u8_malloc(q->E); q->e = srslte_vec_u8_malloc(q->E);
if (!q->e) { if (!q->e) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->e_16 = srslte_vec_i16_malloc(q->E); q->e_16 = srslte_vec_i16_malloc(q->E);
if (!q->e_16) { if (!q->e_16) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->e_bytes = srslte_vec_u8_malloc(q->E / 8); q->e_bytes = srslte_vec_u8_malloc(q->E / 8);
if (!q->e_bytes) { if (!q->e_bytes) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Scrambling // Scrambling
bzero(&q->seq, sizeof(srslte_sequence_t)); bzero(&q->seq, sizeof(srslte_sequence_t));
if (srslte_sequence_LTE_pr(&q->seq, q->E, N_sl_id) != SRSLTE_SUCCESS) { if (srslte_sequence_LTE_pr(&q->seq, q->E, N_sl_id) != SRSLTE_SUCCESS) {
ERROR("Error srslte_sequence_LTE_pr\n"); ERROR("Error srslte_sequence_LTE_pr");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->codeword = srslte_vec_u8_malloc(q->E); q->codeword = srslte_vec_u8_malloc(q->E);
if (!q->codeword) { if (!q->codeword) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->codeword_bytes = srslte_vec_u8_malloc(q->E / 8); q->codeword_bytes = srslte_vec_u8_malloc(q->E / 8);
if (!q->codeword_bytes) { if (!q->codeword_bytes) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Interleaving // Interleaving
q->interleaver_lut = srslte_vec_u32_malloc(q->E); q->interleaver_lut = srslte_vec_u32_malloc(q->E);
if (!q->interleaver_lut) { if (!q->interleaver_lut) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Modulation QPSK // Modulation QPSK
if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_QPSK) != SRSLTE_SUCCESS) { if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_QPSK) != SRSLTE_SUCCESS) {
ERROR("Error srslte_modem_table_lte\n"); ERROR("Error srslte_modem_table_lte");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->mod_symbols = srslte_vec_cf_malloc(q->nof_data_re); q->mod_symbols = srslte_vec_cf_malloc(q->nof_data_re);
if (!q->mod_symbols) { if (!q->mod_symbols) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Soft-demod // Soft-demod
q->llr = srslte_vec_i16_malloc(q->E); q->llr = srslte_vec_i16_malloc(q->E);
if (!q->llr) { if (!q->llr) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Transform precoding // Transform precoding
q->precoding_scaling = 1.0f; q->precoding_scaling = 1.0f;
if (srslte_dft_precoding_init_tx(&q->dft_precoder, SRSLTE_PSBCH_NOF_PRB) != SRSLTE_SUCCESS) { if (srslte_dft_precoding_init_tx(&q->dft_precoder, SRSLTE_PSBCH_NOF_PRB) != SRSLTE_SUCCESS) {
ERROR("Error srslte_dft_precoding_init\n"); ERROR("Error srslte_dft_precoding_init");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->scfdma_symbols = srslte_vec_cf_malloc(q->nof_data_re); q->scfdma_symbols = srslte_vec_cf_malloc(q->nof_data_re);
if (!q->scfdma_symbols) { if (!q->scfdma_symbols) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
///< Make sure last bits are zero as they are not considered during unpack ///< Make sure last bits are zero as they are not considered during unpack
srslte_vec_cf_zero(q->scfdma_symbols, q->nof_data_re); srslte_vec_cf_zero(q->scfdma_symbols, q->nof_data_re);
if (srslte_dft_precoding_init_rx(&q->idft_precoder, SRSLTE_PSBCH_NOF_PRB) != SRSLTE_SUCCESS) { if (srslte_dft_precoding_init_rx(&q->idft_precoder, SRSLTE_PSBCH_NOF_PRB) != SRSLTE_SUCCESS) {
ERROR("Error srslte_idft_precoding_init\n"); ERROR("Error srslte_idft_precoding_init");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -186,7 +186,7 @@ int srslte_psbch_init(srslte_psbch_t* q, uint32_t nof_prb, uint32_t N_sl_id, srs
int srslte_psbch_encode(srslte_psbch_t* q, uint8_t* input, uint32_t input_len, cf_t* sf_buffer) int srslte_psbch_encode(srslte_psbch_t* q, uint8_t* input, uint32_t input_len, cf_t* sf_buffer)
{ {
if (input == NULL || input_len > q->sl_bch_tb_len) { if (input == NULL || input_len > q->sl_bch_tb_len) {
ERROR("Can't encode PSBCH, input too long (%d > %d)\n", input_len, q->sl_bch_tb_len); ERROR("Can't encode PSBCH, input too long (%d > %d)", input_len, q->sl_bch_tb_len);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
@ -238,13 +238,13 @@ int srslte_psbch_encode(srslte_psbch_t* q, uint8_t* input, uint32_t input_len, c
int srslte_psbch_decode(srslte_psbch_t* q, cf_t* equalized_sf_syms, uint8_t* output, uint32_t max_output_len) int srslte_psbch_decode(srslte_psbch_t* q, cf_t* equalized_sf_syms, uint8_t* output, uint32_t max_output_len)
{ {
if (max_output_len < q->sl_bch_tb_len) { if (max_output_len < q->sl_bch_tb_len) {
ERROR("Can't decode PSBCH, provided buffer too small (%d < %d)\n", max_output_len, q->sl_bch_tb_len); ERROR("Can't decode PSBCH, provided buffer too small (%d < %d)", max_output_len, q->sl_bch_tb_len);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// RE extraction // RE extraction
if (q->nof_tx_re != srslte_psbch_get(q, equalized_sf_syms, q->scfdma_symbols)) { if (q->nof_tx_re != srslte_psbch_get(q, equalized_sf_syms, q->scfdma_symbols)) {
ERROR("There was an error getting the PSBCH symbols\n"); ERROR("There was an error getting the PSBCH symbols");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -300,7 +300,7 @@ int srslte_psbch_reset(srslte_psbch_t* q, uint32_t N_sl_id)
// Regen scrambling sequence // Regen scrambling sequence
if (srslte_sequence_LTE_pr(&q->seq, q->E, N_sl_id) != SRSLTE_SUCCESS) { if (srslte_sequence_LTE_pr(&q->seq, q->E, N_sl_id) != SRSLTE_SUCCESS) {
ERROR("Error srslte_sequence_LTE_pr\n"); ERROR("Error srslte_sequence_LTE_pr");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }

@ -40,12 +40,12 @@ int srslte_pscch_init(srslte_pscch_t* q, uint32_t max_prb)
} }
q->c = srslte_vec_u8_malloc(SRSLTE_SCI_MAX_LEN + SRSLTE_SCI_CRC_LEN); q->c = srslte_vec_u8_malloc(SRSLTE_SCI_MAX_LEN + SRSLTE_SCI_CRC_LEN);
if (!q->c) { if (!q->c) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->sci_crc = srslte_vec_u8_malloc(SRSLTE_SCI_CRC_LEN); q->sci_crc = srslte_vec_u8_malloc(SRSLTE_SCI_CRC_LEN);
if (!q->sci_crc) { if (!q->sci_crc) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -60,50 +60,50 @@ int srslte_pscch_init(srslte_pscch_t* q, uint32_t max_prb)
memcpy(q->encoder.poly, poly, 3 * sizeof(int)); memcpy(q->encoder.poly, poly, 3 * sizeof(int));
q->d = srslte_vec_u8_malloc(E_max); q->d = srslte_vec_u8_malloc(E_max);
if (!q->d) { if (!q->d) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
srslte_vec_u8_zero(q->d, E_max); srslte_vec_u8_zero(q->d, E_max);
q->d_16 = srslte_vec_i16_malloc(E_max); q->d_16 = srslte_vec_i16_malloc(E_max);
if (!q->d_16) { if (!q->d_16) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
srslte_viterbi_init( srslte_viterbi_init(
&q->dec, SRSLTE_VITERBI_37, q->encoder.poly, SRSLTE_SCI_MAX_LEN + SRSLTE_SCI_CRC_LEN, q->encoder.tail_biting); &q->dec, SRSLTE_VITERBI_37, q->encoder.poly, SRSLTE_SCI_MAX_LEN + SRSLTE_SCI_CRC_LEN, q->encoder.tail_biting);
q->e = srslte_vec_u8_malloc(E_max); q->e = srslte_vec_u8_malloc(E_max);
if (!q->e) { if (!q->e) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->e_16 = srslte_vec_i16_malloc(E_max); q->e_16 = srslte_vec_i16_malloc(E_max);
if (!q->e_16) { if (!q->e_16) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->e_bytes = srslte_vec_u8_malloc(E_max / 8); q->e_bytes = srslte_vec_u8_malloc(E_max / 8);
if (!q->e_bytes) { if (!q->e_bytes) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->interleaver_lut = srslte_vec_u32_malloc(E_max); q->interleaver_lut = srslte_vec_u32_malloc(E_max);
if (!q->interleaver_lut) { if (!q->interleaver_lut) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->codeword = srslte_vec_u8_malloc(E_max); q->codeword = srslte_vec_u8_malloc(E_max);
if (!q->codeword) { if (!q->codeword) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->codeword_bytes = srslte_vec_u8_malloc(E_max / 8); q->codeword_bytes = srslte_vec_u8_malloc(E_max / 8);
if (!q->codeword_bytes) { if (!q->codeword_bytes) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -118,14 +118,14 @@ int srslte_pscch_init(srslte_pscch_t* q, uint32_t max_prb)
q->mod_symbols = srslte_vec_cf_malloc(E_max / SRSLTE_PSCCH_QM); q->mod_symbols = srslte_vec_cf_malloc(E_max / SRSLTE_PSCCH_QM);
if (!q->mod_symbols) { if (!q->mod_symbols) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
srslte_vec_cf_zero(q->mod_symbols, E_max / SRSLTE_PSCCH_QM); srslte_vec_cf_zero(q->mod_symbols, E_max / SRSLTE_PSCCH_QM);
q->llr = srslte_vec_i16_malloc(E_max); q->llr = srslte_vec_i16_malloc(E_max);
if (!q->llr) { if (!q->llr) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -135,7 +135,7 @@ int srslte_pscch_init(srslte_pscch_t* q, uint32_t max_prb)
} }
q->scfdma_symbols = srslte_vec_cf_malloc(E_max / SRSLTE_PSCCH_QM); q->scfdma_symbols = srslte_vec_cf_malloc(E_max / SRSLTE_PSCCH_QM);
if (!q->scfdma_symbols) { if (!q->scfdma_symbols) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
srslte_vec_cf_zero(q->scfdma_symbols, E_max / SRSLTE_PSCCH_QM); srslte_vec_cf_zero(q->scfdma_symbols, E_max / SRSLTE_PSCCH_QM);

@ -40,57 +40,57 @@ int srslte_pssch_init(srslte_pssch_t* q, srslte_cell_sl_t cell, srslte_sl_comm_r
if (cell.cp == SRSLTE_CP_NORM) { if (cell.cp == SRSLTE_CP_NORM) {
q->nof_data_symbols = SRSLTE_PSSCH_TM34_NUM_DATA_SYMBOLS; q->nof_data_symbols = SRSLTE_PSSCH_TM34_NUM_DATA_SYMBOLS;
} else { } else {
ERROR("Invalid CP for PSSCH, SL TM 3/4\n"); ERROR("Invalid CP for PSSCH, SL TM 3/4");
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
} else { } else {
ERROR("Invalid SL TM\n"); ERROR("Invalid SL TM");
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
// Transport Block // Transport Block
q->b = srslte_vec_u8_malloc(SRSLTE_SL_SCH_MAX_TB_LEN + SRSLTE_PSSCH_CRC_LEN); q->b = srslte_vec_u8_malloc(SRSLTE_SL_SCH_MAX_TB_LEN + SRSLTE_PSSCH_CRC_LEN);
if (!q->b) { if (!q->b) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Transport Block CRC // Transport Block CRC
if (srslte_crc_init(&q->tb_crc, SRSLTE_LTE_CRC24A, SRSLTE_PSSCH_CRC_LEN)) { if (srslte_crc_init(&q->tb_crc, SRSLTE_LTE_CRC24A, SRSLTE_PSSCH_CRC_LEN)) {
ERROR("Error Transport Block CRC init\n"); ERROR("Error Transport Block CRC init");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->tb_crc_temp = srslte_vec_u8_malloc(SRSLTE_PSSCH_CRC_LEN); q->tb_crc_temp = srslte_vec_u8_malloc(SRSLTE_PSSCH_CRC_LEN);
if (!q->tb_crc_temp) { if (!q->tb_crc_temp) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Code Block Segmentation // Code Block Segmentation
q->c_r = srslte_vec_u8_malloc(SRSLTE_TCOD_MAX_LEN_CB); q->c_r = srslte_vec_u8_malloc(SRSLTE_TCOD_MAX_LEN_CB);
if (!q->c_r) { if (!q->c_r) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->f_16 = srslte_vec_i16_malloc(SRSLTE_MAX_CODEWORD_LEN); q->f_16 = srslte_vec_i16_malloc(SRSLTE_MAX_CODEWORD_LEN);
if (!q->f_16) { if (!q->f_16) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->c_r_bytes = srslte_vec_u8_malloc(SRSLTE_TCOD_MAX_LEN_CB / 8); q->c_r_bytes = srslte_vec_u8_malloc(SRSLTE_TCOD_MAX_LEN_CB / 8);
if (!q->c_r_bytes) { if (!q->c_r_bytes) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Code Block CRC // Code Block CRC
if (srslte_crc_init(&q->cb_crc, SRSLTE_LTE_CRC24B, SRSLTE_PSSCH_CRC_LEN)) { if (srslte_crc_init(&q->cb_crc, SRSLTE_LTE_CRC24B, SRSLTE_PSSCH_CRC_LEN)) {
ERROR("Error Code Block CRC init\n"); ERROR("Error Code Block CRC init");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->cb_crc_temp = srslte_vec_u8_malloc(SRSLTE_PSSCH_CRC_LEN); q->cb_crc_temp = srslte_vec_u8_malloc(SRSLTE_PSSCH_CRC_LEN);
if (!q->cb_crc_temp) { if (!q->cb_crc_temp) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -98,32 +98,32 @@ int srslte_pssch_init(srslte_pssch_t* q, srslte_cell_sl_t cell, srslte_sl_comm_r
srslte_tcod_init(&q->tcod, SRSLTE_TCOD_MAX_LEN_CB); srslte_tcod_init(&q->tcod, SRSLTE_TCOD_MAX_LEN_CB);
q->d_r = srslte_vec_u8_malloc(SRSLTE_PSSCH_MAX_CODED_BITS); q->d_r = srslte_vec_u8_malloc(SRSLTE_PSSCH_MAX_CODED_BITS);
if (!q->d_r) { if (!q->d_r) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
srslte_tdec_init(&q->tdec, SRSLTE_TCOD_MAX_LEN_CB); srslte_tdec_init(&q->tdec, SRSLTE_TCOD_MAX_LEN_CB);
srslte_tdec_force_not_sb(&q->tdec); srslte_tdec_force_not_sb(&q->tdec);
q->d_r_16 = srslte_vec_i16_malloc(SRSLTE_PSSCH_MAX_CODED_BITS); q->d_r_16 = srslte_vec_i16_malloc(SRSLTE_PSSCH_MAX_CODED_BITS);
if (!q->d_r_16) { if (!q->d_r_16) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Rate Matching // Rate Matching
q->e_r = srslte_vec_u8_malloc(SRSLTE_MAX_CODEWORD_LEN); q->e_r = srslte_vec_u8_malloc(SRSLTE_MAX_CODEWORD_LEN);
if (!q->e_r) { if (!q->e_r) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->buff_b = srslte_vec_u8_malloc(SRSLTE_PSSCH_MAX_CODED_BITS); q->buff_b = srslte_vec_u8_malloc(SRSLTE_PSSCH_MAX_CODED_BITS);
if (!q->buff_b) { if (!q->buff_b) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
srslte_vec_u8_zero(q->buff_b, SRSLTE_PSSCH_MAX_CODED_BITS); srslte_vec_u8_zero(q->buff_b, SRSLTE_PSSCH_MAX_CODED_BITS);
q->e_r_16 = srslte_vec_i16_malloc(SRSLTE_MAX_CODEWORD_LEN); q->e_r_16 = srslte_vec_i16_malloc(SRSLTE_MAX_CODEWORD_LEN);
if (!q->e_r_16) { if (!q->e_r_16) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
srslte_rm_turbo_gentables(); srslte_rm_turbo_gentables();
@ -131,19 +131,19 @@ int srslte_pssch_init(srslte_pssch_t* q, srslte_cell_sl_t cell, srslte_sl_comm_r
// Code Block Concatenation // Code Block Concatenation
q->f = srslte_vec_u8_malloc(SRSLTE_MAX_CODEWORD_LEN); q->f = srslte_vec_u8_malloc(SRSLTE_MAX_CODEWORD_LEN);
if (!q->f) { if (!q->f) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Interleaving // Interleaving
q->f_bytes = srslte_vec_u8_malloc(SRSLTE_MAX_CODEWORD_LEN / 8); q->f_bytes = srslte_vec_u8_malloc(SRSLTE_MAX_CODEWORD_LEN / 8);
if (!q->f_bytes) { if (!q->f_bytes) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->interleaver_lut = srslte_vec_u32_malloc(SRSLTE_MAX_CODEWORD_LEN); q->interleaver_lut = srslte_vec_u32_malloc(SRSLTE_MAX_CODEWORD_LEN);
if (!q->interleaver_lut) { if (!q->interleaver_lut) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
srslte_vec_u32_zero(q->interleaver_lut, SRSLTE_MAX_CODEWORD_LEN); srslte_vec_u32_zero(q->interleaver_lut, SRSLTE_MAX_CODEWORD_LEN);
@ -151,37 +151,37 @@ int srslte_pssch_init(srslte_pssch_t* q, srslte_cell_sl_t cell, srslte_sl_comm_r
// Scrambling // Scrambling
q->codeword = srslte_vec_u8_malloc(SRSLTE_MAX_CODEWORD_LEN); q->codeword = srslte_vec_u8_malloc(SRSLTE_MAX_CODEWORD_LEN);
if (!q->codeword) { if (!q->codeword) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->codeword_bytes = srslte_vec_u8_malloc(SRSLTE_MAX_CODEWORD_LEN / 8); q->codeword_bytes = srslte_vec_u8_malloc(SRSLTE_MAX_CODEWORD_LEN / 8);
if (!q->codeword_bytes) { if (!q->codeword_bytes) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Modulation // Modulation
q->symbols = srslte_vec_cf_malloc(SRSLTE_MAX_CODEWORD_LEN); q->symbols = srslte_vec_cf_malloc(SRSLTE_MAX_CODEWORD_LEN);
if (!q->symbols) { if (!q->symbols) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
srslte_vec_cf_zero(q->symbols, SRSLTE_MAX_CODEWORD_LEN); srslte_vec_cf_zero(q->symbols, SRSLTE_MAX_CODEWORD_LEN);
q->bits_after_demod = srslte_vec_u8_malloc(SRSLTE_MAX_CODEWORD_LEN); q->bits_after_demod = srslte_vec_u8_malloc(SRSLTE_MAX_CODEWORD_LEN);
if (!q->bits_after_demod) { if (!q->bits_after_demod) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->bytes_after_demod = srslte_vec_u8_malloc(SRSLTE_MAX_CODEWORD_LEN / 8); q->bytes_after_demod = srslte_vec_u8_malloc(SRSLTE_MAX_CODEWORD_LEN / 8);
if (!q->bytes_after_demod) { if (!q->bytes_after_demod) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
for (int i = 0; i < SRSLTE_MOD_NITEMS; i++) { for (int i = 0; i < SRSLTE_MOD_NITEMS; i++) {
if (srslte_modem_table_lte(&q->mod[i], (srslte_mod_t)i)) { if (srslte_modem_table_lte(&q->mod[i], (srslte_mod_t)i)) {
ERROR("Error initiating modem tables\n"); ERROR("Error initiating modem tables");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -189,22 +189,22 @@ int srslte_pssch_init(srslte_pssch_t* q, srslte_cell_sl_t cell, srslte_sl_comm_r
// Demodulation // Demodulation
q->llr = srslte_vec_i16_malloc(SRSLTE_MAX_CODEWORD_LEN); q->llr = srslte_vec_i16_malloc(SRSLTE_MAX_CODEWORD_LEN);
if (!q->llr) { if (!q->llr) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Transform Precoding // Transform Precoding
q->scfdma_symbols = srslte_vec_cf_malloc(q->nof_data_symbols * SRSLTE_NRE * SRSLTE_MAX_PRB); q->scfdma_symbols = srslte_vec_cf_malloc(q->nof_data_symbols * SRSLTE_NRE * SRSLTE_MAX_PRB);
if (!q->scfdma_symbols) { if (!q->scfdma_symbols) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_dft_precoding_init(&q->dft_precoder, SRSLTE_MAX_PRB, true)) { if (srslte_dft_precoding_init(&q->dft_precoder, SRSLTE_MAX_PRB, true)) {
ERROR("Error DFT precoder init\n"); ERROR("Error DFT precoder init");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_dft_precoding_init(&q->idft_precoder, SRSLTE_MAX_PRB, false)) { if (srslte_dft_precoding_init(&q->idft_precoder, SRSLTE_MAX_PRB, false)) {
ERROR("Error in DFT precoder init\n"); ERROR("Error in DFT precoder init");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -250,7 +250,7 @@ int srslte_pssch_set_cfg(srslte_pssch_t* q, srslte_pssch_cfg_t pssch_cfg)
int srslte_pssch_encode(srslte_pssch_t* q, uint8_t* input, uint32_t input_len, cf_t* sf_buffer) int srslte_pssch_encode(srslte_pssch_t* q, uint8_t* input, uint32_t input_len, cf_t* sf_buffer)
{ {
if (!input || input_len > q->sl_sch_tb_len) { if (!input || input_len > q->sl_sch_tb_len) {
ERROR("Can't encode PSSCH, input too long (%d > %d)\n", input_len, q->sl_sch_tb_len); ERROR("Can't encode PSSCH, input too long (%d > %d)", input_len, q->sl_sch_tb_len);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -274,7 +274,6 @@ int srslte_pssch_encode(srslte_pssch_t* q, uint8_t* input, uint32_t input_len, c
srslte_crc_attach(&q->tb_crc, q->b, q->sl_sch_tb_len); srslte_crc_attach(&q->tb_crc, q->b, q->sl_sch_tb_len);
for (int r = 0; r < q->cb_segm.C; r++) { for (int r = 0; r < q->cb_segm.C; r++) {
// Code block segmentation // Code block segmentation
if (r < q->cb_segm.C2) { if (r < q->cb_segm.C2) {
K_r = q->cb_segm.K2; K_r = q->cb_segm.K2;
@ -356,7 +355,7 @@ int srslte_pssch_encode(srslte_pssch_t* q, uint8_t* input, uint32_t input_len, c
// RE mapping // RE mapping
if (q->nof_tx_re != srslte_pssch_put(q, sf_buffer, q->scfdma_symbols)) { if (q->nof_tx_re != srslte_pssch_put(q, sf_buffer, q->scfdma_symbols)) {
ERROR("There was an error mapping the PSSCH symbols\n"); ERROR("There was an error mapping the PSSCH symbols");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -366,13 +365,13 @@ int srslte_pssch_encode(srslte_pssch_t* q, uint8_t* input, uint32_t input_len, c
int srslte_pssch_decode(srslte_pssch_t* q, cf_t* equalized_sf_syms, uint8_t* output, uint32_t output_len) int srslte_pssch_decode(srslte_pssch_t* q, cf_t* equalized_sf_syms, uint8_t* output, uint32_t output_len)
{ {
if (output_len < q->sl_sch_tb_len) { if (output_len < q->sl_sch_tb_len) {
ERROR("Can't decode PSSCH, provided buffer too small (%d < %d)\n", output_len, q->sl_sch_tb_len); ERROR("Can't decode PSSCH, provided buffer too small (%d < %d)", output_len, q->sl_sch_tb_len);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// RE extraction // RE extraction
if (q->nof_tx_re != srslte_pssch_get(q, equalized_sf_syms, q->scfdma_symbols)) { if (q->nof_tx_re != srslte_pssch_get(q, equalized_sf_syms, q->scfdma_symbols)) {
ERROR("There was an error getting the PSSCH symbols\n"); ERROR("There was an error getting the PSSCH symbols");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -443,7 +442,6 @@ int srslte_pssch_decode(srslte_pssch_t* q, cf_t* equalized_sf_syms, uint8_t* out
srslte_bit_unpack_vector(q->c_r_bytes, q->c_r, K_r); srslte_bit_unpack_vector(q->c_r_bytes, q->c_r, K_r);
if (q->cb_segm.C > 1) { if (q->cb_segm.C > 1) {
// Copy received crc to temp // Copy received crc to temp
memcpy(q->cb_crc_temp, &q->c_r[(K_r - L)], sizeof(uint8_t) * L); memcpy(q->cb_crc_temp, &q->c_r[(K_r - L)], sizeof(uint8_t) * L);
@ -489,7 +487,6 @@ int srslte_pssch_put(srslte_pssch_t* q, cf_t* sf_buffer, cf_t* symbols)
uint32_t k = q->pssch_cfg.prb_start_idx * SRSLTE_NRE; uint32_t k = q->pssch_cfg.prb_start_idx * SRSLTE_NRE;
for (int i = 0; i < srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { for (int i = 0; i < srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) {
if (srslte_pssch_is_symbol(SRSLTE_SIDELINK_DATA_SYMBOL, q->cell.tm, i, q->cell.cp)) { if (srslte_pssch_is_symbol(SRSLTE_SIDELINK_DATA_SYMBOL, q->cell.tm, i, q->cell.cp)) {
if (q->cell.tm == SRSLTE_SIDELINK_TM1 || q->cell.tm == SRSLTE_SIDELINK_TM2) { if (q->cell.tm == SRSLTE_SIDELINK_TM1 || q->cell.tm == SRSLTE_SIDELINK_TM2) {
if (q->pssch_cfg.nof_prb <= q->sl_comm_resource_pool.prb_num) { if (q->pssch_cfg.nof_prb <= q->sl_comm_resource_pool.prb_num) {
k = q->pssch_cfg.prb_start_idx * SRSLTE_NRE; k = q->pssch_cfg.prb_start_idx * SRSLTE_NRE;

@ -121,7 +121,6 @@ int srslte_pucch_set_cell(srslte_pucch_t* q, srslte_cell_t cell)
{ {
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL && srslte_cell_isvalid(&cell)) { if (q != NULL && srslte_cell_isvalid(&cell)) {
if (cell.id != q->cell.id || q->cell.nof_prb == 0) { if (cell.id != q->cell.id || q->cell.nof_prb == 0) {
q->cell = cell; q->cell = cell;
@ -163,7 +162,7 @@ int srslte_pucch_set_rnti(srslte_pucch_t* q, uint16_t rnti)
// If the sequence is not allocated generate // If the sequence is not allocated generate
q->users[rnti_idx] = calloc(1, sizeof(srslte_pdsch_user_t)); q->users[rnti_idx] = calloc(1, sizeof(srslte_pdsch_user_t));
if (!q->users[rnti_idx]) { if (!q->users[rnti_idx]) {
ERROR("Alocating PDSCH user\n"); ERROR("Alocating PDSCH user");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} else if (q->users[rnti_idx]->sequence_generated && q->users[rnti_idx]->cell_id == q->cell.id && !q->is_ue) { } else if (q->users[rnti_idx]->sequence_generated && q->users[rnti_idx]->cell_id == q->cell.id && !q->is_ue) {
@ -178,7 +177,7 @@ int srslte_pucch_set_rnti(srslte_pucch_t* q, uint16_t rnti)
for (int sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME; sf_idx++) { for (int sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME; sf_idx++) {
if (srslte_sequence_pucch( if (srslte_sequence_pucch(
&q->users[rnti_idx]->seq_f2[sf_idx], rnti, SRSLTE_NOF_SLOTS_PER_SF * sf_idx, q->cell.id)) { &q->users[rnti_idx]->seq_f2[sf_idx], rnti, SRSLTE_NOF_SLOTS_PER_SF * sf_idx, q->cell.id)) {
ERROR("Error initializing PUCCH scrambling sequence\n"); ERROR("Error initializing PUCCH scrambling sequence");
srslte_pucch_free_rnti(q, rnti); srslte_pucch_free_rnti(q, rnti);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -230,13 +229,13 @@ static srslte_sequence_t* get_user_sequence(srslte_pucch_t* q, uint16_t rnti, ui
return &q->users[rnti_idx]->seq_f2[sf_idx]; return &q->users[rnti_idx]->seq_f2[sf_idx];
} else { } else {
if (srslte_sequence_pucch(&q->tmp_seq, rnti, 2 * sf_idx, q->cell.id)) { if (srslte_sequence_pucch(&q->tmp_seq, rnti, 2 * sf_idx, q->cell.id)) {
ERROR("Error computing PUCCH Format 2 scrambling sequence\n"); ERROR("Error computing PUCCH Format 2 scrambling sequence");
return NULL; return NULL;
} }
return &q->tmp_seq; return &q->tmp_seq;
} }
} else { } else {
ERROR("Invalid RNTI=0x%x\n", rnti); ERROR("Invalid RNTI=0x%x", rnti);
return NULL; return NULL;
} }
} }
@ -268,7 +267,7 @@ uci_mod_bits(srslte_pucch_t* q, srslte_ul_sf_cfg_t* sf, srslte_pucch_cfg_t* cfg,
srslte_scrambling_b_offset(seq, q->bits_scram, 0, SRSLTE_PUCCH2_NOF_BITS); srslte_scrambling_b_offset(seq, q->bits_scram, 0, SRSLTE_PUCCH2_NOF_BITS);
srslte_mod_modulate(&q->mod, q->bits_scram, q->d, SRSLTE_PUCCH2_NOF_BITS); srslte_mod_modulate(&q->mod, q->bits_scram, q->d, SRSLTE_PUCCH2_NOF_BITS);
} else { } else {
ERROR("Error modulating PUCCH2 bits: could not generate sequence\n"); ERROR("Error modulating PUCCH2 bits: could not generate sequence");
return -1; return -1;
} }
break; break;
@ -279,12 +278,12 @@ uci_mod_bits(srslte_pucch_t* q, srslte_ul_sf_cfg_t* sf, srslte_pucch_cfg_t* cfg,
srslte_scrambling_b_offset(seq, q->bits_scram, 0, SRSLTE_PUCCH3_NOF_BITS); srslte_scrambling_b_offset(seq, q->bits_scram, 0, SRSLTE_PUCCH3_NOF_BITS);
srslte_mod_modulate(&q->mod, q->bits_scram, q->d, SRSLTE_PUCCH3_NOF_BITS); srslte_mod_modulate(&q->mod, q->bits_scram, q->d, SRSLTE_PUCCH3_NOF_BITS);
} else { } else {
ERROR("Error modulating PUCCH3 bits: rnti not set\n"); ERROR("Error modulating PUCCH3 bits: rnti not set");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
break; break;
default: default:
ERROR("PUCCH format %s not supported\n", srslte_pucch_format_text(cfg->format)); ERROR("PUCCH format %s not supported", srslte_pucch_format_text(cfg->format));
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
@ -440,7 +439,7 @@ static int pucch_cp(srslte_pucch_t* q,
n_re += SRSLTE_NRE; n_re += SRSLTE_NRE;
} }
} else { } else {
ERROR("Invalid PUCCH n_prb=%d\n", n_prb); ERROR("Invalid PUCCH n_prb=%d", n_prb);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -468,7 +467,7 @@ static int encode_signal_format12(srslte_pucch_t* q,
{ {
if (!signal_only) { if (!signal_only) {
if (uci_mod_bits(q, sf, cfg, bits)) { if (uci_mod_bits(q, sf, cfg, bits)) {
ERROR("Error encoding PUCCH bits\n"); ERROR("Error encoding PUCCH bits");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} else { } else {
@ -481,7 +480,7 @@ static int encode_signal_format12(srslte_pucch_t* q,
uint32_t sf_idx = sf->tti % SRSLTE_NOF_SF_X_FRAME; uint32_t sf_idx = sf->tti % SRSLTE_NOF_SF_X_FRAME;
for (uint32_t ns = SRSLTE_NOF_SLOTS_PER_SF * sf_idx; ns < SRSLTE_NOF_SLOTS_PER_SF * (sf_idx + 1); ns++) { for (uint32_t ns = SRSLTE_NOF_SLOTS_PER_SF * sf_idx; ns < SRSLTE_NOF_SLOTS_PER_SF * (sf_idx + 1); ns++) {
uint32_t N_sf = get_N_sf(cfg->format, ns % 2, sf->shortened); uint32_t N_sf = get_N_sf(cfg->format, ns % 2, sf->shortened);
DEBUG("ns=%d, N_sf=%d\n", ns, N_sf); DEBUG("ns=%d, N_sf=%d", ns, N_sf);
// Get group hopping number u // Get group hopping number u
uint32_t f_gh = 0; uint32_t f_gh = 0;
if (cfg->group_hopping_en) { if (cfg->group_hopping_en) {
@ -505,11 +504,11 @@ static int encode_signal_format12(srslte_pucch_t* q,
uint32_t n_prime_ns = 0; uint32_t n_prime_ns = 0;
uint32_t n_oc = 0; uint32_t n_oc = 0;
float alpha = srslte_pucch_alpha_format1(q->n_cs_cell, cfg, q->cell.cp, true, ns, l, &n_oc, &n_prime_ns); float alpha = srslte_pucch_alpha_format1(q->n_cs_cell, cfg, q->cell.cp, true, ns, l, &n_oc, &n_prime_ns);
float S_ns = 0; float S_ns = 0;
if (n_prime_ns % 2) { if (n_prime_ns % 2) {
S_ns = M_PI / 2; S_ns = M_PI / 2;
} }
DEBUG("PUCCH d_0: %.1f+%.1fi, alpha: %.1f, n_oc: %d, n_prime_ns: %d, n_rb_2=%d\n", DEBUG("PUCCH d_0: %.1f+%.1fi, alpha: %.1f, n_oc: %d, n_prime_ns: %d, n_rb_2=%d",
__real__ q->d[0], __real__ q->d[0],
__imag__ q->d[0], __imag__ q->d[0],
alpha, alpha,
@ -536,7 +535,7 @@ static int encode_signal_format3(srslte_pucch_t* q,
{ {
if (!signal_only) { if (!signal_only) {
if (uci_mod_bits(q, sf, cfg, bits)) { if (uci_mod_bits(q, sf, cfg, bits)) {
ERROR("Error encoding PUCCH bits\n"); ERROR("Error encoding PUCCH bits");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} else { } else {
@ -641,7 +640,7 @@ static int decode_signal_format3(srslte_pucch_t* q,
return (int)srslte_block_decode_i16(q->llr, SRSLTE_PUCCH3_NOF_BITS, bits, SRSLTE_UCI_MAX_ACK_SR_BITS); return (int)srslte_block_decode_i16(q->llr, SRSLTE_PUCCH3_NOF_BITS, bits, SRSLTE_UCI_MAX_ACK_SR_BITS);
} else { } else {
ERROR("Error modulating PUCCH3 bits: rnti not set\n"); ERROR("Error modulating PUCCH3 bits: rnti not set");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -680,7 +679,7 @@ static int encode_bits(srslte_pucch_cfg_t* cfg,
uint8_t buff[SRSLTE_CQI_MAX_BITS]; uint8_t buff[SRSLTE_CQI_MAX_BITS];
int uci_cqi_len = srslte_cqi_value_pack(&cfg->uci_cfg.cqi, &uci_data->cqi, buff); int uci_cqi_len = srslte_cqi_value_pack(&cfg->uci_cfg.cqi, &uci_data->cqi, buff);
if (uci_cqi_len < 0) { if (uci_cqi_len < 0) {
ERROR("Error encoding CQI\n"); ERROR("Error encoding CQI");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
srslte_uci_encode_cqi_pucch(buff, (uint32_t)uci_cqi_len, pucch_bits); srslte_uci_encode_cqi_pucch(buff, (uint32_t)uci_cqi_len, pucch_bits);
@ -727,7 +726,7 @@ static bool decode_signal(srslte_pucch_t* q,
if (corr >= cfg->threshold_format1) { if (corr >= cfg->threshold_format1) {
detected = true; detected = true;
} }
DEBUG("format1 corr=%f, nof_re=%d, th=%f\n", corr, nof_re, cfg->threshold_format1); DEBUG("format1 corr=%f, nof_re=%d, th=%f", corr, nof_re, cfg->threshold_format1);
break; break;
case SRSLTE_PUCCH_FORMAT_1A: case SRSLTE_PUCCH_FORMAT_1A:
detected = 0; detected = 0;
@ -742,7 +741,7 @@ static bool decode_signal(srslte_pucch_t* q,
if (corr_max > cfg->threshold_format1) { // check with format1 in case ack+sr because ack only is binary if (corr_max > cfg->threshold_format1) { // check with format1 in case ack+sr because ack only is binary
detected = true; detected = true;
} }
DEBUG("format1a b=%d, corr=%f, nof_re=%d\n", b, corr, nof_re); DEBUG("format1a b=%d, corr=%f, nof_re=%d", b, corr, nof_re);
} }
corr = corr_max; corr = corr_max;
pucch_bits[0] = b_max; pucch_bits[0] = b_max;
@ -763,7 +762,7 @@ static bool decode_signal(srslte_pucch_t* q,
if (corr_max > cfg->threshold_format1) { // check with format1 in case ack+sr because ack only is binary if (corr_max > cfg->threshold_format1) { // check with format1 in case ack+sr because ack only is binary
detected = true; detected = true;
} }
DEBUG("format1b b=%d, corr=%f, nof_re=%d\n", b, corr, nof_re); DEBUG("format1b b=%d, corr=%f, nof_re=%d", b, corr, nof_re);
} }
} }
corr = corr_max; corr = corr_max;
@ -794,7 +793,7 @@ static bool decode_signal(srslte_pucch_t* q,
} }
detected = true; detected = true;
} else { } else {
ERROR("Decoding PUCCH2: could not generate sequence\n"); ERROR("Decoding PUCCH2: could not generate sequence");
return -1; return -1;
} }
break; break;
@ -803,7 +802,7 @@ static bool decode_signal(srslte_pucch_t* q,
detected = corr > cfg->threshold_data_valid_format3; detected = corr > cfg->threshold_data_valid_format3;
break; break;
default: default:
ERROR("PUCCH format %d not implemented\n", cfg->format); ERROR("PUCCH format %d not implemented", cfg->format);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (correlation) { if (correlation) {
@ -869,7 +868,7 @@ int srslte_pucch_encode(srslte_pucch_t* q,
} }
if (pucch_put(q, sf, cfg, q->z, sf_symbols) < 0) { if (pucch_put(q, sf, cfg, q->z, sf_symbols) < 0) {
ERROR("Error putting PUCCH symbols\n"); ERROR("Error putting PUCCH symbols");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;
@ -892,18 +891,17 @@ int srslte_pucch_decode(srslte_pucch_t* q,
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL && cfg != NULL && channel != NULL && data != NULL) { if (q != NULL && cfg != NULL && channel != NULL && data != NULL) {
uint32_t nof_cqi_bits = srslte_cqi_size(&cfg->uci_cfg.cqi); uint32_t nof_cqi_bits = srslte_cqi_size(&cfg->uci_cfg.cqi);
uint32_t nof_uci_bits = cfg->uci_cfg.cqi.ri_len ? cfg->uci_cfg.cqi.ri_len : nof_cqi_bits; uint32_t nof_uci_bits = cfg->uci_cfg.cqi.ri_len ? cfg->uci_cfg.cqi.ri_len : nof_cqi_bits;
int nof_re = pucch_get(q, sf, cfg, sf_symbols, q->z_tmp); int nof_re = pucch_get(q, sf, cfg, sf_symbols, q->z_tmp);
if (nof_re < 0) { if (nof_re < 0) {
ERROR("Error getting PUCCH symbols\n"); ERROR("Error getting PUCCH symbols");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (pucch_get(q, sf, cfg, channel->ce, q->ce) < 0) { if (pucch_get(q, sf, cfg, channel->ce, q->ce) < 0) {
ERROR("Error getting PUCCH symbols\n"); ERROR("Error getting PUCCH symbols");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -962,7 +960,6 @@ char* srslte_pucch_format_text(srslte_pucch_format_t format)
char* ret = NULL; char* ret = NULL;
switch (format) { switch (format) {
case SRSLTE_PUCCH_FORMAT_1: case SRSLTE_PUCCH_FORMAT_1:
ret = "Format 1"; ret = "Format 1";
break; break;
@ -997,7 +994,6 @@ char* srslte_pucch_format_text_short(srslte_pucch_format_t format)
char* ret = NULL; char* ret = NULL;
switch (format) { switch (format) {
case SRSLTE_PUCCH_FORMAT_1: case SRSLTE_PUCCH_FORMAT_1:
ret = "1"; ret = "1";
break; break;
@ -1033,7 +1029,6 @@ uint32_t srslte_pucch_nof_ack_format(srslte_pucch_format_t format)
uint32_t ret = 0; uint32_t ret = 0;
switch (format) { switch (format) {
case SRSLTE_PUCCH_FORMAT_1A: case SRSLTE_PUCCH_FORMAT_1A:
case SRSLTE_PUCCH_FORMAT_2A: case SRSLTE_PUCCH_FORMAT_2A:
ret = 1; ret = 1;
@ -1159,7 +1154,6 @@ int srslte_pucch_collision(const srslte_cell_t* cell, const srslte_pucch_cfg_t*
uint32_t n_prime2 = 0; uint32_t n_prime2 = 0;
switch (cfg1->format) { switch (cfg1->format) {
case SRSLTE_PUCCH_FORMAT_1: case SRSLTE_PUCCH_FORMAT_1:
case SRSLTE_PUCCH_FORMAT_1A: case SRSLTE_PUCCH_FORMAT_1A:
case SRSLTE_PUCCH_FORMAT_1B: case SRSLTE_PUCCH_FORMAT_1B:
@ -1284,7 +1278,7 @@ float srslte_pucch_alpha_format1(const uint32_t n_cs_cell[SRSLTE_NSLO
n_cs = (n_cs_cell[ns][l] + (n_prime * cfg->delta_pucch_shift + n_oc / n_oc_div) % N_prime) % SRSLTE_NRE; n_cs = (n_cs_cell[ns][l] + (n_prime * cfg->delta_pucch_shift + n_oc / n_oc_div) % N_prime) % SRSLTE_NRE;
} }
DEBUG("n_cs=%d, N_prime=%d, delta_pucch=%d, n_prime=%d, ns=%d, l=%d, ns_cs_cell=%d\n", DEBUG("n_cs=%d, N_prime=%d, delta_pucch=%d, n_prime=%d, ns=%d, l=%d, ns_cs_cell=%d",
n_cs, n_cs,
N_prime, N_prime,
cfg->delta_pucch_shift, cfg->delta_pucch_shift,
@ -1319,7 +1313,7 @@ float srslte_pucch_alpha_format2(const uint32_t n_cs_cell[SRSLTE_NSLO
} }
uint32_t n_cs = (n_cs_cell[ns][l] + n_prime) % SRSLTE_NRE; uint32_t n_cs = (n_cs_cell[ns][l] + n_prime) % SRSLTE_NRE;
float alpha = 2 * M_PI * (n_cs) / SRSLTE_NRE; float alpha = 2 * M_PI * (n_cs) / SRSLTE_NRE;
DEBUG("n_pucch: %d, ns: %d, l: %d, n_prime: %d, n_cs: %d, alpha=%f\n", cfg->n_pucch, ns, l, n_prime, n_cs, alpha); DEBUG("n_pucch: %d, ns: %d, l: %d, n_prime: %d, n_cs: %d, alpha=%f", cfg->n_pucch, ns, l, n_prime, n_cs, alpha);
return alpha; return alpha;
} }

@ -17,23 +17,23 @@
static int pucch_nr_cfg_format0_resource_valid(const srslte_pucch_nr_resource_t* resource) static int pucch_nr_cfg_format0_resource_valid(const srslte_pucch_nr_resource_t* resource)
{ {
if (resource->format != SRSLTE_PUCCH_NR_FORMAT_0) { if (resource->format != SRSLTE_PUCCH_NR_FORMAT_0) {
ERROR("Invalid format (%d)\n", resource->format); ERROR("Invalid format (%d)", resource->format);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (resource->nof_symbols < SRSLTE_PUCCH_NR_FORMAT0_MIN_NSYMB || if (resource->nof_symbols < SRSLTE_PUCCH_NR_FORMAT0_MIN_NSYMB ||
resource->nof_symbols > SRSLTE_PUCCH_NR_FORMAT0_MAX_NSYMB) { resource->nof_symbols > SRSLTE_PUCCH_NR_FORMAT0_MAX_NSYMB) {
ERROR("Invalid number of symbols (%d)\n", resource->nof_symbols); ERROR("Invalid number of symbols (%d)", resource->nof_symbols);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (resource->initial_cyclic_shift > SRSLTE_PUCCH_NR_FORMAT0_MAX_CS) { if (resource->initial_cyclic_shift > SRSLTE_PUCCH_NR_FORMAT0_MAX_CS) {
ERROR("Invalid initial cyclic shift (%d)\n", resource->initial_cyclic_shift); ERROR("Invalid initial cyclic shift (%d)", resource->initial_cyclic_shift);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (resource->start_symbol_idx > SRSLTE_PUCCH_NR_FORMAT0_MAX_STARTSYMB) { if (resource->start_symbol_idx > SRSLTE_PUCCH_NR_FORMAT0_MAX_STARTSYMB) {
ERROR("Invalid initial start symbol idx (%d)\n", resource->start_symbol_idx); ERROR("Invalid initial start symbol idx (%d)", resource->start_symbol_idx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -43,28 +43,28 @@ static int pucch_nr_cfg_format0_resource_valid(const srslte_pucch_nr_resource_t*
static int pucch_nr_cfg_format1_resource_valid(const srslte_pucch_nr_resource_t* resource) static int pucch_nr_cfg_format1_resource_valid(const srslte_pucch_nr_resource_t* resource)
{ {
if (resource->format != SRSLTE_PUCCH_NR_FORMAT_1) { if (resource->format != SRSLTE_PUCCH_NR_FORMAT_1) {
ERROR("Invalid format (%d)\n", resource->format); ERROR("Invalid format (%d)", resource->format);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (resource->nof_symbols < SRSLTE_PUCCH_NR_FORMAT1_MIN_NSYMB || if (resource->nof_symbols < SRSLTE_PUCCH_NR_FORMAT1_MIN_NSYMB ||
resource->nof_symbols > SRSLTE_PUCCH_NR_FORMAT1_MAX_NSYMB) { resource->nof_symbols > SRSLTE_PUCCH_NR_FORMAT1_MAX_NSYMB) {
ERROR("Invalid number of symbols (%d)\n", resource->nof_symbols); ERROR("Invalid number of symbols (%d)", resource->nof_symbols);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (resource->initial_cyclic_shift > SRSLTE_PUCCH_NR_FORMAT1_MAX_CS) { if (resource->initial_cyclic_shift > SRSLTE_PUCCH_NR_FORMAT1_MAX_CS) {
ERROR("Invalid initial cyclic shift (%d)\n", resource->initial_cyclic_shift); ERROR("Invalid initial cyclic shift (%d)", resource->initial_cyclic_shift);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (resource->start_symbol_idx > SRSLTE_PUCCH_NR_FORMAT1_MAX_STARTSYMB) { if (resource->start_symbol_idx > SRSLTE_PUCCH_NR_FORMAT1_MAX_STARTSYMB) {
ERROR("Invalid initial start symbol idx (%d)\n", resource->start_symbol_idx); ERROR("Invalid initial start symbol idx (%d)", resource->start_symbol_idx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (resource->time_domain_occ > SRSLTE_PUCCH_NR_FORMAT1_MAX_TOCC) { if (resource->time_domain_occ > SRSLTE_PUCCH_NR_FORMAT1_MAX_TOCC) {
ERROR("Invalid time domain occ (%d)\n", resource->time_domain_occ); ERROR("Invalid time domain occ (%d)", resource->time_domain_occ);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -74,23 +74,23 @@ static int pucch_nr_cfg_format1_resource_valid(const srslte_pucch_nr_resource_t*
static int pucch_nr_cfg_format2_resource_valid(const srslte_pucch_nr_resource_t* resource) static int pucch_nr_cfg_format2_resource_valid(const srslte_pucch_nr_resource_t* resource)
{ {
if (resource->format != SRSLTE_PUCCH_NR_FORMAT_2) { if (resource->format != SRSLTE_PUCCH_NR_FORMAT_2) {
ERROR("Invalid format (%d)\n", resource->format); ERROR("Invalid format (%d)", resource->format);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (resource->nof_symbols < SRSLTE_PUCCH_NR_FORMAT2_MIN_NSYMB || if (resource->nof_symbols < SRSLTE_PUCCH_NR_FORMAT2_MIN_NSYMB ||
resource->nof_symbols > SRSLTE_PUCCH_NR_FORMAT2_MAX_NSYMB) { resource->nof_symbols > SRSLTE_PUCCH_NR_FORMAT2_MAX_NSYMB) {
ERROR("Invalid number of symbols (%d)\n", resource->nof_symbols); ERROR("Invalid number of symbols (%d)", resource->nof_symbols);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (resource->nof_prb < SRSLTE_PUCCH_NR_FORMAT2_MIN_NPRB || resource->nof_prb > SRSLTE_PUCCH_NR_FORMAT2_MAX_NPRB) { if (resource->nof_prb < SRSLTE_PUCCH_NR_FORMAT2_MIN_NPRB || resource->nof_prb > SRSLTE_PUCCH_NR_FORMAT2_MAX_NPRB) {
ERROR("Invalid number of prb (%d)\n", resource->nof_prb); ERROR("Invalid number of prb (%d)", resource->nof_prb);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (resource->start_symbol_idx > SRSLTE_PUCCH_NR_FORMAT2_MAX_STARTSYMB) { if (resource->start_symbol_idx > SRSLTE_PUCCH_NR_FORMAT2_MAX_STARTSYMB) {
ERROR("Invalid initial start symbol idx (%d)\n", resource->start_symbol_idx); ERROR("Invalid initial start symbol idx (%d)", resource->start_symbol_idx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -100,23 +100,23 @@ static int pucch_nr_cfg_format2_resource_valid(const srslte_pucch_nr_resource_t*
static int pucch_nr_cfg_format3_resource_valid(const srslte_pucch_nr_resource_t* resource) static int pucch_nr_cfg_format3_resource_valid(const srslte_pucch_nr_resource_t* resource)
{ {
if (resource->format != SRSLTE_PUCCH_NR_FORMAT_3) { if (resource->format != SRSLTE_PUCCH_NR_FORMAT_3) {
ERROR("Invalid format (%d)\n", resource->format); ERROR("Invalid format (%d)", resource->format);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (resource->nof_symbols < SRSLTE_PUCCH_NR_FORMAT3_MIN_NSYMB || if (resource->nof_symbols < SRSLTE_PUCCH_NR_FORMAT3_MIN_NSYMB ||
resource->nof_symbols > SRSLTE_PUCCH_NR_FORMAT3_MAX_NSYMB) { resource->nof_symbols > SRSLTE_PUCCH_NR_FORMAT3_MAX_NSYMB) {
ERROR("Invalid number of symbols (%d)\n", resource->nof_symbols); ERROR("Invalid number of symbols (%d)", resource->nof_symbols);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (resource->nof_prb < SRSLTE_PUCCH_NR_FORMAT3_MIN_NPRB || resource->nof_prb > SRSLTE_PUCCH_NR_FORMAT3_MAX_NPRB) { if (resource->nof_prb < SRSLTE_PUCCH_NR_FORMAT3_MIN_NPRB || resource->nof_prb > SRSLTE_PUCCH_NR_FORMAT3_MAX_NPRB) {
ERROR("Invalid number of prb (%d)\n", resource->nof_prb); ERROR("Invalid number of prb (%d)", resource->nof_prb);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (resource->start_symbol_idx > SRSLTE_PUCCH_NR_FORMAT3_MAX_STARTSYMB) { if (resource->start_symbol_idx > SRSLTE_PUCCH_NR_FORMAT3_MAX_STARTSYMB) {
ERROR("Invalid initial start symbol idx (%d)\n", resource->start_symbol_idx); ERROR("Invalid initial start symbol idx (%d)", resource->start_symbol_idx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -126,23 +126,23 @@ static int pucch_nr_cfg_format3_resource_valid(const srslte_pucch_nr_resource_t*
static int pucch_nr_cfg_format4_resource_valid(const srslte_pucch_nr_resource_t* resource) static int pucch_nr_cfg_format4_resource_valid(const srslte_pucch_nr_resource_t* resource)
{ {
if (resource->format != SRSLTE_PUCCH_NR_FORMAT_4) { if (resource->format != SRSLTE_PUCCH_NR_FORMAT_4) {
ERROR("Invalid format (%d)\n", resource->format); ERROR("Invalid format (%d)", resource->format);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (resource->nof_symbols < SRSLTE_PUCCH_NR_FORMAT4_MIN_NSYMB || if (resource->nof_symbols < SRSLTE_PUCCH_NR_FORMAT4_MIN_NSYMB ||
resource->nof_symbols > SRSLTE_PUCCH_NR_FORMAT4_MAX_NSYMB) { resource->nof_symbols > SRSLTE_PUCCH_NR_FORMAT4_MAX_NSYMB) {
ERROR("Invalid number of symbols (%d)\n", resource->nof_symbols); ERROR("Invalid number of symbols (%d)", resource->nof_symbols);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (resource->start_symbol_idx > SRSLTE_PUCCH_NR_FORMAT4_MAX_STARTSYMB) { if (resource->start_symbol_idx > SRSLTE_PUCCH_NR_FORMAT4_MAX_STARTSYMB) {
ERROR("Invalid initial start symbol idx (%d)\n", resource->start_symbol_idx); ERROR("Invalid initial start symbol idx (%d)", resource->start_symbol_idx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (resource->occ_lenth != 2 && resource->occ_lenth != 4) { if (resource->occ_lenth != 2 && resource->occ_lenth != 4) {
ERROR("Invalid OCC length (%d)\n", resource->occ_lenth); ERROR("Invalid OCC length (%d)", resource->occ_lenth);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -161,7 +161,7 @@ int srslte_pucch_nr_cfg_resource_valid(const srslte_pucch_nr_resource_t* resourc
} }
if (resource->intra_slot_hopping) { if (resource->intra_slot_hopping) {
ERROR("Intra-slot hopping is not implemented\n"); ERROR("Intra-slot hopping is not implemented");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -170,7 +170,7 @@ int srslte_pucch_nr_cfg_resource_valid(const srslte_pucch_nr_resource_t* resourc
} }
if (resource->max_code_rate > SRSLTE_PUCCH_NR_MAX_CODE_RATE) { if (resource->max_code_rate > SRSLTE_PUCCH_NR_MAX_CODE_RATE) {
ERROR("Invalid maximum code rate (%d)\n", resource->max_code_rate); ERROR("Invalid maximum code rate (%d)", resource->max_code_rate);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -187,7 +187,7 @@ int srslte_pucch_nr_cfg_resource_valid(const srslte_pucch_nr_resource_t* resourc
return pucch_nr_cfg_format4_resource_valid(resource); return pucch_nr_cfg_format4_resource_valid(resource);
case SRSLTE_PUCCH_NR_FORMAT_ERROR: case SRSLTE_PUCCH_NR_FORMAT_ERROR:
default: default:
ERROR("Invalid case\n"); ERROR("Invalid case");
break; break;
} }

@ -35,10 +35,10 @@ int srslte_pucch_nr_group_sequence(const srslte_carrier_nr_t* carrier,
f_ss = n_id % SRSLTE_ZC_SEQUENCE_NOF_GROUPS; f_ss = n_id % SRSLTE_ZC_SEQUENCE_NOF_GROUPS;
break; break;
case SRSLTE_PUCCH_NR_GROUP_HOPPING_ENABLE: case SRSLTE_PUCCH_NR_GROUP_HOPPING_ENABLE:
ERROR("Group hopping is not implemented\n"); ERROR("Group hopping is not implemented");
return SRSLTE_ERROR; return SRSLTE_ERROR;
case SRSLTE_PUCCH_NR_GROUP_HOPPING_DISABLE: case SRSLTE_PUCCH_NR_GROUP_HOPPING_DISABLE:
ERROR("Hopping is not implemented\n"); ERROR("Hopping is not implemented");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -125,13 +125,13 @@ int srslte_pucch_nr_init(srslte_pucch_nr_t* q, const srslte_pucch_nr_args_t* arg
// Initialise BPSK modulation table // Initialise BPSK modulation table
if (srslte_modem_table_lte(&q->bpsk, SRSLTE_MOD_BPSK) < SRSLTE_SUCCESS) { if (srslte_modem_table_lte(&q->bpsk, SRSLTE_MOD_BPSK) < SRSLTE_SUCCESS) {
ERROR("Initiating modem table\n"); ERROR("Initiating modem table");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Initialise QPSK modulation table // Initialise QPSK modulation table
if (srslte_modem_table_lte(&q->qpsk, SRSLTE_MOD_QPSK) < SRSLTE_SUCCESS) { if (srslte_modem_table_lte(&q->qpsk, SRSLTE_MOD_QPSK) < SRSLTE_SUCCESS) {
ERROR("Initiating modem table\n"); ERROR("Initiating modem table");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -145,7 +145,7 @@ int srslte_pucch_nr_init(srslte_pucch_nr_t* q, const srslte_pucch_nr_args_t* arg
} }
if (srslte_uci_nr_init(&q->uci, &args->uci) < SRSLTE_SUCCESS) { if (srslte_uci_nr_init(&q->uci, &args->uci) < SRSLTE_SUCCESS) {
ERROR("Initiating UCI encoder/decoder\n"); ERROR("Initiating UCI encoder/decoder");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -153,21 +153,21 @@ int srslte_pucch_nr_init(srslte_pucch_nr_t* q, const srslte_pucch_nr_args_t* arg
uint32_t max_encoded_bits = q->max_prb * SRSLTE_NRE * 2 * SRSLTE_NSYMB_PER_SLOT_NR; // Assumes QPSK (Qm = 2) uint32_t max_encoded_bits = q->max_prb * SRSLTE_NRE * 2 * SRSLTE_NSYMB_PER_SLOT_NR; // Assumes QPSK (Qm = 2)
q->b = srslte_vec_u8_malloc(max_encoded_bits); q->b = srslte_vec_u8_malloc(max_encoded_bits);
if (q->b == NULL) { if (q->b == NULL) {
ERROR("Malloc\n"); ERROR("Malloc");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Allocate encoded symbols d // Allocate encoded symbols d
q->d = srslte_vec_cf_malloc(max_encoded_bits / 2); q->d = srslte_vec_cf_malloc(max_encoded_bits / 2);
if (q->d == NULL) { if (q->d == NULL) {
ERROR("Malloc\n"); ERROR("Malloc");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Allocate temporal channel estimates // Allocate temporal channel estimates
q->ce = srslte_vec_cf_malloc(max_encoded_bits / 2); q->ce = srslte_vec_cf_malloc(max_encoded_bits / 2);
if (q->ce == NULL) { if (q->ce == NULL) {
ERROR("Malloc\n"); ERROR("Malloc");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -213,14 +213,14 @@ int srslte_pucch_nr_format0_encode(const srslte_pucch_nr_t* q,
} }
if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) { if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) {
ERROR("Invalid PUCCH format 0 resource\n"); ERROR("Invalid PUCCH format 0 resource");
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
uint32_t u = 0; uint32_t u = 0;
uint32_t v = 0; uint32_t v = 0;
if (srslte_pucch_nr_group_sequence(carrier, cfg, &u, &v) < SRSLTE_SUCCESS) { if (srslte_pucch_nr_group_sequence(carrier, cfg, &u, &v) < SRSLTE_SUCCESS) {
ERROR("Error getting group sequence\n"); ERROR("Error getting group sequence");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -236,7 +236,7 @@ int srslte_pucch_nr_format0_encode(const srslte_pucch_nr_t* q,
// get r_uv sequence from LUT object // get r_uv sequence from LUT object
const cf_t* r_uv = srslte_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx); const cf_t* r_uv = srslte_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx);
if (r_uv == NULL) { if (r_uv == NULL) {
ERROR("Getting r_uv sequence\n"); ERROR("Getting r_uv sequence");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -264,14 +264,14 @@ int srslte_pucch_nr_format0_measure(const srslte_pucch_nr_t* q,
} }
if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) { if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) {
ERROR("Invalid PUCCH format 0 resource\n"); ERROR("Invalid PUCCH format 0 resource");
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
uint32_t u = 0; uint32_t u = 0;
uint32_t v = 0; uint32_t v = 0;
if (srslte_pucch_nr_group_sequence(carrier, cfg, &u, &v) < SRSLTE_SUCCESS) { if (srslte_pucch_nr_group_sequence(carrier, cfg, &u, &v) < SRSLTE_SUCCESS) {
ERROR("Error getting group sequence\n"); ERROR("Error getting group sequence");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -289,7 +289,7 @@ int srslte_pucch_nr_format0_measure(const srslte_pucch_nr_t* q,
// get r_uv sequence from LUT object // get r_uv sequence from LUT object
const cf_t* r_uv = srslte_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx); const cf_t* r_uv = srslte_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx);
if (r_uv == NULL) { if (r_uv == NULL) {
ERROR("Getting r_uv sequence\n"); ERROR("Getting r_uv sequence");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -343,15 +343,15 @@ static uint32_t pucch_nr_format1_n_pucch(const srslte_pucch_nr_resource_t* resou
cf_t srslte_pucch_nr_format1_w(const srslte_pucch_nr_t* q, uint32_t n_pucch, uint32_t i, uint32_t m) cf_t srslte_pucch_nr_format1_w(const srslte_pucch_nr_t* q, uint32_t n_pucch, uint32_t i, uint32_t m)
{ {
if (n_pucch < 1 || n_pucch > SRSLTE_PUCCH_NR_FORMAT1_N_MAX) { if (n_pucch < 1 || n_pucch > SRSLTE_PUCCH_NR_FORMAT1_N_MAX) {
ERROR("Invalid n_pucch\n"); ERROR("Invalid n_pucch");
return NAN; return NAN;
} }
if (i >= SRSLTE_PUCCH_NR_FORMAT1_N_MAX) { if (i >= SRSLTE_PUCCH_NR_FORMAT1_N_MAX) {
ERROR("Invalid i\n"); ERROR("Invalid i");
return NAN; return NAN;
} }
if (m >= SRSLTE_PUCCH_NR_FORMAT1_N_MAX) { if (m >= SRSLTE_PUCCH_NR_FORMAT1_N_MAX) {
ERROR("Invalid m\n"); ERROR("Invalid m");
return NAN; return NAN;
} }
@ -375,12 +375,12 @@ int srslte_pucch_nr_format1_encode(const srslte_pucch_nr_t* q,
} }
if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) { if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) {
ERROR("Invalid PUCCH format 1 resource\n"); ERROR("Invalid PUCCH format 1 resource");
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
if (nof_bits > SRSLTE_PUCCH_NR_FORMAT1_MAX_NOF_BITS) { if (nof_bits > SRSLTE_PUCCH_NR_FORMAT1_MAX_NOF_BITS) {
ERROR("Invalid number of bits (%d)\n", nof_bits); ERROR("Invalid number of bits (%d)", nof_bits);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -396,7 +396,7 @@ int srslte_pucch_nr_format1_encode(const srslte_pucch_nr_t* q,
uint32_t u = 0; uint32_t u = 0;
uint32_t v = 0; uint32_t v = 0;
if (srslte_pucch_nr_group_sequence(carrier, cfg, &u, &v) < SRSLTE_SUCCESS) { if (srslte_pucch_nr_group_sequence(carrier, cfg, &u, &v) < SRSLTE_SUCCESS) {
ERROR("Error getting group sequence\n"); ERROR("Error getting group sequence");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -418,7 +418,7 @@ int srslte_pucch_nr_format1_encode(const srslte_pucch_nr_t* q,
// get r_uv sequence from LUT object // get r_uv sequence from LUT object
const cf_t* r_uv = srslte_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx); const cf_t* r_uv = srslte_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx);
if (r_uv == NULL) { if (r_uv == NULL) {
ERROR("Getting r_uv sequence\n"); ERROR("Getting r_uv sequence");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -453,12 +453,12 @@ int srslte_pucch_nr_format1_decode(srslte_pucch_nr_t* q,
uint32_t m_cs = 0; uint32_t m_cs = 0;
if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) { if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) {
ERROR("Invalid PUCCH format 1 resource\n"); ERROR("Invalid PUCCH format 1 resource");
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
if (nof_bits > SRSLTE_PUCCH_NR_FORMAT1_MAX_NOF_BITS) { if (nof_bits > SRSLTE_PUCCH_NR_FORMAT1_MAX_NOF_BITS) {
ERROR("Invalid number of bits (%d)\n", nof_bits); ERROR("Invalid number of bits (%d)", nof_bits);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -469,7 +469,7 @@ int srslte_pucch_nr_format1_decode(srslte_pucch_nr_t* q,
uint32_t u = 0; uint32_t u = 0;
uint32_t v = 0; uint32_t v = 0;
if (srslte_pucch_nr_group_sequence(carrier, cfg, &u, &v) < SRSLTE_SUCCESS) { if (srslte_pucch_nr_group_sequence(carrier, cfg, &u, &v) < SRSLTE_SUCCESS) {
ERROR("Error getting group sequence\n"); ERROR("Error getting group sequence");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -496,7 +496,7 @@ int srslte_pucch_nr_format1_decode(srslte_pucch_nr_t* q,
// get r_uv sequence from LUT object // get r_uv sequence from LUT object
const cf_t* r_uv = srslte_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx); const cf_t* r_uv = srslte_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx);
if (r_uv == NULL) { if (r_uv == NULL) {
ERROR("Getting r_uv sequence\n"); ERROR("Getting r_uv sequence");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Get w_i_m // Get w_i_m
@ -612,13 +612,13 @@ static int pucch_nr_format2_decode(srslte_pucch_nr_t* q,
// Equalise // Equalise
if (srslte_predecoding_single(q->d, q->ce, q->d, NULL, E, 1.0f, chest_res->noise_estimate) < SRSLTE_SUCCESS) { if (srslte_predecoding_single(q->d, q->ce, q->d, NULL, E, 1.0f, chest_res->noise_estimate) < SRSLTE_SUCCESS) {
ERROR("Error Pre-decoding\n"); ERROR("Error Pre-decoding");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Soft-demodulate // Soft-demodulate
if (srslte_demod_soft_demodulate_b(SRSLTE_MOD_QPSK, q->d, llr, E) < SRSLTE_SUCCESS) { if (srslte_demod_soft_demodulate_b(SRSLTE_MOD_QPSK, q->d, llr, E) < SRSLTE_SUCCESS) {
ERROR("Error soft-demodulate\n"); ERROR("Error soft-demodulate");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -646,7 +646,7 @@ int srslte_pucch_nr_format_2_3_4_encode(srslte_pucch_nr_t* q,
// Encode PUCCH message // Encode PUCCH message
if (srslte_uci_nr_encode_pucch(&q->uci, resource, uci_cfg, uci_value, q->b) < SRSLTE_SUCCESS) { if (srslte_uci_nr_encode_pucch(&q->uci, resource, uci_cfg, uci_value, q->b) < SRSLTE_SUCCESS) {
ERROR("Error encoding UCI\n"); ERROR("Error encoding UCI");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -656,11 +656,11 @@ int srslte_pucch_nr_format_2_3_4_encode(srslte_pucch_nr_t* q,
return pucch_nr_format2_encode(q, carrier, cfg, resource, uci_cfg, slot_symbols); return pucch_nr_format2_encode(q, carrier, cfg, resource, uci_cfg, slot_symbols);
case SRSLTE_PUCCH_NR_FORMAT_3: case SRSLTE_PUCCH_NR_FORMAT_3:
case SRSLTE_PUCCH_NR_FORMAT_4: case SRSLTE_PUCCH_NR_FORMAT_4:
ERROR("Not implemented\n"); ERROR("Not implemented");
return SRSLTE_ERROR; return SRSLTE_ERROR;
default: default:
case SRSLTE_PUCCH_NR_FORMAT_ERROR: case SRSLTE_PUCCH_NR_FORMAT_ERROR:
ERROR("Invalid format\n"); ERROR("Invalid format");
} }
return SRSLTE_ERROR; return SRSLTE_ERROR;
@ -687,22 +687,22 @@ int srslte_pucch_nr_format_2_3_4_decode(srslte_pucch_nr_t* q,
switch (resource->format) { switch (resource->format) {
case SRSLTE_PUCCH_NR_FORMAT_2: 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, carrier, cfg, resource, uci_cfg, chest_res, slot_symbols, llr) < SRSLTE_SUCCESS) {
ERROR("Demodulating PUCCH format 2\n"); ERROR("Demodulating PUCCH format 2");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
break; break;
case SRSLTE_PUCCH_NR_FORMAT_3: case SRSLTE_PUCCH_NR_FORMAT_3:
case SRSLTE_PUCCH_NR_FORMAT_4: case SRSLTE_PUCCH_NR_FORMAT_4:
ERROR("Not implemented\n"); ERROR("Not implemented");
return SRSLTE_ERROR; return SRSLTE_ERROR;
default: default:
case SRSLTE_PUCCH_NR_FORMAT_ERROR: case SRSLTE_PUCCH_NR_FORMAT_ERROR:
ERROR("Invalid format\n"); ERROR("Invalid format");
} }
// Decode PUCCH message // Decode PUCCH message
if (srslte_uci_nr_decode_pucch(&q->uci, resource, uci_cfg, llr, uci_value) < SRSLTE_SUCCESS) { if (srslte_uci_nr_decode_pucch(&q->uci, resource, uci_cfg, llr, uci_value) < SRSLTE_SUCCESS) {
ERROR("Error encoding UCI\n"); ERROR("Error encoding UCI");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }

@ -50,7 +50,7 @@ srslte_pucch_format_t srslte_pucch_proc_select_format(const srslte_cell_t*
else if (pucch_proc_tx_sr(uci_cfg, uci_value)) { else if (pucch_proc_tx_sr(uci_cfg, uci_value)) {
format = SRSLTE_PUCCH_FORMAT_1; format = SRSLTE_PUCCH_FORMAT_1;
} else { } else {
ERROR("Error selecting PUCCH format: Unsupported number of ACK bits %d\n", total_ack); ERROR("Error selecting PUCCH format: Unsupported number of ACK bits %d", total_ack);
} }
} }
// CQI data // CQI data
@ -73,7 +73,7 @@ srslte_pucch_format_t srslte_pucch_proc_select_format(const srslte_cell_t*
} }
} }
if (format == SRSLTE_PUCCH_FORMAT_ERROR) { if (format == SRSLTE_PUCCH_FORMAT_ERROR) {
ERROR("Returned Error while selecting PUCCH format\n"); ERROR("Returned Error while selecting PUCCH format");
} }
return format; return format;
@ -216,7 +216,7 @@ int srslte_pucch_cs_get_ack(const srslte_pucch_cfg_t* cfg,
break; break;
default: default:
// Unhandled case // Unhandled case
ERROR("Unexpected number of ACK (%d)\n", nof_ack); ERROR("Unexpected number of ACK (%d)", nof_ack);
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
} }
} }
@ -256,7 +256,7 @@ static uint32_t n_pucch_i_tdd(uint32_t ncce, uint32_t N_pucch_1, uint32_t nof_pr
return npucch; return npucch;
} }
} }
ERROR("Could not find Np value for ncce=%d\n", ncce); ERROR("Could not find Np value for ncce=%d", ncce);
return 0; return 0;
} }
@ -282,7 +282,7 @@ int srslte_pucch_proc_get_resources(const srslte_cell_t* cell,
uint32_t* n_pucch_i) uint32_t* n_pucch_i)
{ {
if (!cfg || !cell || !uci_cfg || !n_pucch_i) { if (!cfg || !cell || !uci_cfg || !n_pucch_i) {
ERROR("pucch_resource_selection(): Invalid parameters\n"); ERROR("pucch_resource_selection(): Invalid parameters");
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
@ -318,7 +318,7 @@ int srslte_pucch_proc_get_resources(const srslte_cell_t* cell,
} }
// Otherwise an error shall be prompt // Otherwise an error shall be prompt
ERROR("Unhandled PUCCH format mode %s\n", srslte_ack_nack_feedback_mode_string(cfg->ack_nack_feedback_mode)); ERROR("Unhandled PUCCH format mode %s", srslte_ack_nack_feedback_mode_string(cfg->ack_nack_feedback_mode));
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -421,7 +421,7 @@ static uint32_t get_npucch_cs(const srslte_pucch_cfg_t* cfg,
} }
break; break;
default: default:
ERROR("Too many (%d) ACK for this CS mode\n", srslte_uci_cfg_total_ack(uci_cfg)); ERROR("Too many (%d) ACK for this CS mode", srslte_uci_cfg_total_ack(uci_cfg));
} }
return n_pucch; return n_pucch;
@ -447,7 +447,7 @@ static void set_b01(uint8_t* b, uint8_t x)
b[1] = 1; b[1] = 1;
break; break;
default: default:
ERROR("Unhandled case (%d)\n", x); ERROR("Unhandled case (%d)", x);
} }
} }

@ -55,7 +55,7 @@ static int pusch_cp(srslte_pusch_t* q,
if (is_shortened && slot == 1) { if (is_shortened && slot == 1) {
N_srs = 1; N_srs = 1;
} }
INFO("%s PUSCH %d PRB to index %d at slot %d\n", INFO("%s PUSCH %d PRB to index %d at slot %d",
advance_input ? "Allocating" : "Getting", advance_input ? "Allocating" : "Getting",
grant->L_prb, grant->L_prb,
grant->n_prb_tilde[slot], grant->n_prb_tilde[slot],
@ -101,12 +101,11 @@ static int pusch_init(srslte_pusch_t* q, uint32_t max_prb, bool is_ue)
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL) { if (q != NULL) {
bzero(q, sizeof(srslte_pusch_t)); bzero(q, sizeof(srslte_pusch_t));
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
q->max_re = max_prb * MAX_PUSCH_RE(SRSLTE_CP_NORM); q->max_re = max_prb * MAX_PUSCH_RE(SRSLTE_CP_NORM);
INFO("Init PUSCH: %d PRBs\n", max_prb); INFO("Init PUSCH: %d PRBs", max_prb);
for (srslte_mod_t i = 0; i < SRSLTE_MOD_NITEMS; i++) { for (srslte_mod_t i = 0; i < SRSLTE_MOD_NITEMS; i++) {
if (srslte_modem_table_lte(&q->mod[i], i)) { if (srslte_modem_table_lte(&q->mod[i], i)) {
@ -130,7 +129,7 @@ static int pusch_init(srslte_pusch_t* q, uint32_t max_prb, bool is_ue)
srslte_sch_init(&q->ul_sch); srslte_sch_init(&q->ul_sch);
if (srslte_dft_precoding_init(&q->dft_precoding, max_prb, is_ue)) { if (srslte_dft_precoding_init(&q->dft_precoding, max_prb, is_ue)) {
ERROR("Error initiating DFT transform precoding\n"); ERROR("Error initiating DFT transform precoding");
goto clean; goto clean;
} }
@ -159,7 +158,7 @@ static int pusch_init(srslte_pusch_t* q, uint32_t max_prb, bool is_ue)
q->evm_buffer = srslte_evm_buffer_alloc(srslte_ra_tbs_from_idx(SRSLTE_RA_NOF_TBS_IDX - 1, 6)); q->evm_buffer = srslte_evm_buffer_alloc(srslte_ra_tbs_from_idx(SRSLTE_RA_NOF_TBS_IDX - 1, 6));
if (!q->evm_buffer) { if (!q->evm_buffer) {
ERROR("Allocating EVM buffer\n"); ERROR("Allocating EVM buffer");
goto clean; goto clean;
} }
} }
@ -237,7 +236,6 @@ int srslte_pusch_set_cell(srslte_pusch_t* q, srslte_cell_t cell)
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL && srslte_cell_isvalid(&cell)) { if (q != NULL && srslte_cell_isvalid(&cell)) {
// Resize EVM buffer, only for eNb // Resize EVM buffer, only for eNb
if (!q->is_ue && q->evm_buffer) { if (!q->is_ue && q->evm_buffer) {
srslte_evm_buffer_resize(q->evm_buffer, srslte_ra_tbs_from_idx(SRSLTE_RA_NOF_TBS_IDX - 1, cell.nof_prb)); srslte_evm_buffer_resize(q->evm_buffer, srslte_ra_tbs_from_idx(SRSLTE_RA_NOF_TBS_IDX - 1, cell.nof_prb));
@ -262,7 +260,7 @@ int srslte_pusch_set_rnti(srslte_pusch_t* q, uint16_t rnti)
// If the sequence is not allocated generate // If the sequence is not allocated generate
q->users[rnti_idx] = calloc(1, sizeof(srslte_pdsch_user_t)); q->users[rnti_idx] = calloc(1, sizeof(srslte_pdsch_user_t));
if (!q->users[rnti_idx]) { if (!q->users[rnti_idx]) {
ERROR("Alocating PDSCH user\n"); ERROR("Alocating PDSCH user");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} else if (q->users[rnti_idx]->sequence_generated && q->users[rnti_idx]->cell_id == q->cell.id && !q->is_ue) { } else if (q->users[rnti_idx]->sequence_generated && q->users[rnti_idx]->cell_id == q->cell.id && !q->is_ue) {
@ -280,7 +278,7 @@ int srslte_pusch_set_rnti(srslte_pusch_t* q, uint16_t rnti)
SRSLTE_NOF_SLOTS_PER_SF * sf_idx, SRSLTE_NOF_SLOTS_PER_SF * sf_idx,
q->cell.id, q->cell.id,
q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM))) { q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM))) {
ERROR("Error initializing PUSCH scrambling sequence\n"); ERROR("Error initializing PUSCH scrambling sequence");
srslte_pusch_free_rnti(q, rnti); srslte_pusch_free_rnti(q, rnti);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -296,7 +294,6 @@ int srslte_pusch_set_rnti(srslte_pusch_t* q, uint16_t rnti)
void srslte_pusch_free_rnti(srslte_pusch_t* q, uint16_t rnti) void srslte_pusch_free_rnti(srslte_pusch_t* q, uint16_t rnti)
{ {
uint32_t rnti_idx = q->is_ue ? 0 : rnti; uint32_t rnti_idx = q->is_ue ? 0 : rnti;
if (q->users[rnti_idx]) { if (q->users[rnti_idx]) {
@ -320,13 +317,13 @@ static srslte_sequence_t* get_user_sequence(srslte_pusch_t* q, uint16_t rnti, ui
return &q->users[rnti_idx]->seq[sf_idx]; return &q->users[rnti_idx]->seq[sf_idx];
} else { } else {
if (srslte_sequence_pusch(&q->tmp_seq, rnti, 2 * sf_idx, q->cell.id, len)) { if (srslte_sequence_pusch(&q->tmp_seq, rnti, 2 * sf_idx, q->cell.id, len)) {
ERROR("Error generating temporal scrambling sequence\n"); ERROR("Error generating temporal scrambling sequence");
return NULL; return NULL;
} }
return &q->tmp_seq; return &q->tmp_seq;
} }
} else { } else {
ERROR("Invalid RNTI=0x%x\n", rnti); ERROR("Invalid RNTI=0x%x", rnti);
return NULL; return NULL;
} }
} }
@ -362,7 +359,6 @@ int srslte_pusch_encode(srslte_pusch_t* q,
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL && cfg != NULL) { if (q != NULL && cfg != NULL) {
/* Limit UL modulation if not supported by the UE or disabled by higher layers */ /* Limit UL modulation if not supported by the UE or disabled by higher layers */
if (!cfg->enable_64qam) { if (!cfg->enable_64qam) {
if (cfg->grant.tb.mod >= SRSLTE_MOD_64QAM) { if (cfg->grant.tb.mod >= SRSLTE_MOD_64QAM) {
@ -372,7 +368,7 @@ int srslte_pusch_encode(srslte_pusch_t* q,
} }
if (cfg->grant.nof_re > q->max_re) { if (cfg->grant.nof_re > q->max_re) {
ERROR("Error too many RE per subframe (%d). PUSCH configured for %d RE (%d PRB)\n", ERROR("Error too many RE per subframe (%d). PUSCH configured for %d RE (%d PRB)",
cfg->grant.nof_re, cfg->grant.nof_re,
q->max_re, q->max_re,
q->cell.nof_prb); q->cell.nof_prb);
@ -384,7 +380,7 @@ int srslte_pusch_encode(srslte_pusch_t* q,
return err; return err;
} }
INFO("Encoding PUSCH SF: %d, Mod %s, RNTI: %d, TBS: %d, NofRE: %d, NofSymbols=%d, NofBitsE: %d, rv_idx: %d\n", INFO("Encoding PUSCH SF: %d, Mod %s, RNTI: %d, TBS: %d, NofRE: %d, NofSymbols=%d, NofBitsE: %d, rv_idx: %d",
sf->tti % 10, sf->tti % 10,
srslte_mod_string(cfg->grant.tb.mod), srslte_mod_string(cfg->grant.tb.mod),
cfg->rnti, cfg->rnti,
@ -396,7 +392,7 @@ int srslte_pusch_encode(srslte_pusch_t* q,
bzero(q->q, cfg->grant.tb.nof_bits); bzero(q->q, cfg->grant.tb.nof_bits);
if ((ret = srslte_ulsch_encode(&q->ul_sch, cfg, data->ptr, &data->uci, q->g, q->q)) < 0) { if ((ret = srslte_ulsch_encode(&q->ul_sch, cfg, data->ptr, &data->uci, q->g, q->q)) < 0) {
ERROR("Error encoding TB\n"); ERROR("Error encoding TB");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -405,7 +401,7 @@ int srslte_pusch_encode(srslte_pusch_t* q,
// Generate scrambling sequence if not pre-generated // Generate scrambling sequence if not pre-generated
srslte_sequence_t* seq = get_user_sequence(q, cfg->rnti, sf->tti % 10, cfg->grant.tb.nof_bits); srslte_sequence_t* seq = get_user_sequence(q, cfg->rnti, sf->tti % 10, cfg->grant.tb.nof_bits);
if (!seq) { if (!seq) {
ERROR("Error getting user sequence for rnti=0x%x\n", cfg->rnti); ERROR("Error getting user sequence for rnti=0x%x", cfg->rnti);
return -1; return -1;
} }
@ -439,7 +435,7 @@ int srslte_pusch_encode(srslte_pusch_t* q,
// Mapping to resource elements // Mapping to resource elements
uint32_t n = pusch_put(q, &cfg->grant, q->z, sf_symbols, sf->shortened); uint32_t n = pusch_put(q, &cfg->grant, q->z, sf_symbols, sf->shortened);
if (n != cfg->grant.nof_re) { if (n != cfg->grant.nof_re) {
ERROR("Error trying to allocate %d symbols but %d were allocated (tti=%d, short=%d, L=%d)\n", ERROR("Error trying to allocate %d symbols but %d were allocated (tti=%d, short=%d, L=%d)",
cfg->grant.nof_re, cfg->grant.nof_re,
n, n,
sf->tti, sf->tti,
@ -466,7 +462,6 @@ int srslte_pusch_decode(srslte_pusch_t* q,
uint32_t n; uint32_t n;
if (q != NULL && sf_symbols != NULL && out != NULL && cfg != NULL) { if (q != NULL && sf_symbols != NULL && out != NULL && cfg != NULL) {
struct timeval t[3]; struct timeval t[3];
if (cfg->meas_time_en) { if (cfg->meas_time_en) {
gettimeofday(&t[1], NULL); gettimeofday(&t[1], NULL);
@ -480,7 +475,7 @@ int srslte_pusch_decode(srslte_pusch_t* q,
} }
} }
INFO("Decoding PUSCH SF: %d, Mod %s, NofBits: %d, NofRE: %d, NofSymbols=%d, NofBitsE: %d, rv_idx: %d\n", INFO("Decoding PUSCH SF: %d, Mod %s, NofBits: %d, NofRE: %d, NofSymbols=%d, NofBitsE: %d, rv_idx: %d",
sf->tti % 10, sf->tti % 10,
srslte_mod_string(cfg->grant.tb.mod), srslte_mod_string(cfg->grant.tb.mod),
cfg->grant.tb.tbs, cfg->grant.tb.tbs,
@ -492,7 +487,7 @@ int srslte_pusch_decode(srslte_pusch_t* q,
/* extract symbols */ /* extract symbols */
n = pusch_get(q, &cfg->grant, sf_symbols, q->d, sf->shortened); n = pusch_get(q, &cfg->grant, sf_symbols, q->d, sf->shortened);
if (n != cfg->grant.nof_re) { if (n != cfg->grant.nof_re) {
ERROR("Error expecting %d symbols but got %d\n", cfg->grant.nof_re, n); ERROR("Error expecting %d symbols but got %d", cfg->grant.nof_re, n);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -506,7 +501,7 @@ int srslte_pusch_decode(srslte_pusch_t* q,
/* extract channel estimates */ /* extract channel estimates */
n = pusch_get(q, &cfg->grant, channel->ce, q->ce, sf->shortened); n = pusch_get(q, &cfg->grant, channel->ce, q->ce, sf->shortened);
if (n != cfg->grant.nof_re) { if (n != cfg->grant.nof_re) {
ERROR("Error expecting %d symbols but got %d\n", cfg->grant.nof_re, n); ERROR("Error expecting %d symbols but got %d", cfg->grant.nof_re, n);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -536,7 +531,7 @@ int srslte_pusch_decode(srslte_pusch_t* q,
// Generate scrambling sequence if not pre-generated // Generate scrambling sequence if not pre-generated
srslte_sequence_t* seq = get_user_sequence(q, cfg->rnti, sf->tti % 10, cfg->grant.tb.nof_bits); srslte_sequence_t* seq = get_user_sequence(q, cfg->rnti, sf->tti % 10, cfg->grant.tb.nof_bits);
if (!seq) { if (!seq) {
ERROR("Error getting user sequence for rnti=0x%x\n", cfg->rnti); ERROR("Error getting user sequence for rnti=0x%x", cfg->rnti);
return -1; return -1;
} }
@ -577,7 +572,6 @@ uint32_t srslte_pusch_grant_tx_info(srslte_pusch_grant_t* grant,
char* str, char* str,
uint32_t str_len) uint32_t str_len)
{ {
uint32_t len = srslte_ra_ul_info(grant, str, str_len); uint32_t len = srslte_ra_ul_info(grant, str, str_len);
if (uci_data) { if (uci_data) {
@ -589,7 +583,6 @@ uint32_t srslte_pusch_grant_tx_info(srslte_pusch_grant_t* grant,
uint32_t srslte_pusch_tx_info(srslte_pusch_cfg_t* cfg, srslte_uci_value_t* uci_data, char* str, uint32_t str_len) uint32_t srslte_pusch_tx_info(srslte_pusch_cfg_t* cfg, srslte_uci_value_t* uci_data, char* str, uint32_t str_len)
{ {
uint32_t len = srslte_print_check(str, str_len, 0, "rnti=0x%x", cfg->rnti); uint32_t len = srslte_print_check(str, str_len, 0, "rnti=0x%x", cfg->rnti);
len += srslte_pusch_grant_tx_info(&cfg->grant, &cfg->uci_cfg, uci_data, &str[len], str_len - len); len += srslte_pusch_grant_tx_info(&cfg->grant, &cfg->uci_cfg, uci_data, &str[len], str_len - len);
@ -606,7 +599,6 @@ uint32_t srslte_pusch_rx_info(srslte_pusch_cfg_t* cfg,
char* str, char* str,
uint32_t str_len) uint32_t str_len)
{ {
uint32_t len = srslte_print_check(str, str_len, 0, "rnti=0x%x", cfg->rnti); uint32_t len = srslte_print_check(str, str_len, 0, "rnti=0x%x", cfg->rnti);
len += srslte_ra_ul_info(&cfg->grant, &str[len], str_len); len += srslte_ra_ul_info(&cfg->grant, &str[len], str_len);

@ -20,7 +20,7 @@ int pusch_nr_init_common(srslte_pusch_nr_t* q, const srslte_pusch_nr_args_t* arg
{ {
for (srslte_mod_t mod = SRSLTE_MOD_BPSK; mod < SRSLTE_MOD_NITEMS; mod++) { for (srslte_mod_t mod = SRSLTE_MOD_BPSK; mod < SRSLTE_MOD_NITEMS; mod++) {
if (srslte_modem_table_lte(&q->modem_tables[mod], mod) < SRSLTE_SUCCESS) { if (srslte_modem_table_lte(&q->modem_tables[mod], mod) < SRSLTE_SUCCESS) {
ERROR("Error initialising modem table for %s\n", srslte_mod_string(mod)); ERROR("Error initialising modem table for %s", srslte_mod_string(mod));
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (args->measure_evm) { if (args->measure_evm) {
@ -42,7 +42,7 @@ int srslte_pusch_nr_init_ue(srslte_pusch_nr_t* q, const srslte_pusch_nr_args_t*
} }
if (srslte_sch_nr_init_tx(&q->sch, &args->sch)) { if (srslte_sch_nr_init_tx(&q->sch, &args->sch)) {
ERROR("Initialising SCH\n"); ERROR("Initialising SCH");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -60,14 +60,14 @@ int srslte_pusch_nr_init_gnb(srslte_pusch_nr_t* q, const srslte_pusch_nr_args_t*
} }
if (srslte_sch_nr_init_rx(&q->sch, &args->sch)) { if (srslte_sch_nr_init_rx(&q->sch, &args->sch)) {
ERROR("Initialising SCH\n"); ERROR("Initialising SCH");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (args->measure_evm) { if (args->measure_evm) {
q->evm_buffer = srslte_evm_buffer_alloc(8); q->evm_buffer = srslte_evm_buffer_alloc(8);
if (q->evm_buffer == NULL) { if (q->evm_buffer == NULL) {
ERROR("Initialising EVM\n"); ERROR("Initialising EVM");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -410,7 +410,7 @@ pusch_nr_cinit(const srslte_carrier_nr_t* carrier, const srslte_sch_cfg_nr_t* cf
} }
uint32_t cinit = (((uint32_t)rnti) << 15U) + (cw_idx << 14U) + n_id; uint32_t cinit = (((uint32_t)rnti) << 15U) + (cw_idx << 14U) + n_id;
INFO("PUSCH: RNTI=%d (0x%x); nid=%d; cinit=%d (0x%x);\n", rnti, rnti, n_id, cinit, cinit); INFO("PUSCH: RNTI=%d (0x%x); nid=%d; cinit=%d (0x%x);", rnti, rnti, n_id, cinit, cinit);
return cinit; return cinit;
} }
@ -428,19 +428,19 @@ static inline int pusch_nr_encode_codeword(srslte_pusch_nr_t* q,
// Check codeword index // Check codeword index
if (tb->cw_idx >= q->max_cw) { if (tb->cw_idx >= q->max_cw) {
ERROR("Unsupported codeword index %d\n", tb->cw_idx); ERROR("Unsupported codeword index %d", tb->cw_idx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Check modulation // Check modulation
if (tb->mod >= SRSLTE_MOD_NITEMS) { if (tb->mod >= SRSLTE_MOD_NITEMS) {
ERROR("Invalid modulation %s\n", srslte_mod_string(tb->mod)); ERROR("Invalid modulation %s", srslte_mod_string(tb->mod));
return SRSLTE_ERROR_OUT_OF_BOUNDS; return SRSLTE_ERROR_OUT_OF_BOUNDS;
} }
// Encode SCH // Encode SCH
if (srslte_ulsch_nr_encode(&q->sch, &cfg->sch_cfg, tb, data, q->b[tb->cw_idx]) < SRSLTE_SUCCESS) { if (srslte_ulsch_nr_encode(&q->sch, &cfg->sch_cfg, tb, data, q->b[tb->cw_idx]) < SRSLTE_SUCCESS) {
ERROR("Error in DL-SCH encoding\n"); ERROR("Error in DL-SCH encoding");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -482,7 +482,7 @@ int srslte_pusch_nr_encode(srslte_pusch_nr_t* q,
// Check number of layers // Check number of layers
if (q->max_layers < grant->nof_layers) { if (q->max_layers < grant->nof_layers) {
ERROR("Error number of layers (%d) exceeds configured maximum (%d)\n", grant->nof_layers, q->max_layers); ERROR("Error number of layers (%d) exceeds configured maximum (%d)", grant->nof_layers, q->max_layers);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -492,7 +492,7 @@ int srslte_pusch_nr_encode(srslte_pusch_nr_t* q,
nof_cw += grant->tb[tb].enabled ? 1 : 0; nof_cw += grant->tb[tb].enabled ? 1 : 0;
if (pusch_nr_encode_codeword(q, cfg, &grant->tb[tb], data[tb], grant->rnti) < SRSLTE_SUCCESS) { if (pusch_nr_encode_codeword(q, cfg, &grant->tb[tb], data[tb], grant->rnti) < SRSLTE_SUCCESS) {
ERROR("Error encoding TB %d\n", tb); ERROR("Error encoding TB %d", tb);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -513,12 +513,12 @@ int srslte_pusch_nr_encode(srslte_pusch_nr_t* q,
// 7.3.1.6 Mapping from virtual to physical resource blocks // 7.3.1.6 Mapping from virtual to physical resource blocks
int n = srslte_pusch_nr_put(q, cfg, grant, x[0], sf_symbols[0]); int n = srslte_pusch_nr_put(q, cfg, grant, x[0], sf_symbols[0]);
if (n < SRSLTE_SUCCESS) { if (n < SRSLTE_SUCCESS) {
ERROR("Putting NR PUSCH resources\n"); ERROR("Putting NR PUSCH resources");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (n != grant->tb[0].nof_re) { if (n != grant->tb[0].nof_re) {
ERROR("Unmatched number of RE (%d != %d)\n", n, grant->tb[0].nof_re); ERROR("Unmatched number of RE (%d != %d)", n, grant->tb[0].nof_re);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -544,13 +544,13 @@ static inline int pusch_nr_decode_codeword(srslte_pusch_nr_t* q,
// Check codeword index // Check codeword index
if (tb->cw_idx >= q->max_cw) { if (tb->cw_idx >= q->max_cw) {
ERROR("Unsupported codeword index %d\n", tb->cw_idx); ERROR("Unsupported codeword index %d", tb->cw_idx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Check modulation // Check modulation
if (tb->mod >= SRSLTE_MOD_NITEMS) { if (tb->mod >= SRSLTE_MOD_NITEMS) {
ERROR("Invalid modulation %s\n", srslte_mod_string(tb->mod)); ERROR("Invalid modulation %s", srslte_mod_string(tb->mod));
return SRSLTE_ERROR_OUT_OF_BOUNDS; return SRSLTE_ERROR_OUT_OF_BOUNDS;
} }
@ -585,7 +585,7 @@ static inline int pusch_nr_decode_codeword(srslte_pusch_nr_t* q,
// Decode SCH // Decode SCH
if (srslte_ulsch_nr_decode(&q->sch, &cfg->sch_cfg, tb, llr, res->payload, &res->crc) < SRSLTE_SUCCESS) { if (srslte_ulsch_nr_decode(&q->sch, &cfg->sch_cfg, tb, llr, res->payload, &res->crc) < SRSLTE_SUCCESS) {
ERROR("Error in DL-SCH encoding\n"); ERROR("Error in DL-SCH encoding");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -617,14 +617,14 @@ int srslte_pusch_nr_decode(srslte_pusch_nr_t* q,
uint32_t nof_re = srslte_ra_dl_nr_slot_nof_re(cfg, grant); uint32_t nof_re = srslte_ra_dl_nr_slot_nof_re(cfg, grant);
if (channel->nof_re != nof_re) { if (channel->nof_re != nof_re) {
ERROR("Inconsistent number of RE (%d!=%d)\n", channel->nof_re, nof_re); ERROR("Inconsistent number of RE (%d!=%d)", channel->nof_re, nof_re);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Demapping from virtual to physical resource blocks // Demapping from virtual to physical resource blocks
uint32_t nof_re_get = srslte_pusch_nr_get(q, cfg, grant, q->x[0], sf_symbols[0]); uint32_t nof_re_get = srslte_pusch_nr_get(q, cfg, grant, q->x[0], sf_symbols[0]);
if (nof_re_get != nof_re) { if (nof_re_get != nof_re) {
ERROR("Inconsistent number of RE (%d!=%d)\n", nof_re_get, nof_re); ERROR("Inconsistent number of RE (%d!=%d)", nof_re_get, nof_re);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -653,7 +653,7 @@ int srslte_pusch_nr_decode(srslte_pusch_nr_t* q,
nof_cw += grant->tb[tb].enabled ? 1 : 0; nof_cw += grant->tb[tb].enabled ? 1 : 0;
if (pusch_nr_decode_codeword(q, cfg, &grant->tb[tb], &data[tb], grant->rnti) < SRSLTE_SUCCESS) { if (pusch_nr_decode_codeword(q, cfg, &grant->tb[tb], &data[tb], grant->rnti) < SRSLTE_SUCCESS) {
ERROR("Error encoding TB %d\n", tb); ERROR("Error encoding TB %d", tb);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -744,7 +744,7 @@ uint32_t srslte_pusch_nr_rx_info(const srslte_pusch_nr_t* q,
} }
if (q->meas_time_en) { if (q->meas_time_en) {
len = srslte_print_check(str, str_len, len, ", t=%d us\n", q->meas_time_us); len = srslte_print_check(str, str_len, len, ", t=%d us", q->meas_time_us);
} }
return len; return len;
@ -761,7 +761,7 @@ uint32_t srslte_pusch_nr_tx_info(const srslte_pusch_nr_t* q,
len += srslte_pusch_nr_grant_info(cfg, grant, &str[len], str_len - len); len += srslte_pusch_nr_grant_info(cfg, grant, &str[len], str_len - len);
if (q->meas_time_en) { if (q->meas_time_en) {
len = srslte_print_check(str, str_len, len, ", t=%d us\n", q->meas_time_us); len = srslte_print_check(str, str_len, len, ", t=%d us", q->meas_time_us);
} }
return len; return len;

@ -32,7 +32,6 @@ const int tbs_format1c_table[32] = {40, 56, 72, 120, 136, 144, 176, 208
/* Returns the number of RE in a PRB in a slot and subframe */ /* Returns the number of RE in a PRB in a slot and subframe */
uint32_t ra_re_x_prb(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, uint32_t slot, uint32_t prb_idx) uint32_t ra_re_x_prb(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, uint32_t slot, uint32_t prb_idx)
{ {
uint32_t subframe = sf->tti % 10; uint32_t subframe = sf->tti % 10;
uint32_t nof_ctrl_symbols = SRSLTE_NOF_CTRL_SYMBOLS((*cell), sf->cfi); uint32_t nof_ctrl_symbols = SRSLTE_NOF_CTRL_SYMBOLS((*cell), sf->cfi);
@ -188,7 +187,7 @@ int srslte_ra_dl_grant_to_grant_prb_allocation(const srslte_dci_dl_t* dci,
case SRSLTE_RA_ALLOC_TYPE1: case SRSLTE_RA_ALLOC_TYPE1:
// Make sure the rbg_subset is valid // Make sure the rbg_subset is valid
if (dci->type1_alloc.rbg_subset >= P) { if (dci->type1_alloc.rbg_subset >= P) {
ERROR("Invalid RBG subset=%d for nof_prb=%d where P=%d\n", dci->type1_alloc.rbg_subset, nof_prb, P); ERROR("Invalid RBG subset=%d for nof_prb=%d where P=%d", dci->type1_alloc.rbg_subset, nof_prb, P);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
n_rb_type1 = srslte_ra_type1_N_rb(nof_prb); n_rb_type1 = srslte_ra_type1_N_rb(nof_prb);
@ -209,7 +208,7 @@ int srslte_ra_dl_grant_to_grant_prb_allocation(const srslte_dci_dl_t* dci,
grant->prb_idx[0][idx] = true; grant->prb_idx[0][idx] = true;
grant->nof_prb++; grant->nof_prb++;
} else { } else {
ERROR("Invalid idx=%d in Type1 RA, nof_prb=%d\n", idx, nof_prb); ERROR("Invalid idx=%d in Type1 RA, nof_prb=%d", idx, nof_prb);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -360,25 +359,25 @@ static int dl_dci_compute_tb(bool pdsch_use_tbs_index_alt, const srslte_dci_dl_t
i_tbs = dci->tb[0].mcs_idx; i_tbs = dci->tb[0].mcs_idx;
tbs = srslte_ra_tbs_from_idx(i_tbs, n_prb); tbs = srslte_ra_tbs_from_idx(i_tbs, n_prb);
if (tbs < 0) { if (tbs < 0) {
ERROR("Invalid TBS_index=%d or n_prb=%d\n", i_tbs, n_prb); ERROR("Invalid TBS_index=%d or n_prb=%d", i_tbs, n_prb);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} else if (dci->format == SRSLTE_DCI_FORMAT1C) { } else if (dci->format == SRSLTE_DCI_FORMAT1C) {
if (dci->tb[0].mcs_idx < 32) { if (dci->tb[0].mcs_idx < 32) {
tbs = tbs_format1c_table[dci->tb[0].mcs_idx]; tbs = tbs_format1c_table[dci->tb[0].mcs_idx];
} else { } else {
ERROR("Error decoding DCI: Invalid mcs_idx=%d in Format1C\n", dci->tb[0].mcs_idx); ERROR("Error decoding DCI: Invalid mcs_idx=%d in Format1C", dci->tb[0].mcs_idx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} else { } else {
ERROR("Error decoding DCI: P/SI/RA-RNTI supports Format1A/1C only\n"); ERROR("Error decoding DCI: P/SI/RA-RNTI supports Format1A/1C only");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
grant->tb[0].mod = SRSLTE_MOD_QPSK; grant->tb[0].mod = SRSLTE_MOD_QPSK;
if (tbs >= 0) { if (tbs >= 0) {
grant->tb[0].tbs = (uint32_t)tbs; grant->tb[0].tbs = (uint32_t)tbs;
} else { } else {
ERROR("Invalid TBS=%d\n", tbs); ERROR("Invalid TBS=%d", tbs);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} else { } else {
@ -393,7 +392,7 @@ static int dl_dci_compute_tb(bool pdsch_use_tbs_index_alt, const srslte_dci_dl_t
if (grant->tb[i].tbs < 0) { if (grant->tb[i].tbs < 0) {
char str[128]; char str[128];
srslte_dci_dl_info(dci, str, sizeof(str)); srslte_dci_dl_info(dci, str, sizeof(str));
INFO("Error computing TBS from %s\n", str); INFO("Error computing TBS from %s", str);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} else { } else {
@ -448,7 +447,7 @@ config_mimo_type(const srslte_cell_t* cell, srslte_tm_t tm, const srslte_dci_dl_
grant->tx_scheme = SRSLTE_TXSCHEME_PORT0; grant->tx_scheme = SRSLTE_TXSCHEME_PORT0;
} }
if (nof_tb != 1) { if (nof_tb != 1) {
ERROR("Wrong number of transport blocks (%d) for %s.\n", nof_tb, srslte_mimotype2str(grant->tx_scheme)); ERROR("Wrong number of transport blocks (%d) for %s.", nof_tb, srslte_mimotype2str(grant->tx_scheme));
valid_config = false; valid_config = false;
} }
break; break;
@ -458,7 +457,7 @@ config_mimo_type(const srslte_cell_t* cell, srslte_tm_t tm, const srslte_dci_dl_
} else if (nof_tb == 2) { } else if (nof_tb == 2) {
grant->tx_scheme = SRSLTE_TXSCHEME_CDD; grant->tx_scheme = SRSLTE_TXSCHEME_CDD;
} else { } else {
ERROR("Invalid number of transport blocks (%d) for TM3\n", nof_tb); ERROR("Invalid number of transport blocks (%d) for TM3", nof_tb);
valid_config = false; valid_config = false;
} }
break; break;
@ -468,7 +467,7 @@ config_mimo_type(const srslte_cell_t* cell, srslte_tm_t tm, const srslte_dci_dl_
} else if (nof_tb == 2) { } else if (nof_tb == 2) {
grant->tx_scheme = SRSLTE_TXSCHEME_SPATIALMUX; grant->tx_scheme = SRSLTE_TXSCHEME_SPATIALMUX;
} else { } else {
ERROR("Invalid number of transport blocks (%d) for TM4\n", nof_tb); ERROR("Invalid number of transport blocks (%d) for TM4", nof_tb);
valid_config = false; valid_config = false;
} }
break; break;
@ -478,12 +477,12 @@ config_mimo_type(const srslte_cell_t* cell, srslte_tm_t tm, const srslte_dci_dl_
case SRSLTE_TM6: case SRSLTE_TM6:
case SRSLTE_TM7: case SRSLTE_TM7:
case SRSLTE_TM8: case SRSLTE_TM8:
ERROR("Not implemented Tx mode (%d)\n", tm + 1); ERROR("Not implemented Tx mode (%d)", tm + 1);
break; break;
/* Error cases */ /* Error cases */
default: default:
ERROR("Wrong Tx mode (%d)\n", tm + 1); ERROR("Wrong Tx mode (%d)", tm + 1);
} }
return valid_config ? SRSLTE_SUCCESS : SRSLTE_ERROR; return valid_config ? SRSLTE_SUCCESS : SRSLTE_ERROR;
} }
@ -526,14 +525,14 @@ static int config_mimo_layers(const srslte_cell_t* cell, const srslte_dci_dl_t*
switch (grant->tx_scheme) { switch (grant->tx_scheme) {
case SRSLTE_TXSCHEME_PORT0: case SRSLTE_TXSCHEME_PORT0:
if (nof_tb != 1) { if (nof_tb != 1) {
ERROR("Wrong number of transport blocks (%d) for single antenna.\n", nof_tb); ERROR("Wrong number of transport blocks (%d) for single antenna.", nof_tb);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
grant->nof_layers = 1; grant->nof_layers = 1;
break; break;
case SRSLTE_TXSCHEME_DIVERSITY: case SRSLTE_TXSCHEME_DIVERSITY:
if (nof_tb != 1) { if (nof_tb != 1) {
ERROR("Wrong number of transport blocks (%d) for transmit diversity.\n", nof_tb); ERROR("Wrong number of transport blocks (%d) for transmit diversity.", nof_tb);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
grant->nof_layers = cell->nof_ports; grant->nof_layers = cell->nof_ports;
@ -544,17 +543,17 @@ static int config_mimo_layers(const srslte_cell_t* cell, const srslte_dci_dl_t*
} else if (nof_tb == 2) { } else if (nof_tb == 2) {
grant->nof_layers = 2; grant->nof_layers = 2;
} else { } else {
ERROR("Wrong number of transport blocks (%d) for spatial multiplexing.\n", nof_tb); ERROR("Wrong number of transport blocks (%d) for spatial multiplexing.", nof_tb);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
INFO("PDSCH configured for Spatial Multiplex; nof_codewords=%d; nof_layers=%d; pmi=%d\n", INFO("PDSCH configured for Spatial Multiplex; nof_codewords=%d; nof_layers=%d; pmi=%d",
nof_tb, nof_tb,
grant->nof_layers, grant->nof_layers,
grant->pmi); grant->pmi);
break; break;
case SRSLTE_TXSCHEME_CDD: case SRSLTE_TXSCHEME_CDD:
if (nof_tb != 2) { if (nof_tb != 2) {
ERROR("Wrong number of transport blocks (%d) for CDD.\n", nof_tb); ERROR("Wrong number of transport blocks (%d) for CDD.", nof_tb);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
grant->nof_layers = 2; grant->nof_layers = 2;
@ -566,19 +565,18 @@ static int config_mimo_layers(const srslte_cell_t* cell, const srslte_dci_dl_t*
static int static int
config_mimo(const srslte_cell_t* cell, srslte_tm_t tm, const srslte_dci_dl_t* dci, srslte_pdsch_grant_t* grant) config_mimo(const srslte_cell_t* cell, srslte_tm_t tm, const srslte_dci_dl_t* dci, srslte_pdsch_grant_t* grant)
{ {
if (config_mimo_type(cell, tm, dci, grant)) { if (config_mimo_type(cell, tm, dci, grant)) {
ERROR("Configuring MIMO type\n"); ERROR("Configuring MIMO type");
return -1; return -1;
} }
if (config_mimo_pmi(cell, dci, grant)) { if (config_mimo_pmi(cell, dci, grant)) {
ERROR("Configuring MIMO PMI\n"); ERROR("Configuring MIMO PMI");
return -1; return -1;
} }
if (config_mimo_layers(cell, dci, grant)) { if (config_mimo_layers(cell, dci, grant)) {
ERROR("Configuring MIMO layers\n"); ERROR("Configuring MIMO layers");
return -1; return -1;
} }
@ -618,11 +616,11 @@ int srslte_ra_dl_dci_to_grant(const srslte_cell_t* cell,
} }
} }
} else { } else {
INFO("Configuring TB Info\n"); INFO("Configuring TB Info");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} else { } else {
ERROR("Configuring resource allocation\n"); ERROR("Configuring resource allocation");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }

@ -18,23 +18,23 @@ static bool check_time_ra_typeA(uint32_t* S, uint32_t* L)
{ {
// Check values using Table 5.1.2.1-1 // Check values using Table 5.1.2.1-1
if (*S > 3) { if (*S > 3) {
ERROR("S (%d) is out-of-range {0,1,2,3}\n", *S); ERROR("S (%d) is out-of-range {0,1,2,3}", *S);
return false; return false;
} }
if (*L < 3 || *L > 14) { if (*L < 3 || *L > 14) {
ERROR("L (%d) is out-of-range {3,...,14}\n", *L); ERROR("L (%d) is out-of-range {3,...,14}", *L);
return false; return false;
} }
uint32_t sum = *S + *L; uint32_t sum = *S + *L;
if (sum < 3) { if (sum < 3) {
ERROR("The sum of S (%d) and L (%d) is lower than 3\n", *S, *L); ERROR("The sum of S (%d) and L (%d) is lower than 3", *S, *L);
return false; return false;
} }
if (sum > 14) { if (sum > 14) {
ERROR("The sum of S (%d) and L (%d) is greater than 14\n", *S, *L); ERROR("The sum of S (%d) and L (%d) is greater than 14", *S, *L);
return false; return false;
} }
@ -43,7 +43,7 @@ static bool check_time_ra_typeA(uint32_t* S, uint32_t* L)
static bool check_time_ra_typeB(uint32_t* S, uint32_t* L) static bool check_time_ra_typeB(uint32_t* S, uint32_t* L)
{ {
ERROR("Not implemented\n"); ERROR("Not implemented");
return false; return false;
} }
@ -63,7 +63,7 @@ int srslte_ra_dl_nr_time_default_A(uint32_t m, srslte_dmrs_sch_typeA_pos_t dmrs_
} }
if (m >= SRSLTE_MAX_NOF_DL_ALLOCATION) { if (m >= SRSLTE_MAX_NOF_DL_ALLOCATION) {
ERROR("m (%d) is out-of-range\n", m); ERROR("m (%d) is out-of-range", m);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
@ -105,7 +105,7 @@ int srslte_ra_dl_nr_time_default_A(uint32_t m, srslte_dmrs_sch_typeA_pos_t dmrs_
grant->L = L_pos3[m]; grant->L = L_pos3[m];
break; break;
default: default:
ERROR("Undefined case (%d)\n", dmrs_typeA_pos); ERROR("Undefined case (%d)", dmrs_typeA_pos);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -133,7 +133,7 @@ int srslte_ra_dl_nr_time(const srslte_sch_hl_cfg_nr_t* cfg,
} }
if (m >= SRSLTE_MAX_NOF_DL_ALLOCATION) { if (m >= SRSLTE_MAX_NOF_DL_ALLOCATION) {
ERROR("m (%d) is out-of-range\n", m); ERROR("m (%d) is out-of-range", m);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
@ -182,7 +182,7 @@ int srslte_ra_dl_nr_time(const srslte_sch_hl_cfg_nr_t* cfg,
// Validate S and L parameters // Validate S and L parameters
if (!srslte_ra_dl_nr_time_validate(grant)) { if (!srslte_ra_dl_nr_time_validate(grant)) {
ERROR("Invalid Time RA S=%d; L=%d; m=%d\n", grant->S, grant->L, m); ERROR("Invalid Time RA S=%d; L=%d; m=%d", grant->S, grant->L, m);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -270,6 +270,6 @@ int srslte_ra_dl_nr_freq(const srslte_carrier_nr_t* carrier,
} }
ra_freq_type0(carrier, cfg, dci_dl, grant); ra_freq_type0(carrier, cfg, dci_dl, grant);
ERROR("Only DCI Format 1_0 is supported\n"); ERROR("Only DCI Format 1_0 is supported");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }

@ -36,7 +36,7 @@ static int ra_helper_freq_type1(uint32_t N_bwp_size, uint32_t riv, srslte_sch_gr
ra_helper_compute_s_and_l(N_bwp_size, riv, &start, &len); ra_helper_compute_s_and_l(N_bwp_size, riv, &start, &len);
if (start + len > N_bwp_size) { if (start + len > N_bwp_size) {
ERROR("RIV 0x%x for BWP size %d resulted in freq=%d:%d\n", riv, N_bwp_size, start, len); ERROR("RIV 0x%x for BWP size %d resulted in freq=%d:%d", riv, N_bwp_size, start, len);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }

@ -142,7 +142,7 @@ static int nbiot_dl_dci_to_grant_mcs(srslte_ra_nbiot_dl_dci_t* dci, srslte_ra_nb
} }
if (tbs <= 0) { if (tbs <= 0) {
INFO("Unsupported resource allocation specified: i_tbs=%d [0,12], i_sf=%d [0,7]\n", i_tbs, i_sf); INFO("Unsupported resource allocation specified: i_tbs=%d [0,12], i_sf=%d [0,7]", i_tbs, i_sf);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} else { } else {
grant->mcs[0].tbs = (uint32_t)tbs; grant->mcs[0].tbs = (uint32_t)tbs;
@ -471,7 +471,7 @@ int srslte_ra_nbiot_ul_dci_to_grant(srslte_ra_nbiot_ul_dci_t* dci,
} else if (grant->nof_sc == 12) { } else if (grant->nof_sc == 12) {
grant->nof_slots = 2; grant->nof_slots = 2;
} else { } else {
DEBUG("Unsupported value for N_sc_RU=%d\n", grant->nof_sc); DEBUG("Unsupported value for N_sc_RU=%d", grant->nof_sc);
} }
break; break;
case SRSLTE_NPUSCH_FORMAT2: case SRSLTE_NPUSCH_FORMAT2:

@ -474,7 +474,7 @@ static int ra_dl_dmrs(const srslte_sch_hl_cfg_nr_t* pdsch_hl_cfg,
if (pdsch_grant->dci_format == srslte_dci_format_nr_1_0) { if (pdsch_grant->dci_format == srslte_dci_format_nr_1_0) {
if (srslte_ra_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(dmrs_cfg, pdsch_grant) < SRSLTE_SUCCESS) { if (srslte_ra_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(dmrs_cfg, pdsch_grant) < SRSLTE_SUCCESS) {
ERROR("Error loading number of DMRS CDM groups\n"); ERROR("Error loading number of DMRS CDM groups");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} else { } else {
@ -576,11 +576,11 @@ ra_ul_dmrs(const srslte_sch_hl_cfg_nr_t* pusch_hl_cfg, srslte_sch_grant_nr_t* pu
// Set number of DMRS CDM groups without data // Set number of DMRS CDM groups without data
if (pusch_grant->dci_format == srslte_dci_format_nr_0_0) { if (pusch_grant->dci_format == srslte_dci_format_nr_0_0) {
if (srslte_ra_ul_nr_nof_dmrs_cdm_groups_without_data_format_0_0(cfg, pusch_grant) < SRSLTE_SUCCESS) { if (srslte_ra_ul_nr_nof_dmrs_cdm_groups_without_data_format_0_0(cfg, pusch_grant) < SRSLTE_SUCCESS) {
ERROR("Error loading number of DMRS CDM groups\n"); ERROR("Error loading number of DMRS CDM groups");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} else { } else {
ERROR("Invalid case\n"); ERROR("Invalid case");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }

@ -71,14 +71,12 @@ static void compute_freq_hopping(srslte_ra_ul_pusch_hopping_t* q,
srslte_pusch_hopping_cfg_t* hopping_cfg, srslte_pusch_hopping_cfg_t* hopping_cfg,
srslte_pusch_grant_t* grant) srslte_pusch_grant_t* grant)
{ {
if (q->cell.frame_type == SRSLTE_TDD) { if (q->cell.frame_type == SRSLTE_TDD) {
ERROR("Error frequency hopping for TDD not implemented (c_init for each subframe, see end of 5.3.4 36.211)\n"); ERROR("Error frequency hopping for TDD not implemented (c_init for each subframe, see end of 5.3.4 36.211)");
} }
for (uint32_t slot = 0; slot < 2; slot++) { for (uint32_t slot = 0; slot < 2; slot++) {
INFO("PUSCH Freq hopping: %d", grant->freq_hopping);
INFO("PUSCH Freq hopping: %d\n", grant->freq_hopping);
uint32_t n_prb_tilde = grant->n_prb[slot]; uint32_t n_prb_tilde = grant->n_prb[slot];
if (grant->freq_hopping == 1) { if (grant->freq_hopping == 1) {
@ -108,7 +106,7 @@ static void compute_freq_hopping(srslte_ra_ul_pusch_hopping_t* q,
2 * (n_vrb_tilde % n_rb_sb) * f_m(q, hopping_cfg, i, hopping_cfg->current_tx_nb)) % 2 * (n_vrb_tilde % n_rb_sb) * f_m(q, hopping_cfg, i, hopping_cfg->current_tx_nb)) %
(n_rb_sb * hopping_cfg->n_sb); (n_rb_sb * hopping_cfg->n_sb);
INFO("n_prb_tilde: %d, n_vrb_tilde: %d, n_rb_sb: %d, n_sb: %d\n", INFO("n_prb_tilde: %d, n_vrb_tilde: %d, n_rb_sb: %d, n_sb: %d",
n_prb_tilde, n_prb_tilde,
n_vrb_tilde, n_vrb_tilde,
n_rb_sb, n_rb_sb,
@ -146,7 +144,7 @@ static int ra_ul_grant_to_grant_prb_allocation(srslte_dci_ul_t* dci,
} else { } else {
grant->freq_hopping = 2; grant->freq_hopping = 2;
} }
INFO("prb1: %d, prb2: %d, L: %d\n", grant->n_prb[0], grant->n_prb[1], grant->L_prb); INFO("prb1: %d, prb2: %d, L: %d", grant->n_prb[0], grant->n_prb[1], grant->L_prb);
} else { } else {
/* Type1 frequency hopping as defined in 8.4.1 of 36.213 /* Type1 frequency hopping as defined in 8.4.1 of 36.213
* frequency offset between 1st and 2nd slot is fixed. * frequency offset between 1st and 2nd slot is fixed.
@ -156,7 +154,7 @@ static int ra_ul_grant_to_grant_prb_allocation(srslte_dci_ul_t* dci,
// starting prb idx for slot 0 is as given by resource dci // starting prb idx for slot 0 is as given by resource dci
grant->n_prb[0] = n_prb_1; grant->n_prb[0] = n_prb_1;
if (n_prb_1 < n_rb_ho / 2) { if (n_prb_1 < n_rb_ho / 2) {
INFO("Invalid Frequency Hopping parameters. Offset: %d, n_prb_1: %d\n", n_rb_ho, n_prb_1); INFO("Invalid Frequency Hopping parameters. Offset: %d, n_prb_1: %d", n_rb_ho, n_prb_1);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
uint32_t n_prb_1_tilde = n_prb_1; uint32_t n_prb_1_tilde = n_prb_1;
@ -179,7 +177,7 @@ static int ra_ul_grant_to_grant_prb_allocation(srslte_dci_ul_t* dci,
default: default:
break; break;
} }
INFO("n_rb_pusch: %d, prb1: %d, prb2: %d, L: %d\n", n_rb_pusch, grant->n_prb[0], grant->n_prb[1], grant->L_prb); INFO("n_rb_pusch: %d, prb1: %d, prb2: %d, L: %d", n_rb_pusch, grant->n_prb[0], grant->n_prb[1], grant->L_prb);
grant->freq_hopping = 1; grant->freq_hopping = 1;
} }
@ -205,7 +203,7 @@ static void ul_fill_ra_mcs(srslte_ra_tb_t* tb, srslte_ra_tb_t* last_tb, uint32_t
tb->mod = SRSLTE_MOD_64QAM; tb->mod = SRSLTE_MOD_64QAM;
tb->tbs = srslte_ra_tbs_from_idx(tb->mcs_idx - 2, L_prb); tb->tbs = srslte_ra_tbs_from_idx(tb->mcs_idx - 2, L_prb);
} else { } else {
ERROR("Invalid MCS index %d\n", tb->mcs_idx); ERROR("Invalid MCS index %d", tb->mcs_idx);
} }
} else if (tb->mcs_idx == 29 && cqi_request && L_prb <= 4) { } else if (tb->mcs_idx == 29 && cqi_request && L_prb <= 4) {
// 8.6.1 and 8.6.2 36.213 second paragraph // 8.6.1 and 8.6.2 36.213 second paragraph
@ -244,7 +242,7 @@ int srslte_ra_ul_pusch_hopping_init(srslte_ra_ul_pusch_hopping_t* q, srslte_cell
q->initialized = true; q->initialized = true;
/* Precompute sequence for type2 frequency hopping */ /* Precompute sequence for type2 frequency hopping */
if (srslte_sequence_LTE_pr(&q->seq_type2_fo, 210, q->cell.id)) { if (srslte_sequence_LTE_pr(&q->seq_type2_fo, 210, q->cell.id)) {
ERROR("Error initiating type2 frequency hopping sequence\n"); ERROR("Error initiating type2 frequency hopping sequence");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;
@ -279,10 +277,8 @@ int srslte_ra_ul_dci_to_grant(srslte_cell_t* cell,
srslte_dci_ul_t* dci, srslte_dci_ul_t* dci,
srslte_pusch_grant_t* grant) srslte_pusch_grant_t* grant)
{ {
// Compute PRB allocation // Compute PRB allocation
if (!ra_ul_grant_to_grant_prb_allocation(dci, grant, hopping_cfg->n_rb_ho, cell->nof_prb)) { if (!ra_ul_grant_to_grant_prb_allocation(dci, grant, hopping_cfg->n_rb_ho, cell->nof_prb)) {
// copy default values from DCI. RV can be updated by ul_fill_ra_mcs() in case of Adaptive retx (mcs>28) // copy default values from DCI. RV can be updated by ul_fill_ra_mcs() in case of Adaptive retx (mcs>28)
grant->tb.mcs_idx = dci->tb.mcs_idx; grant->tb.mcs_idx = dci->tb.mcs_idx;
grant->tb.rv = dci->tb.rv; grant->tb.rv = dci->tb.rv;
@ -290,18 +286,18 @@ int srslte_ra_ul_dci_to_grant(srslte_cell_t* cell,
// Compute MCS // Compute MCS
ul_fill_ra_mcs(&grant->tb, &grant->last_tb, grant->L_prb, dci->cqi_request); ul_fill_ra_mcs(&grant->tb, &grant->last_tb, grant->L_prb, dci->cqi_request);
/* Compute RE assuming shortened is false*/ /* Compute RE assuming shortened is false*/
srslte_ra_ul_compute_nof_re(grant, cell->cp, 0); srslte_ra_ul_compute_nof_re(grant, cell->cp, 0);
// TODO: Need to compute hopping here before determining if there is collision with SRS, but only MAC knows if it's a // TODO: Need to compute hopping here before determining if there is collision with SRS, but only MAC knows if it's
// a
// new tx or a retx. Need to split MAC interface in 2 calls. For now, assume hopping is the same // new tx or a retx. Need to split MAC interface in 2 calls. For now, assume hopping is the same
for (uint32_t i = 0; i < 2; i++) { for (uint32_t i = 0; i < 2; i++) {
grant->n_prb_tilde[i] = grant->n_prb[i]; grant->n_prb_tilde[i] = grant->n_prb[i];
} }
if (grant->nof_symb == 0 || grant->nof_re == 0) { if (grant->nof_symb == 0 || grant->nof_re == 0) {
INFO("Error converting ul_dci to grant, nof_symb=%d, nof_re=%d\n", grant->nof_symb, grant->nof_re); INFO("Error converting ul_dci to grant, nof_symb=%d, nof_re=%d", grant->nof_symb, grant->nof_re);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }

@ -117,7 +117,7 @@ int regs_pdcch_init(srslte_regs_t* h)
} }
} }
h->pdcch[cfi].nof_regs = (h->pdcch[cfi].nof_regs / 9) * 9; h->pdcch[cfi].nof_regs = (h->pdcch[cfi].nof_regs / 9) * 9;
INFO("Init PDCCH REG space CFI %d. %d useful REGs (%d CCEs)\n", INFO("Init PDCCH REG space CFI %d. %d useful REGs (%d CCEs)",
cfi + 1, cfi + 1,
h->pdcch[cfi].nof_regs, h->pdcch[cfi].nof_regs,
h->pdcch[cfi].nof_regs / 9); h->pdcch[cfi].nof_regs / 9);
@ -139,7 +139,7 @@ clean_and_exit:
int srslte_regs_pdcch_nregs(srslte_regs_t* h, uint32_t cfi) int srslte_regs_pdcch_nregs(srslte_regs_t* h, uint32_t cfi)
{ {
if (cfi < 1 || cfi > 3) { if (cfi < 1 || cfi > 3) {
ERROR("Invalid CFI=%d\n", cfi); ERROR("Invalid CFI=%d", cfi);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} else { } else {
return (int)h->pdcch[cfi - 1].nof_regs; return (int)h->pdcch[cfi - 1].nof_regs;
@ -168,7 +168,7 @@ int srslte_regs_pdcch_put_offset(srslte_regs_t* h,
uint32_t nof_regs) uint32_t nof_regs)
{ {
if (cfi < 1 || cfi > 3) { if (cfi < 1 || cfi > 3) {
ERROR("Invalid CFI=%d\n", cfi); ERROR("Invalid CFI=%d", cfi);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (start_reg + nof_regs <= h->pdcch[cfi - 1].nof_regs) { if (start_reg + nof_regs <= h->pdcch[cfi - 1].nof_regs) {
@ -180,7 +180,7 @@ int srslte_regs_pdcch_put_offset(srslte_regs_t* h,
} }
return k; return k;
} else { } else {
ERROR("Out of range: start_reg + nof_reg must be lower than %d\n", h->pdcch[cfi - 1].nof_regs); ERROR("Out of range: start_reg + nof_reg must be lower than %d", h->pdcch[cfi - 1].nof_regs);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -188,7 +188,7 @@ int srslte_regs_pdcch_put_offset(srslte_regs_t* h,
int srslte_regs_pdcch_put(srslte_regs_t* h, uint32_t cfi, cf_t* d, cf_t* slot_symbols) int srslte_regs_pdcch_put(srslte_regs_t* h, uint32_t cfi, cf_t* d, cf_t* slot_symbols)
{ {
if (cfi < 1 || cfi > 3) { if (cfi < 1 || cfi > 3) {
ERROR("Invalid CFI=%d\n", cfi); ERROR("Invalid CFI=%d", cfi);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
return srslte_regs_pdcch_put_offset(h, cfi, d, slot_symbols, 0, h->pdcch[cfi - 1].nof_regs); return srslte_regs_pdcch_put_offset(h, cfi, d, slot_symbols, 0, h->pdcch[cfi - 1].nof_regs);
@ -202,7 +202,7 @@ int srslte_regs_pdcch_get_offset(srslte_regs_t* h,
uint32_t nof_regs) uint32_t nof_regs)
{ {
if (cfi < 1 || cfi > 3) { if (cfi < 1 || cfi > 3) {
ERROR("Invalid CFI=%d\n", cfi); ERROR("Invalid CFI=%d", cfi);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (start_reg + nof_regs <= h->pdcch[cfi - 1].nof_regs) { if (start_reg + nof_regs <= h->pdcch[cfi - 1].nof_regs) {
@ -214,7 +214,7 @@ int srslte_regs_pdcch_get_offset(srslte_regs_t* h,
} }
return k; return k;
} else { } else {
ERROR("Out of range: start_reg + nof_reg must be lower than %d\n", h->pdcch[cfi - 1].nof_regs); ERROR("Out of range: start_reg + nof_reg must be lower than %d", h->pdcch[cfi - 1].nof_regs);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -222,7 +222,7 @@ int srslte_regs_pdcch_get_offset(srslte_regs_t* h,
int srslte_regs_pdcch_get(srslte_regs_t* h, uint32_t cfi, cf_t* slot_symbols, cf_t* d) int srslte_regs_pdcch_get(srslte_regs_t* h, uint32_t cfi, cf_t* slot_symbols, cf_t* d)
{ {
if (cfi < 1 || cfi > 3) { if (cfi < 1 || cfi > 3) {
ERROR("Invalid CFI=%d\n", cfi); ERROR("Invalid CFI=%d", cfi);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
return srslte_regs_pdcch_get_offset(h, cfi, slot_symbols, d, 0, h->pdcch[cfi - 1].nof_regs); return srslte_regs_pdcch_get_offset(h, cfi, slot_symbols, d, 0, h->pdcch[cfi - 1].nof_regs);
@ -272,7 +272,7 @@ int regs_phich_init(srslte_regs_t* h, uint32_t phich_mi, bool mbsfn_or_sf1_6_tdd
perror("malloc"); perror("malloc");
return -1; return -1;
} }
INFO("Creating %d PHICH mapping units. %s length, Ng=%.2f\n", INFO("Creating %d PHICH mapping units. %s length, Ng=%.2f",
h->ngroups_phich, h->ngroups_phich,
h->phich_len == SRSLTE_PHICH_EXT ? "Extended" : "Normal", h->phich_len == SRSLTE_PHICH_EXT ? "Extended" : "Normal",
ng); ng);
@ -332,7 +332,7 @@ int regs_phich_init(srslte_regs_t* h, uint32_t phich_mi, bool mbsfn_or_sf1_6_tdd
} }
h->phich[mi].regs[i] = regs_phich[li][ni]; h->phich[mi].regs[i] = regs_phich[li][ni];
h->phich[mi].regs[i]->assigned = true; h->phich[mi].regs[i]->assigned = true;
DEBUG("Assigned PHICH REG#%d (%d,%d)\n", nreg, h->phich[mi].regs[i]->k0, li); DEBUG("Assigned PHICH REG#%d (%d,%d)", nreg, h->phich[mi].regs[i]->k0, li);
nreg++; nreg++;
} }
} }
@ -413,7 +413,7 @@ int srslte_regs_phich_add(srslte_regs_t* h, cf_t symbols[REGS_PHICH_NSYM], uint3
{ {
uint32_t i; uint32_t i;
if (ngroup >= h->ngroups_phich) { if (ngroup >= h->ngroups_phich) {
ERROR("Error invalid ngroup %d\n", ngroup); ERROR("Error invalid ngroup %d", ngroup);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
if (SRSLTE_CP_ISEXT(h->cell.cp)) { if (SRSLTE_CP_ISEXT(h->cell.cp)) {
@ -458,7 +458,7 @@ int srslte_regs_phich_get(srslte_regs_t* h, cf_t* slot_symbols, cf_t symbols[REG
{ {
uint32_t i; uint32_t i;
if (ngroup >= h->ngroups_phich) { if (ngroup >= h->ngroups_phich) {
ERROR("Error invalid ngroup %d\n", ngroup); ERROR("Error invalid ngroup %d", ngroup);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
if (SRSLTE_CP_ISEXT(h->cell.cp)) { if (SRSLTE_CP_ISEXT(h->cell.cp)) {
@ -493,22 +493,21 @@ int regs_pcfich_init(srslte_regs_t* h)
} }
ch->nof_regs = REGS_PCFICH_NREGS; ch->nof_regs = REGS_PCFICH_NREGS;
INFO("PCFICH allocating %d regs. CellID: %d, PRB: %d\n", ch->nof_regs, h->cell.id, h->cell.nof_prb); INFO("PCFICH allocating %d regs. CellID: %d, PRB: %d", ch->nof_regs, h->cell.id, h->cell.nof_prb);
k_hat = (SRSLTE_NRE / 2) * (h->cell.id % (2 * h->cell.nof_prb)); k_hat = (SRSLTE_NRE / 2) * (h->cell.id % (2 * h->cell.nof_prb));
for (i = 0; i < REGS_PCFICH_NREGS; i++) { for (i = 0; i < REGS_PCFICH_NREGS; i++) {
k = (k_hat + (i * h->cell.nof_prb / 2) * (SRSLTE_NRE / 2)) % (h->cell.nof_prb * SRSLTE_NRE); k = (k_hat + (i * h->cell.nof_prb / 2) * (SRSLTE_NRE / 2)) % (h->cell.nof_prb * SRSLTE_NRE);
ch->regs[i] = regs_find_reg(h, k, 0); ch->regs[i] = regs_find_reg(h, k, 0);
if (!ch->regs[i]) { if (!ch->regs[i]) {
ERROR("Error allocating PCFICH: REG (%d,0) not found\n", k); ERROR("Error allocating PCFICH: REG (%d,0) not found", k);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} else if (ch->regs[i]->assigned) { } else if (ch->regs[i]->assigned) {
ERROR("Error allocating PCFICH: REG (%d,0) already allocated\n", k); ERROR("Error allocating PCFICH: REG (%d,0) already allocated", k);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} else { } else {
ch->regs[i]->assigned = true; ch->regs[i]->assigned = true;
DEBUG("Assigned PCFICH REG#%d (%d,0)\n", i, k); DEBUG("Assigned PCFICH REG#%d (%d,0)", i, k);
} }
} }
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
@ -581,7 +580,6 @@ srslte_regs_reg_t* regs_find_reg(srslte_regs_t* h, uint32_t k, uint32_t l)
*/ */
int regs_num_x_symbol(uint32_t symbol, uint32_t nof_port, srslte_cp_t cp) int regs_num_x_symbol(uint32_t symbol, uint32_t nof_port, srslte_cp_t cp)
{ {
switch (symbol) { switch (symbol) {
case 0: case 0:
return 2; return 2;
@ -593,7 +591,7 @@ int regs_num_x_symbol(uint32_t symbol, uint32_t nof_port, srslte_cp_t cp)
case 4: case 4:
return 2; return 2;
default: default:
ERROR("Invalid number of ports %d\n", nof_port); ERROR("Invalid number of ports %d", nof_port);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
break; break;
@ -606,7 +604,7 @@ int regs_num_x_symbol(uint32_t symbol, uint32_t nof_port, srslte_cp_t cp)
return 2; return 2;
} }
default: default:
ERROR("Invalid symbol %d\n", symbol); ERROR("Invalid symbol %d", symbol);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -641,7 +639,7 @@ int regs_reg_init(srslte_regs_reg_t* reg, uint32_t symbol, uint32_t nreg, uint32
j++; j++;
} }
if (j != 4) { if (j != 4) {
ERROR("Something went wrong: expected 2 references\n"); ERROR("Something went wrong: expected 2 references");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
break; break;
@ -654,7 +652,7 @@ int regs_reg_init(srslte_regs_reg_t* reg, uint32_t symbol, uint32_t nreg, uint32
} }
break; break;
default: default:
ERROR("Invalid number of REGs per PRB: %d\n", maxreg); ERROR("Invalid number of REGs per PRB: %d", maxreg);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
@ -709,7 +707,7 @@ int srslte_regs_init_opts(srslte_regs_t* h, srslte_cell_t cell, uint32_t phich_m
} }
h->nof_regs += h->cell.nof_prb * n[i]; h->nof_regs += h->cell.nof_prb * n[i];
} }
INFO("Indexing %d REGs. CellId: %d, %d PRB, CP: %s\n", INFO("Indexing %d REGs. CellId: %d, %d PRB, CP: %s",
h->nof_regs, h->nof_regs,
h->cell.id, h->cell.id,
h->cell.nof_prb, h->cell.nof_prb,
@ -726,10 +724,10 @@ int srslte_regs_init_opts(srslte_regs_t* h, srslte_cell_t cell, uint32_t phich_m
while (k < h->nof_regs) { while (k < h->nof_regs) {
if (n[i] == 3 || (n[i] == 2 && jmax != 1)) { if (n[i] == 3 || (n[i] == 2 && jmax != 1)) {
if (regs_reg_init(&h->regs[k], i, j[i], prb * SRSLTE_NRE, n[i], vo)) { if (regs_reg_init(&h->regs[k], i, j[i], prb * SRSLTE_NRE, n[i], vo)) {
ERROR("Error initializing REGs\n"); ERROR("Error initializing REGs");
goto clean_and_exit; goto clean_and_exit;
} }
/*DEBUG("Available REG #%3d: l=%d, prb=%d, nreg=%d (k0=%d)\n", k, i, prb, j[i], /*DEBUG("Available REG #%3d: l=%d, prb=%d, nreg=%d (k0=%d)", k, i, prb, j[i],
h->regs[k].k0); h->regs[k].k0);
*/ */
j[i]++; j[i]++;
@ -747,18 +745,18 @@ int srslte_regs_init_opts(srslte_regs_t* h, srslte_cell_t cell, uint32_t phich_m
} }
} }
if (regs_pcfich_init(h)) { if (regs_pcfich_init(h)) {
ERROR("Error initializing PCFICH REGs\n"); ERROR("Error initializing PCFICH REGs");
goto clean_and_exit; goto clean_and_exit;
} }
h->phich_mi = phich_mi; h->phich_mi = phich_mi;
if (phich_mi > 0) { if (phich_mi > 0) {
if (regs_phich_init(h, phich_mi, mbsfn_or_sf1_6_tdd)) { if (regs_phich_init(h, phich_mi, mbsfn_or_sf1_6_tdd)) {
ERROR("Error initializing PHICH REGs\n"); ERROR("Error initializing PHICH REGs");
goto clean_and_exit; goto clean_and_exit;
} }
} }
if (regs_pdcch_init(h)) { if (regs_pdcch_init(h)) {
ERROR("Error initializing PDCCH REGs\n"); ERROR("Error initializing PDCCH REGs");
goto clean_and_exit; goto clean_and_exit;
} }

@ -39,7 +39,7 @@ static inline float get_beta_harq_offset(uint32_t idx)
if (idx < 15) { if (idx < 15) {
ret = beta_harq_offset[idx]; ret = beta_harq_offset[idx];
} else { } else {
ERROR("Invalid input %d (min: %d, max: %d)\n", idx, 0, 14); ERROR("Invalid input %d (min: %d, max: %d)", idx, 0, 14);
} }
return ret; return ret;
@ -55,7 +55,7 @@ static inline float get_beta_ri_offset(uint32_t idx)
if (idx < 13) { if (idx < 13) {
ret = beta_ri_offset[idx]; ret = beta_ri_offset[idx];
} else { } else {
ERROR("Invalid input %d (min: %d, max: %d)\n", idx, 0, 12); ERROR("Invalid input %d (min: %d, max: %d)", idx, 0, 12);
} }
return ret; return ret;
@ -71,7 +71,7 @@ static inline float get_beta_cqi_offset(uint32_t idx)
if (idx > 1 && idx < 16) { if (idx > 1 && idx < 16) {
ret = beta_cqi_offset[idx]; ret = beta_cqi_offset[idx];
} else { } else {
ERROR("Invalid input %d (min: %d, max: %d)\n", idx, 2, 15); ERROR("Invalid input %d (min: %d, max: %d)", idx, 2, 15);
} }
return ret; return ret;
@ -135,20 +135,20 @@ int srslte_sch_init(srslte_sch_t* q)
bzero(q, sizeof(srslte_sch_t)); bzero(q, sizeof(srslte_sch_t));
if (srslte_crc_init(&q->crc_tb, SRSLTE_LTE_CRC24A, 24)) { if (srslte_crc_init(&q->crc_tb, SRSLTE_LTE_CRC24A, 24)) {
ERROR("Error initiating CRC\n"); ERROR("Error initiating CRC");
goto clean; goto clean;
} }
if (srslte_crc_init(&q->crc_cb, SRSLTE_LTE_CRC24B, 24)) { if (srslte_crc_init(&q->crc_cb, SRSLTE_LTE_CRC24B, 24)) {
ERROR("Error initiating CRC\n"); ERROR("Error initiating CRC");
goto clean; goto clean;
} }
if (srslte_tcod_init(&q->encoder, SRSLTE_TCOD_MAX_LEN_CB)) { if (srslte_tcod_init(&q->encoder, SRSLTE_TCOD_MAX_LEN_CB)) {
ERROR("Error initiating Turbo Coder\n"); ERROR("Error initiating Turbo Coder");
goto clean; goto clean;
} }
if (srslte_tdec_init(&q->decoder, SRSLTE_TCOD_MAX_LEN_CB)) { if (srslte_tdec_init(&q->decoder, SRSLTE_TCOD_MAX_LEN_CB)) {
ERROR("Error initiating Turbo Decoder\n"); ERROR("Error initiating Turbo Decoder");
goto clean; goto clean;
} }
@ -242,14 +242,13 @@ static int encode_tb_off(srslte_sch_t* q,
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL && e_bits != NULL && cb_segm != NULL && softbuffer != NULL) { if (q != NULL && e_bits != NULL && cb_segm != NULL && softbuffer != NULL) {
if (cb_segm->F) { if (cb_segm->F) {
ERROR("Error filler bits are not supported. Use standard TBS\n"); ERROR("Error filler bits are not supported. Use standard TBS");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (cb_segm->C > softbuffer->max_cb) { if (cb_segm->C > softbuffer->max_cb) {
ERROR("Error number of CB to encode (%d) exceeds soft buffer size (%d CBs)\n", cb_segm->C, softbuffer->max_cb); ERROR("Error number of CB to encode (%d) exceeds soft buffer size (%d CBs)", cb_segm->C, softbuffer->max_cb);
return -1; return -1;
} }
@ -266,7 +265,6 @@ static int encode_tb_off(srslte_sch_t* q,
wp = 0; wp = 0;
rp = 0; rp = 0;
for (i = 0; i < cb_segm->C; i++) { for (i = 0; i < cb_segm->C; i++) {
uint32_t cblen_idx; uint32_t cblen_idx;
/* Get read lengths */ /* Get read lengths */
if (i < cb_segm->C2) { if (i < cb_segm->C2) {
@ -287,7 +285,7 @@ static int encode_tb_off(srslte_sch_t* q,
n_e = Qm * ((uint32_t)ceilf((float)Gp / cb_segm->C)); n_e = Qm * ((uint32_t)ceilf((float)Gp / cb_segm->C));
} }
INFO("CB#%d: cb_len: %d, rlen: %d, wp: %d, rp: %d, E: %d\n", i, cb_len, rlen, wp, rp, n_e); INFO("CB#%d: cb_len: %d, rlen: %d, wp: %d, rp: %d, E: %d", i, cb_len, rlen, wp, rp, n_e);
if (data) { if (data) {
bool last_cb = false; bool last_cb = false;
@ -297,7 +295,7 @@ static int encode_tb_off(srslte_sch_t* q,
// Copy data // Copy data
memcpy(q->cb_in, &data[rp / 8], rlen * sizeof(uint8_t) / 8); memcpy(q->cb_in, &data[rp / 8], rlen * sizeof(uint8_t) / 8);
} else { } else {
INFO("Last CB, appending parity: %d from %d and 24 to %d\n", rlen - 24, rp, rlen - 24); INFO("Last CB, appending parity: %d from %d and 24 to %d", rlen - 24, rp, rlen - 24);
/* Append Transport Block parity bits to the last CB */ /* Append Transport Block parity bits to the last CB */
memcpy(q->cb_in, &data[rp / 8], (rlen - 24) * sizeof(uint8_t) / 8); memcpy(q->cb_in, &data[rp / 8], (rlen - 24) * sizeof(uint8_t) / 8);
@ -315,7 +313,7 @@ static int encode_tb_off(srslte_sch_t* q,
cblen_idx, cblen_idx,
last_cb); last_cb);
} }
DEBUG("RM cblen_idx=%d, n_e=%d, wp=%d, nof_e_bits=%d\n", cblen_idx, n_e, wp, nof_e_bits); DEBUG("RM cblen_idx=%d, n_e=%d, wp=%d, nof_e_bits=%d", cblen_idx, n_e, wp, nof_e_bits);
/* Rate matching */ /* Rate matching */
if (srslte_rm_turbo_tx_lut(softbuffer->buffer_b[i], if (srslte_rm_turbo_tx_lut(softbuffer->buffer_b[i],
@ -326,7 +324,7 @@ static int encode_tb_off(srslte_sch_t* q,
n_e, n_e,
(wp + w_offset) % 8, (wp + w_offset) % 8,
rv)) { rv)) {
ERROR("Error in rate matching\n"); ERROR("Error in rate matching");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -335,10 +333,10 @@ static int encode_tb_off(srslte_sch_t* q,
wp += n_e; wp += n_e;
} }
INFO("END CB#%d: wp: %d, rp: %d\n", i, wp, rp); INFO("END CB#%d: wp: %d, rp: %d", i, wp, rp);
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;
} else { } else {
ERROR("Invalid parameters: e_bits=%d, cb_segm=%d, softbuffer=%d\n", e_bits != 0, cb_segm != 0, softbuffer != 0); ERROR("Invalid parameters: e_bits=%d, cb_segm=%d, softbuffer=%d", e_bits != 0, cb_segm != 0, softbuffer != 0);
} }
return ret; return ret;
} }
@ -364,12 +362,11 @@ bool decode_tb_cb(srslte_sch_t* q,
void* e_bits, void* e_bits,
uint8_t* data) uint8_t* data)
{ {
int8_t* e_bits_b = e_bits; int8_t* e_bits_b = e_bits;
int16_t* e_bits_s = e_bits; int16_t* e_bits_s = e_bits;
if (cb_segm->C > SRSLTE_MAX_CODEBLOCKS) { if (cb_segm->C > SRSLTE_MAX_CODEBLOCKS) {
ERROR("Error SRSLTE_MAX_CODEBLOCKS=%d\n", SRSLTE_MAX_CODEBLOCKS); ERROR("Error SRSLTE_MAX_CODEBLOCKS=%d", SRSLTE_MAX_CODEBLOCKS);
return false; return false;
} }
@ -378,7 +375,6 @@ bool decode_tb_cb(srslte_sch_t* q,
for (int cb_idx = 0; cb_idx < cb_segm->C; cb_idx++) { for (int cb_idx = 0; cb_idx < cb_segm->C; cb_idx++) {
/* Do not process blocks with CRC Ok */ /* Do not process blocks with CRC Ok */
if (softbuffer->cb_crc[cb_idx] == false) { if (softbuffer->cb_crc[cb_idx] == false) {
uint32_t cb_len = cb_idx < cb_segm->C1 ? cb_segm->K1 : cb_segm->K2; uint32_t cb_len = cb_idx < cb_segm->C1 ? cb_segm->K1 : cb_segm->K2;
uint32_t cb_len_idx = cb_idx < cb_segm->C1 ? cb_segm->K1_idx : cb_segm->K2_idx; uint32_t cb_len_idx = cb_idx < cb_segm->C1 ? cb_segm->K1_idx : cb_segm->K2_idx;
@ -397,12 +393,12 @@ bool decode_tb_cb(srslte_sch_t* q,
if (q->llr_is_8bit) { if (q->llr_is_8bit) {
if (srslte_rm_turbo_rx_lut_8bit(&e_bits_b[rp], (int8_t*)softbuffer->buffer_f[cb_idx], n_e2, cb_len_idx, rv)) { if (srslte_rm_turbo_rx_lut_8bit(&e_bits_b[rp], (int8_t*)softbuffer->buffer_f[cb_idx], n_e2, cb_len_idx, rv)) {
ERROR("Error in rate matching\n"); ERROR("Error in rate matching");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} else { } else {
if (srslte_rm_turbo_rx_lut(&e_bits_s[rp], softbuffer->buffer_f[cb_idx], n_e2, cb_len_idx, rv)) { if (srslte_rm_turbo_rx_lut(&e_bits_s[rp], softbuffer->buffer_f[cb_idx], n_e2, cb_len_idx, rv)) {
ERROR("Error in rate matching\n"); ERROR("Error in rate matching");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -434,7 +430,6 @@ bool decode_tb_cb(srslte_sch_t* q,
// CRC is OK // CRC is OK
if (!srslte_crc_checksum_byte(crc_ptr, &data[cb_idx * rlen / 8], len_crc)) { if (!srslte_crc_checksum_byte(crc_ptr, &data[cb_idx * rlen / 8], len_crc)) {
softbuffer->cb_crc[cb_idx] = true; softbuffer->cb_crc[cb_idx] = true;
early_stop = true; early_stop = true;
@ -444,7 +439,7 @@ bool decode_tb_cb(srslte_sch_t* q,
} while (cb_noi < q->max_iterations && !early_stop); } while (cb_noi < q->max_iterations && !early_stop);
INFO("CB %d: rp=%d, n_e=%d, cb_len=%d, CRC=%s, rlen=%d, iterations=%d/%d\n", INFO("CB %d: rp=%d, n_e=%d, cb_len=%d, CRC=%s, rlen=%d, iterations=%d/%d",
cb_idx, cb_idx,
rp, rp,
n_e2, n_e2,
@ -504,9 +499,7 @@ static int decode_tb(srslte_sch_t* q,
int16_t* e_bits, int16_t* e_bits,
uint8_t* data) uint8_t* data)
{ {
if (q != NULL && data != NULL && softbuffer != NULL && e_bits != NULL && cb_segm != NULL) { if (q != NULL && data != NULL && softbuffer != NULL && e_bits != NULL && cb_segm != NULL) {
if (cb_segm->tbs == 0 || cb_segm->C == 0) { if (cb_segm->tbs == 0 || cb_segm->C == 0) {
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
@ -534,7 +527,6 @@ static int decode_tb(srslte_sch_t* q,
crc_ok = decode_tb_cb(q, softbuffer, cb_segm, Qm, rv, nof_e_bits, e_bits, data); crc_ok = decode_tb_cb(q, softbuffer, cb_segm, Qm, rv, nof_e_bits, e_bits, data);
if (crc_ok) { if (crc_ok) {
uint32_t par_rx = 0, par_tx = 0; uint32_t par_rx = 0, par_tx = 0;
// Compute transport block CRC // Compute transport block CRC
@ -545,17 +537,17 @@ static int decode_tb(srslte_sch_t* q,
((uint32_t)data[cb_segm->tbs / 8 + 2]); ((uint32_t)data[cb_segm->tbs / 8 + 2]);
if (par_rx == par_tx && par_rx) { if (par_rx == par_tx && par_rx) {
INFO("TB decoded OK\n"); INFO("TB decoded OK");
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} else { } else {
INFO("Error in TB parity: par_tx=0x%x, par_rx=0x%x\n", par_tx, par_rx); INFO("Error in TB parity: par_tx=0x%x, par_rx=0x%x", par_tx, par_rx);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} else { } else {
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} else { } else {
ERROR("Missing inputs: data=%d, softbuffer=%d, e_bits=%d, cb_segm=%d\n", ERROR("Missing inputs: data=%d, softbuffer=%d, e_bits=%d, cb_segm=%d",
data != 0, data != 0,
softbuffer != 0, softbuffer != 0,
e_bits != 0, e_bits != 0,
@ -584,7 +576,7 @@ int srslte_dlsch_decode2(srslte_sch_t* q,
// Prepare cbsegm // Prepare cbsegm
srslte_cbsegm_t cb_segm; srslte_cbsegm_t cb_segm;
if (srslte_cbsegm(&cb_segm, (uint32_t)cfg->grant.tb[tb_idx].tbs)) { if (srslte_cbsegm(&cb_segm, (uint32_t)cfg->grant.tb[tb_idx].tbs)) {
ERROR("Error computing Codeword (%d) segmentation for TBS=%d\n", tb_idx, cfg->grant.tb[tb_idx].tbs); ERROR("Error computing Codeword (%d) segmentation for TBS=%d", tb_idx, cfg->grant.tb[tb_idx].tbs);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -631,7 +623,7 @@ int srslte_dlsch_encode2(srslte_sch_t* q,
// Prepare cbsegm // Prepare cbsegm
srslte_cbsegm_t cb_segm; srslte_cbsegm_t cb_segm;
if (srslte_cbsegm(&cb_segm, (uint32_t)cfg->grant.tb[tb_idx].tbs)) { if (srslte_cbsegm(&cb_segm, (uint32_t)cfg->grant.tb[tb_idx].tbs)) {
ERROR("Error computing Codeword (%d) segmentation for TBS=%d\n", tb_idx, cfg->grant.tb[tb_idx].tbs); ERROR("Error computing Codeword (%d) segmentation for TBS=%d", tb_idx, cfg->grant.tb[tb_idx].tbs);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -737,7 +729,6 @@ static void ulsch_interleave_qm4(uint8_t* g_bits,
/* First bits are aligned to byte */ /* First bits are aligned to byte */
if (0 == (bit_read_idx & 0x3)) { if (0 == (bit_read_idx & 0x3)) {
for (; i < (cols - 3); i += 4) { for (; i < (cols - 3); i += 4) {
uint8_t w1 = *(_g_bits++); uint8_t w1 = *(_g_bits++);
uint8_t w2 = *(_g_bits++); uint8_t w2 = *(_g_bits++);
@ -933,7 +924,7 @@ static void ulsch_interleave(uint8_t* g_bits,
uint8_t* ri_present) uint8_t* ri_present)
{ {
if (N_pusch_symbs == 0 || Qm == 0 || H_prime_total == 0 || H_prime_total < N_pusch_symbs) { if (N_pusch_symbs == 0 || Qm == 0 || H_prime_total == 0 || H_prime_total < N_pusch_symbs) {
ERROR("Invalid input: N_pusch_symbs=%d, Qm=%d, H_prime_total=%d, N_pusch_symbs=%d\n", ERROR("Invalid input: N_pusch_symbs=%d, Qm=%d, H_prime_total=%d, N_pusch_symbs=%d",
N_pusch_symbs, N_pusch_symbs,
Qm, Qm,
H_prime_total, H_prime_total,
@ -972,7 +963,7 @@ static void ulsch_interleave(uint8_t* g_bits,
break; break;
default: default:
/* This line should never be reached */ /* This line should never be reached */
ERROR("Wrong Qm (%d)\n", Qm); ERROR("Wrong Qm (%d)", Qm);
} }
// Reset temp_buffer because will be reused next time // Reset temp_buffer because will be reused next time
@ -1110,7 +1101,7 @@ int srslte_ulsch_decode(srslte_sch_t* q,
// Prepare cbsegm // Prepare cbsegm
srslte_cbsegm_t cb_segm; srslte_cbsegm_t cb_segm;
if (srslte_cbsegm(&cb_segm, (uint32_t)cfg->grant.tb.tbs)) { if (srslte_cbsegm(&cb_segm, (uint32_t)cfg->grant.tb.tbs)) {
ERROR("Error computing segmentation for TBS=%d\n", cfg->grant.tb.tbs); ERROR("Error computing segmentation for TBS=%d", cfg->grant.tb.tbs);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1121,7 +1112,7 @@ int srslte_ulsch_decode(srslte_sch_t* q,
// Decode RI/HARQ values // Decode RI/HARQ values
if ((ret = uci_decode_ri_ack(q, cfg, q_bits, c_seq, uci_data)) < 0) { if ((ret = uci_decode_ri_ack(q, cfg, q_bits, c_seq, uci_data)) < 0) {
ERROR("Error decoding RI/HARQ bits\n"); ERROR("Error decoding RI/HARQ bits");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1192,19 +1183,19 @@ int srslte_ulsch_encode(srslte_sch_t* q,
uint32_t Qm = srslte_mod_bits_x_symbol(cfg->grant.tb.mod); uint32_t Qm = srslte_mod_bits_x_symbol(cfg->grant.tb.mod);
if (Qm == 0) { if (Qm == 0) {
ERROR("Invalid input\n"); ERROR("Invalid input");
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
if (cfg->grant.nof_symb == 0) { if (cfg->grant.nof_symb == 0) {
ERROR("Invalid input\n"); ERROR("Invalid input");
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
// Prepare cbsegm // Prepare cbsegm
srslte_cbsegm_t cb_segm; srslte_cbsegm_t cb_segm;
if (srslte_cbsegm(&cb_segm, (uint32_t)cfg->grant.tb.tbs)) { if (srslte_cbsegm(&cb_segm, (uint32_t)cfg->grant.tb.tbs)) {
ERROR("Error computing segmentation for TBS=%d\n", cfg->grant.tb.tbs); ERROR("Error computing segmentation for TBS=%d", cfg->grant.tb.tbs);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -1217,7 +1208,7 @@ int srslte_ulsch_encode(srslte_sch_t* q,
if (cfg->uci_cfg.cqi.data_enable) { if (cfg->uci_cfg.cqi.data_enable) {
uci_cqi_len = (uint32_t)srslte_cqi_value_pack(&cfg->uci_cfg.cqi, &uci_data->cqi, cqi_buff); uci_cqi_len = (uint32_t)srslte_cqi_value_pack(&cfg->uci_cfg.cqi, &uci_data->cqi, cqi_buff);
if (uci_cqi_len < 0) { if (uci_cqi_len < 0) {
ERROR("Error encoding CQI bits\n"); ERROR("Error encoding CQI bits");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -1315,11 +1306,11 @@ int srslte_ulsch_encode(srslte_sch_t* q,
q_bits[p / 8] &= ~(1U << (7 - p % 8)); q_bits[p / 8] &= ~(1U << (7 - p % 8));
} }
} else { } else {
ERROR("Invalid RI/ACK bit %d/%d, position %d. Max bits=%d, Qm=%d\n", i, nof_ri_ack_bits, p, nb_q, Qm); ERROR("Invalid RI/ACK bit %d/%d, position %d. Max bits=%d, Qm=%d", i, nof_ri_ack_bits, p, nb_q, Qm);
} }
} }
INFO("Q_prime_ack=%d, Q_prime_cqi=%d, Q_prime_ri=%d\n", Q_prime_ack, Q_prime_cqi, Q_prime_ri); INFO("Q_prime_ack=%d, Q_prime_cqi=%d, Q_prime_ri=%d", Q_prime_ack, Q_prime_cqi, Q_prime_ri);
return nof_ri_ack_bits; return nof_ri_ack_bits;
} }

@ -81,18 +81,18 @@ int srslte_sch_nr_fill_cfg(srslte_sch_nr_t* q,
srslte_cbsegm_t cbsegm = {}; srslte_cbsegm_t cbsegm = {};
if (bg == BG1) { if (bg == BG1) {
if (srslte_cbsegm_ldpc_bg1(&cbsegm, tb->tbs) != SRSLTE_SUCCESS) { if (srslte_cbsegm_ldpc_bg1(&cbsegm, tb->tbs) != SRSLTE_SUCCESS) {
ERROR("Error: calculating LDPC BG1 code block segmentation for tbs=%d\n", tb->tbs); ERROR("Error: calculating LDPC BG1 code block segmentation for tbs=%d", tb->tbs);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} else { } else {
if (srslte_cbsegm_ldpc_bg2(&cbsegm, tb->tbs) != SRSLTE_SUCCESS) { if (srslte_cbsegm_ldpc_bg2(&cbsegm, tb->tbs) != SRSLTE_SUCCESS) {
ERROR("Error: calculating LDPC BG1 code block segmentation for tbs=%d\n", tb->tbs); ERROR("Error: calculating LDPC BG1 code block segmentation for tbs=%d", tb->tbs);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
if (cbsegm.Z > MAX_LIFTSIZE) { if (cbsegm.Z > MAX_LIFTSIZE) {
ERROR("Error: lifting size Z=%d is out-of-range maximum is %d\n", cbsegm.Z, MAX_LIFTSIZE); ERROR("Error: lifting size Z=%d is out-of-range maximum is %d", cbsegm.Z, MAX_LIFTSIZE);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -146,7 +146,7 @@ int srslte_sch_nr_fill_cfg(srslte_sch_nr_t* q,
static inline uint32_t sch_nr_get_E(const srslte_sch_nr_common_cfg_t* cfg, uint32_t j) static inline uint32_t sch_nr_get_E(const srslte_sch_nr_common_cfg_t* cfg, uint32_t j)
{ {
if (cfg->Nl == 0 || cfg->Qm == 0 || cfg->Cp == 0) { if (cfg->Nl == 0 || cfg->Qm == 0 || cfg->Cp == 0) {
ERROR("Invalid Nl (%d), Qm (%d) or Cp (%d)\n", cfg->Nl, cfg->Qm, cfg->Cp); ERROR("Invalid Nl (%d), Qm (%d) or Cp (%d)", cfg->Nl, cfg->Qm, cfg->Cp);
return 0; return 0;
} }
@ -211,12 +211,12 @@ int srslte_sch_nr_init_tx(srslte_sch_nr_t* q, const srslte_sch_nr_args_t* args)
q->encoder_bg1[ls] = calloc(1, sizeof(srslte_ldpc_encoder_t)); q->encoder_bg1[ls] = calloc(1, sizeof(srslte_ldpc_encoder_t));
if (!q->encoder_bg1[ls]) { if (!q->encoder_bg1[ls]) {
ERROR("Error: calloc\n"); ERROR("Error: calloc");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_ldpc_encoder_init(q->encoder_bg1[ls], encoder_type, BG1, ls) < SRSLTE_SUCCESS) { if (srslte_ldpc_encoder_init(q->encoder_bg1[ls], encoder_type, BG1, ls) < SRSLTE_SUCCESS) {
ERROR("Error: initialising BG1 LDPC encoder for ls=%d\n", ls); ERROR("Error: initialising BG1 LDPC encoder for ls=%d", ls);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -226,13 +226,13 @@ int srslte_sch_nr_init_tx(srslte_sch_nr_t* q, const srslte_sch_nr_args_t* args)
} }
if (srslte_ldpc_encoder_init(q->encoder_bg2[ls], encoder_type, BG2, ls) < SRSLTE_SUCCESS) { if (srslte_ldpc_encoder_init(q->encoder_bg2[ls], encoder_type, BG2, ls) < SRSLTE_SUCCESS) {
ERROR("Error: initialising BG2 LDPC encoder for ls=%d\n", ls); ERROR("Error: initialising BG2 LDPC encoder for ls=%d", ls);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
if (srslte_ldpc_rm_tx_init(&q->tx_rm) < SRSLTE_SUCCESS) { if (srslte_ldpc_rm_tx_init(&q->tx_rm) < SRSLTE_SUCCESS) {
ERROR("Error: initialising Tx LDPC Rate matching\n"); ERROR("Error: initialising Tx LDPC Rate matching");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -282,29 +282,29 @@ int srslte_sch_nr_init_rx(srslte_sch_nr_t* q, const srslte_sch_nr_args_t* args)
q->decoder_bg1[ls] = calloc(1, sizeof(srslte_ldpc_decoder_t)); q->decoder_bg1[ls] = calloc(1, sizeof(srslte_ldpc_decoder_t));
if (!q->decoder_bg1[ls]) { if (!q->decoder_bg1[ls]) {
ERROR("Error: calloc\n"); ERROR("Error: calloc");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_ldpc_decoder_init(q->decoder_bg1[ls], decoder_type, BG1, ls, scaling_factor) < SRSLTE_SUCCESS) { if (srslte_ldpc_decoder_init(q->decoder_bg1[ls], decoder_type, BG1, ls, scaling_factor) < SRSLTE_SUCCESS) {
ERROR("Error: initialising BG1 LDPC decoder for ls=%d\n", ls); ERROR("Error: initialising BG1 LDPC decoder for ls=%d", ls);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
q->decoder_bg2[ls] = calloc(1, sizeof(srslte_ldpc_decoder_t)); q->decoder_bg2[ls] = calloc(1, sizeof(srslte_ldpc_decoder_t));
if (!q->decoder_bg2[ls]) { if (!q->decoder_bg2[ls]) {
ERROR("Error: calloc\n"); ERROR("Error: calloc");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_ldpc_decoder_init(q->decoder_bg2[ls], decoder_type, BG2, ls, scaling_factor) < SRSLTE_SUCCESS) { if (srslte_ldpc_decoder_init(q->decoder_bg2[ls], decoder_type, BG2, ls, scaling_factor) < SRSLTE_SUCCESS) {
ERROR("Error: initialising BG2 LDPC decoder for ls=%d\n", ls); ERROR("Error: initialising BG2 LDPC decoder for ls=%d", ls);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
if (srslte_ldpc_rm_rx_init_c(&q->rx_rm) < SRSLTE_SUCCESS) { if (srslte_ldpc_rm_rx_init_c(&q->rx_rm) < SRSLTE_SUCCESS) {
ERROR("Error: initialising Rx LDPC Rate matching\n"); ERROR("Error: initialising Rx LDPC Rate matching");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -368,7 +368,7 @@ static inline int sch_nr_encode(srslte_sch_nr_t* q,
} }
if (!tb->softbuffer.tx) { if (!tb->softbuffer.tx) {
ERROR("Error: Missing Tx softbuffer\n"); ERROR("Error: Missing Tx softbuffer");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -382,19 +382,19 @@ static inline int sch_nr_encode(srslte_sch_nr_t* q,
// Check encoder // Check encoder
if (cfg.encoder == NULL) { if (cfg.encoder == NULL) {
ERROR("Error: encoder for lifting size Z=%d not found (tbs=%d)\n", cfg.Z, tb->tbs); ERROR("Error: encoder for lifting size Z=%d not found (tbs=%d)", cfg.Z, tb->tbs);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Check CRC for TB // Check CRC for TB
if (cfg.crc_tb == NULL) { if (cfg.crc_tb == NULL) {
ERROR("Error: CRC for TB not found\n"); ERROR("Error: CRC for TB not found");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Soft-buffer number of code-block protection // Soft-buffer number of code-block protection
if (tb->softbuffer.tx->max_cb < cfg.C) { if (tb->softbuffer.tx->max_cb < cfg.C) {
ERROR("Soft-buffer does not have enough code-blocks (max_cb=%d) for a TBS=%d, C=%d.\n", ERROR("Soft-buffer does not have enough code-blocks (max_cb=%d) for a TBS=%d, C=%d.",
tb->softbuffer.tx->max_cb, tb->softbuffer.tx->max_cb,
tb->tbs, tb->tbs,
cfg.C); cfg.C);
@ -402,7 +402,7 @@ static inline int sch_nr_encode(srslte_sch_nr_t* q,
} }
if (tb->softbuffer.tx->max_cb_size < (cfg.encoder->liftN - 2 * cfg.Z)) { if (tb->softbuffer.tx->max_cb_size < (cfg.encoder->liftN - 2 * cfg.Z)) {
ERROR("Soft-buffer code-block maximum size insufficient (max_cb_size=%d) for a TBS=%d, requires %d.\n", ERROR("Soft-buffer code-block maximum size insufficient (max_cb_size=%d) for a TBS=%d, requires %d.",
tb->softbuffer.tx->max_cb_size, tb->softbuffer.tx->max_cb_size,
tb->tbs, tb->tbs,
(cfg.encoder->liftN - 2 * cfg.Z)); (cfg.encoder->liftN - 2 * cfg.Z));
@ -422,7 +422,7 @@ static inline int sch_nr_encode(srslte_sch_nr_t* q,
// Select rate matching circular buffer // Select rate matching circular buffer
uint8_t* rm_buffer = tb->softbuffer.tx->buffer_b[r]; uint8_t* rm_buffer = tb->softbuffer.tx->buffer_b[r];
if (rm_buffer == NULL) { if (rm_buffer == NULL) {
ERROR("Error: soft-buffer provided NULL buffer for cb_idx=%d\n", r); ERROR("Error: soft-buffer provided NULL buffer for cb_idx=%d", r);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -440,7 +440,7 @@ static inline int sch_nr_encode(srslte_sch_nr_t* q,
// Append TB CRC // Append TB CRC
uint8_t* ptr = &q->temp_cb[cb_len]; uint8_t* ptr = &q->temp_cb[cb_len];
srslte_bit_unpack(checksum_tb, &ptr, cfg.L_tb); srslte_bit_unpack(checksum_tb, &ptr, cfg.L_tb);
SCH_INFO_TX("CB %d: appending TB CRC=%06x\n", r, checksum_tb); SCH_INFO_TX("CB %d: appending TB CRC=%06x", r, checksum_tb);
} else { } else {
// Copy payload // Copy payload
srslte_bit_unpack_vector(input_ptr, q->temp_cb, (int)cb_len); srslte_bit_unpack_vector(input_ptr, q->temp_cb, (int)cb_len);
@ -456,7 +456,7 @@ static inline int sch_nr_encode(srslte_sch_nr_t* q,
// Attach code block CRC if required // Attach code block CRC if required
if (cfg.L_cb) { if (cfg.L_cb) {
srslte_crc_attach(&q->crc_cb, q->temp_cb, (int)(cfg.Kp - cfg.L_cb)); srslte_crc_attach(&q->crc_cb, q->temp_cb, (int)(cfg.Kp - cfg.L_cb));
SCH_INFO_TX("CB %d: CRC=%06x\n", r, (uint32_t)srslte_crc_checksum_get(&q->crc_cb)); SCH_INFO_TX("CB %d: CRC=%06x", r, (uint32_t)srslte_crc_checksum_get(&q->crc_cb));
} }
// Insert filler bits // Insert filler bits
@ -483,7 +483,7 @@ static inline int sch_nr_encode(srslte_sch_nr_t* q,
j++; j++;
// LDPC Rate matching // LDPC Rate matching
SCH_INFO_TX("RM CB %d: E=%d; F=%d; BG=%d; Z=%d; RV=%d; Qm=%d; Nref=%d;\n", SCH_INFO_TX("RM CB %d: E=%d; F=%d; BG=%d; Z=%d; RV=%d; Qm=%d; Nref=%d;",
r, r,
E, E,
cfg.F, cfg.F,
@ -520,13 +520,13 @@ int sch_nr_decode(srslte_sch_nr_t* q,
// Check decoder // Check decoder
if (cfg.decoder == NULL) { if (cfg.decoder == NULL) {
ERROR("Error: decoder for lifting size Z=%d not found\n", cfg.Z); ERROR("Error: decoder for lifting size Z=%d not found", cfg.Z);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Check CRC for TB // Check CRC for TB
if (cfg.crc_tb == NULL) { if (cfg.crc_tb == NULL) {
ERROR("Error: CRC for TB not found\n"); ERROR("Error: CRC for TB not found");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -544,7 +544,7 @@ int sch_nr_decode(srslte_sch_nr_t* q,
bool decoded = tb->softbuffer.rx->cb_crc[r]; bool decoded = tb->softbuffer.rx->cb_crc[r];
int8_t* rm_buffer = (int8_t*)tb->softbuffer.tx->buffer_b[r]; int8_t* rm_buffer = (int8_t*)tb->softbuffer.tx->buffer_b[r];
if (!rm_buffer) { if (!rm_buffer) {
ERROR("Error: soft-buffer provided NULL buffer for cb_idx=%d\n", r); ERROR("Error: soft-buffer provided NULL buffer for cb_idx=%d", r);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -553,7 +553,7 @@ int sch_nr_decode(srslte_sch_nr_t* q,
if (decoded) { if (decoded) {
cb_ok++; cb_ok++;
} }
SCH_INFO_RX("RM CB %d: Disabled, CRC %s ... Skipping\n", r, decoded ? "OK" : "KO"); SCH_INFO_RX("RM CB %d: Disabled, CRC %s ... Skipping", r, decoded ? "OK" : "KO");
continue; continue;
} }
@ -563,13 +563,13 @@ int sch_nr_decode(srslte_sch_nr_t* q,
// Skip CB if it has a matched CRC // Skip CB if it has a matched CRC
if (decoded) { if (decoded) {
SCH_INFO_RX("RM CB %d: CRC OK ... Skipping\n", r); SCH_INFO_RX("RM CB %d: CRC OK ... Skipping", r);
cb_ok++; cb_ok++;
continue; continue;
} }
// LDPC Rate matching // LDPC Rate matching
SCH_INFO_RX("RM CB %d: E=%d; F=%d; BG=%d; Z=%d; RV=%d; Qm=%d; Nref=%d;\n", SCH_INFO_RX("RM CB %d: E=%d; F=%d; BG=%d; Z=%d; RV=%d; Qm=%d; Nref=%d;",
r, r,
E, E,
cfg.F, cfg.F,
@ -591,7 +591,7 @@ int sch_nr_decode(srslte_sch_nr_t* q,
uint32_t checksum2 = srslte_bit_pack(&ptr, cfg.L_cb); uint32_t checksum2 = srslte_bit_pack(&ptr, cfg.L_cb);
tb->softbuffer.rx->cb_crc[r] = (checksum1 == checksum2); tb->softbuffer.rx->cb_crc[r] = (checksum1 == checksum2);
SCH_INFO_RX("CB %d/%d: CRC={%06x, %06x} ... %s\n", SCH_INFO_RX("CB %d/%d: CRC={%06x, %06x} ... %s",
r, r,
cfg.C, cfg.C,
checksum1, checksum1,
@ -648,7 +648,7 @@ int sch_nr_decode(srslte_sch_nr_t* q,
uint32_t checksum1 = srslte_crc_checksum_byte(cfg.crc_tb, data, tb->tbs); uint32_t checksum1 = srslte_crc_checksum_byte(cfg.crc_tb, data, tb->tbs);
*crc_ok = (checksum1 == checksum2 && !all_zeros); *crc_ok = (checksum1 == checksum2 && !all_zeros);
SCH_INFO_RX("TB: TBS=%d; CRC={%06x, %06x}\n", tb->tbs, checksum1, checksum2); SCH_INFO_RX("TB: TBS=%d; CRC={%06x, %06x}", tb->tbs, checksum1, checksum2);
if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) { if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) {
DEBUG("Decode: "); DEBUG("Decode: ");
srslte_vec_fprint_byte(stdout, data, tb->tbs / 8); srslte_vec_fprint_byte(stdout, data, tb->tbs / 8);

@ -167,7 +167,7 @@ void srslte_sci_info(const srslte_sci_t* q, char* str, uint32_t len)
n = srslte_print_check(str, n = srslte_print_check(str,
SRSLTE_SCI_MSG_MAX_LEN, SRSLTE_SCI_MSG_MAX_LEN,
n, n,
", trp_idx=%i, t_adv=%i, n_sa_id=%i, freqhoppflg=%s\n", ", trp_idx=%i, t_adv=%i, n_sa_id=%i, freqhoppflg=%s",
q->trp_idx, q->trp_idx,
q->timing_advance, q->timing_advance,
q->N_sa_id, q->N_sa_id,
@ -176,7 +176,7 @@ void srslte_sci_info(const srslte_sci_t* q, char* str, uint32_t len)
n = srslte_print_check(str, n = srslte_print_check(str,
SRSLTE_SCI_MSG_MAX_LEN, SRSLTE_SCI_MSG_MAX_LEN,
n, n,
", priority=%i, res_rsrv=%i, t_gap=%i, rtx=%i, txformat=%d\n", ", priority=%i, res_rsrv=%i, t_gap=%i, rtx=%i, txformat=%d",
q->priority, q->priority,
q->resource_reserv, q->resource_reserv,
q->time_gap, q->time_gap,

@ -165,7 +165,7 @@ int base_init()
return -1; return -1;
} }
DEBUG("Memory init OK\n"); DEBUG("Memory init OK");
return 0; return 0;
} }
@ -216,7 +216,7 @@ int main(int argc, char** argv)
if (nread == SFLEN) { if (nread == SFLEN) {
// do IFFT and channel estimation only on subframes that are known to contain NRS // do IFFT and channel estimation only on subframes that are known to contain NRS
if (sf_idx == 0 || sf_idx == 4) { if (sf_idx == 0 || sf_idx == 4) {
INFO("%d.%d: Estimating channel.\n", frame_cnt, sf_idx); INFO("%d.%d: Estimating channel.", frame_cnt, sf_idx);
srslte_ofdm_rx_sf(&fft); srslte_ofdm_rx_sf(&fft);
// srslte_ofdm_set_normalize(&fft, true); // srslte_ofdm_set_normalize(&fft, true);
@ -229,10 +229,10 @@ int main(int argc, char** argv)
if (sf_idx == 0) { if (sf_idx == 0) {
float noise_est = (do_chest) ? srslte_chest_dl_nbiot_get_noise_estimate(&chest) : 0.0; float noise_est = (do_chest) ? srslte_chest_dl_nbiot_get_noise_estimate(&chest) : 0.0;
if (frame_cnt % 8 == 0) { if (frame_cnt % 8 == 0) {
DEBUG("Reseting NPBCH decoder.\n"); DEBUG("Reseting NPBCH decoder.");
srslte_npbch_decode_reset(&npbch); srslte_npbch_decode_reset(&npbch);
} }
INFO("%d.0: Calling NPBCH decoder (noise_est=%.2f)\n", frame_cnt, noise_est); INFO("%d.0: Calling NPBCH decoder (noise_est=%.2f)", frame_cnt, noise_est);
ret = srslte_npbch_decode_nf(&npbch, fft_buffer, ce, noise_est, bch_payload, &nof_tx_ports, NULL, nf); ret = srslte_npbch_decode_nf(&npbch, fft_buffer, ce, noise_est, bch_payload, &nof_tx_ports, NULL, nf);
if (ret == SRSLTE_SUCCESS) { if (ret == SRSLTE_SUCCESS) {
@ -246,10 +246,10 @@ int main(int argc, char** argv)
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
if (do_chest) { if (do_chest) {
DEBUG("SAVED FILE npbch_rx_chest_on.bin: NPBCH with chest\n"); DEBUG("SAVED FILE npbch_rx_chest_on.bin: NPBCH with chest");
srslte_vec_save_file("npbch_rx_chest_on.bin", npbch.d, npbch.nof_symbols * sizeof(cf_t)); srslte_vec_save_file("npbch_rx_chest_on.bin", npbch.d, npbch.nof_symbols * sizeof(cf_t));
} else { } else {
DEBUG("SAVED FILE npbch_rx_chest_off.bin: NPBCH without chest\n"); DEBUG("SAVED FILE npbch_rx_chest_off.bin: NPBCH without chest");
srslte_vec_save_file("npbch_rx_chest_off.bin", npbch.d, npbch.nof_symbols * sizeof(cf_t)); srslte_vec_save_file("npbch_rx_chest_off.bin", npbch.d, npbch.nof_symbols * sizeof(cf_t));
} }
} }

@ -75,7 +75,7 @@ void parse_args(int argc, char** argv)
case 'o': case 'o':
dci_format = srslte_dci_format_from_string(argv[optind]); dci_format = srslte_dci_format_from_string(argv[optind]);
if (dci_format == SRSLTE_DCI_NOF_FORMATS) { if (dci_format == SRSLTE_DCI_NOF_FORMATS) {
ERROR("Error unsupported format %s\n", argv[optind]); ERROR("Error unsupported format %s", argv[optind]);
exit(-1); exit(-1);
} }
break; break;
@ -177,7 +177,7 @@ int main(int argc, char** argv)
// Run FFT and estimate channel // Run FFT and estimate channel
srslte_ofdm_rx_sf(&fft); srslte_ofdm_rx_sf(&fft);
INFO("%d.%d: Estimating channel.\n", frame_cnt, tti % 10); INFO("%d.%d: Estimating channel.", frame_cnt, tti % 10);
srslte_chest_dl_nbiot_estimate(&chest, fft_buffer, ce, tti % 10); srslte_chest_dl_nbiot_estimate(&chest, fft_buffer, ce, tti % 10);
// Extract LLR // Extract LLR

@ -60,7 +60,7 @@ void parse_args(int argc, char** argv)
case 'o': case 'o':
dci_format = srslte_dci_format_from_string(argv[optind]); dci_format = srslte_dci_format_from_string(argv[optind]);
if (dci_format == SRSLTE_DCI_NOF_FORMATS) { if (dci_format == SRSLTE_DCI_NOF_FORMATS) {
ERROR("Error unsupported format %s\n", argv[optind]); ERROR("Error unsupported format %s", argv[optind]);
exit(-1); exit(-1);
} }
break; break;

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save