Commit 56a4157b authored by Elena_Lukashova's avatar Elena_Lukashova

Adding HARQ support for TM4. No fallback to Alamouti yet.

Counting for the number of 2CWs or 1CW retransmissions.
Adding corresponding changes to the phy_scope.
parent 25304e46
......@@ -984,8 +984,8 @@ void phy_init_lte_ue__PDSCH( LTE_UE_PDSCH* const pdsch, const LTE_DL_FRAME_PARMS
pdsch->dl_ch_estimates_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
pdsch->dl_ch_mag0 = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
pdsch->dl_ch_magb0 = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
pdsch->dl_ch_mag1 = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
pdsch->dl_ch_magb1 = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
//pdsch->dl_ch_mag1 = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
//pdsch->dl_ch_magb1 = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
// the allocated memory size is fixed:
AssertFatal( frame_parms->nb_antennas_rx <= 2, "nb_antennas_rx > 2" );
......@@ -999,8 +999,8 @@ void phy_init_lte_ue__PDSCH( LTE_UE_PDSCH* const pdsch, const LTE_DL_FRAME_PARMS
pdsch->dl_ch_estimates_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
pdsch->dl_ch_mag0[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
pdsch->dl_ch_magb0[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
pdsch->dl_ch_mag1[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
pdsch->dl_ch_magb1[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
//pdsch->dl_ch_mag1[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
//pdsch->dl_ch_magb1[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
}
}
}
......@@ -1187,6 +1187,9 @@ int phy_init_lte_ue(PHY_VARS_UE *phy_vars_ue,
for (l=0;l<8;l++) { //round
ue_pdsch_vars[eNB_id]->rxdataF_comp1[k][l] = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
ue_pdsch_vars[eNB_id]->dl_ch_rho_ext[k][l] = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
ue_pdsch_vars[eNB_id]->dl_ch_mag1[k][l] = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
ue_pdsch_vars[eNB_id]->dl_ch_magb1[k][l] = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
// ue_pdsch_vars[eNB_id]->clean_x1[k][l] = (int16_t*)malloc16_clear( sizeof(int32_t) * num);
for (int i=0; i<frame_parms->nb_antennas_rx; i++)
......@@ -1194,6 +1197,8 @@ int phy_init_lte_ue(PHY_VARS_UE *phy_vars_ue,
const int idx = (j<<1)+i;
ue_pdsch_vars[eNB_id]->dl_ch_rho_ext[k][l][idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
ue_pdsch_vars[eNB_id]->rxdataF_comp1[k][l][idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
ue_pdsch_vars[eNB_id]->dl_ch_mag1[k][l][idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
ue_pdsch_vars[eNB_id]->dl_ch_magb1[k][l][idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
}
}
}
......
......@@ -1551,7 +1551,7 @@ int generate_eNB_dlsch_params_from_dci(int frame,
}
if (frame_parms->nb_antennas_tx == 2) {
if (dlsch1->active == 1) { // both TBs are active
if (dlsch0->active == 1 && dlsch1->active == 1) { // both TBs are active
dlsch0_harq->dl_power_off = 1;
dlsch1_harq->dl_power_off = 1;
......@@ -1581,7 +1581,7 @@ int generate_eNB_dlsch_params_from_dci(int frame,
break;
}
}
else { // only one is active
else if (dlsch1->active == 0) { // only one is active
dlsch0_harq->dl_power_off = 1;
dlsch0_harq->TBS= TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1];
switch (tpmi) {
......@@ -1614,6 +1614,39 @@ int generate_eNB_dlsch_params_from_dci(int frame,
break;
}
}
else if (dlsch0->active == 0) { // only one is active
dlsch1_harq->dl_power_off = 1;
dlsch1_harq->TBS= TBStable[get_I_TBS(dlsch1_harq->mcs)][dlsch1_harq->nb_rb-1];
switch (tpmi) {
case 0 :
dlsch1_harq->mimo_mode = ALAMOUTI;
break;
case 1:
dlsch1_harq->mimo_mode = UNIFORM_PRECODING11;
dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,0,0);
break;
case 2:
dlsch1_harq->mimo_mode = UNIFORM_PRECODING1m1;
dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,1,0);
break;
case 3:
dlsch1_harq->mimo_mode = UNIFORM_PRECODING1j;
dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,2,0);
break;
case 4:
dlsch1_harq->mimo_mode = UNIFORM_PRECODING1mj;
dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,3,0);
break;
case 5:
dlsch1_harq->mimo_mode = PUSCH_PRECODING0;
dlsch1_harq->pmi_alloc = DL_pmi_single;
break;
case 6:
dlsch1_harq->mimo_mode = PUSCH_PRECODING1;
dlsch1_harq->pmi_alloc = DL_pmi_single;
break;
}
}
} else if (frame_parms->nb_antennas_tx == 4) {
// fill in later
}
......@@ -2670,6 +2703,20 @@ int generate_eNB_dlsch_params_from_dci(int frame,
printf("dlsch0 eNB: mimo_mode %d\n",dlsch0_harq->mimo_mode);
}
if (dlsch1) {
printf("dlsch1 eNB: dlsch1 %p\n",dlsch1);
printf("dlsch1 eNB: rnti %x\n",dlsch1->rnti);
printf("dlsch1 eNB: NBRB %d\n",dlsch1_harq->nb_rb);
printf("dlsch1 eNB: rballoc %x\n",dlsch1_harq->rb_alloc[0]);
printf("dlsch1 eNB: harq_pid %d\n",harq_pid);
printf("dlsch1 eNB: round %d\n",dlsch1_harq->round);
printf("dlsch1 eNB: rvidx %d\n",dlsch1_harq->rvidx);
printf("dlsch1 eNB: TBS %d (NPRB %d)\n",dlsch1_harq->TBS,NPRB);
printf("dlsch1 eNB: mcs %d\n",dlsch1_harq->mcs);
printf("dlsch1 eNB: tpmi %d\n",tpmi);
printf("dlsch1 eNB: mimo_mode %d\n",dlsch1_harq->mimo_mode);
}
#endif
// compute DL power control parameters
......@@ -4730,10 +4777,11 @@ int generate_ue_dlsch_params_from_dci(int frame,
return(-1);
}
if (frame_type == TDD)
/*if (frame_type == TDD)
tbswap = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tb_swap;
else
tbswap = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tb_swap;
tbswap = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tb_swap;*/
if (tbswap == 0) {
dlsch0 = dlsch[0];
......@@ -4802,11 +4850,14 @@ int generate_ue_dlsch_params_from_dci(int frame,
// check if either TB is disabled (see 36-213 V8.6 p. 26)
if ((dlsch0_harq->rvidx == 1) && (dlsch0_harq->mcs == 0)) {
dlsch0_harq->status = DISABLED;
dlsch0->active = 0;
}
if ((dlsch1_harq->rvidx == 1) && (dlsch1_harq->mcs == 0)) {
dlsch1_harq->status = DISABLED;
dlsch1->active = 0;
}
dlsch0_harq->Nl = 1;
......@@ -4815,7 +4866,7 @@ int generate_ue_dlsch_params_from_dci(int frame,
// dlsch0->layer_index = tbswap;
// dlsch1->layer_index = 1-tbswap;
if (dlsch1->active==1) { //two codewords
if (dlsch0->active==1 && dlsch1->active==1) { //two TB
dlsch0_harq->dl_power_off = 1;
dlsch1_harq->dl_power_off = 1;
switch (tpmi) {
......@@ -4840,8 +4891,7 @@ int generate_ue_dlsch_params_from_dci(int frame,
default:
break;
}
}
else {
} else if (dlsch1_harq->status == DISABLED) {
dlsch0_harq->dl_power_off = 1;
switch (tpmi) {
case 0 :
......@@ -4875,6 +4925,40 @@ int generate_ue_dlsch_params_from_dci(int frame,
return(-1);
break;
}
} else if (dlsch0_harq->status == DISABLED) {
dlsch1_harq->dl_power_off = 1;
switch (tpmi) {
case 0 :
dlsch1_harq->mimo_mode = ALAMOUTI;
break;
case 1:
dlsch1_harq->mimo_mode = UNIFORM_PRECODING11;
dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,0, 0);
break;
case 2:
dlsch1_harq->mimo_mode = UNIFORM_PRECODING1m1;
dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,1, 0);
break;
case 3:
dlsch1_harq->mimo_mode = UNIFORM_PRECODING1j;
dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,2, 0);
break;
case 4:
dlsch1_harq->mimo_mode = UNIFORM_PRECODING1mj;
dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,3, 0);
break;
case 5:
dlsch1_harq->mimo_mode = PUSCH_PRECODING0;
// pmi stored from ulsch allocation routine
dlsch1_harq->pmi_alloc = dlsch0->pmi_alloc;
//LOG_I(PHY,"XXX using PMI %x\n",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc));
break;
case 6:
dlsch1_harq->mimo_mode = PUSCH_PRECODING1;
LOG_E(PHY,"Unsupported TPMI\n");
return(-1);
break;
}
}
if (frame_parms->mode1_flag == 1)
......@@ -4882,11 +4966,11 @@ int generate_ue_dlsch_params_from_dci(int frame,
if (dlsch0->active == 1) {
if ((ndi1!=dlsch0_harq->DCINdi) ||
(dlsch0_harq->first_tx==1)) {
if ((ndi1!=dlsch0_harq->DCINdi) || (dlsch0_harq->first_tx==1)) {
dlsch0_harq->round = 0;
dlsch0_harq->status = ACTIVE;
dlsch0_harq->DCINdi = ndi1;
if (dlsch0_harq->first_tx==1) {
LOG_D(PHY,"Format 2 DCI First TX0: Clearing flag\n");
dlsch0_harq->first_tx = 0;
......@@ -4905,8 +4989,7 @@ int generate_ue_dlsch_params_from_dci(int frame,
}
if (dlsch1->active == 1) {
if ((ndi2!=dlsch1_harq->DCINdi) ||
(dlsch1_harq->first_tx==1)) {
if ((ndi2!=dlsch1_harq->DCINdi) || (dlsch1_harq->first_tx==1)) {
dlsch1_harq->round = 0;
dlsch1_harq->status = ACTIVE;
dlsch1_harq->DCINdi = ndi2;
......@@ -4926,7 +5009,7 @@ int generate_ue_dlsch_params_from_dci(int frame,
}
}
dlsch0_harq->mcs = mcs1;
// dlsch0_harq->mcs = mcs1;
if (dlsch0_harq->nb_rb>1) {
dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1];
......@@ -4936,7 +5019,6 @@ int generate_ue_dlsch_params_from_dci(int frame,
dlsch0_harq->Qm = (mcs1-28)<<1;
else
LOG_E(PHY,"invalid mcs1 %d\n",mcs1);
} else
dlsch0_harq->TBS =0;
......@@ -4952,7 +5034,7 @@ int generate_ue_dlsch_params_from_dci(int frame,
}
dlsch1_harq->DCINdi = ndi2;
dlsch1_harq->mcs = mcs2;
// dlsch1_harq->mcs = mcs2;
if (dlsch1_harq->nb_rb>1) {
dlsch1_harq->TBS = TBStable[get_I_TBS(dlsch1_harq->mcs)][dlsch1_harq->nb_rb-1];
......
......@@ -734,7 +734,7 @@ int rx_pdsch(PHY_VARS_UE *phy_vars_ue,
((dlsch0_harq->mimo_mode >=DUALSTREAM_UNIFORM_PRECODING1) &&
(dlsch0_harq->mimo_mode <=DUALSTREAM_PUSCH_PRECODING))) {
rxdataF_comp_ptr = lte_ue_pdsch_vars[eNB_id]->rxdataF_comp1[harq_pid][round];
dl_ch_mag_ptr = lte_ue_pdsch_vars[eNB_id]->dl_ch_mag1;
dl_ch_mag_ptr = lte_ue_pdsch_vars[eNB_id]->dl_ch_mag1[harq_pid][round];
}
else {
rxdataF_comp_ptr = lte_ue_pdsch_vars[eNB_id_i]->rxdataF_comp0;
......@@ -1011,7 +1011,7 @@ int rx_pdsch(PHY_VARS_UE *phy_vars_ue,
dlsch_16qam_llr(frame_parms,
rxdataF_comp_ptr,
lte_ue_pdsch_vars[eNB_id]->llr[1],
lte_ue_pdsch_vars[eNB_id]->dl_ch_mag1,
lte_ue_pdsch_vars[eNB_id]->dl_ch_mag1[harq_pid][round],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,4,subframe,symbol),
lte_ue_pdsch_vars[eNB_id]->llr128_2ndstream);
......@@ -1024,8 +1024,8 @@ int rx_pdsch(PHY_VARS_UE *phy_vars_ue,
dlsch_64qam_llr(frame_parms,
rxdataF_comp_ptr,
lte_ue_pdsch_vars[eNB_id]->llr[1],
lte_ue_pdsch_vars[eNB_id]->dl_ch_mag1,
lte_ue_pdsch_vars[eNB_id]->dl_ch_magb1,
lte_ue_pdsch_vars[eNB_id]->dl_ch_mag1[harq_pid][round],
lte_ue_pdsch_vars[eNB_id]->dl_ch_magb1[harq_pid][round],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,6,subframe,symbol),
lte_ue_pdsch_vars[eNB_id]->llr128_2ndstream);
......@@ -1900,9 +1900,9 @@ void dlsch_channel_compensation_TM34(LTE_DL_FRAME_PARMS *frame_parms,
int **rxdataF_ext = lte_ue_pdsch_vars->rxdataF_ext;
int **dl_ch_estimates_ext = lte_ue_pdsch_vars->dl_ch_estimates_ext;
int **dl_ch_mag0 = lte_ue_pdsch_vars->dl_ch_mag0;
int **dl_ch_mag1 = lte_ue_pdsch_vars->dl_ch_mag1;
int **dl_ch_mag1 = lte_ue_pdsch_vars->dl_ch_mag1[harq_pid][round];
int **dl_ch_magb0 = lte_ue_pdsch_vars->dl_ch_magb0;
int **dl_ch_magb1 = lte_ue_pdsch_vars->dl_ch_magb1;
int **dl_ch_magb1 = lte_ue_pdsch_vars->dl_ch_magb1[harq_pid][round];
int **rxdataF_comp0 = lte_ue_pdsch_vars->rxdataF_comp0;
int **rxdataF_comp1 = lte_ue_pdsch_vars->rxdataF_comp1[harq_pid][round];
unsigned char *pmi_ext = lte_ue_pdsch_vars->pmi_ext;
......@@ -2290,9 +2290,9 @@ void dlsch_channel_compensation_TM34(LTE_DL_FRAME_PARMS *frame_parms,
int **rxdataF_ext = lte_ue_pdsch_vars->rxdataF_ext;
int **dl_ch_estimates_ext = lte_ue_pdsch_vars->dl_ch_estimates_ext;
int **dl_ch_mag0 = lte_ue_pdsch_vars->dl_ch_mag0;
int **dl_ch_mag1 = lte_ue_pdsch_vars->dl_ch_mag1;
int **dl_ch_mag1 = lte_ue_pdsch_vars->dl_ch_mag1[harq_pid][round];
int **dl_ch_magb0 = lte_ue_pdsch_vars->dl_ch_magb0;
int **dl_ch_magb1 = lte_ue_pdsch_vars->dl_ch_magb1;
int **dl_ch_magb1 = lte_ue_pdsch_vars->dl_ch_magb1[harq_pid][round];
int **rxdataF_comp0 = lte_ue_pdsch_vars->rxdataF_comp0;
int **rxdataF_comp1 = lte_ue_pdsch_vars->rxdataF_comp1[harq_pid][round];
......@@ -2968,9 +2968,9 @@ void dlsch_detection_mrc_TM34(LTE_DL_FRAME_PARMS *frame_parms,
int **dl_ch_rho_ext =lte_ue_pdsch_vars->dl_ch_rho_ext[harq_pid][round]; //for second stream
int **dl_ch_rho2_ext =lte_ue_pdsch_vars->dl_ch_rho2_ext;
int **dl_ch_mag0 = lte_ue_pdsch_vars->dl_ch_mag0;
int **dl_ch_mag1 = lte_ue_pdsch_vars->dl_ch_mag1;
int **dl_ch_mag1 = lte_ue_pdsch_vars->dl_ch_mag1[harq_pid][round];
int **dl_ch_magb0 = lte_ue_pdsch_vars->dl_ch_magb0;
int **dl_ch_magb1 = lte_ue_pdsch_vars->dl_ch_magb1;
int **dl_ch_magb1 = lte_ue_pdsch_vars->dl_ch_magb1[harq_pid][round];
if (frame_parms->nb_antennas_rx>1) {
......@@ -3107,7 +3107,7 @@ void dlsch_channel_level(int **dl_ch_estimates_ext,
short rb;
unsigned char aatx,aarx,nre=12,symbol_mod;
__m128i *dl_ch128,avg128D;
__m128i *dl_ch128, avg128D;
symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
......
......@@ -624,9 +624,9 @@ void phy_scope_UE(FD_lte_phy_scope_ue *form,
pdsch_comp1 = (int16_t*) (phy_vars_ue->lte_ue_pdsch_vars[eNB_id]->rxdataF_comp1[0][0])[0];
//pdsch_comp1 = (int16_t*) (phy_vars_ue->lte_ue_pdsch_vars[eNB_id]->dl_ch_rho_ext[0][0])[0];
pdsch_mag0 = (int16_t*) phy_vars_ue->lte_ue_pdsch_vars[eNB_id]->dl_ch_mag0[0];
pdsch_mag1 = (int16_t*) phy_vars_ue->lte_ue_pdsch_vars[eNB_id]->dl_ch_mag1[0];
pdsch_mag1 = (int16_t*) (phy_vars_ue->lte_ue_pdsch_vars[eNB_id]->dl_ch_mag1[0][0])[0];
pdsch_magb0 = (int16_t*) phy_vars_ue->lte_ue_pdsch_vars[eNB_id]->dl_ch_magb0[0];
pdsch_magb1 = (int16_t*) phy_vars_ue->lte_ue_pdsch_vars[eNB_id]->dl_ch_magb1[0];
pdsch_magb1 = (int16_t*) (phy_vars_ue->lte_ue_pdsch_vars[eNB_id]->dl_ch_magb1[0][0])[0];
fl_freeze_form(form->lte_phy_scope_ue);
......
......@@ -678,6 +678,13 @@ typedef struct {
time_stats_t dlsch_tc_intl2_stats;
time_stats_t tx_prach;
//for SIC
time_stats_t dlsch_encoding_SIC_stats;
time_stats_t dlsch_scrambling_SIC_stats;
time_stats_t dlsch_modulation_SIC_stats;
time_stats_t dlsch_llr_stripping_unit_SIC_stats;
time_stats_t dlsch_unscrambling_SIC_stats;
#if ENABLE_RAL
hash_table_t *ral_thresholds_timed;
SLIST_HEAD(ral_thresholds_gen_poll_s, ral_threshold_phy_t) ral_thresholds_gen_polled[RAL_LINK_PARAM_GEN_MAX];
......
......@@ -819,7 +819,7 @@ typedef struct {
/// \brief Magnitude of Downlink Channel second layer (16QAM level/First 64QAM level).
/// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
/// - second index: ? [0..168*N_RB_DL[
int32_t **dl_ch_mag1;
int32_t **dl_ch_mag1[8][8];
/// \brief Magnitude of Downlink Channel, first layer (2nd 64QAM level).
/// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
/// - second index: ? [0..168*N_RB_DL[
......@@ -827,7 +827,7 @@ typedef struct {
/// \brief Magnitude of Downlink Channel second layer (2nd 64QAM level).
/// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
/// - second index: ? [0..168*N_RB_DL[
int32_t **dl_ch_magb1;
int32_t **dl_ch_magb1[8][8];
/// \brief Cross-correlation of two eNB signals.
/// - first index: rx antenna [0..nb_antennas_rx[
/// - second index: symbol [0..]
......
......@@ -154,7 +154,7 @@ int main(int argc, char **argv)
uint16_t Nid_cell=0;
int8_t eNB_id = 0, eNB_id_i = 1;
unsigned char mcs1=0,mcs2=0,mcs_i=0,awgn_flag=0,round,dci_flag=0;
unsigned char mcs1=0,mcs2=0,mcs_i=0,awgn_flag=0,dci_flag=0;
unsigned char i_mod = 2;
unsigned short NB_RB;
unsigned char Ns,l,m;
......@@ -178,7 +178,8 @@ int main(int argc, char **argv)
unsigned int ret[2];
unsigned int coded_bits_per_codeword[2],nsymb,dci_cnt,tbs[2];
unsigned int tx_lev=0,tx_lev_dB=0,trials,errs[2][4],round_trials[4]={0,0,0,0},dci_errors=0,dlsch_active=0,num_layers;
unsigned int tx_lev=0, tx_lev_dB=0, round=0, trials, errs[2][4]={{0,0,0,0},{0,0,0,0}}, round_trials[2][4]={{0,0,0,0},{0,0,0,0}}, round_sic=0;
unsigned int dci_errors=0, dlsch_active=0, num_layers;
int re_allocated;
char fname[32],vname[32];
......@@ -187,7 +188,7 @@ int main(int argc, char **argv)
FILE *time_meas_fd;
char time_meas_fname[256];
//FILE *tikz_fd;
//qFILE *tikz_fd;
//char tikz_fname[256];
FILE *input_trch_fd=NULL;
......@@ -208,7 +209,7 @@ int main(int argc, char **argv)
int n_frames;
int n_ch_rlz = 1;
channel_desc_t *eNB2UE[4];
channel_desc_t *eNB2UE[8];
uint8_t num_pdcch_symbols=1,num_pdcch_symbols_2=0;
uint8_t pilot1,pilot2,pilot3;
uint8_t rx_sample_offset = 0;
......@@ -227,6 +228,10 @@ int main(int argc, char **argv)
int pmi_feedback=0;
int hold_channel=0;
// temporarily for retransmissions:
unsigned char resend_cw1=0; //if 0 resend only cw0
unsigned char resend_cw0_cw1=1; //if 0 resend both cw in a normal way
// void *data;
// int ii;
int bler;
......@@ -894,7 +899,7 @@ n(tikz_fname,"w");
PHY_vars_UE->lte_ue_pdcch_vars[0]->crnti = n_rnti;
PHY_vars_UE->transmission_mode[eNB_id]=transmission_mode;
if (PHY_vars_UE->transmission_mode[eNB_id] !=4)
if (PHY_vars_UE->transmission_mode[eNB_id] !=4) // add TM3 exception
PHY_vars_UE->PHY_measurements.rank[eNB_id]=0;
else
PHY_vars_UE->PHY_measurements.rank[eNB_id]=1;
......@@ -940,6 +945,7 @@ n(tikz_fname,"w");
DLSCH_alloc_pdu2_1E[1].tpmi = (transmission_mode>=5 ? 5 : 0) ; // precoding
DLSCH_alloc_pdu2_1E[1].dl_power_off = (transmission_mode==5 ? 0 : 1);
eNB2UE[0] = new_channel_desc_scm(PHY_vars_eNB->lte_frame_parms.nb_antennas_tx,
PHY_vars_UE->lte_frame_parms.nb_antennas_rx,
channel_model,
......@@ -949,8 +955,8 @@ n(tikz_fname,"w");
rx_sample_offset,
0);
if(num_rounds>1) {
for(n=1; n<4; n++)
if(num_rounds>1) { // 8 is because the round counters are independent across the CW
for(n=1; n<8; n++)
eNB2UE[n] = new_channel_desc_scm(PHY_vars_eNB->lte_frame_parms.nb_antennas_tx,
PHY_vars_UE->lte_frame_parms.nb_antennas_rx,
channel_model,
......@@ -961,6 +967,8 @@ n(tikz_fname,"w");
0);
}
if (eNB2UE[0]==NULL) {
msg("Problem generating channel model. Exiting.\n");
exit(-1);
......@@ -2057,20 +2065,20 @@ n(tikz_fname,"w");
for (SNR=snr0; SNR<snr1; SNR+=snr_step) {
PHY_vars_UE->frame_rx=0;
for (i=0; i<4; i++) {
errs[0][i]=0;
errs[1][i]=0;
/*Let see, how it will work, if */
round_trials[i] = 0;
// round_trials_1[i] = 0;
errs[0][i]=0; //CW_0
errs[1][i]=0; //CW_1
round_trials[0][i] = 0; // CW_0
round_trials[1][i] = 0; // CW_1
}
dci_errors=0;
//avg_ber = 0;
round=0;
round = 0;
avg_iter[0] = 0;
avg_iter[1] = 0;
iter_trials[0]=0;
iter_trials[1]=0;
unsigned int resend_one[4]={0,0,0,0}, resend_both[4]={0,0,0,0};
reset_meas(&PHY_vars_eNB->phy_proc_tx); // total eNB tx
reset_meas(&PHY_vars_eNB->dlsch_scrambling_stats);
reset_meas(&PHY_vars_UE->dlsch_unscrambling_stats);
......@@ -2119,7 +2127,8 @@ n(tikz_fname,"w");
for (trials = 0;trials<n_frames;trials++) {
//printf("Trial %d\n",trials);
fflush(stdout);
round=0;
round = 0;
for (i=0; i<frame_parms->nb_antennas_tx; i++) {
memset(sic_buffer[i], 0, FRAME_LENGTH_COMPLEX_SAMPLES_NO_PREFIX*sizeof(int32_t));
}
......@@ -2129,18 +2138,26 @@ n(tikz_fname,"w");
ret[0] = PHY_vars_UE->dlsch_ue[0][0]->max_turbo_iterations+1;
ret[1] = PHY_vars_UE->dlsch_ue[0][0]->max_turbo_iterations+1;
/*This condition indicates, that the round_trials must go on, while CRC keeps failing at
least for one of the CW and round < num_rounds. This also means that round_trials is a unique
variable for both CW*/
resend_cw0_cw1=1;
resend_cw1=0;
while (((transmission_mode == 3 || transmission_mode == 4) && ((round < num_rounds) && ((ret[0] > PHY_vars_UE->dlsch_ue[0][0]->max_turbo_iterations)
|| (ret[1] > PHY_vars_UE->dlsch_ue[0][0]->max_turbo_iterations)))) ||
((transmission_mode!=4 && transmission_mode != 3)&& ((round < num_rounds) && (ret[0] > PHY_vars_UE->dlsch_ue[0][0]->max_turbo_iterations)))) {
while (((transmission_mode == 3 || transmission_mode == 4) &&
((round < num_rounds) && (ret[0] > PHY_vars_UE->dlsch_ue[0][0]->max_turbo_iterations) &&
(ret[1] > PHY_vars_UE->dlsch_ue[0][0]->max_turbo_iterations))) ||
((transmission_mode!=4 && transmission_mode != 3) && ((round< num_rounds) &&
(ret[0] > PHY_vars_UE->dlsch_ue[0][0]->max_turbo_iterations)))) {
//printf("Trial %d, round %d , ret[0] %d, ret[1] %d, round_trials %d\n",trials,round, ret[0], ret[1], round_trials[round]);
//printf("round_trials %d round %d\n", round_trials[round], round);
round_trials[round]++;
if (ret[0] > PHY_vars_UE->dlsch_ue[0][0]->max_turbo_iterations)
round_trials[0][round]++;
if (ret[1] > PHY_vars_UE->dlsch_ue[0][0]->max_turbo_iterations)
round_trials[1][round]++;
/*printf("Trial %d, round cw0 = %d , round cw1 = %d, ret[0] = %d, ret[1] = %d, round_trials cw0 [%d]= %d, round_trials cw1 [%d]= %d\n",trials, round, round, \
ret[0], ret[1], round, round_trials[0][round], round, round_trials[1][round]);*/
//printf("round_trials %d round %d\n", round_trials[round], round);
......@@ -2172,10 +2189,13 @@ n(tikz_fname,"w");
// Simulate HARQ procedures!!!
if (common_flag == 0) {
PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->rvidx = round&3;
if (transmission_mode == 3 || transmission_mode == 4)
PHY_vars_eNB->dlsch_eNB[0][1]->harq_processes[0]->rvidx = round&3;
if (round == 0) { // First round
TB0_active = 1;
PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->rvidx = round&3;
if (PHY_vars_eNB->lte_frame_parms.frame_type == TDD) {
switch (transmission_mode) {
......@@ -2377,7 +2397,6 @@ n(tikz_fname,"w");
}
}
else {
PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->rvidx = round&3;
if (PHY_vars_eNB->lte_frame_parms.frame_type == TDD) {
switch (transmission_mode) {
......@@ -2662,7 +2681,6 @@ n(tikz_fname,"w");
((DCI2_5MHz_2A_FDD_t *)&DLSCH_alloc_pdu_1[0])->rv1 = 1;
((DCI2_5MHz_2A_FDD_t *)&DLSCH_alloc_pdu_1[0])->ndi2 = trials&1;
((DCI2_5MHz_2A_FDD_t *)&DLSCH_alloc_pdu_1[0])->rv2 = round&3;
//change tpmi
}
memcpy(&dci_alloc[0].dci_pdu[0],&DLSCH_alloc_pdu_1[0],sizeof(DCI2_5MHz_2A_FDD_t));
break;
......@@ -2743,7 +2761,7 @@ n(tikz_fname,"w");
rate[cw] = (double)tbs[cw]/(double)coded_bits_per_codeword[cw];
if ((SNR==snr0) && (trials==0) && (round==0) && (pmi_feedback==0))
if ((SNR == snr0) && (trials == 0) && (round == 0) && (pmi_feedback == 0))
printf("User %d, cw %d: Rate = %f (%f bits/dim) (G %d, TBS %d, mod %d, pdcch_sym %d, ndi %d)\n",
k,cw,rate[cw],rate[cw]*get_Qm(PHY_vars_eNB->dlsch_eNB[k][cw]->harq_processes[0]->mcs),
coded_bits_per_codeword[cw],
......@@ -2787,22 +2805,6 @@ n(tikz_fname,"w");
&PHY_vars_eNB->dlsch_interleaving_stats)<0)
exit(-1);
/*
if (transmission_mode == 3) {
if (dlsch_encoding(input_buffer1[k],
&PHY_vars_eNB->lte_frame_parms,
num_pdcch_symbols,
PHY_vars_eNB->dlsch_eNB[k][1],
0,subframe,
&PHY_vars_eNB->dlsch_rate_matching_stats,
&PHY_vars_eNB->dlsch_turbo_encoding_stats,
&PHY_vars_eNB->dlsch_interleaving_stats
)<0)
exit(-1);
}
*/
stop_meas(&PHY_vars_eNB->dlsch_encoding_stats);
PHY_vars_eNB->dlsch_eNB[k][cw]->rnti = (common_flag==0) ? n_rnti+k : SI_RNTI;
......@@ -2955,7 +2957,7 @@ n(tikz_fname,"w");
// Multipath channel
if (awgn_flag == 0) {
multipath_channel(eNB2UE[round],s_re,s_im,r_re,r_im,
multipath_channel(eNB2UE[round+round],s_re,s_im,r_re,r_im,
2*frame_parms->samples_per_tti,hold_channel);
// printf("amc: ****************** eNB2UE[%d]->n_rx = %d,dd %d\n",round,eNB2UE[round]->nb_rx,eNB2UE[round]->channel_offset);
if(abstx==1 && num_rounds>1)
......@@ -2965,14 +2967,13 @@ n(tikz_fname,"w");
random_channel(eNB2UE[3],0);
}
if (PHY_vars_UE->perfect_ce==1){
freq_channel(eNB2UE[round],PHY_vars_UE->lte_frame_parms.N_RB_DL,12*PHY_vars_UE->lte_frame_parms.N_RB_DL + 1);
freq_channel(eNB2UE[round+round],PHY_vars_UE->lte_frame_parms.N_RB_DL,12*PHY_vars_UE->lte_frame_parms.N_RB_DL + 1);
// write_output("channel.m","ch",eNB2UE[round]->ch[0],eNB2UE[round]->channel_length,1,8);
// write_output("channelF.m","chF",eNB2UE[round]->chF[0],12*PHY_vars_UE->lte_frame_parms.N_RB_DL +1,1,8);
}
}
// freq_channel(eNB2UE[0], NB_RB,12*NB_RB + 1);
if(abstx){
if(abstx){ // TODO: check the rounds here!!
if (trials==0 && round==0) {
// calculate freq domain representation to compute SINR
freq_channel(eNB2UE[0], NB_RB,2*NB_RB + 1);
......@@ -3118,9 +3119,9 @@ n(tikz_fname,"w");
for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
for (i=0; i<frame_parms->N_RB_DL*12; i++) {
((int16_t *) PHY_vars_UE->lte_ue_common_vars.dl_ch_estimates[k][(aa<<1)+aarx])[2*i+((l+(Ns%2)*pilot2)*frame_parms->ofdm_symbol_size+LTE_CE_FILTER_LENGTH)*2]=
(int16_t)(eNB2UE[round]->chF[aarx+(aa*frame_parms->nb_antennas_rx)][i].x*AMP);
(int16_t)(eNB2UE[round+round]->chF[aarx+(aa*frame_parms->nb_antennas_rx)][i].x*AMP);
((int16_t *) PHY_vars_UE->lte_ue_common_vars.dl_ch_estimates[k][(aa<<1)+aarx])[2*i+1+((l+(Ns%2)*pilot2)*frame_parms->ofdm_symbol_size+LTE_CE_FILTER_LENGTH)*2]=
(int16_t)(eNB2UE[round]->chF[aarx+(aa*frame_parms->nb_antennas_rx)][i].y*AMP);
(int16_t)(eNB2UE[round+round]->chF[aarx+(aa*frame_parms->nb_antennas_rx)][i].y*AMP);
}
}
}
......@@ -3219,23 +3220,21 @@ n(tikz_fname,"w");
dlsch_active = 0;
if (round==0) {
dci_errors++;
round=5;
round=5; // this is meant to stop the "while" loop if DCI is wrong;
errs[0][0]++;
//round_trials[0]++;
if (n_frames==1)
printf("DCI error trial %d errs[0][0] %d\n",trials,errs[0][0]);
}
//for (i=1;i<=round;i++)
//round_trials[i]--;
//round=5;
}
for (i=0;i<dci_cnt;i++) {
//printf("Generating dlsch parameters for RNTI %x\n",dci_alloc_rx[i].rnti);
if (round == 0) {
PHY_vars_UE->dlsch_ue[0][0]->harq_processes[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid]->first_tx=1;
PHY_vars_UE->dlsch_ue[0][1]->harq_processes[PHY_vars_UE->dlsch_ue[0][1]->current_harq_pid]->first_tx=1;
PHY_vars_UE->dlsch_ue[0][0]->harq_processes[0]->first_tx=1;
}
if ((transmission_mode == 3 || transmission_mode ==4) && (round == 0)) {
PHY_vars_UE->dlsch_ue[0][1]->harq_processes[0]->first_tx=1;
}
if ((dci_alloc_rx[i].rnti == n_rnti) &&
(generate_ue_dlsch_params_from_dci(0,
......@@ -3258,28 +3257,34 @@ n(tikz_fname,"w");
PHY_vars_UE->lte_ue_pdcch_vars[0]->num_pdcch_symbols,
0,
subframe);
if (transmission_mode == 3 || transmission_mode == 4) {
coded_bits_per_codeword[1]= get_G(&PHY_vars_eNB->lte_frame_parms,
PHY_vars_UE->dlsch_ue[0][1]->harq_processes[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid]->nb_rb,
PHY_vars_UE->dlsch_ue[0][1]->harq_processes[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid]->rb_alloc_even,
get_Qm(PHY_vars_UE->dlsch_ue[0][1]->harq_processes[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid]->mcs),
PHY_vars_UE->dlsch_ue[0][1]->harq_processes[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid]->Nl,
PHY_vars_UE->lte_ue_pdcch_vars[1]->num_pdcch_symbols,
0,
subframe);
}
/*
rate = (double)dlsch_tbs25[get_I_TBS(PHY_vars_UE->dlsch_ue[0][0]->harq_processes[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid]->mcs)][PHY_vars_UE->dlsch_ue[0][0]->nb_rb-1]/(coded_bits_per_codeword);
rate*=get_Qm(PHY_vars_UE->dlsch_ue[0][0]->harq_processes[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid]->mcs);
*/
printf("num_pdcch_symbols %d, G %d, TBS %d\n",PHY_vars_UE->lte_ue_pdcch_vars[0]->num_pdcch_symbols,coded_bits_per_codeword [0],PHY_vars_UE->dlsch_ue[0][0]->harq_processes[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid]->TBS);
dlsch_active = 1;
dlsch_active = 1; // what does it indicates???
} else {
dlsch_active = 0;
if (round==0) {
dci_errors++;
errs[0][0]++;
//round_trials[0]++;
round=5;
if (n_frames==1)
printf("DCI misdetection trial %d\n",trials);
}
// for (i=1;i<=round;i++)
// round_trials[i]--;
// round=5;
}
}
} else { //dci_flag == 0
......@@ -3287,8 +3292,11 @@ n(tikz_fname,"w");
PHY_vars_UE->lte_ue_pdcch_vars[0]->num_pdcch_symbols = num_pdcch_symbols;
if (round == 0) {
PHY_vars_UE->dlsch_ue[0][0]->harq_processes[0]->first_tx=1;
}
if (round == 0) {
PHY_vars_UE->dlsch_ue[0][1]->harq_processes[0]->first_tx=1;
}
switch (transmission_mode) {
case 1:
case 2:
......@@ -3447,7 +3455,7 @@ n(tikz_fname,"w");
cw_to_decode_interf=Kmimo;
}
for (cw_non_sic=0; cw_non_sic<cw_to_decode_interf; cw_non_sic++){
for (cw_non_sic=0; cw_non_sic<cw_to_decode_interf; cw_non_sic++){ // may be we ll have to swap CW
PHY_vars_UE->dlsch_ue[0][cw_non_sic]->rnti = (common_flag==0) ? n_rnti: SI_RNTI;
coded_bits_per_codeword[cw_non_sic] = get_G(&PHY_vars_eNB->lte_frame_parms,
......@@ -3520,9 +3528,13 @@ n(tikz_fname,"w");
PHY_vars_UE->dlsch_ue[0][cw_non_sic]->current_harq_pid,
1,llr8_flag);
stop_meas(&PHY_vars_UE->dlsch_decoding_stats);
//printf("retr cw 0 = %d\n", ret[0]);
//printf("current round = %d\n", PHY_vars_UE->dlsch_ue[0][cw_non_sic]->harq_processes[PHY_vars_UE->dlsch_ue[0][cw_non_sic]->current_harq_pid]->round);
if (ret[cw_non_sic] <= PHY_vars_UE->dlsch_ue[0][cw_non_sic]->max_turbo_iterations ) { //if CW0 is decoded, approach CW1
if (ret[cw_non_sic] <= PHY_vars_UE->dlsch_ue[0][cw_non_sic]->max_turbo_iterations ) { //If CRC for the first CW did not fail
if (cw_non_sic==0) {
avg_iter[0] += ret[0];
iter_trials[0]++;
......@@ -3650,8 +3662,11 @@ n(tikz_fname,"w");
if ((PHY_vars_UE->dlsch_ue[eNB_id][0]->harq_processes[PHY_vars_UE->dlsch_ue[eNB_id][0]->current_harq_pid]->mimo_mode >=DUALSTREAM_UNIFORM_PRECODING1) &&
(PHY_vars_UE->dlsch_ue[eNB_id][0]->harq_processes[PHY_vars_UE->dlsch_ue[eNB_id][0]->current_harq_pid]->mimo_mode <=DUALSTREAM_PUSCH_PRECODING) &&
rx_type==rx_SIC_dual_stream) {
// printf("current round = %d\n", PHY_vars_UE->dlsch_ue[eNB_id][0]->harq_processes[PHY_vars_UE->dlsch_ue[eNB_id][0]->current_harq_pid]->round);
// for (round = 0 ; round < 1 ; round++) {
for (round_sic = 0 ; round_sic < (round +1); round_sic++) {
//printf("I enter round_sic loop \n");
//printf("round_sic= %d\n", round_sic);
dlsch0_ue_harq = PHY_vars_UE->dlsch_ue[eNB_id][0]->harq_processes[PHY_vars_UE->dlsch_ue[eNB_id][0]->current_harq_pid];
dlsch0_eNB_harq = PHY_vars_UE->dlsch_eNB[eNB_id]->harq_processes[PHY_vars_UE->dlsch_ue[eNB_id][0]->current_harq_pid];
......@@ -3714,9 +3729,9 @@ n(tikz_fname,"w");
case 2:
dlsch_qpsk_llr_SIC(&PHY_vars_UE->lte_frame_parms,
PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->rxdataF_comp1[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid][round],
PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->rxdataF_comp1[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid][round_sic],
sic_buffer,
PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->dl_ch_rho_ext[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid][round],
PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->dl_ch_rho_ext[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid][round_sic],
PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->llr[1],
num_pdcch_symbols,
dlsch0_eNB_harq->nb_rb,
......@@ -3729,12 +3744,12 @@ n(tikz_fname,"w");
case 4:
dlsch_16qam_llr_SIC(&PHY_vars_UE->lte_frame_parms,
PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->rxdataF_comp1[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid][round],
PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->rxdataF_comp1[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid][round_sic],
sic_buffer,
PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->dl_ch_rho_ext[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid][round],
PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->dl_ch_rho_ext[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid][round_sic],
PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->llr[1],
num_pdcch_symbols,
PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->dl_ch_mag1,
PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->dl_ch_mag1[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid][round_sic],
dlsch0_eNB_harq->nb_rb,
subframe,
dlsch0_eNB_harq->rb_alloc[0],
......@@ -3743,13 +3758,13 @@ n(tikz_fname,"w");
break;
case 6:
dlsch_64qam_llr_SIC(&PHY_vars_UE->lte_frame_parms,
PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->rxdataF_comp1[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid][round],
PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->rxdataF_comp1[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid][round_sic],
sic_buffer,
PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->dl_ch_rho_ext[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid][round],
PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->dl_ch_rho_ext[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid][round_sic],
PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->llr[1],
num_pdcch_symbols,
PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->dl_ch_mag1,
PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->dl_ch_magb1,
PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->dl_ch_mag1[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid][round_sic],
PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->dl_ch_magb1[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid][round_sic],
dlsch0_eNB_harq->nb_rb,
subframe,
dlsch0_eNB_harq->rb_alloc[0],
......@@ -3757,6 +3772,7 @@ n(tikz_fname,"w");
PHY_vars_UE->dlsch_ue[eNB_id][0]);
break;
}
}
// write_output("rxdata_llr1.m","llr1", PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->llr[1],re_allocated*2,1,0);
......@@ -3774,7 +3790,7 @@ n(tikz_fname,"w");
PHY_vars_UE->dlsch_ue[0][cw_sic]->harq_processes[PHY_vars_UE->dlsch_ue[0][cw_sic]->current_harq_pid]->G = coded_bits_per_codeword[cw_sic];
PHY_vars_UE->dlsch_ue[0][cw_sic]->harq_processes[PHY_vars_UE->dlsch_ue[0][cw_sic]->current_harq_pid]->Qm = get_Qm(PHY_vars_eNB->dlsch_eNB[0][cw_sic]->harq_processes[0]->mcs);
if (n_frames==2) {
if (n_frames==1) {
printf("Kmimo=%d, cw=%d, G=%d, TBS=%d\n",Kmimo,cw_sic,coded_bits_per_codeword[cw_sic],
PHY_vars_UE->dlsch_ue[0][cw_sic]->harq_processes[PHY_vars_UE->dlsch_ue[0][cw_sic]->current_harq_pid]->TBS);
......@@ -3793,7 +3809,8 @@ n(tikz_fname,"w");
if (PHY_vars_eNB->dlsch_eNB[0][cw_sic]->harq_processes[0]->e[i] != (PHY_vars_UE->lte_ue_pdsch_vars[0]->llr[cw_sic][i]<0)) {
uncoded_ber_bit[i] = 1;
uncoded_ber++;
} else
}
else
uncoded_ber_bit[i] = 0;
uncoded_ber/=coded_bits_per_codeword[cw_sic];
......@@ -3827,15 +3844,17 @@ n(tikz_fname,"w");
1,llr8_flag);
stop_meas(&PHY_vars_UE->dlsch_decoding_stats);
// printf("retr cw 1 = %d\n", ret[1]);
if (ret[1] <= PHY_vars_UE->dlsch_ue[0][cw_sic]->max_turbo_iterations ) { //if (ret <= PHY_vars_UE->dlsch_ue[0][cw_sic]->max_turbo_iterations )
if (ret[1] <= PHY_vars_UE->dlsch_ue[0][cw_sic]->max_turbo_iterations ) {
avg_iter[1] += ret[1];
iter_trials[1]++;
if (n_frames==2) {
if (n_frames==1) {
printf("cw sic %d, round %d: No DLSCH errors found, uncoded ber %f\n",cw_sic,round,uncoded_ber);
#ifdef PRINT_BYTES
for (s=0;s<PHY_vars_UE->dlsch_ue[0][cw_sic]->harq_processes[0]->C;s++) {
if (s<PHY_vars_UE->dlsch_ue[0][cw_sic]->harq_processes[0]->Cminus)
......@@ -3846,6 +3865,7 @@ n(tikz_fname,"w");
Kr_bytes = Kr>>3;
printf("Decoded_output (Segment %d):\n",s);
for (i=0;i<Kr_bytes;i++)
printf("%d : %x (%x)\n",i,PHY_vars_UE->dlsch_ue[0][cw_sic]->harq_processes[0]->c[s][i],
PHY_vars_UE->dlsch_ue[0][cw_sic]->harq_processes[0]->c[s][i]^PHY_vars_eNB->dlsch_eNB[0][cw_sic]->harq_processes[0]->c[s][i]);
......@@ -3854,8 +3874,6 @@ n(tikz_fname,"w");
}
}
else {
errs[cw_sic][round]++;
// exit(0);
......@@ -3911,7 +3929,7 @@ n(tikz_fname,"w");
}
if (n_frames==2) {
if (n_frames==1) {
//if ((n_frames==1) || (SNR>=30)) {
printf("cw %d, round %d: DLSCH errors found, uncoded ber %f\n",cw_non_sic,round,uncoded_ber);
#ifdef PRINT_BYTES
......@@ -3935,7 +3953,7 @@ n(tikz_fname,"w");
stop_meas(&PHY_vars_UE->phy_proc_rx);
if (n_frames==2) {
if (n_frames==1) {
//rxsig
sprintf(fname,"rxsig0_r%d.m",round);
......@@ -4022,8 +4040,31 @@ n(tikz_fname,"w");
subframe);
}
if ((transmission_mode != 3 && transmission_mode !=4 ) && ret[0] > PHY_vars_UE->dlsch_ue[0][0]->max_turbo_iterations){
round++;
}
if ((transmission_mode == 3 || transmission_mode == 4 ) && (ret[0] > PHY_vars_UE->dlsch_ue[0][0]->max_turbo_iterations) && (ret[1] > PHY_vars_UE->dlsch_ue[0][0]->max_turbo_iterations)){
resend_both[round]++;
round++;
resend_cw0_cw1=1; //resend both cws
resend_cw1=0;
}
if ((transmission_mode == 3 || transmission_mode == 4 ) && (ret[1] > PHY_vars_UE->dlsch_ue[0][0]->max_turbo_iterations ) && (ret[0] <= PHY_vars_UE->dlsch_ue[0][0]->max_turbo_iterations)){
resend_one[round]++;
round++;
} //round
resend_cw0_cw1=0;
resend_cw1=1; //resend only cw1, alamouti
}
}
//} //round
if(transmission_mode != 3 && transmission_mode !=4 ){
if ((errs[0][0]>=n_frames/10) && (trials>(n_frames/2)) )
......@@ -4082,6 +4123,8 @@ n(tikz_fname,"w");
} //trials
printf("both failed round 0 = %d, both failed round 1 = %d, both failed round 2 = %d, both failed round 3 = %d\n", resend_both[0], resend_both[1], resend_both[2], resend_both[3]);
printf("one failed round 0 = %d, one failed round 1 = %d, one failed round 2 = %d, one failed round 3 = %d\n", resend_one[0], resend_one[1], resend_one[2], resend_one[3]);
// round_trials[0]: number of code word : goodput the protocol
double table_tx[time_vector_tx.size];
......@@ -4170,7 +4213,15 @@ n(tikz_fname,"w");
double std_phy_proc_rx_demod=0;
double std_phy_proc_rx_dec=0;
effective_rate = ((double)(round_trials[0]-dci_errors)/((double)round_trials[0] + round_trials[1] + round_trials[2] + round_trials[3]));
if (transmission_mode != 3 && transmission_mode !=4) {
effective_rate = ((double)(round_trials[0][0]-dci_errors)/((double)round_trials[0][0] + round_trials[0][1] + round_trials[0][2] + round_trials[0][3]));
}
else {
effective_rate = ((double)(round_trials[0][0]-dci_errors)/((double)round_trials[0][0] + round_trials[0][1] + round_trials[0][2] + round_trials[0][3]))+
((double)(round_trials[1][0])/((double)round_trials[1][0] + round_trials[1][1] + round_trials[1][2] + round_trials[1][3]));
}
printf("\n**********************SNR = %f dB (tx_lev %f, sigma2_dB %f)**************************\n",
SNR,
......@@ -4182,39 +4233,39 @@ n(tikz_fname,"w");
"throughput stream 0 = %f , throughput stream 1 = %f, system throughput = %f , rate 0 = %f , rate 1 = %f \n",
errs[0][0],
errs[1][0],
round_trials[0],
round_trials[0][0],
errs[0][1],
errs[1][1],
round_trials[0],
round_trials[0][0],
errs[0][2],
errs[1][2],
round_trials[0],
round_trials[0][0],
errs[0][3],
errs[1][3],
round_trials[0],
(double)errs[0][0]/(round_trials[0]),
(double)errs[1][0]/(round_trials[0]),
(double)errs[0][1]/(round_trials[0]),
(double)errs[1][1]/(round_trials[0]),
(double)errs[0][2]/(round_trials[0]),
(double)errs[1][2]/(round_trials[0]),
(double)errs[0][3]/(round_trials[0]),
(double)errs[1][3]/(round_trials[0]),
round_trials[0][0],
(double)errs[0][0]/(round_trials[0][0]),
(double)errs[1][0]/(round_trials[0][0]),
(double)errs[0][1]/(round_trials[0][0]),
(double)errs[1][1]/(round_trials[0][0]),
(double)errs[0][2]/(round_trials[0][0]),
(double)errs[1][2]/(round_trials[0][0]),
(double)errs[0][3]/(round_trials[0][0]),
(double)errs[1][3]/(round_trials[0][0]),
dci_errors,
round_trials[0],
(double)dci_errors/(round_trials[0]),
round_trials[0][0],
(double)dci_errors/(round_trials[0][0]),
rate[0]*effective_rate,
100*effective_rate,
rate[0],
rate[0]*get_Qm(PHY_vars_UE->dlsch_ue[0][0]->harq_processes[PHY_vars_UE->dlsch_ue[0][0]->current_harq_pid]->mcs),
(1.0*(round_trials[0]-errs[0][0])+2.0*(round_trials[1]-errs[0][1])+3.0*(round_trials[2]-errs[0][2])+
4.0*(round_trials[3]-errs[0][3]))/((double)round_trials[0])/(double)PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->TBS,
(1.0*(round_trials[0]-errs[0][0])+2.0*(round_trials[1]-errs[0][1])+3.0*(round_trials[2]-errs[0][2])
+4.0*(round_trials[3]-errs[0][3]))/((double)round_trials[0]),
rate[0]*get_Qm(PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->mcs)*(1-((double)errs[0][0]/(double)round_trials[0])),
rate[1]*get_Qm(PHY_vars_eNB->dlsch_eNB[0][1]->harq_processes[0]->mcs)*(1-((double)errs[1][0]/(double)round_trials[0])),
rate[0]*get_Qm(PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->mcs)*(1-((double)errs[0][0]/(double)round_trials[0]))+
rate[1]*get_Qm(PHY_vars_eNB->dlsch_eNB[0][1]->harq_processes[0]->mcs)*(1-((double)errs[1][0]/(double)round_trials[0])),
(1.0*(round_trials[0][0]-errs[0][0])+2.0*(round_trials[0][1]-errs[0][1])+3.0*(round_trials[0][2]-errs[0][2])+
4.0*(round_trials[0][3]-errs[0][3]))/((double)round_trials[0][0])/(double)PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->TBS,
(1.0*(round_trials[0][0]-errs[0][0])+2.0*(round_trials[0][1]-errs[0][1])+3.0*(round_trials[0][2]-errs[0][2])
+4.0*(round_trials[0][3]-errs[0][3]))/((double)round_trials[0][0]),
rate[0]*get_Qm(PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->mcs)*(1-((double)errs[0][0]/(double)round_trials[0][0])),
rate[1]*get_Qm(PHY_vars_eNB->dlsch_eNB[0][1]->harq_processes[0]->mcs)*(1-((double)errs[1][0]/(double)round_trials[0][1])),
rate[0]*get_Qm(PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->mcs)*(1-((double)errs[0][0]/(double)round_trials[0][0]))+
rate[1]*get_Qm(PHY_vars_eNB->dlsch_eNB[0][1]->harq_processes[0]->mcs)*(1-((double)errs[1][0]/(double)round_trials[0][1])),
rate[0],
rate[1]);
......@@ -4330,13 +4381,13 @@ n(tikz_fname,"w");
PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->TBS,
rate[0],
errs[0][0],
round_trials[0],
round_trials[0][0],
errs[0][1],
round_trials[1],
round_trials[0][1],
errs[0][2],
round_trials[2],
round_trials[0][2],
errs[0][3],
round_trials[3],
round_trials[0][3],
dci_errors);
}
else {
......@@ -4350,34 +4401,34 @@ n(tikz_fname,"w");
rate[1],
errs[0][0],
errs[1][0],
round_trials[0],
round_trials[0][0],
errs[0][1],
errs[1][1],
round_trials[1],
round_trials[0][1],
errs[0][2],
errs[1][2],
round_trials[2],
round_trials[0][2],
errs[0][3],
errs[1][3],
round_trials[3],
rate[0]*get_Qm(PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->mcs)*(1-((double)errs[0][0]/(double)round_trials[0])),
rate[1]*get_Qm(PHY_vars_eNB->dlsch_eNB[0][1]->harq_processes[0]->mcs)*(1-((double)errs[1][0]/(double)round_trials[0])),
rate[0]*get_Qm(PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->mcs)*(1-((double)errs[0][0]/(double)round_trials[0]))+
rate[1]*get_Qm(PHY_vars_eNB->dlsch_eNB[0][1]->harq_processes[0]->mcs)*(1-((double)errs[1][0]/(double)round_trials[0])),
round_trials[0][3],
rate[0]*get_Qm(PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->mcs)*(1-((double)errs[0][0]/(double)round_trials[0][0])),
rate[1]*get_Qm(PHY_vars_eNB->dlsch_eNB[0][1]->harq_processes[0]->mcs)*(1-((double)errs[1][0]/(double)round_trials[1][0])),
rate[0]*get_Qm(PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->mcs)*(1-((double)errs[0][0]/(double)round_trials[0][0]))+
rate[1]*get_Qm(PHY_vars_eNB->dlsch_eNB[0][1]->harq_processes[0]->mcs)*(1-((double)errs[1][0]/(double)round_trials[1][0])),
dci_errors);
}
if(abstx){ //ABSTRACTION
if ((transmission_mode != 3)&& (transmission_mode != 4)) {
blerr[0][0] = (double)errs[0][0]/(round_trials[0]);
blerr[0][0] = (double)errs[0][0]/(round_trials[0][0]);
if(num_rounds>1){
blerr[0][1] = (double)errs[0][1]/(round_trials[1]);
blerr[0][1] = (double)errs[0][1]/(round_trials[0][1]);
blerr[0][2] = (double)errs[0][2]/(round_trials[2]);
blerr[0][2] = (double)errs[0][2]/(round_trials[0][2]);
blerr[0][3] = (double)errs[0][3]/(round_trials[3]);
blerr[0][3] = (double)errs[0][3]/(round_trials[0][3]);
fprintf(csv_fd,"%e;%e;%e;%e;\n",blerr[0][0],blerr[0][1],blerr[0][2],blerr[0][3]);
}
......@@ -4386,15 +4437,15 @@ n(tikz_fname,"w");
}
}
else {
blerr[0][0] = (double)errs[0][0]/(round_trials[0]);
blerr[1][0] = (double)errs[1][0]/(round_trials[0]);
blerr[0][0] = (double)errs[0][0]/(round_trials[0][0]);
blerr[1][0] = (double)errs[1][0]/(round_trials[0][0]);
if(num_rounds>1){
blerr[0][1] = (double)errs[0][1]/(round_trials[1]);
blerr[1][1] = (double)errs[1][1]/(round_trials[1]);
blerr[0][2] = (double)errs[0][2]/(round_trials[2]);
blerr[1][2] = (double)errs[1][2]/(round_trials[2]);
blerr[0][3] = (double)errs[0][3]/(round_trials[3]);
blerr[1][3] = (double)errs[1][3]/(round_trials[3]);
blerr[0][1] = (double)errs[0][1]/(round_trials[0][1]);
blerr[1][1] = (double)errs[1][1]/(round_trials[1][1]);
blerr[0][2] = (double)errs[0][2]/(round_trials[0][2]);
blerr[1][2] = (double)errs[1][2]/(round_trials[1][2]);
blerr[0][3] = (double)errs[0][3]/(round_trials[0][3]);
blerr[1][3] = (double)errs[1][3]/(round_trials[1][3]);
fprintf(csv_fd,"%e;%e;%e;%e;%e;%e;%e;%e;\n",blerr[0][0],blerr[1][0],blerr[0][1],blerr[1][1],blerr[0][2],blerr[1][2], blerr[0][3], blerr[1][3]);
}
else {
......@@ -4412,13 +4463,13 @@ n(tikz_fname,"w");
PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->TBS,
rate[0],
errs[0][0],
round_trials[0],
round_trials[0][0],
errs[0][1],
round_trials[1],
round_trials[0][1],
errs[0][2],
round_trials[2],
round_trials[0][2],
errs[0][3],
round_trials[3],
round_trials[0][3],
dci_errors);
//fprintf(time_meas_fd,"SNR; MCS; TBS; rate; DL_DECOD_ITER; err0; trials0; err1; trials1; err2; trials2; err3; trials3; PE; dci_err;PE;ND;\n");
......@@ -4438,15 +4489,15 @@ n(tikz_fname,"w");
round_trials[2],
errs[0][3],
round_trials[3],
(double)errs[0][0]/(round_trials[0]),
(double)errs[0][1]/(round_trials[0]),
(double)errs[0][2]/(round_trials[0]),
(double)errs[0][3]/(round_trials[0]),
(double)errs[0][0]/(round_trials[0][0]),
(double)errs[0][1]/(round_trials[0][0]),
(double)errs[0][2]/(round_trials[0][0]),
(double)errs[0][3]/(round_trials[0][0]),
dci_errors,
round_trials[0],
(double)dci_errors/(round_trials[0]),
(1.0*(round_trials[0]-errs[0][0])+2.0*(round_trials[1]-errs[0][1])+3.0*(round_trials[2]-errs[0][2])+4.0*(round_trials[3]-errs[0][3]))/((double)round_trials[0])/(double)PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->TBS,
(1.0*(round_trials[0]-errs[0][0])+2.0*(round_trials[1]-errs[0][1])+3.0*(round_trials[2]-errs[0][2])+4.0*(round_trials[3]-errs[0][3]))/((double)round_trials[0]));
(double)dci_errors/(round_trials[0][0]),
(1.0*(round_trials[0][0]-errs[0][0])+2.0*(round_trials[0][1]-errs[0][1])+3.0*(round_trials[0][2]-errs[0][2])+4.0*(round_trials[0][3]-errs[0][3]))/((double)round_trials[0][0])/(double)PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->TBS,
(1.0*(round_trials[0][0]-errs[0][0])+2.0*(round_trials[0][1]-errs[0][1])+3.0*(round_trials[0][2]-errs[0][2])+4.0*(round_trials[0][3]-errs[0][3]))/((double)round_trials[0][0]));
}
else {
fprintf(time_meas_fd,"%f;%d;%d;%d;%d;%f;%d;%d;%d;%d;%d;%d;%d;%d;%d;",
......@@ -4456,13 +4507,13 @@ n(tikz_fname,"w");
PHY_vars_eNB->dlsch_eNB[0][1]->harq_processes[0]->TBS,
rate[0],
errs[0][0],
round_trials[0],
round_trials[0][0],
errs[0][1],
round_trials[1],
round_trials[0][1],
errs[0][2],
round_trials[2],
round_trials[0][2],
errs[0][3],
round_trials[3],
round_trials[0][3],
dci_errors);
//fprintf(time_meas_fd,"SNR; MCS; TBS; rate; DL_DECOD_ITER; err0; trials0; err1; trials1; err2; trials2; err3; trials3; PE; dci_err;PE;ND;\n");
......@@ -4476,22 +4527,22 @@ n(tikz_fname,"w");
rate[0],
(double)avg_iter[0]/iter_trials[0],
errs[0][0],
round_trials[0],
round_trials[0][0],
errs[0][1],
round_trials[1],
round_trials[0][1],
errs[0][2],
round_trials[2],
round_trials[0][2],
errs[0][3],
round_trials[3],
(double)errs[0][0]/(round_trials[0]),
(double)errs[0][1]/(round_trials[0]),
(double)errs[0][2]/(round_trials[0]),
(double)errs[0][3]/(round_trials[0]),
(double)errs[0][0]/(round_trials[0][0]),
(double)errs[0][1]/(round_trials[0][0]),
(double)errs[0][2]/(round_trials[0][0]),
(double)errs[0][3]/(round_trials[0][0]),
dci_errors,
round_trials[0],
(double)dci_errors/(round_trials[0]),
(1.0*(round_trials[0]-errs[0][0])+2.0*(round_trials[1]-errs[0][1])+3.0*(round_trials[2]-errs[0][2])+4.0*(round_trials[3]-errs[0][3]))/((double)round_trials[0])/(double)PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->TBS,
(1.0*(round_trials[0]-errs[0][0])+2.0*(round_trials[1]-errs[0][1])+3.0*(round_trials[2]-errs[0][2])+4.0*(round_trials[3]-errs[0][3]))/((double)round_trials[0]));
round_trials[0][0],
(double)dci_errors/(round_trials[0][0]),
(1.0*(round_trials[0][0]-errs[0][0])+2.0*(round_trials[0][1]-errs[0][1])+3.0*(round_trials[0][2]-errs[0][2])+4.0*(round_trials[0][3]-errs[0][3]))/((double)round_trials[0][0])/(double)PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->TBS,
(1.0*(round_trials[0][0]-errs[0][0])+2.0*(round_trials[0][1]-errs[0][1])+3.0*(round_trials[0][2]-errs[0][2])+4.0*(round_trials[0][3]-errs[0][3]))/((double)round_trials[0][0]));
}
//fprintf(time_meas_fd,"eNB_PROC_TX(%d); OFDM_MOD(%d); DL_MOD(%d); DL_SCR(%d); DL_ENC(%d); UE_PROC_RX(%d); OFDM_DEMOD_CH_EST(%d); RX_PDCCH(%d); CH_COMP_LLR(%d); DL_USCR(%d); DL_DECOD(%d);\n",
fprintf(time_meas_fd,"%d; %d; %d; %d; %d; %d; %d; %d; %d; %d; %d;",
......@@ -4567,11 +4618,12 @@ n(tikz_fname,"w");
}
if (abstx == 1) {
if ((rx_type==rx_IC_dual_stream) || (rx_type==rx_standard)) {
if (((double)errs[0][0]/(round_trials[0]))<1e-2 && ((double)errs[1][0]/(round_trials[0]))<1e-2)
if (((double)errs[0][0]/(round_trials[0][0]))<1e-2 && ((double)errs[1][0]/(round_trials[1][0]))<1e-2)
if (((double)errs[0][0]/(round_trials[0][0]))<1e-2 && ((double)errs[1][0]/(round_trials[1][0]))<1e-2)
break;
}
else{
if (((double)errs[0][0]/(round_trials[0]))<1e-2)
if (((double)errs[0][0]/(round_trials[0][0]))<1e-2)
break;
}
......@@ -4579,11 +4631,11 @@ n(tikz_fname,"w");
else {
if ((rx_type==rx_IC_dual_stream) || (rx_type==rx_standard) || (rx_type==rx_SIC_dual_stream)) {
if (((double)errs[0][0]/(round_trials[0]))<1e-3 && ((double)errs[1][0]/(round_trials[0]))<1e-3)
if (((double)errs[0][0]/(round_trials[0][0]))<1e-3 && ((double)errs[1][0]/(round_trials[1][0]))<1e-3)
break;
}
else{
if (((double)errs[0][0]/(round_trials[0]))<1e-3)
if (((double)errs[0][0]/(round_trials[0][0]))<1e-3)
break;
}
......
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