Added NR symbol offset helper function

master
Xavier Arteaga 4 years ago committed by Xavier Arteaga
parent 7450232b3e
commit 5e41e99f08

@ -533,6 +533,15 @@ SRSRAN_API srsran_mcs_table_t srsran_mcs_table_from_str(const char* str);
*/ */
SRSRAN_API uint32_t srsran_min_symbol_sz_rb(uint32_t nof_prb); SRSRAN_API uint32_t srsran_min_symbol_sz_rb(uint32_t nof_prb);
/**
* @brief Computes the time in seconds between the beginning of the slot and the given symbol
* @remark All symbol size reference and values are taken from TS 38.211 section 5.3 OFDM baseband signal generation
* @param l Given symbol index
* @param scs Subcarrier spacing
* @return Returns the symbol time offset in seconds
*/
SRSRAN_API float srsran_symbol_offset_s(uint32_t l, srsran_subcarrier_spacing_t scs);
/** /**
* @brief Computes the time in seconds between two symbols in a slot * @brief Computes the time in seconds between two symbols in a slot
* @note l0 is expected to be smaller than l1 * @note l0 is expected to be smaller than l1

@ -152,34 +152,40 @@ uint32_t srsran_min_symbol_sz_rb(uint32_t nof_prb)
return 0; return 0;
} }
float srsran_symbol_distance_s(uint32_t l0, uint32_t l1, srsran_subcarrier_spacing_t scs) float srsran_symbol_offset_s(uint32_t l, srsran_subcarrier_spacing_t scs)
{ {
// l0 must be smaller than l1
if (l0 >= l1) {
return 0.0f;
}
// Count number of symbols in between
uint32_t count = l1 - l0;
// Compute at what symbol there is a longer CP // Compute at what symbol there is a longer CP
uint32_t cp_boundary = 7U << (uint32_t)scs; uint32_t cp_boundary = 7U << (uint32_t)scs;
// Select whether extra CP shall be added // First symbol CP
uint32_t extra_cp = 0; uint32_t N = 160;
if (l0 < cp_boundary && l1 >= cp_boundary) {
extra_cp = 16;
}
// Compute reference FFT size // Symbols in between the first and l
uint32_t N = (2048 + 144) * count + extra_cp; N += (2048 + 144) * l;
// Add extra samples at the longer CP boundary
if (l >= cp_boundary) {
N += 16;
}
// Compute time using reference sampling rate
float TS = SRSRAN_LTE_TS / (float)(1U << (uint32_t)scs); float TS = SRSRAN_LTE_TS / (float)(1U << (uint32_t)scs);
// Return symbol distance in microseconds // Return symbol offset in seconds
return (float)N * TS; return (float)N * TS;
} }
float srsran_symbol_distance_s(uint32_t l0, uint32_t l1, srsran_subcarrier_spacing_t scs)
{
// l0 must be smaller than l1
if (l0 >= l1) {
return 0.0f;
}
// Return symbol distance in seconds
return srsran_symbol_offset_s(l1, scs) - srsran_symbol_offset_s(l0, scs);
}
bool srsran_tdd_nr_is_dl(const srsran_tdd_config_nr_t* cfg, uint32_t numerology, uint32_t slot_idx) bool srsran_tdd_nr_is_dl(const srsran_tdd_config_nr_t* cfg, uint32_t numerology, uint32_t slot_idx)
{ {
// Protect NULL pointer access // Protect NULL pointer access

Loading…
Cancel
Save