Commit b13452ce authored by Raymond Knopp's avatar Raymond Knopp

integration of full channel simulation in Sidelink path

parent cc7037d8
...@@ -1967,7 +1967,7 @@ add_executable(lte-softmodem-stub-nos1 ...@@ -1967,7 +1967,7 @@ add_executable(lte-softmodem-stub-nos1
target_link_libraries (lte-softmodem-stub-nos1 target_link_libraries (lte-softmodem-stub-nos1
-Wl,--start-group -Wl,--start-group
RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS L2 ${MSC_LIB} ${RAL_LIB} ${ITTI_LIB} ${MIH_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS L2 SIMU ${MSC_LIB} ${RAL_LIB} ${ITTI_LIB} ${MIH_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7
NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB
NFAPI_USER_LIB NFAPI_USER_LIB
-Wl,--end-group z dl) -Wl,--end-group z dl)
...@@ -1994,6 +1994,8 @@ add_executable(lte-softmodem-stub ...@@ -1994,6 +1994,8 @@ add_executable(lte-softmodem-stub
${OPENAIR_TARGETS}/RT/USER/lte-enb.c ${OPENAIR_TARGETS}/RT/USER/lte-enb.c
${OPENAIR_TARGETS}/RT/USER/lte-softmodem-stub.c ${OPENAIR_TARGETS}/RT/USER/lte-softmodem-stub.c
${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c
${OPENAIR_TARGETS}/SIMU/USER/channel_sim.c
${OPENAIR1_DIR}/SIMULATION/TOOLS/random_channel.c
${OPENAIR_TARGETS}/SIMU/USER/init_lte.c ${OPENAIR_TARGETS}/SIMU/USER/init_lte.c
${OPENAIR_TARGETS}/COMMON/create_tasks.c ${OPENAIR_TARGETS}/COMMON/create_tasks.c
${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
...@@ -2014,7 +2016,7 @@ add_executable(lte-softmodem-stub ...@@ -2014,7 +2016,7 @@ add_executable(lte-softmodem-stub
target_link_libraries (lte-softmodem-stub target_link_libraries (lte-softmodem-stub
-Wl,--start-group -Wl,--start-group
RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS L2 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${MIH_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY SIMU LFDS L2 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${MIH_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7
NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB
NFAPI_USER_LIB NFAPI_USER_LIB
-Wl,--end-group z dl) -Wl,--end-group z dl)
...@@ -2023,7 +2025,7 @@ target_link_libraries (lte-softmodem-stub ${LIBXML2_LIBRARIES}) ...@@ -2023,7 +2025,7 @@ target_link_libraries (lte-softmodem-stub ${LIBXML2_LIBRARIES})
target_link_libraries (lte-softmodem-stub pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES}) target_link_libraries (lte-softmodem-stub pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES})
target_link_libraries (lte-softmodem-stub ${LIB_LMS_LIBRARIES}) target_link_libraries (lte-softmodem-stub ${LIB_LMS_LIBRARIES})
target_link_libraries (lte-softmodem-stub ${T_LIB}) target_link_libraries (lte-softmodem-stub ${T_LIB})
target_link_libraries (lte-softmodem-stub ${LAPACK_LIBRARIES} ${ATLAS_LIBRARIES})
# rrh # rrh
......
...@@ -420,10 +420,14 @@ void pscch_codingmodulation(PHY_VARS_UE *ue,int frame_tx,int subframe_tx,uint32_ ...@@ -420,10 +420,14 @@ void pscch_codingmodulation(PHY_VARS_UE *ue,int frame_tx,int subframe_tx,uint32_
} }
void slsch_codingmodulation() { void slsch_codingmodulation(PHY_VARS_UE *ue,int frame_tx,int subframe_tx) {
SLSCH_t *slsch=ue->slsch;
AssertFatal(slsch!=NULL,"ue->slsch is null\n");
// G=
} }
void check_and_generate_pssch(PHY_VARS_UE *ue,int frame_tx,int subframe_tx) { void check_and_generate_pssch(PHY_VARS_UE *ue,int frame_tx,int subframe_tx) {
AssertFatal(frame_tx<1024 && frame_tx>0,"frame %d is illegal\n",frame_tx); AssertFatal(frame_tx<1024 && frame_tx>0,"frame %d is illegal\n",frame_tx);
......
...@@ -51,14 +51,14 @@ ...@@ -51,14 +51,14 @@
*/ */
void set_taus_seed(unsigned int seed_type); void set_taus_seed(unsigned int seed_type);
/*! \fn inline unsigned int taus(unsigned int comp); /*! \fn inline unsigned int tausc(unsigned int comp);
* \brief compute random number * \brief compute random number
* \param[in] integer * \param[in] integer
* \param[out] * \param[out]
* \note * \note
* @ingroup _oml * @ingroup _oml
*/ */
unsigned int taus(unsigned int comp); unsigned int tausc(unsigned int comp);
/*! \fn void init_seeds(int seed); /*! \fn void init_seeds(int seed);
......
...@@ -50,7 +50,7 @@ unsigned int s0[MAX_NUM_COMPS], s1[MAX_NUM_COMPS], s2[MAX_NUM_COMPS], b[MAX_NUM_ ...@@ -50,7 +50,7 @@ unsigned int s0[MAX_NUM_COMPS], s1[MAX_NUM_COMPS], s2[MAX_NUM_COMPS], b[MAX_NUM_
inline unsigned int taus(unsigned int comp) inline unsigned int tausc(unsigned int comp)
{ {
b[comp] = (((s0[comp] << 13) ^ s0[comp]) >> 19); b[comp] = (((s0[comp] << 13) ^ s0[comp]) >> 19);
......
...@@ -288,6 +288,8 @@ void init_UE_stub(int nb_inst,int eMBMS_active, int uecap_xer_in, char *emul_ifa ...@@ -288,6 +288,8 @@ void init_UE_stub(int nb_inst,int eMBMS_active, int uecap_xer_in, char *emul_ifa
} }
init_timer_thread(); init_timer_thread();
init_sl_channel();
for (inst=0;inst<nb_inst;inst++) { for (inst=0;inst<nb_inst;inst++) {
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]);
...@@ -300,6 +302,7 @@ void init_UE_stub(int nb_inst,int eMBMS_active, int uecap_xer_in, char *emul_ifa ...@@ -300,6 +302,7 @@ void init_UE_stub(int nb_inst,int eMBMS_active, int uecap_xer_in, char *emul_ifa
multicast_link_start(ue_stub_rx_handler,0,emul_iface); multicast_link_start(ue_stub_rx_handler,0,emul_iface);
} }
...@@ -757,8 +760,28 @@ static void *UE_thread_rxn_txnp4(void *arg) { ...@@ -757,8 +760,28 @@ static void *UE_thread_rxn_txnp4(void *arg) {
} }
#include "openair1/SIMULATION/TOOLS/defs.h"
unsigned int emulator_absSF; unsigned int emulator_absSF;
channel_desc_t *UE2UE[NUMBER_OF_UE_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs];
void init_sl_channel(void) {
for (int UE_id = 0; UE_id < NB_UE_INST; UE_id++) {
for (int UE_id2 = 1; UE_id2 < NB_UE_INST; UE_id2++) {
UE2UE[UE_id][UE_id2][0] =
new_channel_desc_scm(PHY_vars_UE_g[UE_id][0]->frame_parms.nb_antennas_tx,
PHY_vars_UE_g[UE_id][0]->frame_parms.nb_antennas_rx,
AWGN,
N_RB2sampling_rate(PHY_vars_UE_g[UE_id][0]->frame_parms.N_RB_UL),
N_RB2channel_bandwidth(PHY_vars_UE_g[UE_id][0]->frame_parms.N_RB_DL),
0.0,
0,
0);
random_channel(UE2UE[UE_id][UE_id2][0],0);
}
}
}
void ue_stub_rx_handler(unsigned int num_bytes, char *rx_buffer) { void ue_stub_rx_handler(unsigned int num_bytes, char *rx_buffer) {
...@@ -785,10 +808,19 @@ void ue_stub_rx_handler(unsigned int num_bytes, char *rx_buffer) { ...@@ -785,10 +808,19 @@ void ue_stub_rx_handler(unsigned int num_bytes, char *rx_buffer) {
for (int i=0;i<sizeof(SLSCH_t);i++) printf("%x ",((uint8_t*)slsch)[i]); for (int i=0;i<sizeof(SLSCH_t);i++) printf("%x ",((uint8_t*)slsch)[i]);
printf("\n"); printf("\n");
int frame = pdu->header.absSF/10;
int subframe = pdu->header.absSF%10;
if (UE->sidelink_l2_emulation == 2) {
// do simulation here
UE->slsch = slsch;
check_and_generate_pscch(UE,frame,subframe);
check_and_generate_pssch(UE,frame,subframe);
do_SL_sig(UE2UE,subframe,&UE->frame_parms,frame,0);
rx_slcch(UE,frame,subframe);
}
ue_send_sl_sdu(0, ue_send_sl_sdu(0,
0, 0,
pdu->header.absSF/10, frame,subframe,
pdu->header.absSF%10,
pdu->payload, pdu->payload,
slsch->payload_length, slsch->payload_length,
0, 0,
......
...@@ -72,6 +72,8 @@ double r_re_DL[NUMBER_OF_UE_MAX][2][30720]; ...@@ -72,6 +72,8 @@ double r_re_DL[NUMBER_OF_UE_MAX][2][30720];
double r_im_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_re_UL[NUMBER_OF_eNB_MAX][2][30720];
double r_im_UL[NUMBER_OF_eNB_MAX][2][30720]; double r_im_UL[NUMBER_OF_eNB_MAX][2][30720];
double r_re_SL[NUMBER_OF_UE_MAX][2][30720];
double r_im_SL[NUMBER_OF_UE_MAX][2][30720];
int RU_output_mask[NUMBER_OF_UE_MAX]; int RU_output_mask[NUMBER_OF_UE_MAX];
int UE_output_mask[NUMBER_OF_RU_MAX]; int UE_output_mask[NUMBER_OF_RU_MAX];
pthread_mutex_t RU_output_mutex[NUMBER_OF_UE_MAX]; pthread_mutex_t RU_output_mutex[NUMBER_OF_UE_MAX];
...@@ -134,264 +136,171 @@ void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM ...@@ -134,264 +136,171 @@ void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM
else else
hold_channel = 1; hold_channel = 1;
if (abstraction_flag != 0) {
//for (UE_id=0;UE_id<NB_UE_INST;UE_id++) {
if (!hold_channel) { pthread_mutex_lock(&RU_output_mutex[UE_id]);
// calculate the random channel from each RU
for (ru_id=0; ru_id<RC.nb_RU; ru_id++) { if (RU_output_mask[UE_id] == 0) { // This is the first eNodeB for this UE, clear the buffer
random_channel(RU2UE[ru_id][UE_id][CC_id],abstraction_flag); 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));
for (i=0;i<RU2UE[eNB_id][UE_id]->nb_taps;i++) memset((void*)r_im_DL[UE_id][aa],0,(RC.ru[0]->frame_parms.samples_per_tti)*sizeof(double));
printf("RU2UE[%d][%d]->a[0][%d] = (%f,%f)\n",eNB_id,UE_id,i,RU2UE[eNB_id][UE_id]->a[0][i].x,RU2UE[eNB_id][UE_id]->a[0][i].y);
*/
freq_channel(RU2UE[ru_id][UE_id][CC_id], frame_parms->N_RB_DL,frame_parms->N_RB_DL*12+1);
}
// find out which eNB the UE is attached to
/*
for (eNB_id=0; eNB_id<RC.nb_inst; eNB_id++) {
if (find_ue(PHY_vars_UE_g[UE_id][CC_id]->pdcch_vars[0][0]->crnti,RC.eNB[eNB_id][CC_id])>=0) {
// UE with UE_id is connected to eNb with eNB_id
att_eNB_id=eNB_id;
LOG_D(OCM,"A: UE attached to eNB (UE%d->eNB%d)\n",UE_id,eNB_id);
}
}
*/
// if UE is not attached yet, find assume its the eNB with the smallest pathloss
if (att_eNB_id<0) {
for (eNB_id=0; eNB_id<NB_eNB_INST; eNB_id++) {
for (int ru=0;ru<RC.nb_RU;ru++) {
ru_id = RC.eNB[eNB_id][CC_id]->RU_list[ru]->idx;
if (min_path_loss<RU2UE[ru_id][UE_id][CC_id]->path_loss_dB) {
min_path_loss = RU2UE[ru_id][UE_id][CC_id]->path_loss_dB;
att_eNB_id=eNB_id;
LOG_D(OCM,"B: UE attached to eNB (UE%d->eNB%d)\n",UE_id,eNB_id);
}
}
}
}
if (att_eNB_id<0) {
LOG_E(OCM,"Cannot find eNB for UE %d, return\n",UE_id);
return; //exit(-1);
}
#ifdef DEBUG_SIM
rx_pwr = signal_energy_fp2(RU2UE[att_eNB_id][UE_id][CC_id]->ch[0],
RU2UE[att_eNB_id][UE_id][CC_id]->channel_length)*RU2UE[att_eNB_id][UE_id][CC_id]->channel_length;
LOG_D(OCM,"Channel (CCid %d) eNB %d => UE %d : tx_power %d dBm, path_loss %f dB\n",
CC_id,att_eNB_id,UE_id,
frame_parms->pdsch_config_common.referenceSignalPower,
RU2UE[att_eNB_id][UE_id][CC_id]->path_loss_dB);
#endif
//dlsch_abstraction(PHY_vars_UE_g[UE_id]->sinr_dB, rb_alloc, 8);
// fill in perfect channel estimates
channel_desc_t *desc1 = RU2UE[att_eNB_id][UE_id][CC_id];
int32_t **dl_channel_est = PHY_vars_UE_g[UE_id][CC_id]->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[0];
// double scale = pow(10.0,(enb_data[att_eNB_id]->tx_power_dBm + RU2UE[att_eNB_id][UE_id]->path_loss_dB + (double) PHY_vars_UE_g[UE_id]->rx_total_gain_dB)/20.0);
double scale = pow(10.0,(frame_parms->pdsch_config_common.referenceSignalPower+RU2UE[att_eNB_id][UE_id][CC_id]->path_loss_dB + (double) PHY_vars_UE_g[UE_id][CC_id]->rx_total_gain_dB)/20.0);
LOG_D(OCM,"scale =%lf (%d dB)\n",scale,(int) (20*log10(scale)));
// freq_channel(desc1,frame_parms->N_RB_DL,nb_samples);
//write_output("channel.m","ch",desc1->ch[0],desc1->channel_length,1,8);
//write_output("channelF.m","chF",desc1->chF[0],nb_samples,1,8);
int count,count1,a_rx,a_tx;
for(a_tx=0; a_tx<nb_antennas_tx; a_tx++) {
for (a_rx=0; a_rx<nb_antennas_rx; a_rx++) {
//for (count=0;count<frame_parms->symbols_per_tti/2;count++)
for (count=0; count<1; count++) {
for (count1=0; count1<frame_parms->N_RB_DL*12; count1++) {
((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count1+(count*frame_parms->ofdm_symbol_size+LTE_CE_FILTER_LENGTH)*2]=(int16_t)(desc1->chF[a_rx+(a_tx*nb_antennas_rx)][count1].x*scale);
((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count1+1+(count*frame_parms->ofdm_symbol_size+LTE_CE_FILTER_LENGTH)*2]=(int16_t)(desc1->chF[a_rx+(a_tx*nb_antennas_rx)][count1].y*scale) ;
}
}
}
}
// calculate the SNR for the attached eNB (this assumes eNB always uses PMI stored in eNB_UE_stats; to be improved)
init_snr(RU2UE[att_eNB_id][UE_id][CC_id], enb_data[att_eNB_id], ue_data[UE_id], PHY_vars_UE_g[UE_id][CC_id]->sinr_dB, &PHY_vars_UE_g[UE_id][CC_id]->N0,
PHY_vars_UE_g[UE_id][CC_id]->transmission_mode[att_eNB_id], RC.eNB[att_eNB_id][CC_id]->UE_stats[UE_id].DL_pmi_single,
RC.eNB[att_eNB_id][CC_id]->mu_mimo_mode[UE_id].dl_pow_off,RC.eNB[att_eNB_id][CC_id]->frame_parms.N_RB_DL);
// calculate sinr here
for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) {
if (att_eNB_id != eNB_id) {
calculate_sinr(RU2UE[eNB_id][UE_id][CC_id], enb_data[eNB_id], ue_data[UE_id], PHY_vars_UE_g[UE_id][CC_id]->sinr_dB,
RC.eNB[att_eNB_id][CC_id]->frame_parms.N_RB_DL);
}
}
} // hold channel
}
else { //abstraction_flag
pthread_mutex_lock(&RU_output_mutex[UE_id]);
if (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));
}
} }
pthread_mutex_unlock(&RU_output_mutex[UE_id]); }
pthread_mutex_unlock(&RU_output_mutex[UE_id]);
for (ru_id=0; ru_id<RC.nb_RU; ru_id++) {
txdata = RC.ru[ru_id]->common.txdata; for (ru_id=0; ru_id<RC.nb_RU; ru_id++) {
frame_parms = &RC.ru[ru_id]->frame_parms; txdata = RC.ru[ru_id]->common.txdata;
frame_parms = &RC.ru[ru_id]->frame_parms;
sf_offset = (subframe*frame_parms->samples_per_tti) + offset;
LOG_D(EMU,"TXPATH: RU %d : DL_sig reading TX for subframe %d (sf_offset %d, length %d) from %p\n",ru_id,subframe,sf_offset,length,txdata[0]+sf_offset); sf_offset = (subframe*frame_parms->samples_per_tti) + offset;
int length_meas = frame_parms->ofdm_symbol_size; LOG_D(EMU,"TXPATH: RU %d : DL_sig reading TX for subframe %d (sf_offset %d, length %d) from %p\n",ru_id,subframe,sf_offset,length,txdata[0]+sf_offset);
tx_pwr = dac_fixed_gain(s_re, int length_meas = frame_parms->ofdm_symbol_size;
s_im, tx_pwr = dac_fixed_gain(s_re,
txdata, s_im,
sf_offset, txdata,
nb_antennas_tx, sf_offset,
length, nb_antennas_tx,
sf_offset, length,
length_meas, sf_offset,
14, length_meas,
frame_parms->pdsch_config_common.referenceSignalPower, // dBm/RE 14,
0, frame_parms->pdsch_config_common.referenceSignalPower, // dBm/RE
&ru_amp[ru_id], 0,
frame_parms->N_RB_DL*12); &ru_amp[ru_id],
frame_parms->N_RB_DL*12);
#ifdef DEBUG_SIM #ifdef DEBUG_SIM
LOG_D(PHY,"[SIM][DL] subframe %d: txp (time) %d dB\n", LOG_D(PHY,"[SIM][DL] subframe %d: txp (time) %d dB\n",
subframe,dB_fixed(signal_energy(&txdata[0][sf_offset],length_meas))); subframe,dB_fixed(signal_energy(&txdata[0][sf_offset],length_meas)));
LOG_D(OCM,"[SIM][DL] RU %d (CCid %d): tx_pwr %.1f dBm/RE (target %d dBm/RE), for subframe %d\n", LOG_D(OCM,"[SIM][DL] RU %d (CCid %d): tx_pwr %.1f dBm/RE (target %d dBm/RE), for subframe %d\n",
ru_id,CC_id, ru_id,CC_id,
10*log10(tx_pwr), 10*log10(tx_pwr),
frame_parms->pdsch_config_common.referenceSignalPower, frame_parms->pdsch_config_common.referenceSignalPower,
subframe); subframe);
#endif #endif
tx_pwr = signal_energy_fp(s_re,s_im,nb_antennas_tx, tx_pwr = signal_energy_fp(s_re,s_im,nb_antennas_tx,
length<length_meas?length:length_meas, length<length_meas?length:length_meas,
0)/(12.0*frame_parms->N_RB_DL); 0)/(12.0*frame_parms->N_RB_DL);
//RU2UE[eNB_id][UE_id]->path_loss_dB = 0; //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(RU2UE[ru_id][UE_id][CC_id],s_re,s_im,r_re0,r_im0,
length,hold_channel); length,hold_channel);
#ifdef DEBUG_SIM #ifdef DEBUG_SIM
rx_pwr = signal_energy_fp2(RU2UE[ru_id][UE_id][CC_id]->ch[0], 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; RU2UE[ru_id][UE_id][CC_id]->channel_length)*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); 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 #endif
#ifdef DEBUG_SIM #ifdef DEBUG_SIM
for (i=0; i<RU2UE[ru_id][UE_id][CC_id]->channel_length; i++) 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); 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);
#endif #endif
LOG_D(OCM,"[SIM][DL] Channel RU %d => UE %d (CCid %d): tx_power %.1f dBm/RE, path_loss %1.f dB\n", 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, ru_id,UE_id,CC_id,
(double)frame_parms->pdsch_config_common.referenceSignalPower, (double)frame_parms->pdsch_config_common.referenceSignalPower,
// enb_data[eNB_id]->tx_power_dBm, // enb_data[eNB_id]->tx_power_dBm,
RU2UE[ru_id][UE_id][CC_id]->path_loss_dB); RU2UE[ru_id][UE_id][CC_id]->path_loss_dB);
#ifdef DEBUG_SIM #ifdef DEBUG_SIM
rx_pwr = signal_energy_fp(r_re0,r_im0,nb_antennas_rx, rx_pwr = signal_energy_fp(r_re0,r_im0,nb_antennas_rx,
length<length_meas?length:length_meas, length<length_meas?length:length_meas,
0)/(12.0*frame_parms->N_RB_DL); 0)/(12.0*frame_parms->N_RB_DL);
LOG_D(OCM,"[SIM][DL] UE %d : rx_pwr %f dBm/RE (%f dBm RSSI,tx %f dB)for subframe %d (length %d)\n",UE_id, LOG_D(OCM,"[SIM][DL] UE %d : rx_pwr %f dBm/RE (%f dBm RSSI,tx %f dB)for subframe %d (length %d)\n",UE_id,
10*log10(rx_pwr), 10*log10(rx_pwr),
10*log10(rx_pwr*(double)frame_parms->N_RB_DL*12), 10*log10(rx_pwr*(double)frame_parms->N_RB_DL*12),
10*log10(tx_pwr),subframe, 10*log10(tx_pwr),subframe,
length<length_meas?length:length_meas); length<length_meas?length:length_meas);
LOG_D(OCM,"[SIM][DL] UE %d : rx_pwr (noise) -132 dBm/RE (N0fs = %.1f dBm, N0B = %.1f dBm) for subframe %d\n", 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, 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)-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(RU2UE[ru_id][UE_id][CC_id]->sampling_rate*1e6*12*frame_parms->N_RB_DL/(double)frame_parms->ofdm_symbol_size)-174,
subframe); subframe);
#endif #endif
if (RU2UE[ru_id][UE_id][CC_id]->first_run == 1) if (RU2UE[ru_id][UE_id][CC_id]->first_run == 1)
RU2UE[ru_id][UE_id][CC_id]->first_run = 0; RU2UE[ru_id][UE_id][CC_id]->first_run = 0;
// RF model // RF model
#ifdef DEBUG_SIM #ifdef DEBUG_SIM
LOG_D(OCM,"[SIM][DL] UE %d (CCid %d): rx_gain %d dB (-ADC %f) for subframe %d\n",UE_id,CC_id,PHY_vars_UE_g[UE_id][CC_id]->rx_total_gain_dB, LOG_D(OCM,"[SIM][DL] UE %d (CCid %d): rx_gain %d dB (-ADC %f) for subframe %d\n",UE_id,CC_id,PHY_vars_UE_g[UE_id][CC_id]->rx_total_gain_dB,
PHY_vars_UE_g[UE_id][CC_id]->rx_total_gain_dB-66.227,subframe); PHY_vars_UE_g[UE_id][CC_id]->rx_total_gain_dB-66.227,subframe);
#endif #endif
rf_rx_simple(r_re0, rf_rx_simple(r_re0,
r_im0, r_im0,
nb_antennas_rx, nb_antennas_rx,
length, length,
1e3/RU2UE[ru_id][UE_id][CC_id]->sampling_rate, // sampling time (ns) 1e3/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) (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 #ifdef DEBUG_SIM
rx_pwr = signal_energy_fp(r_re0,r_im0, rx_pwr = signal_energy_fp(r_re0,r_im0,
nb_antennas_rx, nb_antennas_rx,
length<length_meas?length:length_meas, length<length_meas?length:length_meas,
0)/(12.0*frame_parms->N_RB_DL); 0)/(12.0*frame_parms->N_RB_DL);
LOG_D(OCM,"[SIM][DL] UE %d : ADC in (RU %d) %f dBm/RE for subframe %d\n", LOG_D(OCM,"[SIM][DL] UE %d : ADC in (RU %d) %f dBm/RE for subframe %d\n",
UE_id,ru_id, UE_id,ru_id,
10*log10(rx_pwr),subframe); 10*log10(rx_pwr),subframe);
#endif #endif
pthread_mutex_lock(&RU_output_mutex[UE_id]); pthread_mutex_lock(&RU_output_mutex[UE_id]);
for (i=0; i<frame_parms->samples_per_tti; i++) { for (i=0; i<frame_parms->samples_per_tti; i++) {
for (aa=0; aa<nb_antennas_rx; aa++) { for (aa=0; aa<nb_antennas_rx; aa++) {
r_re_DL[UE_id][aa][i]+=r_re0[aa][i]; r_re_DL[UE_id][aa][i]+=r_re0[aa][i];
r_im_DL[UE_id][aa][i]+=r_im0[aa][i]; 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] |= (1<<ru_id);
RU_output_mask[UE_id]=0; if (RU_output_mask[UE_id] == (1<<RC.nb_RU)-1) {
RU_output_mask[UE_id]=0;
double *r_re_p[2] = {r_re_DL[ru_id][0],r_re_DL[ru_id][1]};
double *r_im_p[2] = {r_im_DL[ru_id][0],r_im_DL[ru_id][1]};
double *r_re_p[2] = {r_re_DL[ru_id][0],r_re_DL[ru_id][1]};
double *r_im_p[2] = {r_im_DL[ru_id][0],r_im_DL[ru_id][1]};
#ifdef DEBUG_SIM #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); 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);
LOG_D(OCM,"[SIM][DL] UE %d : ADC in %f dBm/RE for subframe %d\n",UE_id,10*log10(rx_pwr),subframe); LOG_D(OCM,"[SIM][DL] UE %d : ADC in %f dBm/RE for subframe %d\n",UE_id,10*log10(rx_pwr),subframe);
#endif #endif
rxdata = PHY_vars_UE_g[UE_id][CC_id]->common_vars.rxdata; rxdata = PHY_vars_UE_g[UE_id][CC_id]->common_vars.rxdata;
sf_offset = (subframe*frame_parms->samples_per_tti)+offset; sf_offset = (subframe*frame_parms->samples_per_tti)+offset;
adc(r_re_p, adc(r_re_p,
r_im_p, r_im_p,
0, 0,
sf_offset, sf_offset,
rxdata, rxdata,
nb_antennas_rx, nb_antennas_rx,
length, length,
12); 12);
#ifdef DEBUG_SIM #ifdef DEBUG_SIM
rx_pwr2 = signal_energy(rxdata[0]+sf_offset,length<length_meas?length:length_meas)/(12.0*frame_parms->N_RB_DL); rx_pwr2 = signal_energy(rxdata[0]+sf_offset,length<length_meas?length:length_meas)/(12.0*frame_parms->N_RB_DL);
LOG_D(OCM,"[SIM][DL] UE %d : rx_pwr (ADC out) %f dB/RE (%d) for subframe %d, writing to %p, length %d\n",UE_id, 10*log10((double)rx_pwr2),rx_pwr2,subframe,rxdata,length<length_meas?length:length_meas); LOG_D(OCM,"[SIM][DL] UE %d : rx_pwr (ADC out) %f dB/RE (%d) for subframe %d, writing to %p, length %d\n",UE_id, 10*log10((double)rx_pwr2),rx_pwr2,subframe,rxdata,length<length_meas?length:length_meas);
LOG_D(OCM,"[SIM][DL] UE %d : rx_pwr (ADC out) %f dB for subframe %d\n",UE_id,10*log10((double)rx_pwr2*12*frame_parms->N_RB_DL) ,subframe); LOG_D(OCM,"[SIM][DL] UE %d : rx_pwr (ADC out) %f dB for subframe %d\n",UE_id,10*log10((double)rx_pwr2*12*frame_parms->N_RB_DL) ,subframe);
#else #else
UNUSED_VARIABLE(rx_pwr2); UNUSED_VARIABLE(rx_pwr2);
UNUSED_VARIABLE(tx_pwr); UNUSED_VARIABLE(tx_pwr);
UNUSED_VARIABLE(rx_pwr); UNUSED_VARIABLE(rx_pwr);
#endif #endif
} // RU_output_mask } // RU_output_mask
pthread_mutex_unlock(&RU_output_mutex[UE_id]); pthread_mutex_unlock(&RU_output_mutex[UE_id]);
} // ru_id } // ru_id
}
} }
...@@ -418,14 +327,6 @@ void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM ...@@ -418,14 +327,6 @@ void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM
uint8_t hold_channel=0; uint8_t hold_channel=0;
#ifdef PHY_ABSTRACTION_UL
double min_path_loss=-200;
uint16_t ul_nb_rb=0 ;
uint16_t ul_fr_rb=0;
int ulnbrb2 ;
int ulfrrb2 ;
uint8_t harq_pid;
#endif
double s_re0[30720]; double s_re0[30720];
double s_re1[30720]; double s_re1[30720];
double *s_re[2]; double *s_re[2];
...@@ -449,148 +350,114 @@ void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM ...@@ -449,148 +350,114 @@ void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM
r_re0[1] = r_re01; r_re0[1] = r_re01;
r_im0[1] = r_im01; r_im0[1] = r_im01;
if (abstraction_flag!=0) {
#ifdef PHY_ABSTRACTION_UL
// wire this to 0 until we figure this out
int eNB_id=0;
for (UE_id=0; UE_id<NB_UE_INST; UE_id++) {
if (!hold_channel) {
random_channel(UE2RU[UE_id][eNB_id][CC_id],abstraction_flag);
freq_channel(UE2RU[UE_id][eNB_id][CC_id], frame_parms->N_RB_UL,frame_parms->N_RB_UL*12+1);
// REceived power at the eNB
rx_pwr = signal_energy_fp2(UE2RU[UE_id][eNB_id][CC_id]->ch[0],
UE2RU[UE_id][eNB_id][CC_id]->channel_length)*UE2RU[UE_id][att_eNB_id][CC_id]->channel_length; // calculate the rx power at the eNB
}
// write_output("SINRch.m","SINRch",PHY_vars_eNB_g[att_eNB_id]->sinr_dB_eNB,frame_parms->N_RB_UL*12+1,1,1);
if(subframe>1 && subframe <5) {
harq_pid = subframe2harq_pid(frame_parms,frame,subframe);
ul_nb_rb = RC.eNB[att_eNB_id][CC_id].ulsch_eNB[(uint8_t)UE_id]->harq_processes[harq_pid]->nb_rb;
ul_fr_rb = RC.eNB[att_eNB_id][CC_id].ulsch_eNB[(uint8_t)UE_id]->harq_processes[harq_pid]->first_rb;
}
if(ul_nb_rb>1 && (ul_fr_rb < 25 && ul_fr_rb > -1)) {
number_rb_ul = ul_nb_rb;
first_rbUL = ul_fr_rb;
init_snr_up(UE2RU[UE_id][att_eNB_id][CC_id],enb_data[att_eNB_id], ue_data[UE_id],PHY_vars_eNB_g[att_eNB_id][CC_id]->sinr_dB,&PHY_vars_UE_g[att_eNB_id][CC_id]->N0,ul_nb_rb,ul_fr_rb);
}
} //UE_id
#else
#endif pthread_mutex_lock(&UE_output_mutex[ru_id]);
} else { //without abstraction // Clear RX signal for eNB = eNB_id
for (i=0; i<frame_parms->samples_per_tti; i++) {
pthread_mutex_lock(&UE_output_mutex[ru_id]); for (aa=0; aa<nb_antennas_rx; aa++) {
// Clear RX signal for eNB = eNB_id r_re_UL[ru_id][aa][i]=0.0;
for (i=0; i<frame_parms->samples_per_tti; i++) { r_im_UL[ru_id][aa][i]=0.0;
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;
}
} }
pthread_mutex_unlock(&UE_output_mutex[ru_id]); }
pthread_mutex_unlock(&UE_output_mutex[ru_id]);
// Compute RX signal for eNB = eNB_id
for (UE_id=0; UE_id<NB_UE_INST; UE_id++) { // Compute RX signal for eNB = eNB_id
for (UE_id=0; UE_id<NB_UE_INST; UE_id++) {
txdata = PHY_vars_UE_g[UE_id][CC_id]->common_vars.txdata;
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) {
// don't simulate a UE that is too weak
LOG_D(OCM,"[SIM][UL] UE %d tx_pwr %d dBm (num_RE %d) for subframe %d (sf_offset %d)\n",
UE_id,
PHY_vars_UE_g[UE_id][CC_id]->tx_power_dBm[subframe],
PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe],
subframe,sf_offset);
} else {
tx_pwr = dac_fixed_gain((double**)s_re,
(double**)s_im,
txdata,
sf_offset,
nb_antennas_tx,
frame_parms->samples_per_tti,
sf_offset,
frame_parms->ofdm_symbol_size,
14,
(double)PHY_vars_UE_g[UE_id][CC_id]->tx_power_dBm[subframe]-10*log10((double)PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe]),
1,
NULL,
PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe]); // This make the previous argument the total power
LOG_D(OCM,"[SIM][UL] UE %d tx_pwr %f dBm (target %d dBm, num_RE %d) for subframe %d (sf_offset %d)\n",
UE_id,
10*log10(tx_pwr*PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe]),
PHY_vars_UE_g[UE_id][CC_id]->tx_power_dBm[subframe],
PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe],
subframe,sf_offset);
txdata = PHY_vars_UE_g[UE_id][CC_id]->common_vars.txdata;
AssertFatal(txdata != NULL,"txdata is null\n"); multipath_channel(UE2RU[UE_id][ru_id][CC_id],s_re,s_im,r_re0,r_im0,
sf_offset = subframe*frame_parms->samples_per_tti; frame_parms->samples_per_tti,hold_channel);
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) {
// don't simulate a UE that is too weak rx_pwr = signal_energy_fp2(UE2RU[UE_id][ru_id][CC_id]->ch[0],
LOG_D(OCM,"[SIM][UL] UE %d tx_pwr %d dBm (num_RE %d) for subframe %d (sf_offset %d)\n", UE2RU[UE_id][ru_id][CC_id]->channel_length)*UE2RU[UE_id][ru_id][CC_id]->channel_length;
UE_id,
PHY_vars_UE_g[UE_id][CC_id]->tx_power_dBm[subframe], 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),
PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe], hold_channel,UE2RU[UE_id][ru_id][CC_id]->channel_length,
subframe,sf_offset); UE2RU[UE_id][ru_id][CC_id]->path_loss_dB);
} else {
tx_pwr = dac_fixed_gain((double**)s_re, rx_pwr = signal_energy_fp(r_re0,r_im0,nb_antennas_rx,frame_parms->samples_per_tti,0);
(double**)s_im, 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",
txdata, 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);
sf_offset, /*
nb_antennas_tx, 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) {
frame_parms->samples_per_tti, write_output("txsig_re.m","s_re",s_re[0],frame_parms->samples_per_tti,1,7);
sf_offset, write_output("txsig_im.m","s_im",s_im[0],frame_parms->samples_per_tti,1,7);
frame_parms->ofdm_symbol_size, write_output("rxsig_re.m","r_re",r_re0[0],frame_parms->samples_per_tti,1,7);
14, write_output("rxsig_im.m","r_im",r_im0[0],frame_parms->samples_per_tti,1,7);
(double)PHY_vars_UE_g[UE_id][CC_id]->tx_power_dBm[subframe]-10*log10((double)PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe]), exit(-1);
1, }*/
NULL,
PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe]); // This make the previous argument the total power if (UE2RU[UE_id][ru_id][CC_id]->first_run == 1)
LOG_D(OCM,"[SIM][UL] UE %d tx_pwr %f dBm (target %d dBm, num_RE %d) for subframe %d (sf_offset %d)\n", UE2RU[UE_id][ru_id][CC_id]->first_run = 0;
UE_id,
10*log10(tx_pwr*PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe]),
PHY_vars_UE_g[UE_id][CC_id]->tx_power_dBm[subframe], pthread_mutex_lock(&UE_output_mutex[ru_id]);
PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe], for (aa=0; aa<nb_antennas_rx; aa++) {
subframe,sf_offset); 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];
multipath_channel(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;
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);
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);
/*
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);
write_output("txsig_im.m","s_im",s_im[0],frame_parms->samples_per_tti,1,7);
write_output("rxsig_re.m","r_re",r_re0[0],frame_parms->samples_per_tti,1,7);
write_output("rxsig_im.m","r_im",r_im0[0],frame_parms->samples_per_tti,1,7);
exit(-1);
}*/
if (UE2RU[UE_id][ru_id][CC_id]->first_run == 1)
UE2RU[UE_id][ru_id][CC_id]->first_run = 0;
pthread_mutex_lock(&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];
}
} }
pthread_mutex_unlock(&UE_output_mutex[ru_id]);
} }
} //UE_id pthread_mutex_unlock(&UE_output_mutex[ru_id]);
}
double *r_re_p[2] = {r_re_UL[ru_id][0],r_re_UL[ru_id][1]}; } //UE_id
double *r_im_p[2] = {r_im_UL[ru_id][0],r_im_UL[ru_id][1]};
double *r_re_p[2] = {r_re_UL[ru_id][0],r_re_UL[ru_id][1]};
rx_pwr = signal_energy_fp(r_re_p,r_im_p,nb_antennas_rx,frame_parms->samples_per_tti,0); double *r_im_p[2] = {r_im_UL[ru_id][0],r_im_UL[ru_id][1]};
LOG_D(OCM,"[SIM][UL] RU %d (%d/%d rx antennas) : rx_pwr %f dBm (before RF) for subframe %d, gain %f\n",
ru_id,nb_antennas_rx,nb_antennas_rx,10*log10(rx_pwr),subframe, rx_pwr = signal_energy_fp(r_re_p,r_im_p,nb_antennas_rx,frame_parms->samples_per_tti,0);
(double)RC.ru[ru_id]->max_rxgain-(double)RC.ru[ru_id]->att_rx - 66.227); LOG_D(OCM,"[SIM][UL] RU %d (%d/%d rx antennas) : rx_pwr %f dBm (before RF) for subframe %d, gain %f\n",
rf_rx_simple(r_re_p, ru_id,nb_antennas_rx,nb_antennas_rx,10*log10(rx_pwr),subframe,
r_im_p, (double)RC.ru[ru_id]->max_rxgain-(double)RC.ru[ru_id]->att_rx - 66.227);
rf_rx_simple(r_re_p,
r_im_p,
nb_antennas_rx, nb_antennas_rx,
frame_parms->samples_per_tti, frame_parms->samples_per_tti,
1e3/UE2RU[0][ru_id][CC_id]->sampling_rate, // sampling time (ns) 1e3/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) (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 #ifdef DEBUG_SIM
rx_pwr = signal_energy_fp(r_re_p,r_im_p,nb_antennas_rx,frame_parms->samples_per_tti,0);//*(double)frame_parms->ofdm_symbol_size/(12.0*frame_parms->N_RB_DL; rx_pwr = signal_energy_fp(r_re_p,r_im_p,nb_antennas_rx,frame_parms->samples_per_tti,0);//*(double)frame_parms->ofdm_symbol_size/(12.0*frame_parms->N_RB_DL;
LOG_D(OCM,"[SIM][UL] rx_pwr (ADC in) %f dB for subframe %d (rx_gain %f)\n",10*log10(rx_pwr),subframe, LOG_D(OCM,"[SIM][UL] rx_pwr (ADC in) %f dB for subframe %d (rx_gain %f)\n",10*log10(rx_pwr),subframe,
(double)RC.ru[ru_id]->max_rxgain-(double)RC.ru[ru_id]->att_rx); (double)RC.ru[ru_id]->max_rxgain-(double)RC.ru[ru_id]->att_rx);
#endif #endif
rxdata = RC.ru[ru_id]->common.rxdata; rxdata = RC.ru[ru_id]->common.rxdata;
sf_offset = subframe*frame_parms->samples_per_tti; sf_offset = subframe*frame_parms->samples_per_tti;
adc(r_re_p, adc(r_re_p,
r_im_p, r_im_p,
...@@ -610,10 +477,171 @@ void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM ...@@ -610,10 +477,171 @@ void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM
UNUSED_VARIABLE(rx_pwr2); UNUSED_VARIABLE(rx_pwr2);
#endif #endif
} // abstraction_flag==0
} }
void do_SL_sig(int UE_id,channel_desc_t *UE2UE[NUMBER_OF_UE_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs],
uint16_t subframe,LTE_DL_FRAME_PARMS *frame_parms,
uint32_t frame,uint8_t CC_id)
{
int32_t **txdata,**rxdata;
uint8_t nb_antennas_rx = UE2UE[0][0][CC_id]->nb_rx; // number of rx antennas at eNB
uint8_t nb_antennas_tx = UE2UE[0][0][CC_id]->nb_tx; // number of tx antennas at UE
double tx_pwr, rx_pwr;
int32_t rx_pwr2;
uint32_t i,aa;
uint32_t sf_offset;
uint8_t hold_channel=0;
double s_re0[30720];
double s_re1[30720];
double *s_re[2];
double s_im0[30720];
double s_im1[30720];
double *s_im[2];
double r_re00[30720];
double r_re01[30720];
double *r_re0[2];
double r_im00[30720];
double r_im01[30720];
double *r_im0[2];
s_re[0] = s_re0;
s_im[0] = s_im0;
s_re[1] = s_re1;
s_im[1] = s_im1;
r_re0[0] = r_re00;
r_im0[0] = r_im00;
r_re0[1] = r_re01;
r_im0[1] = r_im01;
// 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_SL[UE_id][aa][i]=0.0;
r_im_SL[UE_id][aa][i]=0.0;
}
}
txdata = PHY_vars_UE_g[UE_id][CC_id]->common_vars.txdata;
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] +
UE2UE[UE_id][0][CC_id]->path_loss_dB) <= -125.0) {
// don't simulate a UE that is too weak
LOG_D(OCM,"[SIM][UL] UE %d tx_pwr %d dBm (num_RE %d) for subframe %d (sf_offset %d)\n",
UE_id,
PHY_vars_UE_g[UE_id][CC_id]->tx_power_dBm[subframe],
PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe],
subframe,sf_offset);
} else {
tx_pwr = dac_fixed_gain((double**)s_re,
(double**)s_im,
txdata,
sf_offset,
nb_antennas_tx,
frame_parms->samples_per_tti,
sf_offset,
frame_parms->ofdm_symbol_size,
14,
(double)PHY_vars_UE_g[UE_id][CC_id]->tx_power_dBm[subframe]-10*log10((double)PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe]),
1,
NULL,
PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe]); // This make the previous argument the total power
LOG_D(OCM,"[SIM][UL] UE %d tx_pwr %f dBm (target %d dBm, num_RE %d) for subframe %d (sf_offset %d)\n",
UE_id,
10*log10(tx_pwr*PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe]),
PHY_vars_UE_g[UE_id][CC_id]->tx_power_dBm[subframe],
PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe],
subframe,sf_offset);
multipath_channel(UE2UE[UE_id][0][CC_id],s_re,s_im,r_re0,r_im0,
frame_parms->samples_per_tti,hold_channel);
rx_pwr = signal_energy_fp2(UE2UE[UE_id][0][CC_id]->ch[0],
UE2UE[UE_id][0][CC_id]->channel_length)*UE2UE[UE_id][0][CC_id]->channel_length;
LOG_D(OCM,"[SIM][UL] subframe %d Channel UE %d => UE %d : %f dB (hold %d,length %d, PL %f)\n",subframe,UE_id,0,10*log10(rx_pwr),
hold_channel,UE2UE[UE_id][0][CC_id]->channel_length,
UE2UE[UE_id][0][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] UE %d (%d/%d rx antennas) : rx_pwr %f dBm (tx_pwr - PL %f) for subframe %d, sptti %d\n",
UE_id,nb_antennas_rx,UE2UE[UE_id][0][CC_id]->nb_rx,10*log10(rx_pwr),10*log10(tx_pwr*PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe])+UE2UE[UE_id][0][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);
write_output("txsig_im.m","s_im",s_im[0],frame_parms->samples_per_tti,1,7);
write_output("rxsig_re.m","r_re",r_re0[0],frame_parms->samples_per_tti,1,7);
write_output("rxsig_im.m","r_im",r_im0[0],frame_parms->samples_per_tti,1,7);
exit(-1);
}*/
if (UE2UE[UE_id][0][CC_id]->first_run == 1)
UE2UE[UE_id][0][CC_id]->first_run = 0;
for (aa=0; aa<nb_antennas_rx; aa++) {
for (i=0; i<frame_parms->samples_per_tti; i++) {
r_re_SL[0][aa][i]+=r_re0[aa][i];
r_im_SL[0][aa][i]+=r_im0[aa][i];
}
}
}
double *r_re_p[2] = {r_re_SL[0][0],r_re_SL[0][1]};
double *r_im_p[2] = {r_im_SL[0][0],r_im_SL[0][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] UE %d (%d/%d rx antennas) : rx_pwr %f dBm (before RF) for subframe %d, gain %f\n",
UE_id,nb_antennas_rx,nb_antennas_rx,10*log10(rx_pwr),subframe,
PHY_vars_UE_g[UE_id][CC_id]->rx_total_gain_dB - 66.227);
rf_rx_simple(r_re_p,
r_im_p,
nb_antennas_rx,
frame_parms->samples_per_tti,
1e3/UE2UE[0][UE_id][CC_id]->sampling_rate, // sampling time (ns)
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
rx_pwr = signal_energy_fp(r_re_p,r_im_p,nb_antennas_rx,frame_parms->samples_per_tti,0);//*(double)frame_parms->ofdm_symbol_size/(12.0*frame_parms->N_RB_DL;
LOG_D(OCM,"[SIM][UL] rx_pwr (ADC in) %f dB for subframe %d (rx_gain %f)\n",10*log10(rx_pwr),subframe,
PHY_vars_UE_g[0][CC_id]->rx_total_gain_dB);
#endif
rxdata = PHY_vars_UE_g[0][CC_id]->common_vars.rxdata;
sf_offset = subframe*frame_parms->samples_per_tti;
adc(r_re_p,
r_im_p,
0,
sf_offset,
rxdata,
nb_antennas_rx,
frame_parms->samples_per_tti,
12);
#ifdef DEBUG_SIM
rx_pwr2 = signal_energy(rxdata[0]+sf_offset,frame_parms->samples_per_tti)*(double)frame_parms->ofdm_symbol_size/(12.0*frame_parms->N_RB_DL);
LOG_D(OCM,"[SIM][UL] UE %d rx_pwr (ADC out) %f dB (%d) for subframe %d (offset %d) = %p\n",UE_id,10*log10((double)rx_pwr2),rx_pwr2,subframe,sf_offset,rxdata[0]+sf_offset);
#else
UNUSED_VARIABLE(tx_pwr);
UNUSED_VARIABLE(rx_pwr);
UNUSED_VARIABLE(rx_pwr2);
#endif
}
void init_channel_vars(LTE_DL_FRAME_PARMS *frame_parms, double ***s_re,double ***s_im,double ***r_re,double ***r_im,double ***r_re0,double ***r_im0) void init_channel_vars(LTE_DL_FRAME_PARMS *frame_parms, double ***s_re,double ***s_im,double ***r_re,double ***r_im,double ***r_re0,double ***r_im0)
{ {
......
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