Commit 8dd9cf3c authored by knopp's avatar knopp

creation of simulation data structure. some cleanup and testing with multiple UEs

parent c3c6284b
......@@ -111,8 +111,6 @@ Options
-t | --transport protocol
ETHERNET , None
Adds this trasport protocol support in compilation
--oaisim
Makes the oaisim simulator. Hardware will be defaulted to \"None\".
--phy_simulators
Makes the unitary tests Layer 1 simulators
--core_simulators
......@@ -124,12 +122,12 @@ Options
-V | --vcd
Adds a debgging facility to the binary files: GUI with major internal synchronization events
-x | --xforms
Adds a software oscilloscope feature to the produced binaries. If oaisim, then enable PRINT_STATS.
Adds a software oscilloscope feature to the produced binaries.
--install-system-files
Install OpenArInterface required files in Linux system
(will ask root password)
--noS1
Compiles oaisim or lte-softmodem without S1 interface, using direct link to IP instead
Compiles lte-softmodem without S1 interface, using direct link to IP instead
--verbose-compile
Shows detailed compilation instructions in makefile
--cflags_processor
......@@ -164,11 +162,8 @@ Options
Generates a basic [1 UE + 1 eNB + no channel] simulator.
See targets/ARCH/tcp_bridge/README.tcp_bridge_oai for documentation.
Usage (first build):
oaisim (eNB + UE): ./build_oai -I --oaisim -x --install-system-files
Eurecom EXMIMO + COTS UE : ./build_oai -I --eNB -x --install-system-files
NI/ETTUS B201 + COTS UE : ./build_oai -I --eNB -x --install-system-files -w USRP
Usage (Regular):
oaisim : ./build_oai --oaisim -x
Eurecom EXMIMO + OAI ENB : ./build_oai --eNB -x
NI/ETTUS B201 + OAI ENB : ./build_oai --eNB -x -w USRP"
}
......@@ -250,10 +245,6 @@ function main() {
echo_info "Setting transport protocol to: $TP"
fi
shift 2;;
--oaisim)
oaisim=1
echo_info "Will compile oaisim and drivers nasmesh, ..."
shift;;
--phy_simulators)
SIMUS_PHY=1
echo_info "Will compile dlsim, ulsim, ..."
......@@ -490,16 +481,6 @@ function main() {
check_install_additional_tools
fi
if [ "$oaisim" = "1" ] ; then
#to be discussed
# there is no RF device transport protocol
HW="None"
TP="ETHERNET"
if [ "$XFORMS" == "True" ] ; then
PRINT_STATS="True"
fi
fi
echo_info "3. building the compilation directives ..."
......@@ -689,123 +670,6 @@ function main() {
cp $OPENAIR_DIR/cmake_targets/tools/init_exmimo2 $dbin
fi
# oaisim compilation
###############
if [ "$oaisim" = "1" ] ; then
dconf=$OPENAIR_DIR/targets/bin
if [ "$NOS1" = "1" ] ; then
oaisim_build_dir=oaisim_noS1_build_oai
oaisim_exec=oaisim_nos1
else
oaisim_build_dir=oaisim_build_oai
oaisim_exec=oaisim
fi
echo_info "Compiling $oaisim_exec ($oaisim_build_dir)"
cmake_file=$DIR/$oaisim_build_dir/CMakeLists.txt
cp $DIR/$oaisim_build_dir/CMakeLists.template $cmake_file
echo "set ( CMAKE_BUILD_TYPE $CMAKE_BUILD_TYPE )" >> $cmake_file
echo "set ( CFLAGS_PROCESSOR_USER \"$CFLAGS_PROCESSOR_USER\" )" >> $cmake_file
echo "set ( XFORMS $XFORMS )" >> $cmake_file
echo "set ( PRINT_STATS $PRINT_STATS )" >> $cmake_file
echo "set ( RRC_ASN1_VERSION \"${REL}\")" >> $cmake_file
echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )" >> $cmake_file
echo "set ( T_TRACER $T_TRACER )" >> $cmake_file
echo "set ( UE_NAS_USE_TUN $UE_NAS_USE_TUN )" >> $cmake_file
echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)' >> $cmake_file
[ "$CLEAN" = "1" ] && rm -rf $DIR/$oaisim_build_dir/build
mkdir -p $DIR/$oaisim_build_dir/build
cd $DIR/$oaisim_build_dir/build
eval $CMAKE_CMD
compilations \
$oaisim_build_dir $oaisim_exec \
$oaisim_exec $dbin/$oaisim_exec.$REL
compilations \
$oaisim_build_dir $config_libconfig_shlib \
lib$config_libconfig_shlib.so $dbin/lib$config_libconfig_shlib.so
compilations \
$oaisim_build_dir coding \
libcoding.so $dbin/libcoding.so
if [ "$NOS1" != "1" ] ; then
[ "$CLEAN" = "1" ] && rm -rf $DIR/at_commands/build
echo_info "Compiling at_nas_ue"
mkdir -p $DIR/at_commands/build
cd $DIR/at_commands/build
eval $CMAKE_CMD
compilations \
at_commands at_nas_ue \
at_nas_ue $dbin/at_nas_ue
# ue_ip driver compilation
echo_info "Compiling UE specific part (ue_ip driver and usim tools)"
compilations \
oaisim_build_oai ue_ip \
CMakeFiles/ue_ip/ue_ip.ko $dbin/ue_ip.ko
[ "$CLEAN" = "1" ] && rm -rf $DIR/nas_sim_tools/build
mkdir -p $DIR/nas_sim_tools/build
cd $DIR/nas_sim_tools/build
eval $CMAKE_CMD
compilations \
nas_sim_tools usim \
usim $dbin/usim
compilations \
nas_sim_tools nvram \
nvram $dbin/nvram
compilations \
nas_sim_tools conf2uedata \
conf2uedata $dbin/conf2uedata
# generate USIM data
if [ -f $dbin/conf2uedata ]; then
install_nas_tools $conf_nvram_path $gen_nvram_path
else
echo_warning "not generated UE NAS files: binaries not found"
fi
else
compilations \
$oaisim_build_dir rb_tool \
rb_tool $dbin/rb_tool
# nasmesh driver compilation
compilations \
$oaisim_build_dir nasmesh \
CMakeFiles/nasmesh/nasmesh.ko $dbin/nasmesh.ko
#oai_nw_drv
#compilations \
# $oaisim_build_dir oai_nw_drv \
# CMakeFiles/oai_nw_drv/oai_nw_drv.ko $dbin/oai_nw_drv.ko
fi
if [ "$TP" == "ETHERNET" ] ; then
compilations \
$oaisim_build_dir oai_eth_transpro \
liboai_eth_transpro.so $dbin/liboai_eth_transpro.so.$REL
ln -sf liboai_eth_transpro.so liboai_transpro.so
ln -sf $dbin/liboai_eth_transpro.so.$REL $dbin/liboai_transpro.so
echo_info "liboai_transpro.so is linked with ETHERNET library"
fi
cmake_file=$DIR/oaisim_mme_build_oai/CMakeLists.txt
cp $DIR/oaisim_mme_build_oai/CMakeLists.template $cmake_file
echo "set ( CMAKE_BUILD_TYPE $CMAKE_BUILD_TYPE )" >> $cmake_file
echo "set ( XFORMS $XFORMS )" >> $cmake_file
echo "set ( RRC_ASN1_VERSION \"${REL}\")" >> $cmake_file
echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )" >> $cmake_file
echo "set ( T_TRACER $T_TRACER )" >> $cmake_file
echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)' >> $cmake_file
#[ "$CLEAN" = "1" ] && rm -rf $DIR/oaisim_mme_build_oai/build
#mkdir -p $DIR/oaisim_mme_build_oai/build
#cd $DIR/oaisim_mme_build_oai/build
#eval $CMAKE_CMD
#compilations \
# oaisim_mme_build_oai oaisim_mme \
# oaisim_mme $dbin/oaisim_mme.$REL
fi
# Telnet server compilation
#####################
......
......@@ -51,24 +51,10 @@
#define LOG_D(A,B,C...) printf(B,C)
*/
int number_rb_ul;
int first_rbUL ;
extern Signal_buffers_t *signal_buffers_g;
double r_re_DL[NUMBER_OF_UE_MAX][2][30720];
double r_im_DL[NUMBER_OF_UE_MAX][2][30720];
double r_re_UL[NUMBER_OF_eNB_MAX][2][30720];
double r_im_UL[NUMBER_OF_eNB_MAX][2][30720];
int RU_output_mask[NUMBER_OF_UE_MAX];
int UE_output_mask[NUMBER_OF_RU_MAX];
pthread_mutex_t RU_output_mutex[NUMBER_OF_UE_MAX];
pthread_mutex_t UE_output_mutex[NUMBER_OF_RU_MAX];
double ru_amp[NUMBER_OF_RU_MAX];
void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs],
void do_DL_sig(sim_t *sim,
uint16_t subframe,
uint32_t offset,
uint32_t length,
......@@ -87,8 +73,8 @@ void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM
uint32_t sf_offset;
uint8_t hold_channel=0;
uint8_t nb_antennas_rx = RU2UE[0][0][CC_id]->nb_rx; // number of rx antennas at UE
uint8_t nb_antennas_tx = RU2UE[0][0][CC_id]->nb_tx; // number of tx antennas at eNB
uint8_t nb_antennas_rx = sim->RU2UE[0][0][CC_id]->nb_rx; // number of rx antennas at UE
uint8_t nb_antennas_tx = sim->RU2UE[0][0][CC_id]->nb_tx; // number of tx antennas at eNB
double s_re0[30720];
double s_re1[30720];
......@@ -119,15 +105,15 @@ void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM
else
hold_channel = 1;
pthread_mutex_lock(&RU_output_mutex[UE_id]);
pthread_mutex_lock(&sim->RU_output_mutex[UE_id]);
if (RU_output_mask[UE_id] == 0) { // This is the first eNodeB for this UE, clear the buffer
if (sim->RU_output_mask[UE_id] == 0) { // This is the first eNodeB for this UE, clear the buffer
for (aa=0; aa<nb_antennas_rx; aa++) {
memset((void*)r_re_DL[UE_id][aa],0,(RC.ru[0]->frame_parms.samples_per_tti)*sizeof(double));
memset((void*)r_im_DL[UE_id][aa],0,(RC.ru[0]->frame_parms.samples_per_tti)*sizeof(double));
memset((void*)sim->r_re_DL[UE_id][aa],0,(RC.ru[0]->frame_parms.samples_per_tti)*sizeof(double));
memset((void*)sim->r_im_DL[UE_id][aa],0,(RC.ru[0]->frame_parms.samples_per_tti)*sizeof(double));
}
}
pthread_mutex_unlock(&RU_output_mutex[UE_id]);
pthread_mutex_unlock(&sim->RU_output_mutex[UE_id]);
for (ru_id=0; ru_id<RC.nb_RU; ru_id++) {
txdata = RC.ru[ru_id]->common.txdata;
......@@ -150,7 +136,7 @@ void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM
14,
frame_parms->pdsch_config_common.referenceSignalPower, // dBm/RE
0,
&ru_amp[ru_id],
&sim->ru_amp[ru_id],
frame_parms->N_RB_DL*12);
}
......@@ -166,7 +152,7 @@ void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM
14,
frame_parms->pdsch_config_common.referenceSignalPower, // dBm/RE
0,
&ru_amp[ru_id],
&sim->ru_amp[ru_id],
frame_parms->N_RB_DL*12);
tx_pwr = dac_fixed_gain(s_re,
......@@ -180,7 +166,7 @@ void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM
14,
frame_parms->pdsch_config_common.referenceSignalPower, // dBm/RE
0,
&ru_amp[ru_id],
&sim->ru_amp[ru_id],
frame_parms->N_RB_DL*12);
}
#ifdef DEBUG_SIM
......@@ -199,26 +185,26 @@ void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM
0)/(12.0*frame_parms->N_RB_DL);
//RU2UE[eNB_id][UE_id]->path_loss_dB = 0;
multipath_channel(RU2UE[ru_id][UE_id][CC_id],s_re,s_im,r_re0,r_im0,
multipath_channel(sim->RU2UE[ru_id][UE_id][CC_id],s_re,s_im,r_re0,r_im0,
length,hold_channel);
#ifdef DEBUG_SIM
rx_pwr = signal_energy_fp2(RU2UE[ru_id][UE_id][CC_id]->ch[0],
RU2UE[ru_id][UE_id][CC_id]->channel_length)*RU2UE[ru_id][UE_id][CC_id]->channel_length;
rx_pwr = signal_energy_fp2(sim->RU2UE[ru_id][UE_id][CC_id]->ch[0],
sim->RU2UE[ru_id][UE_id][CC_id]->channel_length)*sim->RU2UE[ru_id][UE_id][CC_id]->channel_length;
LOG_D(OCM,"[SIM][DL] Channel RU %d => UE %d (CCid %d): Channel gain %f dB (%f)\n",ru_id,UE_id,CC_id,10*log10(rx_pwr),rx_pwr);
#endif
#ifdef DEBUG_SIM
for (i=0; i<RU2UE[ru_id][UE_id][CC_id]->channel_length; i++)
LOG_D(OCM,"channel(%d,%d)[%d] : (%f,%f)\n",ru_id,UE_id,i,RU2UE[ru_id][UE_id][CC_id]->ch[0][i].x,RU2UE[ru_id][UE_id][CC_id]->ch[0][i].y);
for (i=0; i<sim->RU2UE[ru_id][UE_id][CC_id]->channel_length; i++)
LOG_D(OCM,"channel(%d,%d)[%d] : (%f,%f)\n",ru_id,UE_id,i,sim->RU2UE[ru_id][UE_id][CC_id]->ch[0][i].x,sim->RU2UE[ru_id][UE_id][CC_id]->ch[0][i].y);
#endif
LOG_D(OCM,"[SIM][DL] Channel RU %d => UE %d (CCid %d): tx_power %.1f dBm/RE, path_loss %1.f dB\n",
ru_id,UE_id,CC_id,
(double)frame_parms->pdsch_config_common.referenceSignalPower,
RU2UE[ru_id][UE_id][CC_id]->path_loss_dB);
sim->RU2UE[ru_id][UE_id][CC_id]->path_loss_dB);
#ifdef DEBUG_SIM
rx_pwr = signal_energy_fp(r_re0,r_im0,nb_antennas_rx,
......@@ -233,13 +219,13 @@ void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM
LOG_D(OCM,"[SIM][DL] UE %d : rx_pwr (noise) -132 dBm/RE (N0fs = %.1f dBm, N0B = %.1f dBm) for subframe %d\n",
UE_id,
10*log10(RU2UE[ru_id][UE_id][CC_id]->sampling_rate*1e6)-174,
10*log10(RU2UE[ru_id][UE_id][CC_id]->sampling_rate*1e6*12*frame_parms->N_RB_DL/(double)frame_parms->ofdm_symbol_size)-174,
10*log10(sim->RU2UE[ru_id][UE_id][CC_id]->sampling_rate*1e6)-174,
10*log10(sim->RU2UE[ru_id][UE_id][CC_id]->sampling_rate*1e6*12*frame_parms->N_RB_DL/(double)frame_parms->ofdm_symbol_size)-174,
subframe);
#endif
if (RU2UE[ru_id][UE_id][CC_id]->first_run == 1)
RU2UE[ru_id][UE_id][CC_id]->first_run = 0;
if (sim->RU2UE[ru_id][UE_id][CC_id]->first_run == 1)
sim->RU2UE[ru_id][UE_id][CC_id]->first_run = 0;
// RF model
......@@ -252,7 +238,7 @@ void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM
r_im0,
nb_antennas_rx,
length,
1e3/RU2UE[ru_id][UE_id][CC_id]->sampling_rate, // sampling time (ns)
1e3/sim->RU2UE[ru_id][UE_id][CC_id]->sampling_rate, // sampling time (ns)
(double)PHY_vars_UE_g[UE_id][CC_id]->rx_total_gain_dB - 66.227); // rx_gain (dB) (66.227 = 20*log10(pow2(11)) = gain from the adc that will be applied later)
#ifdef DEBUG_SIM
......@@ -266,21 +252,21 @@ void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM
#endif
pthread_mutex_lock(&RU_output_mutex[UE_id]);
pthread_mutex_lock(&sim->RU_output_mutex[UE_id]);
for (i=0; i<frame_parms->samples_per_tti; i++) {
for (aa=0; aa<nb_antennas_rx; aa++) {
r_re_DL[UE_id][aa][i]+=r_re0[aa][i];
r_im_DL[UE_id][aa][i]+=r_im0[aa][i];
sim->r_re_DL[UE_id][aa][i]+=r_re0[aa][i];
sim->r_im_DL[UE_id][aa][i]+=r_im0[aa][i];
}
}
RU_output_mask[UE_id] |= (1<<ru_id);
if (RU_output_mask[UE_id] == (1<<RC.nb_RU)-1) {
RU_output_mask[UE_id]=0;
sim->RU_output_mask[UE_id] |= (1<<ru_id);
if (sim->RU_output_mask[UE_id] == (1<<RC.nb_RU)-1) {
sim->RU_output_mask[UE_id]=0;
double *r_re_p[2] = {r_re_DL[UE_id][0],r_re_DL[UE_id][1]};
double *r_im_p[2] = {r_im_DL[UE_id][0],r_im_DL[UE_id][1]};
double *r_re_p[2] = {sim->r_re_DL[UE_id][0],sim->r_re_DL[UE_id][1]};
double *r_im_p[2] = {sim->r_im_DL[UE_id][0],sim->r_im_DL[UE_id][1]};
#ifdef DEBUG_SIM
rx_pwr = signal_energy_fp(r_re_p,r_im_p,nb_antennas_rx,length<length_meas?length:length_meas,0)/(12.0*frame_parms->N_RB_DL);
......@@ -311,7 +297,7 @@ void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM
#endif
} // RU_output_mask
pthread_mutex_unlock(&RU_output_mutex[UE_id]);
pthread_mutex_unlock(&sim->RU_output_mutex[UE_id]);
} // ru_id
}
......@@ -319,7 +305,7 @@ void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM
void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM_CCs],
void do_UL_sig(sim_t *sim,
uint16_t subframe,uint8_t abstraction_flag,LTE_DL_FRAME_PARMS *frame_parms,
uint32_t frame,int ru_id,uint8_t CC_id)
{
......@@ -327,8 +313,8 @@ void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM
int32_t **txdata,**rxdata;
uint8_t UE_id=0;
uint8_t nb_antennas_rx = UE2RU[0][0][CC_id]->nb_rx; // number of rx antennas at eNB
uint8_t nb_antennas_tx = UE2RU[0][0][CC_id]->nb_tx; // number of tx antennas at UE
uint8_t nb_antennas_rx = sim->UE2RU[0][0][CC_id]->nb_rx; // number of rx antennas at eNB
uint8_t nb_antennas_tx = sim->UE2RU[0][0][CC_id]->nb_tx; // number of tx antennas at UE
double tx_pwr, rx_pwr;
int32_t rx_pwr2;
......@@ -360,15 +346,15 @@ void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM
r_re0[1] = r_re01;
r_im0[1] = r_im01;
pthread_mutex_lock(&UE_output_mutex[ru_id]);
pthread_mutex_lock(&sim->UE_output_mutex[ru_id]);
// Clear RX signal for eNB = eNB_id
for (i=0; i<frame_parms->samples_per_tti; i++) {
for (aa=0; aa<nb_antennas_rx; aa++) {
r_re_UL[ru_id][aa][i]=0.0;
r_im_UL[ru_id][aa][i]=0.0;
sim->r_re_UL[ru_id][aa][i]=0.0;
sim->r_im_UL[ru_id][aa][i]=0.0;
}
}
pthread_mutex_unlock(&UE_output_mutex[ru_id]);
pthread_mutex_unlock(&sim->UE_output_mutex[ru_id]);
// Compute RX signal for eNB = eNB_id
for (UE_id=0; UE_id<NB_UE_INST; UE_id++) {
......@@ -377,7 +363,7 @@ void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM
AssertFatal(txdata != NULL,"txdata is null\n");
sf_offset = subframe*frame_parms->samples_per_tti;
if (((double)PHY_vars_UE_g[UE_id][CC_id]->tx_power_dBm[subframe] +
UE2RU[UE_id][ru_id][CC_id]->path_loss_dB) <= -125.0) {
sim->UE2RU[UE_id][ru_id][CC_id]->path_loss_dB) <= -125.0) {
// don't simulate a UE that is too weak
LOG_D(OCM,"[SIM][UL] ULPOWERS UE %d tx_pwr %d dBm (num_RE %d) for subframe %d (sf_offset %d)\n",
UE_id,
......@@ -406,20 +392,20 @@ void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM
subframe,sf_offset);
multipath_channel(UE2RU[UE_id][ru_id][CC_id],s_re,s_im,r_re0,r_im0,
multipath_channel(sim->UE2RU[UE_id][ru_id][CC_id],s_re,s_im,r_re0,r_im0,
frame_parms->samples_per_tti,hold_channel);
rx_pwr = signal_energy_fp2(UE2RU[UE_id][ru_id][CC_id]->ch[0],
UE2RU[UE_id][ru_id][CC_id]->channel_length)*UE2RU[UE_id][ru_id][CC_id]->channel_length;
rx_pwr = signal_energy_fp2(sim->UE2RU[UE_id][ru_id][CC_id]->ch[0],
sim->UE2RU[UE_id][ru_id][CC_id]->channel_length)*sim->UE2RU[UE_id][ru_id][CC_id]->channel_length;
LOG_D(OCM,"[SIM][UL] subframe %d Channel UE %d => RU %d : %f dB (hold %d,length %d, PL %f)\n",subframe,UE_id,ru_id,10*log10(rx_pwr),
hold_channel,UE2RU[UE_id][ru_id][CC_id]->channel_length,
UE2RU[UE_id][ru_id][CC_id]->path_loss_dB);
hold_channel,sim->UE2RU[UE_id][ru_id][CC_id]->channel_length,
sim->UE2RU[UE_id][ru_id][CC_id]->path_loss_dB);
rx_pwr = signal_energy_fp(r_re0,r_im0,nb_antennas_rx,frame_parms->samples_per_tti,0);
LOG_D(OCM,"[SIM][UL] RU %d (%d/%d rx antennas) : rx_pwr %f dBm (tx_pwr - PL %f) for subframe %d, sptti %d\n",
ru_id,nb_antennas_rx,UE2RU[UE_id][ru_id][CC_id]->nb_rx,10*log10(rx_pwr),10*log10(tx_pwr*PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe])+UE2RU[UE_id][ru_id][CC_id]->path_loss_dB,subframe,frame_parms->samples_per_tti);
ru_id,nb_antennas_rx,sim->UE2RU[UE_id][ru_id][CC_id]->nb_rx,10*log10(rx_pwr),10*log10(tx_pwr*PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe])+sim->UE2RU[UE_id][ru_id][CC_id]->path_loss_dB,subframe,frame_parms->samples_per_tti);
/*
if (abs(10*log10(rx_pwr)-10*log10(tx_pwr*PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe])-UE2RU[UE_id][ru_id][CC_id]->path_loss_dB)>3) {
write_output("txsig_re.m","s_re",s_re[0],frame_parms->samples_per_tti,1,7);
......@@ -429,23 +415,23 @@ void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM
exit(-1);
}*/
if (UE2RU[UE_id][ru_id][CC_id]->first_run == 1)
UE2RU[UE_id][ru_id][CC_id]->first_run = 0;
if (sim->UE2RU[UE_id][ru_id][CC_id]->first_run == 1)
sim->UE2RU[UE_id][ru_id][CC_id]->first_run = 0;
pthread_mutex_lock(&UE_output_mutex[ru_id]);
pthread_mutex_lock(&sim->UE_output_mutex[ru_id]);
for (aa=0; aa<nb_antennas_rx; aa++) {
for (i=0; i<frame_parms->samples_per_tti; i++) {
r_re_UL[ru_id][aa][i]+=r_re0[aa][i];
r_im_UL[ru_id][aa][i]+=r_im0[aa][i];
sim->r_re_UL[ru_id][aa][i]+=r_re0[aa][i];
sim->r_im_UL[ru_id][aa][i]+=r_im0[aa][i];
}
}
pthread_mutex_unlock(&UE_output_mutex[ru_id]);
pthread_mutex_unlock(&sim->UE_output_mutex[ru_id]);
}
} //UE_id
double *r_re_p[2] = {r_re_UL[ru_id][0],r_re_UL[ru_id][1]};
double *r_im_p[2] = {r_im_UL[ru_id][0],r_im_UL[ru_id][1]};
double *r_re_p[2] = {sim->r_re_UL[ru_id][0],sim->r_re_UL[ru_id][1]};
double *r_im_p[2] = {sim->r_im_UL[ru_id][0],sim->r_im_UL[ru_id][1]};
rx_pwr = signal_energy_fp(r_re_p,r_im_p,nb_antennas_rx,frame_parms->samples_per_tti,0);
LOG_D(OCM,"[SIM][UL] RU %d (%d/%d rx antennas) : rx_pwr %f dBm (before RF) for subframe %d, gain %f\n",
......@@ -455,7 +441,7 @@ void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM
r_im_p,
nb_antennas_rx,
frame_parms->samples_per_tti,
1e3/UE2RU[0][ru_id][CC_id]->sampling_rate, // sampling time (ns)
1e3/sim->UE2RU[0][ru_id][CC_id]->sampling_rate, // sampling time (ns)
(double)RC.ru[ru_id]->max_rxgain-(double)RC.ru[ru_id]->att_rx - 66.227); // rx_gain (dB) (66.227 = 20*log10(pow2(11)) = gain from the adc that will be applied later)
#ifdef DEBUG_SIM
......
......@@ -22,7 +22,7 @@
#ifndef __SIMULATION_TOOLS_DEFS_H__
#define __SIMULATION_TOOLS_DEFS_H__
#include "PHY/defs_common.h"
#include <pthread.h>
/** @defgroup _numerical_ Useful Numerical Functions
*@{
The present clause specifies several numerical functions for testing of digital communication systems.
......@@ -181,6 +181,31 @@ typedef enum {
EPA_high,
} SCM_t;
#include "platform_constants.h"
typedef struct {
channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs];
channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM_CCs];
double r_re_DL[NUMBER_OF_UE_MAX][2][30720];
double r_im_DL[NUMBER_OF_UE_MAX][2][30720];
double r_re_UL[NUMBER_OF_eNB_MAX][2][30720];
double r_im_UL[NUMBER_OF_eNB_MAX][2][30720];
int RU_output_mask[NUMBER_OF_UE_MAX];
int UE_output_mask[NUMBER_OF_RU_MAX];
pthread_mutex_t RU_output_mutex[NUMBER_OF_UE_MAX];
pthread_mutex_t UE_output_mutex[NUMBER_OF_RU_MAX];
pthread_mutex_t subframe_mutex;
int subframe_ru_mask;
int subframe_UE_mask;
openair0_timestamp current_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs];
openair0_timestamp current_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs];
openair0_timestamp last_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs];
openair0_timestamp last_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs];
double ru_amp[NUMBER_OF_RU_MAX];
pthread_t rfsim_thread;
} sim_t;
/**
\brief This routine initializes a new channel descriptor
\param nb_tx Number of TX antennas
......@@ -373,7 +398,9 @@ void multipath_tv_channel(channel_desc_t *desc,
double N_RB2sampling_rate(uint16_t N_RB);
double N_RB2channel_bandwidth(uint16_t N_RB);
void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs],
#include "targets/RT/USER/rfsim.h"
void do_DL_sig(sim_t *sim,
uint16_t subframe,
uint32_t offset,
uint32_t length,
......@@ -381,7 +408,7 @@ void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM
uint8_t UE_id,
int CC_id);
void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM_CCs],
void do_UL_sig(sim_t *sim,
uint16_t subframe,uint8_t abstraction_flag,LTE_DL_FRAME_PARMS *frame_parms,
uint32_t frame,int ru_id,uint8_t CC_id);
......
......@@ -93,7 +93,7 @@ uint16_t ue_process_rar(const module_id_t module_idP, const int CC_id, const fra
}
LOG_I(MAC,
"[eNB %d][RAPROC] Frame %d Received RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for preamble %d/%d\n",
"[UE %d][RAPROC] Frame %d Received RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for preamble %d/%d\n",
module_idP, frameP, *(uint8_t *) rarh, rar[0], rar[1], rar[2],
rar[3], rar[4], rar[5], rarh->RAPID, preamble_index);
#ifdef DEBUG_RAR
......
......@@ -53,6 +53,7 @@
#define CONFIG_HLP_CALPRACH "UE run normal prach with maximum power, but don't continue random-access\n"
#define CONFIG_HLP_NOL2CN "bypass L2 and upper layers\n"
#define CONFIG_HLP_SIML1 "activate RF simulator instead of HW\n"
#define CONFIG_HLP_NUMUE "number of UE instances\n"
#define CONFIG_HLP_UERXG "set UE RX gain\n"
#define CONFIG_HLP_UERXGOFF "external UE amplifier offset\n"
#define CONFIG_HLP_UETXG "set UE TX gain\n"
......@@ -134,6 +135,7 @@
/*--------------------------------------------------------------------------------------------------------------------------------------------------*/
#define CMDLINE_UEPARAMS_DESC { \
{"siml1", CONFIG_HLP_SIML1, PARAMFLAG_BOOL, iptr:&simL1flag, defintval:0, TYPE_INT, 0}, \
{"U", CONFIG_HLP_NUMUE, 0, u8ptr:&NB_UE_INST, defuintval:1, TYPE_UINT, 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-txgain", CONFIG_HLP_UETXG, 0, dblptr:&(tx_gain[0][0]), defdblval:0, TYPE_DOUBLE, 0}, \
......@@ -290,7 +292,7 @@ extern void kill_te_thread(PHY_VARS_eNB *);
extern void RCConfig_sim(void);
extern void init_ocm(double,double);
extern void init_ue_devices(void);
extern void init_ue_devices(PHY_VARS_UE *);
PHY_VARS_UE* init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms,
uint8_t UE_id,
......
......@@ -254,7 +254,7 @@ void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in, int timing_correcti
for (inst=0;inst<nb_inst;inst++) {
if (PHY_vars_UE_g[inst]==NULL) PHY_vars_UE_g[inst] = (PHY_VARS_UE**)calloc(1+MAX_NUM_CCs,sizeof(PHY_VARS_UE*));
LOG_I(PHY,"Allocating UE context %d\n",inst);
if (simL1flag == 0) PHY_vars_UE_g[inst][0] = init_ue_vars(NULL,inst,0);
else {
......@@ -307,7 +307,7 @@ void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in, int timing_correcti
UE->frame_parms.nb_antennas_tx = nb_tx;
UE->frame_parms.nb_antennas_rx = nb_rx;
if (simL1flag == 1) init_ue_devices();
if (simL1flag == 1) 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]);
init_UE_threads(inst);
......@@ -327,14 +327,6 @@ void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in, int timing_correcti
}
printf("UE threads created by %ld\n", gettid());
#if 0
#if defined(ENABLE_USE_MME)
extern volatile int start_UE;
while (start_UE == 0) {
sleep(1);
}
#endif
#endif
}
// Panos: Initiating all UEs within a single set of threads for PHY_STUB. Future extensions -> multiple
......
......@@ -817,7 +817,11 @@ int main( int argc, char **argv )
get_options ();
printf("Running with %d UE instances\n",NB_UE_INST);
if (NB_UE_INST > 1 && simL1flag != 1) {
printf("Running with more than 1 UE instance and simL1 is not active, this will result in undefined behaviour for now, exiting.\n");
abort();
}
printf("NFAPI_MODE value: %d \n", nfapi_mode);
......@@ -970,7 +974,7 @@ int main( int argc, char **argv )
init_UE_stub_single_thread(NB_UE_INST,eMBMS_active,uecap_xer_in,emul_iface);
}
else {
init_UE(1,eMBMS_active,uecap_xer_in,0,phy_test,UE_scan,UE_scan_carrier,mode,(int)rx_gain[0][0],tx_max_power[0],
init_UE(NB_UE_INST,eMBMS_active,uecap_xer_in,0,phy_test,UE_scan,UE_scan_carrier,mode,(int)rx_gain[0][0],tx_max_power[0],
frame_parms[0]->nb_antennas_rx,
frame_parms[0]->nb_antennas_tx);
}
......
......@@ -57,24 +57,7 @@ extern PHY_VARS_UE ***PHY_vars_UE_g;
// put all of these in a common structure after
channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs];
channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM_CCs];
double r_re_DL[NUMBER_OF_UE_MAX][2][30720];
double r_im_DL[NUMBER_OF_UE_MAX][2][30720];
double r_re_UL[NUMBER_OF_eNB_MAX][2][30720];
double r_im_UL[NUMBER_OF_eNB_MAX][2][30720];
int RU_output_mask[NUMBER_OF_UE_MAX];
int UE_output_mask[NUMBER_OF_RU_MAX];
pthread_mutex_t RU_output_mutex[NUMBER_OF_UE_MAX];
pthread_mutex_t UE_output_mutex[NUMBER_OF_RU_MAX];
pthread_mutex_t subframe_mutex;
int subframe_ru_mask=0,subframe_UE_mask=0;
openair0_timestamp current_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs];
openair0_timestamp current_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs];
openair0_timestamp last_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs];
openair0_timestamp last_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs];
double ru_amp[NUMBER_OF_RU_MAX];
pthread_t rfsim_thread;
sim_t sim;
void init_ru_devices(void);
......@@ -96,32 +79,11 @@ void wait_RUs(void)
// copy frame parameters from RU to UEs
for (i=0;i<NB_UE_INST;i++) {
/*
PHY_vars_UE_g[i][0]->frame_parms.N_RB_DL = RC.ru[0]->frame_parms.N_RB_DL;
PHY_vars_UE_g[i][0]->frame_parms.N_RB_UL = RC.ru[0]->frame_parms.N_RB_UL;
PHY_vars_UE_g[i][0]->frame_parms.nb_antennas_tx = 1;
PHY_vars_UE_g[i][0]->frame_parms.nb_antennas_rx = 1;
// set initially to 2, it will be revised after initial synchronization
PHY_vars_UE_g[i][0]->frame_parms.nb_antenna_ports_eNB = 2;
PHY_vars_UE_g[i][0]->frame_parms.tdd_config = 1;
PHY_vars_UE_g[i][0]->frame_parms.dl_CarrierFreq = RC.ru[0]->frame_parms.dl_CarrierFreq;
PHY_vars_UE_g[i][0]->frame_parms.ul_CarrierFreq = RC.ru[0]->frame_parms.ul_CarrierFreq;
PHY_vars_UE_g[i][0]->frame_parms.eutra_band = RC.ru[0]->frame_parms.eutra_band;
LOG_I(PHY,"Initializing UE %d frame parameters from RU information: N_RB_DL %d, p %d, dl_Carrierfreq %u, ul_CarrierFreq %u, eutra_band %d\n",
i,
PHY_vars_UE_g[i][0]->frame_parms.N_RB_DL,
PHY_vars_UE_g[i][0]->frame_parms.nb_antenna_ports_eNB,
PHY_vars_UE_g[i][0]->frame_parms.dl_CarrierFreq,
PHY_vars_UE_g[i][0]->frame_parms.ul_CarrierFreq,
PHY_vars_UE_g[i][0]->frame_parms.eutra_band);
*/
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;
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++) current_ru_rx_timestamp[ru_id][0] = RC.ru[ru_id]->frame_parms.samples_per_tti;
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");
}
......@@ -153,7 +115,7 @@ void RCConfig_sim(void) {
static int nframes = 100000;
AssertFatal(0 == pthread_create(&rfsim_thread,
AssertFatal(0 == pthread_create(&