Commit 36aedecf authored by cig's avatar cig

Compute and apply symbol rotation for DL and UL

- now done according to the proper DL/UL frequency
- this makes it compatible with FDD mode
parent 55ef412f
......@@ -531,7 +531,8 @@ int main( int argc, char **argv ) {
fapi_nr_config_request_t *nrUE_config = &UE[CC_id]->nrUE_config;
nr_init_frame_parms_ue(&UE[CC_id]->frame_parms, nrUE_config, *mac->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]);
init_symbol_rotation(&UE[CC_id]->frame_parms, UE[CC_id]->frame_parms.dl_CarrierFreq);
init_symbol_rotation(&UE[CC_id]->frame_parms);
init_nr_ue_vars(UE[CC_id], 0, abstraction_flag);
#ifdef FR2_TEST
......
......@@ -494,7 +494,7 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) {
// }
RC.gNB[Mod_id]->configured = 1;
init_symbol_rotation(fp,fp->dl_CarrierFreq);
init_symbol_rotation(fp);
LOG_I(PHY,"gNB %d configured\n",Mod_id);
}
......
......@@ -502,35 +502,62 @@ void nr_dft(int32_t *z, int32_t *d, uint32_t Msc_PUSCH)
}
void init_symbol_rotation(NR_DL_FRAME_PARMS *fp,uint64_t CarrierFreq) {
void init_symbol_rotation(NR_DL_FRAME_PARMS *fp) {
uint64_t dl_CarrierFreq = fp->dl_CarrierFreq;
uint64_t ul_CarrierFreq = fp->ul_CarrierFreq;
double f[2] = {(double)dl_CarrierFreq, (double)ul_CarrierFreq};
const int nsymb = fp->symbols_per_slot * fp->slots_per_frame/10;
const double Tc=(1/480e3/4096);
const double Nu=2048*64*(1/(float)(1<<fp->numerology_index));
const double f0= (double)CarrierFreq;
const double Ncp0=16*64 + (144*64*(1/(float)(1<<fp->numerology_index)));
const double Ncp1=(144*64*(1/(float)(1<<fp->numerology_index)));
double tl=0,poff,exp_re,exp_im;
double Ncp,Ncpm1=Ncp0;
poff = 2*M_PI*((Ncp0*Tc))*f0;
exp_re = cos(poff);
exp_im = sin(-poff);
fp->symbol_rotation[0]=(int16_t)floor(exp_re*32767);
fp->symbol_rotation[1]=(int16_t)floor(exp_im*32767);
LOG_I(PHY,"Doing symbol rotation calculation for gNB TX/RX, f0 %f Hz, Nsymb %d\n",f0,nsymb);
LOG_I(PHY,"Symbol rotation %d/%d => (%d,%d)\n",0,nsymb,fp->symbol_rotation[0],fp->symbol_rotation[1]);
for (int l=1;l<nsymb;l++) {
if (l==(7*(1<<fp->numerology_index))) Ncp=Ncp0;
else Ncp=Ncp1;
tl += (Nu+Ncpm1)*Tc;
poff = 2*M_PI*(tl + (Ncp*Tc))*f0;
for (uint8_t ll = 0; ll < 2; ll++){
double f0 = f[ll];
int16_t *symbol_rotation = fp->symbol_rotation[ll];
poff = 2 * M_PI * ((Ncp0 * Tc)) * f0;
exp_re = cos(poff);
exp_im = sin(-poff);
fp->symbol_rotation[l<<1]=(int16_t)floor(exp_re*32767);
fp->symbol_rotation[1+(l<<1)]=(int16_t)floor(exp_im*32767);
LOG_I(PHY,"Symbol rotation %d/%d => tl %f (%d,%d) (%f)\n",l,nsymb,tl,fp->symbol_rotation[l<<1],fp->symbol_rotation[1+(l<<1)],
(poff/2/M_PI)-floor(poff/2/M_PI));
Ncpm1=Ncp;
symbol_rotation[0] = (int16_t)floor(exp_re * 32767);
symbol_rotation[1] = (int16_t)floor(exp_im * 32767);
LOG_I(PHY, "Doing symbol rotation calculation for gNB TX/RX, f0 %f Hz, Nsymb %d\n", f0, nsymb);
LOG_I(PHY, "Symbol rotation %d/%d => (%d,%d)\n",
0,
nsymb,
symbol_rotation[0],
symbol_rotation[1]);
for (int l = 1; l < nsymb; l++) {
if (l == (7 * (1 << fp->numerology_index))) {
Ncp = Ncp0;
} else {
Ncp = Ncp1;
}
tl += (Nu + Ncpm1) * Tc;
poff = 2 * M_PI * (tl + (Ncp * Tc)) * f0;
exp_re = cos(poff);
exp_im = sin(-poff);
symbol_rotation[l<<1] = (int16_t)floor(exp_re * 32767);
symbol_rotation[1 + (l<<1)] = (int16_t)floor(exp_im * 32767);
LOG_I(PHY, "Symbol rotation %d/%d => tl %f (%d,%d) (%f)\n",
l,
nsymb,
tl,
symbol_rotation[l<<1],
symbol_rotation[1 + (l<<1)],
(poff / 2 / M_PI) - floor(poff / 2 / M_PI));
Ncpm1 = Ncp;
}
}
}
......@@ -110,7 +110,7 @@ void apply_nr_rotation(NR_DL_FRAME_PARMS *fp,
int nsymb,
int length);
void init_symbol_rotation(NR_DL_FRAME_PARMS *fp,uint64_t CarrierFreq);
void init_symbol_rotation(NR_DL_FRAME_PARMS *fp);
void apply_nr_rotation_ul(NR_DL_FRAME_PARMS *frame_parms,
int32_t *rxdataF,
......
......@@ -306,15 +306,23 @@ void apply_nr_rotation(NR_DL_FRAME_PARMS *fp,
int length) {
int symb_offset = (slot%fp->slots_per_subframe)*fp->symbols_per_slot;
int16_t *symbol_rotation = fp->symbol_rotation[0];
for (int sidx=0;sidx<nsymb;sidx++) {
LOG_D(PHY,"Rotating symbol %d, slot %d, symbol_subframe_index %d, length %d (%d,%d)\n",
first_symbol+sidx,slot,sidx+first_symbol+symb_offset,length,
fp->symbol_rotation[2*(sidx+first_symbol+symb_offset)],fp->symbol_rotation[1+2*(sidx+first_symbol+symb_offset)]);
rotate_cpx_vector(trxdata+(sidx*length*2),
&fp->symbol_rotation[2*(sidx+first_symbol+symb_offset)],
trxdata+(sidx*length*2),
length,
15);
first_symbol + sidx,
slot,
sidx + first_symbol + symb_offset,
length,
symbol_rotation[2 * (sidx + first_symbol + symb_offset)],
symbol_rotation[1 + 2 * (sidx + first_symbol + symb_offset)]);
rotate_cpx_vector(trxdata + (sidx * length * 2),
&symbol_rotation[2 * (sidx + first_symbol + symb_offset)],
trxdata + (sidx * length * 2),
length,
15);
}
}
......@@ -205,7 +205,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
#endif
int symb_offset = (Ns%frame_parms->slots_per_subframe)*frame_parms->symbols_per_slot;
int32_t rot2 = ((uint32_t*)frame_parms->symbol_rotation)[symbol+symb_offset];
int32_t rot2 = ((uint32_t*)frame_parms->symbol_rotation[0])[symbol + symb_offset];
((int16_t*)&rot2)[1]=-((int16_t*)&rot2)[1];
rotate_cpx_vector((int16_t *)&common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],
(int16_t*)&rot2,
......@@ -386,7 +386,7 @@ int nr_slot_fep_init_sync(PHY_VARS_NR_UE *ue,
}
int symb_offset = (Ns%frame_parms->slots_per_subframe)*frame_parms->symbols_per_slot;
int32_t rot2 = ((uint32_t*)frame_parms->symbol_rotation)[symbol+symb_offset];
int32_t rot2 = ((uint32_t*)frame_parms->symbol_rotation[0])[symbol + symb_offset];
((int16_t*)&rot2)[1]=-((int16_t*)&rot2)[1];
#ifdef DEBUG_FEP
......@@ -513,7 +513,7 @@ void apply_nr_rotation_ul(NR_DL_FRAME_PARMS *frame_parms,
for (int symbol=0;symbol<nsymb;symbol++) {
uint32_t rot2 = ((uint32_t*)frame_parms->symbol_rotation)[symbol+symb_offset];
uint32_t rot2 = ((uint32_t*)frame_parms->symbol_rotation[1])[symbol + symb_offset];
((int16_t*)&rot2)[1]=-((int16_t*)&rot2)[1];
LOG_D(PHY,"slot %d, symb_offset %d rotating by %d.%d\n",slot,symb_offset,((int16_t*)&rot2)[0],((int16_t*)&rot2)[1]);
rotate_cpx_vector((int16_t *)&rxdataF[frame_parms->ofdm_symbol_size*symbol],
......
......@@ -496,13 +496,19 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE,
int symb_offset = (slot%frame_parms->slots_per_subframe)*frame_parms->symbols_per_slot;
for(ap = 0; ap < Nl; ap++) {
for (int s=0;s<NR_NUMBER_OF_SYMBOLS_PER_SLOT;s++){
LOG_D(PHY,"rotating txdataF symbol %d (%d) => (%d.%d)\n",
s,s+symb_offset,frame_parms->symbol_rotation[2*(s+symb_offset)],frame_parms->symbol_rotation[1+(2*(s+symb_offset))]);
rotate_cpx_vector((int16_t *)&txdataF[ap][frame_parms->ofdm_symbol_size*s],
&frame_parms->symbol_rotation[2*(s+symb_offset)],
(int16_t *)&txdataF[ap][frame_parms->ofdm_symbol_size*s],
frame_parms->ofdm_symbol_size,
15);
LOG_D(PHY,"In %s: rotating txdataF symbol %d (%d) => (%d.%d)\n",
__FUNCTION__,
s,
s + symb_offset,
frame_parms->symbol_rotation[1][2 * (s + symb_offset)],
frame_parms->symbol_rotation[1][1 + (2 * (s + symb_offset))]);
rotate_cpx_vector((int16_t *)&txdataF[ap][frame_parms->ofdm_symbol_size * s],
&frame_parms->symbol_rotation[1][2 * (s + symb_offset)],
(int16_t *)&txdataF[ap][frame_parms->ofdm_symbol_size * s],
frame_parms->ofdm_symbol_size,
15);
}
}
......
......@@ -327,7 +327,8 @@ struct NR_DL_FRAME_PARMS {
/// Cyclic Prefix for DL (0=Normal CP, 1=Extended CP)
lte_prefix_type_t Ncp;
/// sequence which is computed based on carrier frequency and numerology to rotate/derotate each OFDM symbol according to Section 5.3 in 38.211
int16_t symbol_rotation[224*2];
/// First dimension is for the direction of the link (0 DL, 1 UL)
int16_t symbol_rotation[2][224*2];
/// shift of pilot position in one RB
uint8_t nushift;
/// SRS configuration from TS 38.331 RRC
......
......@@ -111,7 +111,7 @@ void nr_phy_config_request_sim_pbchsim(PHY_VARS_gNB *gNB,
nr_init_frame_parms(gNB_config, fp);
init_symbol_rotation(fp,fp->dl_CarrierFreq);
init_symbol_rotation(fp);
gNB->configured = 1;
LOG_I(PHY,"gNB configured\n");
......
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