Commit 00106a7e authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/configurable_rounds_in_sim' into integration_2022_wk44

parents e9126363 847044a5
......@@ -74,13 +74,12 @@ void nr_fill_ulsch(PHY_VARS_gNB *gNB,
harq->slot=slot;
harq->handled = 0;
harq->status= NR_ACTIVE;
harq->new_rx = harq->ndi != ulsch_pdu->pusch_data.new_data_indicator;
if (harq->new_rx) {
harq->ndi = ulsch_pdu->pusch_data.new_data_indicator;
harq->new_rx = ulsch_pdu->pusch_data.new_data_indicator;
LOG_D(PHY,"ULSCH ID %d RNTI %x HARQ PID %d new data indicator %d\n",ulsch_id, ulsch_pdu->rnti, harq_pid, ulsch_pdu->pusch_data.new_data_indicator);
if (harq->new_rx)
harq->round = 0;
} else {
else
harq->round++;
}
memcpy((void*)&ulsch->harq_processes[harq_pid]->ulsch_pdu, (void*)ulsch_pdu, sizeof(nfapi_nr_pusch_pdu_t));
......
......@@ -104,7 +104,6 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations, uint16_t N_RB_UL)
ulsch->max_ldpc_iterations = max_ldpc_iterations;
for (i=0; i<NR_MAX_ULSCH_HARQ_PROCESSES; i++) {
ulsch->harq_processes[i] = (NR_UL_gNB_HARQ_t *)malloc16_clear(sizeof(NR_UL_gNB_HARQ_t));
ulsch->harq_processes[i]->b = (uint8_t*)malloc16_clear(ulsch_bytes);
ulsch->harq_processes[i]->c = (uint8_t**)malloc16_clear(a_segments*sizeof(uint8_t *));
......@@ -442,30 +441,16 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_ULSCH_DECODING,1);
harq_process->TBS = pusch_pdu->pusch_data.tb_size;
harq_process->round = nr_rv_to_round(pusch_pdu->pusch_data.rv_index);
harq_process->new_rx = false; // flag to indicate if this is a new reception for this harq (initialized to false)
dtx_det = 0;
if (harq_process->round == 0) {
harq_process->new_rx = true;
harq_process->ndi = pusch_pdu->pusch_data.new_data_indicator;
}
// this happens if there was a DTX in round 0
if (harq_process->ndi != pusch_pdu->pusch_data.new_data_indicator) {
harq_process->new_rx = true;
harq_process->ndi = pusch_pdu->pusch_data.new_data_indicator;
LOG_D(PHY,"Missed ULSCH detection. NDI toggled but rv %d does not correspond to first reception\n",pusch_pdu->pusch_data.rv_index);
}
A = (harq_process->TBS)<<3;
// target_code_rate is in 0.1 units
float Coderate = (float) pusch_pdu->target_code_rate / 10240.0f;
LOG_D(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, Coderate %f RV %d round %d\n",
harq_pid, A, G, mcs, n_layers, nb_rb, Qm, Coderate, pusch_pdu->pusch_data.rv_index, harq_process->round);
LOG_D(PHY,"ULSCH Decoding, harq_pid %d rnti %x TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, Coderate %f RV %d round %d new RX %d\n",
harq_pid, ulsch->rnti, A, G, mcs, n_layers, nb_rb, Qm, Coderate, pusch_pdu->pusch_data.rv_index, harq_process->round, harq_process->new_rx);
p_decParams->BG = pusch_pdu->maintenance_parms_v3.ldpcBaseGraph;
int kc;
......
......@@ -239,7 +239,6 @@ typedef struct {
uint32_t slot;
/// Index of current HARQ round for this DLSCH
uint8_t round;
uint8_t ndi;
bool new_rx;
/// Last TPC command
uint8_t TPC;
......
......@@ -379,17 +379,9 @@ int main(int argc, char **argv)
int i,aa;//,l;
double sigma2, sigma2_dB=10, SNR, snr0=-2.0, snr1=2.0;
uint8_t snr1set=0;
uint32_t errors_scrambling[4][100] = {{0}};
int n_errors[4][100] = {{0}};
int round_trials[4][100] = {{0}};
double roundStats[100] = {0};
double blerStats[4][100] = {{0}};
double berStats[4][100] = {{0}};
double snrStats[100] = {0};
float effRate;
//float psnr;
float eff_tp_check = 0.7;
uint8_t snrRun;
uint32_t TBS = 0;
int **txdata;
double **s_re,**s_im,**r_re,**r_im;
......@@ -471,7 +463,7 @@ int main(int argc, char **argv)
FILE *scg_fd=NULL;
while ((c = getopt (argc, argv, "f:hA:pf:g:i:n:s:S:t:x:y:z:M:N:F:GR:d:PI:L:Ea:b:e:m:w:T:U:q:X:Y")) != -1) {
while ((c = getopt(argc, argv, "f:hA:pf:g:i:n:s:S:t:v:x:y:z:M:N:F:GR:d:PI:L:Ea:b:e:m:w:T:U:q:X:Y")) != -1) {
switch (c) {
case 'f':
scg_fd = fopen(optarg,"r");
......@@ -577,6 +569,12 @@ int main(int argc, char **argv)
break;
case 'v':
num_rounds = atoi(optarg);
AssertFatal(num_rounds > 0 && num_rounds < 16, "Unsupported number of rounds %d, should be in [1,16]\n", num_rounds);
break;
case 'y':
n_tx=atoi(optarg);
......@@ -723,6 +721,7 @@ int main(int argc, char **argv)
printf("-T Enable PTRS, arguments list L_PTRS{0,1,2} K_PTRS{2,4}, e.g. -T 2 0 2 \n");
printf("-U Change DMRS Config, arguments list DMRS TYPE{0=A,1=B} DMRS AddPos{0:2} DMRS ConfType{1:2}, e.g. -U 3 0 2 1 \n");
printf("-P Print DLSCH performances\n");
printf("-v Maximum number of rounds\n");
printf("-w Write txdata to binary file (one frame)\n");
printf("-d number of dlsch threads, 0: no dlsch parallelization\n");
printf("-X gNB thread pool configuration, n => no threads\n");
......@@ -1034,7 +1033,6 @@ int main(int argc, char **argv)
nr_ue_phy_config_request(&UE_mac->phy_config);
//NR_COMMON_channels_t *cc = RC.nrmac[0]->common_channels;
snrRun = 0;
int n_errs = 0;
initNamedTpool(gNBthreads, &gNB->threadPool, true, "gNB-tpool");
......@@ -1065,6 +1063,13 @@ int main(int argc, char **argv)
clear_pdsch_stats(gNB);
uint32_t errors_scrambling[16] = {0};
int n_errors[16] = {0};
int round_trials[16] = {0};
double roundStats = {0};
double blerStats[16] = {0};
double berStats[16] = {0};
effRate = 0;
//n_errors2 = 0;
//n_alamouti = 0;
......@@ -1098,7 +1103,7 @@ int main(int argc, char **argv)
UE_harq_process->first_rx = 1;
while ((round<num_rounds) && (UE_harq_process->ack==0)) {
round_trials[round][snrRun]++;
round_trials[round]++;
clear_nr_nfapi_information(RC.nrmac[0], 0, frame, slot);
UE_info->UE_sched_ctrl.harq_processes[harq_pid].ndi = !(trial&1);
......@@ -1269,9 +1274,8 @@ int main(int argc, char **argv)
//---------------------- count errors ----------------------
//----------------------------------------------------------
if (UE->dlsch[0][0]->last_iteration_cnt >=
UE->dlsch[0][0]->max_ldpc_iterations+1)
n_errors[round][snrRun]++;
if (UE->dlsch[0][0]->last_iteration_cnt >= UE->dlsch[0][0]->max_ldpc_iterations + 1)
n_errors[round]++;
NR_UE_PDSCH **pdsch_vars = UE->pdsch_vars;
int16_t *UE_llr = pdsch_vars[0]->llr[0];
......@@ -1293,10 +1297,10 @@ int main(int argc, char **argv)
if(((gNB_dlsch->harq_process.f[i] == 0) && (UE_llr[i] <= 0)) ||
((gNB_dlsch->harq_process.f[i] == 1) && (UE_llr[i] >= 0)))
{
if(errors_scrambling[round][snrRun] == 0) {
if (errors_scrambling[round] == 0) {
LOG_D(PHY,"First bit in error in unscrambling = %d\n",i);
}
errors_scrambling[round][snrRun]++;
errors_scrambling[round]++;
}
}
......@@ -1324,51 +1328,34 @@ int main(int argc, char **argv)
if (n_trials == 1)
printf("errors_bit = %u (trial %d)\n", errors_bit, trial);
}
roundStats[snrRun]+=((float)round);
roundStats += ((float)round);
if (UE_harq_process->ack==1) effRate += ((float)TBS)/round;
} // noise trials
roundStats[snrRun]/=((float)n_trials);
roundStats /= ((float)n_trials);
blerStats[0][snrRun] = (double)n_errors[0][snrRun]/round_trials[0][snrRun];
blerStats[1][snrRun] = (double)n_errors[1][snrRun]/round_trials[1][snrRun];
blerStats[2][snrRun] = (double)n_errors[2][snrRun]/round_trials[2][snrRun];
blerStats[3][snrRun] = (double)n_errors[3][snrRun]/round_trials[3][snrRun];
berStats[0][snrRun] = (double)errors_scrambling[0][snrRun]/available_bits/round_trials[0][snrRun];
berStats[1][snrRun] = (double)errors_scrambling[1][snrRun]/available_bits/round_trials[1][snrRun];
berStats[2][snrRun] = (double)errors_scrambling[2][snrRun]/available_bits/round_trials[2][snrRun];
berStats[3][snrRun] = (double)errors_scrambling[3][snrRun]/available_bits/round_trials[3][snrRun];
for (int r = 0; r < num_rounds; r++) {
blerStats[r] = (double)n_errors[r] / round_trials[r];
berStats[r] = (double)errors_scrambling[r] / available_bits / round_trials[r];
}
effRate /= n_trials;
printf("*****************************************\n");
printf("SNR %f: n_errors (%d/%d,%d/%d,%d/%d,%d/%d) (negative CRC), false_positive %d/%d, errors_scrambling (%u/%u,%u/%u,%u/%u,%u/%u\n",
SNR,
n_errors[0][snrRun], round_trials[0][snrRun],
n_errors[1][snrRun], round_trials[1][snrRun],
n_errors[2][snrRun], round_trials[2][snrRun],
n_errors[3][snrRun], round_trials[3][snrRun],
n_false_positive, n_trials,
errors_scrambling[0][snrRun], available_bits*round_trials[0][snrRun],
errors_scrambling[1][snrRun], available_bits*round_trials[1][snrRun],
errors_scrambling[2][snrRun], available_bits*round_trials[2][snrRun],
errors_scrambling[3][snrRun], available_bits*round_trials[3][snrRun]);
printf("\n");
printf("SNR %f: n_errors (%d/%d", SNR, n_errors[0], round_trials[0]);
for (int r = 1; r < num_rounds; r++)
printf(",%d/%d", n_errors[r], round_trials[r]);
printf(") (negative CRC), false_positive %d/%d, errors_scrambling (%u/%u", n_false_positive, n_trials, errors_scrambling[0], available_bits * round_trials[0]);
for (int r = 1; r < num_rounds; r++)
printf(",%u/%u", errors_scrambling[r], available_bits * round_trials[r]);
printf(")\n\n");
dump_pdsch_stats(stdout,gNB);
printf("SNR %f: Channel BLER (%e,%e,%e,%e), Channel BER (%e,%e,%e,%e) Avg round %.2f, Eff Rate %.4f bits/slot, Eff Throughput %.2f, TBS %u bits/slot\n",
SNR,
blerStats[0][snrRun],
blerStats[1][snrRun],
blerStats[2][snrRun],
blerStats[3][snrRun],
berStats[0][snrRun],
berStats[1][snrRun],
berStats[2][snrRun],
berStats[3][snrRun],
roundStats[snrRun],
effRate,
effRate/TBS*100,
TBS);
printf("SNR %f: Channel BLER (%e", SNR, blerStats[0]);
for (int r = 1; r < num_rounds; r++)
printf(",%e", blerStats[r]);
printf("), Channel BER (%e", berStats[0]);
for (int r = 1; r < num_rounds; r++)
printf(",%e", berStats[r]);
printf(") Avg round %.2f, Eff Rate %.4f bits/slot, Eff Throughput %.2f, TBS %u bits/slot\n", roundStats, effRate, effRate / TBS * 100, TBS);
printf("*****************************************\n");
printf("\n");
......@@ -1442,24 +1429,9 @@ int main(int argc, char **argv)
break;
}
snrStats[snrRun] = SNR;
snrRun++;
n_errs = n_errors[0][snrRun];
n_errs = n_errors[0];
} // NSR
LOG_M("dlsimStats.m","SNR",snrStats,snrRun,1,7);
LOG_MM("dlsimStats.m","BLER",blerStats,snrRun,1,7);
LOG_MM("dlsimStats.m","BER",berStats,snrRun,1,7);
LOG_MM("dlsimStats.m","rounds",roundStats,snrRun,1,7);
/*if (n_trials>1) {
printf("HARQ stats:\nSNR\tRounds\n");
psnr = snr0;
for (uint8_t i=0; i<snrRun; i++) {
printf("%.1f\t%.2f\n",psnr,roundStats[i]);
psnr+=0.2;
}
}*/
free_channel_desc_scm(gNB2UE);
for (i = 0; i < n_tx; i++) {
......
This diff is collapsed.
......@@ -833,6 +833,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t
NULL,
ra->Msg3_tda_id,
ra->msg3_TPC,
1, // Not toggling NDI in msg3 retransmissions
&ra->UL_BWP);
fill_dci_pdu_rel15(scc,
......@@ -1036,7 +1037,7 @@ void fill_msg3_pusch_pdu(nfapi_nr_pusch_pdu_t *pusch_pdu,
//Optional Data only included if indicated in pduBitmap
pusch_pdu->pusch_data.rv_index = nr_rv_round_map[round%4];
pusch_pdu->pusch_data.harq_process_id = 0;
pusch_pdu->pusch_data.new_data_indicator = 1;
pusch_pdu->pusch_data.new_data_indicator = (round == 0) ? 1 : 0;;
pusch_pdu->pusch_data.num_cb = 0;
int num_dmrs_symb = 0;
for(int i = start_symbol_index; i < start_symbol_index+nr_of_symbols; i++)
......
......@@ -885,6 +885,7 @@ void config_uldci(const NR_SIB1_t *sib1,
nr_srs_feedback_t *srs_feedback,
int time_domain_assignment,
uint8_t tpc,
uint8_t ndi,
NR_UE_UL_BWP_t *ul_bwp) {
int bwp_id = ul_bwp->bwp_id;
......@@ -895,7 +896,7 @@ void config_uldci(const NR_SIB1_t *sib1,
dci_pdu_rel15->time_domain_assignment.val = time_domain_assignment;
dci_pdu_rel15->frequency_hopping_flag.val = pusch_pdu->frequency_hopping;
dci_pdu_rel15->mcs = pusch_pdu->mcs_index;
dci_pdu_rel15->ndi = pusch_pdu->pusch_data.new_data_indicator;
dci_pdu_rel15->ndi = ndi;
dci_pdu_rel15->rv = pusch_pdu->pusch_data.rv_index;
dci_pdu_rel15->harq_pid = pusch_pdu->pusch_data.harq_process_id;
dci_pdu_rel15->tpc = tpc;
......
......@@ -2171,7 +2171,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot)
AssertFatal(cur_harq->round < nr_mac->ul_bler.harq_round_max, "Indexing nr_rv_round_map[%d] is out of bounds\n", cur_harq->round%4);
pusch_pdu->pusch_data.rv_index = nr_rv_round_map[cur_harq->round%4];
pusch_pdu->pusch_data.harq_process_id = harq_id;
pusch_pdu->pusch_data.new_data_indicator = cur_harq->ndi;
pusch_pdu->pusch_data.new_data_indicator = (cur_harq->round == 0) ? 1 : 0; // not NDI but indicator for new transmission
pusch_pdu->pusch_data.tb_size = sched_pusch->tb_size;
pusch_pdu->pusch_data.num_cb = 0; //CBG not supported
......@@ -2275,6 +2275,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot)
&sched_ctrl->srs_feedback,
sched_pusch->time_domain_allocation,
UE->UE_sched_ctrl.tpc0,
cur_harq->ndi,
current_BWP);
fill_dci_pdu_rel15(scc,
......
......@@ -192,6 +192,7 @@ void config_uldci(const NR_SIB1_t *sib1,
nr_srs_feedback_t *srs_feedback,
int time_domain_assignment,
uint8_t tpc,
uint8_t ndi,
NR_UE_UL_BWP_t *ul_bwp);
void nr_schedule_pucch(gNB_MAC_INST *nrmac,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment