From 36207db615cf79b1d4bf9b31456c4653538e33cf Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Thu, 19 Aug 2021 15:50:03 +0200 Subject: [PATCH] Added CORESET start_rb helper function --- lib/include/srsran/phy/common/phy_common_nr.h | 12 +++++++++++ lib/src/phy/common/phy_common_nr.c | 20 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/lib/include/srsran/phy/common/phy_common_nr.h b/lib/include/srsran/phy/common/phy_common_nr.h index 9941df529..bf8270082 100644 --- a/lib/include/srsran/phy/common/phy_common_nr.h +++ b/lib/include/srsran/phy/common/phy_common_nr.h @@ -518,6 +518,18 @@ SRSRAN_API uint32_t srsran_coreset_get_bw(const srsran_coreset_t* coreset); */ SRSRAN_API uint32_t srsran_coreset_get_sz(const srsran_coreset_t* coreset); +/** + * @brief Calculates the starting resource block index in the resource grid + * + * @remark Intended to be used for common search space as specifies the lat clause in TS 38.214 section 5.1.2.2 Resource + * allocation in frequency domain + * + * @param coreset provides the given CORESET configuration + * @return The index of the lowest resource block in the resource grid used by the given CORESET if the CORESET + * configuration is valid; Otherwise, 0. + */ +SRSRAN_API uint32_t srsran_coreset_start_rb(const srsran_coreset_t* coreset); + /** * @brief Get the NR PDSCH mapping type in string * @param mapping_type Mapping type diff --git a/lib/src/phy/common/phy_common_nr.c b/lib/src/phy/common/phy_common_nr.c index 9a78bc310..c46dfd222 100644 --- a/lib/src/phy/common/phy_common_nr.c +++ b/lib/src/phy/common/phy_common_nr.c @@ -115,6 +115,26 @@ uint32_t srsran_coreset_get_sz(const srsran_coreset_t* coreset) return srsran_coreset_get_bw(coreset) * SRSRAN_NRE * coreset->duration; } +uint32_t srsran_coreset_start_rb(const srsran_coreset_t* coreset) +{ + // Protect CORESET access + if (coreset == NULL) { + return 0; + } + + // Iterates all the possible frequency resources trying to find the first enabled + for (uint32_t res = 0; res < SRSRAN_CORESET_FREQ_DOMAIN_RES_SIZE; res++) { + // If the frequency resource is enabled... + if (coreset->freq_resources[res]) { + // ... return the lowest resource block index + return 6 * res + coreset->offset_rb; + } + } + + // Returns the start resource index + return 0; +} + const char* srsran_sch_mapping_type_to_str(srsran_sch_mapping_type_t mapping_type) { switch (mapping_type) {