From 2c837750879c96a1abf7bd25a0c1b78410cf06e7 Mon Sep 17 00:00:00 2001 From: Guy De Souza <desouza@eurecom.fr> Date: Wed, 21 Mar 2018 15:08:01 +0100 Subject: [PATCH] Fix CMakeLists.txt for lte-uesoftmodem --- cmake_targets/CMakeLists.txt | 49 +++---- .../PHY/LTE_ESTIMATION/lte_adjust_sync_ue.c | 136 ++++++++++++++++++ openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c | 9 ++ targets/RT/USER/lte-softmodem.h | 2 +- targets/RT/USER/lte-uesoftmodem.c | 1 + 5 files changed, 167 insertions(+), 30 deletions(-) create mode 100644 openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_ue.c diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 31e001b9a6..e5f4730fe6 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1145,35 +1145,26 @@ set(PHY_SRC_UE # depend on code generation from asn1c ${RRC_FULL_DIR}/asn1_constants.h # actual source - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pss.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/sss.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pilots.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pilots_mbsfn.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_coding.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_modulation.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/power_control.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_scrambling.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dci_tools.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/uci_tools.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/lte_mcs.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pbch.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dci.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/edci.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/phich.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pcfich.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pucch.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/prach.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pmch.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pch.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/group_hopping.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/srs_modulation.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/ulsch_demodulation.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/ulsch_decoding.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/rar_tools.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/print_stats.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/initial_sync.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/if4_tools.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/if5_tools.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pss.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/sss.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pilots.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pilots_mbsfn.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_coding.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_modulation.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/power_control.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_scrambling.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/uci_tools.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/lte_mcs.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/edci.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pucch.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/prach.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/group_hopping.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/srs_modulation.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/rar_tools.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/print_stats.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/initial_sync.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/if4_tools.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/if5_tools.c ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dci_ue.c ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c diff --git a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_ue.c b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_ue.c new file mode 100644 index 0000000000..1105f83597 --- /dev/null +++ b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_ue.c @@ -0,0 +1,136 @@ +/* + * 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 + */ + +#include "PHY/types.h" +#include "PHY/defs.h" +#include "PHY/extern.h" + +#include "UTIL/LOG/vcd_signal_dumper.h" + +#define DEBUG_PHY + +// Adjust location synchronization point to account for drift +// The adjustment is performed once per frame based on the +// last channel estimate of the receiver + +void lte_adjust_synch(LTE_DL_FRAME_PARMS *frame_parms, + PHY_VARS_UE *ue, + unsigned char eNB_id, + uint8_t subframe, + unsigned char clear, + short coef) +{ + + static int max_pos_fil = 0; + static int count_max_pos_ok = 0; + static int first_time = 1; + int temp = 0, i, aa, max_val = 0, max_pos = 0; + int diff; + short Re,Im,ncoef; + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_ADJUST_SYNCH, VCD_FUNCTION_IN); + + ncoef = 32767 - coef; + +#ifdef DEBUG_PHY + LOG_D(PHY,"AbsSubframe %d.%d: rx_offset (before) = %d\n",ue->proc.proc_rxtx[0].frame_rx%1024,subframe,ue->rx_offset); +#endif //DEBUG_PHY + + + // we only use channel estimates from tx antenna 0 here + for (i = 0; i < frame_parms->nb_prefix_samples; i++) { + temp = 0; + + for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) { + Re = ((int16_t*)ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates_time[eNB_id][aa])[(i<<2)]; + Im = ((int16_t*)ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates_time[eNB_id][aa])[1+(i<<2)]; + temp += (Re*Re/2) + (Im*Im/2); + } + + if (temp > max_val) { + max_pos = i; + max_val = temp; + } + } + + // filter position to reduce jitter + if (clear == 1) + max_pos_fil = max_pos; + else + max_pos_fil = ((max_pos_fil * coef) + (max_pos * ncoef)) >> 15; + + // do not filter to have proactive timing adjustment + max_pos_fil = max_pos; + + if(subframe == 6) + { + diff = max_pos_fil - (frame_parms->nb_prefix_samples>>3); + + if ( abs(diff) < SYNCH_HYST ) + ue->rx_offset = 0; + else + ue->rx_offset = diff; + + if(abs(diff)<5) + count_max_pos_ok ++; + else + count_max_pos_ok = 0; + + if(count_max_pos_ok > 10 && first_time == 1) + { + first_time = 0; + ue->time_sync_cell = 1; + if (ue->mac_enabled==1) { + LOG_I(PHY,"[UE%d] Sending synch status to higher layers\n",ue->Mod_id); + //mac_resynch(); + dl_phy_sync_success(ue->Mod_id,ue->proc.proc_rxtx[0].frame_rx,0,1);//ue->common_vars.eNb_id); + ue->UE_mode[0] = PRACH; + } + else { + ue->UE_mode[0] = PUSCH; + } + } + + if ( ue->rx_offset < 0 ) + ue->rx_offset += FRAME_LENGTH_COMPLEX_SAMPLES; + + if ( ue->rx_offset >= FRAME_LENGTH_COMPLEX_SAMPLES ) + ue->rx_offset -= FRAME_LENGTH_COMPLEX_SAMPLES; + + + + #ifdef DEBUG_PHY + LOG_D(PHY,"AbsSubframe %d.%d: ThreadId %d diff =%i rx_offset (final) = %i : clear %d,max_pos = %d,max_pos_fil = %d (peak %d) max_val %d target_pos %d \n", + ue->proc.proc_rxtx[ue->current_thread_id[subframe]].frame_rx, + subframe, + ue->current_thread_id[subframe], + diff, + ue->rx_offset, + clear, + max_pos, + max_pos_fil, + temp,max_val, + (frame_parms->nb_prefix_samples>>3)); + #endif //DEBUG_PHY + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_ADJUST_SYNCH, VCD_FUNCTION_OUT); + } +} diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c index 70b5f735ff..b496f69a06 100755 --- a/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c @@ -52,6 +52,15 @@ //extern uint16_t phich_reg[MAX_NUM_PHICH_GROUPS][3]; //extern uint16_t pcfich_reg[4]; +#define CCEBITS 72 +#define CCEPERSYMBOL 33 // This is for 1200 RE +#define CCEPERSYMBOL0 22 // This is for 1200 RE +#define DCI_BITS_MAX ((2*CCEPERSYMBOL+CCEPERSYMBOL0)*CCEBITS) +#define Msymb (DCI_BITS_MAX/2) +//#define Mquad (Msymb/4) + +static uint32_t bitrev_cc_dci[32] = {1,17,9,25,5,21,13,29,3,19,11,27,7,23,15,31,0,16,8,24,4,20,12,28,2,18,10,26,6,22,14,30}; + uint32_t check_phich_reg(LTE_DL_FRAME_PARMS *frame_parms,uint32_t kprime,uint8_t lprime,uint8_t mi) { diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 4b77613892..89e9fb025b 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -134,7 +134,7 @@ } #define DEFAULT_DLF 2680000000 -//extern int16_t dlsch_demod_shift; + /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /* command line parameters common to eNodeB and UE */ /* optname helpstr paramflags XXXptr defXXXval type numelt */ diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index ae4798f399..538c74e157 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -455,6 +455,7 @@ void *l2l1_task(void *arg) { } #endif +extern int16_t dlsch_demod_shift; static void get_options(void) { int CC_id; -- GitLab