builds are succesful (eNB,UE,gNB,nrUE,physim)
This commit is contained in:
@@ -3004,9 +3004,6 @@ add_executable(lte-uesoftmodem
|
|||||||
${OPENAIR_TARGETS}/RT/USER/lte-ue.c
|
${OPENAIR_TARGETS}/RT/USER/lte-ue.c
|
||||||
${OPENAIR_TARGETS}/RT/USER/lte-uesoftmodem.c
|
${OPENAIR_TARGETS}/RT/USER/lte-uesoftmodem.c
|
||||||
${OPENAIR_DIR}/executables/softmodem-common.c
|
${OPENAIR_DIR}/executables/softmodem-common.c
|
||||||
${OPENAIR_TARGETS}/RT/USER/lte-ru.c
|
|
||||||
${OPENAIR_TARGETS}/RT/USER/ru_control.c
|
|
||||||
${OPENAIR_TARGETS}/RT/USER/rfsim.c
|
|
||||||
${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c
|
${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c
|
||||||
${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
|
${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
|
||||||
${OPENAIR_TARGETS}/ARCH/COMMON/record_player.c
|
${OPENAIR_TARGETS}/ARCH/COMMON/record_player.c
|
||||||
|
|||||||
@@ -1831,7 +1831,7 @@ nr_rrc_ue_establish_srb1(
|
|||||||
{
|
{
|
||||||
// add descriptor from RRC PDU
|
// add descriptor from RRC PDU
|
||||||
NR_UE_rrc_inst[ue_mod_idP].Srb1[gNB_index].Active = 1;
|
NR_UE_rrc_inst[ue_mod_idP].Srb1[gNB_index].Active = 1;
|
||||||
NR_UE_rrc_inst[ue_mod_idP].Srb1[gNB_index].Status = RADIO_CONFIG_OK;//RADIO CFG
|
NR_UE_rrc_inst[ue_mod_idP].Srb1[gNB_index].status = RADIO_CONFIG_OK;//RADIO CFG
|
||||||
NR_UE_rrc_inst[ue_mod_idP].Srb1[gNB_index].Srb_info.Srb_id = 1;
|
NR_UE_rrc_inst[ue_mod_idP].Srb1[gNB_index].Srb_info.Srb_id = 1;
|
||||||
LOG_I(NR_RRC, "[UE %d], CONFIG_SRB1 %d corresponding to gNB_index %d\n", ue_mod_idP, DCCH, gNB_index);
|
LOG_I(NR_RRC, "[UE %d], CONFIG_SRB1 %d corresponding to gNB_index %d\n", ue_mod_idP, DCCH, gNB_index);
|
||||||
return(0);
|
return(0);
|
||||||
@@ -1849,7 +1849,7 @@ nr_rrc_ue_establish_srb2(
|
|||||||
{
|
{
|
||||||
// add descriptor from RRC PDU
|
// add descriptor from RRC PDU
|
||||||
NR_UE_rrc_inst[ue_mod_idP].Srb2[gNB_index].Active = 1;
|
NR_UE_rrc_inst[ue_mod_idP].Srb2[gNB_index].Active = 1;
|
||||||
NR_UE_rrc_inst[ue_mod_idP].Srb2[gNB_index].Status = RADIO_CONFIG_OK;//RADIO CFG
|
NR_UE_rrc_inst[ue_mod_idP].Srb2[gNB_index].status = RADIO_CONFIG_OK;//RADIO CFG
|
||||||
NR_UE_rrc_inst[ue_mod_idP].Srb2[gNB_index].Srb_info.Srb_id = 2;
|
NR_UE_rrc_inst[ue_mod_idP].Srb2[gNB_index].Srb_info.Srb_id = 2;
|
||||||
LOG_I(NR_RRC, "[UE %d], CONFIG_SRB2 %d corresponding to gNB_index %d\n", ue_mod_idP, DCCH1, gNB_index);
|
LOG_I(NR_RRC, "[UE %d], CONFIG_SRB2 %d corresponding to gNB_index %d\n", ue_mod_idP, DCCH1, gNB_index);
|
||||||
return(0);
|
return(0);
|
||||||
|
|||||||
@@ -97,7 +97,6 @@
|
|||||||
/*-------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#define CMDLINE_UEPARAMS_DESC { \
|
#define CMDLINE_UEPARAMS_DESC { \
|
||||||
{"siml1", CONFIG_HLP_SIML1, PARAMFLAG_BOOL, iptr:&simL1flag, defintval:0, TYPE_INT, 0}, \
|
|
||||||
{"U", CONFIG_HLP_NUMUE, 0, u16ptr:&NB_UE_INST, defuintval:1, TYPE_UINT16, 0}, \
|
{"U", CONFIG_HLP_NUMUE, 0, u16ptr:&NB_UE_INST, defuintval:1, TYPE_UINT16, 0}, \
|
||||||
{"ue-rxgain", CONFIG_HLP_UERXG, 0, dblptr:&(rx_gain[0][0]), defdblval:130, TYPE_DOUBLE, 0}, \
|
{"ue-rxgain", CONFIG_HLP_UERXG, 0, dblptr:&(rx_gain[0][0]), defdblval:130, TYPE_DOUBLE, 0}, \
|
||||||
{"ue-rxgain-off", CONFIG_HLP_UERXGOFF, 0, dblptr:&rx_gain_off, defdblval:0, TYPE_DOUBLE, 0}, \
|
{"ue-rxgain-off", CONFIG_HLP_UERXGOFF, 0, dblptr:&rx_gain_off, defdblval:0, TYPE_DOUBLE, 0}, \
|
||||||
@@ -199,7 +198,6 @@ extern void init_te_thread(PHY_VARS_eNB *);
|
|||||||
extern void kill_td_thread(PHY_VARS_eNB *);
|
extern void kill_td_thread(PHY_VARS_eNB *);
|
||||||
extern void kill_te_thread(PHY_VARS_eNB *);
|
extern void kill_te_thread(PHY_VARS_eNB *);
|
||||||
|
|
||||||
extern void RCConfig_sim(void);
|
|
||||||
extern void init_ocm(void);
|
extern void init_ocm(void);
|
||||||
extern void init_ue_devices(PHY_VARS_UE *);
|
extern void init_ue_devices(PHY_VARS_UE *);
|
||||||
|
|
||||||
|
|||||||
@@ -283,13 +283,7 @@ void init_UE(int nb_inst,
|
|||||||
|
|
||||||
LOG_I(PHY,"Allocating UE context %d\n",inst);
|
LOG_I(PHY,"Allocating UE context %d\n",inst);
|
||||||
|
|
||||||
if ( !IS_SOFTMODEM_SIML1 ) PHY_vars_UE_g[inst][0] = init_ue_vars(fp0,inst,0);
|
PHY_vars_UE_g[inst][0] = init_ue_vars(fp0,inst,0);
|
||||||
else {
|
|
||||||
// needed for memcopy below. these are not used in the RU, but needed for UE
|
|
||||||
RC.ru[0]->frame_parms->nb_antennas_rx = fp0->nb_antennas_rx;
|
|
||||||
RC.ru[0]->frame_parms->nb_antennas_tx = fp0->nb_antennas_tx;
|
|
||||||
PHY_vars_UE_g[inst][0] = init_ue_vars(RC.ru[0]->frame_parms,inst,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// turn off timing control loop in UE
|
// turn off timing control loop in UE
|
||||||
PHY_vars_UE_g[inst][0]->no_timing_correction = timing_correction;
|
PHY_vars_UE_g[inst][0]->no_timing_correction = timing_correction;
|
||||||
@@ -371,17 +365,13 @@ void init_UE(int nb_inst,
|
|||||||
*/
|
*/
|
||||||
UE->N_TA_offset = 0;
|
UE->N_TA_offset = 0;
|
||||||
|
|
||||||
if (IS_SOFTMODEM_SIML1 ) init_ue_devices(UE);
|
|
||||||
|
|
||||||
LOG_I(PHY,"Intializing UE Threads for instance %d (%p,%p)...\n",inst,PHY_vars_UE_g[inst],PHY_vars_UE_g[inst][0]);
|
LOG_I(PHY,"Intializing UE Threads for instance %d (%p,%p)...\n",inst,PHY_vars_UE_g[inst],PHY_vars_UE_g[inst][0]);
|
||||||
init_UE_threads(inst);
|
init_UE_threads(inst);
|
||||||
|
|
||||||
if (!IS_SOFTMODEM_SIML1 ) {
|
ret = openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]);
|
||||||
ret = openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]);
|
|
||||||
|
|
||||||
if (ret !=0) {
|
if (ret !=0) {
|
||||||
exit_fun("Error loading device library");
|
exit_fun("Error loading device library");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UE->rfdevice.host_type = RAU_HOST;
|
UE->rfdevice.host_type = RAU_HOST;
|
||||||
|
|||||||
@@ -193,6 +193,9 @@ int oaisim_flag=0;
|
|||||||
*/
|
*/
|
||||||
uint8_t abstraction_flag=0;
|
uint8_t abstraction_flag=0;
|
||||||
|
|
||||||
|
// needed for pdcp.c
|
||||||
|
RAN_CONTEXT_t RC;
|
||||||
|
|
||||||
/* forward declarations */
|
/* forward declarations */
|
||||||
void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]);
|
void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]);
|
||||||
|
|
||||||
@@ -286,7 +289,6 @@ static void get_options(void) {
|
|||||||
int dumpframe=0;
|
int dumpframe=0;
|
||||||
int timingadv=0;
|
int timingadv=0;
|
||||||
uint8_t nfapi_mode = NFAPI_MONOLITHIC;
|
uint8_t nfapi_mode = NFAPI_MONOLITHIC;
|
||||||
int simL1flag =0;
|
|
||||||
|
|
||||||
set_default_frame_parms(frame_parms);
|
set_default_frame_parms(frame_parms);
|
||||||
CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP);
|
CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP);
|
||||||
@@ -300,8 +302,6 @@ static void get_options(void) {
|
|||||||
config_process_cmdline( cmdline_ueparams,sizeof(cmdline_ueparams)/sizeof(paramdef_t),NULL);
|
config_process_cmdline( cmdline_ueparams,sizeof(cmdline_ueparams)/sizeof(paramdef_t),NULL);
|
||||||
nfapi_setmode(nfapi_mode);
|
nfapi_setmode(nfapi_mode);
|
||||||
|
|
||||||
if (simL1flag)
|
|
||||||
set_softmodem_optmask(SOFTMODEM_SIML1_BIT);
|
|
||||||
|
|
||||||
if (loopfile != NULL) {
|
if (loopfile != NULL) {
|
||||||
printf("Input file for hardware emulation: %s",loopfile);
|
printf("Input file for hardware emulation: %s",loopfile);
|
||||||
@@ -574,11 +574,6 @@ int main( int argc, char **argv ) {
|
|||||||
EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1;
|
EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1;
|
||||||
printf("Running with %d UE instances\n",NB_UE_INST);
|
printf("Running with %d UE instances\n",NB_UE_INST);
|
||||||
|
|
||||||
if (NB_UE_INST > 1 && (!IS_SOFTMODEM_SIML1) && NFAPI_MODE!=NFAPI_UE_STUB_PNF) {
|
|
||||||
printf("Running with more than 1 UE instance and simL1 is not active, this will result in undefined behaviour for now, exiting.\n");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Checking option of nums_ue_thread.
|
// Checking option of nums_ue_thread.
|
||||||
if(NB_THREAD_INST < 1) {
|
if(NB_THREAD_INST < 1) {
|
||||||
printf("Running with 0 UE rxtx thread, exiting.\n");
|
printf("Running with 0 UE rxtx thread, exiting.\n");
|
||||||
@@ -649,9 +644,6 @@ int main( int argc, char **argv ) {
|
|||||||
}
|
}
|
||||||
} else init_openair0(frame_parms[0],(int)rx_gain[0][0]);
|
} else init_openair0(frame_parms[0],(int)rx_gain[0][0]);
|
||||||
|
|
||||||
if (IS_SOFTMODEM_SIML1 ) {
|
|
||||||
RCConfig_sim();
|
|
||||||
}
|
|
||||||
|
|
||||||
cpuf=get_cpu_freq_GHz();
|
cpuf=get_cpu_freq_GHz();
|
||||||
|
|
||||||
@@ -753,10 +745,6 @@ int main( int argc, char **argv ) {
|
|||||||
|
|
||||||
//p_exmimo_config->framing.tdd_config = TXRXSWITCH_TESTRX;
|
//p_exmimo_config->framing.tdd_config = TXRXSWITCH_TESTRX;
|
||||||
|
|
||||||
if (IS_SOFTMODEM_SIML1 ) {
|
|
||||||
init_ocm();
|
|
||||||
PHY_vars_UE_g[0][0]->no_timing_correction = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(IS_SOFTMODEM_DOFORMS)
|
if(IS_SOFTMODEM_DOFORMS)
|
||||||
load_softscope("ue",NULL);
|
load_softscope("ue",NULL);
|
||||||
|
|||||||
@@ -1,490 +0,0 @@
|
|||||||
/*
|
|
||||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership.
|
|
||||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
|
||||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
|
||||||
* except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.openairinterface.org/?page_id=698
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*-------------------------------------------------------------------------------
|
|
||||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
|
||||||
* contact@openairinterface.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*! \file rfsim.c
|
|
||||||
* \brief function for simulated RF device
|
|
||||||
* \author R. Knopp
|
|
||||||
* \date 2018
|
|
||||||
* \version 1.0
|
|
||||||
* \company Eurecom
|
|
||||||
* \email: openair_tech@eurecom.fr
|
|
||||||
* \note
|
|
||||||
* \warning
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <execinfo.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <mcheck.h>
|
|
||||||
#include <sys/timerfd.h>
|
|
||||||
|
|
||||||
#include "assertions.h"
|
|
||||||
#include "rfsim.h"
|
|
||||||
#include "openair1/SIMULATION/TOOLS/sim.h"
|
|
||||||
#include "enb_config.h"
|
|
||||||
#include "enb_paramdef.h"
|
|
||||||
#include "platform_constants.h"
|
|
||||||
#include "common/config/config_paramdesc.h"
|
|
||||||
#include "common/config/config_userapi.h"
|
|
||||||
#include "common/ran_context.h"
|
|
||||||
#include "PHY/defs_UE.h"
|
|
||||||
#include "PHY/defs_eNB.h"
|
|
||||||
#include "PHY/defs_RU.h"
|
|
||||||
#include "common/utils/LOG/vcd_signal_dumper.h"
|
|
||||||
|
|
||||||
RAN_CONTEXT_t RC;
|
|
||||||
extern PHY_VARS_UE ***PHY_vars_UE_g;
|
|
||||||
|
|
||||||
|
|
||||||
// put all of these in a common structure after
|
|
||||||
sim_t sim;
|
|
||||||
|
|
||||||
|
|
||||||
void init_ru_devices(void);
|
|
||||||
|
|
||||||
void init_RU(char *,int send_dmrssync);
|
|
||||||
|
|
||||||
void *rfsim_top(void *n_frames);
|
|
||||||
|
|
||||||
void wait_RUs(void) {
|
|
||||||
int i;
|
|
||||||
// wait for all RUs to be configured over fronthaul
|
|
||||||
pthread_mutex_lock(&RC.ru_mutex);
|
|
||||||
|
|
||||||
while (RC.ru_mask>0) {
|
|
||||||
pthread_cond_wait(&RC.ru_cond,&RC.ru_mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&RC.ru_mutex);
|
|
||||||
|
|
||||||
// copy frame parameters from RU to UEs
|
|
||||||
for (i=0; i<NB_UE_INST; i++) {
|
|
||||||
sim.current_UE_rx_timestamp[i][0] = RC.ru[0]->frame_parms->samples_per_tti + RC.ru[0]->frame_parms->ofdm_symbol_size + RC.ru[0]->frame_parms->nb_prefix_samples0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int ru_id=0; ru_id<RC.nb_RU; ru_id++) sim.current_ru_rx_timestamp[ru_id][0] = RC.ru[ru_id]->frame_parms->samples_per_tti;
|
|
||||||
|
|
||||||
printf("RUs are ready, let's go\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void wait_eNBs(void) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void RCConfig_sim(void) {
|
|
||||||
paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0};
|
|
||||||
// Get num RU instances
|
|
||||||
config_getlist( &RUParamList,NULL,0, NULL);
|
|
||||||
RC.nb_RU = RUParamList.numelt;
|
|
||||||
AssertFatal(RC.nb_RU>0,"we need at least 1 RU for simulation\n");
|
|
||||||
printf("returned with %d rus\n",RC.nb_RU);
|
|
||||||
init_RU(NULL,0);
|
|
||||||
printf("Waiting for RUs to get set up\n");
|
|
||||||
wait_RUs();
|
|
||||||
init_ru_devices();
|
|
||||||
static int nframes = 100000;
|
|
||||||
AssertFatal(0 == pthread_create(&sim.rfsim_thread,
|
|
||||||
NULL,
|
|
||||||
rfsim_top,
|
|
||||||
(void *)&nframes), "");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int ru_trx_start(openair0_device *device) {
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ru_trx_end(openair0_device *device) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ru_trx_stop(openair0_device *device) {
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
int UE_trx_start(openair0_device *device) {
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
void UE_trx_end(openair0_device *device) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int UE_trx_stop(openair0_device *device) {
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
int ru_trx_set_freq(openair0_device *device, openair0_config_t *openair0_cfg, int dummy) {
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
int ru_trx_set_gains(openair0_device *device, openair0_config_t *openair0_cfg) {
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
int UE_trx_set_freq(openair0_device *device, openair0_config_t *openair0_cfg, int dummy) {
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
int UE_trx_set_gains(openair0_device *device, openair0_config_t *openair0_cfg) {
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern pthread_mutex_t subframe_mutex;
|
|
||||||
extern int subframe_ru_mask,subframe_UE_mask;
|
|
||||||
|
|
||||||
|
|
||||||
int ru_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) {
|
|
||||||
int ru_id = device->Mod_id;
|
|
||||||
int CC_id = device->CC_id;
|
|
||||||
int subframe;
|
|
||||||
int sample_count=0;
|
|
||||||
*ptimestamp = sim.last_ru_rx_timestamp[ru_id][CC_id];
|
|
||||||
LOG_D(SIM,"RU_trx_read nsamps %d TS(%llu,%llu) => subframe %d\n",nsamps,
|
|
||||||
(unsigned long long)sim.current_ru_rx_timestamp[ru_id][CC_id],
|
|
||||||
(unsigned long long)sim.last_ru_rx_timestamp[ru_id][CC_id],
|
|
||||||
(int)((*ptimestamp/RC.ru[ru_id]->frame_parms->samples_per_tti)%10));
|
|
||||||
|
|
||||||
// if we're at a subframe boundary generate UL signals for this ru
|
|
||||||
|
|
||||||
while (sample_count<nsamps) {
|
|
||||||
while (sim.current_ru_rx_timestamp[ru_id][CC_id]<
|
|
||||||
(nsamps+sim.last_ru_rx_timestamp[ru_id][CC_id])) {
|
|
||||||
LOG_D(SIM,"RU: current TS %"PRIi64", last TS %"PRIi64", sleeping\n",sim.current_ru_rx_timestamp[ru_id][CC_id],sim.last_ru_rx_timestamp[ru_id][CC_id]);
|
|
||||||
usleep(500);
|
|
||||||
}
|
|
||||||
|
|
||||||
subframe = (sim.last_ru_rx_timestamp[ru_id][CC_id]/RC.ru[ru_id]->frame_parms->samples_per_tti)%10;
|
|
||||||
|
|
||||||
if (subframe_select(RC.ru[ru_id]->frame_parms,subframe) != SF_DL || RC.ru[ru_id]->frame_parms->frame_type == FDD) {
|
|
||||||
LOG_D(SIM,"RU_trx_read generating UL subframe %d (Ts %llu, current TS %llu)\n",
|
|
||||||
subframe,(unsigned long long)*ptimestamp,
|
|
||||||
(unsigned long long)sim.current_ru_rx_timestamp[ru_id][CC_id]);
|
|
||||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_DO_UL_SIGNAL,1);
|
|
||||||
do_UL_sig(&sim,
|
|
||||||
subframe,
|
|
||||||
0, // abstraction_flag
|
|
||||||
RC.ru[ru_id]->frame_parms,
|
|
||||||
0, // frame is only used for abstraction
|
|
||||||
ru_id,
|
|
||||||
CC_id);
|
|
||||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_DO_UL_SIGNAL,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
sim.last_ru_rx_timestamp[ru_id][CC_id] += RC.ru[ru_id]->frame_parms->samples_per_tti;
|
|
||||||
sample_count += RC.ru[ru_id]->frame_parms->samples_per_tti;
|
|
||||||
}
|
|
||||||
|
|
||||||
return(nsamps);
|
|
||||||
}
|
|
||||||
|
|
||||||
int UE_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) {
|
|
||||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_UE_TRX_READ,1);
|
|
||||||
int UE_id = device->Mod_id;
|
|
||||||
int CC_id = device->CC_id;
|
|
||||||
int subframe;
|
|
||||||
int sample_count=0;
|
|
||||||
int read_size;
|
|
||||||
int sptti = PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti;
|
|
||||||
*ptimestamp = sim.last_UE_rx_timestamp[UE_id][CC_id];
|
|
||||||
LOG_D(PHY,"UE %d DL simulation 0: UE_trx_read nsamps %d TS %llu (%llu, offset %d) antenna %d\n",
|
|
||||||
UE_id,
|
|
||||||
nsamps,
|
|
||||||
(unsigned long long)sim.current_UE_rx_timestamp[UE_id][CC_id],
|
|
||||||
(unsigned long long)sim.last_UE_rx_timestamp[UE_id][CC_id],
|
|
||||||
(int)(sim.last_UE_rx_timestamp[UE_id][CC_id]%sptti),
|
|
||||||
cc);
|
|
||||||
|
|
||||||
if (nsamps < sptti)
|
|
||||||
read_size = nsamps;
|
|
||||||
else
|
|
||||||
read_size = sptti;
|
|
||||||
|
|
||||||
while (sample_count<nsamps) {
|
|
||||||
LOG_D(SIM,"UE %d: DL simulation 1: UE_trx_read : current TS now %"PRIi64", last TS %"PRIi64"\n",UE_id,sim.current_UE_rx_timestamp[UE_id][CC_id],sim.last_UE_rx_timestamp[UE_id][CC_id]);
|
|
||||||
|
|
||||||
while (sim.current_UE_rx_timestamp[UE_id][CC_id] <
|
|
||||||
(sim.last_UE_rx_timestamp[UE_id][CC_id]+read_size)) {
|
|
||||||
LOG_D(SIM,"UE %d: DL simulation 2: UE_trx_read : current TS %"PRIi64", last TS %"PRIi64", sleeping\n",UE_id,sim.current_UE_rx_timestamp[UE_id][CC_id],sim.last_UE_rx_timestamp[UE_id][CC_id]);
|
|
||||||
usleep(500);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_D(SIM,"UE %d: DL simulation 3: UE_trx_read : current TS now %"PRIi64", last TS %"PRIi64"\n",UE_id,sim.current_UE_rx_timestamp[UE_id][CC_id],sim.last_UE_rx_timestamp[UE_id][CC_id]);
|
|
||||||
// if we cross a subframe-boundary
|
|
||||||
subframe = (sim.last_UE_rx_timestamp[UE_id][CC_id]/sptti)%10;
|
|
||||||
// tell top-level we are busy
|
|
||||||
pthread_mutex_lock(&sim.subframe_mutex);
|
|
||||||
sim.subframe_UE_mask|=(1<<UE_id);
|
|
||||||
LOG_D(SIM,"Setting UE_id %d mask to busy (%d)\n",UE_id,sim.subframe_UE_mask);
|
|
||||||
pthread_mutex_unlock(&sim.subframe_mutex);
|
|
||||||
LOG_D(PHY,"UE %d: DL simulation 4: UE_trx_read generating DL subframe %d (Ts %llu, current TS %llu,nsamps %d)\n",
|
|
||||||
UE_id,subframe,(unsigned long long)*ptimestamp,
|
|
||||||
(unsigned long long)sim.current_UE_rx_timestamp[UE_id][CC_id],
|
|
||||||
nsamps);
|
|
||||||
LOG_D(SIM,"UE %d: DL simulation 5: Doing DL simulation for %d samples starting in subframe %d at offset %d\n",
|
|
||||||
UE_id,nsamps,subframe,
|
|
||||||
(int)(sim.last_UE_rx_timestamp[UE_id][CC_id]%sptti));
|
|
||||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_DO_DL_SIGNAL,1);
|
|
||||||
do_DL_sig(&sim,
|
|
||||||
subframe,
|
|
||||||
sim.last_UE_rx_timestamp[UE_id][CC_id]%sptti,
|
|
||||||
sptti,
|
|
||||||
0, //abstraction_flag,
|
|
||||||
&PHY_vars_UE_g[UE_id][CC_id]->frame_parms,
|
|
||||||
UE_id,
|
|
||||||
CC_id);
|
|
||||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_DO_DL_SIGNAL,0);
|
|
||||||
LOG_D(PHY,"UE %d: DL simulation 6: UE_trx_read @ TS %"PRIi64" (%"PRIi64")=> frame %d, subframe %d\n",
|
|
||||||
UE_id, sim.current_UE_rx_timestamp[UE_id][CC_id],
|
|
||||||
sim.last_UE_rx_timestamp[UE_id][CC_id],
|
|
||||||
(int)((sim.last_UE_rx_timestamp[UE_id][CC_id]/(sptti*10))&1023),
|
|
||||||
subframe);
|
|
||||||
sim.last_UE_rx_timestamp[UE_id][CC_id] += read_size;
|
|
||||||
sample_count += read_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_UE_TRX_READ,0);
|
|
||||||
return(nsamps);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int ru_trx_write(openair0_device *device,openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) {
|
|
||||||
int ru_id = device->Mod_id;
|
|
||||||
LTE_DL_FRAME_PARMS *frame_parms = RC.ru[ru_id]->frame_parms;
|
|
||||||
pthread_mutex_lock(&sim.subframe_mutex);
|
|
||||||
LOG_D(SIM,"[TXPATH] ru_trx_write: RU %d mask %d\n",ru_id,sim.subframe_ru_mask);
|
|
||||||
pthread_mutex_unlock(&sim.subframe_mutex);
|
|
||||||
// compute amplitude of TX signal from first symbol in subframe
|
|
||||||
// note: assumes that the packet is an entire subframe
|
|
||||||
sim.ru_amp[ru_id] = 0;
|
|
||||||
|
|
||||||
for (int aa=0; aa<RC.ru[ru_id]->nb_tx; aa++) {
|
|
||||||
sim.ru_amp[ru_id] += (double)signal_energy((int32_t *)buff[aa],frame_parms->ofdm_symbol_size)/(12*frame_parms->N_RB_DL);
|
|
||||||
}
|
|
||||||
|
|
||||||
sim.ru_amp[ru_id] = sqrt(sim.ru_amp[ru_id]);
|
|
||||||
LOG_D(PHY,"Setting amp for RU %d to %f (%d)\n",ru_id,sim.ru_amp[ru_id], dB_fixed((double)signal_energy((int32_t *)buff[0],frame_parms->ofdm_symbol_size)));
|
|
||||||
// tell top-level we are done
|
|
||||||
pthread_mutex_lock(&sim.subframe_mutex);
|
|
||||||
sim.subframe_ru_mask|=(1<<ru_id);
|
|
||||||
LOG_D(SIM,"Setting RU %d to busy\n",ru_id);
|
|
||||||
pthread_mutex_unlock(&sim.subframe_mutex);
|
|
||||||
return(nsamps);
|
|
||||||
}
|
|
||||||
|
|
||||||
int UE_trx_write(openair0_device *device,openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) {
|
|
||||||
return(nsamps);
|
|
||||||
}
|
|
||||||
|
|
||||||
void init_ru_devices() {
|
|
||||||
module_id_t ru_id;
|
|
||||||
RU_t *ru;
|
|
||||||
|
|
||||||
// allocate memory for RU if not already done
|
|
||||||
if (RC.ru==NULL) RC.ru = (RU_t **)malloc(RC.nb_RU*sizeof(RU_t *));
|
|
||||||
|
|
||||||
for (ru_id=0; ru_id<RC.nb_RU; ru_id++) {
|
|
||||||
LOG_D(SIM,"Initiaizing rfdevice for RU %d\n",ru_id);
|
|
||||||
|
|
||||||
if (RC.ru[ru_id]==NULL) RC.ru[ru_id] = (RU_t *)malloc(sizeof(RU_t));
|
|
||||||
|
|
||||||
ru = RC.ru[ru_id];
|
|
||||||
ru->rfdevice.Mod_id = ru_id;
|
|
||||||
ru->rfdevice.CC_id = 0;
|
|
||||||
ru->rfdevice.trx_start_func = ru_trx_start;
|
|
||||||
ru->rfdevice.trx_read_func = ru_trx_read;
|
|
||||||
ru->rfdevice.trx_write_func = ru_trx_write;
|
|
||||||
ru->rfdevice.trx_end_func = ru_trx_end;
|
|
||||||
ru->rfdevice.trx_stop_func = ru_trx_stop;
|
|
||||||
ru->rfdevice.trx_set_freq_func = ru_trx_set_freq;
|
|
||||||
ru->rfdevice.trx_set_gains_func = ru_trx_set_gains;
|
|
||||||
sim.last_ru_rx_timestamp[ru_id][0] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void init_ue_devices(PHY_VARS_UE *UE) {
|
|
||||||
AssertFatal(UE!=NULL,"UE context is not allocated\n");
|
|
||||||
printf("Initializing UE %d.%d\n",UE->Mod_id,UE->CC_id);
|
|
||||||
UE->rfdevice.Mod_id = UE->Mod_id;
|
|
||||||
UE->rfdevice.CC_id = UE->CC_id;
|
|
||||||
UE->rfdevice.trx_start_func = UE_trx_start;
|
|
||||||
UE->rfdevice.trx_read_func = UE_trx_read;
|
|
||||||
UE->rfdevice.trx_write_func = UE_trx_write;
|
|
||||||
UE->rfdevice.trx_end_func = UE_trx_end;
|
|
||||||
UE->rfdevice.trx_stop_func = UE_trx_stop;
|
|
||||||
UE->rfdevice.trx_set_freq_func = UE_trx_set_freq;
|
|
||||||
UE->rfdevice.trx_set_gains_func = UE_trx_set_gains;
|
|
||||||
sim.last_UE_rx_timestamp[UE->Mod_id][UE->CC_id] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void init_ocm(void) {
|
|
||||||
module_id_t UE_id, ru_id;
|
|
||||||
int CC_id;
|
|
||||||
double DS_TDL = .03;
|
|
||||||
randominit(0);
|
|
||||||
set_taus_seed(0);
|
|
||||||
init_channelmod();
|
|
||||||
double snr_dB = channelmod_get_snr_dB();
|
|
||||||
double sinr_dB = channelmod_get_sinr_dB();
|
|
||||||
init_channel_vars ();//fp, &s_re, &s_im, &r_re, &r_im, &r_re0, &r_im0);
|
|
||||||
// initialize channel descriptors
|
|
||||||
LOG_I(PHY,"Initializing channel descriptors (nb_RU %d, nb_UE %d)\n",RC.nb_RU,NB_UE_INST);
|
|
||||||
|
|
||||||
for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) {
|
|
||||||
for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) {
|
|
||||||
for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
|
|
||||||
LOG_I(PHY,"Initializing channel descriptors (RU %d, UE %d) for N_RB_DL %d\n",ru_id,UE_id,
|
|
||||||
RC.ru[ru_id]->frame_parms->N_RB_DL);
|
|
||||||
sim.RU2UE[ru_id][UE_id][CC_id] =
|
|
||||||
new_channel_desc_scm(RC.ru[ru_id]->nb_tx,
|
|
||||||
PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_rx,
|
|
||||||
AWGN,
|
|
||||||
N_RB2sampling_rate(RC.ru[ru_id]->frame_parms->N_RB_DL),
|
|
||||||
N_RB2channel_bandwidth(RC.ru[ru_id]->frame_parms->N_RB_DL),
|
|
||||||
DS_TDL,
|
|
||||||
0.0,
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
random_channel(sim.RU2UE[ru_id][UE_id][CC_id],0);
|
|
||||||
LOG_D(OCM,"[SIM] Initializing channel (%s) from UE %d to ru %d\n", "AWGN", UE_id, ru_id);
|
|
||||||
|
|
||||||
sim.UE2RU[UE_id][ru_id][CC_id] =
|
|
||||||
new_channel_desc_scm(PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_tx,
|
|
||||||
RC.ru[ru_id]->nb_rx,
|
|
||||||
AWGN,
|
|
||||||
N_RB2sampling_rate(RC.ru[ru_id]->frame_parms->N_RB_UL),
|
|
||||||
N_RB2channel_bandwidth(RC.ru[ru_id]->frame_parms->N_RB_UL),
|
|
||||||
DS_TDL,
|
|
||||||
0.0,
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
random_channel(sim.UE2RU[UE_id][ru_id][CC_id],0);
|
|
||||||
// to make channel reciprocal uncomment following line instead of previous. However this only works for SISO at the moment. For MIMO the channel would need to be transposed.
|
|
||||||
//UE2RU[UE_id][ru_id] = RU2UE[ru_id][UE_id];
|
|
||||||
AssertFatal(sim.RU2UE[ru_id][UE_id][CC_id]!=NULL,"RU2UE[%d][%d][%d] is null\n",ru_id,UE_id,CC_id);
|
|
||||||
AssertFatal(sim.UE2RU[UE_id][ru_id][CC_id]!=NULL,"UE2RU[%d][%d][%d] is null\n",UE_id,ru_id,CC_id);
|
|
||||||
|
|
||||||
//pathloss: -132.24 dBm/15kHz RE + target SNR - eNB TX power per RE
|
|
||||||
if (ru_id == (UE_id % RC.nb_RU)) {
|
|
||||||
sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower;
|
|
||||||
sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower;
|
|
||||||
} else {
|
|
||||||
sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower;
|
|
||||||
sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_I(OCM,"Path loss from eNB %d to UE %d (CCid %d)=> %f dB (eNB TX %d, SNR %f)\n",ru_id,UE_id,CC_id,
|
|
||||||
sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB,
|
|
||||||
RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower,
|
|
||||||
snr_dB);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void update_ocm(double snr_dB,double sinr_dB) {
|
|
||||||
module_id_t UE_id, ru_id;
|
|
||||||
int CC_id;
|
|
||||||
|
|
||||||
for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) {
|
|
||||||
for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) {
|
|
||||||
for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
|
|
||||||
AssertFatal(sim.RU2UE[ru_id][UE_id][CC_id]!=NULL,"RU2UE[%d][%d][%d] is null\n",ru_id,UE_id,CC_id);
|
|
||||||
AssertFatal(sim.UE2RU[UE_id][ru_id][CC_id]!=NULL,"UE2RU[%d][%d][%d] is null\n",UE_id,ru_id,CC_id);
|
|
||||||
|
|
||||||
//pathloss: -132.24 dBm/15kHz RE + target SNR - eNB TX power per RE
|
|
||||||
if (ru_id == (UE_id % RC.nb_RU)) {
|
|
||||||
sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower;
|
|
||||||
sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower;
|
|
||||||
} else {
|
|
||||||
sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower;
|
|
||||||
sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_D(OCM,"Path loss from eNB %d to UE %d (CCid %d)=> %f dB (eNB TX %d, SNR %f)\n",ru_id,UE_id,CC_id,
|
|
||||||
sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB,
|
|
||||||
RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower,
|
|
||||||
snr_dB);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void init_channel_vars(void) {
|
|
||||||
int i;
|
|
||||||
memset(sim.RU_output_mask,0,sizeof(int)*NUMBER_OF_UE_MAX);
|
|
||||||
|
|
||||||
for (i=0; i<NB_UE_INST; i++)
|
|
||||||
pthread_mutex_init(&sim.RU_output_mutex[i],NULL);
|
|
||||||
|
|
||||||
memset(sim.UE_output_mask,0,sizeof(int)*NUMBER_OF_RU_MAX);
|
|
||||||
|
|
||||||
for (i=0; i<RC.nb_RU; i++)
|
|
||||||
pthread_mutex_init(&sim.UE_output_mutex[i],NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void *rfsim_top(void *n_frames) {
|
|
||||||
wait_sync("rfsim_top");
|
|
||||||
printf("Running rfsim with %d frames\n",*(int *)n_frames);
|
|
||||||
|
|
||||||
for (int frame = 0; frame < *(int *)n_frames; frame++) {
|
|
||||||
for (int sf = 0; sf < 10; sf++) {
|
|
||||||
int CC_id=0;
|
|
||||||
int all_done=0;
|
|
||||||
|
|
||||||
while (all_done==0) {
|
|
||||||
pthread_mutex_lock(&sim.subframe_mutex);
|
|
||||||
int subframe_ru_mask_local = (subframe_select(RC.ru[0]->frame_parms,(sf+4)%10)!=SF_UL) ? sim.subframe_ru_mask : ((1<<RC.nb_RU)-1);
|
|
||||||
int subframe_UE_mask_local = (RC.ru[0]->frame_parms->frame_type == FDD || subframe_select(RC.ru[0]->frame_parms,(sf+4)%10)!=SF_DL) ? sim.subframe_UE_mask : ((1<<NB_UE_INST)-1);
|
|
||||||
pthread_mutex_unlock(&sim.subframe_mutex);
|
|
||||||
LOG_D(SIM,"Frame %d, Subframe %d, NB_RU %d, NB_UE %d: Checking masks %x,%x\n",frame,sf,RC.nb_RU,NB_UE_INST,subframe_ru_mask_local,subframe_UE_mask_local);
|
|
||||||
|
|
||||||
if ((subframe_ru_mask_local == ((1<<RC.nb_RU)-1)) &&
|
|
||||||
(subframe_UE_mask_local == ((1<<NB_UE_INST)-1))) all_done=1;
|
|
||||||
else usleep(1500);
|
|
||||||
}
|
|
||||||
|
|
||||||
//clear subframe masks for next round
|
|
||||||
pthread_mutex_lock(&sim.subframe_mutex);
|
|
||||||
sim.subframe_ru_mask=0;
|
|
||||||
sim.subframe_UE_mask=0;
|
|
||||||
pthread_mutex_unlock(&sim.subframe_mutex);
|
|
||||||
|
|
||||||
// increment timestamps
|
|
||||||
|
|
||||||
for (int ru_id=0; ru_id<RC.nb_RU; ru_id++) {
|
|
||||||
sim.current_ru_rx_timestamp[ru_id][CC_id] += RC.ru[ru_id]->frame_parms->samples_per_tti;
|
|
||||||
LOG_D(SIM,"RU %d/%d: TS %"PRIi64"\n",ru_id,CC_id,sim.current_ru_rx_timestamp[ru_id][CC_id]);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int UE_inst = 0; UE_inst<NB_UE_INST; UE_inst++) {
|
|
||||||
sim.current_UE_rx_timestamp[UE_inst][CC_id] += PHY_vars_UE_g[UE_inst][CC_id]->frame_parms.samples_per_tti;
|
|
||||||
LOG_D(SIM,"UE %d/%d: TS %"PRIi64"\n",UE_inst,CC_id,sim.current_UE_rx_timestamp[UE_inst][CC_id]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oai_exit == 1) return((void *)NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return((void *)NULL);
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user