From f94dad6893d43bfb387ab290a1643fffc0b57b50 Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 24 Mar 2026 16:49:50 +0100 Subject: [PATCH] rename and take out gold generic function from lte files to specific file to avoid cross-compilation --- openair1/PHY/LTE_REFSIG/defs_NB_IoT.h | 4 -- openair1/PHY/LTE_REFSIG/lte_refsig.h | 2 +- openair1/PHY/LTE_TRANSPORT/dci.c | 4 +- openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c | 12 ++--- openair1/PHY/LTE_TRANSPORT/edci.c | 8 ++-- openair1/PHY/LTE_TRANSPORT/group_hopping.c | 6 +-- openair1/PHY/LTE_TRANSPORT/pbch.c | 8 ++-- openair1/PHY/LTE_TRANSPORT/pcfich.c | 4 +- openair1/PHY/LTE_TRANSPORT/phich.c | 4 +- openair1/PHY/LTE_TRANSPORT/pucch.c | 4 +- openair1/PHY/LTE_TRANSPORT/pucch_common.c | 2 +- openair1/PHY/LTE_TRANSPORT/transport_proto.h | 48 ------------------- openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c | 2 +- openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c | 4 +- openair1/PHY/LTE_UE_TRANSPORT/pbch_ue.c | 8 ++-- openair1/PHY/LTE_UE_TRANSPORT/pcfich_ue.c | 4 +- openair1/PHY/LTE_UE_TRANSPORT/phich_ue.c | 4 +- openair1/PHY/LTE_UE_TRANSPORT/pucch_ue.c | 6 +-- .../PHY/LTE_UE_TRANSPORT/ulsch_modulation.c | 6 +-- openair1/PHY/NR_REFSIG/nr_gold_ue.c | 4 +- openair1/PHY/NR_REFSIG/refsig.c | 6 +-- openair1/PHY/NR_UE_TRANSPORT/nr_psbch_tx.c | 7 +-- .../NR_UE_TRANSPORT/nr_transport_proto_ue.h | 2 - openair1/PHY/gold.h | 46 ++++++++++++++++++ 24 files changed, 99 insertions(+), 106 deletions(-) create mode 100644 openair1/PHY/gold.h diff --git a/openair1/PHY/LTE_REFSIG/defs_NB_IoT.h b/openair1/PHY/LTE_REFSIG/defs_NB_IoT.h index 8adf92c189..85342f006f 100644 --- a/openair1/PHY/LTE_REFSIG/defs_NB_IoT.h +++ b/openair1/PHY/LTE_REFSIG/defs_NB_IoT.h @@ -41,10 +41,6 @@ int lte_dl_cell_spec_NB_IoT(PHY_VARS_eNB_NB_IoT *phy_vars_eNB, unsigned char p, unsigned short RB_IoT_ID); - -unsigned int lte_gold_generic_NB_IoT(unsigned int *x1, - unsigned int *x2, - unsigned char reset); void generate_ul_ref_sigs_rx_NB_IoT(void); diff --git a/openair1/PHY/LTE_REFSIG/lte_refsig.h b/openair1/PHY/LTE_REFSIG/lte_refsig.h index 0521c9d3a5..66ac6e25a5 100644 --- a/openair1/PHY/LTE_REFSIG/lte_refsig.h +++ b/openair1/PHY/LTE_REFSIG/lte_refsig.h @@ -10,7 +10,7 @@ #define __LTE_REFSIG_DEFS__H__ #include "PHY/defs_eNB.h" #include "PHY/defs_UE.h" - +#include "PHY/gold.h" /** @ingroup _PHY_REF_SIG * @{ */ diff --git a/openair1/PHY/LTE_TRANSPORT/dci.c b/openair1/PHY/LTE_TRANSPORT/dci.c index bc6065606c..e15a3a35ec 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci.c +++ b/openair1/PHY/LTE_TRANSPORT/dci.c @@ -184,12 +184,12 @@ void pdcch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, uint32_t x1 = 0, x2 = 0, s = 0; //LOG_D(PHY, "%s(fp, subframe:%d, e, length:%d)\n", __FUNCTION__, subframe, length); reset = 1; - // x1 is set in lte_gold_generic + // x1 is set in gold_generic x2 = (subframe<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.8.2 for (i=0; i>1)<<9) + frame_parms->Nid_cell_mbsfn; //this is c_init in 36.211 Sec 6.3.1 for PMCH } - s = lte_gold_generic(&x1, &x2, 1); + s = gold_generic(&x1, &x2, 1); for (n=0; n<(1+(G>>5)); n++) { #ifdef DEBUG_SCRAMBLING @@ -132,7 +132,7 @@ void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, // This is not faster for some unknown reason // ((simde__m128i *)e)[0] = simde_mm_xor_si128(((simde__m128i *)e)[0],((simde__m128i *)scrambling_lut)[s&65535]); // ((simde__m128i *)e)[1] = simde_mm_xor_si128(((simde__m128i *)e)[1],((simde__m128i *)scrambling_lut)[s>>16]); - s = lte_gold_generic(&x1, &x2, 0); + s = gold_generic(&x1, &x2, 0); e += 32; } @@ -163,7 +163,7 @@ void dlsch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, uint32_t x1, x2, s=0; // reset = 1; - // x1 is set in first call to lte_gold_generic + // x1 is set in first call to gold_generic if (mbsfn_flag == 0) x2 = (dlsch->rnti<<14) + (q<<13) + ((Ns>>1)<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.3.1 @@ -173,7 +173,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_generic(&x1, &x2, 1); + s = gold_generic(&x1, &x2, 1); for (i=0; i<(1+(G>>5)); i++) { for (j=0; j<32; j++,k++) { @@ -186,7 +186,7 @@ void dlsch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, #endif } - s = lte_gold_generic(&x1, &x2, 0); + s = gold_generic(&x1, &x2, 0); } } diff --git a/openair1/PHY/LTE_TRANSPORT/edci.c b/openair1/PHY/LTE_TRANSPORT/edci.c index 7c46de8bba..f12ecb6838 100644 --- a/openair1/PHY/LTE_TRANSPORT/edci.c +++ b/openair1/PHY/LTE_TRANSPORT/edci.c @@ -38,7 +38,7 @@ void mpdcch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, mDCI_ALLOC_t *mdci, uint uint16_t i0 = mdci->i0; // Note: we could actually not do anything if i-i0 < Nacc, save it for later reset = 1; - // x1 is set in lte_gold_generic + // x1 is set in gold_generic if ((mdci->rnti == 0xFFFE) || (mdci->ce_mode == 2)) // CEModeB Note: also for mdci->rnti==SC_RNTI Nacc = frame_parms->frame_type == FDD ? 4 : 10; @@ -59,7 +59,7 @@ void mpdcch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, mDCI_ALLOC_t *mdci, uint for (n = 0; n < length; n++) { if ((n & 0x1f) == 0) { - s = lte_gold_generic(&x1, &x2, reset); + s = gold_generic(&x1, &x2, reset); //printf("lte_gold[%d]=%x\n",i,s); reset = 0; } @@ -354,7 +354,7 @@ void generate_mdci_top(PHY_VARS_eNB *eNB, int frame, int subframe, int16_t amp, // pilot scrambling initiatlization (note: this is for a single repetition) - // x1 is set in lte_gold_generic + // x1 is set in gold_generic // rule for BL/CE UEs from Section 6.10.3A.1 in 36.211 @@ -394,7 +394,7 @@ void generate_mdci_top(PHY_VARS_eNB *eNB, int frame, int subframe, int16_t amp, for (int mprime=0; mprime<3; mprime++,ii+=2) { if ((ii & 0x1f) == 0) { - s = lte_gold_generic(&x1, &x2, reset); + s = gold_generic(&x1, &x2, reset); reset = 0; } diff --git a/openair1/PHY/LTE_TRANSPORT/group_hopping.c b/openair1/PHY/LTE_TRANSPORT/group_hopping.c index 4c60eee146..3feae398a7 100644 --- a/openair1/PHY/LTE_TRANSPORT/group_hopping.c +++ b/openair1/PHY/LTE_TRANSPORT/group_hopping.c @@ -34,7 +34,7 @@ void generate_grouphop(LTE_DL_FRAME_PARMS *frame_parms) } else { if ((ns&3) == 0) { - s = lte_gold_generic(&x1,&x2,reset); + s = gold_generic(&x1,&x2,reset); reset = 0; } @@ -62,7 +62,7 @@ void generate_seqhop(LTE_DL_FRAME_PARMS *frame_parms) x2 = (32*(frame_parms->Nid_cell/30) + fss_pusch)%30; - s = lte_gold_generic(&x1,&x2,reset); + s = gold_generic(&x1,&x2,reset); #ifdef DEBUG_GROUPHOP printf("[PHY] SeqHop:"); #endif @@ -105,7 +105,7 @@ void generate_nPRS(LTE_DL_FRAME_PARMS *frame_parms) for (n=0; n<(20*Nsymb_UL); n++) { //loop over total number of bytes to generate if ((n&3) == 0) { - s = lte_gold_generic(&x1,&x2,reset); + s = gold_generic(&x1,&x2,reset); reset = 0; // printf("n %d : s (%d,%d,%d,%d)\n",n,((uint8_t*)&s)[0],((uint8_t*)&s)[1],((uint8_t*)&s)[2],((uint8_t*)&s)[3]); } diff --git a/openair1/PHY/LTE_TRANSPORT/pbch.c b/openair1/PHY/LTE_TRANSPORT/pbch.c index 971dad59f7..d9962a2c8e 100644 --- a/openair1/PHY/LTE_TRANSPORT/pbch.c +++ b/openair1/PHY/LTE_TRANSPORT/pbch.c @@ -125,13 +125,13 @@ void pbch_scrambling_fembms(LTE_DL_FRAME_PARMS *frame_parms, uint32_t x1 = 0, x2 = 0, s = 0; reset = 1; - // x1 is set in lte_gold_generic + // x1 is set in gold_generic x2 = frame_parms->Nid_cell + (1<<9); //this is c_init for FeMBMS in 36.211 Sec 6.6.1 // msg("pbch_scrambling: Nid_cell = %d\n",x2); for (i=0; iNid_cell; //this is c_init in 36.211 Sec 6.6.1 // msg("pbch_scrambling: Nid_cell = %d\n",x2); for (i=0; iNid_cell)+1)*(1+subframe))<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.7.1 for (i=0; i<32; i++) { if ((i&0x1f)==0) { - s = lte_gold_generic(&x1, &x2, reset); + s = gold_generic(&x1, &x2, reset); //printf("lte_gold[%d]=%x\n",i,s); reset = 0; } diff --git a/openair1/PHY/LTE_TRANSPORT/phich.c b/openair1/PHY/LTE_TRANSPORT/phich.c index 7ba5c344fa..efdedf7399 100644 --- a/openair1/PHY/LTE_TRANSPORT/phich.c +++ b/openair1/PHY/LTE_TRANSPORT/phich.c @@ -60,10 +60,10 @@ void generate_phich(LTE_DL_FRAME_PARMS *frame_parms, // c = (1-(2*HI))*SSS_AMP; - // x1 is set in lte_gold_generic + // x1 is set in gold_generic x2 = (((subframe+1)*((frame_parms->Nid_cell<<1)+1))<<9) + frame_parms->Nid_cell; - s = lte_gold_generic(&x1, &x2, reset); + s = gold_generic(&x1, &x2, reset); // compute scrambling sequence for (i=0; i<12; i++) { diff --git a/openair1/PHY/LTE_TRANSPORT/pucch.c b/openair1/PHY/LTE_TRANSPORT/pucch.c index 73ed4d1940..2e8fc4004f 100644 --- a/openair1/PHY/LTE_TRANSPORT/pucch.c +++ b/openair1/PHY/LTE_TRANSPORT/pucch.c @@ -645,8 +645,8 @@ uint16_t pucchfmt3_Descramble( int16_t IFFTOutData_Fmt3[2][12][2], uint32_t x1; uint32_t s,s0,s1; cinit = (subframe + 1) * ((2 * Nid_cell + 1)<<16) + rnti; - s0 = lte_gold_generic(&x1,&cinit,1); - s1 = lte_gold_generic(&x1,&cinit,0); + s0 = gold_generic(&x1,&cinit,1); + s1 = gold_generic(&x1,&cinit,0); i=0; for (m=0; m>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); -} - - /**@}*/ #endif diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index 8b71450d48..e0208e8435 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -405,7 +405,7 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB, else harq_pid = subframe2harq_pid(frame_parms,proc->frame_rx,subframe); - // x1 is set in lte_gold_generic + // x1 is set in gold_generic uint32_t x2 = ((uint32_t)ulsch->rnti << 14) + ((uint32_t)subframe << 9) + frame_parms->Nid_cell; // this is c_init in 36.211 Sec 6.3.1 LTE_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_processes[harq_pid]; diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c index 909d3e96d1..32aa367fd6 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c @@ -1199,13 +1199,13 @@ void pdcch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, uint32_t x1 = 0, x2 = 0, s = 0; reset = 1; - // x1 is set in first call to lte_gold_generic + // x1 is set in first call to gold_generic x2 = (subframe<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.8.2 for (i=0; iNid_cell; //this is c_init in 36.211 Sec 6.6.1 // msg("pbch_unscrambling: Nid_cell = %d\n",x2); for (i=0; iNid_cell+(1<<9); //this is c_init for FeMBMS in 36.211 Sec 6.6.1 //msg("pbch_unscrambling: Nid_cell = %d, x2 = %d, frame_mod4 %d length %d\n",frame_parms->Nid_cell,x2,frame_mod4,length); for (i=0; iNid_cell)+1)*(1+subframe))<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.7.1 for (uint32_t i=0; i<32; i++) { if ((i&0x1f)==0) { - s = lte_gold_generic(&x1, &x2, reset); + s = gold_generic(&x1, &x2, reset); //printf("lte_gold[%d]=%x\n",i,s); reset = 0; } diff --git a/openair1/PHY/LTE_UE_TRANSPORT/phich_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/phich_ue.c index b3c7673088..c922f32908 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/phich_ue.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/phich_ue.c @@ -111,10 +111,10 @@ void rx_phich(PHY_VARS_UE *ue, memset(d,0,24*sizeof(int8_t)); phich_d_ptr = phich_d; - // x1 is set in lte_gold_generic + // x1 is set in gold_generic x2 = (((subframe+1)*((frame_parms->Nid_cell<<1)+1))<<9) + frame_parms->Nid_cell; - s = lte_gold_generic(&x1, &x2, reset); + s = gold_generic(&x1, &x2, reset); // compute scrambling sequence for (i=0; i<12; i++) { diff --git a/openair1/PHY/LTE_UE_TRANSPORT/pucch_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/pucch_ue.c index 2b856b63bb..dfece3a4a0 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/pucch_ue.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/pucch_ue.c @@ -321,7 +321,7 @@ static inline void pucch2x_scrambling(LTE_DL_FRAME_PARMS *fp,int subframe,uint16 uint8_t c; x2 = (rnti) + ((uint32_t)(1+subframe)<<16)*(1+(fp->Nid_cell<<1)); //this is c_init in 36.211 Sec 6.3.1 - s = lte_gold_generic(&x1, &x2, 1); + s = gold_generic(&x1, &x2, 1); for (i=0;i<19;i++) { c = (uint8_t)((s>>i)&1); btilde[i] = (((B>>i)&1) ^ c); @@ -632,8 +632,8 @@ void generate_pucch3x(int32_t **txdataF, // Scrambling cinit = (subframe + 1) * ((2 * frame_parms->Nid_cell + 1)<<16) + rnti; - s0 = lte_gold_generic(&x1,&cinit,1); - s1 = lte_gold_generic(&x1,&cinit,0); + s0 = gold_generic(&x1,&cinit,1); + s1 = gold_generic(&x1,&cinit,0); for (i=0; i<48; i++) { s = (i<32)? s0:s1; diff --git a/openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c b/openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c index c4ef20c98e..ae9ea15a26 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c @@ -164,7 +164,7 @@ void ulsch_modulation(int32_t **txdataF, return; } - // x1 is set in lte_gold_generic + // x1 is set in gold_generic x2 = (ulsch->rnti<<14) + (subframe<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.3.1 if (harq_pid>=8) { @@ -203,7 +203,7 @@ void ulsch_modulation(int32_t **txdataF, // scrambling (Note the placeholding bits are handled in ulsch_coding.c directly!) //printf("ulsch bits: "); - s = lte_gold_generic(&x1, &x2, 1); + s = gold_generic(&x1, &x2, 1); k=0; //printf("G %d\n",G); @@ -224,7 +224,7 @@ void ulsch_modulation(int32_t **txdataF, } - s = lte_gold_generic(&x1, &x2, 0); + s = gold_generic(&x1, &x2, 0); } //printf("\n"); diff --git a/openair1/PHY/NR_REFSIG/nr_gold_ue.c b/openair1/PHY/NR_REFSIG/nr_gold_ue.c index 5fb5758ee2..d0ad168716 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold_ue.c +++ b/openair1/PHY/NR_REFSIG/nr_gold_ue.c @@ -3,7 +3,7 @@ */ #include "sl_refsig_defs.h" -#include "openair1/PHY/LTE_TRANSPORT/transport_proto.h" // for lte_gold_generic() +#include "openair1/PHY/gold.h" void sl_init_psbch_dmrs_gold_sequences(PHY_VARS_NR_UE *UE) { @@ -20,7 +20,7 @@ void sl_init_psbch_dmrs_gold_sequences(PHY_VARS_NR_UE *UE) #endif for (uint8_t n = 0; n < SL_NR_NUM_PSBCH_DMRS_RE_DWORD; n++) { - UE->SL_UE_PHY_PARAMS.init_params.psbch_dmrs_gold_sequences[slss_id][n] = lte_gold_generic(&x1, &x2, reset); + UE->SL_UE_PHY_PARAMS.init_params.psbch_dmrs_gold_sequences[slss_id][n] = gold_generic(&x1, &x2, reset); reset = 0; #ifdef SL_DEBUG_INIT_DATA diff --git a/openair1/PHY/NR_REFSIG/refsig.c b/openair1/PHY/NR_REFSIG/refsig.c index b22dcb6c2f..418d6aa702 100644 --- a/openair1/PHY/NR_REFSIG/refsig.c +++ b/openair1/PHY/NR_REFSIG/refsig.c @@ -3,7 +3,7 @@ */ #include "nr_refsig.h" -#include "openair1/PHY/LTE_TRANSPORT/transport_proto.h" // for lte_gold_generic() +#include "openair1/PHY/gold.h" #define REFRESH_RATE (1000 * 100) @@ -141,9 +141,9 @@ uint32_t *gold_cache(uint32_t key, int length) *new = (gold_cache_t){.key = key, .length = length, .usage = 1}; unsigned int x1 = 0, x2 = key; uint32_t *sequence = firstFree + roundedHeaderSz; - *sequence++ = lte_gold_generic(&x1, &x2, 1); + *sequence++ = gold_generic(&x1, &x2, 1); for (int n = 1; n < length; n++) - *sequence++ = lte_gold_generic(&x1, &x2, 0); + *sequence++ = gold_generic(&x1, &x2, 0); LOG_D(PHY, "created a gold sequence, start %d; len %d\n", key, length); return firstFree + roundedHeaderSz; } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_psbch_tx.c b/openair1/PHY/NR_UE_TRANSPORT/nr_psbch_tx.c index f649d62a4b..6504b06c9a 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_psbch_tx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_psbch_tx.c @@ -7,6 +7,7 @@ #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "PHY/CODING/nrPolar_tools/nr_polar_psbch_defs.h" #include "PHY/MODULATION/nr_modulation.h" +#include "PHY/gold.h" // #define SL_DEBUG @@ -19,7 +20,7 @@ void sl_psbch_scrambling(uint32_t *output, uint32_t id, uint16_t length) { uint32_t x1, x2, s = 0; - // x1 is set in lte_gold_generic + // x1 is set in gold_generic x2 = id; // C_INIT #ifdef SL_DEBUG @@ -29,7 +30,7 @@ void sl_psbch_scrambling(uint32_t *output, uint32_t id, uint16_t length) #endif // get initial 32 scrambing bits - s = lte_gold_generic(&x1, &x2, 1); + s = gold_generic(&x1, &x2, 1); #ifdef SL_DEBUG printf("s: %04x\t", s); #endif @@ -40,7 +41,7 @@ void sl_psbch_scrambling(uint32_t *output, uint32_t id, uint16_t length) output[i >> 5] ^= s; i += 32; - s = lte_gold_generic(&x1, &x2, 0); + s = gold_generic(&x1, &x2, 0); #ifdef SL_DEBUG printf("s: %04x\t", s); #endif diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h index 157b5efd46..32d03c1010 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -11,8 +11,6 @@ #include "SCHED_NR_UE/defs.h" #include "PHY/NR_TRANSPORT/nr_transport_common_proto.h" #include -#include "nfapi_interface.h" -#include #define NR_PUSCH_x 2 // UCI placeholder bit TS 38.212 V15.4.0 subclause 5.3.3.1 #define NR_PUSCH_y 3 // UCI placeholder bit diff --git a/openair1/PHY/gold.h b/openair1/PHY/gold.h new file mode 100644 index 0000000000..fbaa580fe0 --- /dev/null +++ b/openair1/PHY/gold.h @@ -0,0 +1,46 @@ +/* + * SPDX-License-Identifier: LicenseRef-CSSL-1.0 + */ + +#ifndef __openair_GOLD_H__ +#define __openair_GOLD_H__ + +static inline uint32_t 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 + (1U << 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); +} + +#endif