Commit 408422ef authored by Raymond Knopp's avatar Raymond Knopp

Merge branch 'nr_prach' of https://gitlab.eurecom.fr/oai/openairinterface5g into nr_prach

parents 90e6a90e d342e2d1
...@@ -684,7 +684,7 @@ function main() { ...@@ -684,7 +684,7 @@ function main() {
echo_info "Compiling unitary tests simulators" echo_info "Compiling unitary tests simulators"
# TODO: fix: dlsim_tm4 pucchsim prachsim pdcchsim pbchsim mbmssim # TODO: fix: dlsim_tm4 pucchsim prachsim pdcchsim pbchsim mbmssim
#simlist="dlsim_tm4 dlsim ulsim pucchsim prachsim pdcchsim pbchsim mbmssim" #simlist="dlsim_tm4 dlsim ulsim pucchsim prachsim pdcchsim pbchsim mbmssim"
simlist="nr_pucchsim dlsim ulsim polartest ldpctest smallblocktest nr_pbchsim nr_dlschsim nr_dlsim nr_ulschsim nr_prachsim" simlist="nr_prachsim nr_pucchsim dlsim ulsim polartest ldpctest smallblocktest nr_pbchsim nr_dlschsim nr_dlsim nr_ulschsim "
for f in $simlist ; do for f in $simlist ; do
compilations \ compilations \
phy_simulators $f \ phy_simulators $f \
......
...@@ -701,8 +701,7 @@ void init_gNB_proc(int inst) { ...@@ -701,8 +701,7 @@ void init_gNB_proc(int inst) {
PHY_VARS_gNB *gNB; PHY_VARS_gNB *gNB;
gNB_L1_proc_t *proc; gNB_L1_proc_t *proc;
gNB_L1_rxtx_proc_t *L1_proc,*L1_proc_tx; gNB_L1_rxtx_proc_t *L1_proc,*L1_proc_tx;
LOG_I(PHY,"%s(inst:%d) RC.nb_nr_CC[inst]:%d \n",__FUNCTION__,inst,RC.nb_nr_CC[inst]); // LOG_I(PHY,"%s(inst:%d) RC.nb_nr_CC[inst]:%d \n",__FUNCTION__,inst,RC.nb_nr_CC[inst]);
gNB = RC.gNB[inst]; gNB = RC.gNB[inst];
#ifndef OCP_FRAMEWORK #ifndef OCP_FRAMEWORK
LOG_I(PHY,"Initializing gNB processes instance:%d CC_id %d \n",inst,CC_id); LOG_I(PHY,"Initializing gNB processes instance:%d CC_id %d \n",inst,CC_id);
...@@ -753,7 +752,6 @@ void init_gNB_proc(int inst) { ...@@ -753,7 +752,6 @@ void init_gNB_proc(int inst) {
AssertFatal(proc->instance_cnt_prach == -1,"instance_cnt_prach = %d\n",proc->instance_cnt_prach); AssertFatal(proc->instance_cnt_prach == -1,"instance_cnt_prach = %d\n",proc->instance_cnt_prach);
/* setup PHY proc TX sync mechanism */ /* setup PHY proc TX sync mechanism */
pthread_mutex_init(&sync_phy_proc.mutex_phy_proc_tx, NULL); pthread_mutex_init(&sync_phy_proc.mutex_phy_proc_tx, NULL);
pthread_cond_init(&sync_phy_proc.cond_phy_proc_tx, NULL); pthread_cond_init(&sync_phy_proc.cond_phy_proc_tx, NULL);
...@@ -852,7 +850,6 @@ void init_eNB_afterRU(void) { ...@@ -852,7 +850,6 @@ void init_eNB_afterRU(void) {
LOG_I(PHY,"%s() RC.nb_nr_inst:%d\n", __FUNCTION__, RC.nb_nr_inst); LOG_I(PHY,"%s() RC.nb_nr_inst:%d\n", __FUNCTION__, RC.nb_nr_inst);
for (inst=0; inst<RC.nb_nr_inst; inst++) { for (inst=0; inst<RC.nb_nr_inst; inst++) {
LOG_I(PHY,"RC.nb_nr_CC[inst:%d]:%p\n", inst, CC_id, RC.gNB[inst]); LOG_I(PHY,"RC.nb_nr_CC[inst:%d]:%p\n", inst, CC_id, RC.gNB[inst]);
gNB = RC.gNB[inst]; gNB = RC.gNB[inst];
phy_init_nr_gNB(gNB,0,0); phy_init_nr_gNB(gNB,0,0);
...@@ -885,10 +882,8 @@ void init_eNB_afterRU(void) { ...@@ -885,10 +882,8 @@ void init_eNB_afterRU(void) {
* (not tested in other modes). * (not tested in other modes).
*/ */
//init_precoding_weights(RC.gNB[inst]); //init_precoding_weights(RC.gNB[inst]);
}
init_gNB_proc(inst); init_gNB_proc(inst);
}
for (ru_id=0; ru_id<RC.nb_RU; ru_id++) { for (ru_id=0; ru_id<RC.nb_RU; ru_id++) {
AssertFatal(RC.ru[ru_id]!=NULL,"ru_id %d is null\n",ru_id); AssertFatal(RC.ru[ru_id]!=NULL,"ru_id %d is null\n",ru_id);
......
...@@ -790,7 +790,7 @@ static void *ru_thread_asynch_rxtx( void *param ) { ...@@ -790,7 +790,7 @@ static void *ru_thread_asynch_rxtx( void *param ) {
LOG_D(PHY,"ru_thread_asynch_rxtx: Waiting on incoming fronthaul\n"); LOG_D(PHY,"ru_thread_asynch_rxtx: Waiting on incoming fronthaul\n");
// asynchronous receive from north (RRU IF4/IF5) // asynchronous receive from north (RRU IF4/IF5)
else if (ru->fh_north_asynch_in) { if (ru->fh_north_asynch_in) {
if (nr_slot_select(&ru->gNB_list[0]->gNB_config,subframe)!=SF_UL) if (nr_slot_select(&ru->gNB_list[0]->gNB_config,subframe)!=SF_UL)
ru->fh_north_asynch_in(ru,&frame,&subframe); ru->fh_north_asynch_in(ru,&frame,&subframe);
} else AssertFatal(1==0,"Unknown function in ru_thread_asynch_rxtx\n"); } else AssertFatal(1==0,"Unknown function in ru_thread_asynch_rxtx\n");
......
...@@ -185,7 +185,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, ...@@ -185,7 +185,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
*/ */
// PRACH // PRACH
prach_vars->prachF = (int16_t *)malloc16_clear( 1024*2*sizeof(int16_t) ); prach_vars->prachF = (int16_t *)malloc16_clear( 1024*2*sizeof(int16_t) );
prach_vars->rxsigF = (int16_t *)malloc16_clear( 1024*2*sizeof(int16_t) );
prach_vars->prach_ifft = (int32_t *)malloc16_clear(1024*2*sizeof(int32_t)); prach_vars->prach_ifft = (int32_t *)malloc16_clear(1024*2*sizeof(int32_t));
/* /*
......
...@@ -1035,6 +1035,7 @@ typedef struct { ...@@ -1035,6 +1035,7 @@ typedef struct {
int current_dlsch_cqi[NUMBER_OF_CONNECTED_eNB_MAX]; int current_dlsch_cqi[NUMBER_OF_CONNECTED_eNB_MAX];
unsigned char first_run_timing_advance[NUMBER_OF_CONNECTED_eNB_MAX]; unsigned char first_run_timing_advance[NUMBER_OF_CONNECTED_eNB_MAX];
uint8_t generate_prach; uint8_t generate_prach;
uint8_t generate_nr_prach;
uint8_t prach_cnt; uint8_t prach_cnt;
uint8_t prach_PreambleIndex; uint8_t prach_PreambleIndex;
// uint8_t prach_timer; // uint8_t prach_timer;
......
...@@ -242,6 +242,7 @@ typedef struct NR_DL_FRAME_PARMS { ...@@ -242,6 +242,7 @@ typedef struct NR_DL_FRAME_PARMS {
/// total Number of Resource Block Groups: this is ceil(N_PRB/P) /// total Number of Resource Block Groups: this is ceil(N_PRB/P)
/// Frame type (0 FDD, 1 TDD) /// Frame type (0 FDD, 1 TDD)
lte_frame_type_t frame_type; lte_frame_type_t frame_type;
uint8_t tdd_config;
/// Cell ID /// Cell ID
uint16_t Nid_cell; uint16_t Nid_cell;
/// subcarrier spacing (15,30,60,120) /// subcarrier spacing (15,30,60,120)
......
...@@ -4813,3 +4813,193 @@ uint8_t is_ri_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t gNB_id) ...@@ -4813,3 +4813,193 @@ uint8_t is_ri_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t gNB_id)
else else
return(0); return(0);
} }
void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode) {
int frame_tx = proc->frame_tx;
int nr_tti_tx = proc->nr_tti_tx;
int prach_power;
uint16_t preamble_tx=50;
PRACH_RESOURCES_t prach_resources;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PRACH, VCD_FUNCTION_IN);
ue->generate_nr_prach=0;
if (ue->mac_enabled==0){
ue->prach_resources[eNB_id] = &prach_resources;
ue->prach_resources[eNB_id]->ra_PreambleIndex = preamble_tx;
ue->prach_resources[eNB_id]->ra_TDD_map_index = 0;
}
if (ue->mac_enabled==1){
// ask L2 for RACH transport
if ((mode != rx_calib_ue) && (mode != rx_calib_ue_med) && (mode != rx_calib_ue_byp) && (mode != no_L2_connect) ) {
LOG_D(PHY,"Getting PRACH resources\n");
//ue->prach_resources[eNB_id] = mac_xface->ue_get_rach(ue->Mod_id,ue->CC_id,frame_tx,eNB_id,nr_tti_tx);
// LOG_D(PHY,"Got prach_resources for eNB %d address %p, RRCCommon %p\n",eNB_id,ue->prach_resources[eNB_id],UE_mac_inst[ue->Mod_id].radioResourceConfigCommon);
// LOG_D(PHY,"Prach resources %p\n",ue->prach_resources[eNB_id]);
}
}
if (ue->prach_resources[eNB_id]!=NULL) {
ue->generate_nr_prach=1;
ue->prach_cnt=0;
#ifdef SMBV
ue->prach_resources[eNB_id]->ra_PreambleIndex = preamble_tx;
#endif
#ifdef OAI_EMU
ue->prach_PreambleIndex=ue->prach_resources[eNB_id]->ra_PreambleIndex;
#endif
if (abstraction_flag == 0) {
LOG_I(PHY,"mode %d\n",mode);
if ((ue->mac_enabled==1) && (mode != calib_prach_tx)) {
ue->tx_power_dBm[nr_tti_tx] = ue->prach_resources[eNB_id]->ra_PREAMBLE_RECEIVED_TARGET_POWER+get_nr_PL(ue,eNB_id);
}
else {
ue->tx_power_dBm[nr_tti_tx] = ue->tx_power_max_dBm;
ue->prach_resources[eNB_id]->ra_PreambleIndex = preamble_tx;
}
LOG_I(PHY,"[UE %d][RAPROC] Frame %d, nr_tti_rx %d : Generating PRACH, preamble %d,PL %d, P0_PRACH %d, TARGET_RECEIVED_POWER %d dBm, PRACH TDD Resource index %d, RA-RNTI %d\n",
ue->Mod_id,
frame_tx,
nr_tti_tx,
ue->prach_resources[eNB_id]->ra_PreambleIndex,
get_nr_PL(ue,eNB_id),
ue->tx_power_dBm[nr_tti_tx],
ue->prach_resources[eNB_id]->ra_PREAMBLE_RECEIVED_TARGET_POWER,
ue->prach_resources[eNB_id]->ra_TDD_map_index,
ue->prach_resources[eNB_id]->ra_RNTI);
ue->tx_total_RE[nr_tti_tx] = 96;
#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706)
ue->prach_vars[eNB_id]->amp = get_tx_amp(ue->tx_power_dBm[nr_tti_tx],
ue->tx_power_max_dBm,
ue->frame_parms.N_RB_UL,
6);
#else
ue->prach_vars[eNB_id]->amp = AMP;
#endif
if ((mode == calib_prach_tx) && (((proc->frame_tx&0xfffe)%100)==0))
LOG_D(PHY,"[UE %d][RAPROC] Frame %d, nr_tti_rx %d : PRACH TX power %d dBm, amp %d\n",
ue->Mod_id,
proc->frame_rx,
proc->nr_tti_tx,
ue->tx_power_dBm[nr_tti_tx],
ue->prach_vars[eNB_id]->amp);
// start_meas(&ue->tx_prach);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GENERATE_PRACH, VCD_FUNCTION_IN);
// prach_power = generate_nr_prach(ue,eNB_id,nr_tti_tx,frame_tx);
prach_power = generate_nr_prach(ue,0,9,0); //subframe number hardcoded according to the simulator
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GENERATE_PRACH, VCD_FUNCTION_OUT);
// stop_meas(&ue->tx_prach);
LOG_D(PHY,"[UE %d][RAPROC] PRACH PL %d dB, power %d dBm, digital power %d dB (amp %d)\n",
ue->Mod_id,
get_nr_PL(ue,eNB_id),
ue->tx_power_dBm[nr_tti_tx],
dB_fixed(prach_power),
ue->prach_vars[eNB_id]->amp);
}/* else {
UE_transport_info[ue->Mod_id][ue->CC_id].cntl.prach_flag=1;
UE_transport_info[ue->Mod_id][ue->CC_id].cntl.prach_id=ue->prach_resources[eNB_id]->ra_PreambleIndex;
}*/ // commented for compiling as abstraction flag is 0
if (ue->mac_enabled==1){
//mac_xface->Msg1_transmitted(ue->Mod_id,ue->CC_id,frame_tx,eNB_id);
}
LOG_I(PHY,"[UE %d][RAPROC] Frame %d, nr_tti_rx %d: Generating PRACH (eNB %d) preamble index %d for UL, TX power %d dBm (PL %d dB), l3msg \n",
ue->Mod_id,frame_tx,nr_tti_tx,eNB_id,
ue->prach_resources[eNB_id]->ra_PreambleIndex,
ue->prach_resources[eNB_id]->ra_PREAMBLE_RECEIVED_TARGET_POWER+get_nr_PL(ue,eNB_id),
get_nr_PL(ue,eNB_id));
}
// if we're calibrating the PRACH kill the pointer to its resources so that the RA protocol doesn't continue
if (mode == calib_prach_tx)
ue->prach_resources[eNB_id]=NULL;
LOG_D(PHY,"[UE %d] frame %d nr_tti_rx %d : generate_nr_prach %d, prach_cnt %d\n",
ue->Mod_id,frame_tx,nr_tti_tx,ue->generate_nr_prach,ue->prach_cnt);
ue->prach_cnt++;
if (ue->prach_cnt==3)
ue->generate_nr_prach=0;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PRACH, VCD_FUNCTION_OUT);
}
//Yet to be done
/* void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode,relaying_type_t r_type) {
NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms;
int32_t ulsch_start=0;
int nr_tti_tx = proc->nr_tti_tx;
int frame_tx = proc->frame_tx;
unsigned int aa;
uint8_t isSubframeSRS;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX,VCD_FUNCTION_IN);
LOG_D(PHY,"****** start TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, nr_tti_tx);
ue->generate_ul_signal[eNB_id] = 0;
#if UE_TIMING_TRACE
start_meas(&ue->phy_proc_tx);
#endif
ue->tx_power_dBm[nr_tti_tx]=-127;
printf("ue mode =%d\n",ue->UE_mode[eNB_id]);
if (abstraction_flag==0) {
for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
memset(&ue->common_vars.txdataF[aa][nr_tti_tx*frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti],0,frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti*sizeof(int32_t));
}
}
if (abstraction_flag == 0) {
ulsch_common_procedures(ue,proc, (ue->generate_ul_signal[eNB_id] == 0));
}
ue->UE_mode[eNB_id]=1;
ue->frame_parms.prach_config_common.prach_Config_enabled=1;
printf("S: ue->UE_mode[eNB_id] == PRACH is %d and ue->frame_parms.prach_config_common.prach_Config_enabled is %d\n", ue->UE_mode[eNB_id],ue->frame_parms.prach_config_common.prach_Config_enabled);
if ((ue->UE_mode[eNB_id] == PRACH) &&
(ue->frame_parms.prach_config_common.prach_Config_enabled==1)) {
// check if we have PRACH opportunity
if (is_nr_prach_subframe(&ue->frame_parms,frame_tx,nr_tti_tx)) {
printf("the value of is_nr_prach subframe is %d\n",is_nr_prach_subframe(&ue->frame_parms,frame_tx,nr_tti_tx));
nr_ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode);
}
} // mode is PRACH
else {
ue->generate_prach=0;
}
LOG_D(PHY,"****** end TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, nr_tti_tx);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_FUNCTION_OUT);
#if UE_TIMING_TRACE
stop_meas(&ue->phy_proc_tx);
#endif
} */
...@@ -114,7 +114,7 @@ int main(int argc, char **argv) ...@@ -114,7 +114,7 @@ int main(int argc, char **argv)
int N_RB_UL=273; int N_RB_UL=273;
uint32_t prach_errors=0; uint32_t prach_errors=0;
uint8_t subframe=9; uint8_t subframe=9;
uint16_t preamble_energy_list[64],preamble_tx=99,preamble_delay_list[64]; uint16_t preamble_energy_list[64],preamble_tx=50,preamble_delay_list[64];
uint16_t preamble_max,preamble_energy_max; uint16_t preamble_max,preamble_energy_max;
PRACH_RESOURCES_t prach_resources; PRACH_RESOURCES_t prach_resources;
//uint8_t prach_fmt; //uint8_t prach_fmt;
...@@ -514,10 +514,14 @@ int main(int argc, char **argv) ...@@ -514,10 +514,14 @@ int main(int argc, char **argv)
UE->prach_resources[0]->ra_PreambleIndex = preamble_tx; UE->prach_resources[0]->ra_PreambleIndex = preamble_tx;
UE->prach_resources[0]->ra_TDD_map_index = 0; UE->prach_resources[0]->ra_TDD_map_index = 0;
tx_lev = generate_nr_prach(UE, /*tx_lev = generate_nr_prach(UE,
0, //gNB_id, 0, //gNB_id,
subframe, subframe,
0); //Nf 0); //Nf */ //commented for testing purpose
UE_nr_rxtx_proc_t proc={0};
nr_ue_prach_procedures(UE,&proc,0,0,0);
/* tx_lev_dB not used later, no need to set */ /* tx_lev_dB not used later, no need to set */
//tx_lev_dB = (unsigned int) dB_fixed(tx_lev); //tx_lev_dB = (unsigned int) dB_fixed(tx_lev);
...@@ -603,7 +607,7 @@ int main(int argc, char **argv) ...@@ -603,7 +607,7 @@ int main(int argc, char **argv)
if (preamble_rx!=preamble_tx) if (preamble_rx!=preamble_tx)
prach_errors++; prach_errors++;
else { else {
delay_avg += (double)preamble_delay_list[preamble_max]; delay_avg += (double)preamble_delay_list[preamble_tx];
} }
if (n_frames==1) { if (n_frames==1) {
......
...@@ -57,6 +57,26 @@ void config_common(int Mod_idP, ...@@ -57,6 +57,26 @@ void config_common(int Mod_idP,
int mu = 1; int mu = 1;
switch (*scc->ssb_periodicityServingCell) {
case 0:
cfg->sch_config.ssb_periodicity.value = 5;
break;
case 1:
cfg->sch_config.ssb_periodicity.value = 10;
break;
case 2:
cfg->sch_config.ssb_periodicity.value = 20;
break;
case 3:
cfg->sch_config.ssb_periodicity.value = 40;
break;
case 4:
cfg->sch_config.ssb_periodicity.value = 80;
break;
case 5:
cfg->sch_config.ssb_periodicity.value = 160;
break;
}
cfg->sch_config.physical_cell_id.value = *scc->physCellId; cfg->sch_config.physical_cell_id.value = *scc->physCellId;
......
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