Commit 1e193853 authored by Calisson's avatar Calisson

WIP: adding srs channel estimation to eNB. estimation results yet to be checked.

parent 39c7e629
......@@ -667,28 +667,28 @@ int32_t lte_ul_channel_estimation(PHY_VARS_eNB *eNB,
}
extern uint16_t transmission_offset_tdd[16];
#define DEBUG_SRS
//#define DEBUG_SRS
int32_t lte_srs_channel_estimation(LTE_DL_FRAME_PARMS *frame_parms,
LTE_eNB_COMMON *common_vars,
LTE_eNB_SRS *srs_vars,
SOUNDINGRS_UL_CONFIG_DEDICATED *soundingrs_ul_config_dedicated,
unsigned char sub_frame_number,
unsigned char subframe,
unsigned char eNB_id)
{
int T_SFC,aa;
int aa;
int N_symb,symbol;
uint8_t nb_antennas_rx = frame_parms->nb_antenna_ports_eNB;
uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx;
#ifdef DEBUG_SRS
char fname[40], vname[40];
#endif
uint8_t Ssrs = frame_parms->soundingrs_ul_config_common.srs_SubframeConfig;
//uint8_t Ssrs = frame_parms->soundingrs_ul_config_common.srs_SubframeConfig;
//uint8_t T_SFC = (Ssrs<=7 ? 5 : 10);
N_symb = 2*7-frame_parms->Ncp;
symbol = (sub_frame_number+1)*N_symb-1; //SRS is always in last symbol of subframe
T_SFC = (Ssrs<=7 ? 5 : 10);
symbol = N_symb-1; //SRS is always in last symbol of subframe
/*
msg("SRS channel estimation eNB %d, subframs %d, %d %d %d %d %d\n",eNB_id,sub_frame_number,
......@@ -699,19 +699,21 @@ int32_t lte_srs_channel_estimation(LTE_DL_FRAME_PARMS *frame_parms,
SRS_parms->Ssrs);
*/
if ((1<<(sub_frame_number%T_SFC))&transmission_offset_tdd[Ssrs]) {
//if ((1<<(sub_frame_number%T_SFC))&transmission_offset_tdd[Ssrs]) {
if (generate_srs_rx(frame_parms,
soundingrs_ul_config_dedicated,
srs_vars->srs)==-1) {
msg("lte_srs_channel_estimation: Error in generate_srs_rx\n");
if (generate_srs(frame_parms,
soundingrs_ul_config_dedicated,
&srs_vars->srs[eNB_id],
0x7FFF,
subframe)==-1) {
LOG_E(PHY,"lte_srs_channel_estimation: Error in generate_srs_rx\n");
return(-1);
}
for (aa=0; aa<nb_antennas_rx; aa++) {
#ifdef DEBUG_SRS
msg("SRS channel estimation eNB %d, subframs %d, aarx %d, %p, %p, %p\n",eNB_id,sub_frame_number,aa,
&common_vars->rxdataF[eNB_id][aa][2*frame_parms->ofdm_symbol_size*symbol],
&common_vars->rxdataF[eNB_id][aa][frame_parms->ofdm_symbol_size*symbol],
srs_vars->srs,
srs_vars->srs_ch_estimates[eNB_id][aa]);
#endif
......@@ -719,14 +721,15 @@ int32_t lte_srs_channel_estimation(LTE_DL_FRAME_PARMS *frame_parms,
//write_output("eNB_rxF.m","rxF",&common_vars->rxdataF[0][aa][2*frame_parms->ofdm_symbol_size*symbol],2*(frame_parms->ofdm_symbol_size),2,1);
//write_output("eNB_srs.m","srs_eNB",common_vars->srs,(frame_parms->ofdm_symbol_size),1,1);
mult_cpx_conj_vector((int16_t*) &common_vars->rxdataF[eNB_id][aa][2*frame_parms->ofdm_symbol_size*symbol],
(int16_t*) srs_vars->srs,
//memcpy(srs_vars->srs_ch_estimates[eNB_id][aa],&srs_vars->srs[eNB_id],frame_parms->ofdm_symbol_size*sizeof(int32_t));
//memcpy(srs_vars->srs_ch_estimates[eNB_id][aa],&common_vars->rxdataF[eNB_id][aa][frame_parms->ofdm_symbol_size*symbol],frame_parms->ofdm_symbol_size*sizeof(int32_t));
mult_cpx_conj_vector((int16_t*) &common_vars->rxdataF[eNB_id][aa][frame_parms->ofdm_symbol_size*symbol],
(int16_t*) &srs_vars->srs[eNB_id],
(int16_t*) srs_vars->srs_ch_estimates[eNB_id][aa],
frame_parms->ofdm_symbol_size,
15,
0);
//msg("SRS channel estimation cmult out\n");
#ifdef USER_MODE
#ifdef DEBUG_SRS
sprintf(fname,"eNB_id%d_an%d_srs_ch_est.m",eNB_id,aa);
......@@ -735,7 +738,6 @@ int32_t lte_srs_channel_estimation(LTE_DL_FRAME_PARMS *frame_parms,
#endif
#endif
}
}
/*
else {
......
......@@ -1538,9 +1538,11 @@ uint8_t SE2I_TBS(float SE,
@param soundingrs_ul_config_dedicated Dynamic configuration from RRC during Connection Establishment
@param txdataF pointer to the frequency domain TX signal
@returns 0 on success*/
int generate_srs_rx(LTE_DL_FRAME_PARMS *frame_parms,
SOUNDINGRS_UL_CONFIG_DEDICATED *soundingrs_ul_config_dedicated,
int *txdataF);
int generate_srs(LTE_DL_FRAME_PARMS *frame_parms,
SOUNDINGRS_UL_CONFIG_DEDICATED *soundingrs_ul_config_dedicated,
int *txdataF,
int16_t amp,
uint32_t subframe);
int32_t generate_srs_tx_emul(PHY_VARS_UE *phy_vars_ue,
uint8_t subframe);
......
......@@ -120,17 +120,15 @@ int compareints (const void * a, const void * b)
return ( *(unsigned short*)a - *(unsigned short*)b );
}
int32_t generate_srs_tx(PHY_VARS_UE *ue,
uint8_t eNB_id,
int16_t amp,
uint32_t subframe)
#define DEBUG_SRS
int32_t generate_srs(LTE_DL_FRAME_PARMS *frame_parms,
SOUNDINGRS_UL_CONFIG_DEDICATED *soundingrs_ul_config_dedicated,
int32_t *txptr,
int16_t amp,
uint32_t subframe)
{
LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms;
SOUNDINGRS_UL_CONFIG_DEDICATED *soundingrs_ul_config_dedicated=&ue->soundingrs_ul_config_dedicated[eNB_id];
int32_t **txdataF = ue->common_vars.txdataF;
uint16_t msrsb=0,Nb=0,nb,b,msrs0=0,k,Msc_RS,Msc_RS_idx,carrier_pos,symbol_offset;
uint16_t msrsb=0,Nb=0,nb,b,msrs0=0,k,Msc_RS,Msc_RS_idx,carrier_pos;
uint16_t *Msc_idx_ptr;
int32_t k0;
//uint32_t subframe_offset;
......@@ -178,7 +176,7 @@ int32_t generate_srs_tx(PHY_VARS_UE *ue,
}
if (k0<0) {
msg("generate_srs: invalid parameter set msrs0=%d, msrsb=%d, Nb=%d => nb=%d, k0=%d\n",msrs0,msrsb,Nb,nb,k0);
LOG_E(PHY,"generate_srs: invalid parameter set msrs0=%d, msrsb=%d, Nb=%d => nb=%d, k0=%d\n",msrs0,msrsb,Nb,nb,k0);
return(-1);
}
......@@ -188,7 +186,7 @@ int32_t generate_srs_tx(PHY_VARS_UE *ue,
if (Msc_idx_ptr)
Msc_RS_idx = Msc_idx_ptr - dftsizes;
else {
msg("generate_srs: index for Msc_RS=%d not found\n",Msc_RS);
LOG_E(PHY,"generate_srs: index for Msc_RS=%d not found\n",Msc_RS);
return(-1);
}
......@@ -199,29 +197,20 @@ int32_t generate_srs_tx(PHY_VARS_UE *ue,
else if (Msc_RS==144)
Msc_RS_idx = 9;
else {
msg("generate_srs: index for Msc_RS=%d not implemented\n",Msc_RS);
LOG_E(PHY,"generate_srs: index for Msc_RS=%d not implemented\n",Msc_RS);
return(-1);
}
#endif
#ifdef DEBUG_SRS
msg("generate_srs_tx: Msc_RS = %d, Msc_RS_idx = %d\n",Msc_RS, Msc_RS_idx);
LOG_I(PHY,"generate_srs_tx: Msc_RS = %d, Msc_RS_idx = %d, k0 = %d\n",Msc_RS, Msc_RS_idx,k0);
#endif
carrier_pos = (frame_parms->first_carrier_offset + k0);
if (carrier_pos>frame_parms->ofdm_symbol_size) {
carrier_pos -= frame_parms->ofdm_symbol_size;
}
uint16_t nsymb = (frame_parms->Ncp==0) ? 14:12;
symbol_offset = (int)frame_parms->ofdm_symbol_size*((subframe*nsymb)+(nsymb-1));
//msg("carrier_pos = %d\n",carrier_pos);
//subframe_offset = subframe*frame_parms->symbols_per_tti*frame_parms->ofdm_symbol_size;
//symbol_offset = subframe_offset+(frame_parms->symbols_per_tti-1)*frame_parms->ofdm_symbol_size;
int32_t *txptr;
txptr = &txdataF[0][symbol_offset];
for (k=0; k<Msc_RS; k++) {
int32_t real = ((int32_t) amp * (int32_t) ul_ref_sigs[u][v][Msc_RS_idx][k<<1]) >> 15;
......@@ -245,6 +234,7 @@ int generate_srs_tx_emul(PHY_VARS_UE *phy_vars_ue,uint8_t subframe)
return(0);
}
#if 0
int generate_srs_rx(LTE_DL_FRAME_PARMS *frame_parms,
SOUNDINGRS_UL_CONFIG_DEDICATED *soundingrs_ul_config_dedicated,
int *txdataF)
......@@ -285,7 +275,7 @@ int generate_srs_rx(LTE_DL_FRAME_PARMS *frame_parms,
}
if (k0<0) {
msg("Invalid parameter set msrs0=%d, msrsb=%d, Nb=%d => nb=%d, k0=%d\n",msrs0,msrsb,Nb,nb,k0);
LOG_E(PHY,"Invalid parameter set msrs0=%d, msrsb=%d, Nb=%d => nb=%d, k0=%d\n",msrs0,msrsb,Nb,nb,k0);
return(-1);
}
......@@ -295,7 +285,7 @@ int generate_srs_rx(LTE_DL_FRAME_PARMS *frame_parms,
if (Msc_idx_ptr)
Msc_RS_idx = Msc_idx_ptr - dftsizes;
else {
msg("generate_srs: index for Msc_RS=%d not found\n",Msc_RS);
LOG_E(PHY,"generate_srs: index for Msc_RS=%d not found\n",Msc_RS);
return(-1);
}
......@@ -306,23 +296,21 @@ int generate_srs_rx(LTE_DL_FRAME_PARMS *frame_parms,
else if (Msc_RS==144)
Msc_RS_idx = 9;
else {
msg("generate_srs: index for Msc_RS=%d not implemented\n",Msc_RS);
LOG_E(PHY,"generate_srs: index for Msc_RS=%d not implemented\n",Msc_RS);
return(-1);
}
#endif
#ifdef DEBUG_SRS
msg("generate_srs_rx: Msc_RS = %d, Msc_RS_idx = %d, k0=%d\n",Msc_RS, Msc_RS_idx,k0);
LOG_I(PHY,"generate_srs_rx: Msc_RS = %d, Msc_RS_idx = %d, k0=%d\n",Msc_RS, Msc_RS_idx,k0);
#endif
carrier_pos = (frame_parms->first_carrier_offset + k0) % frame_parms->ofdm_symbol_size;
for (k=0; k<Msc_RS; k++) {
((short*) txdataF)[carrier_pos<<2] = ul_ref_sigs_rx[0][0][Msc_RS_idx][k<<2];
((short*) txdataF)[(carrier_pos<<2)+1] = ul_ref_sigs_rx[0][0][Msc_RS_idx][(k<<2)+1];
((short*) txdataF)[(carrier_pos<<2)+2] = ul_ref_sigs_rx[0][0][Msc_RS_idx][(k<<2)+2];
((short*) txdataF)[(carrier_pos<<2)+3] = ul_ref_sigs_rx[0][0][Msc_RS_idx][(k<<2)+3];
((short*) txdataF)[carrier_pos<<1] = ul_ref_sigs_rx[0][0][Msc_RS_idx][k<<1];
((short*) txdataF)[(carrier_pos<<1)+1] = ul_ref_sigs_rx[0][0][Msc_RS_idx][(k<<1)+1];
carrier_pos+=2;
if (carrier_pos >= frame_parms->ofdm_symbol_size)
......@@ -365,7 +353,7 @@ int generate_srs_rx(LTE_DL_FRAME_PARMS *frame_parms,
// write_output("srs_rx.m","srsrx",txdataF,1024,2,1);
return(0);
}
#endif
#ifdef MAIN
main()
......
......@@ -84,7 +84,7 @@ FD_lte_phy_scope_enb *create_lte_phy_scope_enb( void )
fl_set_xyplot_ybounds(fdui->rxsig_t,10,70);
// Time-domain channel response
fdui->chest_t = fl_add_xyplot( FL_NORMAL_XYPLOT, 410, 20, 370, 100, "Channel Impulse Response (samples, abs)" );
fdui->chest_t = fl_add_xyplot( FL_NORMAL_XYPLOT, 410, 20, 370, 100, "SRS Frequency Response (samples, abs)" );
fl_set_object_boxtype( fdui->chest_t, FL_EMBOSSED_BOX );
fl_set_object_color( fdui->chest_t, FL_BLACK, FL_RED );
fl_set_object_lcolor( fdui->chest_t, FL_WHITE ); // Label color
......@@ -196,7 +196,8 @@ void phy_scope_eNB(FD_lte_phy_scope_enb *form,
bit = malloc(coded_bits_per_codeword*sizeof(float));
rxsig_t = (int16_t**) phy_vars_enb->common_vars.rxdata[eNB_id];
chest_t = (int16_t**) phy_vars_enb->pusch_vars[UE_id]->drs_ch_estimates_time[eNB_id];
//chest_t = (int16_t**) phy_vars_enb->pusch_vars[UE_id]->drs_ch_estimates_time[eNB_id];
chest_t = (int16_t**) phy_vars_enb->srs_vars[UE_id].srs_ch_estimates[eNB_id];
chest_f = (int16_t**) phy_vars_enb->pusch_vars[UE_id]->drs_ch_estimates[eNB_id];
pusch_llr = (int16_t*) phy_vars_enb->pusch_vars[UE_id]->llr;
pusch_comp = (int16_t*) phy_vars_enb->pusch_vars[UE_id]->rxdataF_comp[eNB_id][0];
......@@ -232,8 +233,10 @@ void phy_scope_eNB(FD_lte_phy_scope_enb *form,
if (chest_t[0] !=NULL) {
for (i=0; i<(frame_parms->ofdm_symbol_size); i++) {
i2 = (i+(frame_parms->ofdm_symbol_size>>1))%frame_parms->ofdm_symbol_size;
time2[i] = (float)(i-(frame_parms->ofdm_symbol_size>>1));
//i2 = (i+(frame_parms->ofdm_symbol_size>>1))%frame_parms->ofdm_symbol_size;
i2=i;
//time2[i] = (float)(i-(frame_parms->ofdm_symbol_size>>1));
time2[i] = (float)i;
chest_t_abs[0][i] = 10*log10((float) (1+chest_t[0][2*i2]*chest_t[0][2*i2]+chest_t[0][2*i2+1]*chest_t[0][2*i2+1]));
if (chest_t_abs[0][i] > ymax)
......@@ -768,4 +771,4 @@ void phy_scope_UE(FD_lte_phy_scope_ue *form,
}
free(chest_t_abs);
}
\ No newline at end of file
}
......@@ -2087,7 +2087,7 @@ void prach_procedures(PHY_VARS_eNB *eNB) {
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PRACH_RX,0);
}
void pucch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,int UE_id,int harq_pid)
void pucch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,int UE_id,int harq_pid,uint8_t do_srs)
{
LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
uint8_t SR_payload = 0,*pucch_payload=NULL,pucch_payload0[2]= {0,0},pucch_payload1[2]= {0,0};
......@@ -2099,10 +2099,6 @@ void pucch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,int UE_id,int harq
PUCCH_FMT_t format;
const int subframe = proc->subframe_rx;
const int frame = proc->frame_rx;
uint16_t srsPeriodicity;
uint16_t srsOffset;
uint16_t do_srs=0;
uint16_t is_srs_pos=0;
if ((eNB->dlsch[UE_id][0]) &&
(eNB->dlsch[UE_id][0]->rnti>0) &&
......@@ -2112,16 +2108,6 @@ void pucch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,int UE_id,int harq
do_SR = is_SR_subframe(eNB,proc,UE_id);
// do_SR = 0;
// check if there is SRS and we have to use shortened format
// TODO: check for exceptions in transmission of SRS together with ACK/NACK
is_srs_pos = is_srs_occasion_common(fp,pdcch_alloc2ul_frame(fp,frame,subframe),pdcch_alloc2ul_subframe(fp,subframe));
if (is_srs_pos && eNB->soundingrs_ul_config_dedicated[UE_id].srsConfigDedicatedSetup ) {
compute_srs_pos(fp->frame_type, eNB->soundingrs_ul_config_dedicated[UE_id].srs_ConfigIndex, &srsPeriodicity, &srsOffset);
if ((((10*pdcch_alloc2ul_frame(fp,frame,subframe)+pdcch_alloc2ul_subframe(fp,subframe)) % srsPeriodicity) == srsOffset)) {
do_srs = 1;
}
}
// Now ACK/NAK
// First check subframe_tx flag for earlier subframes
......@@ -2896,6 +2882,11 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const
const int frame = proc->frame_rx;
int offset = eNB->CC_id;//(proc == &eNB->proc.proc_rxtx[0]) ? 0 : 1;
uint16_t srsPeriodicity;
uint16_t srsOffset;
uint16_t do_srs=0;
uint16_t is_srs_pos=0;
T(T_ENB_PHY_UL_TICK, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe));
T(T_ENB_PHY_INPUT_SIGNAL, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), T_INT(0),
......@@ -2925,13 +2916,34 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const
eNB->cba_last_reception[i]=0;
}
// Do PUCCH processing first
for (i=0; i<NUMBER_OF_UE_MAX; i++) {
pucch_procedures(eNB,proc,i,harq_pid);
}
for (i=0; i<NUMBER_OF_UE_MAX; i++) {
// Do SRS processing
// check if there is SRS and we have to use shortened format
// TODO: check for exceptions in transmission of SRS together with ACK/NACK
is_srs_pos = is_srs_occasion_common(fp,pdcch_alloc2ul_frame(fp,frame,subframe),pdcch_alloc2ul_subframe(fp,subframe));
if (is_srs_pos && eNB->soundingrs_ul_config_dedicated[i].srsConfigDedicatedSetup ) {
compute_srs_pos(fp->frame_type, eNB->soundingrs_ul_config_dedicated[i].srs_ConfigIndex, &srsPeriodicity, &srsOffset);
if ((((10*pdcch_alloc2ul_frame(fp,frame,subframe)+pdcch_alloc2ul_subframe(fp,subframe)) % srsPeriodicity) == srsOffset)) {
do_srs = 1;
}
}
if (do_srs==1) {
if (lte_srs_channel_estimation(fp,
&eNB->common_vars,
&eNB->srs_vars[i],
&eNB->soundingrs_ul_config_dedicated[i],
subframe,
0/*eNB_id*/)) {
LOG_E(PHY,"problem processing SRS\n");
}
}
// Do PUCCH processing
pucch_procedures(eNB,proc,i,harq_pid, do_srs);
// check for Msg3
if (eNB->mac_enabled==1) {
......
......@@ -1579,7 +1579,13 @@ void ue_srs_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8
nb_rb_srs,
tx_amp);
generate_srs_tx(ue, eNB_id, tx_amp, subframe_tx);
uint16_t nsymb = (ue->frame_parms.Ncp==0) ? 14:12;
uint16_t symbol_offset = (int)ue->frame_parms.ofdm_symbol_size*((subframe_tx*nsymb)+(nsymb-1));
generate_srs(&ue->frame_parms,
&ue->soundingrs_ul_config_dedicated[eNB_id],
&ue->common_vars.txdataF[eNB_id][symbol_offset],
tx_amp,
subframe_tx);
}
}
......
......@@ -1593,7 +1593,7 @@ do_RRCConnectionSetup(
SoundingRS_UL_ConfigDedicated__setup__srs_HoppingBandwidth_hbw0;
physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.freqDomainPosition=0;
physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.duration=1;
physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex=19;
physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex=2;
physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb=0;
physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift=
SoundingRS_UL_ConfigDedicated__setup__cyclicShift_cs0;
......
......@@ -137,7 +137,7 @@ eNBs =
////////// MME parameters:
mme_ip_address = ( { ipv4 = "192.168.12.26";
mme_ip_address = ( { ipv4 = "192.168.12.70";
ipv6 = "192:168:30::17";
active = "yes";
preference = "ipv4";
......
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