/** * * \section COPYRIGHT * * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the distribution. * */ #ifndef SRSRAN_PBCH_NR_H #define SRSRAN_PBCH_NR_H #include "srsran/phy/common/phy_common_nr.h" #include "srsran/phy/fec/crc.h" #include "srsran/phy/fec/polar/polar_code.h" #include "srsran/phy/fec/polar/polar_decoder.h" #include "srsran/phy/fec/polar/polar_encoder.h" #include "srsran/phy/fec/polar/polar_rm.h" #include "srsran/phy/modem/modem_table.h" /** * @brief NR PBCH payload size generated by higher layers, deduced from TS 38.331 MIB description */ #define SRSRAN_PBCH_NR_PAYLOAD_SZ 24 /** * @brief Describes the NR PBCH object initialisation arguments */ typedef struct SRSRAN_API { bool enable_encode; ///< Enable encoder bool enable_decode; ///< Enable decoder bool disable_simd; ///< Disable SIMD polar encoder/decoder } srsran_pbch_nr_args_t; /** * @brief Describes the NR PBCH configuration */ typedef struct SRSRAN_API { uint32_t N_id; ///< Physical cell identifier srsran_subcarrier_spacing_t ssb_scs; ///< SSB Subcarrier spacing uint32_t Lmax; ///< Number of SSB opportunities, described in TS 38.213 4.1 ... float beta; ///< Scaling factor for PBCH symbols, set to zero for default float beta_dmrs; ///< Scaling factor for PBCH DM-RS, set to zero for default } srsran_pbch_nr_cfg_t; /** * @brief Describes the NR PBCH object initialisation arguments */ typedef struct SRSRAN_API { srsran_polar_code_t code; srsran_polar_encoder_t polar_encoder; srsran_polar_decoder_t polar_decoder; srsran_polar_rm_t polar_rm_tx; srsran_polar_rm_t polar_rm_rx; srsran_crc_t crc; srsran_modem_table_t qpsk; } srsran_pbch_nr_t; /** * @brief Describes the PBCH message */ typedef struct SRSRAN_API { uint8_t payload[SRSRAN_PBCH_NR_PAYLOAD_SZ]; ///< Actual PBCH payload provided by higher layers uint8_t sfn_4lsb; ///< SFN 4 LSB uint8_t ssb_idx; ///< SS/PBCH blocks index described in TS 38.213 4.1 uint8_t k_ssb_msb; ///< Subcarrier offset MSB described in TS 38.211 7.4.3.1 bool hrf; ///< Half Radio Frame bit bool crc; ///< Decoder only, it is true only if the received CRC matches } srsran_pbch_msg_nr_t; /** * @brief Initialises an NR PBCH object with the provided arguments * @param q NR PBCH object * @param args Arguments providing the desired configuration * @return SRSRAN_SUCCESS if initialization is successful, SRSRAN_ERROR code otherwise */ SRSRAN_API int srsran_pbch_nr_init(srsran_pbch_nr_t* q, const srsran_pbch_nr_args_t* args); /** * @brief Deallocates an NR PBCH object * @param q NR PBCH object */ SRSRAN_API void srsran_pbch_nr_free(srsran_pbch_nr_t* q); /** * @brief Encodes an NR PBCH message into a SSB resource grid * @param q NR PBCH object * @param cfg NR PBCH configuration * @param msg NR PBCH message to transmit * @param[out] ssb_grid SSB resource grid * @return SRSRAN_SUCCESS if encoding is successful, SRSRAN_ERROR code otherwise */ SRSRAN_API int srsran_pbch_nr_encode(srsran_pbch_nr_t* q, const srsran_pbch_nr_cfg_t* cfg, const srsran_pbch_msg_nr_t* msg, cf_t ssb_grid[SRSRAN_SSB_NOF_RE]); /** * @brief Decodes an NR PBCH message in the SSB resource grid * @param q NR PBCH object * @param cfg NR PBCH configuration * @param ssb_idx SSB candidate index * @param[in] ssb_grid SSB resource grid * @param[in] ce Channel estimates for the SSB resource grid * @param msg NR PBCH message received * @return SRSRAN_SUCCESS if decoding is successful, SRSRAN_ERROR code otherwise */ SRSRAN_API int srsran_pbch_nr_decode(srsran_pbch_nr_t* q, const srsran_pbch_nr_cfg_t* cfg, uint32_t ssb_idx, const cf_t ssb_grid[SRSRAN_SSB_NOF_RE], const cf_t ce[SRSRAN_SSB_NOF_RE], srsran_pbch_msg_nr_t* msg); SRSRAN_API uint32_t srsran_pbch_msg_info(const srsran_pbch_msg_nr_t* msg, char* str, uint32_t str_len); #endif // SRSRAN_PBCH_NR_H