From 6742d6f47184eb49659fba352e75ef47a2845f4c Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Mon, 4 Jun 2018 16:09:10 +0200 Subject: [PATCH 1/3] Encapsulated lte_gold_generic functionality --- cmake_targets/CMakeLists.txt | 1 + openair1/PHY/LTE_REFSIG/lte_gold.c | 40 +------------------ openair1/PHY/LTE_REFSIG/lte_refsig.h | 5 +-- openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c | 40 +++---------------- openair1/PHY/defs_common.h | 2 - 5 files changed, 11 insertions(+), 77 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index d112660f18..10027bd4e7 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1093,6 +1093,7 @@ set(PHY_SRC_COMMON ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/prach_common.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pucch_common.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_scrambling.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/lte_gold_generic.c ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/srs_modulation.c ${OPENAIR1_DIR}/PHY/MODULATION/ofdm_mod.c ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_sync_time.c diff --git a/openair1/PHY/LTE_REFSIG/lte_gold.c b/openair1/PHY/LTE_REFSIG/lte_gold.c index 78fae8b8f3..c5e48d8364 100644 --- a/openair1/PHY/LTE_REFSIG/lte_gold.c +++ b/openair1/PHY/LTE_REFSIG/lte_gold.c @@ -44,7 +44,6 @@ N_{ID}^{cell = 0..503 void lte_gold(LTE_DL_FRAME_PARMS *frame_parms,uint32_t lte_gold_table[20][2][14],uint16_t Nid_cell) { - unsigned char ns,l,Ncp=1-frame_parms->Ncp; unsigned int n,x1,x2;//,x1tmp,x2tmp; @@ -54,7 +53,7 @@ void lte_gold(LTE_DL_FRAME_PARMS *frame_parms,uint32_t lte_gold_table[20][2][14] x2 = Ncp + (Nid_cell<<1) + - (((1+(Nid_cell<<1))*(1 + (((frame_parms->Ncp==0)?4:3)*l) + (7*(1+ns))))<<10); //cinit + (((1+(Nid_cell<<1))*(1 + (((frame_parms->Ncp==0)?4:3)*l) + (7*(1+ns))))<<10); //cinit //x2 = frame_parms->Ncp + (Nid_cell<<1) + (1+(Nid_cell<<1))*(1 + (3*l) + (7*(1+ns))); //cinit //n = 0 x1 = 1+ (1<<31); @@ -81,7 +80,7 @@ void lte_gold(LTE_DL_FRAME_PARMS *frame_parms,uint32_t lte_gold_table[20][2][14] } } -void lte_gold_ue_spec(LTE_DL_FRAME_PARMS *frame_parms,uint32_t lte_gold_uespec_table[2][20][2][21],uint16_t Nid_cell, uint16_t *n_idDMRS) +void lte_gold_ue_spec(uint32_t lte_gold_uespec_table[2][20][2][21],uint16_t Nid_cell, uint16_t *n_idDMRS) { unsigned char ns,l; @@ -169,41 +168,6 @@ void lte_gold_ue_spec_port5(uint32_t lte_gold_uespec_port5_table[20][38],uint16_ } } -/*! \brief gold sequenquence generator -\param x1 -\param x2 this should be set to c_init if reset=1 -\param reset resets the generator -\return 32 bits of the gold sequence -*/ -unsigned int lte_gold_generic(unsigned int *x1, unsigned int *x2, unsigned char reset) -{ - int n; - - if (reset) { - *x1 = 1+ (1<<31); - *x2=*x2 ^ ((*x2 ^ (*x2>>1) ^ (*x2>>2) ^ (*x2>>3))<<31); - - // skip first 50 double words (1600 bits) - // printf("n=0 : x1 %x, x2 %x\n",x1,x2); - for (n=1; n<50; n++) { - *x1 = (*x1>>1) ^ (*x1>>4); - *x1 = *x1 ^ (*x1<<31) ^ (*x1<<28); - *x2 = (*x2>>1) ^ (*x2>>2) ^ (*x2>>3) ^ (*x2>>4); - *x2 = *x2 ^ (*x2<<31) ^ (*x2<<30) ^ (*x2<<29) ^ (*x2<<28); - } - } - - *x1 = (*x1>>1) ^ (*x1>>4); - *x1 = *x1 ^ (*x1<<31) ^ (*x1<<28); - *x2 = (*x2>>1) ^ (*x2>>2) ^ (*x2>>3) ^ (*x2>>4); - *x2 = *x2 ^ (*x2<<31) ^ (*x2<<30) ^ (*x2<<29) ^ (*x2<<28); - return(*x1^*x2); - // printf("n=%d : c %x\n",n,x1^x2); - -} - - - #ifdef LTE_GOLD_MAIN main() { diff --git a/openair1/PHY/LTE_REFSIG/lte_refsig.h b/openair1/PHY/LTE_REFSIG/lte_refsig.h index 27788e5e1a..1bac0d14fc 100644 --- a/openair1/PHY/LTE_REFSIG/lte_refsig.h +++ b/openair1/PHY/LTE_REFSIG/lte_refsig.h @@ -36,7 +36,7 @@ \param reset resets the generator \return 32 bits of the gold sequence */ -unsigned int lte_gold_generic(unsigned int *x1, unsigned int *x2, unsigned char reset); +uint32_t lte_gold_generic(uint32_t *x1, uint32_t *x2, uint8_t reset); /*!\brief This function generates the LTE Gold sequence (36-211, Sec 7.2), specifically for DL reference signals. @@ -45,8 +45,7 @@ unsigned int lte_gold_generic(unsigned int *x1, unsigned int *x2, unsigned char @param Nid_cell Cell Id (to compute sequences for local and adjacent cells) */ void lte_gold(LTE_DL_FRAME_PARMS *frame_parms,uint32_t lte_gold_table[20][2][14],uint16_t Nid_cell); - -void lte_gold_ue_spec(LTE_DL_FRAME_PARMS *frame_parms,uint32_t lte_gold_uespec_table[2][20][2][21],uint16_t Nid_cell, uint16_t *n_idDMRS); +void lte_gold_ue_spec(uint32_t lte_gold_uespec_table[2][20][2][21],uint16_t Nid_cell, uint16_t *n_idDMRS); void lte_gold_ue_spec_port5(uint32_t lte_gold_uespec_port5_table[20][38],uint16_t Nid_cell, uint16_t n_rnti); diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c b/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c index c1f80c40a4..09531deebb 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c @@ -40,41 +40,13 @@ #include "PHY/phy_extern.h" #include "UTIL/LOG/vcd_signal_dumper.h" -static inline unsigned int lte_gold_scram(unsigned int *x1, unsigned int *x2, unsigned char reset) __attribute__((always_inline)); -static inline unsigned int lte_gold_scram(unsigned int *x1, unsigned int *x2, unsigned char reset) -{ - int n; - - if (reset) { - *x1 = 1+ (1<<31); - *x2=*x2 ^ ((*x2 ^ (*x2>>1) ^ (*x2>>2) ^ (*x2>>3))<<31); - - // skip first 50 double words (1600 bits) - // printf("n=0 : x1 %x, x2 %x\n",x1,x2); - for (n=1; n<50; n++) { - *x1 = (*x1>>1) ^ (*x1>>4); - *x1 = *x1 ^ (*x1<<31) ^ (*x1<<28); - *x2 = (*x2>>1) ^ (*x2>>2) ^ (*x2>>3) ^ (*x2>>4); - *x2 = *x2 ^ (*x2<<31) ^ (*x2<<30) ^ (*x2<<29) ^ (*x2<<28); - } - } - - *x1 = (*x1>>1) ^ (*x1>>4); - *x1 = *x1 ^ (*x1<<31) ^ (*x1<<28); - *x2 = (*x2>>1) ^ (*x2>>2) ^ (*x2>>3) ^ (*x2>>4); - *x2 = *x2 ^ (*x2<<31) ^ (*x2<<30) ^ (*x2<<29) ^ (*x2<<28); - return(*x1^*x2); - // printf("n=%d : c %x\n",n,x1^x2); - -} - void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, int mbsfn_flag, LTE_eNB_DLSCH_t *dlsch, - int harq_pid, + int harq_pid, int G, uint8_t q, - uint16_t frame, + uint16_t frame, uint8_t Ns) { @@ -130,7 +102,7 @@ void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, printf("scrambling: rnti %x, q %d, Ns %d, Nid_cell %d, G %d x2 %x\n",dlsch->rnti,q,Ns,frame_parms->Nid_cell, G, x2); #endif #endif - s = lte_gold_scram(&x1, &x2, 1); + s = lte_gold_generic(&x1, &x2, 1); for (n=0; n<(1+(G>>5)); n++) { @@ -179,7 +151,7 @@ void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, - s = lte_gold_scram(&x1, &x2, 0); + s = lte_gold_generic(&x1, &x2, 0); e += 32; } @@ -225,7 +197,7 @@ void dlsch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, #ifdef DEBUG_SCRAMBLING printf("unscrambling: rnti %x, q %d, Ns %d, Nid_cell %d G %d, x2 %x\n",dlsch->rnti,q,Ns,frame_parms->Nid_cell,G,x2); #endif - s = lte_gold_scram(&x1, &x2, 1); + s = lte_gold_generic(&x1, &x2, 1); for (i=0; i<(1+(G>>5)); i++) { for (j=0; j<32; j++,k++) { @@ -238,7 +210,7 @@ void dlsch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, #endif } - s = lte_gold_scram(&x1, &x2, 0); + s = lte_gold_generic(&x1, &x2, 0); } } diff --git a/openair1/PHY/defs_common.h b/openair1/PHY/defs_common.h index c253488a20..94120d6892 100644 --- a/openair1/PHY/defs_common.h +++ b/openair1/PHY/defs_common.h @@ -72,13 +72,11 @@ #include -#include "targets/ARCH/COMMON/common_lib.h" #include "targets/COMMON/openairinterface5g_limits.h" #include "types.h" #include "nfapi_interface.h" //#include "defs.h" -#include "openair2/COMMON/platform_types.h" #define RX_NB_TH_MAX 2 #define RX_NB_TH 2 From ee91f661fb0aa91fb5be288a8e8b2f7c256c1f40 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Mon, 4 Jun 2018 16:27:17 +0200 Subject: [PATCH 2/3] Added missing file lte_gold_generic.c --- openair1/PHY/LTE_TRANSPORT/lte_gold_generic.c | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 openair1/PHY/LTE_TRANSPORT/lte_gold_generic.c diff --git a/openair1/PHY/LTE_TRANSPORT/lte_gold_generic.c b/openair1/PHY/LTE_TRANSPORT/lte_gold_generic.c new file mode 100644 index 0000000000..b249052cbf --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/lte_gold_generic.c @@ -0,0 +1,75 @@ +/* + * 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" + +/** + \brief Gold Sequence Generation defined in 3x.211 + \param x1 x1 shift register + \param x2 x2 shift register / cinit if reset is set + \param reset Reset flag / reinitialize the generator + \return c 32 bits of gold output +*/ +extern inline uint32_t lte_gold_generic(uint32_t *x1, uint32_t *x2, uint8_t reset) +{ + int32_t n; + + // 3GPP 3x.211 + // Nc = 1600 + // c(n) = [x1(n+Nc) + x2(n+Nc)]mod2 + // x1(n+31) = [x1(n+3) + x1(n)]mod2 + // x2(n+31) = [x2(n+3) + x2(n+2) + x2(n+1) + x2(n)]mod2 + if (reset) + { + // Init value for x1: x1(0) = 1, x1(n) = 0, n=1,2,...,30 + // x1(31) = [x1(3) + x1(0)]mod2 = 1 + *x1 = 1 + (1<<31); + // Init value for x2: cinit = sum_{i=0}^30 x2*2^i + // x2(31) = [x2(3) + x2(2) + x2(1) + x2(0)]mod2 + // = (*x2>>3) ^ (*x2>>2) + (*x2>>1) + *x2 + *x2 = *x2 ^ ((*x2 ^ (*x2>>1) ^ (*x2>>2) ^ (*x2>>3))<<31); + + // x1 and x2 contain bits n = 0,1,...,31 + + // Nc = 1600 bits are skipped at the beginning + // i.e., 1600 / 32 = 50 32bit words + + for (n = 1; n < 50; n++) + { + // Compute x1(0),...,x1(27) + *x1 = (*x1>>1) ^ (*x1>>4); + // Compute x1(28),..,x1(31) and xor + *x1 = *x1 ^ (*x1<<31) ^ (*x1<<28); + // Compute x2(0),...,x2(27) + *x2 = (*x2>>1) ^ (*x2>>2) ^ (*x2>>3) ^ (*x2>>4); + // Compute x2(28),..,x2(31) and xor + *x2 = *x2 ^ (*x2<<31) ^ (*x2<<30) ^ (*x2<<29) ^ (*x2<<28); + } + } + + *x1 = (*x1>>1) ^ (*x1>>4); + *x1 = *x1 ^ (*x1<<31) ^ (*x1<<28); + *x2 = (*x2>>1) ^ (*x2>>2) ^ (*x2>>3) ^ (*x2>>4); + *x2 = *x2 ^ (*x2<<31) ^ (*x2<<30) ^ (*x2<<29) ^ (*x2<<28); + + // c(n) = [x1(n+Nc) + x2(n+Nc)]mod2 + return(*x1^*x2); +} From 432ad112c53dbb9d0d93a99f201402eff331a8e1 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Mon, 4 Jun 2018 07:45:28 -0700 Subject: [PATCH 3/3] fixing implicit declaration warning --- openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c | 1 + 1 file changed, 1 insertion(+) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c b/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c index 09531deebb..43c6700aac 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c @@ -34,6 +34,7 @@ #include "PHY/defs_eNB.h" #include "PHY/defs_UE.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" #include "PHY/CODING/coding_extern.h" #include "PHY/CODING/lte_interleaver_inline.h" #include "transport_eNB.h"