Commit 9c652258 authored by Elena_Lukashova's avatar Elena_Lukashova

Full Support for TM4 HARQ, excpept for PUSCH precoder at this moment.

parent 630e39ae
......@@ -44,6 +44,7 @@
#include "PHY/vars.h"
#endif
#include "assertions.h"
//#define DEBUG_HARQ
//#define DEBUG_DCI
......@@ -1525,7 +1526,9 @@ int generate_eNB_dlsch_params_from_dci(int frame,
dlsch1_harq->status = ACTIVE;
dlsch0_harq->codeword=0;
dlsch1_harq->codeword=1;
#ifdef DEBUG_HARQ
printf("\n ENB: BOTH ACTIVE\n");
#endif
}
else if (TB0_active && TB1_active && tbswap==1) {
dlsch0=dlsch[0];
......@@ -1564,7 +1567,9 @@ int generate_eNB_dlsch_params_from_dci(int frame,
dlsch1_harq->codeword = 0;
dlsch0=NULL;
dlsch0_harq = NULL;
#ifdef DEBUG_HARQ
printf("\n ENB: TB0 is deactivated, retransmit TB1 transmit in TM6\n");
#endif
}
if (dlsch0 != NULL){
......@@ -2800,8 +2805,15 @@ int generate_eNB_dlsch_params_from_dci(int frame,
#endif
// compute DL power control parameters
if (dlsch0 != NULL){
computeRhoA_eNB(pdsch_config_dedicated, dlsch[0],dlsch0_harq->dl_power_off, frame_parms->nb_antennas_tx_eNB);
computeRhoB_eNB(pdsch_config_dedicated,&(frame_parms->pdsch_config_common),frame_parms->nb_antennas_tx_eNB,dlsch[0],dlsch0_harq->dl_power_off);
}
if (dlsch1 != NULL){
computeRhoA_eNB(pdsch_config_dedicated, dlsch[1],dlsch1_harq->dl_power_off, frame_parms->nb_antennas_tx_eNB);
computeRhoB_eNB(pdsch_config_dedicated,&(frame_parms->pdsch_config_common),frame_parms->nb_antennas_tx_eNB,dlsch[1],dlsch1_harq->dl_power_off);
}
return(0);
}
......@@ -4879,6 +4891,9 @@ int generate_ue_dlsch_params_from_dci(int frame,
if ((rv2 == 1) && (mcs2 == 0)) {
TB1_active=0;
}
#ifdef DEBUG_HARQ
printf("[DCI UE]: TB0 status %d , TB1 status %d\n", TB0_active, TB1_active);
#endif
//printf("RV TB0 = %d\n", rv1);
......@@ -4898,7 +4913,9 @@ int generate_ue_dlsch_params_from_dci(int frame,
dlsch1_harq->status = ACTIVE;
dlsch0_harq->codeword=0;
dlsch1_harq->codeword=1;
//printf("\n UE: BOTH ACTIVE\n");
#ifdef DEBUG_HARQ
printf("[DCI UE]: BOTH ACTIVE\n");
#endif
}
else if (TB0_active && TB1_active && tbswap==1) {
dlsch0=dlsch[0];
......@@ -4937,7 +4954,9 @@ int generate_ue_dlsch_params_from_dci(int frame,
dlsch1_harq->codeword = 0;
dlsch0=NULL;
dlsch0_harq = NULL;
//printf("\n UE: TB0 is deactivated, retransmit TB1 transmit in TM6\n");
#ifdef DEBUG_HARQ
printf("[DCI UE]: TB0 is deactivated, retransmit TB1 transmit in TM6\n");
#endif
}
......@@ -4990,7 +5009,9 @@ int generate_ue_dlsch_params_from_dci(int frame,
dlsch1_harq->rb_alloc_odd[1]= dlsch1_harq->rb_alloc_even[1];
dlsch1_harq->rb_alloc_odd[2]= dlsch1_harq->rb_alloc_even[2];
dlsch1_harq->rb_alloc_odd[3]= dlsch1_harq->rb_alloc_even[3];
dlsch1_harq->nb_rb = dlsch0_harq->nb_rb;
dlsch1_harq->nb_rb = conv_nprb(rah,
rballoc,
frame_parms->N_RB_DL);
}
......@@ -5010,6 +5031,9 @@ int generate_ue_dlsch_params_from_dci(int frame,
if (dlsch1_harq != NULL)
dlsch1_harq->Nl = 1;
#ifdef DEBUG_HARQ
printf ("[DCI UE] tpmi = %d\n", tpmi);
#endif
if ((dlsch0 != NULL) && (dlsch1 != NULL)){ //two CW active
......@@ -5112,7 +5136,10 @@ int generate_ue_dlsch_params_from_dci(int frame,
break;
}
}
#ifdef DEBUG_HARQ
printf("[DCI UE] harq1 MIMO mode = %d\n", dlsch1_harq->mimo_mode);
#endif
//printf(" UE DCI harq0 MIMO mode = %d\n", dlsch0_harq->mimo_mode);
if ((frame_parms->mode1_flag == 1) && (dlsch0_harq != NULL))
dlsch0_harq->mimo_mode = SISO;
......@@ -5196,6 +5223,12 @@ int generate_ue_dlsch_params_from_dci(int frame,
dlsch1->rnti = rnti;
}
#ifdef DEBUG_HARQ
if (dlsch0 != NULL)
printf("[DCI UE] dlsch0_harq status = %d, dlsch1_harq status = %d\n", dlsch0_harq->status, dlsch1_harq->status);
else
printf("[DCI UE] dlsch1_harq status = %d\n", dlsch1_harq->status);
#endif
break;
......@@ -5869,11 +5902,19 @@ int generate_ue_dlsch_params_from_dci(int frame,
}
#endif
dlsch[0]->active=1;
//dlsch[0]->active=1;
// compute DL power control parameters
if (dlsch0_harq != NULL){
computeRhoA_UE(pdsch_config_dedicated, dlsch[0],dlsch0_harq->dl_power_off, frame_parms->nb_antennas_tx_eNB);
computeRhoB_UE(pdsch_config_dedicated,&(frame_parms->pdsch_config_common),frame_parms->nb_antennas_tx_eNB,dlsch[0],dlsch0_harq->dl_power_off);
}
if (dlsch1_harq != NULL) {
computeRhoA_UE(pdsch_config_dedicated, dlsch[1],dlsch1_harq->dl_power_off, frame_parms->nb_antennas_tx_eNB);
computeRhoB_UE(pdsch_config_dedicated,&(frame_parms->pdsch_config_common),frame_parms->nb_antennas_tx_eNB,dlsch[1],dlsch1_harq->dl_power_off);
}
return(0);
}
......
......@@ -37,8 +37,7 @@
* \note
* \warning
*/
#include "PHY/defs.h"
//#include "PHY/defs.h"
#include "PHY/extern.h"
#include "defs.h"
#include "extern.h"
......@@ -51,6 +50,8 @@
#define NOCYGWIN_STATIC
#endif
//#define DEBUG_HARQ
//#undef LOG_D
//#define LOG_D LOG_I
......@@ -139,12 +140,30 @@ int rx_pdsch(PHY_VARS_UE *phy_vars_ue,
break;
case PDSCH:
lte_ue_pdsch_vars = &phy_vars_ue->lte_ue_pdsch_vars[eNB_id];
dlsch_ue = phy_vars_ue->dlsch_ue[eNB_id];
if ((dlsch_ue[0]->harq_processes[harq_pid]->status == ACTIVE) &&
(dlsch_ue[1]->harq_processes[harq_pid]->status == ACTIVE)){
codeword_TB0 = dlsch_ue[0]->harq_processes[harq_pid]->codeword;
codeword_TB1 = dlsch_ue[1]->harq_processes[harq_pid]->codeword;
dlsch0_harq = dlsch_ue[codeword_TB0]->harq_processes[harq_pid];
dlsch1_harq = dlsch_ue[codeword_TB1]->harq_processes[harq_pid];
}
else if ((dlsch_ue[0]->harq_processes[harq_pid]->status == ACTIVE) &&
(dlsch_ue[1]->harq_processes[harq_pid]->status != ACTIVE) ) {
codeword_TB0 = dlsch_ue[0]->harq_processes[harq_pid]->codeword;
dlsch0_harq = dlsch_ue[0]->harq_processes[harq_pid];
dlsch1_harq = NULL;
codeword_TB1 = -1;
}
else if ((dlsch_ue[0]->harq_processes[harq_pid]->status != ACTIVE) &&
(dlsch_ue[1]->harq_processes[harq_pid]->status == ACTIVE) ){
codeword_TB1 = dlsch_ue[1]->harq_processes[harq_pid]->codeword;
dlsch0_harq = dlsch_ue[1]->harq_processes[harq_pid];
dlsch1_harq = NULL;
codeword_TB0 = -1;
}
break;
default:
......@@ -152,6 +171,10 @@ int rx_pdsch(PHY_VARS_UE *phy_vars_ue,
return(-1);
break;
}
#ifdef DEBUG_HARQ
printf("[DEMOD] MIMO mode = %d\n", dlsch0_harq->mimo_mode);
printf("[DEMOD] cw for TB0 = %d, cw for TB1 = %d\n", codeword_TB0, codeword_TB1);
#endif
DevAssert(dlsch0_harq);
round = dlsch0_harq->round;
......@@ -311,6 +334,7 @@ int rx_pdsch(PHY_VARS_UE *phy_vars_ue,
if (dlsch0_harq->mimo_mode<LARGE_CDD) {// SISO or ALAMOUTI
dlsch_scale_channel(lte_ue_pdsch_vars[eNB_id]->dl_ch_estimates_ext,
frame_parms,
dlsch_ue,
......@@ -629,6 +653,7 @@ int rx_pdsch(PHY_VARS_UE *phy_vars_ue,
nb_rb);
if (first_symbol_flag==1) {
dlsch_channel_level(lte_ue_pdsch_vars[eNB_id]->dl_ch_estimates_ext,
frame_parms,
avg,
......@@ -645,12 +670,12 @@ int rx_pdsch(PHY_VARS_UE *phy_vars_ue,
avgs = cmax(avgs,avg[(aatx<<1)+aarx]);
// avgs = cmax(avgs,avg[(aarx<<1)+aatx]);
lte_ue_pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2) + interf_unaw_shift_tm1_mcs[dlsch0_harq->mcs];
lte_ue_pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2) + 1;
lte_ue_pdsch_vars[eNB_id]->log2_maxh++;
}
dlsch_channel_compensation_TM56(lte_ue_pdsch_vars[eNB_id]->rxdataF_ext,
lte_ue_pdsch_vars[eNB_id]->dl_ch_estimates_ext,
lte_ue_pdsch_vars[eNB_id]->dl_ch_mag0,
......@@ -748,7 +773,7 @@ int rx_pdsch(PHY_VARS_UE *phy_vars_ue,
switch (dlsch0_harq->Qm) {
case 2 :
if (rx_type==rx_standard) {
if ((rx_type==rx_standard) || (codeword_TB0 = 1)) {
dlsch_qpsk_llr(frame_parms,
lte_ue_pdsch_vars[eNB_id]->rxdataF_comp0,
lte_ue_pdsch_vars[eNB_id]->llr[0],
......@@ -824,7 +849,7 @@ int rx_pdsch(PHY_VARS_UE *phy_vars_ue,
}
break;
case 4 :
if (rx_type==rx_standard) {
if ((rx_type==rx_standard ) || (codeword_TB0 = 1) ) {
dlsch_16qam_llr(frame_parms,
lte_ue_pdsch_vars[eNB_id]->rxdataF_comp0,
lte_ue_pdsch_vars[eNB_id]->llr[0],
......@@ -833,7 +858,7 @@ int rx_pdsch(PHY_VARS_UE *phy_vars_ue,
adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,subframe,symbol),
lte_ue_pdsch_vars[eNB_id]->llr128);
}
else if (rx_type >= rx_IC_single_stream) {
else if ((rx_type >= rx_IC_single_stream) && (codeword_TB0 != -1)) {
if (dlsch1_harq->Qm == 2) {
dlsch_16qam_qpsk_llr(frame_parms,
lte_ue_pdsch_vars[eNB_id]->rxdataF_comp0,
......@@ -907,7 +932,7 @@ int rx_pdsch(PHY_VARS_UE *phy_vars_ue,
}
break;
case 6 :
if (rx_type==rx_standard) {
if ((rx_type==rx_standard) || (codeword_TB0 == -1)) {
dlsch_64qam_llr(frame_parms,
lte_ue_pdsch_vars[eNB_id]->rxdataF_comp0,
lte_ue_pdsch_vars[eNB_id]->llr[0],
......@@ -917,7 +942,7 @@ int rx_pdsch(PHY_VARS_UE *phy_vars_ue,
adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,subframe,symbol),
lte_ue_pdsch_vars[eNB_id]->llr128);
}
else if (rx_type >= rx_IC_single_stream) {
else if ((rx_type >= rx_IC_single_stream) && (codeword_TB0 != -1)){
if (dlsch1_harq->Qm == 2) {
dlsch_64qam_qpsk_llr(frame_parms,
lte_ue_pdsch_vars[eNB_id]->rxdataF_comp0,
......
......@@ -156,7 +156,7 @@ int allocate_REs_in_RB(LTE_DL_FRAME_PARMS *frame_parms,
uint8_t *x0 = NULL; //dlsch0_harq->e;
MIMO_mode_t mimo_mode = dlsch0_harq->mimo_mode;
MIMO_mode_t mimo_mode;//= dlsch0_harq->mimo_mode;
int first_layer0; //= dlsch0_harq->first_layer;
int Nlayers0; // = dlsch0_harq->Nlayers;
......@@ -1411,8 +1411,13 @@ int dlsch_modulation(int32_t **txdataF,
nsymb = (frame_parms->Ncp==0) ? 14:12;
if (dlsch0 != NULL){
amp_rho_a = (int16_t)(((int32_t)amp*dlsch0->sqrt_rho_a)>>13); //amp=512 in full scale; dlsch0->sqrt_rho_a=8192in Q2.13, 1 in full scale
amp_rho_b = (int16_t)(((int32_t)amp*dlsch0->sqrt_rho_b)>>13);
} else{
amp_rho_a = (int16_t)(((int32_t)amp*dlsch1->sqrt_rho_a)>>13);
amp_rho_b = (int16_t)(((int32_t)amp*dlsch1->sqrt_rho_b)>>13);
}
if (mod_order0 == 4)
for (i=0; i<4; i++) {
......@@ -1445,6 +1450,7 @@ int dlsch_modulation(int32_t **txdataF,
// printf("num_pdcch_symbols %d, nsymb %d\n",num_pdcch_symbols,nsymb);
for (l=num_pdcch_symbols; l<nsymb; l++) {
if (dlsch0 != NULL ) {
#ifdef DEBUG_DLSCH_MODULATION
printf("Generating DLSCH (harq_pid %d,mimo %d, pmi_alloc0 %lx, mod0 %d, mod1 %d, rb_alloc[0] %d) in %d\n",
harq_pid,
......@@ -1455,6 +1461,7 @@ int dlsch_modulation(int32_t **txdataF,
rb_alloc[0],
len);
#endif
}
if (frame_parms->Ncp==0) { // normal prefix
if ((l==4)||(l==11))
......@@ -1611,10 +1618,12 @@ int dlsch_modulation(int32_t **txdataF,
}
}
if (dlsch0) {
if (dlsch0_harq->Nlayers>1) {
msg("Nlayers %d: re_offset %d, symbol %d offset %d\n",dlsch0_harq->Nlayers,re_offset,l,symbol_offset);
return(-1);
}
}
if (dlsch1) {
if (dlsch1_harq->Nlayers>1) {
......@@ -1639,6 +1648,17 @@ int dlsch_modulation(int32_t **txdataF,
if (rb_alloc_ind > 0) {
// printf("Allocated rb %d/symbol %d, skip_half %d, subframe_offset %d, symbol_offset %d, re_offset %d, jj %d\n",rb,l,skip_half,subframe_offset,symbol_offset,re_offset,jj);
if (dlsch0 != NULL) {
get_pmi_temp = get_pmi(frame_parms->N_RB_DL,
dlsch0->harq_processes[harq_pid]->mimo_mode,
dlsch0->harq_processes[harq_pid]->pmi_alloc,
rb);
} else
get_pmi_temp = get_pmi(frame_parms->N_RB_DL,
dlsch1->harq_processes[harq_pid]->mimo_mode,
dlsch1->harq_processes[harq_pid]->pmi_alloc,
rb);
allocate_REs_in_RB(frame_parms,
txdataF,
......@@ -1646,11 +1666,11 @@ int dlsch_modulation(int32_t **txdataF,
&jj2,
re_offset,
symbol_offset,
dlsch0->harq_processes[harq_pid],
(dlsch1==NULL) ? NULL : dlsch1->harq_processes[harq_pid],
(dlsch0 == NULL) ? NULL : dlsch0->harq_processes[harq_pid],
(dlsch1 == NULL) ? NULL : dlsch1->harq_processes[harq_pid],
pilots,
((pilots) ? amp_rho_b : amp_rho_a),
get_pmi(frame_parms->N_RB_DL,dlsch0->harq_processes[harq_pid]->mimo_mode,dlsch0->harq_processes[harq_pid]->pmi_alloc,rb),
get_pmi_temp,
qam_table_s0,
qam_table_s1,
&re_allocated,
......@@ -1672,7 +1692,11 @@ int dlsch_modulation(int32_t **txdataF,
}
#ifdef DEBUG_DLSCH_MODULATION
if (dlsch0 != NULL){
msg("generate_dlsch : jj = %d,re_allocated = %d (G %d)\n",jj,re_allocated,get_G(frame_parms,dlsch0_harq->nb_rb,dlsch0_harq->rb_alloc,mod_order0,Nl0,2,0,subframe_offset));
}else{
msg("generate_dlsch : jj = %d,re_allocated = %d (G %d)\n",jj,re_allocated,get_G(frame_parms,dlsch1_harq->nb_rb,dlsch1_harq->rb_alloc,mod_order1,Nl1,2,0,subframe_offset));
}
#endif
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_MODULATION, VCD_FUNCTION_OUT);
......
......@@ -46,7 +46,7 @@ double get_pa_dB(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated)
}
double computeRhoA_eNB(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated,
LTE_eNB_DLSCH_t *dlsch_eNB,int dl_power_off, uint8_t n_antenna_port){
LTE_eNB_DLSCH_t *dlsch_eNB, int dl_power_off, uint8_t n_antenna_port){
double rho_a_dB;
double sqrt_rho_a_lin;
......
......@@ -1871,7 +1871,8 @@ double computeRhoA_eNB(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated,
double computeRhoB_eNB(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated,
PDSCH_CONFIG_COMMON *pdsch_config_common,
uint8_t n_antenna_port,
LTE_eNB_DLSCH_t *dlsch_eNB,int dl_power_off);
LTE_eNB_DLSCH_t *dlsch_eNB,
int dl_power_off);
double computeRhoA_UE(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated,
LTE_UE_DLSCH_t *dlsch_ue,
......
This diff is collapsed.
......@@ -46,7 +46,7 @@ static unsigned int seed, iy, ir[98];
#define a 1664525lu
#define mod 4294967296.0 /* is 2**32 */
#if 1
void randominit(unsigned seed_init)
{
int i;
......@@ -70,9 +70,10 @@ void randominit(unsigned seed_init)
iy=1;
}
#endif
/*void randominit(unsigned seed_init)
#if 0
void randominit(unsigned seed_init)
{
int i;
// this need to be integrated with the existing rng, like taus: navid
......@@ -90,14 +91,14 @@ void randominit(unsigned seed_init)
if (seed % 2 == 0) seed += 1; /* seed and mod are relative prime */
// for (i=1; i<=97; i++) {
// seed = a*seed; /* mod 2**32 */
// ir[i]= seed; /* initialize the shuffle table */
// }
// iy=1;
//}
for (i=1; i<=97; i++) {
seed = a*seed; /* mod 2**32 */
ir[i]= seed; /* initialize the shuffle table */
}
iy=1;
}
#endif
/*!\brief Uniform linear congruential random number generator on \f$[0,1)\f$. Returns a double-precision floating-point number.*/
double uniformrandom(void)
......
......@@ -58,7 +58,7 @@ unsigned int taus(void)
s2 = (((s2 & 0xFFFFFFF0) << 17)^ b);
return s0 ^ s1 ^ s2;
}
#if 1
void set_taus_seed(unsigned int seed_init)
{
......@@ -88,8 +88,10 @@ void set_taus_seed(unsigned int seed_init)
#endif
}
}
#endif
/* void set_taus_seed(unsigned int seed_init)
#if 0
void set_taus_seed(unsigned int seed_init)
{
#ifdef USER_MODE
......@@ -113,18 +115,17 @@ void set_taus_seed(unsigned int seed_init)
s2 = (unsigned int)0xfe1a133e;
#else
// Use reentrant version of rand48 to ensure that no conflicts with other generators occur */
// srand48_r((long int)seed_init, &buffer);
// mrand48_r(&buffer, (long int *)&result);
// s0 = result;
// mrand48_r(&buffer, (long int *)&result);
// s1 = result;
// mrand48_r(&buffer, (long int *)&result);
// s2 = result;
//#endif
// }
//}
srand48_r((long int)seed_init, &buffer);
mrand48_r(&buffer, (long int *)&result);
s0 = result;
mrand48_r(&buffer, (long int *)&result);
s1 = result;
mrand48_r(&buffer, (long int *)&result);
s2 = result;
#endif
}
}
#endif
#ifdef MAIN
......
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