Merging latest develop commits
This commit is contained in:
@@ -34,7 +34,10 @@
|
||||
#include "LAYER2/MAC/mac.h"
|
||||
#include "RRC/LTE/rrc_extern.h"
|
||||
#include "PHY_INTERFACE/phy_interface.h"
|
||||
#include "PHY/LTE_REFSIG/lte_refsig.h"
|
||||
|
||||
// Note: this is for prototype of generate_drs_pusch (OTA synchronization of RRUs)
|
||||
#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h"
|
||||
|
||||
int* sync_corr_ue0 = NULL;
|
||||
int* sync_corr_ue1 = NULL;
|
||||
@@ -338,7 +341,6 @@ int lte_sync_time(int **rxdata, ///rx data in time domain
|
||||
{
|
||||
|
||||
|
||||
|
||||
// perform a time domain correlation using the oversampled sync sequence
|
||||
|
||||
unsigned int n, ar, s, peak_pos, peak_val, sync_source;
|
||||
@@ -348,20 +350,12 @@ int lte_sync_time(int **rxdata, ///rx data in time domain
|
||||
int length = LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti>>1;
|
||||
|
||||
//LOG_D(PHY,"[SYNC TIME] Calling sync_time.\n");
|
||||
if (sync_corr_ue0 == NULL) {
|
||||
LOG_E(PHY,"[SYNC TIME] sync_corr_ue0 not yet allocated! Exiting.\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if (sync_corr_ue1 == NULL) {
|
||||
LOG_E(PHY,"[SYNC TIME] sync_corr_ue1 not yet allocated! Exiting.\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if (sync_corr_ue2 == NULL) {
|
||||
LOG_E(PHY,"[SYNC TIME] sync_corr_ue2 not yet allocated! Exiting.\n");
|
||||
return(-1);
|
||||
}
|
||||
AssertFatal(sync_corr_ue0 != NULL,
|
||||
"sync_corr_ue0 not yet allocated! Exiting.\n");
|
||||
AssertFatal(sync_corr_ue1 != NULL,
|
||||
"sync_corr_ue0 not yet allocated! Exiting.\n");
|
||||
AssertFatal(sync_corr_ue2 != NULL,
|
||||
"sync_corr_ue0 not yet allocated! Exiting.\n");
|
||||
|
||||
peak_val = 0;
|
||||
peak_pos = 0;
|
||||
@@ -478,6 +472,79 @@ int lte_sync_time(int **rxdata, ///rx data in time domain
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ru_sync_time_init(RU_t *ru) // LTE_UE_COMMON *common_vars
|
||||
{
|
||||
|
||||
/*
|
||||
int16_t dmrs[2048];
|
||||
int16_t *dmrsp[2] = {dmrs,NULL};
|
||||
*/
|
||||
|
||||
int32_t dmrs[ru->frame_parms.ofdm_symbol_size*14] __attribute__((aligned(32)));
|
||||
// int32_t *dmrsp[2] = {&dmrs[(3-ru->frame_parms.Ncp)*ru->frame_parms.ofdm_symbol_size],NULL};
|
||||
int32_t *dmrsp[2] = {&dmrs[0],NULL};
|
||||
|
||||
generate_ul_ref_sigs();
|
||||
|
||||
ru->dmrssync = (int16_t*)malloc16_clear(ru->frame_parms.ofdm_symbol_size*2*sizeof(int16_t));
|
||||
ru->dmrs_corr = (uint64_t*)malloc16_clear(ru->frame_parms.samples_per_tti*10*sizeof(uint64_t));
|
||||
|
||||
generate_drs_pusch(NULL,NULL,
|
||||
&ru->frame_parms,
|
||||
dmrsp,
|
||||
0,
|
||||
AMP,
|
||||
0,
|
||||
0,
|
||||
ru->frame_parms.N_RB_DL,
|
||||
0);
|
||||
|
||||
switch (ru->frame_parms.N_RB_DL) {
|
||||
case 6:
|
||||
idft128((int16_t*)(&dmrsp[0][3*ru->frame_parms.ofdm_symbol_size]),
|
||||
ru->dmrssync, /// complex output
|
||||
1);
|
||||
break;
|
||||
case 25:
|
||||
idft512((int16_t*)(&dmrsp[0][3*ru->frame_parms.ofdm_symbol_size]),
|
||||
ru->dmrssync, /// complex output
|
||||
1);
|
||||
break;
|
||||
case 50:
|
||||
idft1024((int16_t*)(&dmrsp[0][3*ru->frame_parms.ofdm_symbol_size]),
|
||||
ru->dmrssync, /// complex output
|
||||
1);
|
||||
break;
|
||||
|
||||
case 75:
|
||||
idft1536((int16_t*)(&dmrsp[0][3*ru->frame_parms.ofdm_symbol_size]),
|
||||
ru->dmrssync,
|
||||
1); /// complex output
|
||||
break;
|
||||
case 100:
|
||||
idft2048((int16_t*)(&dmrsp[0][3*ru->frame_parms.ofdm_symbol_size]),
|
||||
ru->dmrssync, /// complex output
|
||||
1);
|
||||
break;
|
||||
default:
|
||||
AssertFatal(1==0,"Unsupported N_RB_DL %d\n",ru->frame_parms.N_RB_DL);
|
||||
break;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
void ru_sync_time_free(RU_t *ru) {
|
||||
|
||||
AssertFatal(ru->dmrssync!=NULL,"ru->dmrssync is NULL\n");
|
||||
free(ru->dmrssync);
|
||||
if (ru->dmrs_corr) free(ru->dmrs_corr);
|
||||
}
|
||||
|
||||
//#define DEBUG_PHY
|
||||
|
||||
int lte_sync_time_eNB(int32_t **rxdata, ///rx data in time domain
|
||||
LTE_DL_FRAME_PARMS *frame_parms,
|
||||
uint32_t length,
|
||||
@@ -558,40 +625,96 @@ int lte_sync_time_eNB(int32_t **rxdata, ///rx data in time domain
|
||||
*peak_val_out = peak_val;
|
||||
|
||||
if (peak_val <= (40*(uint32_t)mean_val)) {
|
||||
LOG_D(PHY,"[SYNC TIME] No peak found (%u,%u,%"PRIu64",%"PRIu64")\n",peak_pos,peak_val,mean_val,40*mean_val);
|
||||
LOG_I(PHY,"[SYNC TIME] No peak found (%u,%u,%"PRIu64",%"PRIu64")\n",peak_pos,peak_val,mean_val,40*mean_val);
|
||||
return(-1);
|
||||
} else {
|
||||
LOG_D(PHY,"[SYNC TIME] Peak found at pos %u, val = %u, mean_val = %"PRIu64"\n",peak_pos,peak_val,mean_val);
|
||||
LOG_I(PHY,"[SYNC TIME] Peak found at pos %u, val = %u, mean_val = %"PRIu64"\n",peak_pos,peak_val,mean_val);
|
||||
return(peak_pos);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef PHY_ABSTRACTION
|
||||
#include "SIMULATION/TOOLS/defs.h"
|
||||
#include "SIMULATION/RF/defs.h"
|
||||
//extern channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX];
|
||||
|
||||
int lte_sync_time_eNB_emul(PHY_VARS_eNB *phy_vars_eNB,
|
||||
uint8_t sect_id,
|
||||
int32_t *sync_val)
|
||||
static inline int64_t abs64(int64_t x)
|
||||
{
|
||||
return (((int64_t)((int32_t*)&x)[0])*((int64_t)((int32_t*)&x)[0]) + ((int64_t)
|
||||
((int32_t*)&x)[1])*((int64_t)((int32_t*)&x)[1]));
|
||||
}
|
||||
|
||||
uint8_t UE_id;
|
||||
uint8_t CC_id = phy_vars_eNB->CC_id;
|
||||
int ru_sync_time(RU_t *ru,
|
||||
int64_t *lev,
|
||||
int64_t *avg)
|
||||
{
|
||||
LTE_DL_FRAME_PARMS *frame_parms = &ru->frame_parms;
|
||||
RU_CALIBRATION *calibration = &ru->calibration;
|
||||
|
||||
// perform a time domain correlation using the oversampled sync sequence
|
||||
|
||||
LOG_E(PHY,"[PHY] EMUL lte_sync_time_eNB_emul eNB %d, sect_id %d\n",phy_vars_eNB->Mod_id,sect_id);
|
||||
*sync_val = 0;
|
||||
int length = LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti;
|
||||
|
||||
|
||||
for (UE_id=0; UE_id<NB_UE_INST; UE_id++) {
|
||||
//LOG_E(PHY,"[PHY] EMUL : eNB %d checking UE %d (PRACH %d) PL %d dB\n",phy_vars_eNB->Mod_id,UE_id,PHY_vars_UE_g[UE_id]->generate_prach,UE2eNB[UE_id][phy_vars_eNB->Mod_id]->path_loss_dB);
|
||||
if ((PHY_vars_UE_g[UE_id][CC_id]->generate_prach == 1) && (phy_vars_eNB->Mod_id == (UE_id % NB_eNB_INST))) {
|
||||
*sync_val = 1;
|
||||
return(0);
|
||||
}
|
||||
// circular copy of beginning to end of rxdata buffer. Note: buffer should be big enough upon calling this function
|
||||
for (int ar=0;ar<ru->nb_rx;ar++) memcpy((void*)&ru->common.rxdata[ar][2*length],
|
||||
(void*)&ru->common.rxdata[ar][0],
|
||||
frame_parms->ofdm_symbol_size);
|
||||
|
||||
int32_t maxlev0=0;
|
||||
int maxpos0=0;
|
||||
int64_t avg0=0;
|
||||
int64_t result;
|
||||
int64_t dmrs_corr;
|
||||
|
||||
int maxval=0;
|
||||
for (int i=0;i<2*(frame_parms->ofdm_symbol_size);i++) {
|
||||
maxval = max(maxval,ru->dmrssync[i]);
|
||||
maxval = max(maxval,-ru->dmrssync[i]);
|
||||
}
|
||||
|
||||
if (ru->state == RU_CHECK_SYNC) {
|
||||
for (int i=0;i<2*(frame_parms->ofdm_symbol_size);i++) {
|
||||
maxval = max(maxval,calibration->drs_ch_estimates_time[0][i]);
|
||||
maxval = max(maxval,-calibration->drs_ch_estimates_time[0][i]);
|
||||
}
|
||||
}
|
||||
|
||||
int shift = log2_approx(maxval);
|
||||
|
||||
for (int n=0; n<length; n+=4) {
|
||||
|
||||
dmrs_corr = 0;
|
||||
|
||||
//calculate dot product of primary_synch0_time and rxdata[ar][n] (ar=0..nb_ant_rx) and store the sum in temp[n];
|
||||
for (int ar=0; ar<ru->nb_rx; ar++) {
|
||||
|
||||
result = dot_product64(ru->dmrssync,
|
||||
(int16_t*) &ru->common.rxdata[ar][n],
|
||||
frame_parms->ofdm_symbol_size,
|
||||
shift);
|
||||
|
||||
if (ru->state == RU_CHECK_SYNC) {
|
||||
result = dot_product64((int16_t*) &calibration->drs_ch_estimates_time[ar],
|
||||
(int16_t*) &ru->common.rxdata[ar][n],
|
||||
frame_parms->ofdm_symbol_size,
|
||||
shift);
|
||||
}
|
||||
dmrs_corr += abs64(result);
|
||||
}
|
||||
if (ru->dmrs_corr != NULL) ru->dmrs_corr[n] = dmrs_corr;
|
||||
|
||||
// tmpi holds <synchi,rx0>+<synci,rx1>+...+<synchi,rx_{nbrx-1}>
|
||||
|
||||
|
||||
if (dmrs_corr>maxlev0) { maxlev0 = dmrs_corr; maxpos0 = n; }
|
||||
avg0 += dmrs_corr;
|
||||
}
|
||||
avg0/=(length/4);
|
||||
|
||||
int dmrsoffset = frame_parms->samples_per_tti + (3*frame_parms->ofdm_symbol_size)+(3*frame_parms->nb_prefix_samples) + frame_parms->nb_prefix_samples0;
|
||||
|
||||
if ((int64_t)maxlev0 > (10*avg0)) {*lev = maxlev0; *avg=avg0; return((length+maxpos0-dmrsoffset)%length);}
|
||||
|
||||
return(-1);
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user