Fix NR TDD pattern configuration

master
Xavier Arteaga 4 years ago committed by Andre Puschmann
parent 21fe502448
commit 17a3c76540

@ -35,21 +35,6 @@ struct phy_cfg_nr_t {
phy_cfg_nr_t()
{
// tdd-UL-DL-ConfigurationCommon
// referenceSubcarrierSpacing: kHz15 (0)
// pattern1
// dl-UL-TransmissionPeriodicity: ms10 (7)
// nrofDownlinkSlots: 7
// nrofDownlinkSymbols: 6
// nrofUplinkSlots: 2
// nrofUplinkSymbols: 4
tdd.pattern1.period_ms = 10;
tdd.pattern1.nof_dl_slots = 7;
tdd.pattern1.nof_dl_symbols = 6;
tdd.pattern1.nof_ul_slots = 2;
tdd.pattern1.nof_ul_symbols = 4;
tdd.pattern2.period_ms = 0;
// physicalCellGroupConfig
// pdsch-HARQ-ACK-Codebook: dynamic (1)
harq_ack.harq_ack_codebook = srsran_pdsch_harq_ack_codebook_dynamic;

@ -259,6 +259,42 @@ bool make_phy_tdd_cfg(const tdd_ul_dl_cfg_common_s& tdd_ul_dl_cfg_common,
srsran_tdd_config_nr.pattern1.nof_ul_symbols = tdd_ul_dl_cfg_common.pattern1.nrof_ul_symbols;
// Copy and return struct
*in_srsran_tdd_config_nr = srsran_tdd_config_nr;
if (not tdd_ul_dl_cfg_common.pattern2_present) {
return true;
}
switch (tdd_ul_dl_cfg_common.pattern2.dl_ul_tx_periodicity) {
case tdd_ul_dl_pattern_s::dl_ul_tx_periodicity_opts::ms1:
srsran_tdd_config_nr.pattern2.period_ms = 1;
break;
case tdd_ul_dl_pattern_s::dl_ul_tx_periodicity_opts::ms2:
srsran_tdd_config_nr.pattern2.period_ms = 2;
break;
case tdd_ul_dl_pattern_s::dl_ul_tx_periodicity_opts::ms5:
srsran_tdd_config_nr.pattern2.period_ms = 5;
break;
case tdd_ul_dl_pattern_s::dl_ul_tx_periodicity_opts::ms10:
srsran_tdd_config_nr.pattern2.period_ms = 10;
break;
case tdd_ul_dl_pattern_s::dl_ul_tx_periodicity_opts::ms1p25:
case tdd_ul_dl_pattern_s::dl_ul_tx_periodicity_opts::ms0p5:
case tdd_ul_dl_pattern_s::dl_ul_tx_periodicity_opts::ms0p625:
case tdd_ul_dl_pattern_s::dl_ul_tx_periodicity_opts::ms2p5:
default:
asn1::log_warning("Invalid option for pattern2 dl_ul_tx_periodicity_opts %s",
tdd_ul_dl_cfg_common.pattern2.dl_ul_tx_periodicity.to_string());
return false;
}
srsran_tdd_config_nr.pattern2.nof_dl_slots = tdd_ul_dl_cfg_common.pattern2.nrof_dl_slots;
srsran_tdd_config_nr.pattern2.nof_dl_symbols = tdd_ul_dl_cfg_common.pattern2.nrof_dl_symbols;
srsran_tdd_config_nr.pattern2.nof_ul_slots = tdd_ul_dl_cfg_common.pattern2.nrof_ul_slots;
srsran_tdd_config_nr.pattern2.nof_ul_symbols = tdd_ul_dl_cfg_common.pattern2.nrof_ul_symbols;
// Copy and return struct
*in_srsran_tdd_config_nr = srsran_tdd_config_nr;
return true;
}

@ -179,10 +179,16 @@ float srsran_symbol_distance_s(uint32_t l0, uint32_t l1, uint32_t numerology)
bool srsran_tdd_nr_is_dl(const srsran_tdd_config_nr_t* cfg, uint32_t numerology, uint32_t slot_idx)
{
// Protect NULL pointer access
if (cfg == NULL) {
return false;
}
// Prevent zero division
if (cfg->pattern1.period_ms == 0 && cfg->pattern2.period_ms == 0) {
return false;
}
// Calculate slot index within the TDD overall period
uint32_t slot_x_ms = 1U << numerology; // Number of slots per millisecond
uint32_t period_sum = (cfg->pattern1.period_ms + cfg->pattern2.period_ms) * slot_x_ms; // Total perdiod sum
@ -195,16 +201,23 @@ bool srsran_tdd_nr_is_dl(const srsran_tdd_config_nr_t* cfg, uint32_t numerology,
slot_idx_period -= cfg->pattern1.period_ms * slot_x_ms; // Remove pattern 1 offset
}
// Check DL boundaries
return (slot_idx_period < pattern->nof_dl_slots ||
(slot_idx_period == pattern->nof_dl_slots && pattern->nof_dl_symbols != 0));
}
bool srsran_tdd_nr_is_ul(const srsran_tdd_config_nr_t* cfg, uint32_t numerology, uint32_t slot_idx)
{
// Protect NULL pointer access
if (cfg == NULL) {
return false;
}
// Prevent zero division
if (cfg->pattern1.period_ms == 0 && cfg->pattern2.period_ms == 0) {
return false;
}
// Calculate slot index within the TDD overall period
uint32_t slot_x_ms = 1U << numerology; // Number of slots per millisecond
uint32_t period_sum = (cfg->pattern1.period_ms + cfg->pattern2.period_ms) * slot_x_ms; // Total perdiod sum
@ -220,5 +233,6 @@ bool srsran_tdd_nr_is_ul(const srsran_tdd_config_nr_t* cfg, uint32_t numerology,
// Calculate slot in which UL starts
uint32_t start_ul = (pattern->period_ms * slot_x_ms - pattern->nof_ul_slots) - 1;
// Check UL boundaries
return (slot_idx_period > start_ul || (slot_idx_period == start_ul && pattern->nof_ul_symbols != 0));
}

Loading…
Cancel
Save