Commit 59b0b394 authored by lfarizav's avatar lfarizav

rar uplink

parent 2e29a27c
......@@ -1352,6 +1352,7 @@ int32_t generate_prach_freq( PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe,
Xu_re = (((int32_t)Xu[offset<<1]*amp)>>15);
Xu_im = (((int32_t)Xu[1+(offset<<1)]*amp)>>15);
if (offset<10 || (offset>829&&offset<839))
printf("[prach] k %d, offset %d, offset2 %d, PRACH (%d,%d)\n",k,offset,offset2,((Xu_re*ru[offset2<<1]) - (Xu_im*ru[1+(offset2<<1)]))>>15,((Xu_im*ru[offset2<<1]) + (Xu_re*ru[1+(offset2<<1)]))>>15);
prachF[k++]= ((Xu_re*ru[offset2<<1]) - (Xu_im*ru[1+(offset2<<1)]))>>15;
prachF[k++]= ((Xu_im*ru[offset2<<1]) + (Xu_re*ru[1+(offset2<<1)]))>>15;
......@@ -1606,7 +1607,6 @@ void rx_prach(PHY_VARS_eNB *eNB,
uint16_t Nf,
uint8_t tdd_mapindex)
{
int i;
lte_frame_type_t frame_type = eNB->frame_parms.frame_type;
int subframe = eNB->proc.subframe_prach;
......@@ -1645,7 +1645,6 @@ void rx_prach(PHY_VARS_eNB *eNB,
int fft_size,log2_ifft_size;
uint8_t nb_ant_rx = 1; //eNB->frame_parms.nb_antennas_rx;
for (aa=0; aa<nb_ant_rx; aa++) {
prach[aa] = (int16_t*)&eNB->common_vars.rxdata[0][aa][subframe*eNB->frame_parms.samples_per_tti-eNB->N_TA_offset];
}
......@@ -1783,13 +1782,14 @@ void rx_prach(PHY_VARS_eNB *eNB,
break;
case 50:
printf("[prach.c] prach2 %x, +24576 %x\n",prach2,prach2+24576);
if (prach_fmt == 4) {
dft2048(prach2,rxsigF[aa],1);
dft2048(prach2,rxsigF[aa],1);//7.5Khz*2=15Khz-->2*1024=2048 PRACH subcarriers
} else {
dft12288(prach2,rxsigF[aa]);
dft12288(prach2,rxsigF[aa]);//1.25khz*12=15Khz-->12*1024=12288 PRACH subcarriers
if (prach_fmt>1)
dft12288(prach2+24576,rxsigF[aa]+24576);
dft12288(prach2+24576,rxsigF[aa]+24576);//
}
break;
......@@ -1865,7 +1865,7 @@ void rx_prach(PHY_VARS_eNB *eNB,
printf("PRACH: Frame %d, Subframe %d => %d dB\n",eNB->proc.frame_rx,eNB->proc.subframe_rx,en);
>>>>>>> origin/fix-if4p5
#endif
write_output("rxsigF.m","prach_rxF",rxsigF[0],24576,1,16);
return;
} else if (eNB->node_function == NGFI_RCC_IF4p5) {
k = (12*n_ra_prb) - 6*eNB->frame_parms.N_RB_UL;
......@@ -2069,7 +2069,6 @@ void rx_prach(PHY_VARS_eNB *eNB,
#ifdef PRACH_DEBUG
if (aa==0) write_output("prach_rxF_comp0.m","prach_rxF_comp0",prachF,1024,1,1);
#endif
}// antennas_rx
#ifdef PRACH_DEBUG
......@@ -2119,16 +2118,13 @@ void rx_prach(PHY_VARS_eNB *eNB,
}// preamble_index
stop_meas(&eNB->rx_prach);
}
void rx_prach_freq(PHY_VARS_eNB *eNB,
uint16_t *preamble_energy_list,
uint16_t *preamble_delay_list,
uint16_t Nf,
uint8_t tdd_mapindex)
{
int i;
lte_frame_type_t frame_type = eNB->frame_parms.frame_type;
int subframe = eNB->proc.subframe_prach;
......@@ -2167,9 +2163,9 @@ void rx_prach_freq(PHY_VARS_eNB *eNB,
int fft_size,log2_ifft_size;
uint8_t nb_ant_rx = 1; //eNB->frame_parms.nb_antennas_rx;
/*for (aa=0; aa<nb_ant_rx; aa++) {
for (aa=0; aa<nb_ant_rx; aa++) {
prach[aa] = (int16_t*)&eNB->common_vars.rxdata[0][aa][subframe*eNB->frame_parms.samples_per_tti-eNB->N_TA_offset];
}*/
}
// First compute physical root sequence
if (restricted_set == 0) {
......@@ -2195,6 +2191,340 @@ void rx_prach_freq(PHY_VARS_eNB *eNB,
n_ra_prb = get_prach_prb_offset(&(eNB->frame_parms),tdd_mapindex,Nf);
prach_root_sequence_map = (prach_fmt < 4) ? prach_root_sequence_map0_3 : prach_root_sequence_map4;
// PDP is oversampled, e.g. 1024 sample instead of 839
// Adapt the NCS (zero-correlation zones) with oversampling factor e.g. 1024/839
/*NCS2 = (N_ZC==839) ? ((NCS<<10)/839) : ((NCS<<8)/139);
if (NCS2==0)
NCS2 = N_ZC;
switch (prach_fmt) {
case 0:
Ncp = 3168;
break;
case 1:
case 3:
Ncp = 21024;
break;
case 2:
Ncp = 6240;
break;
case 4:
Ncp = 448;
break;
default:
Ncp = 3168;
break;
}
// Adjust CP length based on UL bandwidth
switch (eNB->frame_parms.N_RB_UL) {
case 6:
Ncp>>=4;
break;
case 15:
Ncp>>=3;
break;
case 25:
Ncp>>=2;
break;
case 50:
Ncp>>=1;
break;
case 75:
Ncp=(Ncp*3)>>2;
break;
case 100:
if (eNB->frame_parms.threequarter_fs == 1)
Ncp=(Ncp*3)>>2;
break;
}*/
/*if ((eNB->node_function == eNodeB_3GPP) ||
(eNB->node_function == eNodeB_3GPP_BBU) ||
(eNB->node_function == NGFI_RRU_IF4p5)) { // compute the DFTs of the PRACH temporal resources
// Do forward transform
for (aa=0; aa<nb_ant_rx; aa++) {
prach2 = prach[aa] + (Ncp<<1);
// do DFT
switch (eNB->frame_parms.N_RB_UL) {
case 6:
if (prach_fmt == 4) {
dft256(prach2,rxsigF[aa],1);
} else {
dft1536(prach2,rxsigF[aa],1);
if (prach_fmt>1)
dft1536(prach2+3072,rxsigF[aa]+3072,1);
}
break;
case 15:
if (prach_fmt == 4) {
dft256(prach2,rxsigF[aa],1);
} else {
dft3072(prach2,rxsigF[aa]);
if (prach_fmt>1)
dft3072(prach2+6144,rxsigF[aa]+6144);
}
break;
case 25:
default:
if (prach_fmt == 4) {
dft1024(prach2,rxsigF[aa],1);
fft_size = 1024;
} else {
dft6144(prach2,rxsigF[aa]);
if (prach_fmt>1)
dft6144(prach2+12288,rxsigF[aa]+12288);
fft_size = 6144;
}
break;
case 50:
if (prach_fmt == 4) {
dft2048(prach2,rxsigF[aa],1);
} else {
dft12288(prach2,rxsigF[aa]);
if (prach_fmt>1)
dft12288(prach2+24576,rxsigF[aa]+24576);
}
break;
case 75:
if (prach_fmt == 4) {
dft3072(prach2,rxsigF[aa]);
} else {
dft18432(prach2,rxsigF[aa]);
if (prach_fmt>1)
dft18432(prach2+36864,rxsigF[aa]+36864);
}
break;
case 100:
if (eNB->frame_parms.threequarter_fs==0) {
if (prach_fmt == 4) {
dft4096(prach2,rxsigF[aa],1);
} else {
dft24576(prach2,rxsigF[aa]);
if (prach_fmt>1)
dft24576(prach2+49152,rxsigF[aa]+49152);
}
} else {
if (prach_fmt == 4) {
dft3072(prach2,rxsigF[aa]);
} else {
dft18432(prach2,rxsigF[aa]);
if (prach_fmt>1)
dft18432(prach2+36864,rxsigF[aa]+36864);
}
}
break;
}
}
}*/
if (eNB->node_function == NGFI_RRU_IF4p5) {
k = (12*n_ra_prb) - 6*eNB->frame_parms.N_RB_UL;
if (k<0) {
k+=(eNB->frame_parms.ofdm_symbol_size);
}
k*=12;
k+=13;
k*=2;
/// **** send_IF4 of rxsigF to RCC **** ///
send_IF4p5(eNB, eNB->proc.frame_prach, eNB->proc.subframe_prach, IF4p5_PRACH, k);
#if 0
/* TODO: resolv this conflict (there should be no printf anyway, so no big deal) */
<<<<<<< HEAD
/*
en = dB_fixed(signal_energy(&rxsigF[0][k],840));
printf("Sending PRACH, k %d,n_ra_prb %d, N_RB_UL %d, en %d\n",k,n_ra_prb,eNB->frame_parms.N_RB_UL,en);
if (en>60) {
printf("PRACH: Frame %d, Subframe %d => %d dB\n",eNB->proc.frame_rx,eNB->proc.subframe_rx,en);
write_output("prach_rx0.m","prach_rx0",(int16_t*)&rxsigF[0][k],839,1,1);
exit(-1);
}
*/
=======
en = dB_fixed(signal_energy(&rxsigF[0][k],840));
if (en>60)
printf("PRACH: Frame %d, Subframe %d => %d dB\n",eNB->proc.frame_rx,eNB->proc.subframe_rx,en);
>>>>>>> origin/fix-if4p5
#endif
write_output("rxsigF.m","prach_rxF",rxsigF[0],24576,1,16);
printf("ok in prach2 \n");
return;
} else if (eNB->node_function == NGFI_RCC_IF4p5) {
k = (12*n_ra_prb) - 6*eNB->frame_parms.N_RB_UL;
if (k<0) {
k+=(eNB->frame_parms.ofdm_symbol_size);
}
k*=12;
k+=13;
k*=2;
// Adjust received rxsigF offset
memmove((&rxsigF[0][k]),
(&rxsigF[0][0]),
839*2*sizeof(int16_t));
#if 0
/* TODO: resolv this conflict (there should be no printf anyway, so no big deal) */
<<<<<<< HEAD
/*
en = dB_fixed(signal_energy(&rxsigF[0][k],840));
printf("Receiving PRACH, k %d,n_ra_prb %d, N_RB_UL %d, en %d\n",k,n_ra_prb,eNB->frame_parms.N_RB_UL,en);
if (en>60) {
printf("PRACH: Frame %d, Subframe %d => %d dB\n",eNB->proc.frame_rx,eNB->proc.subframe_rx,en);
write_output("prach_rx0.m","prach_rx0",(int16_t*)&rxsigF[0][k],839,1,1);
exit(-1);
}
*/
=======
en = dB_fixed(signal_energy(&rxsigF[0][k],840));
/*if (en>60)
printf("PRACH: Frame %d, Subframe %d => %d dB\n",eNB->proc.frame_rx,eNB->proc.subframe_rx,en);*/
>>>>>>> origin/fix-if4p5
#endif
}
// in case of RCC and prach received rx_thread wakes up prach
// here onwards is for eNodeB_3GPP or NGFI_RCC_IF4p5
preamble_offset_old = 99;
for (preamble_index=0 ; preamble_index<64 ; preamble_index++) {
if (restricted_set == 0) {
// This is the relative offset in the root sequence table (5.7.2-4 from 36.211) for the given preamble index
preamble_offset = ((NCS==0)? preamble_index : (preamble_index/(N_ZC/NCS)));
if (preamble_offset != preamble_offset_old) {
preamble_offset_old = preamble_offset;
new_dft = 1;
// This is the \nu corresponding to the preamble index
preamble_shift = 0;
}
else {
preamble_shift -= NCS;
if (preamble_shift < 0)
preamble_shift+=N_ZC;
}
} else { // This is the high-speed case
new_dft = 0;
// set preamble_offset to initial rootSequenceIndex and look if we need more root sequences for this
// preamble index and find the corresponding cyclic shift
// Check if all shifts for that root have been processed
if (preamble_index0 == numshift) {
not_found = 1;
new_dft = 1;
preamble_index0 -= numshift;
(preamble_offset==0 && numshift==0) ? (preamble_offset) : (preamble_offset++);
while (not_found == 1) {
// current root depending on rootSequenceIndex
int index = (rootSequenceIndex + preamble_offset) % N_ZC;
if (prach_fmt<4) {
// prach_root_sequence_map points to prach_root_sequence_map0_3
DevAssert( index < sizeof(prach_root_sequence_map0_3) / sizeof(prach_root_sequence_map0_3[0]) );
} else {
// prach_root_sequence_map points to prach_root_sequence_map4
DevAssert( index < sizeof(prach_root_sequence_map4) / sizeof(prach_root_sequence_map4[0]) );
}
u = prach_root_sequence_map[index];
uint16_t n_group_ra = 0;
if ( (du[u]<(N_ZC/3)) && (du[u]>=NCS) ) {
n_shift_ra = du[u]/NCS;
d_start = (du[u]<<1) + (n_shift_ra * NCS);
n_group_ra = N_ZC/d_start;
n_shift_ra_bar = max(0,(N_ZC-(du[u]<<1)-(n_group_ra*d_start))/N_ZC);
} else if ( (du[u]>=(N_ZC/3)) && (du[u]<=((N_ZC - NCS)>>1)) ) {
n_shift_ra = (N_ZC - (du[u]<<1))/NCS;
d_start = N_ZC - (du[u]<<1) + (n_shift_ra * NCS);
n_group_ra = du[u]/d_start;
n_shift_ra_bar = min(n_shift_ra,max(0,(du[u]- (n_group_ra*d_start))/NCS));
} else {
n_shift_ra = 0;
n_shift_ra_bar = 0;
}
// This is the number of cyclic shifts for the current root u
numshift = (n_shift_ra*n_group_ra) + n_shift_ra_bar;
// skip to next root and recompute parameters if numshift==0
(numshift>0) ? (not_found = 0) : (preamble_offset++);
}
}
if (n_shift_ra>0)
preamble_shift = -((d_start * (preamble_index0/n_shift_ra)) + ((preamble_index0%n_shift_ra)*NCS)); // minus because the channel is h(t -\tau + Cv)
else
preamble_shift = 0;
if (preamble_shift < 0)
preamble_shift+=N_ZC;
preamble_index0++;
if (preamble_index == 0)
first_nonzero_root_idx = preamble_offset;
}
// Compute DFT of RX signal (conjugate input, results in conjugate output) for each new rootSequenceIndex
#ifdef PRACH_DEBUG
LOG_I(PHY,"preamble index %d: offset %d, preamble shift %d\n",preamble_index,preamble_offset,preamble_shift);
#endif
log2_ifft_size = 10;
fft_size = 6144;
if (new_dft == 1) {
new_dft = 0;
Xu=(int16_t*)eNB->X_u[preamble_offset-first_nonzero_root_idx];
k = (12*n_ra_prb) - 6*eNB->frame_parms.N_RB_UL;
if (k<0)
......@@ -2213,7 +2543,7 @@ void rx_prach_freq(PHY_VARS_eNB *eNB,
memset( prachF, 0, sizeof(int16_t)*2*1024 );
#ifdef PRACH_DEBUG
//write_output("prach_rx0.m","prach_rx0",prach[0],6144+792,1,1);
write_output("prach_rx0.m","prach_rx0",prach[0],6144+792,1,1);
#endif
// write_output("prach_rx1.m","prach_rx1",prach[1],6144+792,1,1);
// write_output("prach_rxF0.m","prach_rxF0",rxsigF[0],24576,1,1);
......@@ -2223,8 +2553,8 @@ void rx_prach_freq(PHY_VARS_eNB *eNB,
// Do componentwise product with Xu*
for (offset=0; offset<(N_ZC<<1); offset+=2) {
prachF[offset] = 1;//((short *)eNB->prach_vars.prachF)[((offset)<<1)];
prachF[offset+1] = 2;//((short *)eNB->prach_vars.prachF)[1+((offset)<<1)];
prachF[offset] = (int16_t)(((int32_t)Xu[offset]*rxsigF[aa][k] + (int32_t)Xu[offset+1]*rxsigF[aa][k+1])>>15);
prachF[offset+1] = (int16_t)(((int32_t)Xu[offset]*rxsigF[aa][k+1] - (int32_t)Xu[offset+1]*rxsigF[aa][k])>>15);
/*
if (offset<16)
printf("Xu[%d] %d %d, rxsigF[%d][%d] %d %d\n",offset,Xu[offset],Xu[offset+1],aa,k,rxsigF[aa][k],rxsigF[aa][k+1]);
......@@ -2246,60 +2576,66 @@ void rx_prach_freq(PHY_VARS_eNB *eNB,
if (k==(12*2*eNB->frame_parms.ofdm_symbol_size))
k=0;
}
// Now do IFFT of size 1024 (N_ZC=839) or 256 (N_ZC=139)
/*if (N_ZC == 839) {
if (N_ZC == 839) {
log2_ifft_size = 10;
idft1024(prachF,prach_ifft[aa],1);
} else {
idft256(prachF,prach_ifft[aa],1);
log2_ifft_size = 8;
}*/
}
#ifdef PRACH_DEBUG
//write_output("prach_rxF_comp0.m","prach_rxF_comp0",prachF,1024,1,1);
if (aa==0) write_output("prach_rxF_comp0.m","prach_rxF_comp0",prachF,1024,1,1);
#endif
write_output("prach_rxF_comp1.m","prach_rxF_comp1",prachF,1024,1,1);
}// antennas_rx
if (eNB->node_function == NGFI_RRU_IF4p5) {
#ifdef PRACH_DEBUG
if (en>40) {
k = (12*n_ra_prb) - 6*eNB->frame_parms.N_RB_UL;
if (k<0) {
if (k<0)
k+=(eNB->frame_parms.ofdm_symbol_size);
}
k*=12;
k+=13;
k*=2;
printf("Dumping prach, k = %d (n_ra_prb %d)\n",k,n_ra_prb);
write_output("rxsigF.m","prach_rxF",&rxsigF[0][k],840,1,1);
write_output("prach_rxF_comp0.m","prach_rxF_comp0",prachF,1024,1,1);
write_output("prach_ifft0.m","prach_t0",prach_ifft[0],1024,1,1);
exit(-1);
}
#endif
} // new dft
/// **** send_IF4 of rxsigF to RCC **** ///
send_IF4p5(eNB, eNB->proc.frame_prach, eNB->proc.subframe_prach, IF4p5_PRACH, k);
// check energy in nth time shift
preamble_shift2 = ((preamble_shift==0) ? 0 : ((preamble_shift<<log2_ifft_size)/N_ZC));
preamble_energy_list[preamble_index] = 0;
#if 0
/* TODO: resolv this conflict (there should be no printf anyway, so no big deal) */
<<<<<<< HEAD
/*
en = dB_fixed(signal_energy(&rxsigF[0][k],840));
printf("Sending PRACH, k %d,n_ra_prb %d, N_RB_UL %d, en %d\n",k,n_ra_prb,eNB->frame_parms.N_RB_UL,en);
if (en>60) {
printf("PRACH: Frame %d, Subframe %d => %d dB\n",eNB->proc.frame_rx,eNB->proc.subframe_rx,en);
write_output("prach_rx0.m","prach_rx0",(int16_t*)&rxsigF[0][k],839,1,1);
exit(-1);
for (i=0; i<NCS2; i++) {
lev = 0;
for (aa=0; aa<nb_ant_rx; aa++) {
lev += (int32_t)prach_ifft[aa][(preamble_shift2+i)<<1]*prach_ifft[aa][(preamble_shift2+i)<<1] + (int32_t)prach_ifft[aa][1+((preamble_shift2+i)<<1)]*prach_ifft[aa][1+((preamble_shift2+i)<<1)];
}
*/
=======
en = dB_fixed(signal_energy(&rxsigF[0][k],840));
if (en>60)
printf("PRACH: Frame %d, Subframe %d => %d dB\n",eNB->proc.frame_rx,eNB->proc.subframe_rx,en);
>>>>>>> origin/fix-if4p5
#endif
levdB = dB_fixed_times10(lev);
return;
if (levdB>preamble_energy_list[preamble_index] ) {
preamble_energy_list[preamble_index] = levdB;
preamble_delay_list[preamble_index] = (i*fft_size)>>log2_ifft_size;
}
}
#ifdef PRACH_DEBUG
LOG_D(PHY,"[RAPROC] Preamble %d => %d dB, %d (shift %d (%d), NCS2 %d(%d), Ncp %d)\n",preamble_index,preamble_energy_list[preamble_index],preamble_delay_list[preamble_index],preamble_shift2,
preamble_shift, NCS2,NCS,Ncp);
// exit(-1);
#endif
stop_meas(&eNB->rx_prach);
}// preamble_index
stop_meas(&eNB->rx_prach);
}
void init_prach_tables(int N_ZC)
{
......
......@@ -2164,7 +2164,6 @@ int32_t generate_prach_freq(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t subf
*/
void rx_prach(PHY_VARS_eNB *phy_vars_eNB,uint16_t *preamble_energy_list, uint16_t *preamble_delay_list, uint16_t Nf, uint8_t tdd_mapindex);
void rx_prach_freq(PHY_VARS_eNB *phy_vars_eNB,uint16_t *preamble_energy_list, uint16_t *preamble_delay_list, uint16_t Nf, uint8_t tdd_mapindex);
/*!
\brief Helper for MAC, returns number of available PRACH in TDD for a particular configuration index
@param frame_parms Pointer to LTE_DL_FRAME_PARMS structure
......
......@@ -2005,7 +2005,7 @@ void prach_procedures(PHY_VARS_eNB *eNB) {
if (eNB->abstraction_flag == 0) {
if (do_ofdm_mod)
{
LOG_D(PHY,"[eNB %d][RAPROC] Frame %d, Subframe %d : PRACH RX Signal Power : %d dBm\n",eNB->Mod_id,
LOG_D(PHY,"[eNB %d][RAPROC][Freq] Frame %d, Subframe %d : PRACH RX Signal Power : %d dBm\n",eNB->Mod_id,
frame,subframe,dB_fixed(signal_energy(&eNB->common_vars.rxdataF[0][0][subframe*fp->symbols_per_tti*fp->ofdm_symbol_size],512)) - eNB->rx_total_gain_dB);
rx_prach_freq(eNB,
preamble_energy_list,
......@@ -2023,7 +2023,6 @@ void prach_procedures(PHY_VARS_eNB *eNB) {
preamble_delay_list,
frame,
0);
printf("[prach] ook\n");
write_output("prach_rxF_comp1.m","prach_rxF_comp1",eNB->prach_vars.prachF,1024,1,1);
}
} else {
......
......@@ -18,7 +18,7 @@
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#define DEBUG_ADC
void adc(double *r_re[2],
double *r_im[2],
unsigned int input_offset,
......@@ -47,7 +47,7 @@ void adc(double *r_re[2],
//printf("Adc outputs %d %e %d \n",i,((short *)output[0])[((i+output_offset)<<1)], ((i+output_offset)<<1) );
}
}
void adc_freq(double *r_re[2],
/*void adc_freq(double *r_re[2],
double *r_im[2],
unsigned int input_offset,
unsigned int output_offset,
......@@ -62,7 +62,7 @@ void adc_freq(double *r_re[2],
int i;
//int th_id;
int aa;
double gain = (double)(1<<(B-1));
double gain = (double)(1<<(B-1));*/
/*int dummy_rx[nb_rx_antennas][length] __attribute__((aligned(32)));
for (aa=0; aa<nb_rx_antennas; aa++) {
......@@ -70,7 +70,7 @@ void adc_freq(double *r_re[2],
}*/
//double gain = 1.0;
for (i=0; i<length; i++) {
/*for (i=0; i<length; i++) {
for (aa=0; aa<nb_rx_antennas; aa++) {
((short *)output1[aa])[((i+output_offset)<<1)] = (short)(r_re[aa][i+input_offset]*gain);
((short *)output1[aa])[1+((i+output_offset)<<1)] = (short)(r_im[aa][i+input_offset]*gain);
......@@ -86,7 +86,7 @@ void adc_freq(double *r_re[2],
printf("rxdataF (thread[0]) %d: (%d,%d) \n",i,((short *)output2[aa])[((i+output_offset+length+4)<<1)],((short *)output2[aa])[1+((i+output_offset+length+4)<<1)]);
}
}
}*/
/*for (aa=0; aa<nb_rx_antennas; aa++) {
for (th_id=1; th_id<2; th_id++)
{
......@@ -95,16 +95,16 @@ void adc_freq(double *r_re[2],
length*sizeof(int));
}
}*/
}
/*}
printf("thread %d\n",(unsigned int)thread);
//write_output("adc_rxsigF_frame0.m","adc_rxsF0", output1[0],10*length,1,16);
//write_output("adc_rxsigF_frame1.m","adc_rxsF1", output2[0],10*length,1,16);
}
}*/
void adc_prach(double *r_re[2],
double *r_im[2],
unsigned int input_offset,
unsigned int output_offset,
unsigned int *output,
unsigned int **output,
unsigned int nb_rx_antennas,
unsigned int length,
unsigned char B)
......@@ -117,9 +117,13 @@ void adc_prach(double *r_re[2],
for (i=0; i<length; i++) {
for (aa=0; aa<nb_rx_antennas; aa++) {
((short *)output)[((i+output_offset)<<1)] = (short)(r_re[aa][i+input_offset]*gain);
((short *)output)[1+((i+output_offset)<<1)] = (short)(r_im[aa][i+input_offset]*gain);
printf("[adc_prach]i %d output (%d,%d)\n",i,((short *)output)[((i+output_offset)<<1)],((short *)output)[1+((i+output_offset)<<1)]);
((short *)output[aa])[((i+output_offset/2)<<1)] = (short)(r_re[aa][i+input_offset]*gain);
((short *)output[aa])[1+((i+output_offset/2)<<1)] = (short)(r_im[aa][i+input_offset]*gain);
#ifdef DEBUG_ADC
if (i<10)
printf("[adc_prach]i %d. input (%d,%d), output (%d,%d)\n",i,(short)(r_re[aa][i+input_offset]),(short)(r_im[aa][i+input_offset]),((short *)output[aa])[((i+output_offset/2)<<1)],((short *)output[aa])[1+((i+output_offset/2)<<1)]);
if (i>length-10&&i<length)
#endif
if ((r_re[aa][i+input_offset]*gain) > 30000) {
//("Adc outputs %d %e %d \n",i,((short *)output[0])[((i+output_offset)<<1)], ((i+output_offset)<<1) );
}
......
......@@ -19,7 +19,7 @@
* contact@openairinterface.org
*/
//#define DEBUG_DAC 1
//#define DEBUG_DAC
#include <math.h>
#include <stdio.h>
#include "PHY/TOOLS/defs.h"
......@@ -165,13 +165,19 @@ double dac_fixed_gain_prach(double *s_re[2],
amp1 = amp1*sqrt(512.0/300.0); //account for loss due to null carriers
//printf("DL: amp1 %f dB (%d,%d), tx_power %f\n",20*log10(amp1),input_offset,input_offset_meas,txpwr_dBm);
*/
printf("[dac_fixed_gain_prach] input_offset %d\n",input_offset);
#ifdef DEBUG_DAC
printf("DAC: input_offset %d, amp %e, amp1 %e\n",input_offset,amp,amp1);
#endif
for (i=0; i<length*2; i+=2) {
for (aa=0; aa<nb_tx_antennas; aa++) {
printf("[dac_fixed_gain_prach] input (%d,%d)\n",(((short *)input))[((i+input_offset))],(((short *)input))[((i+input_offset))+1]);
s_re[aa][i/2] = amp*((double)(((short *)input))[((i+input_offset))])/amp1; ///(1<<(B-1));
s_im[aa][i/2] = amp*((double)(((short *)input))[((i+input_offset))+1])/amp1; ///(1<<(B-1));
#ifdef DEBUG_DAC
if(i<20)
printf("DAC[%d]: input (%d,%d). output (%e,%e)\n",i/2,(((short *)input))[((i+input_offset))],(((short *)input))[((i+input_offset))+1],s_re[aa][i/2],s_im[aa][i/2]);
if (i>length*2-20&&i<length*2)
printf("DAC[%d]: input (%d,%d). output (%e,%e)\n",i/2,(((short *)input))[((i+input_offset))],(((short *)input))[((i+input_offset))+1],s_re[aa][i/2],s_im[aa][i/2]);
#endif
}
}
......
......@@ -74,23 +74,11 @@ void adc(double *r_re[2],
unsigned int length,
unsigned char B);
void adc_freq(double *r_re[2],
double *r_im[2],
unsigned int input_offset,
unsigned int output_offset,
unsigned int **output1,//ue->current_thread_id[subframe]
unsigned int **output2,//thread 0
unsigned int **output3,//thread 1
unsigned int nb_rx_antennas,
unsigned int length,
unsigned char B,
int thread);
void adc_prach(double *r_re[2],
double *r_im[2],
unsigned int input_offset,
unsigned int output_offset,
unsigned int *output,
int **output,
unsigned int nb_rx_antennas,
unsigned int length,
unsigned char B);
......
......@@ -181,8 +181,8 @@ int init_freq_channel_prach(channel_desc_t *desc,uint16_t nb_rb,int16_t n_sample
cos_lut[f1][l] = cos(2*M_PI*freq*delay);
sin_lut[f1][l] = sin(2*M_PI*freq*delay);
if (f<max_nb_rb_samples/2-prach_pbr_offset_samples+10)
printf("freq: %e, f1: %d, f: %d, arg_sin_cos = %e, cos () = %e, sin () =n %e)\n",freq, f1,f, 2*M_PI*freq*delay, cos_lut[f1][l], sin_lut[f1][l]);
}
}
......@@ -238,6 +238,7 @@ int freq_channel_prach(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples,int
}
}
}
if (f<10 || (f>829&&f<839))
printf("chF_prach[0][%d], (x,y) = (%e,%e)\n",f,desc->chF_prach[0][f].x,desc->chF_prach[0][f].y);
}
stop_meas(&desc->interp_freq);
......
......@@ -359,7 +359,7 @@ void multipath_channel_prach(channel_desc_t *desc,
uint8_t prach_ConfigIndex = PHY_vars_UE_g[UE_id][CC_id]->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex;
uint8_t prach_fmt = get_prach_fmt(prach_ConfigIndex,frame_type);
int n_ra_prb;
int ii,j,k,f,l;
int ii,j,f;
struct complex rx_tmp;
double delta_f;
prach_samples = (prach_fmt<4)?13+839+12:3+139+2;
......@@ -399,5 +399,3 @@ void multipath_channel_prach(channel_desc_t *desc,
} // ii
} // f
}
......@@ -1029,7 +1029,7 @@ void do_UL_prach(channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX][MAX
int32_t att_eNB_id=-1;
#endif
uint8_t UE_id=0;
int16_t *rx_prachF;
int16_t **rx_prachF;
int16_t *tx_prachF;
uint8_t nb_antennas_rx = UE2eNB[0][0][CC_id]->nb_rx; // number of rx antennas at eNB
uint8_t nb_antennas_tx = UE2eNB[0][0][CC_id]->nb_tx; // number of tx antennas at UE
......@@ -1106,10 +1106,11 @@ void do_UL_prach(channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX][MAX
tx_prachF = PHY_vars_UE_g[UE_id][CC_id]->prach_vars[eNB_id]->prachF;
//write_output("txprachF.m","prach_txF", PHY_vars_UE_g[0][0]->prach_vars[0]->prachF,frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti*12,1,1);
//sf_offset = subframe*frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti*12;
//for (int idx=0;idx<10;idx++) printf("dumping DL raw subframe %d: txdataF[%d] = (%d,%d)\n", subframe, idx, ((short*)&txdataF[0][sf_offset+idx])[0], ((short*)&txdataF[0][sf_offset+idx])[1]);
pointer_firstvalue_PRACH=((12*n_ra_prb) - 6*PHY_vars_UE_g[UE_id][CC_id]->frame_parms.N_RB_UL<0)?(((12*n_ra_prb) - 6*PHY_vars_UE_g[UE_id][CC_id]->frame_parms.N_RB_UL+PHY_vars_UE_g[UE_id][CC_id]->frame_parms.ofdm_symbol_size)*12+13)*2:(((12*n_ra_prb) - 6*PHY_vars_UE_g[UE_id][CC_id]->frame_parms.N_RB_UL)*12+13)*2;
sf_offset = pointer_firstvalue_PRACH;
for (int idx=pointer_firstvalue_PRACH;idx<pointer_firstvalue_PRACH+20;idx+=2) printf("dumping PRACH UL raw, subframe %d: ue->prachF[%d] = (%d,%d)\n", subframe, idx/2, (short)tx_prachF[idx], (short)tx_prachF[idx+1]);
......@@ -1137,6 +1138,8 @@ void do_UL_prach(channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX][MAX
14,
(double)PHY_vars_UE_g[UE_id][CC_id]->tx_power_dBm[subframe]-10*log10((double)PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe]),
PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe]); // This make the previous argument the total power
for (int idx=0;idx<10;idx++) printf("dumping raw PRACH UL tx subframe (input) %d: s_f[%d] = (%f,%f)\n", subframe, idx, s_re_f_prach[0][idx],s_im_f_prach[0][idx]);
for (int idx=829;idx<839;idx++) printf("dumping raw PRACH UL tx subframe (input) %d: s_f[%d] = (%f,%f)\n", subframe, idx, s_re_f_prach[0][idx],s_im_f_prach[0][idx]);
LOG_D(OCM,"[SIM][UL] UE %d tx_pwr %f dBm (target %d dBm, num_RE %d) for subframe %d (sf_offset %d)\n",
UE_id,
10*log10(tx_pwr),
......@@ -1147,8 +1150,6 @@ void do_UL_prach(channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX][MAX
// write_output("s_re_f_prach.m","s_re_f_prach_txF", s_re_f_prach,frame_parms->ofdm_symbol_size*12,1,1);
multipath_channel_prach(UE2eNB[UE_id][eNB_id][CC_id],s_re_f_prach,s_im_f_prach,r_re0_f_prach,r_im0_f_prach,
frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti*12,hold_channel,eNB_id,UE_id,CC_id,subframe&0x1,subframe);
for (int idx=0;idx<10;idx++) printf("dumping raw PRACH UL tx subframe (input) %d: s_f[%d] = (%f,%f)\n", subframe, idx, s_re_f_prach[0][idx],s_im_f_prach[0][idx]);
for (int idx=829;idx<839;idx++) printf("dumping raw PRACH UL tx subframe (input) %d: s_f[%d] = (%f,%f)\n", subframe, idx, s_re_f_prach[0][idx],s_im_f_prach[0][idx]);
for (int idx=0;idx<10;idx++) printf("dumping raw PRACH UL tx subframe (output) %d: r_f[%d] = (%f,%f)\n", subframe, idx, r_re0_f_prach[0][idx],r_im0_f_prach[0][idx]);
for (int idx=829;idx<839;idx++) printf("dumping raw PRACH UL tx subframe (output) %d: r_f[%d] = (%f,%f)\n", subframe, idx, r_re0_f_prach[0][idx],r_im0_f_prach[0][idx]);
//write_output("txprachF.m","prach_txF", PHY_vars_UE_g[0][0]->prach_vars[0]->prachF,frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti,1,1);
......@@ -1163,12 +1164,12 @@ void do_UL_prach(channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX][MAX
#ifdef DEBUG_SIM
for (i=0; i<864; i++)
LOG_D(OCM,"do_UL_prach channel(%d,%d)[%d] : (%f,%f)\n",UE_id,eNB_id,i,UE2eNB[UE_id][eNB_id][CC_id]->ch[0][i].x,UE2eNB[UE_id][eNB_id][CC_id]->ch[0][i].y);
LOG_D(OCM,"do_UL_prach channel(%d,%d)[%d] : (%f,%f)\n",UE_id,eNB_id,i,UE2eNB[UE_id][eNB_id][CC_id]->chF_prach[0][i].x,UE2eNB[UE_id][eNB_id][CC_id]->chF_prach[0][i].y);
#endif
//for (i=0; i<864; i++){
// LOG_D(OCM,"channel_prach(%d,%d)[%d] : (%f,%f)\n",eNB_id,UE_id,i,UE2eNB[UE_id][eNB_id][CC_id]->chF[0][i].x,UE2eNB[UE_id][eNB_id][CC_id]->chF[0][i].y);
//}
for (i=0; i<864; i++){
LOG_D(OCM,"channel_prach(%d,%d)[%d] : (%f,%f)\n",eNB_id,UE_id,i,UE2eNB[UE_id][eNB_id][CC_id]->chF_prach[0][i].x,UE2eNB[UE_id][eNB_id][CC_id]->chF_prach[0][i].y);
}
if (UE2eNB[UE_id][eNB_id][CC_id]->first_run == 1)
UE2eNB[UE_id][eNB_id][CC_id]->first_run = 0;
......@@ -1186,7 +1187,8 @@ void do_UL_prach(channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX][MAX
double *r_re_p_f_prach[2] = {r_re_UL_f_prach[eNB_id][0],r_re_UL_f_prach[eNB_id][1]};
double *r_im_p_f_prach[2] = {r_im_UL_f_prach[eNB_id][0],r_im_UL_f_prach[eNB_id][1]};
for (int idx=0;idx<10;idx++) printf("dumping raw PRACH UL tx subframe (output) %d: r_re_im_p_f_prach[%d] = (%d,%d)\n", subframe, idx, (short)(r_re_p_f_prach[0][idx]),(short)(r_im_p_f_prach[0][idx]));
for (int idx=829;idx<839;idx++) printf("dumping raw PRACH UL tx subframe (output) %d: r_re_im_p_f_prach[%d] = (%d,%d)\n", subframe, idx, (short)(r_re_p_f_prach[0][idx]),(short)(r_im_p_f_prach[0][idx]));
rf_rx_simple(r_re_p_f_prach,
r_im_p_f_prach,
nb_antennas_rx,
......@@ -1201,17 +1203,17 @@ void do_UL_prach(channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX][MAX
LOG_D(OCM,"[SIM][UL] rx_pwr (ADC in) %f dB for subframe %d\n",10*log10(rx_pwr),subframe);
#endif
rx_prachF = PHY_vars_eNB_g[eNB_id][CC_id]->prach_vars.prachF;
//sf_offset = subframe*frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti*12;
rx_prachF = PHY_vars_eNB_g[eNB_id][CC_id]->prach_vars.rxsigF;
sf_offset = pointer_firstvalue_PRACH;
adc_prach(r_re_p_f_prach,
r_im_p_f_prach,
0,
0,
(unsigned int*)rx_prachF,
sf_offset,
(int **)rx_prachF,
nb_antennas_rx,
(prach_fmt<4)?839:139,
12);
write_output("rxprachF.m","prach_rxF", PHY_vars_eNB_g[eNB_id][CC_id]->prach_vars.prachF,4*frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti,1,16);
write_output("chsim_rxsigF.m","chsim_rx_sigF", PHY_vars_eNB_g[eNB_id][CC_id]->prach_vars.rxsigF[0],4*frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti,1,16);
#ifdef DEBUG_SIM
//rx_pwr2 = signal_energy(rxdataF[0]+sf_offset,subframe*frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti)*(double)frame_parms->ofdm_symbol_size/(12.0*frame_parms->N_RB_DL);
......
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