Commit a2e7ddee authored by knopp's avatar knopp

fixed AVX2 issue in 3gpplte_sse.c

parent 89eba068
...@@ -233,7 +233,7 @@ char interleave_compact_byte(short * base_interleaver,unsigned char * input, uns ...@@ -233,7 +233,7 @@ char interleave_compact_byte(short * base_interleaver,unsigned char * input, uns
loop++; loop++;
#endif #endif
for (i=0; i<loop ; i++ ) { for (i=0; i<loop ; i++ ) {
// int cur_byte=i<<3; // int cur_byte=i<<3;
// for (b=0;b<8;b++) // for (b=0;b<8;b++)
...@@ -438,12 +438,14 @@ char interleave_compact_byte(short * base_interleaver,unsigned char * input, uns ...@@ -438,12 +438,14 @@ char interleave_compact_byte(short * base_interleaver,unsigned char * input, uns
uint8_t *systematic2_ptr=(uint8_t *) output; uint8_t *systematic2_ptr=(uint8_t *) output;
#endif #endif
#ifndef __AVX2__ #ifndef __AVX2__
int input_length_words=n>>1; int input_length_words=1+((n-1)>>1);
#else #else
int input_length_words=n>>2; int input_length_words=1+((n-1)>>2);
#endif #endif
for ( i=0; i< input_length_words ; i ++ ) { for ( i=0; i< input_length_words ; i ++ ) {
#if defined(__x86_64__) || defined(__i386__) #if defined(__x86_64__) || defined(__i386__)
#ifndef __AVX2__ #ifndef __AVX2__
tmp=_mm_insert_epi8(tmp,expandInput[*ptr_intl++],7); tmp=_mm_insert_epi8(tmp,expandInput[*ptr_intl++],7);
...@@ -571,6 +573,7 @@ void threegpplte_turbo_encoder(unsigned char *input, ...@@ -571,6 +573,7 @@ void threegpplte_turbo_encoder(unsigned char *input,
unsigned char systematic2[768] __attribute__((aligned(32))); unsigned char systematic2[768] __attribute__((aligned(32)));
interleave_compact_byte(base_interleaver,input,systematic2,input_length_bytes); interleave_compact_byte(base_interleaver,input,systematic2,input_length_bytes);
#if defined(__x86_64__) || defined(__i386__) #if defined(__x86_64__) || defined(__i386__)
...@@ -584,7 +587,7 @@ void threegpplte_turbo_encoder(unsigned char *input, ...@@ -584,7 +587,7 @@ void threegpplte_turbo_encoder(unsigned char *input,
for ( state0=state1=i=0 ; i<input_length_bytes; i++ ) { for ( state0=state1=i=0 ; i<input_length_bytes; i++ ) {
cur_s1=input[i]; cur_s1=input[i];
cur_s2=systematic2[i]; cur_s2=systematic2[i];
for ( code_rate=0; code_rate<3; code_rate++) { for ( code_rate=0; code_rate<3; code_rate++) {
#if defined(__x86_64__) || defined(__i386__) #if defined(__x86_64__) || defined(__i386__)
/* /*
...@@ -592,6 +595,7 @@ void threegpplte_turbo_encoder(unsigned char *input, ...@@ -592,6 +595,7 @@ void threegpplte_turbo_encoder(unsigned char *input,
_mm_add_pi8(all_treillis[state0][cur_s1].parity1_64[code_rate], _mm_add_pi8(all_treillis[state0][cur_s1].parity1_64[code_rate],
all_treillis[state1][cur_s2].parity2_64[code_rate])); all_treillis[state1][cur_s2].parity2_64[code_rate]));
*/ */
*ptr_output++ = _mm_add_pi8(all_treillis[state0][cur_s1].systematic_andp1_64[code_rate], *ptr_output++ = _mm_add_pi8(all_treillis[state0][cur_s1].systematic_andp1_64[code_rate],
all_treillis[state1][cur_s2].parity2_64[code_rate]); all_treillis[state1][cur_s2].parity2_64[code_rate]);
......
...@@ -153,7 +153,7 @@ int lte_segmentation(unsigned char *input_buffer, ...@@ -153,7 +153,7 @@ int lte_segmentation(unsigned char *input_buffer,
while (k<((Kr - L)>>3)) { while (k<((Kr - L)>>3)) {
output_buffers[r][k] = input_buffer[s]; output_buffers[r][k] = input_buffer[s];
// printf("encoding segment %d : byte %d => %d\n",r,k,input_buffer[s]); // printf("encoding segment %d : byte %d (%d) => %d\n",r,k,Kr>>3,input_buffer[s]);
k++; k++;
s++; s++;
} }
......
...@@ -28,10 +28,11 @@ void lte_param_init(unsigned char N_tx, ...@@ -28,10 +28,11 @@ void lte_param_init(unsigned char N_tx,
LTE_DL_FRAME_PARMS *frame_parms; LTE_DL_FRAME_PARMS *frame_parms;
int i; int i;
printf("Start lte_param_init\n"); printf("Start lte_param_init\n");
eNB = malloc(sizeof(PHY_VARS_eNB)); eNB = malloc(sizeof(PHY_VARS_eNB));
UE = malloc(sizeof(PHY_VARS_UE)); UE = malloc(sizeof(PHY_VARS_UE));
memset((void*)eNB,0,sizeof(PHY_VARS_eNB));
memset((void*)UE,0,sizeof(PHY_VARS_UE));
//PHY_config = malloc(sizeof(PHY_CONFIG)); //PHY_config = malloc(sizeof(PHY_CONFIG));
mac_xface = malloc(sizeof(MAC_xface)); mac_xface = malloc(sizeof(MAC_xface));
......
...@@ -217,6 +217,7 @@ void phy_adjust_gain (PHY_VARS_UE *phy_vars_ue, ...@@ -217,6 +217,7 @@ void phy_adjust_gain (PHY_VARS_UE *phy_vars_ue,
unsigned char eNB_id); unsigned char eNB_id);
int lte_ul_channel_estimation(PHY_VARS_eNB *phy_vars_eNB, int lte_ul_channel_estimation(PHY_VARS_eNB *phy_vars_eNB,
eNB_rxtx_proc_t *proc,
module_id_t eNB_id, module_id_t eNB_id,
module_id_t UE_id, module_id_t UE_id,
uint8_t l, uint8_t l,
......
...@@ -53,6 +53,7 @@ static int16_t ru_90c[2*128] = {32767, 0,32766, -402,32758, -804,32746, -1206,32 ...@@ -53,6 +53,7 @@ static int16_t ru_90c[2*128] = {32767, 0,32766, -402,32758, -804,32746, -1206,32
#define SCALE 0x3FFF #define SCALE 0x3FFF
int32_t lte_ul_channel_estimation(PHY_VARS_eNB *eNB, int32_t lte_ul_channel_estimation(PHY_VARS_eNB *eNB,
eNB_rxtx_proc_t *proc,
uint8_t eNB_id, uint8_t eNB_id,
uint8_t UE_id, uint8_t UE_id,
unsigned char l, unsigned char l,
...@@ -67,8 +68,8 @@ int32_t lte_ul_channel_estimation(PHY_VARS_eNB *eNB, ...@@ -67,8 +68,8 @@ int32_t lte_ul_channel_estimation(PHY_VARS_eNB *eNB,
int32_t **ul_ch_estimates_0= pusch_vars->drs_ch_estimates_0[eNB_id]; int32_t **ul_ch_estimates_0= pusch_vars->drs_ch_estimates_0[eNB_id];
int32_t **ul_ch_estimates_1= pusch_vars->drs_ch_estimates_1[eNB_id]; int32_t **ul_ch_estimates_1= pusch_vars->drs_ch_estimates_1[eNB_id];
int32_t **rxdataF_ext= pusch_vars->rxdataF_ext[eNB_id]; int32_t **rxdataF_ext= pusch_vars->rxdataF_ext[eNB_id];
int subframe = eNB->proc.subframe_rx; int subframe = proc->subframe_rx;
uint8_t harq_pid = subframe2harq_pid(frame_parms,eNB->proc.frame_rx,subframe); uint8_t harq_pid = subframe2harq_pid(frame_parms,proc->frame_rx,subframe);
int16_t delta_phase = 0; int16_t delta_phase = 0;
int16_t *ru1 = ru_90; int16_t *ru1 = ru_90;
int16_t *ru2 = ru_90; int16_t *ru2 = ru_90;
......
...@@ -94,7 +94,7 @@ int generate_drs_pusch(PHY_VARS_UE *ue, ...@@ -94,7 +94,7 @@ int generate_drs_pusch(PHY_VARS_UE *ue,
if (Msc_idx_ptr) if (Msc_idx_ptr)
Msc_RS_idx = Msc_idx_ptr - dftsizes; Msc_RS_idx = Msc_idx_ptr - dftsizes;
else { else {
msg("generate_drs_pusch: index for Msc_RS=%d not found\n",Msc_RS); printf("generate_drs_pusch: index for Msc_RS=%d not found\n",Msc_RS);
return(-1); return(-1);
} }
...@@ -107,7 +107,7 @@ int generate_drs_pusch(PHY_VARS_UE *ue, ...@@ -107,7 +107,7 @@ int generate_drs_pusch(PHY_VARS_UE *ue,
#endif #endif
#ifdef DEBUG_DRS #ifdef DEBUG_DRS
msg("[PHY] drs_modulation: Msc_RS = %d, Msc_RS_idx = %d,cyclic_shift %d, u0 %d, v0 %d, u1 %d, v1 %d,cshift0 %d,cshift1 %d\n",Msc_RS, Msc_RS_idx,cyclic_shift,u0,v0,u1,v1,cyclic_shift0,cyclic_shift1); printf("[PHY] drs_modulation: Msc_RS = %d, Msc_RS_idx = %d,cyclic_shift %d, u0 %d, v0 %d, u1 %d, v1 %d,cshift0 %d,cshift1 %d\n",Msc_RS, Msc_RS_idx,cyclic_shift,u0,v0,u1,v1,cyclic_shift0,cyclic_shift1);
#endif #endif
...@@ -116,21 +116,17 @@ int generate_drs_pusch(PHY_VARS_UE *ue, ...@@ -116,21 +116,17 @@ int generate_drs_pusch(PHY_VARS_UE *ue,
l<frame_parms->symbols_per_tti; l<frame_parms->symbols_per_tti;
l += (7 - frame_parms->Ncp),u=u1,v=v1,cyclic_shift=cyclic_shift1) { l += (7 - frame_parms->Ncp),u=u1,v=v1,cyclic_shift=cyclic_shift1) {
drs_offset = 0; // msg("drs_modulation: Msc_RS = %d, Msc_RS_idx = %d\n",Msc_RS, Msc_RS_idx); drs_offset = 0; // printf("drs_modulation: Msc_RS = %d, Msc_RS_idx = %d\n",Msc_RS, Msc_RS_idx);
#ifdef IFFT_FPGA_UE
re_offset = frame_parms->N_RB_DL*12/2;
subframe_offset = subframe*frame_parms->symbols_per_tti*frame_parms->N_RB_UL*12;
symbol_offset = subframe_offset + frame_parms->N_RB_UL*12*l;
#else
re_offset = frame_parms->first_carrier_offset; re_offset = frame_parms->first_carrier_offset;
subframe_offset = subframe*frame_parms->symbols_per_tti*frame_parms->ofdm_symbol_size; subframe_offset = subframe*frame_parms->symbols_per_tti*frame_parms->ofdm_symbol_size;
symbol_offset = subframe_offset + frame_parms->ofdm_symbol_size*l; symbol_offset = subframe_offset + frame_parms->ofdm_symbol_size*l;
#endif
#ifdef DEBUG_DRS #ifdef DEBUG_DRS
msg("generate_drs_pusch: symbol_offset %d, subframe offset %d, cyclic shift %d\n",symbol_offset,subframe_offset,cyclic_shift); printf("generate_drs_pusch: symbol_offset %d, subframe offset %d, cyclic shift %d\n",symbol_offset,subframe_offset,cyclic_shift);
#endif #endif
alpha_ind = 0; alpha_ind = 0;
...@@ -139,60 +135,9 @@ int generate_drs_pusch(PHY_VARS_UE *ue, ...@@ -139,60 +135,9 @@ int generate_drs_pusch(PHY_VARS_UE *ue,
if ((rb >= first_rb) && (rb<(first_rb+nb_rb))) { if ((rb >= first_rb) && (rb<(first_rb+nb_rb))) {
#ifdef DEBUG_DRS #ifdef DEBUG_DRS
msg("generate_drs_pusch: doing RB %d, re_offset=%d, drs_offset=%d,cyclic shift %d\n",rb,re_offset,drs_offset,cyclic_shift); printf("generate_drs_pusch: doing RB %d, re_offset=%d, drs_offset=%d,cyclic shift %d\n",rb,re_offset,drs_offset,cyclic_shift);
#endif #endif
#ifdef IFFT_FPGA_UE
if (cyclic_shift == 0) {
for (k=0; k<12; k++) {
if ((ul_ref_sigs[u][v][Msc_RS_idx][drs_offset<<1] >= 0) && (ul_ref_sigs[u][v][Msc_RS_idx][(drs_offset<<1)+1] >= 0))
txdataF[symbol_offset+re_offset] = (int32_t) 1;
else if ((ul_ref_sigs[u][v][Msc_RS_idx][drs_offset<<1] >= 0) && (ul_ref_sigs[u][v][Msc_RS_idx][(drs_offset<<1)+1] < 0))
txdataF[symbol_offset+re_offset] = (int32_t) 2;
else if ((ul_ref_sigs[u][v][Msc_RS_idx][drs_offset<<1] < 0) && (ul_ref_sigs[u][v][Msc_RS_idx][(drs_offset<<1)+1] >= 0))
txdataF[symbol_offset+re_offset] = (int32_t) 3;
else if ((ul_ref_sigs[u][v][Msc_RS_idx][drs_offset<<1] < 0) && (ul_ref_sigs[u][v][Msc_RS_idx][(drs_offset<<1)+1] < 0))
txdataF[symbol_offset+re_offset] = (int32_t) 4;
re_offset++;
drs_offset++;
if (re_offset >= frame_parms->N_RB_UL*12)
re_offset=0;
}
} else if(cyclic_shift == 6 ) {
for (k=0; k<12; k++) {
if(k%2 == 0) {
if ((ul_ref_sigs[u][v][Msc_RS_idx][drs_offset<<1] >= 0) && (ul_ref_sigs[u][v][Msc_RS_idx][(drs_offset<<1)+1] >= 0))
txdataF[symbol_offset+re_offset] = (int32_t) 4;
else if ((ul_ref_sigs[u][v][Msc_RS_idx][drs_offset<<1] >= 0) && (ul_ref_sigs[u][v][Msc_RS_idx][(drs_offset<<1)+1] < 0))
txdataF[symbol_offset+re_offset] = (int32_t) 3;
else if ((ul_ref_sigs[u][v][Msc_RS_idx][drs_offset<<1] < 0) && (ul_ref_sigs[u][v][Msc_RS_idx][(drs_offset<<1)+1] >= 0))
txdataF[symbol_offset+re_offset] = (int32_t) 2;
else if ((ul_ref_sigs[u][v][Msc_RS_idx][drs_offset<<1] < 0) && (ul_ref_sigs[u][v][Msc_RS_idx][(drs_offset<<1)+1] < 0))
txdataF[symbol_offset+re_offset] = (int32_t) 1;
} else {
if ((ul_ref_sigs[u][v][Msc_RS_idx][drs_offset<<1] >= 0) && (ul_ref_sigs[u][v][Msc_RS_idx][(drs_offset<<1)+1] >= 0))
txdataF[symbol_offset+re_offset] = (int32_t) 1;
else if ((ul_ref_sigs[u][v][Msc_RS_idx][drs_offset<<1] >= 0) && (ul_ref_sigs[u][v][Msc_RS_idx][(drs_offset<<1)+1] < 0))
txdataF[symbol_offset+re_offset] = (int32_t) 2;
else if ((ul_ref_sigs[u][v][Msc_RS_idx][drs_offset<<1] < 0) && (ul_ref_sigs[u][v][Msc_RS_idx][(drs_offset<<1)+1] >= 0))
txdataF[symbol_offset+re_offset] = (int32_t) 3;
else if ((ul_ref_sigs[u][v][Msc_RS_idx][drs_offset<<1] < 0) && (ul_ref_sigs[u][v][Msc_RS_idx][(drs_offset<<1)+1] < 0))
txdataF[symbol_offset+re_offset] = (int32_t) 4;
}
re_offset++;
drs_offset++;
if (re_offset >= frame_parms->N_RB_UL*12)
re_offset=0;
}
}
#else //IFFT_FPGA_UE
for (k=0; k<12; k++) { for (k=0; k<12; k++) {
ref_re = (int32_t) ul_ref_sigs[u][v][Msc_RS_idx][drs_offset<<1]; ref_re = (int32_t) ul_ref_sigs[u][v][Msc_RS_idx][drs_offset<<1];
ref_im = (int32_t) ul_ref_sigs[u][v][Msc_RS_idx][(drs_offset<<1)+1]; ref_im = (int32_t) ul_ref_sigs[u][v][Msc_RS_idx][(drs_offset<<1)+1];
...@@ -211,7 +156,7 @@ int generate_drs_pusch(PHY_VARS_UE *ue, ...@@ -211,7 +156,7 @@ int generate_drs_pusch(PHY_VARS_UE *ue,
alpha_ind-=12; alpha_ind-=12;
#ifdef DEBUG_DRS #ifdef DEBUG_DRS
msg("symbol_offset %d, alpha_ind %d , re_offset %d : (%d,%d)\n", printf("symbol_offset %d, alpha_ind %d , re_offset %d : (%d,%d)\n",
symbol_offset, symbol_offset,
alpha_ind, alpha_ind,
re_offset, re_offset,
...@@ -226,21 +171,10 @@ int generate_drs_pusch(PHY_VARS_UE *ue, ...@@ -226,21 +171,10 @@ int generate_drs_pusch(PHY_VARS_UE *ue,
re_offset = 0; re_offset = 0;
} }
#endif // IFFT_FPGA_UE
} else { } else {
re_offset+=12; // go to next RB re_offset+=12; // go to next RB
// check if we crossed the symbol boundary and skip DC // check if we crossed the symbol boundary and skip DC
#ifdef IFFT_FPGA_UE
if (re_offset >= frame_parms->N_RB_DL*12) {
if (frame_parms->N_RB_DL&1) // odd number of RBs
re_offset=6;
else // even number of RBs (doesn't straddle DC)
re_offset=0;
}
#else
if (re_offset >= frame_parms->ofdm_symbol_size) { if (re_offset >= frame_parms->ofdm_symbol_size) {
if (frame_parms->N_RB_DL&1) // odd number of RBs if (frame_parms->N_RB_DL&1) // odd number of RBs
...@@ -249,7 +183,7 @@ int generate_drs_pusch(PHY_VARS_UE *ue, ...@@ -249,7 +183,7 @@ int generate_drs_pusch(PHY_VARS_UE *ue,
re_offset=0; re_offset=0;
} }
#endif
} }
} }
} }
......
...@@ -739,7 +739,7 @@ void ulsch_extract_rbs_single(int32_t **rxdataF, ...@@ -739,7 +739,7 @@ void ulsch_extract_rbs_single(int32_t **rxdataF,
nb_rb2 = 2*nb_rb - nb_rb1; // 2 times no. RBs after the DC nb_rb2 = 2*nb_rb - nb_rb1; // 2 times no. RBs after the DC
#ifdef DEBUG_ULSCH #ifdef DEBUG_ULSCH
msg("ulsch_extract_rbs_single: 2*nb_rb1 = %d, 2*nb_rb2 = %d\n",nb_rb1,nb_rb2); printf("ulsch_extract_rbs_single: 2*nb_rb1 = %d, 2*nb_rb2 = %d\n",nb_rb1,nb_rb2);
#endif #endif
rxF_ext = &rxdataF_ext[aarx][(symbol*frame_parms->N_RB_UL*12)]; rxF_ext = &rxdataF_ext[aarx][(symbol*frame_parms->N_RB_UL*12)];
...@@ -1608,7 +1608,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB, ...@@ -1608,7 +1608,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
harq_pid = subframe2harq_pid(frame_parms,proc->frame_rx,subframe); harq_pid = subframe2harq_pid(frame_parms,proc->frame_rx,subframe);
Qm = get_Qm_ul(ulsch[UE_id]->harq_processes[harq_pid]->mcs); Qm = get_Qm_ul(ulsch[UE_id]->harq_processes[harq_pid]->mcs);
#ifdef DEBUG_ULSCH #ifdef DEBUG_ULSCH
msg("rx_ulsch: eNB_id %d, harq_pid %d, nb_rb %d first_rb %d, cooperation %d\n",eNB_id,harq_pid,ulsch[UE_id]->harq_processes[harq_pid]->nb_rb,ulsch[UE_id]->harq_processes[harq_pid]->first_rb, printf("rx_ulsch: eNB_id %d, harq_pid %d, nb_rb %d first_rb %d, cooperation %d\n",eNB_id,harq_pid,ulsch[UE_id]->harq_processes[harq_pid]->nb_rb,ulsch[UE_id]->harq_processes[harq_pid]->first_rb,
cooperation_flag); cooperation_flag);
#endif //DEBUG_ULSCH #endif //DEBUG_ULSCH
...@@ -1622,7 +1622,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB, ...@@ -1622,7 +1622,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
for (l=0; l<(frame_parms->symbols_per_tti-ulsch[UE_id]->harq_processes[harq_pid]->srs_active); l++) { for (l=0; l<(frame_parms->symbols_per_tti-ulsch[UE_id]->harq_processes[harq_pid]->srs_active); l++) {
#ifdef DEBUG_ULSCH #ifdef DEBUG_ULSCH
msg("rx_ulsch : symbol %d (first_rb %d,nb_rb %d), rxdataF %p, rxdataF_ext %p\n",l, printf("rx_ulsch : symbol %d (first_rb %d,nb_rb %d), rxdataF %p, rxdataF_ext %p\n",l,
ulsch[UE_id]->harq_processes[harq_pid]->first_rb, ulsch[UE_id]->harq_processes[harq_pid]->first_rb,
ulsch[UE_id]->harq_processes[harq_pid]->nb_rb, ulsch[UE_id]->harq_processes[harq_pid]->nb_rb,
common_vars->rxdataF[eNB_id], common_vars->rxdataF[eNB_id],
...@@ -1637,7 +1637,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB, ...@@ -1637,7 +1637,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
l/(frame_parms->symbols_per_tti/2), l/(frame_parms->symbols_per_tti/2),
frame_parms); frame_parms);
lte_ul_channel_estimation(eNB, lte_ul_channel_estimation(eNB,proc,
eNB_id, eNB_id,
UE_id, UE_id,
l%(frame_parms->symbols_per_tti/2), l%(frame_parms->symbols_per_tti/2),
...@@ -1681,7 +1681,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB, ...@@ -1681,7 +1681,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
avgU_0, avgU_0,
ulsch[UE_id]->harq_processes[harq_pid]->nb_rb); ulsch[UE_id]->harq_processes[harq_pid]->nb_rb);
// msg("[ULSCH] avg_0[0] %d\n",avgU_0[0]); // printf("[ULSCH] avg_0[0] %d\n",avgU_0[0]);
avgs_0 = 0; avgs_0 = 0;
...@@ -1691,7 +1691,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB, ...@@ -1691,7 +1691,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
log2_maxh_0 = (log2_approx(avgs_0)/2)+ log2_approx(frame_parms->nb_antennas_rx-1)+3; log2_maxh_0 = (log2_approx(avgs_0)/2)+ log2_approx(frame_parms->nb_antennas_rx-1)+3;
#ifdef DEBUG_ULSCH #ifdef DEBUG_ULSCH
msg("[ULSCH] log2_maxh_0 = %d (%d,%d)\n",log2_maxh_0,avgU_0[0],avgs_0); printf("[ULSCH] log2_maxh_0 = %d (%d,%d)\n",log2_maxh_0,avgU_0[0],avgs_0);
#endif #endif
ulsch_channel_level(pusch_vars->drs_ch_estimates_1[eNB_id], ulsch_channel_level(pusch_vars->drs_ch_estimates_1[eNB_id],
...@@ -1699,7 +1699,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB, ...@@ -1699,7 +1699,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
avgU_1, avgU_1,
ulsch[UE_id]->harq_processes[harq_pid]->nb_rb); ulsch[UE_id]->harq_processes[harq_pid]->nb_rb);
// msg("[ULSCH] avg_1[0] %d\n",avgU_1[0]); // printf("[ULSCH] avg_1[0] %d\n",avgU_1[0]);
avgs_1 = 0; avgs_1 = 0;
...@@ -1709,7 +1709,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB, ...@@ -1709,7 +1709,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
log2_maxh_1 = (log2_approx(avgs_1)/2) + log2_approx(frame_parms->nb_antennas_rx-1)+3; log2_maxh_1 = (log2_approx(avgs_1)/2) + log2_approx(frame_parms->nb_antennas_rx-1)+3;
#ifdef DEBUG_ULSCH #ifdef DEBUG_ULSCH
msg("[ULSCH] log2_maxh_1 = %d (%d,%d)\n",log2_maxh_1,avgU_1[0],avgs_1); printf("[ULSCH] log2_maxh_1 = %d (%d,%d)\n",log2_maxh_1,avgU_1[0],avgs_1);
#endif #endif
log2_maxh = max(log2_maxh_0,log2_maxh_1); log2_maxh = max(log2_maxh_0,log2_maxh_1);
} else { } else {
...@@ -1718,7 +1718,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB, ...@@ -1718,7 +1718,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
avgU, avgU,
ulsch[UE_id]->harq_processes[harq_pid]->nb_rb); ulsch[UE_id]->harq_processes[harq_pid]->nb_rb);
// msg("[ULSCH] avg[0] %d\n",avgU[0]); // printf("[ULSCH] avg[0] %d\n",avgU[0]);
avgs = 0; avgs = 0;
...@@ -1731,7 +1731,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB, ...@@ -1731,7 +1731,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
log2_maxh = (log2_approx(avgs)/2)+ log2_approx(frame_parms->nb_antennas_rx-1)+4; log2_maxh = (log2_approx(avgs)/2)+ log2_approx(frame_parms->nb_antennas_rx-1)+4;
#ifdef DEBUG_ULSCH #ifdef DEBUG_ULSCH
msg("[ULSCH] log2_maxh = %d (%d,%d)\n",log2_maxh,avgU[0],avgs); printf("[ULSCH] log2_maxh = %d (%d,%d)\n",log2_maxh,avgU[0],avgs);
#endif #endif
} }
...@@ -1827,11 +1827,11 @@ void rx_ulsch(PHY_VARS_eNB *eNB, ...@@ -1827,11 +1827,11 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
//#ifdef DEBUG_ULSCH //#ifdef DEBUG_ULSCH
// Inverse-Transform equalized outputs // Inverse-Transform equalized outputs
// msg("Doing IDFTs\n"); // printf("Doing IDFTs\n");
lte_idft(frame_parms, lte_idft(frame_parms,
(uint32_t*)pusch_vars->rxdataF_comp[eNB_id][0], (uint32_t*)pusch_vars->rxdataF_comp[eNB_id][0],
ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12); ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12);
// msg("Done\n"); // printf("Done\n");
//#endif //DEBUG_ULSCH //#endif //DEBUG_ULSCH
#endif #endif
...@@ -1877,7 +1877,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB, ...@@ -1877,7 +1877,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
default: default:
#ifdef DEBUG_ULSCH #ifdef DEBUG_ULSCH
msg("ulsch_demodulation.c (rx_ulsch): Unknown Qm!!!!\n"); printf("ulsch_demodulation.c (rx_ulsch): Unknown Qm!!!!\n");
#endif //DEBUG_ULSCH #endif //DEBUG_ULSCH
break; break;
} }
...@@ -1890,7 +1890,7 @@ void rx_ulsch_emul(PHY_VARS_eNB *eNB, ...@@ -1890,7 +1890,7 @@ void rx_ulsch_emul(PHY_VARS_eNB *eNB,
uint8_t sect_id, uint8_t sect_id,
uint8_t UE_index) uint8_t UE_index)
{ {
msg("[PHY] EMUL eNB %d rx_ulsch_emul : subframe %d, sect_id %d, UE_index %d\n",eNB->Mod_id,proc->subframe_rx,sect_id,UE_index); printf("[PHY] EMUL eNB %d rx_ulsch_emul : subframe %d, sect_id %d, UE_index %d\n",eNB->Mod_id,proc->subframe_rx,sect_id,UE_index);
eNB->pusch_vars[UE_index]->ulsch_power[0] = 31622; //=45dB; eNB->pusch_vars[UE_index]->ulsch_power[0] = 31622; //=45dB;
eNB->pusch_vars[UE_index]->ulsch_power[1] = 31622; //=45dB; eNB->pusch_vars[UE_index]->ulsch_power[1] = 31622; //=45dB;
......
...@@ -754,7 +754,7 @@ void ulsch_modulation(int32_t **txdataF, ...@@ -754,7 +754,7 @@ void ulsch_modulation(int32_t **txdataF,
re_offset = re_offset0; re_offset = re_offset0;
symbol_offset = (uint32_t)frame_parms->ofdm_symbol_size*(l+(subframe*nsymb)); symbol_offset = (uint32_t)frame_parms->ofdm_symbol_size*(l+(subframe*nsymb));
#ifdef DEBUG_ULSCH_MODULATION #ifdef DEBUG_ULSCH_MODULATION
printf("ulsch_mod (OFDMA) symbol %d (subframe %d): symbol_offset %d\n",l,subframe,symbol_offset); printf("ulsch_mod (SC-FDMA) symbol %d (subframe %d): symbol_offset %d\n",l,subframe,symbol_offset);
#endif #endif
txptr = &txdataF[0][symbol_offset]; txptr = &txdataF[0][symbol_offset];
......
...@@ -45,8 +45,9 @@ DIO_s8 DIO_LinearToALaw(DIO_s16 sample) ...@@ -45,8 +45,9 @@ DIO_s8 DIO_LinearToALaw(DIO_s16 sample)
}; };
DIO_s32 sign, exponent, mantissa; DIO_s32 sign, exponent, mantissa;
DIO_s8 compandedValue; DIO_s8 compandedValue;
sample = (sample ==-32768) ? -32767 : sample;
sample = (sample ==-32768) ? -32767 : sample;
sign = ((~sample) >> 8) & 0x80; sign = ((~sample) >> 8) & 0x80;
if (!sign) if (!sign)
sample = (short)-sample; sample = (short)-sample;
...@@ -123,3 +124,16 @@ DIO_s32 DIO_IIRavgPower2FR (DIO_s32 prevAvg, DIO_u8 windowLenInBits, DIO_s16 new ...@@ -123,3 +124,16 @@ DIO_s32 DIO_IIRavgPower2FR (DIO_s32 prevAvg, DIO_u8 windowLenInBits, DIO_s16 new
iirAvg = (((prevAvg<<windowLenInBits)-prevAvg) + (DIO_I2FR(newSample,radix)))>>windowLenInBits; iirAvg = (((prevAvg<<windowLenInBits)-prevAvg) + (DIO_I2FR(newSample,radix)))>>windowLenInBits;
return iirAvg; return iirAvg;
} }
#ifdef MAIN
int main(int argc, char* argv[])
{
return 0;
}
#endif
...@@ -668,7 +668,7 @@ int main(int argc, char **argv) ...@@ -668,7 +668,7 @@ int main(int argc, char **argv)
if (eNB->frame_parms.frame_type == TDD) { if (eNB->frame_parms.frame_type == TDD) {
((DCI0_5MHz_TDD_1_6_t*)&UL_alloc_pdu)->type = 0; ((DCI0_5MHz_TDD_1_6_t*)&UL_alloc_pdu)->type = 0;
((DCI0_5MHz_TDD_1_6_t*)&UL_alloc_pdu)->rballoc = computeRIV(eNB->frame_parms.N_RB_UL,first_rb,nb_rb);// 12 RBs from position 8 ((DCI0_5MHz_TDD_1_6_t*)&UL_alloc_pdu)->rballoc = computeRIV(eNB->frame_parms.N_RB_UL,first_rb,nb_rb);// 12 RBs from position 8
printf("nb_rb %d/%d, rballoc %d (dci %x)\n",nb_rb,eNB->frame_parms.N_RB_UL,((DCI0_5MHz_TDD_1_6_t*)&UL_alloc_pdu)->rballoc,*(uint32_t *)&UL_alloc_pdu); // printf("nb_rb %d/%d, rballoc %d (dci %x)\n",nb_rb,eNB->frame_parms.N_RB_UL,((DCI0_5MHz_TDD_1_6_t*)&UL_alloc_pdu)->rballoc,*(uint32_t *)&UL_alloc_pdu);
((DCI0_5MHz_TDD_1_6_t*)&UL_alloc_pdu)->mcs = mcs; ((DCI0_5MHz_TDD_1_6_t*)&UL_alloc_pdu)->mcs = mcs;
((DCI0_5MHz_TDD_1_6_t*)&UL_alloc_pdu)->ndi = 1; ((DCI0_5MHz_TDD_1_6_t*)&UL_alloc_pdu)->ndi = 1;
((DCI0_5MHz_TDD_1_6_t*)&UL_alloc_pdu)->TPC = 0; ((DCI0_5MHz_TDD_1_6_t*)&UL_alloc_pdu)->TPC = 0;
...@@ -678,7 +678,7 @@ int main(int argc, char **argv) ...@@ -678,7 +678,7 @@ int main(int argc, char **argv)
} else { } else {
((DCI0_5MHz_FDD_t*)&UL_alloc_pdu)->type = 0; ((DCI0_5MHz_FDD_t*)&UL_alloc_pdu)->type = 0;
((DCI0_5MHz_FDD_t*)&UL_alloc_pdu)->rballoc = computeRIV(eNB->frame_parms.N_RB_UL,first_rb,nb_rb);// 12 RBs from position 8 ((DCI0_5MHz_FDD_t*)&UL_alloc_pdu)->rballoc = computeRIV(eNB->frame_parms.N_RB_UL,first_rb,nb_rb);// 12 RBs from position 8
printf("nb_rb %d/%d, rballoc %d (dci %x)\n",nb_rb,eNB->frame_parms.N_RB_UL,((DCI0_5MHz_FDD_t*)&UL_alloc_pdu)->rballoc,*(uint32_t *)&UL_alloc_pdu); // printf("nb_rb %d/%d, rballoc %d (dci %x)\n",nb_rb,eNB->frame_parms.N_RB_UL,((DCI0_5MHz_FDD_t*)&UL_alloc_pdu)->rballoc,*(uint32_t *)&UL_alloc_pdu);
((DCI0_5MHz_FDD_t*)&UL_alloc_pdu)->mcs = mcs; ((DCI0_5MHz_FDD_t*)&UL_alloc_pdu)->mcs = mcs;
((DCI0_5MHz_FDD_t*)&UL_alloc_pdu)->ndi = 1; ((DCI0_5MHz_FDD_t*)&UL_alloc_pdu)->ndi = 1;
((DCI0_5MHz_FDD_t*)&UL_alloc_pdu)->TPC = 0; ((DCI0_5MHz_FDD_t*)&UL_alloc_pdu)->TPC = 0;
...@@ -692,7 +692,7 @@ int main(int argc, char **argv) ...@@ -692,7 +692,7 @@ int main(int argc, char **argv)
if (eNB->frame_parms.frame_type == TDD) { if (eNB->frame_parms.frame_type == TDD) {
((DCI0_10MHz_TDD_1_6_t*)&UL_alloc_pdu)->type = 0; ((DCI0_10MHz_TDD_1_6_t*)&UL_alloc_pdu)->type = 0;
((DCI0_10MHz_TDD_1_6_t*)&UL_alloc_pdu)->rballoc = computeRIV(eNB->frame_parms.N_RB_UL,first_rb,nb_rb);// 12 RBs from position 8 ((DCI0_10MHz_TDD_1_6_t*)&UL_alloc_pdu)->rballoc = computeRIV(eNB->frame_parms.N_RB_UL,first_rb,nb_rb);// 12 RBs from position 8
printf("nb_rb %d/%d, rballoc %d (dci %x)\n",nb_rb,eNB->frame_parms.N_RB_UL,((DCI0_10MHz_TDD_1_6_t*)&UL_alloc_pdu)->rballoc,*(uint32_t *)&UL_alloc_pdu); // printf("nb_rb %d/%d, rballoc %d (dci %x)\n",nb_rb,eNB->frame_parms.N_RB_UL,((DCI0_10MHz_TDD_1_6_t*)&UL_alloc_pdu)->rballoc,*(uint32_t *)&UL_alloc_pdu);
((DCI0_10MHz_TDD_1_6_t*)&UL_alloc_pdu)->mcs = mcs; ((DCI0_10MHz_TDD_1_6_t*)&UL_alloc_pdu)->mcs = mcs;
((DCI0_10MHz_TDD_1_6_t*)&UL_alloc_pdu)->ndi = 1; ((DCI0_10MHz_TDD_1_6_t*)&UL_alloc_pdu)->ndi = 1;
((DCI0_10MHz_TDD_1_6_t*)&UL_alloc_pdu)->TPC = 0; ((DCI0_10MHz_TDD_1_6_t*)&UL_alloc_pdu)->TPC = 0;
...@@ -702,7 +702,7 @@ int main(int argc, char **argv) ...@@ -702,7 +702,7 @@ int main(int argc, char **argv)
} else { } else {
((DCI0_10MHz_FDD_t*)&UL_alloc_pdu)->type = 0; ((DCI0_10MHz_FDD_t*)&UL_alloc_pdu)->type = 0;
((DCI0_10MHz_FDD_t*)&UL_alloc_pdu)->rballoc = computeRIV(eNB->frame_parms.N_RB_UL,first_rb,nb_rb);// 12 RBs from position 8 ((DCI0_10MHz_FDD_t*)&UL_alloc_pdu)->rballoc = computeRIV(eNB->frame_parms.N_RB_UL,first_rb,nb_rb);// 12 RBs from position 8
printf("nb_rb %d/%d, rballoc %d (dci %x)\n",nb_rb,eNB->frame_parms.N_RB_UL,((DCI0_10MHz_FDD_t*)&UL_alloc_pdu)->rballoc,*(uint32_t *)&UL_alloc_pdu); //printf("nb_rb %d/%d, rballoc %d (dci %x)\n",nb_rb,eNB->frame_parms.N_RB_UL,((DCI0_10MHz_FDD_t*)&UL_alloc_pdu)->rballoc,*(uint32_t *)&UL_alloc_pdu);
((DCI0_10MHz_FDD_t*)&UL_alloc_pdu)->mcs = mcs; ((DCI0_10MHz_FDD_t*)&UL_alloc_pdu)->mcs = mcs;
((DCI0_10MHz_FDD_t*)&UL_alloc_pdu)->ndi = 1; ((DCI0_10MHz_FDD_t*)&UL_alloc_pdu)->ndi = 1;
((DCI0_10MHz_FDD_t*)&UL_alloc_pdu)->TPC = 0; ((DCI0_10MHz_FDD_t*)&UL_alloc_pdu)->TPC = 0;
...@@ -754,16 +754,15 @@ int main(int argc, char **argv) ...@@ -754,16 +754,15 @@ int main(int argc, char **argv)
eNB->frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = 0; eNB->frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = 0;
eNB_rxtx_proc_t *proc_rxtx = &eNB->proc.proc_rxtx[subframe&1];
proc_rxtx->frame_rx=1;
proc_rxtx->subframe_rx=subframe;
proc_rxtx->frame_tx=pdcch_alloc2ul_frame(&eNB->frame_parms,1,subframe);
proc_rxtx->subframe_tx=pdcch_alloc2ul_subframe(&eNB->frame_parms,subframe);
eNB->proc.frame_rx=1; UE->frame_tx = proc_rxtx->frame_rx;
eNB->proc.subframe_rx=subframe; UE->frame_rx = proc_rxtx->frame_tx;
eNB->proc.frame_tx=pdcch_alloc2ul_frame(&eNB->frame_parms,1,subframe);
eNB->proc.subframe_tx=pdcch_alloc2ul_subframe(&eNB->frame_parms,subframe);
UE->frame_tx = eNB->proc.frame_rx;
UE->frame_rx = eNB->proc.frame_tx;
printf("Init UL hopping UE\n"); printf("Init UL hopping UE\n");
init_ul_hopping(&UE->frame_parms); init_ul_hopping(&UE->frame_parms);
...@@ -773,11 +772,11 @@ int main(int argc, char **argv) ...@@ -773,11 +772,11 @@ int main(int argc, char **argv)
UE->dlsch[0][0]->harq_ack[ul_subframe2pdcch_alloc_subframe(&eNB->frame_parms,subframe)].send_harq_status = 1; UE->dlsch[0][0]->harq_ack[ul_subframe2pdcch_alloc_subframe(&eNB->frame_parms,subframe)].send_harq_status = 1;
UE->ulsch_Msg3_active[eNB_id] = 0;
UE->ul_power_control_dedicated[eNB_id].accumulationEnabled=1;
generate_ue_ulsch_params_from_dci((void *)&UL_alloc_pdu, generate_ue_ulsch_params_from_dci((void *)&UL_alloc_pdu,
14, 14,
eNB->proc.subframe_tx, proc_rxtx->subframe_tx,
format0, format0,
UE, UE,
SI_RNTI, SI_RNTI,
...@@ -789,7 +788,7 @@ int main(int argc, char **argv) ...@@ -789,7 +788,7 @@ int main(int argc, char **argv)
// printf("RIV %d\n",UL_alloc_pdu.rballoc); // printf("RIV %d\n",UL_alloc_pdu.rballoc);
generate_eNB_ulsch_params_from_dci(eNB, generate_eNB_ulsch_params_from_dci(eNB,proc_rxtx,
(void *)&UL_alloc_pdu, (void *)&UL_alloc_pdu,
14, 14,
format0, format0,
...@@ -848,7 +847,7 @@ int main(int argc, char **argv) ...@@ -848,7 +847,7 @@ int main(int argc, char **argv)
harq_pid = subframe2harq_pid(&UE->frame_parms,UE->frame_tx,subframe); harq_pid = subframe2harq_pid(&UE->frame_parms,UE->frame_tx,subframe);
input_buffer_length = UE->ulsch[0]->harq_processes[harq_pid]->TBS/8; input_buffer_length = UE->ulsch[0]->harq_processes[harq_pid]->TBS/8;
input_buffer = (unsigned char *)malloc(input_buffer_length+4); input_buffer = (unsigned char *)memalign(32,input_buffer_length+64);