diff --git a/lib/include/srslte/phy/common/phy_common_nr.h b/lib/include/srslte/phy/common/phy_common_nr.h index 21ed49489..0f8f029e3 100644 --- a/lib/include/srslte/phy/common/phy_common_nr.h +++ b/lib/include/srslte/phy/common/phy_common_nr.h @@ -311,6 +311,14 @@ SRSLTE_API const char* srslte_mcs_table_to_str(srslte_mcs_table_t mcs_table); */ SRSLTE_API srslte_mcs_table_t srslte_mcs_table_from_str(const char* str); +/** + * @brief Computes the minimum valid symbol size for a given amount of PRB + * @attention The valid FFT sizes are radix 2 and radix 3 between 128 to 4096 points. + * @param nof_prb Number of PRB + * @return The minimum valid FFT size if the number of PRB is in range, 0 otherwise + */ +SRSLTE_API uint32_t srslte_min_symbol_sz_rb(uint32_t nof_prb); + #ifdef __cplusplus } #endif diff --git a/lib/include/srslte/phy/dft/ofdm.h b/lib/include/srslte/phy/dft/ofdm.h index 5d4517bad..9494e6fbd 100644 --- a/lib/include/srslte/phy/dft/ofdm.h +++ b/lib/include/srslte/phy/dft/ofdm.h @@ -76,8 +76,28 @@ typedef struct SRSLTE_API { cf_t* window_offset_buffer; } srslte_ofdm_t; +/** + * @brief Initialises or reconfigures OFDM receiver + * + * @note The reconfiguration of the OFDM object considers only CP, number of PRB and optionally the FFT size + * @attention The OFDM object must be zeroed externally prior calling the initialization for first time + * + * @param q OFDM object + * @param cfg OFDM configuration + * @return SRSLTE_SUCCESS if the initialization/reconfiguration is successful, SRSLTE_ERROR code otherwise + */ SRSLTE_API int srslte_ofdm_rx_init_cfg(srslte_ofdm_t* q, srslte_ofdm_cfg_t* cfg); +/** + * @brief Initialises or reconfigures OFDM transmitter + * + * @note The reconfiguration of the OFDM object considers only CP, number of PRB and optionally the FFT size + * @attention The OFDM object must be zeroed externally prior calling the initialization for first time + * + * @param q OFDM object + * @param cfg OFDM configuration + * @return SRSLTE_SUCCESS if the initialization/reconfiguration is successful, SRSLTE_ERROR code otherwise + */ SRSLTE_API int srslte_ofdm_tx_init_cfg(srslte_ofdm_t* q, srslte_ofdm_cfg_t* cfg); SRSLTE_API int diff --git a/lib/src/phy/common/phy_common_nr.c b/lib/src/phy/common/phy_common_nr.c index 37cc6e51c..3b3cf498d 100644 --- a/lib/src/phy/common/phy_common_nr.c +++ b/lib/src/phy/common/phy_common_nr.c @@ -74,3 +74,25 @@ srslte_mcs_table_t srslte_mcs_table_from_str(const char* str) } return srslte_mcs_table_N; } + +#define PHY_COMMON_NR_NOF_VALID_SYMB_SZ 10U + +static const uint32_t phy_common_nr_valid_symbol_sz[PHY_COMMON_NR_NOF_VALID_SYMB_SZ] = + {128, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096}; + +uint32_t srslte_min_symbol_sz_rb(uint32_t nof_prb) +{ + uint32_t nof_re = nof_prb * SRSLTE_NRE; + + if (nof_re == 0) { + return 0; + } + + for (uint32_t i = 0; i < PHY_COMMON_NR_NOF_VALID_SYMB_SZ; i++) { + if (phy_common_nr_valid_symbol_sz[i] > nof_re) { + return phy_common_nr_valid_symbol_sz[i]; + } + } + + return 0; +} diff --git a/lib/src/phy/dft/ofdm.c b/lib/src/phy/dft/ofdm.c index 9de0a0aaa..30794014c 100644 --- a/lib/src/phy/dft/ofdm.c +++ b/lib/src/phy/dft/ofdm.c @@ -276,15 +276,11 @@ int srslte_ofdm_tx_init(srslte_ofdm_t* q, srslte_cp_t cp, cf_t* in_buffer, cf_t* int srslte_ofdm_tx_init_cfg(srslte_ofdm_t* q, srslte_ofdm_cfg_t* cfg) { - bzero(q, sizeof(srslte_ofdm_t)); - return ofdm_init_mbsfn_(q, cfg, SRSLTE_DFT_BACKWARD); } int srslte_ofdm_rx_init_cfg(srslte_ofdm_t* q, srslte_ofdm_cfg_t* cfg) { - bzero(q, sizeof(srslte_ofdm_t)); - return ofdm_init_mbsfn_(q, cfg, SRSLTE_DFT_FORWARD); } diff --git a/lib/src/phy/ue/ue_dl_nr.c b/lib/src/phy/ue/ue_dl_nr.c index 79896631e..c669d959e 100644 --- a/lib/src/phy/ue/ue_dl_nr.c +++ b/lib/src/phy/ue/ue_dl_nr.c @@ -138,7 +138,11 @@ int srslte_ue_dl_nr_set_carrier(srslte_ue_dl_nr_t* q, const srslte_carrier_nr_t* if (carrier->nof_prb != q->carrier.nof_prb) { for (uint32_t i = 0; i < q->nof_rx_antennas; i++) { - srslte_ofdm_rx_set_prb(&q->fft[i], SRSLTE_CP_NORM, carrier->nof_prb); + srslte_ofdm_cfg_t cfg = {}; + cfg.nof_prb = carrier->nof_prb; + cfg.symbol_sz = srslte_min_symbol_sz_rb(carrier->nof_prb); + cfg.cp = SRSLTE_CP_NORM; + srslte_ofdm_rx_init_cfg(&q->fft[i], &cfg); } }