bugfix,tpc: only cap PUSCH TPC when PHR is negative. I also extended TPC unit test

master
Francisco 3 years ago committed by Francisco Paisana
parent bdc4362475
commit 9e2a7d4592

@ -173,10 +173,9 @@ private:
// more time required before sending next TPC
return encode_tpc_delta(0);
}
if (last_phr < 0 and not ch_snr.phr_flag) {
// negative PHR
logger.info(
"TPC: rnti=0x%x, %s command=-1 due to PHR=%d < 0", rnti, cc == PUSCH_CODE ? "PUSCH" : "PUCCH", last_phr);
if (cc == PUSCH_CODE and last_phr < 0 and not ch_snr.phr_flag) {
// if negative PHR and PUSCH
logger.info("TPC: rnti=0x%x, PUSCH command=0 due to PHR=%d<0", rnti, last_phr);
ch_snr.phr_flag = true;
return encode_tpc_delta(-1);
}
@ -185,8 +184,11 @@ private:
float diff = target_snr_dB - ch_snr.snr_avg.value();
diff -= ch_snr.win_tpc_values.value() + ch_snr.acc_tpc_values;
if (diff >= 1) {
diff = std::min(diff, (float)std::max(last_phr, 0)); // low PHR places a cap on TPC
ch_snr.pending_delta = diff > 3 ? 3 : 1;
ch_snr.pending_delta = diff > 3 ? 3 : 1;
if (cc == PUSCH_CODE and static_cast<int>(ch_snr.pending_delta) > last_phr) {
// cap PUSCH TPC when PHR is low
ch_snr.pending_delta = last_phr > 1 ? 1 : 0;
}
ch_snr.last_tpc_tti_count = tti_count;
} else if (diff <= -1) {
ch_snr.pending_delta = -1;

@ -71,6 +71,25 @@ int test_finite_target_snr()
TESTASSERT(sum_pucch > 0 and sum_pucch <= -snr_diff);
}
// TEST: PHR is negative. Checks:
// - one TPC should be sent to decrease power. No more TPCs != 0 should be sent until the next PHR
snr_diff = -10;
tpcfsm.set_snr(target_snr + snr_diff, tpc::PUSCH_CODE);
tpcfsm.set_snr(target_snr + snr_diff, tpc::PUCCH_CODE);
for (uint32_t i = 0; i < 3; ++i) {
tpcfsm.set_phr(-2, 1);
tpcfsm.new_tti();
TESTASSERT(decode_tpc(tpcfsm.encode_pusch_tpc()) == -1);
TESTASSERT(decode_tpc(tpcfsm.encode_pucch_tpc()) == 3); // PUCCH doesnt get affected by neg PHR
for (uint32_t j = 0; j < 100; ++j) {
tpcfsm.new_tti();
TESTASSERT(decode_tpc(tpcfsm.encode_pusch_tpc()) == 0);
}
}
tpcfsm.set_phr(20, 1);
tpcfsm.new_tti();
TESTASSERT(decode_tpc(tpcfsm.encode_pusch_tpc()) == 3);
return SRSRAN_SUCCESS;
}

Loading…
Cancel
Save