From 380bac3e984ffe1db43ac29d6d9dea0b5a3028b6 Mon Sep 17 00:00:00 2001 From: yilmazt Date: Fri, 15 Feb 2019 11:06:30 +0100 Subject: [PATCH 01/15] Warning removals and first update of small block coding --- .../nfapi/public_inc/nfapi_interface.h | 2 +- .../nfapi/public_inc/nfapi_nr_interface.h | 2 +- openair1/PHY/CODING/TESTBENCH/polartest.c | 122 +++++++++++++-- openair1/PHY/CODING/coding_defs.h | 2 + openair1/PHY/CODING/crc_byte.c | 2 +- .../PHY/CODING/nrPolar_tools/nr_polar_defs.h | 2 +- .../CODING/nrPolar_tools/nr_polar_encoder.c | 139 ++++++++++-------- .../PHY/CODING/nrSmallBlock/encodeSmall.c | 0 openair1/PHY/CODING/nr_rate_matching.c | 1 + openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 2 +- .../SCHED_NR_UE/pucch_power_control_ue_nr.c | 2 + openair1/SCHED_NR_UE/pucch_uci_ue_nr.c | 57 +------ openair1/SIMULATION/NR_PHY/dlschsim.c | 18 +-- openair1/SIMULATION/NR_PHY/dlsim.c | 49 +++--- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 13 +- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 22 +++ 17 files changed, 261 insertions(+), 176 deletions(-) create mode 100644 openair1/PHY/CODING/nrSmallBlock/encodeSmall.c diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h index 51f66c3075..fc3859be94 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h @@ -583,7 +583,7 @@ typedef struct { } nfapi_pnf_phy_rf_config_t; #define NFAPI_PNF_PHY_RF_TAG 0x1003 -// Generic strucutre for single tlv value. +// Generic structure for single tlv value. typedef struct { nfapi_tl_t tl; uint16_t value; diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h index 4273186dcf..36c865be01 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h @@ -72,7 +72,7 @@ typedef struct // These TLVs are used by the VNF to configure the RF in the PNF // nfapi_uint16_tlv_t max_transmit_power; - nfapi_uint16_tlv_t nrarfcn; + nfapi_uint32_tlv_t nrarfcn; // nfapi_nmm_frequency_bands_t nmm_gsm_frequency_bands; // nfapi_nmm_frequency_bands_t nmm_umts_frequency_bands; diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index 6d50070b86..e4b4758493 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -11,10 +11,36 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h" #include "PHY/CODING/coding_defs.h" #include "SIMULATION/TOOLS/sim.h" +//#include "PHY/NR_TRANSPORT/nr_transport.h" +//#include "common/utils/LOG/log.h" //#define DEBUG_DCI_POLAR_PARAMS //#define DEBUG_POLAR_TIMING //#define DEBUG_CRC +//#define DEBUG_POLARTEST + +uint8_t nr_pbch_payload_interleaving_pattern[32] = {16, 23, 18, 17, 8, 30, 10, 6, 24, 7, 0, 5, 3, 2, 1, 4, + 9, 11, 12, 13, 14, 15, 19, 20, 21, 22, 25, 26, 27, 28, 29, 31}; + +void nr_init_pbch_interleaver(uint8_t *interleaver) { + uint8_t j_sfn=0, j_hrf=10, j_ssb=11, j_other=14; + memset((void*)interleaver,0, NR_POLAR_PBCH_PAYLOAD_BITS); + + for (uint8_t i=0; i0x%08x\n", testInput[0]); - for (int i=0; i<32; i++) - printf("%d\n",(testInput[0]>>i)&1);*/ - +#ifdef DEBUG_POLARTEST + printf("testInput: "); + for (int i = 0; i < testArrayLength; i++) printf("[%d]->0x%08x\t",i, testInput[i]); + printf("\n"); + printf("testInput[0]: "); + for (int i=0; i<32; i++) printf("[%d]=%d-",i,(testInput[0]>>i)&1); + printf("\n"); + printf("testInput[1]: "); + for (int i=0; i<32; i++) printf("[%d]=%d-",i,(testInput[1]>>i)&1); + printf("\n"); +#endif int len_mod64=currentPtr->payloadBits&63; ((uint64_t*)testInput)[currentPtr->payloadBits/64]&=((((uint64_t)1)<0x%08x\t",i, testInput[i]); + printf("\n"); + + printf("testInput[0]: "); + for (int i=0; i<32; i++) printf("[%d]=%d-",i,(testInput[0]>>i)&1); + printf("\n"); + printf("testInput[1]: "); + for (int i=0; i<32; i++) printf("[%d]=%d-",i,(testInput[1]>>i)&1); + printf("\n"); +#endif + + if (matlabDebug == 1){ + memset(testInput,0,sizeof(uint32_t) * testArrayLength); + /*testInput[0] |= ((uint32_t)1 << 31); testInput[0] |= ((uint32_t)1 << 28); testInput[0] |= ((uint32_t)1 << 26); + testInput[0] |= ((uint32_t)1 << 25); testInput[0] |= ((uint32_t)1 << 22); testInput[0] |= ((uint32_t)1 << 21); + testInput[0] |= ((uint32_t)1 << 19); testInput[0] |= ((uint32_t)1 << 17); testInput[0] |= ((uint32_t)1 << 15); + testInput[0] |= ((uint32_t)1 << 14); testInput[0] |= ((uint32_t)1 << 12); testInput[0] |= ((uint32_t)1 << 10); + testInput[0] |= ((uint32_t)1 << 8); testInput[0] |= ((uint32_t)1 << 5); testInput[0] |= ((uint32_t)1 << 3); + testInput[0] |= ((uint32_t)1 << 2); testInput[0] |= ((uint32_t)1 << 1);*/ + + + + testInput[0] |= ((uint32_t)1 << 30); testInput[0] |= ((uint32_t)1 << 29); testInput[0] |= ((uint32_t)1 << 28); + testInput[0] |= ((uint32_t)1 << 26); testInput[0] |= ((uint32_t)1 << 23); testInput[0] |= ((uint32_t)1 << 21); + testInput[0] |= ((uint32_t)1 << 19); testInput[0] |= ((uint32_t)1 << 17); testInput[0] |= ((uint32_t)1 << 16); + testInput[0] |= ((uint32_t)1 << 14); testInput[0] |= ((uint32_t)1 << 12); testInput[0] |= ((uint32_t)1 << 10); + testInput[0] |= ((uint32_t)1 << 9); testInput[0] |= ((uint32_t)1 << 6); testInput[0] |= ((uint32_t)1 << 5); + testInput[0] |= ((uint32_t)1 << 3); testInput[0] |= ((uint32_t)1); + + + /*printf("testInput (a_31,..., a_0): "); + for (int i=31; i>=0; i--) printf("%d-",(testInput[0]>>i)&1); //a_31, a_30, ..., a_0 + printf("testInput = 0x%llx\n", testInput[0]); + printf("\n");*/ + + + /*for (int i=0;i<32;i++){ + memset(testInput,0,sizeof(uint32_t) * testArrayLength); + testInput[0] |= ((uint32_t)1 << i); + int crc = crc24c(testInput,32); + printf("[i=%d]testInput = 0x%08lx, crc = 0x%lx\n", i,testInput[0], crc); + } + memset(testInput,0,sizeof(uint32_t) * testArrayLength); + int crc = crc24c(testInput,32); + printf("testInput = 0x%08lx, crc = 0x%lx\n", testInput[0], crc);*/ + + } + + uint8_t nr_pbch_interleaver[NR_POLAR_PBCH_PAYLOAD_BITS]; + memset((void*)nr_pbch_interleaver,0, NR_POLAR_PBCH_PAYLOAD_BITS); + nr_init_pbch_interleaver(nr_pbch_interleaver); + for (int i=0; i<=31;i++) + printf("nr_pbch_interleaver[%d]=%d\n",i,nr_pbch_interleaver[i]); + + for (int i=0; i0x%08x\n", encoderOutput[0]); diff --git a/openair1/PHY/CODING/coding_defs.h b/openair1/PHY/CODING/coding_defs.h index 0f316e7869..1b23de1cb9 100644 --- a/openair1/PHY/CODING/coding_defs.h +++ b/openair1/PHY/CODING/coding_defs.h @@ -30,6 +30,8 @@ #include #include +typedef unsigned __int128 uint128_t; + #define CRC24_A 0 #define CRC24_B 1 #define CRC16 2 diff --git a/openair1/PHY/CODING/crc_byte.c b/openair1/PHY/CODING/crc_byte.c index d728d6b9ad..67190698e1 100644 --- a/openair1/PHY/CODING/crc_byte.c +++ b/openair1/PHY/CODING/crc_byte.c @@ -258,7 +258,7 @@ unsigned int crcPayload(unsigned char * inptr, int bitlen, uint32_t* crc256Table int check_crc(uint8_t* decoded_bytes, uint32_t n, uint32_t F, uint8_t crc_type) { uint32_t crc=0,oldcrc=0; - uint8_t crc_len,temp; + uint8_t crc_len; switch (crc_type) { case CRC24_A: diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index 68e9ef3571..bd056c3a18 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -147,7 +147,7 @@ void polar_encoder_dci(uint32_t *in, t_nrPolar_paramsPtr polarParams, uint16_t n_RNTI); -void polar_encoder_fast(uint64_t *A, +void polar_encoder_fast(uint64_t *Aprime, uint32_t *out, int32_t crcmask, t_nrPolar_paramsPtr polarParams); diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c index 50d14d87e2..bafddae850 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c @@ -33,6 +33,7 @@ //#define DEBUG_POLAR_ENCODER //#define DEBUG_POLAR_ENCODER_DCI //#define DEBUG_POLAR_ENCODER_TIMING +#define DEBUG_POLAR_MATLAB #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "assertions.h" @@ -336,8 +337,8 @@ void build_polar_tables(t_nrPolar_paramsPtr polarParams) { if (polarParams->information_bit_pattern[i] > 0) { polarParams->G_N_tab[k] = (uint64_t*)memalign(32,(polarParams->N/64)*sizeof(uint64_t)); memset((void*)polarParams->G_N_tab[k],0,(polarParams->N/64)*sizeof(uint64_t)); - for (int j=0;jN;j++) - polarParams->G_N_tab[k][j/64] |= ((uint64_t)polarParams->G_N[i][j])<<(j&63); + for (int j=0;jN;j++) + polarParams->G_N_tab[k][j/64] |= ((uint64_t)polarParams->G_N[i][j])<<(j&63); #ifdef DEBUG_POLAR_ENCODER printf("Bit %d Selecting row %d of G : ",k,i); for (int j=0;jN;j+=4) printf("%1x",polarParams->G_N[i][j]+(polarParams->G_N[i][j+1]*2)+(polarParams->G_N[i][j+2]*4)+(polarParams->G_N[i][j+3]*8)); @@ -385,7 +386,7 @@ void build_polar_tables(t_nrPolar_paramsPtr polarParams) { } -void polar_encoder_fast(uint64_t *A, +void polar_encoder_fast(uint64_t *Aprime, uint32_t *out, int32_t crcmask, t_nrPolar_paramsPtr polarParams) { @@ -394,9 +395,13 @@ void polar_encoder_fast(uint64_t *A, AssertFatal(polarParams->K < 129, "K = %d > 128, is not supported yet\n",polarParams->K); AssertFatal(polarParams->payloadBits < 65, "payload bits = %d > 64, is not supported yet\n",polarParams->payloadBits); - uint64_t B[4]={0,0,0,0},Cprime[4]={0,0,0,0}; + uint64_t B[4]={0,0,0,0}, Cprime[4]={0,0,0,0}; int bitlen = polarParams->payloadBits; +#ifdef DEBUG_POLAR_MATLAB + if (polarParams->K<65) printf("[polar_encoder_fast]A[0] = 0x%llx\n", (unsigned long long)(Aprime[0])); //(unsigned long long)(Aprime[0]&(((uint64_t)1<>8))); } else if (bitlen<=64) { uint8_t A64_flip[8]; - uint64_t Aprime= (uint32_t)(((uint64_t)*A)<<(64-bitlen)); - A64_flip[0]=((uint8_t*)&Aprime)[7]; - A64_flip[1]=((uint8_t*)&Aprime)[6]; - A64_flip[2]=((uint8_t*)&Aprime)[5]; - A64_flip[3]=((uint8_t*)&Aprime)[4]; - A64_flip[4]=((uint8_t*)&Aprime)[3]; - A64_flip[5]=((uint8_t*)&Aprime)[2]; - A64_flip[6]=((uint8_t*)&Aprime)[1]; - A64_flip[7]=((uint8_t*)&Aprime)[0]; + uint64_t AprimeTmp= (uint32_t)(((uint64_t)*Aprime)<<(64-bitlen)); + A64_flip[0]=((uint8_t*)&AprimeTmp)[7]; + A64_flip[1]=((uint8_t*)&AprimeTmp)[6]; + A64_flip[2]=((uint8_t*)&AprimeTmp)[5]; + A64_flip[3]=((uint8_t*)&AprimeTmp)[4]; + A64_flip[4]=((uint8_t*)&AprimeTmp)[3]; + A64_flip[5]=((uint8_t*)&AprimeTmp)[2]; + A64_flip[6]=((uint8_t*)&AprimeTmp)[1]; + A64_flip[7]=((uint8_t*)&AprimeTmp)[0]; tcrc = (uint64_t)((crcmask^(crc24c(A64_flip,bitlen)>>8))); } + else if (bitlen<=128) { + uint8_t A128_flip[16]; + uint128_t AprimeTmp= (uint32_t)(((uint128_t)*Aprime)<<(128-bitlen)); + A128_flip[0]=((uint8_t*)&AprimeTmp)[15]; A128_flip[1]=((uint8_t*)&AprimeTmp)[14]; + A128_flip[2]=((uint8_t*)&AprimeTmp)[13]; A128_flip[3]=((uint8_t*)&AprimeTmp)[12]; + A128_flip[4]=((uint8_t*)&AprimeTmp)[11]; A128_flip[5]=((uint8_t*)&AprimeTmp)[10]; + A128_flip[6] =((uint8_t*)&AprimeTmp)[9]; A128_flip[7] =((uint8_t*)&AprimeTmp)[8]; + A128_flip[8] =((uint8_t*)&AprimeTmp)[7]; A128_flip[9] =((uint8_t*)&AprimeTmp)[6]; + A128_flip[10]=((uint8_t*)&AprimeTmp)[5]; A128_flip[11]=((uint8_t*)&AprimeTmp)[4]; + A128_flip[12]=((uint8_t*)&AprimeTmp)[3]; A128_flip[13]=((uint8_t*)&AprimeTmp)[2]; + A128_flip[14]=((uint8_t*)&AprimeTmp)[1]; A128_flip[15]=((uint8_t*)&AprimeTmp)[0]; + tcrc = (uint64_t)((crcmask^(crc24c(A128_flip,bitlen)>>8))); + } int n; - // this is number of quadwords in the bit string - int quadwlen = (polarParams->K>>6); + int quadwlen = (polarParams->K>>6); // this is number of quadwords (64-bits) in the bit string if ((polarParams->K&63) > 0) quadwlen++; - // Create the B bitstring as - // b_{N'-1} b_{N'-2} ... b_{N'-A} b_{N'-A-1} ... b_{N'-A-Nparity} = a_{N-1} a_{N-2} ... a_{N-A} p_{N_parity-1} ... p_0 + // Create the B bit string as + // 0, 0, ..., 0, a'_0, a'_1, ..., a'_A-1, p_0, p_1, ..., p_{N_parity-1} - for (n=0;ncrcParityBits) | tcrc; - else B[n] = (A[n] << polarParams->crcParityBits) | (A[n-1]>>(64-polarParams->crcParityBits)); + //??? b_{N'-1} b_{N'-2} ... b_{N'-A} b_{N'-A-1} ... b_{N'-A-Nparity} = a_{N-1} a_{N-2} ... a_{N-A} p_{N_parity-1} ... p_0 + + + for (n=0;ncrcParityBits) | tcrc; + else B[n] = (Aprime[n] << polarParams->crcParityBits) | (Aprime[n-1]>>(64-polarParams->crcParityBits)); - +#ifdef DEBUG_POLAR_MATLAB + // B = pbchB + for (int i = 0; i < quadwlen; i++) printf("[polar_encoder_fast]B[%d] = 0x%llx\n", i, (unsigned long long)(B[i])); +#endif + uint8_t *Bbyte = (uint8_t*)B; // for each byte of B, lookup in corresponding table for 64-bit word corresponding to that byte and its position if (polarParams->K<65) @@ -464,10 +489,15 @@ void polar_encoder_fast(uint64_t *A, } } +#ifdef DEBUG_POLAR_MATLAB + // Cprime = pbchCprime + for (int i = 0; i < quadwlen; i++) printf("[polar_encoder_fast]C'[%d]= 0x%llx\n", i, (unsigned long long)(Cprime[i])); +#endif + #ifdef DEBUG_POLAR_ENCODER if (polarParams->K<65) printf("A %llx B %llx Cprime %llx (payload bits %d,crc %x)\n", - (unsigned long long)(A[0]&(((uint64_t)1<payloadBits, @@ -475,52 +505,35 @@ void polar_encoder_fast(uint64_t *A, else if (polarParams->K<129) { if (bitlen<64) printf("A %llx B %llx|%llx Cprime %llx|%llx (payload bits %d,crc %x)\n", - (unsigned long long)(A[0]&(((uint64_t)1<payloadBits, tcrc); else printf("A %llx|%llx B %llx|%llx Cprime %llx|%llx (payload bits %d,crc %x)\n", - (unsigned long long)(A[1]&(((uint64_t)1<<(bitlen-64))-1)),(unsigned long long)(A[0]), + (unsigned long long)(Aprime[1]&(((uint64_t)1<<(bitlen-64))-1)),(unsigned long long)(Aprime[0]), (unsigned long long)(B[1]),(unsigned long long)(B[0]), (unsigned long long)(Cprime[1]),(unsigned long long)(Cprime[0]), polarParams->payloadBits, - crc24c((uint8_t*)A,bitlen)>>8); + crc24c((uint8_t*)Aprime,bitlen)>>8); } #endif - /* printf("Bbytes : %x.%x.%x.%x.%x.%x.%x.%x\n",Bbyte[0],Bbyte[1],Bbyte[2],Bbyte[3],Bbyte[4],Bbyte[5],Bbyte[6],Bbyte[7]); - printf("%llx,%llx,%llx,%llx,%llx,%llx,%llx,%llx\n",polarParams->cprime_tab[0][Bbyte[0]] , - polarParams->cprime_tab[1][Bbyte[1]] , - polarParams->cprime_tab[2][Bbyte[2]] , - polarParams->cprime_tab[3][Bbyte[3]] , - polarParams->cprime_tab[4][Bbyte[4]] , - polarParams->cprime_tab[5][Bbyte[5]] , - polarParams->cprime_tab[6][Bbyte[6]] , - polarParams->cprime_tab[7][Bbyte[7]]);*/ // now do Gu product (here using 64-bit XORs, we can also do with SIMD after) // here we're reading out the bits LSB -> MSB, is this correct w.r.t. 3GPP ? uint64_t Cprime_i; - /* printf("%llx Cprime_0 (%llx) G %llx,%llx,%llx,%llx,%llx,%llx,%llx,%llx\n",Cprime_i,Cprime &1, - polarParams->G_N_tab[0][0], - polarParams->G_N_tab[0][1], - polarParams->G_N_tab[0][2], - polarParams->G_N_tab[0][3], - polarParams->G_N_tab[0][4], - polarParams->G_N_tab[0][5], - polarParams->G_N_tab[0][6], - polarParams->G_N_tab[0][7]);*/ uint64_t D[8]={0,0,0,0,0,0,0,0}; int off=0; int len=polarParams->K; + for (int j=0;j<(1+(polarParams->K>>6));j++,off+=64,len-=64) { for (int i=0;i<((len>63) ? 64 : len);i++) { Cprime_i = -((Cprime[j]>>i)&1); // this converts bit 0 as, 0 => 0000x00, 1 => 1111x11 - /* -#ifdef DEBUG_POLAR_ENCODER + + #ifdef DEBUG_POLAR_ENCODER printf("%llx Cprime_%d (%llx) G %llx,%llx,%llx,%llx,%llx,%llx,%llx,%llx\n", Cprime_i,off+i,(Cprime[j]>>i) &1, polarParams->G_N_tab[off+i][0], @@ -531,8 +544,8 @@ void polar_encoder_fast(uint64_t *A, polarParams->G_N_tab[off+i][5], polarParams->G_N_tab[off+i][6], polarParams->G_N_tab[off+i][7]); -#endif - */ + #endif + uint64_t *Gi=polarParams->G_N_tab[off+i]; D[0] ^= (Cprime_i & Gi[0]); D[1] ^= (Cprime_i & Gi[1]); @@ -545,17 +558,17 @@ void polar_encoder_fast(uint64_t *A, } } #ifdef DEBUG_POLAR_ENCODER - printf("D %llx,%llx,%llx,%llx,%llx,%llx,%llx,%llx\n", - D[0], - D[1], - D[2], - D[3], - D[4], - D[5], - D[6], - D[7]); + printf("D %llx,%llx,%llx,%llx,%llx,%llx,%llx,%llx\n", D[0], D[1], D[2], D[3], D[4], D[5], D[6], D[7]); #endif - polar_rate_matching(polarParams,(void*)D,(void*)out); +#ifdef DEBUG_POLAR_MATLAB + // D = pbchD + for (int i = 0; i < 8; i++) printf("[polar_encoder_fast]D[%d] = 0x%016llx\n", i, (unsigned long long)(D[i])); +#endif + polar_rate_matching(polarParams,(void*)D,(void*)out); +#ifdef DEBUG_POLAR_MATLAB + // out = pbchF + for (int i = 0; i < (NR_POLAR_PBCH_E/32); i++) printf("[polar_encoder_fast]F[%d] = 0x%08lx\n", i, (unsigned long)(out[i])); +#endif } diff --git a/openair1/PHY/CODING/nrSmallBlock/encodeSmall.c b/openair1/PHY/CODING/nrSmallBlock/encodeSmall.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/openair1/PHY/CODING/nr_rate_matching.c b/openair1/PHY/CODING/nr_rate_matching.c index 0bce31630f..f71535f654 100644 --- a/openair1/PHY/CODING/nr_rate_matching.c +++ b/openair1/PHY/CODING/nr_rate_matching.c @@ -26,6 +26,7 @@ #include "PHY/defs_gNB.h" #include "PHY/defs_nr_UE.h" +#include "PHY/CODING/coding_defs.h" //#define RM_DEBUG 1 diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index a7e4b33c16..12870016fa 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -703,7 +703,7 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB, int dlsch_encoding(PHY_VARS_eNB *eNB, - unsigned char *a, + unsigned char *a, uint8_t num_pdcch_symbols, LTE_eNB_DLSCH_t *dlsch, int frame, diff --git a/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c b/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c index 93400def0a..3a910cfd1e 100644 --- a/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c +++ b/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c @@ -33,6 +33,8 @@ #include "SCHED_NR_UE/pucch_uci_ue_nr.h" #include "SCHED_NR_UE/pucch_power_control_ue_nr.h" +int16_t get_PL(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index); + /**************** defines **************************************/ /**************** variables **************************************/ diff --git a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c index fb38c80eb8..27295f15d3 100644 --- a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c +++ b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c @@ -36,6 +36,7 @@ #include "PHY/NR_REFSIG/ss_pbch_nr.h" #include "PHY/defs_nr_UE.h" +#include "PHY/NR_UE_TRANSPORT/pucch_nr.h" #ifndef NO_RAT_NR @@ -51,57 +52,7 @@ int8_t nr_ue_get_SR(module_id_t module_idP, int CC_id, frame_t frameP, uint8_t eNB_id, uint16_t rnti, sub_frame_t subframe); uint8_t is_cqi_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t gNB_id); uint8_t is_ri_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t gNB_id); -/* -void nr_generate_pucch0(int32_t **txdataF, - NR_DL_FRAME_PARMS *frame_parms, - PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, - int16_t amp, - int nr_tti_tx, - uint8_t mcs, - uint8_t nrofSymbols, - uint8_t startingSymbolIndex, - uint16_t startingPRB); -void nr_generate_pucch1(int32_t **txdataF, - NR_DL_FRAME_PARMS *frame_parms, - PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, - uint64_t payload, - int16_t amp, - int nr_tti_tx, - uint8_t nrofSymbols, - uint8_t startingSymbolIndex, - uint16_t startingPRB, - uint16_t startingPRB_intraSlotHopping, - uint8_t timeDomainOCC, - uint8_t nr_bit); - -void nr_generate_pucch2(int32_t **txdataF, - NR_DL_FRAME_PARMS *frame_parms, - PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, - uint64_t payload, - int16_t amp, - int nr_tti_tx, - uint8_t nrofSymbols, - uint8_t startingSymbolIndex, - uint8_t nrofPRB, - uint16_t startingPRB, - uint8_t nr_bit); - -void nr_generate_pucch3_4(int32_t **txdataF, - NR_DL_FRAME_PARMS *frame_parms, - pucch_format_nr_t fmt, - PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, - uint64_t payload, - int16_t amp, - int nr_tti_tx, - uint8_t nrofSymbols, - uint8_t startingSymbolIndex, - uint8_t nrofPRB, - uint16_t startingPRB, - uint8_t nr_bit, - uint8_t occ_length_format4, - uint8_t occ_index_format4); -*/ /**************** variables **************************************/ @@ -556,7 +507,8 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_ switch(format) { case pucch_format0_nr: { - nr_generate_pucch0(ue,ue->common_vars.txdataF, + nr_generate_pucch0(ue, + ue->common_vars.txdataF, &ue->frame_parms, &ue->pucch_config_dedicated_nr[gNB_id], tx_amp, @@ -570,7 +522,8 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_ } case pucch_format1_nr: { - nr_generate_pucch1(ue,ue->common_vars.txdataF, + nr_generate_pucch1(ue, + ue->common_vars.txdataF, &ue->frame_parms, &ue->pucch_config_dedicated_nr[gNB_id], pucch_payload, diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 1c2b2305d6..c648d19264 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -145,8 +145,7 @@ int main(int argc, char **argv) { //uint16_t NB_RB=25; SCM_t channel_model = AWGN; //Rayleigh1_anticorr; uint8_t N_RB_DL = 106, mu = 1; - unsigned char frame_type = 0; - unsigned char pbch_phase = 0; + unsigned char frame_type = 0, pbch_phase = 0; int frame = 0, subframe = 0; int frame_length_complex_samples; //int frame_length_complex_samples_no_prefix; @@ -341,8 +340,8 @@ int main(int argc, char **argv) { printf("-x Transmission mode (1,2,6 for the moment)\n"); printf("-y Number of TX antennas used in eNB\n"); printf("-z Number of RX antennas used in UE\n"); - printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); - printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); + printf("-i Relative strength of first interfering eNB (in dB) - cell_id mod 3 = 1\n"); + printf("-j Relative strength of second interfering eNB (in dB) - cell_id mod 3 = 2\n"); printf("-N Nid_cell\n"); printf("-R N_RB_DL\n"); printf("-O oversampling factor (1,2,4,8,16)\n"); @@ -482,13 +481,10 @@ int main(int argc, char **argv) { short *channel_output_fixed = malloc16(sizeof(short) * 16 * 68 * 384); short *channel_output_uncoded = malloc16(sizeof(unsigned short) * 16 * 68 * 384); double errors_bit_uncoded = 0; - unsigned char *estimated_output; - unsigned char *estimated_output_bit; - unsigned char *test_input_bit; + //unsigned char *estimated_output = malloc16(sizeof(unsigned char) * 16 * 68 * 384); + unsigned char *estimated_output_bit = malloc16(sizeof(unsigned char) * 16 * 68 * 384); + unsigned char *test_input_bit = malloc16(sizeof(unsigned char) * 16 * 68 * 384); unsigned int errors_bit = 0; - test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); - estimated_output = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); - estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); NR_UE_DLSCH_t *dlsch0_ue = UE->dlsch[UE->current_thread_id[subframe]][0][0]; NR_DL_UE_HARQ_t *harq_process = dlsch0_ue->harq_processes[harq_pid]; harq_process->mcs = Imcs; @@ -503,7 +499,7 @@ int main(int argc, char **argv) { for (i = 0; i < TBS / 8; i++) test_input[i] = (unsigned char) rand(); - estimated_output = harq_process->b; + //estimated_output = harq_process->b; #ifdef DEBUG_DLSCHSIM for (i = 0; i < TBS / 8; i++) printf("test_input[i]=%d \n",test_input[i]); diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 1d440c5d0d..4b7102ae7f 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -42,10 +42,11 @@ #include "PHY/MODULATION/modulation_UE.h" #include "PHY/INIT/phy_init.h" #include "PHY/NR_TRANSPORT/nr_transport.h" -#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" +//#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "SCHED_NR/sched_nr.h" #include "SCHED_NR_UE/fapi_nr_ue_l1.h" +#include "SCHED_NR/fapi_nr_l1.h" #include "LAYER2/NR_MAC_gNB/nr_mac_gNB.h" #include "LAYER2/NR_MAC_UE/mac_defs.h" @@ -54,6 +55,10 @@ #include "NR_PHY_INTERFACE/NR_IF_Module.h" #include "NR_UE_PHY_INTERFACE/NR_IF_Module.h" +#include "LAYER2/NR_MAC_UE/mac_proto.h" +#include "LAYER2/NR_MAC_gNB/mac_proto.h" +#include "RRC/NR/MESSAGES/asn1_msg.h" + PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; @@ -78,7 +83,7 @@ int32_t get_uldl_offset(int nr_bandP) {return(0);} NR_IF_Module_t *NR_IF_Module_init(int Mod_id){return(NULL);} int8_t dummy_nr_ue_dl_indication(nr_downlink_indication_t *dl_info){return(0);} -int8_t dummy_nr_ue_ul_indication(nr_uplink_indication_t *ul_info){return(0);} +int dummy_nr_ue_ul_indication(nr_uplink_indication_t *ul_info){return(0);} lte_subframe_t subframe_select(LTE_DL_FRAME_PARMS *frame_parms,unsigned char subframe) { return(SF_DL);} @@ -99,13 +104,6 @@ int rlc_module_init (void) {return(0);} void pdcp_layer_init(void) {} int rrc_init_nr_global_param(void){return(0);} -void config_common(int Mod_idP, - int CC_idP, - int nr_bandP, - uint64_t dl_CarrierFreqP, - uint32_t dl_BandwidthP - ); - // needed for some functions PHY_VARS_NR_UE ***PHY_vars_UE_g; @@ -115,40 +113,39 @@ int main(int argc, char **argv) { char c; - - int i,l,aa; + int i,aa; double sigma2, sigma2_dB=10,SNR,snr0=-2.0,snr1=2.0; uint8_t snr1set=0; int **txdata; double **s_re,**s_im,**r_re,**r_im; - double iqim = 0.0; - unsigned char pbch_pdu[6]; + //double iqim = 0.0; + //unsigned char pbch_pdu[6]; // int sync_pos, sync_pos_slot; // FILE *rx_frame_file; FILE *output_fd = NULL; uint8_t write_output_file=0; //int result; - int freq_offset; - // int subframe_offset; + // int freq_offset, subframe_offset; // char fname[40], vname[40]; - int trial,n_trials=1,n_errors,n_errors2,n_alamouti; + int trial,n_trials=1,n_errors=0; + //int n_errors2=0,n_alamouti=0; uint8_t transmission_mode = 1,n_tx=1,n_rx=1; uint16_t Nid_cell=0; channel_desc_t *gNB2UE; - uint32_t nsymb,tx_lev,tx_lev1 = 0,tx_lev2 = 0; + //uint32_t nsymb,tx_lev,tx_lev1 = 0,tx_lev2 = 0; uint8_t extended_prefix_flag=0; int8_t interf1=-21,interf2=-21; FILE *input_fd=NULL,*pbch_file_fd=NULL; - char input_val_str[50],input_val_str2[50]; + //char input_val_str[50],input_val_str2[50]; - uint8_t frame_mod4,num_pdcch_symbols = 0; + //uint8_t frame_mod4, num_pdcch_symbols = 0; SCM_t channel_model=AWGN;//Rayleigh1_anticorr; - double pbch_sinr; - int pbch_tx_ant; + //double pbch_sinr; + //int pbch_tx_ant; int N_RB_DL=273,mu=1; unsigned char frame_type = 0; @@ -358,8 +355,8 @@ int main(int argc, char **argv) printf("-x Transmission mode (1,2,6 for the moment)\n"); printf("-y Number of TX antennas used in eNB\n"); printf("-z Number of RX antennas used in UE\n"); - printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); - printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); + printf("-i Relative strength of first interfering eNB (in dB) - cell_id mod 3 = 1\n"); + printf("-j Relative strength of second interfering eNB (in dB) - cell_id mod 3 = 2\n"); printf("-N Nid_cell\n"); printf("-R N_RB_DL\n"); printf("-O oversampling factor (1,2,4,8,16)\n"); @@ -497,7 +494,7 @@ int main(int argc, char **argv) gNB_mac = RC.nrmac[0]; config_common(0,0,78,(uint64_t)3640000000L,N_RB_DL); - config_nr_mib(0,0,1,kHz30,0,0,0,0); + config_nr_mib(0,0,1,kHz30,0,0,0,0,0); nr_l2_init_ue(); UE_mac = get_mac_inst(0); @@ -640,8 +637,8 @@ int main(int argc, char **argv) for (SNR=snr0; SNRul_config_request; - fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; + //fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; nr_phy_config_t *phy_config = &mac->phy_config; //ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.rnti = rnti; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index d29a9fb908..b0f6cff84e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -36,6 +36,7 @@ #include "LAYER2/MAC/mac_extern.h" #include "LAYER2/MAC/mac_proto.h" #include "LAYER2/NR_MAC_gNB/mac_proto.h" +#include "openair1/PHY/LTE_TRANSPORT/transport_proto.h" #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" @@ -324,7 +325,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, rnti = UE_RNTI(module_idP, i); CC_id = UE_PCCID(module_idP, i); - int spf = get_spf(cfg); + //int spf = get_spf(cfg); if (((frameP&127) == 0) && (slotP == 0)) { LOG_I(MAC, @@ -382,11 +383,11 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, } for (int ii=0; iidlsch[ii][0]; - if((dlsch != NULL) && (dlsch->rnti == rnti)){ - LOG_I(MAC, "clean_eNb_dlsch UE %x \n", rnti); - clean_eNb_dlsch(dlsch); - } + NR_gNB_DLSCH_t *dlsch = RC.gNB[module_idP][CC_id]->dlsch[ii][0]; + if((dlsch != NULL) && (dlsch->rnti == rnti)){ + LOG_I(MAC, "clean_eNb_dlsch UE %x \n", rnti); + clean_eNb_dlsch(dlsch); + } } for(int j = 0; j < 10; j++){ diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 784496ff9e..7060d80e7a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -36,6 +36,28 @@ void mac_top_init_gNB(void); +uint32_t to_nrarfcn(int nr_bandP, uint64_t dl_CarrierFreq, uint32_t bw); + +uint64_t from_nrarfcn(int nr_bandP, uint32_t dl_nrarfcn); + +void config_nr_mib(int Mod_idP, + int CC_idP, + int p_gNBP, + int subCarrierSpacingCommon, + uint32_t ssb_SubcarrierOffset, + int dmrs_TypeA_Position, + uint32_t pdcch_ConfigSIB1, + int cellBarred, + int intraFreqReselection + ); + +void config_common(int Mod_idP, + int CC_idP, + int nr_bandP, + uint64_t dl_CarrierFreqP, + uint32_t dl_BandwidthP + ); + int rrc_mac_config_req_gNB(module_id_t Mod_idP, int CC_id, int p_gNB, From 9cbfe2e3fac81469fcf90d5b6bcc888665ed46c8 Mon Sep 17 00:00:00 2001 From: yilmazt Date: Sun, 17 Feb 2019 17:43:33 +0100 Subject: [PATCH 02/15] More warning removals --- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 41 ++++++++++--------- .../SCHED_NR_UE/pucch_power_control_ue_nr.c | 2 +- openair1/SCHED_NR_UE/pucch_uci_ue_nr.c | 2 +- openair1/SIMULATION/NR_PHY/dlsim.c | 5 ++- openair2/GNB_APP/gnb_config.c | 2 +- openair2/LAYER2/NR_MAC_UE/mac.h | 10 ++--- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 5 ++- openair2/RRC/NR/L2_nr_interface.c | 1 - openair2/RRC/NR/rrc_gNB.c | 9 ++-- 10 files changed, 40 insertions(+), 39 deletions(-) diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index a4d627823f..5ff6c0d559 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -2961,8 +2961,8 @@ void nr_ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * //uint8_t pbch_phase; int ret = 0; uint16_t frame_tx; - static uint8_t first_run = 1; - uint8_t pbch_trials = 0; + //static uint8_t first_run = 1; + //uint8_t pbch_trials = 0; DevAssert(ue); @@ -3054,9 +3054,10 @@ unsigned int get_tx_amp(int power_dBm, int power_max_dBm, int N_RB_UL, int nb_rb #ifdef NR_PDCCH_SCHED -int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc) +int nr_ue_pdcch_procedures(uint8_t eNB_id, + PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc) { - // unsigned int dci_cnt=0, i; //removed for nr_ue_pdcch_procedures and added in the loop for nb_coreset_active #ifdef NR_PDCCH_SCHED_DEBUG printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_ue_pdcch_procedures() \n"); @@ -3100,10 +3101,10 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * #endif // p in TS 38.212 Subclause 10.1, for each active BWP the UE can deal with 3 different CORESETs (including coresetId 0 for common search space) - int nb_coreset_total = NR_NBR_CORESET_ACT_BWP; + //int nb_coreset_total = NR_NBR_CORESET_ACT_BWP; unsigned int dci_cnt=0; // this table contains 56 (NBR_NR_DCI_FIELDS) elements for each dci field and format described in TS 38.212. Each element represents the size in bits for each dci field - uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS] = {{0}}; + //uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS] = {{0}}; // this is the UL bandwidth part. FIXME! To be defined where this value comes from // uint16_t n_RB_ULBWP = 106; // this is the DL bandwidth part. FIXME! To be defined where this value comes from @@ -3130,7 +3131,7 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * * To be implemented LATER !!! */ //int _offset,_index,_M; - int searchSpace_id = pdcch_vars2->searchSpace[nb_searchspace_active].searchSpaceId; + //int searchSpace_id = pdcch_vars2->searchSpace[nb_searchspace_active].searchSpaceId; #ifdef NR_PDCCH_SCHED_DEBUG @@ -3143,16 +3144,16 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * // the searchSpace indicates that we need to monitor PDCCH in current nr_tti_rx // get the parameters describing the current SEARCHSPACE // the CORESET id applicable to the current SearchSpace - int searchSpace_coreset_id = pdcch_vars2->searchSpace[nb_searchspace_active].controlResourceSetId; + //int searchSpace_coreset_id = pdcch_vars2->searchSpace[nb_searchspace_active].controlResourceSetId; // FIXME this variable is a bit string (14 bits) identifying every OFDM symbol in a slot. // at the moment we will not take into consideration this variable and we will consider that the OFDM symbol offset is always the first OFDM in a symbol uint16_t symbol_within_slot_mon = pdcch_vars2->searchSpace[nb_searchspace_active].monitoringSymbolWithinSlot; // get the remaining parameters describing the current SEARCHSPACE: // FIXME! To be defined where we get this information from - NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L1 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel1; - NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L2 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel2; - NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L4 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel4; - NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L8 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel8; - NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L16 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel16; + //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L1 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel1; + //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L2 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel2; + //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L4 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel4; + //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L8 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel8; + //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L16 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel16; // FIXME! A table of five enum elements // searchSpaceType indicates whether this is a common search space or a UE-specific search space //int searchSpaceType = pdcch_vars2->searchSpace[nb_searchspace_active].searchSpaceType.type; @@ -3899,7 +3900,7 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, int frame_rx = proc->frame_rx; int nr_tti_rx = proc->nr_tti_rx; int ret=0, ret1=0; - int CC_id = ue->CC_id; + //int CC_id = ue->CC_id; NR_UE_PDSCH *pdsch_vars; uint8_t is_cw0_active = 0; uint8_t is_cw1_active = 0; @@ -4957,11 +4958,11 @@ int phy_procedures_slot_parallelization_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_pr #endif -int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id, - uint8_t do_pdcch_flag,runmode_t mode) { - - - +int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc,uint8_t eNB_id, + uint8_t do_pdcch_flag, + runmode_t mode) +{ int l,l2; int pilot1; @@ -5201,7 +5202,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN } // for l=1..l2 // do first symbol of next downlink nr_tti_rx for channel estimation - int next_nr_tti_rx = (1+nr_tti_rx)%10; + //int next_nr_tti_rx = (1+nr_tti_rx)%10; /* if (nr_subframe_select(&ue->frame_parms,next_nr_tti_rx) != SF_UL)*/ { /*nr_slot_fep(ue, diff --git a/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c b/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c index 3a910cfd1e..4541c7fdc6 100644 --- a/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c +++ b/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c @@ -148,7 +148,7 @@ int16_t get_pucch_tx_power_ue(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_pro } } - int l = 0; + //int l = 0; int k2; if (power_config->twoPUCCH_PC_AdjustmentStates > 1) { diff --git a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c index 27295f15d3..5c80040e2b 100644 --- a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c +++ b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c @@ -36,7 +36,7 @@ #include "PHY/NR_REFSIG/ss_pbch_nr.h" #include "PHY/defs_nr_UE.h" -#include "PHY/NR_UE_TRANSPORT/pucch_nr.h" +//#include "PHY/NR_UE_TRANSPORT/pucch_nr.h" #ifndef NO_RAT_NR diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 4b7102ae7f..8582c70e13 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -56,7 +56,8 @@ #include "NR_UE_PHY_INTERFACE/NR_IF_Module.h" #include "LAYER2/NR_MAC_UE/mac_proto.h" -#include "LAYER2/NR_MAC_gNB/mac_proto.h" +//#include "LAYER2/NR_MAC_gNB/mac_proto.h" +//#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h" #include "RRC/NR/MESSAGES/asn1_msg.h" @@ -107,7 +108,7 @@ int rrc_init_nr_global_param(void){return(0);} // needed for some functions PHY_VARS_NR_UE ***PHY_vars_UE_g; -uint16_t conjugate[8]__attribute__((aligned(32))) = {-1,1,-1,1,-1,1,-1,1}; +short conjugate[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1}; int main(int argc, char **argv) { diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 4484cc18a8..82f92b0a4c 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -629,7 +629,7 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { paramdef_t GNBParams[] = GNBPARAMS_DESC; paramlist_def_t GNBParamList = {GNB_CONFIG_STRING_GNB_LIST,NULL,0}; ////////// Physical parameters - checkedparam_t config_check_CCparams[] = NRCCPARAMS_CHECK; + //checkedparam_t config_check_CCparams[] = NRCCPARAMS_CHECK; paramdef_t CCsParams[] = NRCCPARAMS_DESC; paramlist_def_t CCsParamList = {GNB_CONFIG_STRING_COMPONENT_CARRIERS,NULL,0}; diff --git a/openair2/LAYER2/NR_MAC_UE/mac.h b/openair2/LAYER2/NR_MAC_UE/mac.h index 65a00c9cea..b108bb2f1a 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac.h +++ b/openair2/LAYER2/NR_MAC_UE/mac.h @@ -65,7 +65,7 @@ typedef struct { } __attribute__ ((__packed__)) NR_MAC_SUBHEADER_LONG; typedef struct { - uint8_t LCID:5; // octet 1 [5:0] + uint8_t LCID:6; // octet 1 [5:0] uint8_t R:2; // octet 1 [7:6] } __attribute__ ((__packed__)) NR_MAC_SUBHEADER_FIXED; @@ -82,10 +82,10 @@ typedef struct { #define DL_SCH_LCID_TCI_STATE_IND_UE_SPEC_PDCCH 0x34 #define DL_SCH_LCID_TCI_STATE_ACT_UE_SPEC_PDSCH 0x35 #define DL_SCH_LCID_APERIODIC_CSI_TRI_STATE_SUBSEL 0x36 -#define DL_SCH_LCID_SP_CSI_RS_CSI_IM_RES_SET_ACT 0X37 -#define DL_SCH_LCID_DUPLICATION_ACT 0X38 -#define DL_SCH_LCID_SCell_ACT_4_OCT 0X39 -#define DL_SCH_LCID_SCell_ACT_1_OCT 0X3A +#define DL_SCH_LCID_SP_CSI_RS_CSI_IM_RES_SET_ACT 0x37 +#define DL_SCH_LCID_DUPLICATION_ACT 0x38 +#define DL_SCH_LCID_SCell_ACT_4_OCT 0x39 +#define DL_SCH_LCID_SCell_ACT_1_OCT 0x3A #define DL_SCH_LCID_L_DRX 0x3B #define DL_SCH_LCID_DRX 0x3C #define DL_SCH_LCID_TA_COMMAND 0x3D diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index ede150a399..39b6303bcd 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -1754,7 +1754,7 @@ printf("\n>>> nr_ue_process_dci at MAC layer with dci_format=%d\n",dci_format); dci->time_dom_resource_assignment, dlsch_config_pdu_1_0->number_symbols, dlsch_config_pdu_1_0->start_symbol); - printf(">>> (nr_ue_procedures.c) vrb_to_prb_mapping=%d \n>>> mcs=%d\n>>> ndi=%d\n>>> rv=%d\n>>> harq_process_nbr=%d\n>>> dai=%d\n>>> scaling_factor_S=%d\n>>> tpc_pucch=%d\n>>> pucch_res_ind=%d\n>>> pdsch_to_harq_feedback_time_ind=%d\n", + printf(">>> (nr_ue_procedures.c) vrb_to_prb_mapping=%d \n>>> mcs=%d\n>>> ndi=%d\n>>> rv=%d\n>>> harq_process_nbr=%d\n>>> dai=%d\n>>> scaling_factor_S=%f\n>>> tpc_pucch=%d\n>>> pucch_res_ind=%d\n>>> pdsch_to_harq_feedback_time_ind=%d\n", dlsch_config_pdu_1_0->vrb_to_prb_mapping, dlsch_config_pdu_1_0->mcs, dlsch_config_pdu_1_0->ndi, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index b0f6cff84e..27d4dc36a9 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -37,6 +37,7 @@ #include "LAYER2/MAC/mac_proto.h" #include "LAYER2/NR_MAC_gNB/mac_proto.h" #include "openair1/PHY/LTE_TRANSPORT/transport_proto.h" +#include "openair1/PHY/NR_TRANSPORT/nr_dlsch.h" #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" @@ -385,8 +386,8 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, for (int ii=0; iidlsch[ii][0]; if((dlsch != NULL) && (dlsch->rnti == rnti)){ - LOG_I(MAC, "clean_eNb_dlsch UE %x \n", rnti); - clean_eNb_dlsch(dlsch); + LOG_I(MAC, "clean_gNB_dlsch UE %x \n", rnti); + clean_gNB_dlsch(dlsch); } } diff --git a/openair2/RRC/NR/L2_nr_interface.c b/openair2/RRC/NR/L2_nr_interface.c index 0dca3b80d2..c8cdfd336f 100644 --- a/openair2/RRC/NR/L2_nr_interface.c +++ b/openair2/RRC/NR/L2_nr_interface.c @@ -58,7 +58,6 @@ int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP, uint8_t sfn_msb = (uint8_t)((frameP>>4)&0x3f); #ifdef DEBUG_RRC - int i; LOG_I(RRC,"[eNB %d] mac_rrc_data_req to SRB ID=%d\n",Mod_idP,Srb_id); #endif diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 10fc6b6a4e..52ac623b5e 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -144,16 +144,15 @@ void rrc_gNB_generate_SgNBAdditionRequestAcknowledge( rrc_gNB_ue_context_t *const ue_context_pP ){ - uint8_t size; - uint8_t buffer[100]; - int CC_id = ue_context_pP->ue_context.primaryCC_id; - OCTET_STRING_t *secondaryCellGroup; + //uint8_t size, buffer[100]; + //int CC_id = ue_context_pP->ue_context.primaryCC_id; + //OCTET_STRING_t *secondaryCellGroup; NR_CellGroupConfig_t *cellGroupconfig; struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_BearerToAddModList; struct NR_MAC_CellGroupConfig *mac_CellGroupConfig; struct NR_PhysicalCellGroupConfig *physicalCellGroupConfig; struct NR_SpCellConfig *spCellConfig; - struct NR_CellGroupConfig__sCellToAddModList *sCellToAddModList; + //struct NR_CellGroupConfig__sCellToAddModList *sCellToAddModList; cellGroupconfig = CALLOC(1,sizeof(NR_CellGroupConfig_t)); cellGroupconfig->rlc_BearerToAddModList = CALLOC(1,sizeof(struct NR_CellGroupConfig__rlc_BearerToAddModList)); From dd61e5a71739f9c92f9c11de7e59d8b4b2ec8da0 Mon Sep 17 00:00:00 2001 From: yilmazt Date: Fri, 8 Mar 2019 15:44:50 +0100 Subject: [PATCH 03/15] Working short block coding and various warning removals in --phy_simulators --- cmake_targets/CMakeLists.txt | 13 +- openair1/PHY/CODING/TESTBENCH/ldpctest.c | 8 +- openair1/PHY/CODING/TESTBENCH/polartest.c | 83 +++-- .../PHY/CODING/TESTBENCH/smallblocktest.c | 169 ++++++++++ .../nrPolar_tools/nr_bitwise_operations.c | 6 +- .../CODING/nrPolar_tools/nr_polar_decoder.c | 308 ++---------------- .../nrPolar_tools/nr_polar_decoding_tools.c | 127 ++++---- .../PHY/CODING/nrPolar_tools/nr_polar_defs.h | 284 +++++++--------- .../CODING/nrPolar_tools/nr_polar_encoder.c | 14 +- .../nrPolar_tools/nr_polar_procedures.c | 42 ++- .../CODING/nrSmallBlock/decodeSmallBlock.c | 117 +++++++ .../PHY/CODING/nrSmallBlock/encodeSmall.c | 0 .../CODING/nrSmallBlock/encodeSmallBlock.c | 44 +++ .../CODING/nrSmallBlock/nr_small_block_defs.h | 134 ++++++++ openair1/PHY/CODING/nr_polar_init.c | 19 +- 15 files changed, 766 insertions(+), 602 deletions(-) create mode 100644 openair1/PHY/CODING/TESTBENCH/smallblocktest.c create mode 100644 openair1/PHY/CODING/nrSmallBlock/decodeSmallBlock.c delete mode 100644 openair1/PHY/CODING/nrSmallBlock/encodeSmall.c create mode 100644 openair1/PHY/CODING/nrSmallBlock/encodeSmallBlock.c create mode 100644 openair1/PHY/CODING/nrSmallBlock/nr_small_block_defs.h diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index c4e2399351..668c3acc2e 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1143,15 +1143,19 @@ set(PHY_POLARSRC ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_procedures.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_sequence_pattern.c ) +set(PHY_SMALLBLOCKSRC + ${OPENAIR1_DIR}/PHY/CODING/nrSmallBlock/encodeSmallBlock.c + ${OPENAIR1_DIR}/PHY/CODING/nrSmallBlock/decodeSmallBlock.c +) set(PHY_TURBOIF ${OPENAIR1_DIR}/PHY/CODING/coding_load.c - ) +) set(PHY_LDPCSRC ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_encoder.c ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_generate_coefficient.c - ) +) add_library(coding MODULE ${PHY_TURBOSRC} ) @@ -1326,6 +1330,7 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/TOOLS/time_meas.c ${OPENAIR1_DIR}/PHY/TOOLS/lut.c ${PHY_POLARSRC} + ${PHY_SMALLBLOCKSRC} ${PHY_LDPCSRC} ) @@ -1372,6 +1377,7 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/INIT/nr_init_ue.c # ${OPENAIR1_DIR}/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c ${PHY_POLARSRC} + ${PHY_SMALLBLOCKSRC} ${PHY_LDPCSRC} ) @@ -2558,6 +2564,9 @@ target_link_libraries (dlsim_tm4 add_executable(polartest ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/polartest.c) target_link_libraries(polartest SIMU PHY PHY_NR PHY_COMMON m ${ATLAS_LIBRARIES}) +add_executable(smallblocktest ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/smallblocktest.c) +target_link_libraries(smallblocktest SIMU PHY PHY_NR PHY_COMMON m ${ATLAS_LIBRARIES}) + add_executable(ldpctest ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/ldpctest.c) target_link_libraries(ldpctest SIMU PHY PHY_NR m ${ATLAS_LIBRARIES}) diff --git a/openair1/PHY/CODING/TESTBENCH/ldpctest.c b/openair1/PHY/CODING/TESTBENCH/ldpctest.c index 6db9548dbe..d8ba986175 100644 --- a/openair1/PHY/CODING/TESTBENCH/ldpctest.c +++ b/openair1/PHY/CODING/TESTBENCH/ldpctest.c @@ -382,12 +382,12 @@ int test_ldpc(short No_iteration, //Uncoded BER if (channel_output_fixed[j][i]<0) - channel_output_uncoded[j][i]=1; //QPSK demod - else - channel_output_uncoded[j][i]=0; + channel_output_uncoded[j][i]=1; //QPSK demod + else + channel_output_uncoded[j][i]=0; if (channel_output_uncoded[j][i] != channel_input[j][i-2*Zc]) - *errors_bit_uncoded = (*errors_bit_uncoded) + 1; + *errors_bit_uncoded = (*errors_bit_uncoded) + 1; } } // End segments diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index e4b4758493..72ef16907c 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -62,7 +62,6 @@ int main(int argc, char *argv[]) { int16_t nBitError = 0; // -1 = Decoding failed (All list entries have failed the CRC checks). uint32_t decoderState=0, blockErrorState=0; //0 = Success, -1 = Decoding failed, 1 = Block Error. uint16_t testLength = 0, coderLength = 0, blockErrorCumulative=0, bitErrorCumulative=0; - double timeEncoderCumulative = 0, timeDecoderCumulative = 0; uint8_t aggregation_level = 8, decoderListSize = 8, pathMetricAppr = 0, matlabDebug = 0; while ((arguments = getopt (argc, argv, "s:d:f:c:i:l:a:hqgm")) != -1) @@ -217,7 +216,7 @@ int main(int argc, char *argv[]) { memset(dci_estimation,0,sizeof(uint32_t)*4); printf("dci_estimation: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", dci_estimation[0], dci_estimation[1], dci_estimation[2], dci_estimation[3]); - nr_bit2byte_uint32_8_t(encoder_output, currentPtrDCI->encoderLength, encoder_outputByte); + nr_bit2byte_uint32_8(encoder_output, currentPtrDCI->encoderLength, encoder_outputByte); printf("[polartest] encoder_outputByte: "); for (int i = 0; i < currentPtrDCI->encoderLength; i++) printf("%d-", encoder_outputByte[i]); printf("\n"); @@ -257,7 +256,7 @@ int main(int argc, char *argv[]) { uint32_t testInputcrc2=0x00291880; uint8_t testInputCRC2[8]; - nr_crc_bit2bit_uint32_8_t(testInputCRC, 32, testInputCRC2); + nr_crc_bit2bit_uint32_8(testInputCRC, 32, testInputCRC2); printf("testInputCRC2: [0]->%x \t [1]->%x \t [2]->%x \t [3]->%x\n" " [4]->%x \t [5]->%x \t [6]->%x \t [7]->%x\n", testInputCRC2[0], testInputCRC2[1], testInputCRC2[2], testInputCRC2[3], @@ -339,7 +338,7 @@ int main(int argc, char *argv[]) { for (int i=0; ipayloadBits; i++) aPrioriArray[i] = NAN; for (SNR = SNRstart; SNR <= SNRstop; SNR += SNRinc) { - printf("SNR %f\n",SNR); + printf("SNR %f\n",SNR); SNR_lin = pow(10, SNR/10); for (itr = 1; itr <= iterations; itr++) { @@ -420,11 +419,11 @@ int main(int argc, char *argv[]) { uint8_t nr_pbch_interleaver[NR_POLAR_PBCH_PAYLOAD_BITS]; memset((void*)nr_pbch_interleaver,0, NR_POLAR_PBCH_PAYLOAD_BITS); nr_init_pbch_interleaver(nr_pbch_interleaver); - for (int i=0; i<=31;i++) + /*for (int i=0; i<=31;i++) printf("nr_pbch_interleaver[%d]=%d\n",i,nr_pbch_interleaver[i]); for (int i=0; i0x%08x\n", encoderOutput[1]);*/ //Bit-to-byte: - nr_bit2byte_uint32_8_t(encoderOutput, coderLength, encoderOutputByte); + nr_bit2byte_uint32_8(encoderOutput, coderLength, encoderOutputByte); //BPSK modulation for(int i=0; i 15) channelOutput_int16[i] = 127; - else if (channelOutput[i] < -16) channelOutput_int16[i] = -128; - else channelOutput_int16[i] = (int16_t) (8*channelOutput[i]); + if (channelOutput[i] > 15) + channelOutput_int16[i] = 127; + else if (channelOutput[i] < -16) + channelOutput_int16[i] = -128; + else + channelOutput_int16[i] = (int16_t) (8*channelOutput[i]); } - - } start_meas(&timeDecoder); @@ -466,44 +468,38 @@ int main(int argc, char *argv[]) { NR_POLAR_DECODER_LISTSIZE, aPrioriArray, NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION);*/ - if (decoder_int16==0) - decoderState = polar_decoder_aPriori(channelOutput, - estimatedOutput, - currentPtr, - NR_POLAR_DECODER_LISTSIZE, - NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION, - aPrioriArray); - else - decoderState = polar_decoder_int16(channelOutput_int16, - (uint64_t*)estimatedOutput, - currentPtr); - + if (decoder_int16 == 1) + decoderState = polar_decoder_int16(channelOutput_int16, + (uint64_t*) estimatedOutput, + currentPtr); + else + decoderState = polar_decoder_aPriori(channelOutput, + estimatedOutput, currentPtr, + NR_POLAR_DECODER_LISTSIZE, + NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION, + aPrioriArray); stop_meas(&timeDecoder); /*printf("testInput: [0]->0x%08x\n", testInput[0]); printf("estimatedOutput: [0]->0x%08x\n", estimatedOutput[0]);*/ - //calculate errors if (decoderState!=0) { blockErrorState=-1; nBitError=-1; } else { - for (int j = 0; j < currentPtr->payloadBits; j++) { - if (((estimatedOutput[0]>>j) & 1) != ((testInput[0]>>j) & 1)) nBitError++; + for (int j = 0; j < currentPtr->payloadBits; j++) { + if (((estimatedOutput[0]>>j) & 1) != ((testInput[0]>>j) & 1)) + nBitError++; // printf("bit %d: %d => %d\n",j,(testInput[0]>>j)&1,(estimatedOutput[0]>>j)&1); - } - - - if (nBitError>0) { - blockErrorState=1; - // printf("Error: Input %x, Output %x\n",testInput[0],estimatedOutput[0]); - } + } + if (nBitError>0) { + blockErrorState=1; + //printf("Error: Input %x, Output %x\n",testInput[0],estimatedOutput[0]); + } } //Iteration times are in microseconds. - timeEncoderCumulative+=(timeEncoder.diff/(cpu_freq_GHz*1000.0)); - timeDecoderCumulative+=(timeDecoder.diff/(cpu_freq_GHz*1000.0)); fprintf(logFile,",%f,%d,%d,%f,%f\n", SNR, nBitError, blockErrorState, (timeEncoder.diff/(cpu_freq_GHz*1000.0)), (timeDecoder.diff/(cpu_freq_GHz*1000.0))); @@ -521,17 +517,16 @@ int main(int argc, char *argv[]) { } //Calculate error statistics for the SNR. - printf("[ListSize=%d, Appr=%d] SNR=%+8.3f, BLER=%9.6f, BER=%12.9f, t_Encoder=%9.3fus, t_Decoder=%9.3fus\n", + printf("[ListSize=%d, Appr=%d] SNR=%+8.3f, BLER=%9.6f, BER=%12.9f, t_Encoder=%12.6fus, t_Decoder=%12.6fus\n", decoderListSize, pathMetricAppr, SNR, ((double)blockErrorCumulative/iterations), ((double)bitErrorCumulative / (iterations*testLength)), - (double)timeEncoder.diff/timeEncoder.trials/(cpu_freq_GHz*1000.0),(double)timeDecoder.diff/timeDecoder.trials/(cpu_freq_GHz*1000.0)); - //(timeEncoderCumulative/iterations),timeDecoderCumulative/iterations); + (double)timeEncoder.diff/timeEncoder.trials/(cpu_freq_GHz*1000.0), + (double)timeDecoder.diff/timeDecoder.trials/(cpu_freq_GHz*1000.0)); if (blockErrorCumulative==0 && bitErrorCumulative==0) break; blockErrorCumulative = 0; bitErrorCumulative = 0; - timeEncoderCumulative = 0; timeDecoderCumulative = 0; } print_meas(&timeEncoder,"polar_encoder",NULL,NULL); diff --git a/openair1/PHY/CODING/TESTBENCH/smallblocktest.c b/openair1/PHY/CODING/TESTBENCH/smallblocktest.c new file mode 100644 index 0000000000..7ffa3900a6 --- /dev/null +++ b/openair1/PHY/CODING/TESTBENCH/smallblocktest.c @@ -0,0 +1,169 @@ +#include "PHY/CODING/nrSmallBlock/nr_small_block_defs.h" +#include "SIMULATION/TOOLS/sim.h" +#include + +//#define DEBUG_SMALLBLOCKTEST + +signed char quantize(double D, double x, unsigned char B) +{ + double qxd; + short maxlev; + qxd = floor(x/D); + + maxlev = 1<<(B-1);//(char)(pow(2,B-1)); + + if (qxd <= -maxlev) + qxd = -maxlev; + else if (qxd >= maxlev) + qxd = maxlev-1; + + return((char)qxd); +} + +int main(int argc, char *argv[]) { + + time_stats_t timeEncoder,timeDecoder; + opp_enabled=1; + cpu_freq_GHz = get_cpu_freq_GHz(); + reset_meas(&timeEncoder); + reset_meas(&timeDecoder); + randominit(0); + + int arguments, iterations = 1000, matlabDebug = 0, messageLength = 11; + uint32_t testInput, encoderOutput, codingDifference, nBitError=0, blockErrorState = 0, blockErrorCumulative=0, bitErrorCumulative=0; + uint16_t estimatedOutput; + double SNRstart = -20.0, SNRstop = 5.0, SNRinc= 0.5; //dB + double SNR, SNR_lin, sigma; + double modulatedInput[NR_SMALL_BLOCK_CODED_BITS], channelOutput[NR_SMALL_BLOCK_CODED_BITS]; + int16_t channelOutput_int16[NR_SMALL_BLOCK_CODED_BITS]; + int8_t channelOutput_int8[NR_SMALL_BLOCK_CODED_BITS]; + unsigned char qbits=8; + + while ((arguments = getopt (argc, argv, "s:d:f:l:i:mhg")) != -1) + switch (arguments) + { + case 's': + SNRstart = atof(optarg); + break; + + case 'd': + SNRinc = atof(optarg); + break; + + case 'f': + SNRstop = atof(optarg); + break; + + case 'l': + messageLength = atoi(optarg); + break; + + case 'i': + iterations = atoi(optarg); + break; + + case 'm': + matlabDebug = 1; + //#define DEBUG_POLAR_MATLAB + break; + + case 'g': + iterations = 1; + SNRstart = -6.0; + SNRstop = -6.0; + messageLength = 11; + break; + + case 'h': + printf("./smallblocktest -s SNRstart -d SNRinc -f SNRstop -l messageLength -i iterations -m Matlab Debug\n"); + exit(-1); + + default: + perror("[smallblocktest.c] Problem at argument parsing with getopt"); + exit(-1); + } + + + uint16_t mask = 0x07ff >> (11-messageLength); + for (SNR = SNRstart; SNR <= SNRstop; SNR += SNRinc) { + printf("SNR %f\n",SNR); + SNR_lin = pow(10, SNR/10.0); + sigma = 1.0/sqrt(SNR_lin); + + for (int itr = 1; itr <= iterations; itr++) { + + //Generate random test input of length "messageLength" + testInput = 0; + for (int i = 1; i < messageLength; i++) { + testInput |= ( ((uint32_t) (rand()%2)) &1); + testInput<<=1; + } + testInput |= ( ((uint32_t) (rand()%2)) &1); + + //Encoding + start_meas(&timeEncoder); + encoderOutput = encodeSmallBlock((uint16_t*)&testInput, (uint8_t)messageLength); + stop_meas(&timeEncoder); + + for (int i=0; i>i) & 1 ) { + modulatedInput[i]=-1; + } else { + modulatedInput[i]=1; + } + + //AWGN + channelOutput[i] = modulatedInput[i] + ( gaussdouble(0.0,1.0) * ( 1/sqrt(SNR_lin) ) ); + + //Quantization + channelOutput_int8[i] = quantize(sigma/16.0, channelOutput[i], qbits); + } + + //Decoding + start_meas(&timeDecoder); + estimatedOutput = decodeSmallBlock(channelOutput_int8, (uint8_t)messageLength); + stop_meas(&timeDecoder); + +#ifdef DEBUG_SMALLBLOCKTEST + printf("[smallblocktest] Input = 0x%x, Output = 0x%x, DecoderOutput = 0x%x\n", testInput, encoderOutput, estimatedOutput); + for (int i=0;i<32;i++) + printf("[smallblocktest] Input[%d] = %d, Output[%d] = %d, Mask[%d] = %d\n", i, (testInput>>i)&1, i, (estimatedOutput>>i)&1, i, (mask>>i)&1); +#endif + + //Error Calculation + estimatedOutput &= mask; + codingDifference = ((uint32_t)estimatedOutput) ^ testInput; // Count the # of 1's in codingDifference by Brian Kernighan’s algorithm. + + //for (int i=0;i<32;i++) + //printf("[smallblocktest] Input[%d] = %d, Output[%d] = %d, codingDifference[%d]=%d, Mask[%d] = %d, bitError = %d\n", i, (testInput>>i)&1, i, (estimatedOutput>>i)&1, i, (codingDifference>>i)&1, i, (mask>>i)&1, nBitError); + + + for (nBitError = 0; codingDifference; nBitError++) + codingDifference &= codingDifference - 1; + + blockErrorState = (nBitError > 0) ? 1 : 0; + + blockErrorCumulative+=blockErrorState; + bitErrorCumulative+=nBitError; + + nBitError = 0; blockErrorState = 0; + } + + //Error statistics for the SNR; iteration times are in nanoseconds and microseconds, respectively. + printf("[smallblocktest] SNR=%+7.3f, BER=%9.6f, BLER=%9.6f, t_Encoder=%9.3fns, t_Decoder=%7.3fus\n", + SNR, + ((double)bitErrorCumulative / (iterations*messageLength)), + ((double)blockErrorCumulative/iterations), + ((double)timeEncoder.diff/timeEncoder.trials)/(cpu_freq_GHz), + ((double)timeDecoder.diff/timeDecoder.trials)/(cpu_freq_GHz*1000.0)); + + blockErrorCumulative=0; + bitErrorCumulative=0; + } + + print_meas(&timeEncoder, "smallblock_encoder", NULL, NULL); + print_meas(&timeDecoder, "smallblock_decoder", NULL, NULL); + + return (0); +} diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c b/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c index beabeead36..a5e78b6f2b 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c @@ -21,7 +21,7 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" -void nr_bit2byte_uint32_8_t(uint32_t *in, uint16_t arraySize, uint8_t *out) { +void nr_bit2byte_uint32_8(uint32_t *in, uint16_t arraySize, uint8_t *out) { uint8_t arrayInd = ceil(arraySize / 32.0); for (int i = 0; i < (arrayInd-1); i++) { for (int j = 0; j < 32; j++) { @@ -32,7 +32,7 @@ void nr_bit2byte_uint32_8_t(uint32_t *in, uint16_t arraySize, uint8_t *out) { for (int j = 0; j < arraySize - ((arrayInd-1) * 32); j++) out[j + ((arrayInd-1) * 32)] = (in[(arrayInd-1)] >> j) & 1; } -void nr_byte2bit_uint8_32_t(uint8_t *in, uint16_t arraySize, uint32_t *out) { +void nr_byte2bit_uint8_32(uint8_t *in, uint16_t arraySize, uint32_t *out) { uint8_t arrayInd = ceil(arraySize / 32.0); for (int i = 0; i < arrayInd; i++) { out[i]=0; @@ -44,7 +44,7 @@ void nr_byte2bit_uint8_32_t(uint8_t *in, uint16_t arraySize, uint32_t *out) { } } -void nr_crc_bit2bit_uint32_8_t(uint32_t *in, uint16_t arraySize, uint8_t *out) { +void nr_crc_bit2bit_uint32_8(uint32_t *in, uint16_t arraySize, uint8_t *out) { out[0]=0xff; out[1]=0xff; out[2]=0xff; diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c index 305a9c6266..b754bda1f9 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c @@ -39,12 +39,11 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "assertions.h" -int8_t polar_decoder( - double *input, - uint8_t *out, - t_nrPolar_paramsPtr polarParams, - uint8_t listSize, - uint8_t pathMetricAppr) +int8_t polar_decoder(double *input, + uint8_t *out, + t_nrPolar_paramsPtr polarParams, + uint8_t listSize, + uint8_t pathMetricAppr) { //Assumes no a priori knowledge. @@ -276,18 +275,18 @@ int8_t polar_decoder( /* * Return bits. */ - //nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out); + //nr_byte2bit_uint8_32(polarParams->nr_polar_A, polarParams->payloadBits, out); return(0); } int8_t polar_decoder_aPriori(double *input, - uint32_t *out, - t_nrPolar_paramsPtr polarParams, - uint8_t listSize, - uint8_t pathMetricAppr, - double *aPrioriPayload) + uint32_t *out, + t_nrPolar_paramsPtr polarParams, + uint8_t listSize, + uint8_t pathMetricAppr, + double *aPrioriPayload) { - uint8_t ***bit = nr_alloc_uint8_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); + uint8_t ***bit = nr_alloc_uint8_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); uint8_t **bitUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True uint8_t **llrUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True double ***llr = nr_alloc_double_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); @@ -528,269 +527,10 @@ int8_t polar_decoder_aPriori(double *input, /* * Return bits. */ - nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out); - - return(0); - -} - - - -int8_t polar_decoder_aPriori_timing(double *input, - uint32_t *out, - t_nrPolar_paramsPtr polarParams, - uint8_t listSize, - uint8_t pathMetricAppr, - double *aPrioriPayload, - double cpuFreqGHz, - FILE* logFile) -{ - - uint8_t ***bit = nr_alloc_uint8_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); - uint8_t **bitUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True - uint8_t **llrUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True - double ***llr = nr_alloc_double_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); - uint8_t **crcChecksum = nr_alloc_uint8_2D_array(polarParams->crcParityBits, 2*listSize); - double *pathMetric = malloc(sizeof(double)*(2*listSize)); - uint8_t *crcState = malloc(sizeof(uint8_t)*(2*listSize)); //0=False, 1=True - - for (int i=0; i<(2*listSize); i++) { - pathMetric[i] = 0; - crcState[i]=1; - } - for (int i=0; iN; i++) { - llrUpdated[i][polarParams->n]=1; - bitUpdated[i][0]=((polarParams->information_bit_pattern[i]+1) % 2); - } - - uint8_t **extended_crc_generator_matrix = malloc(polarParams->K * sizeof(uint8_t *)); //G_P3 - uint8_t **tempECGM = malloc(polarParams->K * sizeof(uint8_t *)); //G_P2 - for (int i = 0; i < polarParams->K; i++){ - extended_crc_generator_matrix[i] = malloc(polarParams->crcParityBits * sizeof(uint8_t)); - tempECGM[i] = malloc(polarParams->crcParityBits * sizeof(uint8_t)); - } - - for (int i=0; ipayloadBits; i++) { - for (int j=0; jcrcParityBits; j++) { - tempECGM[i][j]=polarParams->crc_generator_matrix[i][j]; - } - } - for (int i=polarParams->payloadBits; iK; i++) { - for (int j=0; jcrcParityBits; j++) { - if( (i-polarParams->payloadBits) == j ){ - tempECGM[i][j]=1; - } else { - tempECGM[i][j]=0; - } - } - } - - for (int i=0; iK; i++) { - for (int j=0; jcrcParityBits; j++) { - extended_crc_generator_matrix[i][j]=tempECGM[polarParams->interleaving_pattern[i]][j]; - } - } - - //The index of the last 1-valued bit that appears in each column. - uint16_t last1ind[polarParams->crcParityBits]; - for (int j=0; jcrcParityBits; j++) { - for (int i=0; iK; i++) { - if (extended_crc_generator_matrix[i][j]==1) last1ind[j]=i; - } - } - - double *d_tilde = malloc(sizeof(double) * polarParams->N); - nr_polar_rate_matching(input, d_tilde, polarParams->rate_matching_pattern, polarParams->K, polarParams->N, polarParams->encoderLength); - for (int j = 0; j < polarParams->N; j++) llr[j][polarParams->n][0]=d_tilde[j]; - - - /* - * SCL polar decoder. - */ - - uint32_t nonFrozenBit=0; - uint8_t currentListSize=1; - uint8_t decoderIterationCheck=0; - int16_t checkCrcBits=-1; - uint8_t listIndex[2*listSize], copyIndex; - - for (uint16_t currentBit=0; currentBitN; currentBit++){ - updateLLR(llr, llrUpdated, bit, bitUpdated, currentListSize, currentBit, 0, polarParams->N, (polarParams->n+1), pathMetricAppr); - if (polarParams->information_bit_pattern[currentBit]==0) { //Frozen bit. - updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit, pathMetricAppr); //approximation=0 --> 11b, approximation=1 --> 12 - } else { //Information or CRC bit. - if ( (polarParams->interleaving_pattern[nonFrozenBit] <= polarParams->payloadBits) && - (aPrioriPayload[polarParams->interleaving_pattern[nonFrozenBit]] == 0) ) { - //Information bit with known value of "0". - updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit, pathMetricAppr); - bitUpdated[currentBit][0]=1; //0=False, 1=True - } else if ( (polarParams->interleaving_pattern[nonFrozenBit] <= polarParams->payloadBits) && - (aPrioriPayload[polarParams->interleaving_pattern[nonFrozenBit]] == 1) ) { - //Information bit with known value of "1". - updatePathMetric(pathMetric, llr, currentListSize, 1, currentBit, pathMetricAppr); - for (uint8_t i=0; icrcParityBits); - } else { - updatePathMetric2(pathMetric, llr, currentListSize, currentBit, pathMetricAppr); - - for (int i = 0; i < currentListSize; i++) { - for (int j = 0; j < polarParams->N; j++) { - for (int k = 0; k < (polarParams->n+1); k++) { - bit[j][k][i+currentListSize]=bit[j][k][i]; - llr[j][k][i+currentListSize]=llr[j][k][i];}}} - for (int i = 0; i < currentListSize; i++) { - bit[currentBit][0][i]=0; - crcState[i+currentListSize]=crcState[i]; - } - for (int i = currentListSize; i < 2*currentListSize; i++) bit[currentBit][0][i]=1; - bitUpdated[currentBit][0]=1; - updateCrcChecksum2(crcChecksum, extended_crc_generator_matrix, currentListSize, nonFrozenBit, polarParams->crcParityBits); - currentListSize*=2; - - //Keep only the best "listSize" number of entries. - if (currentListSize > listSize) { - for (uint8_t i = 0; i < 2*listSize; i++) listIndex[i]=i; - nr_sort_asc_double_1D_array_ind(pathMetric, listIndex, currentListSize); - - //sort listIndex[listSize, ..., 2*listSize-1] in descending order. - uint8_t swaps, tempInd; - for (uint8_t i = 0; i < listSize; i++) { - swaps = 0; - for (uint8_t j = listSize; j < (2*listSize - i) - 1; j++) { - if (listIndex[j+1] > listIndex[j]) { - tempInd = listIndex[j]; - listIndex[j] = listIndex[j + 1]; - listIndex[j + 1] = tempInd; - swaps++; - } - } - if (swaps == 0) - break; - } - - //First, backup the best "listSize" number of entries. - for (int k=(listSize-1); k>0; k--) { - for (int i=0; iN; i++) { - for (int j=0; j<(polarParams->n+1); j++) { - bit[i][j][listIndex[(2*listSize-1)-k]]=bit[i][j][listIndex[k]]; - llr[i][j][listIndex[(2*listSize-1)-k]]=llr[i][j][listIndex[k]]; - } - } - } - for (int k=(listSize-1); k>0; k--) { - for (int i = 0; i < polarParams->crcParityBits; i++) { - crcChecksum[i][listIndex[(2*listSize-1)-k]] = crcChecksum[i][listIndex[k]]; - } - } - for (int k=(listSize-1); k>0; k--) crcState[listIndex[(2*listSize-1)-k]]=crcState[listIndex[k]]; - - //Copy the best "listSize" number of entries to the first indices. - for (int k = 0; k < listSize; k++) { - if (k > listIndex[k]) { - copyIndex = listIndex[(2*listSize-1)-k]; - } else { //Use the backup. - copyIndex = listIndex[k]; - } - for (int i = 0; i < polarParams->N; i++) { - for (int j = 0; j < (polarParams->n + 1); j++) { - bit[i][j][k] = bit[i][j][copyIndex]; - llr[i][j][k] = llr[i][j][copyIndex]; - } - } - } - for (int k = 0; k < listSize; k++) { - if (k > listIndex[k]) { - copyIndex = listIndex[(2*listSize-1)-k]; - } else { //Use the backup. - copyIndex = listIndex[k]; - } - for (int i = 0; i < polarParams->crcParityBits; i++) { - crcChecksum[i][k]=crcChecksum[i][copyIndex]; - } - } - for (int k = 0; k < listSize; k++) { - if (k > listIndex[k]) { - copyIndex = listIndex[(2*listSize-1)-k]; - } else { //Use the backup. - copyIndex = listIndex[k]; - } - crcState[k]=crcState[copyIndex]; - } - currentListSize = listSize; - } - } - - for (int i=0; icrcParityBits; i++) { - if (last1ind[i]==nonFrozenBit) { - checkCrcBits=i; - break; - } - } - - if ( checkCrcBits > (-1) ) { - for (uint8_t i = 0; i < currentListSize; i++) { - if (crcChecksum[checkCrcBits][i]==1) { - crcState[i]=0; //0=False, 1=True - } - } - } - - for (uint8_t i = 0; i < currentListSize; i++) decoderIterationCheck+=crcState[i]; - if (decoderIterationCheck==0) { - //perror("[SCL polar decoder] All list entries have failed the CRC checks."); - free(d_tilde); - free(pathMetric); - free(crcState); - nr_free_uint8_3D_array(bit, polarParams->N, (polarParams->n+1)); - nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1)); - nr_free_uint8_2D_array(crcChecksum, polarParams->crcParityBits); - return(-1); - } - - nonFrozenBit++; - decoderIterationCheck=0; - checkCrcBits=-1; - } - } - - for (uint8_t i = 0; i < 2*listSize; i++) listIndex[i]=i; - nr_sort_asc_double_1D_array_ind(pathMetric, listIndex, currentListSize); - - for (uint8_t i = 0; i < fmin(listSize, (pow(2,polarParams->crcCorrectionBits)) ); i++) { - if ( crcState[listIndex[i]] == 1 ) { - for (int j = 0; j < polarParams->N; j++) polarParams->nr_polar_U[j]=bit[j][0][listIndex[i]]; - - //Extract the information bits (û to ĉ) - nr_polar_info_bit_extraction(polarParams->nr_polar_U, polarParams->nr_polar_CPrime, polarParams->information_bit_pattern, polarParams->N); - - //Deinterleaving (ĉ to b) - nr_polar_deinterleaver(polarParams->nr_polar_CPrime, polarParams->nr_polar_B, polarParams->interleaving_pattern, polarParams->K); - - //Remove the CRC (â) - for (int j = 0; j < polarParams->payloadBits; j++) polarParams->nr_polar_A[j]=polarParams->nr_polar_B[j]; - - break; - } - } - - free(d_tilde); - free(pathMetric); - free(crcState); - nr_free_uint8_3D_array(bit, polarParams->N, (polarParams->n+1)); - nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1)); - nr_free_uint8_2D_array(crcChecksum, polarParams->crcParityBits); - nr_free_uint8_2D_array(extended_crc_generator_matrix, polarParams->K); - nr_free_uint8_2D_array(tempECGM, polarParams->K); - - /* - * Return bits. - */ - nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out); + nr_byte2bit_uint8_32(polarParams->nr_polar_A, polarParams->payloadBits, out); return(0); } - int8_t polar_decoder_dci(double *input, uint32_t *out, t_nrPolar_paramsPtr polarParams, @@ -798,7 +538,6 @@ int8_t polar_decoder_dci(double *input, uint8_t pathMetricAppr, uint16_t n_RNTI) { - uint8_t ***bit = nr_alloc_uint8_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); uint8_t **bitUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True uint8_t **llrUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True @@ -1035,7 +774,7 @@ int8_t polar_decoder_dci(double *input, /* * Return bits. */ - nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out); + nr_byte2bit_uint8_32(polarParams->nr_polar_A, polarParams->payloadBits, out); return(0); } @@ -1072,24 +811,20 @@ void init_polar_deinterleaver_table(t_nrPolar_params *polarParams) { } uint32_t polar_decoder_int16(int16_t *input, - uint64_t *out, - t_nrPolar_params *polarParams) + uint64_t *out, + t_nrPolar_params *polarParams) { - - - int16_t d_tilde[polarParams->N];// = malloc(sizeof(double) * polarParams->N); nr_polar_rate_matching_int16(input, d_tilde, polarParams->rate_matching_pattern, polarParams->K, polarParams->N, polarParams->encoderLength); for (int i=0;iN;i++) { - if (d_tilde[i]<-128) d_tilde[i]=-128; - else if (d_tilde[i]>127) d_tilde[i]=128; + if (d_tilde[i]<-128) d_tilde[i]=-128; + else if (d_tilde[i]>127) d_tilde[i]=127; } memcpy((void*)&polarParams->tree.root->alpha[0],(void*)&d_tilde[0],sizeof(int16_t)*polarParams->N); - generic_polar_decoder(polarParams,polarParams->tree.root); - + generic_polar_decoder(polarParams, polarParams->tree.root); //Extract the information bits (û to ĉ) uint64_t Cprime[4]={0,0,0,0}; @@ -1117,7 +852,6 @@ uint32_t polar_decoder_int16(int16_t *input, } } - int len=polarParams->payloadBits; //int len_mod64=len&63; int crclen = polarParams->crcParityBits; @@ -1160,9 +894,5 @@ uint32_t polar_decoder_int16(int16_t *input, out[0]=Ar; - return(crc^rxcrc); - - - } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c index bec322b946..6ac29eb50b 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c @@ -37,15 +37,15 @@ //#define DEBUG_NEW_IMPL 1 void updateLLR(double ***llr, - uint8_t **llrU, - uint8_t ***bit, - uint8_t **bitU, - uint8_t listSize, - uint16_t row, - uint16_t col, - uint16_t xlen, - uint8_t ylen, - uint8_t approximation) + uint8_t **llrU, + uint8_t ***bit, + uint8_t **bitU, + uint8_t listSize, + uint16_t row, + uint16_t col, + uint16_t xlen, + uint8_t ylen, + uint8_t approximation) { uint16_t offset = (xlen/(pow(2,(ylen-col-1)))); for (uint8_t i=0; itree.num_nodes=0; + polarParams->tree.root = add_nodes(polarParams->n,0,polarParams); +#ifdef DEBUG_NEW_IMPL + printf("root : left %p, right %p\n",polarParams->tree.root->left,polarParams->tree.root->right); +#endif +} - -decoder_node_t *new_decoder_node(int first_leaf_index,int level) { +decoder_node_t *new_decoder_node(int first_leaf_index, int level) { decoder_node_t *node=(decoder_node_t *)malloc(sizeof(decoder_node_t)); @@ -208,32 +208,34 @@ decoder_node_t *new_decoder_node(int first_leaf_index,int level) { node->beta = (int16_t*)malloc16(node->Nv*sizeof(int16_t)); memset((void*)node->beta,-1,node->Nv*sizeof(int16_t)); - return(node); } -decoder_node_t *add_nodes(int level,int first_leaf_index,t_nrPolar_params *pp) { +decoder_node_t *add_nodes(int level, int first_leaf_index, t_nrPolar_params *polarParams) { - int all_frozen_below=1; + int all_frozen_below = 1; int Nv = 1<tree.num_nodes,Nv,level); + printf("New node %d order %d, level %d\n",polarParams->tree.num_nodes,Nv,level); #endif - pp->tree.num_nodes++; + polarParams->tree.num_nodes++; if (level==0) { #ifdef DEBUG_NEW_IMPL - printf("leaf %d (%s)\n",first_leaf_index,pp->information_bit_pattern[first_leaf_index]==1 ? "information or crc" : "frozen"); + printf("leaf %d (%s)\n", first_leaf_index, polarParams->information_bit_pattern[first_leaf_index]==1 ? "information or crc" : "frozen"); #endif new_node->leaf=1; - new_node->all_frozen = pp->information_bit_pattern[first_leaf_index]==0 ? 1 : 0; + new_node->all_frozen = polarParams->information_bit_pattern[first_leaf_index]==0 ? 1 : 0; return new_node; // this is a leaf node } for (int i=0;iinformation_bit_pattern[i+first_leaf_index]>0) all_frozen_below=0; + if (polarParams->information_bit_pattern[i+first_leaf_index]>0) + all_frozen_below=0; } - if (all_frozen_below==0) new_node->left=add_nodes(level-1,first_leaf_index,pp); + + if (all_frozen_below==0) + new_node->left=add_nodes(level-1, first_leaf_index, polarParams); else { #ifdef DEBUG_NEW_IMPL printf("aggregating frozen bits %d ... %d at level %d (%s)\n",first_leaf_index,first_leaf_index+Nv-1,level,((first_leaf_index/Nv)&1)==0?"left":"right"); @@ -241,22 +243,14 @@ decoder_node_t *add_nodes(int level,int first_leaf_index,t_nrPolar_params *pp) { new_node->leaf=1; new_node->all_frozen=1; } - if (all_frozen_below==0) new_node->right=add_nodes(level-1,first_leaf_index+(Nv/2),pp); + if (all_frozen_below==0) + new_node->right=add_nodes(level-1,first_leaf_index+(Nv/2),polarParams); #ifdef DEBUG_NEW_IMPL printf("new_node (%d): first_leaf_index %d, left %p, right %p\n",Nv,first_leaf_index,new_node->left,new_node->right); -#endif - return(new_node); -} - - -void build_decoder_tree(t_nrPolar_params *pp) { - - pp->tree.num_nodes=0; - pp->tree.root = add_nodes(pp->n,0,pp); -#ifdef DEBUG_NEW_IMPL - printf("root : left %p, right %p\n",pp->tree.root->left,pp->tree.root->right); #endif + + return(new_node); } #if defined(__arm__) || defined(__aarch64__) @@ -271,7 +265,7 @@ void build_decoder_tree(t_nrPolar_params *pp) { #define _mm_subs_pi16(a,b) vsub_s16(a,b) #endif -void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) { +void applyFtoleft(t_nrPolar_params *pp, decoder_node_t *node) { int16_t *alpha_v=node->alpha; int16_t *alpha_l=node->left->alpha; int16_t *betal = node->left->beta; @@ -370,16 +364,16 @@ void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) { #endif { // equvalent scalar code to above, activated only on non x86/ARM architectures for (int i=0;iNv/2;i++) { - a=alpha_v[i]; - b=alpha_v[i+(node->Nv/2)]; - maska=a>>15; - maskb=b>>15; - absa=(a+maska)^maska; - absb=(b+maskb)^maskb; - minabs = absaNv/2)]; + maska=a>>15; + maskb=b>>15; + absa=(a+maska)^maska; + absb=(b+maskb)^maskb; + minabs = absaNv == 2) { // apply hard decision on left node betal[0] = (alpha_l[0]>0) ? -1 : 1; @@ -463,11 +457,7 @@ void applyGtoright(t_nrPolar_params *pp,decoder_node_t *node) { } } - -int16_t all1[16] = {1,1,1,1, - 1,1,1,1, - 1,1,1,1, - 1,1,1,1}; +int16_t all1[16] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; void computeBeta(t_nrPolar_params *pp,decoder_node_t *node) { @@ -504,38 +494,35 @@ void computeBeta(t_nrPolar_params *pp,decoder_node_t *node) { int ssr4len = node->Nv/2/8; register __m128i allones=*((__m128i*)all1); for (int i=0;iNv/2;i++) { - betav[i] = (betal[i] != betar[i]) ? 1 : -1; + betav[i] = (betal[i] != betar[i]) ? 1 : -1; } } } else memcpy((void*)&betav[0],betar,(node->Nv/2)*sizeof(int16_t)); memcpy((void*)&betav[node->Nv/2],betar,(node->Nv/2)*sizeof(int16_t)); - } -void generic_polar_decoder(t_nrPolar_params *pp,decoder_node_t *node) { - +void generic_polar_decoder(t_nrPolar_params *polarParams, decoder_node_t *node) { // Apply F to left - applyFtoleft(pp,node); + applyFtoleft(polarParams, node); // if left is not a leaf recurse down to the left - if (node->left->leaf==0) generic_polar_decoder(pp,node->left); + if (node->left->leaf==0) + generic_polar_decoder(polarParams, node->left); - applyGtoright(pp,node); - if (node->right->leaf==0) generic_polar_decoder(pp,node->right); + applyGtoright(polarParams, node); + if (node->right->leaf==0) generic_polar_decoder(polarParams, node->right); - computeBeta(pp,node); + computeBeta(polarParams, node); } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index bd056c3a18..76f1c322fe 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -54,8 +54,7 @@ #define NR_POLAR_AGGREGATION_LEVEL_8_PRIME 163 //uint16_t #define NR_POLAR_AGGREGATION_LEVEL_16_PRIME 167 //uint16_t -static const uint8_t nr_polar_subblock_interleaver_pattern[32] = { 0, 1, 2, 4, 3, 5, 6, 7, 8, 16, 9, 17, 10, 18, 11, 19, 12, 20, 13, 21, 14, 22, 15, 23, 24, 25, 26, 28, 27, 29, 30, 31 }; - +static const uint8_t nr_polar_subblock_interleaver_pattern[32] = {0,1,2,4,3,5,6,7,8,16,9,17,10,18,11,19,12,20,13,21,14,22,15,23,24,25,26,28,27,29,30,31}; #define Nmax 1024 #define nmax 10 @@ -112,7 +111,7 @@ struct nrPolar_params { uint8_t **G_N; uint64_t **G_N_tab; int groupsize; - int *rm_tab; + int *rm_tab; uint64_t cprime_tab0[32][256]; uint64_t cprime_tab1[32][256]; uint64_t B_tab0[32][256]; @@ -148,9 +147,9 @@ void polar_encoder_dci(uint32_t *in, uint16_t n_RNTI); void polar_encoder_fast(uint64_t *Aprime, - uint32_t *out, - int32_t crcmask, - t_nrPolar_paramsPtr polarParams); + uint32_t *out, + int32_t crcmask, + t_nrPolar_paramsPtr polarParams); int8_t polar_decoder(double *input, uint8_t *output, @@ -158,10 +157,6 @@ int8_t polar_decoder(double *input, uint8_t listSize, uint8_t pathMetricAppr); -uint32_t polar_decoder_int16(int16_t *input, - uint64_t *out, - t_nrPolar_params *polarParams); - int8_t polar_decoder_aPriori(double *input, uint32_t *output, t_nrPolar_paramsPtr polarParams, @@ -169,15 +164,6 @@ int8_t polar_decoder_aPriori(double *input, uint8_t pathMetricAppr, double *aPrioriPayload); -int8_t polar_decoder_aPriori_timing(double *input, - uint32_t *output, - t_nrPolar_paramsPtr polarParams, - uint8_t listSize, - uint8_t pathMetricAppr, - double *aPrioriPayload, - double cpuFreqGHz, - FILE* logFile); - int8_t polar_decoder_dci(double *input, uint32_t *out, t_nrPolar_paramsPtr polarParams, @@ -185,11 +171,28 @@ int8_t polar_decoder_dci(double *input, uint8_t pathMetricAppr, uint16_t n_RNTI); -void generic_polar_decoder(t_nrPolar_params *, - decoder_node_t *); +uint32_t polar_decoder_int16(int16_t *input, + uint64_t *out, + t_nrPolar_params *polarParams); + +void generic_polar_decoder(t_nrPolar_params *, decoder_node_t *); + +void applyFtoleft(t_nrPolar_params *polarParams, decoder_node_t *node); + +void applyGtoright(t_nrPolar_params *polarParams, decoder_node_t *node); + +void computeBeta(t_nrPolar_params *polarParams, decoder_node_t *node); + + +void build_decoder_tree(t_nrPolar_params *polarParams); + +decoder_node_t *new_decoder_node(int first_leaf_index, int level); + +decoder_node_t *add_nodes(int level, int first_leaf_index, t_nrPolar_params *polarParams); + -void build_decoder_tree(t_nrPolar_params *pp); void build_polar_tables(t_nrPolar_paramsPtr polarParams); + void init_polar_deinterleaver_table(t_nrPolar_params *polarParams); void nr_polar_init(t_nrPolar_paramsPtr *polarParams, @@ -216,168 +219,143 @@ const uint16_t* nr_polar_sequence_pattern(uint8_t n); * @param E * @param n_max */ uint32_t nr_polar_output_length(uint16_t K, - uint16_t E, - uint8_t n_max); + uint16_t E, + uint8_t n_max); void nr_polar_channel_interleaver_pattern(uint16_t *cip, - uint8_t I_BIL, - uint16_t E); + uint8_t I_BIL, + uint16_t E); void nr_polar_rate_matching_pattern(uint16_t *rmp, - uint16_t *J, - const uint8_t *P_i_, - uint16_t K, - uint16_t N, - uint16_t E); + uint16_t *J, + const uint8_t *P_i_, + uint16_t K, + uint16_t N, + uint16_t E); void nr_polar_rate_matching(double *input, - double *output, - uint16_t *rmp, - uint16_t K, - uint16_t N, - uint16_t E); + double *output, + uint16_t *rmp, + uint16_t K, + uint16_t N, + uint16_t E); void nr_polar_rate_matching_int16(int16_t *input, - int16_t *output, - uint16_t *rmp, - uint16_t K, - uint16_t N, - uint16_t E); + int16_t *output, + uint16_t *rmp, + uint16_t K, + uint16_t N, + uint16_t E); -void nr_polar_interleaving_pattern(uint16_t K, - uint8_t I_IL, - uint16_t *PI_k_); +void nr_polar_interleaving_pattern(uint16_t K, uint8_t I_IL, uint16_t *PI_k_); void nr_polar_info_bit_pattern(uint8_t *ibp, - int16_t *Q_I_N, - int16_t *Q_F_N, - uint16_t *J, - const uint16_t *Q_0_Nminus1, - uint16_t K, - uint16_t N, - uint16_t E, - uint8_t n_PC); + int16_t *Q_I_N, + int16_t *Q_F_N, + uint16_t *J, + const uint16_t *Q_0_Nminus1, + uint16_t K, + uint16_t N, + uint16_t E, + uint8_t n_PC); void nr_polar_info_bit_extraction(uint8_t *input, - uint8_t *output, - uint8_t *pattern, - uint16_t size); + uint8_t *output, + uint8_t *pattern, + uint16_t size); -void nr_bit2byte_uint32_8_t(uint32_t *in, - uint16_t arraySize, - uint8_t *out); +void nr_bit2byte_uint32_8(uint32_t *in, uint16_t arraySize, uint8_t *out); -void nr_byte2bit_uint8_32_t(uint8_t *in, - uint16_t arraySize, - uint32_t *out); +void nr_byte2bit_uint8_32(uint8_t *in, uint16_t arraySize, uint32_t *out); -void nr_crc_bit2bit_uint32_8_t(uint32_t *in, - uint16_t arraySize, - uint8_t *out); +void nr_crc_bit2bit_uint32_8(uint32_t *in, uint16_t arraySize, uint8_t *out); void nr_polar_bit_insertion(uint8_t *input, - uint8_t *output, - uint16_t N, - uint16_t K, - int16_t *Q_I_N, - int16_t *Q_PC_N, - uint8_t n_PC); + uint8_t *output, + uint16_t N, + uint16_t K, + int16_t *Q_I_N, + int16_t *Q_PC_N, + uint8_t n_PC); void nr_matrix_multiplication_uint8_1D_uint8_2D(uint8_t *matrix1, - uint8_t **matrix2, - uint8_t *output, - uint16_t row, - uint16_t col); + uint8_t **matrix2, + uint8_t *output, + uint16_t row, + uint16_t col); -uint8_t ***nr_alloc_uint8_3D_array(uint16_t xlen, - uint16_t ylen, - uint16_t zlen); +uint8_t ***nr_alloc_uint8_3D_array(uint16_t xlen, uint16_t ylen, uint16_t zlen); -uint8_t **nr_alloc_uint8_2D_array(uint16_t xlen, - uint16_t ylen); +uint8_t **nr_alloc_uint8_2D_array(uint16_t xlen, uint16_t ylen); -double ***nr_alloc_double_3D_array(uint16_t xlen, - uint16_t ylen, - uint16_t zlen); +double ***nr_alloc_double_3D_array(uint16_t xlen, uint16_t ylen, uint16_t zlen); -double **nr_alloc_double_2D_array(uint16_t xlen, - uint16_t ylen); +double **nr_alloc_double_2D_array(uint16_t xlen, uint16_t ylen); -void nr_free_double_3D_array(double ***input, - uint16_t xlen, - uint16_t ylen); - -void nr_free_double_2D_array(double **input, - uint16_t xlen); - -void nr_free_uint8_3D_array(uint8_t ***input, - uint16_t xlen, - uint16_t ylen); - -void nr_free_uint8_2D_array(uint8_t **input, - uint16_t xlen); - -void nr_sort_asc_double_1D_array_ind(double *matrix, - uint8_t *ind, - uint8_t len); - -void nr_sort_asc_int16_1D_array_ind(int32_t *matrix, - int *ind, - int len); +void nr_free_double_3D_array(double ***input, uint16_t xlen, uint16_t ylen); void nr_free_double_2D_array(double **input, uint16_t xlen); +void nr_free_uint8_3D_array(uint8_t ***input, uint16_t xlen, uint16_t ylen); + +void nr_free_uint8_2D_array(uint8_t **input, uint16_t xlen); + +void nr_sort_asc_double_1D_array_ind(double *matrix, uint8_t *ind, uint8_t len); + +void nr_sort_asc_int16_1D_array_ind(int32_t *matrix, int *ind, int len); + +void nr_free_double_2D_array(double **input, uint16_t xlen); void updateLLR(double ***llr, - uint8_t **llrU, - uint8_t ***bit, - uint8_t **bitU, - uint8_t listSize, - uint16_t row, - uint16_t col, - uint16_t xlen, - uint8_t ylen, - uint8_t approximation); + uint8_t **llrU, + uint8_t ***bit, + uint8_t **bitU, + uint8_t listSize, + uint16_t row, + uint16_t col, + uint16_t xlen, + uint8_t ylen, + uint8_t approximation); void updateBit(uint8_t ***bit, - uint8_t **bitU, - uint8_t listSize, - uint16_t row, - uint16_t col, - uint16_t xlen, - uint8_t ylen); + uint8_t **bitU, + uint8_t listSize, + uint16_t row, + uint16_t col, + uint16_t xlen, + uint8_t ylen); void updatePathMetric(double *pathMetric, - double ***llr, - uint8_t listSize, - uint8_t bitValue, - uint16_t row, - uint8_t approximation); + double ***llr, + uint8_t listSize, + uint8_t bitValue, + uint16_t row, + uint8_t approximation); void updatePathMetric2(double *pathMetric, - double ***llr, - uint8_t listSize, - uint16_t row, - uint8_t approximation); + double ***llr, + uint8_t listSize, + uint16_t row, + uint8_t approximation); void computeLLR(double ***llr, - uint16_t row, - uint16_t col, - uint8_t i, - uint16_t offset, - uint8_t approximation); + uint16_t row, + uint16_t col, + uint8_t i, + uint16_t offset, + uint8_t approximation); void updateCrcChecksum(uint8_t **crcChecksum, - uint8_t **crcGen, - uint8_t listSize, - uint32_t i2, - uint8_t len); + uint8_t **crcGen, + uint8_t listSize, + uint32_t i2, + uint8_t len); void updateCrcChecksum2(uint8_t **crcChecksum, - uint8_t **crcGen, - uint8_t listSize, - uint32_t i2, - uint8_t len); + uint8_t **crcGen, + uint8_t listSize, + uint32_t i2, + uint8_t len); uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits); @@ -386,24 +364,14 @@ uint8_t **crc11_generator_matrix(uint16_t payloadSizeBits); uint8_t **crc6_generator_matrix(uint16_t payloadSizeBits); //Also nr_polar_rate_matcher -static inline void nr_polar_interleaver(uint8_t *input, - uint8_t *output, - uint16_t *pattern, - uint16_t size) -{ - for (int i=0; ipayloadBits)>>8); #endif -nr_bit2byte_uint32_8_t((uint32_t*)&B, polarParams->K, polarParams->nr_polar_B);*/ +nr_bit2byte_uint32_8((uint32_t*)&B, polarParams->K, polarParams->nr_polar_B);*/ - nr_bit2byte_uint32_8_t((uint32_t*)in, polarParams->payloadBits, polarParams->nr_polar_A); + nr_bit2byte_uint32_8((uint32_t*)in, polarParams->payloadBits, polarParams->nr_polar_A); /* * Bytewise operations */ @@ -147,7 +147,7 @@ nr_bit2byte_uint32_8_t((uint32_t*)&B, polarParams->K, polarParams->nr_polar_B);* for (int i=0; i< polarParams->encoderLength;i++) printf("f[%d]=%d\n", i, polarParams->nr_polar_E[i]); #endif - nr_byte2bit_uint8_32_t(polarParams->nr_polar_E, polarParams->encoderLength, out); + nr_byte2bit_uint8_32(polarParams->nr_polar_E, polarParams->encoderLength, out); } void polar_encoder_dci(uint32_t *in, @@ -163,7 +163,7 @@ void polar_encoder_dci(uint32_t *in, * Bytewise operations */ //(a to a') - nr_bit2byte_uint32_8_t(in, polarParams->payloadBits, polarParams->nr_polar_A); + nr_bit2byte_uint32_8(in, polarParams->payloadBits, polarParams->nr_polar_A); for (int i=0; icrcParityBits; i++) polarParams->nr_polar_APrime[i]=1; for (int i=0; ipayloadBits; i++) polarParams->nr_polar_APrime[i+(polarParams->crcParityBits)]=polarParams->nr_polar_A[i]; #ifdef DEBUG_POLAR_ENCODER_DCI @@ -202,7 +202,7 @@ void polar_encoder_dci(uint32_t *in, } /* //(a to a') - nr_crc_bit2bit_uint32_8_t(in, polarParams->payloadBits, polarParams->nr_polar_aPrime); + nr_crc_bit2bit_uint32_8(in, polarParams->payloadBits, polarParams->nr_polar_aPrime); //Parity bits computation (p) polarParams->crcBit = crc24c(polarParams->nr_polar_aPrime, (polarParams->payloadBits+polarParams->crcParityBits)); #ifdef DEBUG_POLAR_ENCODER_DCI @@ -273,7 +273,7 @@ void polar_encoder_dci(uint32_t *in, /* * Return bits. */ - nr_byte2bit_uint8_32_t(polarParams->nr_polar_E, polarParams->encoderLength, out); + nr_byte2bit_uint8_32(polarParams->nr_polar_E, polarParams->encoderLength, out); #ifdef DEBUG_POLAR_ENCODER_DCI printf("[polar_encoder_dci] E: "); for (int i = 0; i < polarParams->encoderLength; i++) printf("%d-", polarParams->nr_polar_E[i]); diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c index 985266447b..fd7793ca79 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c @@ -33,12 +33,12 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" void nr_polar_bit_insertion(uint8_t *input, - uint8_t *output, - uint16_t N, - uint16_t K, - int16_t *Q_I_N, - int16_t *Q_PC_N, - uint8_t n_PC) + uint8_t *output, + uint16_t N, + uint16_t K, + int16_t *Q_I_N, + int16_t *Q_PC_N, + uint8_t n_PC) { uint16_t k=0; uint8_t flag; @@ -256,8 +256,13 @@ void nr_polar_info_bit_extraction(uint8_t *input, } -void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t *J, const uint8_t *P_i_, uint16_t K, uint16_t N, uint16_t E){ - +void nr_polar_rate_matching_pattern(uint16_t *rmp, + uint16_t *J, + const uint8_t *P_i_, + uint16_t K, + uint16_t N, + uint16_t E) +{ uint8_t i; uint16_t *d, *y, ind; d = (uint16_t *)malloc(sizeof(uint16_t) * N); @@ -293,8 +298,13 @@ void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t *J, const uint8_t *P } -void nr_polar_rate_matching(double *input, double *output, uint16_t *rmp, uint16_t K, uint16_t N, uint16_t E){ - +void nr_polar_rate_matching(double *input, + double *output, + uint16_t *rmp, + uint16_t K, + uint16_t N, + uint16_t E) +{ if (E>=N) { //repetition for (int i=0; i<=N-1; i++) output[i]=0; for (int i=0; i<=E-1; i++){ @@ -311,11 +321,15 @@ void nr_polar_rate_matching(double *input, double *output, uint16_t *rmp, uint16 output[rmp[i]]=input[i]; } } - } -void nr_polar_rate_matching_int16(int16_t *input, int16_t *output, uint16_t *rmp, uint16_t K, uint16_t N, uint16_t E){ - +void nr_polar_rate_matching_int16(int16_t *input, + int16_t *output, + uint16_t *rmp, + uint16_t K, + uint16_t N, + uint16_t E) +{ if (E>=N) { //repetition for (int i=0; i<=N-1; i++) output[i]=0; for (int i=0; i<=E-1; i++){ @@ -332,6 +346,4 @@ void nr_polar_rate_matching_int16(int16_t *input, int16_t *output, uint16_t *rmp output[rmp[i]]=input[i]; } } - } - diff --git a/openair1/PHY/CODING/nrSmallBlock/decodeSmallBlock.c b/openair1/PHY/CODING/nrSmallBlock/decodeSmallBlock.c new file mode 100644 index 0000000000..95237ea40b --- /dev/null +++ b/openair1/PHY/CODING/nrSmallBlock/decodeSmallBlock.c @@ -0,0 +1,117 @@ +/* + * 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 + */ + +/*!\file PHY/CODING/nrSmallBlock/decodeSmallBlock.c + * \brief + * \author Turker Yilmaz + * \date 2019 + * \version 0.1 + * \company EURECOM + * \email turker.yilmaz@eurecom.fr + * \note + * \warning +*/ + +#include "PHY/CODING/nrSmallBlock/nr_small_block_defs.h" +#include "assertions.h" +#include "PHY/sse_intrin.h" + +//#define DEBUG_DECODESMALLBLOCK + +uint16_t decodeSmallBlock(int8_t *in, uint8_t len){ + uint16_t out = 0; + + AssertFatal(len >= 3 && len <= 11, "[decodeSmallBlock] Message Length = %d (Small Block Coding is only defined for input lengths 3 to 11)", len); + + if(len<7) { + int16_t Rhat[NR_SMALL_BLOCK_CODED_BITS] = {0}, Rhatabs[NR_SMALL_BLOCK_CODED_BITS] = {0}; + uint16_t maxVal; + uint8_t maxInd = 0; + + for (int j = 0; j < NR_SMALL_BLOCK_CODED_BITS; ++j) + for (int k = 0; k < NR_SMALL_BLOCK_CODED_BITS; ++k) + Rhat[j] += in[k] * hadamard32InterleavedTransposed[j][k]; + +#if defined(__AVX2__) + for (int i = 0; i < NR_SMALL_BLOCK_CODED_BITS; i += 16) { + __m256i a15_a0 = _mm256_loadu_si256((__m256i*)&Rhat[i]); + a15_a0 = _mm256_abs_epi16(a15_a0); + _mm256_storeu_si256((__m256i*)(&Rhatabs[i]), a15_a0); + } +#else + for (int i = 0; i < NR_SMALL_BLOCK_CODED_BITS; i += 8) { + __m128i a7_a0 = _mm_loadu_si128((__m128i*)&Rhat[i]); + a7_a0 = _mm_abs_epi16(a7_a0); + _mm_storeu_si128((__m128i*)(&Rhatabs[i]), a7_a0); + } +#endif + maxVal = Rhatabs[0]; + for (int k = 1; k < NR_SMALL_BLOCK_CODED_BITS; ++k){ + if (Rhatabs[k] > maxVal){ + maxVal = Rhatabs[k]; + maxInd = k; + } + } + + out = properOrderedBasis[maxInd] | ( (Rhat[maxInd] > 0) ? (uint16_t)0 : (uint16_t)1 ); + +#ifdef DEBUG_DECODESMALLBLOCK + for (int k = 0; k < NR_SMALL_BLOCK_CODED_BITS; ++k) + printf("[decodeSmallBlock]Rhat[%d]=%d %d %d %d\n",k, Rhat[k], maxVal, maxInd, ((uint32_t)out>>k)&1); + printf("[decodeSmallBlock]0x%x 0x%x\n", out, properOrderedBasis[maxInd]); +#endif + + } else { + int8_t Dmatrix[NR_SMALL_BLOCK_CODED_BITS][NR_SMALL_BLOCK_CODED_BITS] = {0}; + int16_t DmatrixFHT[NR_SMALL_BLOCK_CODED_BITS][NR_SMALL_BLOCK_CODED_BITS] = {0}; + uint16_t maxVal; + uint8_t maxRow = 0, maxCol = 0; + + for (int j = 0; j < NR_SMALL_BLOCK_CODED_BITS; ++j) + for (int k = 0; k < NR_SMALL_BLOCK_CODED_BITS; ++k) + Dmatrix[j][k] = in[k] * maskD[j][k]; + + + for (int i = 0; i < NR_SMALL_BLOCK_CODED_BITS; ++i) + for (int j = 0; j < NR_SMALL_BLOCK_CODED_BITS; ++j) + for (int k = 0; k < NR_SMALL_BLOCK_CODED_BITS; ++k) + DmatrixFHT[i][j] += Dmatrix[i][k] * hadamard32InterleavedTransposed[j][k]; + + maxVal = abs(DmatrixFHT[0][0]); + for (int i = 0; i < NR_SMALL_BLOCK_CODED_BITS; ++i) + for (int j = 0; j < NR_SMALL_BLOCK_CODED_BITS; ++j) + if (abs(DmatrixFHT[i][j]) > maxVal){ + maxVal = abs(DmatrixFHT[i][j]); + maxRow = i; + maxCol = j; + } + + out = properOrderedBasisExtended[maxRow] | properOrderedBasis[maxCol] | ( (DmatrixFHT[maxRow][maxCol] > 0) ? (uint16_t)0 : (uint16_t)1 ); + +#ifdef DEBUG_DECODESMALLBLOCK + for (int k = 0; k < NR_SMALL_BLOCK_CODED_BITS; ++k) + printf("[decodeSmallBlock]maxRow = %d maxCol = %d out[%d]=%d\n", maxRow, maxCol, k, ((uint32_t)out>>k)&1); +#endif + + } + + return out; +} diff --git a/openair1/PHY/CODING/nrSmallBlock/encodeSmall.c b/openair1/PHY/CODING/nrSmallBlock/encodeSmall.c deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/openair1/PHY/CODING/nrSmallBlock/encodeSmallBlock.c b/openair1/PHY/CODING/nrSmallBlock/encodeSmallBlock.c new file mode 100644 index 0000000000..8358bd270b --- /dev/null +++ b/openair1/PHY/CODING/nrSmallBlock/encodeSmallBlock.c @@ -0,0 +1,44 @@ +/* + * 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 + */ + +/*!\file PHY/CODING/nrSmallBlock/encodeSmallBlock.c + * \brief + * \author Turker Yilmaz + * \date 2019 + * \version 0.1 + * \company EURECOM + * \email turker.yilmaz@eurecom.fr + * \note + * \warning +*/ + +#include "PHY/CODING/nrSmallBlock/nr_small_block_defs.h" + +//input = [0 ... 0 c_K-1 ... c_2 c_1 c_0] +//output = [d_31 d_30 ... d_2 d_1 d_0] +uint32_t encodeSmallBlock(uint16_t *in, uint8_t len){ + uint32_t out = 0; + for (uint16_t i=0; i 0) + out^=nrSmallBlockBasis[i]; + + return out; +} diff --git a/openair1/PHY/CODING/nrSmallBlock/nr_small_block_defs.h b/openair1/PHY/CODING/nrSmallBlock/nr_small_block_defs.h new file mode 100644 index 0000000000..50559aa0d2 --- /dev/null +++ b/openair1/PHY/CODING/nrSmallBlock/nr_small_block_defs.h @@ -0,0 +1,134 @@ +/* + * 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 + */ + +/*!\file PHY/CODING/nrSmallBlock/nr_small_block_defs.h + * \brief + * \author Turker Yilmaz + * \date 2019 + * \version 0.1 + * \company EURECOM + * \email turker.yilmaz@eurecom.fr + * \note + * \warning +*/ + +#ifndef __NR_SMALL_BLOCK_DEFS__H__ +#define __NR_SMALL_BLOCK_DEFS__H__ + +#include +#include +#include +#include +#include + +#define NR_SMALL_BLOCK_CODED_BITS 32 + +#define L1d_CLS 64 + +uint32_t encodeSmallBlock(uint16_t *in, uint8_t len); + +uint16_t decodeSmallBlock(int8_t *in, uint8_t len); + +static const uint32_t nrSmallBlockBasis[11] = {0xFFFFFFFF, 0x4BA5A933, 0x7D910E5A, 0x6D26339C, 0x71C7C3E0, + 0x7E0FFC00, 0x731D8E64, 0x6B44F5B0, 0x7DC218EC, 0x4DA1B746, 0x42F0FFFF}; + +static const uint16_t properOrderedBasis[32] = {0x0000, 0x0002, 0x0004, 0x0006, 0x0008, 0x000A, 0x000C, 0x000E, 0x0010, 0x0012, + 0x0014, 0x0016, 0x0018, 0x001A, 0x001C, 0x001E, 0x0020, 0x0022, 0x0024, 0x0026, + 0x0028, 0x002A, 0x002C, 0x002E, 0x0030, 0x0032, 0x0034, 0x0036, 0x0038, 0x003A, 0x003C, 0x003E}; + +static const uint16_t properOrderedBasisExtended[32] = {0x0000, 0x0040, 0x0080, 0x00C0, 0x0100, 0x0140, 0x0180, 0x01C0, 0x0200, 0x0240, + 0x0280, 0x02C0, 0x0300, 0x0340, 0x0380, 0x03C0, 0x0400, 0x0440, 0x0480, 0x04C0, + 0x0500, 0x0540, 0x0580, 0x05C0, 0x0600, 0x0640, 0x0680, 0x06C0, 0x0700, 0x0740, 0x0780, 0x07C0}; + +static const int8_t hadamard32InterleavedTransposed[32][32] __attribute__ ((aligned(32))) = { + {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, + {-1,-1,1,1,-1,-1,1,1,-1,1,1,-1,1,-1,1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,1,1,-1,1}, + {1,-1,1,-1,-1,1,-1,1,1,-1,-1,-1,1,1,1,1,-1,1,1,1,-1,1,1,-1,-1,1,-1,-1,-1,-1,-1,1}, + {-1,1,1,-1,1,-1,-1,1,-1,-1,-1,1,1,-1,1,-1,1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,-1,1,1}, + {1,1,-1,-1,-1,1,1,-1,-1,-1,1,1,-1,-1,1,1,1,-1,-1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1}, + {-1,-1,-1,-1,1,-1,1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,1,1,1,1,1,-1,1,-1,-1,1,1,-1,1,1}, + {1,-1,-1,1,1,1,-1,-1,-1,1,-1,-1,-1,-1,1,1,-1,-1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,1,1}, + {-1,1,-1,1,-1,-1,-1,-1,1,1,-1,1,-1,1,1,-1,1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,1,-1,1}, + {1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,-1,-1,1,1,1,-1,-1,-1,1}, + {-1,-1,1,1,-1,1,-1,-1,1,-1,1,-1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,1,-1,1,-1,-1,-1,1,1}, + {1,-1,1,-1,-1,-1,1,-1,-1,1,-1,-1,1,1,-1,-1,1,-1,-1,1,-1,1,-1,1,1,1,-1,-1,1,1,1,1}, + {-1,1,1,-1,1,1,1,-1,1,1,-1,1,1,-1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,-1,1,1,1,-1,1}, + {1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,1,1,-1,-1,-1,1,1,1}, + {-1,-1,-1,-1,1,1,-1,1,-1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,-1,1,-1,-1,-1,1,-1,1,-1,1}, + {1,-1,-1,1,1,-1,1,1,1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1}, + {-1,1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,-1,1,-1,1,-1,1,-1,1,1}, + {1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1}, + {-1,-1,1,1,-1,-1,1,1,-1,1,-1,1,-1,1,-1,1,1,-1,1,-1,1,-1,1,-1,-1,1,-1,1,-1,-1,1,1}, + {1,-1,1,-1,-1,1,-1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,1,1,-1,-1,-1,1,1,1,1,1,1}, + {-1,1,1,-1,1,-1,-1,1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,-1,-1,-1,1,1,1,1,1,-1,1,1,-1,1}, + {1,1,-1,-1,-1,1,1,-1,-1,-1,-1,-1,1,1,-1,-1,-1,1,1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1}, + {-1,-1,-1,-1,1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,1,1,-1,-1,1,1,1,-1,1,1,1,-1,-1,1,-1,1}, + {1,-1,-1,1,1,1,-1,-1,-1,1,1,1,1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,-1,-1,-1,1,-1,-1,1}, + {-1,1,-1,1,-1,-1,-1,-1,1,1,1,-1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,1,-1,1,-1,1,1,-1,1,1}, + {1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,1,1,-1,-1,-1,-1,-1,-1,1,1,1,1}, + {-1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,-1,1,1,-1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,1,1,1,-1,1}, + {1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,-1,-1,1,1,-1,1,1,-1,-1,1,-1,1,1,-1,1,1,-1,-1,-1,1}, + {-1,1,1,-1,1,1,1,-1,1,1,1,-1,-1,1,1,-1,1,1,-1,-1,-1,-1,-1,-1,-1,1,1,-1,-1,-1,1,1}, + {1,1,-1,-1,-1,-1,-1,1,1,1,-1,-1,1,1,1,1,1,-1,-1,-1,1,-1,-1,-1,1,-1,1,1,1,-1,-1,1}, + {-1,-1,-1,-1,1,1,-1,1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,1,1,-1,1,-1,1,1,-1,1,-1,1,1}, + {1,-1,-1,1,1,-1,1,1,1,-1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1}, + {-1,1,-1,1,-1,1,1,1,-1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,-1,1,-1,-1,1,1,-1,1,-1,1,-1,1} +}; + +static const int8_t maskD[32][32] __attribute__ ((aligned(32))) = { + {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, + {1,1,-1,1,1,-1,-1,1,1,-1,-1,-1,1,1,1,-1,-1,1,-1,-1,-1,1,1,1,-1,-1,1,1,-1,-1,-1,1}, + {1,1,1,1,-1,-1,1,-1,-1,1,-1,1,-1,-1,-1,-1,1,1,-1,1,1,1,-1,1,-1,-1,1,-1,1,-1,-1,1}, + {1,1,-1,1,-1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,1,-1,1,1,-1,-1,1,-1,1,1,1,1,-1,-1,1,1,1}, + {1,1,-1,-1,1,-1,-1,-1,1,1,1,-1,-1,1,1,1,1,-1,1,1,1,1,-1,-1,-1,1,-1,-1,-1,-1,-1,1}, + {1,1,1,-1,1,1,1,-1,1,-1,-1,1,-1,1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,1,-1,-1,-1,1,1,1,1}, + {1,1,-1,-1,-1,1,-1,1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,1,-1,1,-1,-1,1,-1,1,1,1}, + {1,1,1,-1,-1,-1,1,1,-1,-1,1,1,1,-1,-1,1,-1,-1,1,-1,-1,1,1,-1,-1,1,-1,1,1,-1,-1,1}, + {1,-1,-1,1,1,1,-1,1,-1,-1,-1,1,-1,-1,1,-1,-1,1,1,1,1,-1,1,-1,-1,1,-1,-1,1,1,-1,1}, + {1,-1,1,1,1,-1,1,1,-1,1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,-1,1,-1,-1,-1,-1,-1,1,1}, + {1,-1,-1,1,-1,-1,-1,-1,1,-1,1,1,1,1,-1,1,-1,1,-1,1,1,-1,-1,-1,1,-1,-1,1,1,-1,1,1}, + {1,-1,1,1,-1,1,1,-1,1,1,-1,-1,1,1,-1,-1,1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,-1,1,-1,1}, + {1,-1,1,-1,1,-1,1,-1,-1,-1,-1,-1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,1,1,1,1,1,-1,-1,1,1}, + {1,-1,-1,-1,1,1,-1,-1,-1,1,1,1,1,-1,1,1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,1,1,1,1,-1,1}, + {1,-1,1,-1,-1,1,1,1,1,-1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,1,1,-1,-1,1,-1,-1,1,-1,1}, + {1,-1,-1,-1,-1,-1,-1,1,1,1,-1,1,-1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,1,1,1,-1,1,-1,1,1}, + {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,-1,1,1,1,1,-1,1}, + {-1,-1,1,-1,-1,1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,-1,-1,1,-1,-1,-1,-1,1,1,1,-1,-1,1,1}, + {-1,-1,-1,-1,1,1,-1,1,1,-1,1,-1,1,1,1,1,1,1,-1,1,-1,-1,1,-1,-1,1,1,-1,1,-1,1,1}, + {-1,-1,1,-1,1,-1,1,1,1,1,-1,1,1,1,1,-1,-1,1,1,-1,1,-1,1,-1,1,-1,1,-1,-1,1,-1,1}, + {-1,-1,1,1,-1,1,1,1,-1,-1,-1,1,1,-1,-1,-1,1,-1,1,1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,1}, + {-1,-1,-1,1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,1,-1,1}, + {-1,-1,1,1,1,-1,1,-1,1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,-1,-1,1,1,1,-1,1,-1,1,-1,1}, + {-1,-1,-1,1,1,1,-1,-1,1,1,-1,-1,-1,1,1,-1,-1,-1,1,-1,1,-1,-1,1,-1,-1,-1,1,1,-1,1,1}, + {-1,1,1,-1,-1,-1,1,-1,1,1,1,-1,1,1,-1,1,-1,1,1,1,-1,1,-1,1,-1,-1,-1,-1,1,1,1,1}, + {-1,1,-1,-1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,-1,-1,-1,1}, + {-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,1,1,1,1,1,-1,1,1,-1,-1,1}, + {-1,1,-1,-1,1,-1,-1,1,-1,-1,1,1,-1,-1,1,1,1,1,1,-1,1,1,1,1,-1,-1,-1,1,-1,1,1,1}, + {-1,1,-1,1,-1,1,-1,1,1,1,1,1,-1,1,-1,1,-1,-1,1,1,-1,1,1,-1,1,-1,1,1,-1,-1,-1,1}, + {-1,1,1,1,-1,-1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,-1,-1,1,1,1,-1,-1,1,1,1,1,1,1,1}, + {-1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,1,1,1,}, + {-1,1,1,1,1,1,1,-1,-1,-1,1,-1,1,-1,1,1,1,-1,1,-1,1,1,-1,-1,1,-1,1,-1,1,-1,-1,1} +}; + + + +#endif + diff --git a/openair1/PHY/CODING/nr_polar_init.c b/openair1/PHY/CODING/nr_polar_init.c index 93bcdecd6e..946657a905 100644 --- a/openair1/PHY/CODING/nr_polar_init.c +++ b/openair1/PHY/CODING/nr_polar_init.c @@ -42,9 +42,9 @@ static int intcmp(const void *p1,const void *p2) { } void nr_polar_init(t_nrPolar_paramsPtr *polarParams, - int8_t messageType, - uint16_t messageLength, - uint8_t aggregation_level) + int8_t messageType, + uint16_t messageLength, + uint8_t aggregation_level) { t_nrPolar_paramsPtr currentPtr = *polarParams; uint16_t aggregation_prime = nr_polar_aggregation_prime(aggregation_level); @@ -63,7 +63,8 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, if (newPolarInitNode != NULL) { newPolarInitNode->idx = (messageType * messageLength * aggregation_prime); - newPolarInitNode->nextPtr = NULL; + newPolarInitNode->nextPtr = (t_nrPolar_params *)NULL; + //printf("newPolarInitNode->idx %d, (%d,%d,%d:%d)\n",newPolarInitNode->idx,messageType,messageLength,aggregation_prime,aggregation_level); if (messageType == 0) { //PBCH @@ -186,9 +187,7 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, currentPtr = currentPtr->nextPtr; } currentPtr->nextPtr= newPolarInitNode; - printf("Adding new polarParams entry to list index %d,%p\n", - newPolarInitNode->idx, - currentPtr->nextPtr); + printf("Adding new polarParams entry to list index %d,%p\n", newPolarInitNode->idx, currentPtr->nextPtr); return; } @@ -209,9 +208,9 @@ void nr_polar_print_polarParams(t_nrPolar_paramsPtr polarParams) } t_nrPolar_paramsPtr nr_polar_params (t_nrPolar_paramsPtr polarParams, - int8_t messageType, - uint16_t messageLength, - uint8_t aggregation_level) + int8_t messageType, + uint16_t messageLength, + uint8_t aggregation_level) { t_nrPolar_paramsPtr currentPtr = NULL; From f070801d0ae33622a3795aee7dac505e623bd309 Mon Sep 17 00:00:00 2001 From: yilmazt Date: Tue, 12 Mar 2019 15:36:24 +0100 Subject: [PATCH 04/15] AVX512F intrinsics added for shortBlockCoding --- .../nrPolar_tools/nr_polar_decoding_tools.c | 4 +- .../CODING/nrSmallBlock/decodeSmallBlock.c | 49 +++++++++++++++++-- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c index 6ac29eb50b..9f8fac24c5 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c @@ -362,7 +362,7 @@ void applyFtoleft(t_nrPolar_params *pp, decoder_node_t *node) { else #endif - { // equvalent scalar code to above, activated only on non x86/ARM architectures + { // equivalent scalar code to above, activated only on non x86/ARM architectures for (int i=0;iNv/2;i++) { a=alpha_v[i]; b=alpha_v[i+(node->Nv/2)]; @@ -442,7 +442,7 @@ void applyGtoright(t_nrPolar_params *pp,decoder_node_t *node) { } else #endif - {// equvalent scalar code to above, activated only on non x86/ARM architectures or Nv=1,2 + {// equivalent scalar code to above, activated only on non x86/ARM architectures or Nv=1,2 for (int i=0;iNv/2;i++) { alpha_r[i] = alpha_v[i+(node->Nv/2)] - (betal[i]*alpha_v[i]); } diff --git a/openair1/PHY/CODING/nrSmallBlock/decodeSmallBlock.c b/openair1/PHY/CODING/nrSmallBlock/decodeSmallBlock.c index 95237ea40b..38b9a6b13c 100644 --- a/openair1/PHY/CODING/nrSmallBlock/decodeSmallBlock.c +++ b/openair1/PHY/CODING/nrSmallBlock/decodeSmallBlock.c @@ -36,6 +36,9 @@ //#define DEBUG_DECODESMALLBLOCK +//input = [d̂_0] [d̂_1] [d̂_2] ... [d̂_31] +//output = [? ... ? ĉ_K-1 ... ĉ_2 ĉ_1 ĉ_0] + uint16_t decodeSmallBlock(int8_t *in, uint8_t len){ uint16_t out = 0; @@ -80,23 +83,58 @@ uint16_t decodeSmallBlock(int8_t *in, uint8_t len){ #endif } else { + uint8_t maxRow = 0, maxCol = 0; + +#if defined(__AVX2__) + int16_t maxVal = 0; + int DmatrixElementVal = 0; + int8_t DmatrixElement[NR_SMALL_BLOCK_CODED_BITS] = {0}; + __m256i _in_256 = _mm256_loadu_si256 ((__m256i*)&in[0]); + __m256i _maskD_256, _Dmatrixj_256, _maskH_256, _DmatrixElement_256; + for (int j = 0; j < ( 1<<(len-6) ); ++j) { + _maskD_256 = _mm256_loadu_si256 ((__m256i*)(&maskD[j][0])); + _Dmatrixj_256 = _mm256_sign_epi8 (_in_256, _maskD_256); + for (int k = 0; k < NR_SMALL_BLOCK_CODED_BITS; ++k) { + _maskH_256 = _mm256_loadu_si256 ((__m256i*)(&hadamard32InterleavedTransposed[k][0])); + _DmatrixElement_256 = _mm256_sign_epi8 (_Dmatrixj_256, _maskH_256); +#if defined(__AVX512F__) + DmatrixElementVal = _mm512_reduce_add_epi32 ( + _mm512_add_epi32( + _mm512_cvtepi8_epi32 (_mm256_extracti128_si256 (_DmatrixElement_256, 1)), + _mm512_cvtepi8_epi32 (_mm256_castsi256_si128 (_DmatrixElement_256)) + ) + ); +#else + _mm256_storeu_si256((__m256i*)(&DmatrixElement[0]), _DmatrixElement_256); + for (int i = 0; i < NR_SMALL_BLOCK_CODED_BITS; ++i) + DmatrixElementVal += DmatrixElement[i]; +#endif + if (abs(DmatrixElementVal) > abs(maxVal)){ + maxVal = DmatrixElementVal; + maxRow = j; + maxCol = k; + } + DmatrixElementVal=0; + } + } + out = properOrderedBasisExtended[maxRow] | properOrderedBasis[maxCol] | ( (maxVal > 0) ? (uint16_t)0 : (uint16_t)1 ); +#else int8_t Dmatrix[NR_SMALL_BLOCK_CODED_BITS][NR_SMALL_BLOCK_CODED_BITS] = {0}; int16_t DmatrixFHT[NR_SMALL_BLOCK_CODED_BITS][NR_SMALL_BLOCK_CODED_BITS] = {0}; uint16_t maxVal; - uint8_t maxRow = 0, maxCol = 0; + uint8_t rowLimit = 1<<(len-6); - for (int j = 0; j < NR_SMALL_BLOCK_CODED_BITS; ++j) + for (int j = 0; j < ( rowLimit ); ++j) for (int k = 0; k < NR_SMALL_BLOCK_CODED_BITS; ++k) Dmatrix[j][k] = in[k] * maskD[j][k]; - - for (int i = 0; i < NR_SMALL_BLOCK_CODED_BITS; ++i) + for (int i = 0; i < ( rowLimit ); ++i) for (int j = 0; j < NR_SMALL_BLOCK_CODED_BITS; ++j) for (int k = 0; k < NR_SMALL_BLOCK_CODED_BITS; ++k) DmatrixFHT[i][j] += Dmatrix[i][k] * hadamard32InterleavedTransposed[j][k]; maxVal = abs(DmatrixFHT[0][0]); - for (int i = 0; i < NR_SMALL_BLOCK_CODED_BITS; ++i) + for (int i = 0; i < ( rowLimit ); ++i) for (int j = 0; j < NR_SMALL_BLOCK_CODED_BITS; ++j) if (abs(DmatrixFHT[i][j]) > maxVal){ maxVal = abs(DmatrixFHT[i][j]); @@ -105,6 +143,7 @@ uint16_t decodeSmallBlock(int8_t *in, uint8_t len){ } out = properOrderedBasisExtended[maxRow] | properOrderedBasis[maxCol] | ( (DmatrixFHT[maxRow][maxCol] > 0) ? (uint16_t)0 : (uint16_t)1 ); +#endif #ifdef DEBUG_DECODESMALLBLOCK for (int k = 0; k < NR_SMALL_BLOCK_CODED_BITS; ++k) From 3554fb9b006f6662e50c84257a0720739fa6fda9 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Tue, 26 Mar 2019 13:48:20 +0100 Subject: [PATCH 05/15] adding testcases for smallblocktest --- cmake_targets/autotests/test_case_list.xml | 25 +++++++++++++++++++++- cmake_targets/build_oai | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml index 2f66c6af34..aa1db28d75 100644 --- a/cmake_targets/autotests/test_case_list.xml +++ b/cmake_targets/autotests/test_case_list.xml @@ -1076,7 +1076,30 @@ segmentation fault|assertion|exiting|fatal 3 - + + + execution + shortblocktest Test cases. (Test1: 3 bits), + (Test2: 6 bits) + (Test3: 7 bits) + (Test4: 11 bits) + + + $OPENAIR_DIR/cmake_targets/build_oai + --phy_simulators -c + $OPENAIR_DIR/cmake_targets/autotests/tools/free_mem.bash + + $OPENAIR_DIR/targets/bin/smallblocktest.Rel15 + -l 3 + -l 6 + -l 7 + -l 11 + smallblocktest.test1 smallblocktest.test2 smallblocktest.test3 smallblocktest.test3 + BLER= 0.000000 + segmentation fault|assertion|exiting|fatal + 3 + + execution diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index 01ab01f0a7..69aafbc41b 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -696,7 +696,7 @@ function main() { echo_info "Compiling unitary tests simulators" # TODO: fix: dlsim_tm4 pucchsim prachsim pdcchsim pbchsim mbmssim #simlist="dlsim_tm4 dlsim ulsim pucchsim prachsim pdcchsim pbchsim mbmssim" - simlist="dlsim ulsim polartest ldpctest nr_pbchsim nr_dlschsim nr_dlsim" + simlist="dlsim ulsim polartest ldpctest smallblocktest nr_pbchsim nr_dlschsim nr_dlsim" for f in $simlist ; do compilations \ phy_simulators $f \ From 27ef071b8119e2ddfdfec2195479e8da483e23f4 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Fri, 12 Apr 2019 07:57:34 +0200 Subject: [PATCH 06/15] polartest changes for DCI parameters --- openair1/PHY/CODING/TESTBENCH/polartest.c | 4 ++++ openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index ddcc3ce826..108aacd96f 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -142,6 +142,10 @@ int main(int argc, char *argv[]) { if (polarMessageType == 0) { //PBCH } else if (polarMessageType == 1) { //DCI + if (aggregation_level != 16 && aggregation_level!=8 && aggregation_level != 4 && aggregation_level !=2 && aggregation_level !=1) { + printf("Illegal aggregation level %d\n",aggregation_level); + exit(-1); + } coderLength = 108*aggregation_level; } else if (polarMessageType == -1) { //UCI printf("UCI testing not supported yet\n"); diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c index e78f3a85b7..26832fd70c 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c @@ -88,7 +88,7 @@ uint32_t nr_polar_output_length(uint16_t K, if (n>n_2) n=n_2; if (n Date: Fri, 12 Apr 2019 08:55:10 +0200 Subject: [PATCH 07/15] added backtrace.c to smallblocktest executable --- cmake_targets/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 253a78726a..f3c0f4cca3 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -2511,7 +2511,9 @@ add_executable(polartest target_link_libraries(polartest SIMU PHY PHY_NR PHY_COMMON m ${ATLAS_LIBRARIES}) -add_executable(smallblocktest ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/smallblocktest.c) +add_executable(smallblocktest +${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/smallblocktest.c +${OPENAIR_DIR}/common/utils/backtrace.c) target_link_libraries(smallblocktest SIMU PHY PHY_NR PHY_COMMON m ${ATLAS_LIBRARIES}) add_executable(ldpctest From 99c6c9227ea39a21f993e5a82fef90f3fc0ca018 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Fri, 12 Apr 2019 13:27:20 +0200 Subject: [PATCH 08/15] cleanup after merge with develop-nr --- .../nfapi/public_inc/nfapi_interface.h | 2 +- openair1/PHY/CODING/TESTBENCH/ldpctest.c | 8 +-- openair1/PHY/CODING/coding_defs.h | 2 - openair1/PHY/CODING/crc_byte.c | 2 +- .../PHY/CODING/nrPolar_tools/nr_polar_defs.h | 2 + .../CODING/nrPolar_tools/nr_polar_encoder.c | 1 + openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 2 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 39 +++++++------ .../SCHED_NR_UE/pucch_power_control_ue_nr.c | 4 +- openair1/SCHED_NR_UE/pucch_uci_ue_nr.c | 56 +++++++++++++++++-- openair1/SIMULATION/NR_PHY/dlschsim.c | 8 +-- openair1/SIMULATION/NR_PHY/dlsim.c | 35 +++++------- openair2/GNB_APP/gnb_config.c | 2 +- openair2/LAYER2/NR_MAC_UE/mac.h | 8 +-- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 4 +- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 22 -------- openair2/RRC/NR/L2_nr_interface.c | 1 + openair2/RRC/NR/rrc_gNB.c | 9 +-- 19 files changed, 114 insertions(+), 95 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h index fc3859be94..51f66c3075 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h @@ -583,7 +583,7 @@ typedef struct { } nfapi_pnf_phy_rf_config_t; #define NFAPI_PNF_PHY_RF_TAG 0x1003 -// Generic structure for single tlv value. +// Generic strucutre for single tlv value. typedef struct { nfapi_tl_t tl; uint16_t value; diff --git a/openair1/PHY/CODING/TESTBENCH/ldpctest.c b/openair1/PHY/CODING/TESTBENCH/ldpctest.c index d8ba986175..6db9548dbe 100644 --- a/openair1/PHY/CODING/TESTBENCH/ldpctest.c +++ b/openair1/PHY/CODING/TESTBENCH/ldpctest.c @@ -382,12 +382,12 @@ int test_ldpc(short No_iteration, //Uncoded BER if (channel_output_fixed[j][i]<0) - channel_output_uncoded[j][i]=1; //QPSK demod - else - channel_output_uncoded[j][i]=0; + channel_output_uncoded[j][i]=1; //QPSK demod + else + channel_output_uncoded[j][i]=0; if (channel_output_uncoded[j][i] != channel_input[j][i-2*Zc]) - *errors_bit_uncoded = (*errors_bit_uncoded) + 1; + *errors_bit_uncoded = (*errors_bit_uncoded) + 1; } } // End segments diff --git a/openair1/PHY/CODING/coding_defs.h b/openair1/PHY/CODING/coding_defs.h index 2277826a66..0c1dbfae35 100644 --- a/openair1/PHY/CODING/coding_defs.h +++ b/openair1/PHY/CODING/coding_defs.h @@ -30,8 +30,6 @@ #include #include -typedef unsigned __int128 uint128_t; - #define CRC24_A 0 #define CRC24_B 1 #define CRC16 2 diff --git a/openair1/PHY/CODING/crc_byte.c b/openair1/PHY/CODING/crc_byte.c index bf8d63fb39..5e0ebeb991 100644 --- a/openair1/PHY/CODING/crc_byte.c +++ b/openair1/PHY/CODING/crc_byte.c @@ -259,7 +259,7 @@ unsigned int crcPayload(unsigned char * inptr, int bitlen, uint32_t* crc256Table int check_crc(uint8_t* decoded_bytes, uint32_t n, uint32_t F, uint8_t crc_type) { uint32_t crc=0,oldcrc=0; - uint8_t crc_len; + uint8_t crc_len,temp; switch (crc_type) { case CRC24_A: diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index f6c66e89dc..7b63e5757c 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -59,6 +59,8 @@ static const uint8_t nr_polar_subblock_interleaver_pattern[32] = {0,1,2,4,3,5,6, #define Nmax 1024 #define nmax 10 +#define uint128_t __uint128_t + typedef struct decoder_node_t_s { struct decoder_node_t_s *left; struct decoder_node_t_s *right; diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c index 245094e238..b504812d0b 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c @@ -37,6 +37,7 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "assertions.h" +#include " //input [a_31 a_30 ... a_0] //output [f_31 f_30 ... f_0] [f_63 f_62 ... f_32] ... diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index 12870016fa..a7e4b33c16 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -703,7 +703,7 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB, int dlsch_encoding(PHY_VARS_eNB *eNB, - unsigned char *a, + unsigned char *a, uint8_t num_pdcch_symbols, LTE_eNB_DLSCH_t *dlsch, int frame, diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 2a12b33104..c83074d8a2 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -2814,8 +2814,8 @@ void nr_ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * //uint8_t pbch_phase; int ret = 0; uint16_t frame_tx; - //static uint8_t first_run = 1; - //uint8_t pbch_trials = 0; + static uint8_t first_run = 1; + uint8_t pbch_trials = 0; DevAssert(ue); @@ -2908,10 +2908,9 @@ unsigned int get_tx_amp(int power_dBm, int power_max_dBm, int N_RB_UL, int nb_rb #ifdef NR_PDCCH_SCHED -int nr_ue_pdcch_procedures(uint8_t eNB_id, - PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc) +int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc) { + // unsigned int dci_cnt=0, i; //removed for nr_ue_pdcch_procedures and added in the loop for nb_coreset_active #ifdef NR_PDCCH_SCHED_DEBUG printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_ue_pdcch_procedures() \n"); @@ -2959,10 +2958,10 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id, #endif // p in TS 38.212 Subclause 10.1, for each active BWP the UE can deal with 3 different CORESETs (including coresetId 0 for common search space) - //int nb_coreset_total = NR_NBR_CORESET_ACT_BWP; + int nb_coreset_total = NR_NBR_CORESET_ACT_BWP; unsigned int dci_cnt=0; // this table contains 56 (NBR_NR_DCI_FIELDS) elements for each dci field and format described in TS 38.212. Each element represents the size in bits for each dci field - //uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS] = {{0}}; + uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS] = {{0}}; // this is the UL bandwidth part. FIXME! To be defined where this value comes from // uint16_t n_RB_ULBWP = 106; // this is the DL bandwidth part. FIXME! To be defined where this value comes from @@ -2989,7 +2988,7 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id, * To be implemented LATER !!! */ //int _offset,_index,_M; - //int searchSpace_id = pdcch_vars2->searchSpace[nb_searchspace_active].searchSpaceId; + int searchSpace_id = pdcch_vars2->searchSpace[nb_searchspace_active].searchSpaceId; #ifdef NR_PDCCH_SCHED_DEBUG @@ -3002,16 +3001,16 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id, // the searchSpace indicates that we need to monitor PDCCH in current nr_tti_rx // get the parameters describing the current SEARCHSPACE // the CORESET id applicable to the current SearchSpace - //int searchSpace_coreset_id = pdcch_vars2->searchSpace[nb_searchspace_active].controlResourceSetId; + int searchSpace_coreset_id = pdcch_vars2->searchSpace[nb_searchspace_active].controlResourceSetId; // FIXME this variable is a bit string (14 bits) identifying every OFDM symbol in a slot. // at the moment we will not take into consideration this variable and we will consider that the OFDM symbol offset is always the first OFDM in a symbol uint16_t symbol_within_slot_mon = pdcch_vars2->searchSpace[nb_searchspace_active].monitoringSymbolWithinSlot; // get the remaining parameters describing the current SEARCHSPACE: // FIXME! To be defined where we get this information from - //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L1 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel1; - //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L2 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel2; - //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L4 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel4; - //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L8 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel8; - //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L16 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel16; + NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L1 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel1; + NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L2 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel2; + NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L4 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel4; + NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L8 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel8; + NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L16 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel16; // FIXME! A table of five enum elements // searchSpaceType indicates whether this is a common search space or a UE-specific search space //int searchSpaceType = pdcch_vars2->searchSpace[nb_searchspace_active].searchSpaceType.type; @@ -3781,7 +3780,7 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, int frame_rx = proc->frame_rx; int nr_tti_rx = proc->nr_tti_rx; int ret=0, ret1=0; - //int CC_id = ue->CC_id; + int CC_id = ue->CC_id; NR_UE_PDSCH *pdsch_vars; uint8_t is_cw0_active = 0; uint8_t is_cw1_active = 0; @@ -4318,11 +4317,11 @@ void *UE_thread_slot1_dl_processing(void *arg) { -int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc,uint8_t eNB_id, - uint8_t do_pdcch_flag, - runmode_t mode) -{ +int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id, + uint8_t do_pdcch_flag,runmode_t mode) { + + + int l,l2; int pilot1; diff --git a/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c b/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c index f0005f25b1..debb0d4ed5 100644 --- a/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c +++ b/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c @@ -34,8 +34,6 @@ #include "SCHED_NR_UE/pucch_power_control_ue_nr.h" #include -int16_t get_PL(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index); - /**************** defines **************************************/ /**************** variables **************************************/ @@ -149,7 +147,7 @@ int16_t get_pucch_tx_power_ue(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_pro } } - //int l = 0; + int l = 0; int k2; if (power_config->twoPUCCH_PC_AdjustmentStates > 1) { diff --git a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c index 161ee0b57c..ec5ed6d91d 100644 --- a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c +++ b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c @@ -53,7 +53,57 @@ int8_t nr_ue_get_SR(module_id_t module_idP, int CC_id, frame_t frameP, uint8_t eNB_id, uint16_t rnti, sub_frame_t subframe); uint8_t is_cqi_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t gNB_id); uint8_t is_ri_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t gNB_id); +/* +void nr_generate_pucch0(int32_t **txdataF, + NR_DL_FRAME_PARMS *frame_parms, + PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, + int16_t amp, + int nr_tti_tx, + uint8_t mcs, + uint8_t nrofSymbols, + uint8_t startingSymbolIndex, + uint16_t startingPRB); +void nr_generate_pucch1(int32_t **txdataF, + NR_DL_FRAME_PARMS *frame_parms, + PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, + uint64_t payload, + int16_t amp, + int nr_tti_tx, + uint8_t nrofSymbols, + uint8_t startingSymbolIndex, + uint16_t startingPRB, + uint16_t startingPRB_intraSlotHopping, + uint8_t timeDomainOCC, + uint8_t nr_bit); + +void nr_generate_pucch2(int32_t **txdataF, + NR_DL_FRAME_PARMS *frame_parms, + PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, + uint64_t payload, + int16_t amp, + int nr_tti_tx, + uint8_t nrofSymbols, + uint8_t startingSymbolIndex, + uint8_t nrofPRB, + uint16_t startingPRB, + uint8_t nr_bit); + +void nr_generate_pucch3_4(int32_t **txdataF, + NR_DL_FRAME_PARMS *frame_parms, + pucch_format_nr_t fmt, + PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, + uint64_t payload, + int16_t amp, + int nr_tti_tx, + uint8_t nrofSymbols, + uint8_t startingSymbolIndex, + uint8_t nrofPRB, + uint16_t startingPRB, + uint8_t nr_bit, + uint8_t occ_length_format4, + uint8_t occ_index_format4); +*/ /**************** variables **************************************/ @@ -508,8 +558,7 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_ switch(format) { case pucch_format0_nr: { - nr_generate_pucch0(ue, - ue->common_vars.txdataF, + nr_generate_pucch0(ue,ue->common_vars.txdataF, &ue->frame_parms, &ue->pucch_config_dedicated[gNB_id], tx_amp, @@ -523,8 +572,7 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_ } case pucch_format1_nr: { - nr_generate_pucch1(ue, - ue->common_vars.txdataF, + nr_generate_pucch1(ue,ue->common_vars.txdataF, &ue->frame_parms, &ue->pucch_config_dedicated[gNB_id], pucch_payload, diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index fef06e5a50..2a95768a3e 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -493,9 +493,9 @@ int main(int argc, char **argv) { short *channel_output_fixed = malloc16(sizeof(short) * 16 * 68 * 384); short *channel_output_uncoded = malloc16(sizeof(unsigned short) * 16 * 68 * 384); double errors_bit_uncoded = 0; - //unsigned char *estimated_output = malloc16(sizeof(unsigned char) * 16 * 68 * 384); - unsigned char *estimated_output_bit = malloc16(sizeof(unsigned char) * 16 * 68 * 384); - unsigned char *test_input_bit = malloc16(sizeof(unsigned char) * 16 * 68 * 384); + unsigned char *estimated_output; + unsigned char *estimated_output_bit; + unsigned char *test_input_bit; unsigned int errors_bit = 0; test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); estimated_output = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); @@ -514,7 +514,7 @@ int main(int argc, char **argv) { for (i = 0; i < TBS / 8; i++) test_input[i] = (unsigned char) rand(); - //estimated_output = harq_process->b; + estimated_output = harq_process->b; #ifdef DEBUG_DLSCHSIM for (i = 0; i < TBS / 8; i++) printf("test_input[i]=%d \n",test_input[i]); diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index acba9d0ef0..b95ea7502e 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -42,12 +42,11 @@ #include "PHY/MODULATION/modulation_UE.h" #include "PHY/INIT/phy_init.h" #include "PHY/NR_TRANSPORT/nr_transport.h" -//#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" +#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "SCHED_NR/sched_nr.h" #include "SCHED_NR/fapi_nr_l1.h" #include "SCHED_NR_UE/fapi_nr_ue_l1.h" -#include "SCHED_NR/fapi_nr_l1.h" #include "LAYER2/NR_MAC_gNB/nr_mac_gNB.h" #include "LAYER2/NR_MAC_UE/mac_defs.h" @@ -58,11 +57,6 @@ #include "NR_PHY_INTERFACE/NR_IF_Module.h" #include "NR_UE_PHY_INTERFACE/NR_IF_Module.h" -#include "LAYER2/NR_MAC_UE/mac_proto.h" -//#include "LAYER2/NR_MAC_gNB/mac_proto.h" -//#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h" -#include "RRC/NR/MESSAGES/asn1_msg.h" - PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; @@ -126,40 +120,41 @@ int main(int argc, char **argv) { char c; - int i,aa; + + int i,l,aa; double sigma2, sigma2_dB=10,SNR,snr0=-2.0,snr1=2.0; uint8_t snr1set=0; int **txdata; double **s_re,**s_im,**r_re,**r_im; - //double iqim = 0.0; - //unsigned char pbch_pdu[6]; + double iqim = 0.0; + unsigned char pbch_pdu[6]; // int sync_pos, sync_pos_slot; // FILE *rx_frame_file; FILE *output_fd = NULL; uint8_t write_output_file=0; //int result; - // int freq_offset, subframe_offset; + int freq_offset; + // int subframe_offset; // char fname[40], vname[40]; - int trial,n_trials=1,n_errors=0; - //int n_errors2=0,n_alamouti=0; + int trial,n_trials=1,n_errors,n_errors2,n_alamouti; uint8_t transmission_mode = 1,n_tx=1,n_rx=1; uint16_t Nid_cell=0; uint64_t SSB_positions=0x01; channel_desc_t *gNB2UE; - //uint32_t nsymb,tx_lev,tx_lev1 = 0,tx_lev2 = 0; + uint32_t nsymb,tx_lev,tx_lev1 = 0,tx_lev2 = 0; uint8_t extended_prefix_flag=0; int8_t interf1=-21,interf2=-21; FILE *input_fd=NULL,*pbch_file_fd=NULL; - //char input_val_str[50],input_val_str2[50]; + char input_val_str[50],input_val_str2[50]; - //uint8_t frame_mod4, num_pdcch_symbols = 0; + uint8_t frame_mod4,num_pdcch_symbols = 0; SCM_t channel_model=AWGN;//Rayleigh1_anticorr; - //double pbch_sinr; - //int pbch_tx_ant; + double pbch_sinr; + int pbch_tx_ant; int N_RB_DL=273,mu=1; uint64_t ssb_pattern = 0x01; @@ -681,8 +676,8 @@ int main(int argc, char **argv) for (SNR=snr0; SNRul_config_request; - //fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; + fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; nr_phy_config_t *phy_config = &mac->phy_config; //ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.rnti = rnti; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 4c7c491454..def897433e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -36,8 +36,6 @@ #include "LAYER2/MAC/mac_extern.h" #include "LAYER2/MAC/mac_proto.h" #include "LAYER2/NR_MAC_gNB/mac_proto.h" -#include "openair1/PHY/LTE_TRANSPORT/transport_proto.h" -#include "openair1/PHY/NR_TRANSPORT/nr_dlsch.h" #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" @@ -337,7 +335,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, rnti = UE_RNTI(module_idP, i); CC_id = UE_PCCID(module_idP, i); - //int spf = get_spf(cfg); + int spf = get_spf(cfg); if (((frameP&127) == 0) && (slotP == 0)) { LOG_I(MAC, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 9968c39df4..97a417fea1 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -36,28 +36,6 @@ void mac_top_init_gNB(void); -uint32_t to_nrarfcn(int nr_bandP, uint64_t dl_CarrierFreq, uint32_t bw); - -uint64_t from_nrarfcn(int nr_bandP, uint32_t dl_nrarfcn); - -void config_nr_mib(int Mod_idP, - int CC_idP, - int p_gNBP, - int subCarrierSpacingCommon, - uint32_t ssb_SubcarrierOffset, - int dmrs_TypeA_Position, - uint32_t pdcch_ConfigSIB1, - int cellBarred, - int intraFreqReselection - ); - -void config_common(int Mod_idP, - int CC_idP, - int nr_bandP, - uint64_t dl_CarrierFreqP, - uint32_t dl_BandwidthP - ); - int rrc_mac_config_req_gNB(module_id_t Mod_idP, int CC_id, int cellid, diff --git a/openair2/RRC/NR/L2_nr_interface.c b/openair2/RRC/NR/L2_nr_interface.c index c8cdfd336f..0dca3b80d2 100644 --- a/openair2/RRC/NR/L2_nr_interface.c +++ b/openair2/RRC/NR/L2_nr_interface.c @@ -58,6 +58,7 @@ int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP, uint8_t sfn_msb = (uint8_t)((frameP>>4)&0x3f); #ifdef DEBUG_RRC + int i; LOG_I(RRC,"[eNB %d] mac_rrc_data_req to SRB ID=%d\n",Mod_idP,Srb_id); #endif diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index af5ec8df82..801673b2ef 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -144,15 +144,16 @@ void rrc_gNB_generate_SgNBAdditionRequestAcknowledge( rrc_gNB_ue_context_t *const ue_context_pP ){ - //uint8_t size, buffer[100]; - //int CC_id = ue_context_pP->ue_context.primaryCC_id; - //OCTET_STRING_t *secondaryCellGroup; + uint8_t size; + uint8_t buffer[100]; + int CC_id = ue_context_pP->ue_context.primaryCC_id; + OCTET_STRING_t *secondaryCellGroup; NR_CellGroupConfig_t *cellGroupconfig; struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_BearerToAddModList; struct NR_MAC_CellGroupConfig *mac_CellGroupConfig; struct NR_PhysicalCellGroupConfig *physicalCellGroupConfig; struct NR_SpCellConfig *spCellConfig; - //struct NR_CellGroupConfig__sCellToAddModList *sCellToAddModList; + struct NR_CellGroupConfig__sCellToAddModList *sCellToAddModList; cellGroupconfig = CALLOC(1,sizeof(NR_CellGroupConfig_t)); cellGroupconfig->rlc_BearerToAddModList = CALLOC(1,sizeof(struct NR_CellGroupConfig__rlc_BearerToAddModList)); From b2add95524de502179abf2bce720793223f581b6 Mon Sep 17 00:00:00 2001 From: yilmazt Date: Sun, 14 Apr 2019 17:38:52 +0200 Subject: [PATCH 09/15] Added clean_gNB_ulsch, fully working polartest, and many other minor warning removals. --- cmake_targets/CMakeLists.txt | 4 +- cmake_targets/autotests/test_case_list.xml | 17 +- cmake_targets/build_oai | 2 - openair1/PHY/CODING/TESTBENCH/polartest.c | 473 +++++++----------- .../PHY/CODING/TESTBENCH/smallblocktest.c | 6 +- openair1/PHY/CODING/crc_byte.c | 33 +- .../nrLDPC_decoder/nrLDPC_tools/time_meas.c | 117 ----- .../nrLDPC_decoder/nrLDPC_tools/time_meas.h | 156 ------ .../PHY/CODING/nrLDPC_decoder/nrLDPC_types.h | 2 +- .../nrPolar_tools/nr_bitwise_operations.c | 27 +- .../PHY/CODING/nrPolar_tools/nr_crc_byte.c | 62 +-- .../CODING/nrPolar_tools/nr_polar_decoder.c | 293 +---------- .../PHY/CODING/nrPolar_tools/nr_polar_defs.h | 56 +-- .../CODING/nrPolar_tools/nr_polar_encoder.c | 103 +--- .../CODING/nrSmallBlock/decodeSmallBlock.c | 2 +- openair1/PHY/CODING/nr_polar_init.c | 19 +- openair1/PHY/NR_TRANSPORT/nr_dci.h | 2 - openair1/PHY/NR_TRANSPORT/nr_dlsch.h | 2 + openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 100 +++- .../PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 4 +- openair1/SCHED_NR/fapi_nr_l1.h | 4 +- openair1/SIMULATION/NR_PHY/dlschsim.c | 2 +- openair1/SIMULATION/NR_PHY/dlsim.c | 7 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 16 +- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 8 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 4 - 26 files changed, 417 insertions(+), 1104 deletions(-) delete mode 100644 openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_tools/time_meas.c delete mode 100644 openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_tools/time_meas.h diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 253a78726a..f504af1733 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -2511,7 +2511,9 @@ add_executable(polartest target_link_libraries(polartest SIMU PHY PHY_NR PHY_COMMON m ${ATLAS_LIBRARIES}) -add_executable(smallblocktest ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/smallblocktest.c) +add_executable(smallblocktest + ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/smallblocktest.c + ${OPENAIR_DIR}/common/utils/backtrace.c) target_link_libraries(smallblocktest SIMU PHY PHY_NR PHY_COMMON m ${ATLAS_LIBRARIES}) add_executable(ldpctest diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml index c0f8eac447..a970ccbf5d 100644 --- a/cmake_targets/autotests/test_case_list.xml +++ b/cmake_targets/autotests/test_case_list.xml @@ -1120,16 +1120,15 @@ execution shortblocktest Test cases. (Test1: 3 bits), - (Test2: 6 bits) - (Test3: 7 bits) - (Test4: 11 bits) - + (Test2: 6 bits), + (Test3: 7 bits), + (Test4: 11 bits) $OPENAIR_DIR/targets/bin/smallblocktest.Rel15 - -l 3 - -l 6 - -l 7 - -l 11 - smallblocktest.test1 smallblocktest.test2 smallblocktest.test3 smallblocktest.test3 + -l 3 -s -4 -d 1 -i 10000 + -l 6 -s -4 -d 1 -i 10000 + -l 7 -s -4 -d 1 -i 10000 + -l 11 -s -4 -d 1 -i 10000 + smallblocktest.test1 smallblocktest.test2 smallblocktest.test3 smallblocktest.test4 BLER= 0.000000 segmentation fault|assertion|exiting|fatal 3 diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index 4bfa734709..af051abab7 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -80,8 +80,6 @@ function print_help() { This program installs OpenAirInterface Software You should have ubuntu 16.xx or 18.04 updated Options --h - This help -c | --clean Erase all files to make a rebuild from start -C | --clean-all diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index ddcc3ce826..49e71abbc9 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -16,43 +16,11 @@ //#define DEBUG_DCI_POLAR_PARAMS //#define DEBUG_POLAR_TIMING -//#define DEBUG_CRC //#define DEBUG_POLARTEST -uint8_t nr_pbch_payload_interleaving_pattern[32] = {16, 23, 18, 17, 8, 30, 10, 6, 24, 7, 0, 5, 3, 2, 1, 4, - 9, 11, 12, 13, 14, 15, 19, 20, 21, 22, 25, 26, 27, 28, 29, 31}; - -void nr_init_pbch_interleaver(uint8_t *interleaver) { - uint8_t j_sfn=0, j_hrf=10, j_ssb=11, j_other=14; - memset((void*)interleaver,0, NR_POLAR_PBCH_PAYLOAD_BITS); - - for (uint8_t i=0; i 60) { - printf("Illegal packet bitlength\n",testLength); - exit(-1); - } - - break; + testLength=atoi(optarg); + if (testLength < 12 || testLength > 60) { + printf("Illegal packet bitlength %d \n",testLength); + exit(-1); + } + break; case 'h': - printf("./polartest -s SNRstart -d SNRinc -f SNRstop -m [0=PBCH|1=DCI|2=UCI] -i iterations -l decoderListSize -a pathMetricAppr -L aggregation level (for DCI) -K packet_length (bits) for DCI/UCI\n"); + printf("./polartest\nOptions\n-h Print this help\n-s SNRstart (dB)\n-d SNRinc (dB)\n-f SNRstop (dB)\n-m [0=PBCH|1=DCI|2=UCI]\n" + "-i Number of iterations\n-l decoderListSize\n-a pathMetricAppr\n-q Flag for optimized coders usage\n-F Flag for test results logging\n" + "-L aggregation level (for DCI)\n-K packet_length (bits) for DCI/UCI\n"); exit(-1); break; @@ -140,23 +107,34 @@ int main(int argc, char *argv[]) { break; } + //Initiate timing. (Results depend on CPU Frequency. Therefore, might change due to performance variances during simulation.) + time_stats_t timeEncoder,timeDecoder; + opp_enabled=1; + cpu_freq_GHz = get_cpu_freq_GHz(); + reset_meas(&timeEncoder); + reset_meas(&timeDecoder); + randominit(0); + crcTableInit(); + if (polarMessageType == 0) { //PBCH + aggregation_level = NR_POLAR_PBCH_AGGREGATION_LEVEL; } else if (polarMessageType == 1) { //DCI - coderLength = 108*aggregation_level; + coderLength = 108*aggregation_level; } else if (polarMessageType == -1) { //UCI - printf("UCI testing not supported yet\n"); - exit(-1); + printf("UCI testing not supported yet\n"); + exit(-1); } //Logging time_t currentTime; - time (¤tTime); char fileName[512], currentTimeInfo[25]; char folderName[] = "."; - /* - folderName=getenv("HOME"); - strcat(folderName,"/Desktop/polartestResults"); - */ + FILE *logFile; + /*folderName=getenv("HOME"); + strcat(folderName,"/Desktop/polartestResults");*/ + +if (logFlag){ + time (¤tTime); #ifdef DEBUG_POLAR_TIMING sprintf(fileName,"%s/TIMING_ListSize_%d_pmAppr_%d_Payload_%d_Itr_%d",folderName,decoderListSize,pathMetricAppr,testLength,iterations); #else @@ -165,11 +143,8 @@ int main(int argc, char *argv[]) { strftime(currentTimeInfo, 25, "_%Y-%m-%d-%H-%M-%S.csv", localtime(¤tTime)); strcat(fileName,currentTimeInfo); //Create "~/Desktop/polartestResults" folder if it doesn't already exist. - /* - struct stat folder = {0}; - if (stat(folderName, &folder) == -1) mkdir(folderName, S_IRWXU | S_IRWXG | S_IRWXO); - */ - FILE *logFile; + /*struct stat folder = {0}; + if (stat(folderName, &folder) == -1) mkdir(folderName, S_IRWXU | S_IRWXG | S_IRWXO);*/ logFile = fopen(fileName, "w"); if (logFile==NULL) { @@ -178,11 +153,12 @@ int main(int argc, char *argv[]) { } #ifdef DEBUG_POLAR_TIMING - fprintf(logFile, - ",timeEncoderCRCByte[us],timeEncoderCRCBit[us],timeEncoderInterleaver[us],timeEncoderBitInsertion[us],timeEncoder1[us],timeEncoder2[us],timeEncoderRateMatching[us],timeEncoderByte2Bit[us]\n"); + fprintf(logFile,",timeEncoderCRCByte[us],timeEncoderCRCBit[us],timeEncoderInterleaver[us],timeEncoderBitInsertion[us],timeEncoder1[us],timeEncoder2[us],timeEncoderRateMatching[us],timeEncoderByte2Bit[us]\n"); #else fprintf(logFile,",SNR,nBitError,blockErrorState,t_encoder[us],t_decoder[us]\n"); #endif +} + uint8_t testArrayLength = ceil(testLength / 32.0); uint8_t coderArrayLength = ceil(coderLength / 32.0); uint32_t testInput[testArrayLength]; //generate randomly @@ -196,261 +172,160 @@ int main(int argc, char *argv[]) { double channelOutput[coderLength]; //add noise int16_t channelOutput_int16[coderLength]; t_nrPolar_params *currentPtr = nr_polar_params(polarMessageType, testLength, aggregation_level); + #ifdef DEBUG_DCI_POLAR_PARAMS uint32_t dci_pdu[4]; memset(dci_pdu,0,sizeof(uint32_t)*4); dci_pdu[0]=0x01189400; - printf("dci_pdu: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", - dci_pdu[0], dci_pdu[1], dci_pdu[2], dci_pdu[3]); + printf("dci_pdu: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", dci_pdu[0], dci_pdu[1], dci_pdu[2], dci_pdu[3]); + uint16_t size=41; + rnti=3; + aggregation_level=8; uint32_t encoder_output[54]; memset(encoder_output,0,sizeof(uint32_t)*54); - uint16_t size=41; - uint16_t rnti=3; - aggregation_level=8; t_nrPolar_params *currentPtrDCI=nr_polar_params(1, size, aggregation_level); - polar_encoder_dci(dci_pdu, encoder_output, currentPtrDCI, rnti); - for (int i=0; i<54; i++) - printf("encoder_output: [%2d]->0x%08x \n",i, encoder_output[i]); + polar_encoder_dci(dci_pdu, encoder_output, currentPtrDCI, rnti); + for (int i=0; i<54; i++) printf("encoder_output: [%2d]->0x%08x \n", i, encoder_output[i]); uint8_t *encoder_outputByte = malloc(sizeof(uint8_t) * currentPtrDCI->encoderLength); - double *channel_output = malloc (sizeof(double) * currentPtrDCI->encoderLength); - uint32_t dci_estimation[4]; - memset(dci_estimation,0,sizeof(uint32_t)*4); - printf("dci_estimation: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", - dci_estimation[0], dci_estimation[1], dci_estimation[2], dci_estimation[3]); + double *modulated_input = malloc (sizeof(double) * currentPtrDCI->encoderLength); + double *channel_output = malloc (sizeof(double) * currentPtrDCI->encoderLength); + uint32_t dci_est[4]; + memset(dci_est,0,sizeof(uint32_t)*4); + printf("dci_est: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", dci_est[0], dci_est[1], dci_est[2], dci_est[3]); nr_bit2byte_uint32_8(encoder_output, currentPtrDCI->encoderLength, encoder_outputByte); printf("[polartest] encoder_outputByte: "); + for (int i = 0; i < currentPtrDCI->encoderLength; i++) printf("%d-", encoder_outputByte[i]); printf("\n"); - for (int i = 0; i < currentPtrDCI->encoderLength; i++) printf("%d-", encoder_outputByte[i]); - - printf("\n"); - + SNR_lin = pow(10, 0/10); //SNR = 0 dB for(int i=0; iencoderLength; i++) { - if (encoder_outputByte[i] == 0) { - channel_output[i]=1/sqrt(2); - } else { - channel_output[i]=(-1)/sqrt(2); - } + if (encoder_outputByte[i] == 0) + modulated_input[i]=1/sqrt(2); + else + modulated_input[i]=(-1)/sqrt(2); + channel_output[i] = modulated_input[i] + (gaussdouble(0.0,1.0) * (1/sqrt(2*SNR_lin))); } - - decoderState = polar_decoder_dci(channel_output, - dci_estimation, - currentPtrDCI, - NR_POLAR_DECODER_LISTSIZE, - NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION, - rnti); - printf("dci_estimation: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", - dci_estimation[0], dci_estimation[1], dci_estimation[2], dci_estimation[3]); + decoderState = polar_decoder_dci(channel_output, dci_est, currentPtrDCI, NR_POLAR_DECODER_LISTSIZE, NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION, rnti); + printf("dci_est: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", dci_est[0], dci_est[1], dci_est[2], dci_est[3]); free(encoder_outputByte); free(channel_output); + free(modulated_input); return 0; #endif -#ifdef DEBUG_CRC - uint32_t crc; - unsigned int poly24c = 0xb2b11700; - uint32_t testInputCRC[4]; - testInputCRC[0]=0x00291880; - //testInputCRC[0]=0x01189400; - testInputCRC[1]=0x00000000; - testInputCRC[2]=0x00000000; - testInputCRC[3]=0x00000000; - uint32_t testInputcrc=0x01189400; - uint32_t testInputcrc2=0x00291880; - uint8_t testInputCRC2[8]; - nr_crc_bit2bit_uint32_8(testInputCRC, 32, testInputCRC2); - printf("testInputCRC2: [0]->%x \t [1]->%x \t [2]->%x \t [3]->%x\n" - " [4]->%x \t [5]->%x \t [6]->%x \t [7]->%x\n", - testInputCRC2[0], testInputCRC2[1], testInputCRC2[2], testInputCRC2[3], - testInputCRC2[4], testInputCRC2[5], testInputCRC2[6], testInputCRC2[7]); - unsigned int crc41 = crc24c(testInputCRC, 32); - unsigned int crc65 = crc24c(testInputCRC, 56); - printf("crc41: [0]->0x%08x\tcrc65: [0]->0x%08x\n",crc41, crc65); - for (int i=0; i<32; i++) printf("crc41[%d]=%d\tcrc65[%d]=%d\n",i,(crc41>>i)&1,i,(crc65>>i)&1); - - crc = crc24c(testInputCRC, testLength)>>8; - - for (int i=0; i<24; i++) printf("[i]=%d\n",(crc>>i)&1); - - printf("crc: [0]->0x%08x\n",crc); - //crcbit(testInputCRC, sizeof(test) - 1, poly24c)); - testInputCRC[testLength>>3] = ((uint8_t *)&crc)[2]; - testInputCRC[1+(testLength>>3)] = ((uint8_t *)&crc)[1]; - testInputCRC[2+(testLength>>3)] = ((uint8_t *)&crc)[0]; - printf("testInputCRC: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", - testInputCRC[0], testInputCRC[1], testInputCRC[2], testInputCRC[3]); - //uint32_t trial32 = 0xffffffff; - uint32_t trial32 = 0xf10fffff; - uint8_t a[4]; - //memcpy(a, &trial32, sizeof(trial32)); - *(uint32_t *)a = trial32; - unsigned char trial[4]; - trial[0]=0xff; - trial[1]=0xff; - trial[2]=0x0f; - trial[3]=0xf1; - uint32_t trialcrc = crc24c(trial, 32); - uint32_t trialcrc32 = crc24c((uint8_t *)&trial32, 32); - //uint32_t trialcrc32 = crc24c(a, 32); - printf("crcbit(trial = %x\n", crcbit(trial, 4, poly24c)); - printf("trialcrc = %x\n", trialcrc); - printf("trialcrc32 = %x\n", trialcrc32); - - for (int i=0; i<32; i++) printf("trialcrc[%2d]=%d\ttrialcrc32[%2d]=%d\n",i,(trialcrc>>i)&1,i,(trialcrc32>>i)&1); - - //uint8_t nr_polar_A[32] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; - uint8_t nr_polar_A[32] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,1}; - uint8_t nr_polar_crc[24]; - uint8_t **crc_generator_matrix = crc24c_generator_matrix(32); - nr_matrix_multiplication_uint8_1D_uint8_2D(nr_polar_A, - crc_generator_matrix, - nr_polar_crc, - 32, - 24); - - for (uint8_t i = 0; i < 24; i++) { - nr_polar_crc[i] = (nr_polar_crc[i] % 2); - printf("nr_polar_crc[%d]=%d\n",i,nr_polar_crc[i]); - } - - return 0; -#endif -#ifdef DEBUG_POLAR_TIMING - for (SNR = SNRstart; SNR <= SNRstop; SNR += SNRinc) { - SNR_lin = pow(10, SNR / 10); - - for (itr = 1; itr <= iterations; itr++) { - for (int j=0; j0x%08x \n", testInput[0]); - polar_encoder_timing(testInput, encoderOutput, currentPtr, cpu_freq_GHz, logFile); - } - } - - fclose(logFile); - free(testInput); - free(encoderOutput); - free(modulatedInput); - free(channelOutput); - free(estimatedOutput); - return (0); -#endif // We assume no a priori knowledge available about the payload. double aPrioriArray[currentPtr->payloadBits]; for (int i=0; ipayloadBits; i++) aPrioriArray[i] = NAN; for (SNR = SNRstart; SNR <= SNRstop; SNR += SNRinc) { - printf("SNR %f\n",SNR); - SNR_lin = pow(10, SNR/10); + printf("SNR %f\n",SNR); + SNR_lin = pow(10, SNR/10); - for (itr = 1; itr <= iterations; itr++) { - for (int i = 0; i < testArrayLength; i++) { - for (int j = 0; j < (sizeof(testInput[0])*8)-1; j++) { - testInput[i] |= ( ((uint32_t) (rand()%2)) &1); - testInput[i]<<=1; - } + for (itr = 1; itr <= iterations; itr++) { + //Generate random values for all the bits of "testInput", not just as much as "currentPtr->payloadBits". + for (int i = 0; i < testArrayLength; i++) { + for (int j = 0; j < (sizeof(testInput[0])*8)-1; j++) { + testInput[i] |= ( ((uint32_t) (rand()%2)) &1); + testInput[i]<<=1; + } + testInput[i] |= ( ((uint32_t) (rand()%2)) &1); + } +#ifdef DEBUG_POLARTEST + //testInput[0] = 0x360f8a5c; + printf("testInput: [0]->0x%08x\n", testInput[0]); + //for (int i=0; i<32; i++) printf("%d-",(testInput[0]>>i)&1); printf("\n"); +#endif + int len_mod64=currentPtr->payloadBits&63; + ((uint64_t *)testInput)[currentPtr->payloadBits/64]&=((((uint64_t)1)< PBCH, 1 --> DCI, -1 --> UCI + if (polarMessageType == 0) + polar_encoder(testInput, encoderOutput, currentPtr); + else if (polarMessageType == 1) + polar_encoder_dci(testInput, encoderOutput, currentPtr, rnti); + } + stop_meas(&timeEncoder); - /*printf("testInput: [0]->0x%08x\n", testInput[0]); - for (int i=0; i<32; i++) - printf("%d\n",(testInput[0]>>i)&1);*/ - int len_mod64=currentPtr->payloadBits&63; - ((uint64_t *)testInput)[currentPtr->payloadBits/64]&=((((uint64_t)1)<0x%08x\n", encoderOutput[0]); + //for (int i=1;i0x%08x\n", i, encoderOutput[1]); +#endif - if (decoder_int16==0) { - if (polarMessageType == 0) polar_encoder(testInput, encoderOutput, currentPtr); - else polar_encoder_dci(testInput, encoderOutput, currentPtr, 0); - } - else - polar_encoder_fast((uint64_t *)testInput, encoderOutput,0, currentPtr); - - //polar_encoder_fast((uint64_t*)testInput, (uint64_t*)encoderOutput,0, currentPtr); - stop_meas(&timeEncoder); - /*printf("encoderOutput: [0]->0x%08x\n", encoderOutput[0]); - printf("encoderOutput: [1]->0x%08x\n", encoderOutput[1]);*/ //Bit-to-byte: nr_bit2byte_uint32_8(encoderOutput, coderLength, encoderOutputByte); //BPSK modulation for(int i=0; i 15) channelOutput_int16[i] = 127; - else if (channelOutput[i] < -16) channelOutput_int16[i] = -128; - else channelOutput_int16[i] = (int16_t) (8*channelOutput[i]); - } + if (decoder_int16==1) { + if (channelOutput[i] > 15) channelOutput_int16[i] = 127; + else if (channelOutput[i] < -16) channelOutput_int16[i] = -128; + else channelOutput_int16[i] = (int16_t) (8*channelOutput[i]); + } } start_meas(&timeDecoder); - /*decoderState = polar_decoder(channelOutput, - estimatedOutput, - currentPtr, - NR_POLAR_DECODER_LISTSIZE, - aPrioriArray, - NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION);*/ - if (decoder_int16==0) { - if (polarMessageType == 0) - decoderState = polar_decoder_aPriori(channelOutput, - estimatedOutput, - currentPtr, - NR_POLAR_DECODER_LISTSIZE, - NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION, - aPrioriArray); - else if (polarMessageType == 1) - decoderState = polar_decoder_dci(channelOutput, - estimatedOutput, - currentPtr, - NR_POLAR_DECODER_LISTSIZE, - NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION, - 0); + if (decoder_int16==1) { + decoderState = polar_decoder_int16(channelOutput_int16, (uint64_t *)estimatedOutput, currentPtr); + } else { //0 --> PBCH, 1 --> DCI, -1 --> UCI + if (polarMessageType == 0) + decoderState = polar_decoder(channelOutput, + estimatedOutput, + currentPtr, + decoderListSize, + NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION); + else if (polarMessageType == 1) + decoderState = polar_decoder_dci(channelOutput, + estimatedOutput, + currentPtr, + decoderListSize, + NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION, + rnti); } - else decoderState = polar_decoder_int16(channelOutput_int16, - (uint64_t *)estimatedOutput, - currentPtr); - stop_meas(&timeDecoder); - /*printf("testInput: [0]->0x%08x\n", testInput[0]); - printf("estimatedOutput: [0]->0x%08x\n", estimatedOutput[0]);*/ + +#ifdef DEBUG_POLARTEST + printf("estimatedOutput: [0]->0x%08x\n", estimatedOutput[0]); +#endif //calculate errors if (decoderState!=0) { - blockErrorState=-1; - nBitError=-1; + blockErrorState=-1; + nBitError=-1; } else { - for (int j = 0; j < currentPtr->payloadBits; j++) { - if (((estimatedOutput[0]>>j) & 1) != ((testInput[0]>>j) & 1)) nBitError++; - - // printf("bit %d: %d => %d\n",j,(testInput[0]>>j)&1,(estimatedOutput[0]>>j)&1); - } - - if (nBitError>0) { - blockErrorState=1; - // printf("Error: Input %x, Output %x\n",testInput[0],estimatedOutput[0]); - } + for (int i = 0; i < (testArrayLength-1); i++) { + for (int j = 0; j < 32; j++) { + if ( ((estimatedOutput[i]>>j) & 1) != ((testInput[i]>>j) & 1) ) + nBitError++; + } + } + for (int j = 0; j < testLength - ((testArrayLength-1) * 32); j++) + if ( ((estimatedOutput[(testArrayLength-1)]>>j) & 1) != ((testInput[(testArrayLength-1)]>>j) & 1) ) + nBitError++; } + if (nBitError>0) blockErrorState=1; +#ifdef DEBUG_POLARTEST + for (int i = 0; i < testArrayLength; i++) + printf("[polartest/decoderState=%d] testInput[%d]=0x%08x, estimatedOutput[%d]=0x%08x\n",decoderState, i, testInput[i], i, estimatedOutput[i]); +#endif //Iteration times are in microseconds. timeEncoderCumulative+=(timeEncoder.diff/(cpu_freq_GHz*1000.0)); timeDecoderCumulative+=(timeDecoder.diff/(cpu_freq_GHz*1000.0)); - fprintf(logFile,",%f,%d,%d,%f,%f\n", SNR, nBitError, blockErrorState, - (timeEncoder.diff/(cpu_freq_GHz*1000.0)), (timeDecoder.diff/(cpu_freq_GHz*1000.0))); + if (logFlag) fprintf(logFile,",%f,%d,%d,%f,%f\n", SNR, nBitError, blockErrorState, (timeEncoder.diff/(cpu_freq_GHz*1000.0)), (timeDecoder.diff/(cpu_freq_GHz*1000.0))); if (nBitError<0) { blockErrorCumulative++; @@ -463,6 +338,9 @@ int main(int argc, char *argv[]) { decoderState=0; nBitError=0; blockErrorState=0; + memset(testInput,0,sizeof(uint32_t) * testArrayLength); + memset(encoderOutput,0,sizeof(uint32_t) * coderArrayLength); + memset(estimatedOutput,0,sizeof(uint32_t) * testArrayLength); } //Calculate error statistics for the SNR. @@ -472,8 +350,7 @@ int main(int argc, char *argv[]) { (double)timeEncoder.diff/timeEncoder.trials/(cpu_freq_GHz*1000.0),(double)timeDecoder.diff/timeDecoder.trials/(cpu_freq_GHz*1000.0)); //(timeEncoderCumulative/iterations),timeDecoderCumulative/iterations); - if (blockErrorCumulative==0 && bitErrorCumulative==0) - break; + if (blockErrorCumulative==0 && bitErrorCumulative==0) break; blockErrorCumulative = 0; bitErrorCumulative = 0; @@ -483,6 +360,6 @@ int main(int argc, char *argv[]) { print_meas(&timeEncoder,"polar_encoder",NULL,NULL); print_meas(&timeDecoder,"polar_decoder",NULL,NULL); - fclose(logFile); + if (logFlag) fclose(logFile); return (0); } diff --git a/openair1/PHY/CODING/TESTBENCH/smallblocktest.c b/openair1/PHY/CODING/TESTBENCH/smallblocktest.c index 0b863d2cbf..6278420d8a 100644 --- a/openair1/PHY/CODING/TESTBENCH/smallblocktest.c +++ b/openair1/PHY/CODING/TESTBENCH/smallblocktest.c @@ -127,17 +127,13 @@ int main(int argc, char *argv[]) { #ifdef DEBUG_SMALLBLOCKTEST printf("[smallblocktest] Input = 0x%x, Output = 0x%x, DecoderOutput = 0x%x\n", testInput, encoderOutput, estimatedOutput); for (int i=0;i<32;i++) - printf("[smallblocktest] Input[%d] = %d, Output[%d] = %d, Mask[%d] = %d\n", i, (testInput>>i)&1, i, (estimatedOutput>>i)&1, i, (mask>>i)&1); + printf("[smallblocktest] Input[%d] = %d, Output[%d] = %d, codingDifference[%d]=%d, Mask[%d] = %d\n", i, (testInput>>i)&1, i, (estimatedOutput>>i)&1, i, (codingDifference>>i)&1, i, (mask>>i)&1); #endif //Error Calculation estimatedOutput &= mask; codingDifference = ((uint32_t)estimatedOutput) ^ testInput; // Count the # of 1's in codingDifference by Brian Kernighan’s algorithm. - //for (int i=0;i<32;i++) - //printf("[smallblocktest] Input[%d] = %d, Output[%d] = %d, codingDifference[%d]=%d, Mask[%d] = %d, bitError = %d\n", i, (testInput>>i)&1, i, (estimatedOutput>>i)&1, i, (codingDifference>>i)&1, i, (mask>>i)&1, nBitError); - - for (nBitError = 0; codingDifference; nBitError++) codingDifference &= codingDifference - 1; diff --git a/openair1/PHY/CODING/crc_byte.c b/openair1/PHY/CODING/crc_byte.c index bf8d63fb39..9ca5355ab4 100644 --- a/openair1/PHY/CODING/crc_byte.c +++ b/openair1/PHY/CODING/crc_byte.c @@ -106,17 +106,6 @@ void crcTableInit (void) } while (++c); } -//Generic version -void crcTable256Init (uint32_t poly, uint32_t* crc256Table) -{ - unsigned char c = 0; - - do { - crc256Table[c] = crcbit(&c, 1, poly); - } while (++c); - -} - /********************************************************* Byte by byte implementations, @@ -236,26 +225,6 @@ crc8 (unsigned char * inptr, int bitlen) return crc; } -//Generic version -unsigned int crcPayload(unsigned char * inptr, int bitlen, uint32_t* crc256Table) -{ - int octetlen, resbit; - unsigned int crc = 0; - octetlen = bitlen/8; // Change in bytes - resbit = (bitlen % 8); - - while (octetlen-- > 0) - { - crc = (crc << 8) ^ crc256Table[(*inptr++) ^ (crc >> 24)]; - } - - if (resbit > 0) - { - crc = (crc << resbit) ^ crc256Table[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))]; - } - return crc; -} - int check_crc(uint8_t* decoded_bytes, uint32_t n, uint32_t F, uint8_t crc_type) { uint32_t crc=0,oldcrc=0; @@ -335,7 +304,7 @@ main() { unsigned char test[] = "Thebigredfox"; crcTableInit(); - printf("%x\n", crcbit(test, sizeof(test) - 1, poly24)); + printf("%x\n", crcbit(test, sizeof(test) - 1, poly24a)); printf("%x\n", crc24(test, (sizeof(test) - 1)*8)); printf("%x\n", crcbit(test, sizeof(test) - 1, poly8)); printf("%x\n", crc8(test, (sizeof(test) - 1)*8)); diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_tools/time_meas.c b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_tools/time_meas.c deleted file mode 100644 index c784188071..0000000000 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_tools/time_meas.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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 -#include "time_meas.h" -#include -#include - -// global var for openair performance profiler -extern int opp_enabled; - - -double get_cpu_freq_GHz(void) { - - time_stats_t ts = {0}; - reset_meas(&ts); - ts.trials++; - ts.in = rdtsc_oai(); - sleep(1); - ts.diff = (rdtsc_oai()-ts.in); - cpu_freq_GHz = (double)ts.diff/1000000000; - printf("CPU Freq is %f \n", cpu_freq_GHz); - return cpu_freq_GHz; -} - -void print_meas_now(time_stats_t *ts, const char* name, FILE* file_name){ - - if (opp_enabled) { - - //static double cpu_freq_GHz = 3.2; - - //if (cpu_freq_GHz == 0.0) - //cpu_freq_GHz = get_cpu_freq_GHz(); // super slow - - if (ts->trials>0) { - - //fprintf(file_name,"Name %25s: Processing %15.3f ms for SF %d, diff_now %15.3f \n", name,(ts->diff_now/(cpu_freq_GHz*1000000.0)),subframe,ts->diff_now); - fprintf(file_name,"%15.3f ms, diff_now %15.3f \n",(ts->diff_now/(cpu_freq_GHz*1000000.0)),(double)ts->diff_now); - - } - } -} - -void print_meas(time_stats_t *ts, const char* name, time_stats_t * total_exec_time, time_stats_t * sf_exec_time) -{ - - if (opp_enabled) { - - static int first_time = 0; - static double cpu_freq_GHz = 0.0; - - if (cpu_freq_GHz == 0.0) - cpu_freq_GHz = get_cpu_freq_GHz(); - - if (first_time == 0) { - first_time=1; - - if ((total_exec_time == NULL) || (sf_exec_time== NULL)) - fprintf(stderr, "%25s %25s %25s %25s %25s %6f\n","Name","Total","Per Trials", "Num Trials","CPU_F_GHz", cpu_freq_GHz); - else - fprintf(stderr, "%25s %25s %25s %20s %15s %6f\n","Name","Total","Average/Frame","Trials", "CPU_F_GHz", cpu_freq_GHz); - } - - if (ts->trials>0) { - //printf("%20s: total: %10.3f ms, average: %10.3f us (%10d trials)\n", name, ts->diff/cpu_freq_GHz/1000000.0, ts->diff/ts->trials/cpu_freq_GHz/1000.0, ts->trials); - - if ((total_exec_time == NULL) || (sf_exec_time== NULL)) { - fprintf(stderr, "%25s: %15.3f ms ; %15.3f us; %15d;\n", - name, - (ts->diff/cpu_freq_GHz/1000000.0), - (ts->diff/ts->trials/cpu_freq_GHz/1000.0), - ts->trials); - } else { - fprintf(stderr, "%25s: %15.3f ms (%5.2f%%); %15.3f us (%5.2f%%); %15d;\n", - name, - (ts->diff/cpu_freq_GHz/1000000.0), - ((ts->diff/cpu_freq_GHz/1000000.0)/(total_exec_time->diff/cpu_freq_GHz/1000000.0))*100, // percentage - (ts->diff/ts->trials/cpu_freq_GHz/1000.0), - ((ts->diff/ts->trials/cpu_freq_GHz/1000.0)/(sf_exec_time->diff/sf_exec_time->trials/cpu_freq_GHz/1000.0))*100, // percentage - ts->trials); - } - } - } - -} - -double get_time_meas_us(time_stats_t *ts) -{ - - static double cpu_freq_GHz = 0.0; - - if (cpu_freq_GHz == 0.0) - cpu_freq_GHz = get_cpu_freq_GHz(); - - if (ts->trials>0) - return (ts->diff/ts->trials/cpu_freq_GHz/1000.0); - - return 0; -} diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_tools/time_meas.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_tools/time_meas.h deleted file mode 100644 index e6bec31176..0000000000 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_tools/time_meas.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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 - */ - -#ifndef __TIME_MEAS_DEFS__H__ -#define __TIME_MEAS_DEFS__H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -// global var to enable openair performance profiler -static int opp_enabled = 1; -double cpu_freq_GHz; -#if defined(__x86_64__) || defined(__i386__) - -typedef struct { - - long long in; - long long diff; - long long diff_now; - long long p_time; /*!< \brief absolute process duration */ - long long diff_square; /*!< \brief process duration square */ - long long max; - int trials; - int meas_flag; -} time_stats_t; -#elif defined(__arm__) -typedef struct { - uint32_t in; - uint32_t diff_now; - uint32_t diff; - uint32_t p_time; /*!< \brief absolute process duration */ - uint32_t diff_square; /*!< \brief process duration square */ - uint32_t max; - int trials; -} time_stats_t; - -#endif -static inline void start_meas(time_stats_t *ts) __attribute__((always_inline)); -static inline void stop_meas(time_stats_t *ts) __attribute__((always_inline)); - - -void print_meas_now(time_stats_t *ts, const char* name, FILE* file_name); -//void print_meas(time_stats_t *ts, const char* name, time_stats_t * total_exec_time, time_stats_t * sf_exec_time); -double get_time_meas_us(time_stats_t *ts); -double get_cpu_freq_GHz(void); - -#if defined(__i386__) -static inline unsigned long long rdtsc_oai(void) __attribute__((always_inline)); -static inline unsigned long long rdtsc_oai(void) -{ - unsigned long long int x; - __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x)); - return x; -} -#elif defined(__x86_64__) -static inline unsigned long long rdtsc_oai(void) __attribute__((always_inline)); -static inline unsigned long long rdtsc_oai(void) -{ - unsigned long long a, d; - __asm__ volatile ("rdtsc" : "=a" (a), "=d" (d)); - return (d<<32) | a; -} - -#elif defined(__arm__) -static inline uint32_t rdtsc_oai(void) __attribute__((always_inline)); -static inline uint32_t rdtsc_oai(void) -{ - uint32_t r = 0; - asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r"(r) ); - return r; -} -#endif - -static inline void start_meas(time_stats_t *ts) -{ - - if (opp_enabled) { - if (ts->meas_flag==0) { - ts->trials++; - ts->in = rdtsc_oai(); - ts->meas_flag=1; - } - else { - ts->in = rdtsc_oai(); - } - } -} - -static inline void stop_meas(time_stats_t *ts) -{ - - if (opp_enabled) { - long long out = rdtsc_oai(); - - ts->diff_now = (out-ts->in); - - ts->diff_now = (out-ts->in); - ts->diff += (out-ts->in); - /// process duration is the difference between two clock points - ts->p_time = (out-ts->in); - ts->diff_square += (out-ts->in)*(out-ts->in); - - if ((out-ts->in) > ts->max) - ts->max = out-ts->in; - - ts->meas_flag=0; - } -} - -static inline void reset_meas(time_stats_t *ts) { - - ts->trials=0; - ts->diff=0; - ts->diff_now=0; - ts->p_time=0; - ts->diff_square=0; - ts->max=0; - ts->meas_flag=0; - -} - -static inline void copy_meas(time_stats_t *dst_ts,time_stats_t *src_ts) -{ - - if (opp_enabled) { - dst_ts->trials=src_ts->trials; - dst_ts->diff=src_ts->diff; - dst_ts->max=src_ts->max; - } -} - -#endif diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h index ae32f6ffb6..a61a15459c 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h @@ -31,7 +31,7 @@ #ifndef __NR_LDPC_TYPES__H__ #define __NR_LDPC_TYPES__H__ -#include "./nrLDPC_tools/time_meas.h" +#include "PHY/TOOLS/time_meas.h" // ============================================================================== // TYPES diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c b/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c index a5e78b6f2b..fdba4e1b65 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c @@ -19,6 +19,17 @@ * contact@openairinterface.org */ +/*!\file PHY/CODING/nrPolar_tools/nr_bitwise_operations.c + * \brief + * \author Turker Yilmaz + * \date 2018 + * \version 0.1 + * \company EURECOM + * \email turker.yilmaz@eurecom.fr + * \note + * \warning +*/ + #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" void nr_bit2byte_uint32_8(uint32_t *in, uint16_t arraySize, uint8_t *out) { @@ -29,7 +40,8 @@ void nr_bit2byte_uint32_8(uint32_t *in, uint16_t arraySize, uint8_t *out) { } } - for (int j = 0; j < arraySize - ((arrayInd-1) * 32); j++) out[j + ((arrayInd-1) * 32)] = (in[(arrayInd-1)] >> j) & 1; + for (int j = 0; j < arraySize - ((arrayInd-1) * 32); j++) + out[j + ((arrayInd-1) * 32)] = (in[(arrayInd-1)] >> j) & 1; } void nr_byte2bit_uint8_32(uint8_t *in, uint16_t arraySize, uint32_t *out) { @@ -43,16 +55,3 @@ void nr_byte2bit_uint8_32(uint8_t *in, uint16_t arraySize, uint32_t *out) { out[i]|=in[(i*32)]; } } - -void nr_crc_bit2bit_uint32_8(uint32_t *in, uint16_t arraySize, uint8_t *out) { - out[0]=0xff; - out[1]=0xff; - out[2]=0xff; - uint8_t arrayInd = ceil(arraySize / 32.0); - for (int i = 0; i < arrayInd; i++) { - out[3+i*4] = ((in[i] & (0x0000000f))<<4) | ((in[i] & (0x000000f0))>>4); - out[4+i*4] = (((in[i] & (0x00000f00))<<4) | ((in[i] & (0x0000f000))>>4))>>8; - out[5+i*4] = (((in[i] & (0x000f0000))<<4) | ((in[i] & (0x00f00000))>>4))>>16; - out[6+i*4] = (((in[i] & (0x0f000000))<<4) | ((in[i] & (0xf0000000))>>4))>>24; - } -} diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_crc_byte.c b/openair1/PHY/CODING/nrPolar_tools/nr_crc_byte.c index ef329b3aaa..461eb7d6f6 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_crc_byte.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_crc_byte.c @@ -21,43 +21,36 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" - // ----- Old implementation ---- uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits){ uint8_t crcPolynomialPattern[25] = {1,1,0,1,1,0,0,1,0,1,0,1,1,0,0,0,1,0,0,0,1,0,1,1,1}; // 1011 0010 1011 0001 0001 0111 D^24 + D^23 + D^21 + D^20 + D^17 + D^15 + D^13 + D^12 + D^8 + D^4 + D^2 + D + 1 - uint8_t crcPolynomialSize = 24;// 24 because crc24c + uint8_t crcPolynomialSize = 24; uint8_t temp1[crcPolynomialSize], temp2[crcPolynomialSize]; uint8_t **crc_generator_matrix = malloc(payloadSizeBits * sizeof(uint8_t *)); if (crc_generator_matrix) - { for (int i = 0; i < payloadSizeBits; i++) - { crc_generator_matrix[i] = malloc(crcPolynomialSize * sizeof(uint8_t)); - } - } for (int i = 0; i < crcPolynomialSize; i++) crc_generator_matrix[payloadSizeBits-1][i]=crcPolynomialPattern[i+1]; for (int i = payloadSizeBits-2; i >= 0; i--){ - for (int j = 0; j < crcPolynomialSize-1; j++) temp1[j]=crc_generator_matrix[i+1][j+1]; + temp1[crcPolynomialSize-1]=0; - for (int j = 0; j < crcPolynomialSize; j++) temp2[j]=crc_generator_matrix[i+1][0]*crcPolynomialPattern[j+1]; + for (int j = 0; j < crcPolynomialSize; j++) + temp2[j]=crc_generator_matrix[i+1][0]*crcPolynomialPattern[j+1]; for (int j = 0; j < crcPolynomialSize; j++){ - if(temp1[j]+temp2[j] == 1){ + if(temp1[j]+temp2[j] == 1) crc_generator_matrix[i][j]=1; - } else { + else crc_generator_matrix[i][j]=0; - } } - } - return crc_generator_matrix; } @@ -70,30 +63,26 @@ uint8_t **crc11_generator_matrix(uint16_t payloadSizeBits){ uint8_t **crc_generator_matrix = malloc(payloadSizeBits * sizeof(uint8_t *)); if (crc_generator_matrix) - { for (int i = 0; i < payloadSizeBits; i++) - { crc_generator_matrix[i] = malloc(crcPolynomialSize * sizeof(uint8_t)); - } - } for (int i = 0; i < crcPolynomialSize; i++) crc_generator_matrix[payloadSizeBits-1][i]=crcPolynomialPattern[i+1]; for (int i = payloadSizeBits-2; i >= 0; i--){ + for (int j = 0; j < crcPolynomialSize-1; j++) + temp1[j]=crc_generator_matrix[i+1][j+1]; - for (int j = 0; j < crcPolynomialSize-1; j++) temp1[j]=crc_generator_matrix[i+1][j+1]; temp1[crcPolynomialSize-1]=0; - for (int j = 0; j < crcPolynomialSize; j++) temp2[j]=crc_generator_matrix[i+1][0]*crcPolynomialPattern[j+1]; + for (int j = 0; j < crcPolynomialSize; j++) + temp2[j]=crc_generator_matrix[i+1][0]*crcPolynomialPattern[j+1]; for (int j = 0; j < crcPolynomialSize; j++){ - if(temp1[j]+temp2[j] == 1){ + if(temp1[j]+temp2[j] == 1) crc_generator_matrix[i][j]=1; - } else { + else crc_generator_matrix[i][j]=0; - } } - } return crc_generator_matrix; @@ -105,33 +94,30 @@ uint8_t **crc6_generator_matrix(uint16_t payloadSizeBits){ // 0110 0001 D^6 + D^5 + 1 uint8_t crcPolynomialSize = 6; uint8_t temp1[crcPolynomialSize], temp2[crcPolynomialSize]; - uint8_t **crc_generator_matrix = malloc(payloadSizeBits * sizeof(uint8_t *)); - if (crc_generator_matrix) - { - for (int i = 0; i < payloadSizeBits; i++) - { - crc_generator_matrix[i] = malloc(crcPolynomialSize * sizeof(uint8_t)); - } - } - for (int i = 0; i < crcPolynomialSize; i++) crc_generator_matrix[payloadSizeBits-1][i]=crcPolynomialPattern[i+1]; + if (crc_generator_matrix) + for (int i = 0; i < payloadSizeBits; i++) + crc_generator_matrix[i] = malloc(crcPolynomialSize * sizeof(uint8_t)); + + for (int i = 0; i < crcPolynomialSize; i++) + crc_generator_matrix[payloadSizeBits-1][i]=crcPolynomialPattern[i+1]; for (int i = payloadSizeBits-2; i >= 0; i--){ + for (int j = 0; j < crcPolynomialSize-1; j++) + temp1[j]=crc_generator_matrix[i+1][j+1]; - for (int j = 0; j < crcPolynomialSize-1; j++) temp1[j]=crc_generator_matrix[i+1][j+1]; temp1[crcPolynomialSize-1]=0; - for (int j = 0; j < crcPolynomialSize; j++) temp2[j]=crc_generator_matrix[i+1][0]*crcPolynomialPattern[j+1]; + for (int j = 0; j < crcPolynomialSize; j++) + temp2[j]=crc_generator_matrix[i+1][0]*crcPolynomialPattern[j+1]; for (int j = 0; j < crcPolynomialSize; j++){ - if(temp1[j]+temp2[j] == 1){ + if(temp1[j]+temp2[j] == 1) crc_generator_matrix[i][j]=1; - } else { + else crc_generator_matrix[i][j]=0; - } } - } return crc_generator_matrix; diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c index 5cf044309e..3c32de916e 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c @@ -21,11 +21,11 @@ /*!\file PHY/CODING/nrPolar_tools/nr_polar_decoder.c * \brief - * \author Turker Yilmaz + * \author Raymond Knopp, Turker Yilmaz * \date 2018 * \version 0.1 * \company EURECOM - * \email turker.yilmaz@eurecom.fr + * \email raymond.knopp@eurecom.fr, turker.yilmaz@eurecom.fr * \note * \warning */ @@ -39,12 +39,11 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "assertions.h" -int8_t polar_decoder( - double *input, - uint8_t *out, - t_nrPolar_params *polarParams, - uint8_t listSize, - uint8_t pathMetricAppr) { +int8_t polar_decoder(double *input, + uint32_t *out, + t_nrPolar_params *polarParams, + uint8_t listSize, + uint8_t pathMetricAppr) { //Assumes no a priori knowledge. uint8_t ***bit = nr_alloc_uint8_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); uint8_t **bitUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True @@ -293,7 +292,7 @@ int8_t polar_decoder( /* * Return bits. */ - //nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out); + nr_byte2bit_uint8_32(polarParams->nr_polar_A, polarParams->payloadBits, out); return(0); } @@ -572,282 +571,6 @@ int8_t polar_decoder_aPriori(double *input, } - -int8_t polar_decoder_aPriori_timing(double *input, - uint32_t *out, - t_nrPolar_params *polarParams, - uint8_t listSize, - uint8_t pathMetricAppr, - double *aPrioriPayload, - double cpuFreqGHz, - FILE *logFile) { - uint8_t ***bit = nr_alloc_uint8_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); - uint8_t **bitUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True - uint8_t **llrUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True - double ***llr = nr_alloc_double_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); - uint8_t **crcChecksum = nr_alloc_uint8_2D_array(polarParams->crcParityBits, 2*listSize); - double *pathMetric = malloc(sizeof(double)*(2*listSize)); - uint8_t *crcState = malloc(sizeof(uint8_t)*(2*listSize)); //0=False, 1=True - - for (int i=0; i<(2*listSize); i++) { - pathMetric[i] = 0; - crcState[i]=1; - } - - for (int i=0; iN; i++) { - llrUpdated[i][polarParams->n]=1; - bitUpdated[i][0]=((polarParams->information_bit_pattern[i]+1) % 2); - } - - uint8_t **extended_crc_generator_matrix = malloc(polarParams->K * sizeof(uint8_t *)); //G_P3 - uint8_t **tempECGM = malloc(polarParams->K * sizeof(uint8_t *)); //G_P2 - - for (int i = 0; i < polarParams->K; i++) { - extended_crc_generator_matrix[i] = malloc(polarParams->crcParityBits * sizeof(uint8_t)); - tempECGM[i] = malloc(polarParams->crcParityBits * sizeof(uint8_t)); - } - - for (int i=0; ipayloadBits; i++) { - for (int j=0; jcrcParityBits; j++) { - tempECGM[i][j]=polarParams->crc_generator_matrix[i][j]; - } - } - - for (int i=polarParams->payloadBits; iK; i++) { - for (int j=0; jcrcParityBits; j++) { - if( (i-polarParams->payloadBits) == j ) { - tempECGM[i][j]=1; - } else { - tempECGM[i][j]=0; - } - } - } - - for (int i=0; iK; i++) { - for (int j=0; jcrcParityBits; j++) { - extended_crc_generator_matrix[i][j]=tempECGM[polarParams->interleaving_pattern[i]][j]; - } - } - - //The index of the last 1-valued bit that appears in each column. - uint16_t last1ind[polarParams->crcParityBits]; - - for (int j=0; jcrcParityBits; j++) { - for (int i=0; iK; i++) { - if (extended_crc_generator_matrix[i][j]==1) last1ind[j]=i; - } - } - - double *d_tilde = malloc(sizeof(double) * polarParams->N); - nr_polar_rate_matching(input, d_tilde, polarParams->rate_matching_pattern, polarParams->K, polarParams->N, polarParams->encoderLength); - - for (int j = 0; j < polarParams->N; j++) llr[j][polarParams->n][0]=d_tilde[j]; - - /* - * SCL polar decoder. - */ - uint32_t nonFrozenBit=0; - uint8_t currentListSize=1; - uint8_t decoderIterationCheck=0; - int16_t checkCrcBits=-1; - uint8_t listIndex[2*listSize], copyIndex; - - for (uint16_t currentBit=0; currentBitN; currentBit++) { - updateLLR(llr, llrUpdated, bit, bitUpdated, currentListSize, currentBit, 0, polarParams->N, (polarParams->n+1), pathMetricAppr); - - if (polarParams->information_bit_pattern[currentBit]==0) { //Frozen bit. - updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit, pathMetricAppr); //approximation=0 --> 11b, approximation=1 --> 12 - } else { //Information or CRC bit. - if ( (polarParams->interleaving_pattern[nonFrozenBit] <= polarParams->payloadBits) && - (aPrioriPayload[polarParams->interleaving_pattern[nonFrozenBit]] == 0) ) { - //Information bit with known value of "0". - updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit, pathMetricAppr); - bitUpdated[currentBit][0]=1; //0=False, 1=True - } else if ( (polarParams->interleaving_pattern[nonFrozenBit] <= polarParams->payloadBits) && - (aPrioriPayload[polarParams->interleaving_pattern[nonFrozenBit]] == 1) ) { - //Information bit with known value of "1". - updatePathMetric(pathMetric, llr, currentListSize, 1, currentBit, pathMetricAppr); - - for (uint8_t i=0; icrcParityBits); - } else { - updatePathMetric2(pathMetric, llr, currentListSize, currentBit, pathMetricAppr); - - for (int i = 0; i < currentListSize; i++) { - for (int j = 0; j < polarParams->N; j++) { - for (int k = 0; k < (polarParams->n+1); k++) { - bit[j][k][i+currentListSize]=bit[j][k][i]; - llr[j][k][i+currentListSize]=llr[j][k][i]; - } - } - } - - for (int i = 0; i < currentListSize; i++) { - bit[currentBit][0][i]=0; - crcState[i+currentListSize]=crcState[i]; - } - - for (int i = currentListSize; i < 2*currentListSize; i++) bit[currentBit][0][i]=1; - - bitUpdated[currentBit][0]=1; - updateCrcChecksum2(crcChecksum, extended_crc_generator_matrix, currentListSize, nonFrozenBit, polarParams->crcParityBits); - currentListSize*=2; - - //Keep only the best "listSize" number of entries. - if (currentListSize > listSize) { - for (uint8_t i = 0; i < 2*listSize; i++) listIndex[i]=i; - - nr_sort_asc_double_1D_array_ind(pathMetric, listIndex, currentListSize); - //sort listIndex[listSize, ..., 2*listSize-1] in descending order. - uint8_t swaps, tempInd; - - for (uint8_t i = 0; i < listSize; i++) { - swaps = 0; - - for (uint8_t j = listSize; j < (2*listSize - i) - 1; j++) { - if (listIndex[j+1] > listIndex[j]) { - tempInd = listIndex[j]; - listIndex[j] = listIndex[j + 1]; - listIndex[j + 1] = tempInd; - swaps++; - } - } - - if (swaps == 0) - break; - } - - //First, backup the best "listSize" number of entries. - for (int k=(listSize-1); k>0; k--) { - for (int i=0; iN; i++) { - for (int j=0; j<(polarParams->n+1); j++) { - bit[i][j][listIndex[(2*listSize-1)-k]]=bit[i][j][listIndex[k]]; - llr[i][j][listIndex[(2*listSize-1)-k]]=llr[i][j][listIndex[k]]; - } - } - } - - for (int k=(listSize-1); k>0; k--) { - for (int i = 0; i < polarParams->crcParityBits; i++) { - crcChecksum[i][listIndex[(2*listSize-1)-k]] = crcChecksum[i][listIndex[k]]; - } - } - - for (int k=(listSize-1); k>0; k--) crcState[listIndex[(2*listSize-1)-k]]=crcState[listIndex[k]]; - - //Copy the best "listSize" number of entries to the first indices. - for (int k = 0; k < listSize; k++) { - if (k > listIndex[k]) { - copyIndex = listIndex[(2*listSize-1)-k]; - } else { //Use the backup. - copyIndex = listIndex[k]; - } - - for (int i = 0; i < polarParams->N; i++) { - for (int j = 0; j < (polarParams->n + 1); j++) { - bit[i][j][k] = bit[i][j][copyIndex]; - llr[i][j][k] = llr[i][j][copyIndex]; - } - } - } - - for (int k = 0; k < listSize; k++) { - if (k > listIndex[k]) { - copyIndex = listIndex[(2*listSize-1)-k]; - } else { //Use the backup. - copyIndex = listIndex[k]; - } - - for (int i = 0; i < polarParams->crcParityBits; i++) { - crcChecksum[i][k]=crcChecksum[i][copyIndex]; - } - } - - for (int k = 0; k < listSize; k++) { - if (k > listIndex[k]) { - copyIndex = listIndex[(2*listSize-1)-k]; - } else { //Use the backup. - copyIndex = listIndex[k]; - } - - crcState[k]=crcState[copyIndex]; - } - - currentListSize = listSize; - } - } - - for (int i=0; icrcParityBits; i++) { - if (last1ind[i]==nonFrozenBit) { - checkCrcBits=i; - break; - } - } - - if ( checkCrcBits > (-1) ) { - for (uint8_t i = 0; i < currentListSize; i++) { - if (crcChecksum[checkCrcBits][i]==1) { - crcState[i]=0; //0=False, 1=True - } - } - } - - for (uint8_t i = 0; i < currentListSize; i++) decoderIterationCheck+=crcState[i]; - - if (decoderIterationCheck==0) { - //perror("[SCL polar decoder] All list entries have failed the CRC checks."); - free(d_tilde); - free(pathMetric); - free(crcState); - nr_free_uint8_3D_array(bit, polarParams->N, (polarParams->n+1)); - nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1)); - nr_free_uint8_2D_array(crcChecksum, polarParams->crcParityBits); - return(-1); - } - - nonFrozenBit++; - decoderIterationCheck=0; - checkCrcBits=-1; - } - } - - for (uint8_t i = 0; i < 2*listSize; i++) listIndex[i]=i; - - nr_sort_asc_double_1D_array_ind(pathMetric, listIndex, currentListSize); - - for (uint8_t i = 0; i < fmin(listSize, (pow(2,polarParams->crcCorrectionBits)) ); i++) { - if ( crcState[listIndex[i]] == 1 ) { - for (int j = 0; j < polarParams->N; j++) polarParams->nr_polar_U[j]=bit[j][0][listIndex[i]]; - - //Extract the information bits (û to ĉ) - nr_polar_info_bit_extraction(polarParams->nr_polar_U, polarParams->nr_polar_CPrime, polarParams->information_bit_pattern, polarParams->N); - //Deinterleaving (ĉ to b) - nr_polar_deinterleaver(polarParams->nr_polar_CPrime, polarParams->nr_polar_B, polarParams->interleaving_pattern, polarParams->K); - - //Remove the CRC (â) - for (int j = 0; j < polarParams->payloadBits; j++) polarParams->nr_polar_A[j]=polarParams->nr_polar_B[j]; - - break; - } - } - - free(d_tilde); - free(pathMetric); - free(crcState); - nr_free_uint8_3D_array(bit, polarParams->N, (polarParams->n+1)); - nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1)); - nr_free_uint8_2D_array(crcChecksum, polarParams->crcParityBits); - nr_free_uint8_2D_array(extended_crc_generator_matrix, polarParams->K); - nr_free_uint8_2D_array(tempECGM, polarParams->K); - /* - * Return bits. - */ - nr_byte2bit_uint8_32(polarParams->nr_polar_A, polarParams->payloadBits, out); - return(0); -} - int8_t polar_decoder_dci(double *input, uint32_t *out, t_nrPolar_params *polarParams, diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index f6c66e89dc..675015a712 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -21,11 +21,11 @@ /*!\file PHY/CODING/nrPolar_tools/nr_polar_defs.h * \brief - * \author Turker Yilmaz + * \author Raymond Knopp, Turker Yilmaz * \date 2018 * \version 0.1 * \company EURECOM - * \email turker.yilmaz@eurecom.fr + * \email raymond.knopp@eurecom.fr, turker.yilmaz@eurecom.fr * \note * \warning */ @@ -105,7 +105,7 @@ struct nrPolar_params { int16_t *Q_PC_N; uint8_t *information_bit_pattern; uint16_t *channel_interleaver_pattern; - uint32_t crc_polynomial; + //uint32_t crc_polynomial; uint8_t **crc_generator_matrix; //G_P uint8_t **G_N; @@ -116,7 +116,6 @@ struct nrPolar_params { uint64_t cprime_tab1[32][256]; uint64_t B_tab0[32][256]; uint64_t B_tab1[32][256]; - uint32_t *crc256Table; uint8_t **extended_crc_generator_matrix; //lowercase: bits, Uppercase: Bits stored in bytes //polar_encoder vectors @@ -151,7 +150,7 @@ void polar_encoder_fast(uint64_t *A, t_nrPolar_params *polarParams); int8_t polar_decoder(double *input, - uint8_t *output, + uint32_t *output, t_nrPolar_params *polarParams, uint8_t listSize, uint8_t pathMetricAppr); @@ -167,15 +166,6 @@ int8_t polar_decoder_aPriori(double *input, uint8_t pathMetricAppr, double *aPrioriPayload); -int8_t polar_decoder_aPriori_timing(double *input, - uint32_t *output, - t_nrPolar_params *polarParams, - uint8_t listSize, - uint8_t pathMetricAppr, - double *aPrioriPayload, - double cpuFreqGHz, - FILE *logFile); - int8_t polar_decoder_dci(double *input, uint32_t *out, t_nrPolar_params *polarParams, @@ -192,9 +182,9 @@ void init_polar_deinterleaver_table(t_nrPolar_params *polarParams); void nr_polar_print_polarParams(t_nrPolar_params *polarParams); -t_nrPolar_params *nr_polar_params ( int8_t messageType, - uint16_t messageLength, - uint8_t aggregation_level); +t_nrPolar_params *nr_polar_params (int8_t messageType, + uint16_t messageLength, + uint8_t aggregation_level); uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level); @@ -256,16 +246,18 @@ void nr_polar_info_bit_extraction(uint8_t *input, uint16_t size); void nr_bit2byte_uint32_8(uint32_t *in, - uint16_t arraySize, - uint8_t *out); + uint16_t arraySize, + uint8_t *out); void nr_byte2bit_uint8_32(uint8_t *in, - uint16_t arraySize, - uint32_t *out); + uint16_t arraySize, + uint32_t *out); -void nr_crc_bit2bit_uint32_8(uint32_t *in, - uint16_t arraySize, - uint8_t *out); +uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits); + +uint8_t **crc11_generator_matrix(uint16_t payloadSizeBits); + +uint8_t **crc6_generator_matrix(uint16_t payloadSizeBits); void nr_polar_bit_insertion(uint8_t *input, uint8_t *output, @@ -370,12 +362,6 @@ void updateCrcChecksum2(uint8_t **crcChecksum, uint32_t i2, uint8_t len); -uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits); - -uint8_t **crc11_generator_matrix(uint16_t payloadSizeBits); - -uint8_t **crc6_generator_matrix(uint16_t payloadSizeBits); - //Also nr_polar_rate_matcher static inline void nr_polar_interleaver(uint8_t *input, uint8_t *output, @@ -385,12 +371,10 @@ static inline void nr_polar_interleaver(uint8_t *input, } static inline void nr_polar_deinterleaver(uint8_t *input, - uint8_t *output, - uint16_t *pattern, - uint16_t size) { - for (int i=0; ipayloadBits)>>8); #endif nr_bit2byte_uint32_8_t((uint32_t*)&B, polarParams->K, polarParams->nr_polar_B);*/ - nr_bit2byte_uint32_8((uint32_t *)in, polarParams->payloadBits, polarParams->nr_polar_A); + nr_bit2byte_uint32_8(in, polarParams->payloadBits, polarParams->nr_polar_A); /* * Bytewise operations */ //Calculate CRC. nr_matrix_multiplication_uint8_1D_uint8_2D(polarParams->nr_polar_A, - polarParams->crc_generator_matrix, - polarParams->nr_polar_crc, - polarParams->payloadBits, - polarParams->crcParityBits); + polarParams->crc_generator_matrix, + polarParams->nr_polar_crc, + polarParams->payloadBits, + polarParams->crcParityBits); for (uint8_t i = 0; i < polarParams->crcParityBits; i++) polarParams->nr_polar_crc[i] = (polarParams->nr_polar_crc[i] % 2); @@ -78,6 +77,8 @@ void polar_encoder(uint32_t *in, for (int i = 0; iK; i++) B2 = B2 | ((uint64_t)polarParams->nr_polar_B[i] << i); printf("polar_B %llx\n",B2); + for (int i=0; i< polarParams->payloadBits; i++) printf("a[%d]=%d\n", i, polarParams->nr_polar_A[i]); + for (int i=0; i< polarParams->K; i++) printf("b[%d]=%d\n", i, polarParams->nr_polar_B[i]); #endif /* for (int j=0;jcrcParityBits;j++) { for (int i=0;ipayloadBits;i++) @@ -116,10 +117,10 @@ void polar_encoder(uint32_t *in, polarParams->nr_polar_U[247]=1; polarParams->nr_polar_U[253]=1;*/ nr_matrix_multiplication_uint8_1D_uint8_2D(polarParams->nr_polar_U, - polarParams->G_N, - polarParams->nr_polar_D, - polarParams->N, - polarParams->N); + polarParams->G_N, + polarParams->nr_polar_D, + polarParams->N, + polarParams->N); for (uint16_t i = 0; i < polarParams->N; i++) polarParams->nr_polar_D[i] = (polarParams->nr_polar_D[i] % 2); @@ -169,35 +170,29 @@ void polar_encoder_dci(uint32_t *in, #ifdef DEBUG_POLAR_ENCODER_DCI printf("[polar_encoder_dci] A: "); - for (int i=0; ipayloadBits; i++) printf("%d-", polarParams->nr_polar_A[i]); - printf("\n"); + printf("[polar_encoder_dci] APrime: "); - for (int i=0; iK; i++) printf("%d-", polarParams->nr_polar_APrime[i]); - printf("\n"); + printf("[polar_encoder_dci] GP: "); - for (int i=0; icrcParityBits; i++) printf("%d-", polarParams->crc_generator_matrix[0][i]); - printf("\n"); #endif //Calculate CRC. nr_matrix_multiplication_uint8_1D_uint8_2D(polarParams->nr_polar_APrime, - polarParams->crc_generator_matrix, - polarParams->nr_polar_crc, - polarParams->K, - polarParams->crcParityBits); + polarParams->crc_generator_matrix, + polarParams->nr_polar_crc, + polarParams->K, + polarParams->crcParityBits); for (uint8_t i = 0; i < polarParams->crcParityBits; i++) polarParams->nr_polar_crc[i] = (polarParams->nr_polar_crc[i] % 2); #ifdef DEBUG_POLAR_ENCODER_DCI printf("[polar_encoder_dci] CRC: "); - for (int i=0; icrcParityBits; i++) printf("%d-", polarParams->nr_polar_crc[i]); - printf("\n"); #endif @@ -209,55 +204,16 @@ void polar_encoder_dci(uint32_t *in, polarParams->nr_polar_B[i]= polarParams->nr_polar_crc[i-(polarParams->payloadBits)]; //Scrambling (b to c) - for (int i=0; i<16; i++) { - polarParams->nr_polar_B[polarParams->payloadBits+8+i] = - ( polarParams->nr_polar_B[polarParams->payloadBits+8+i] + ((n_RNTI>>(15-i))&1) ) % 2; - } + for (int i=0; i<16; i++) + polarParams->nr_polar_B[polarParams->payloadBits+8+i]=( polarParams->nr_polar_B[polarParams->payloadBits+8+i] + ((n_RNTI>>(15-i))&1) ) % 2; - /* //(a to a') - nr_crc_bit2bit_uint32_8_t(in, polarParams->payloadBits, polarParams->nr_polar_aPrime); - //Parity bits computation (p) - polarParams->crcBit = crc24c(polarParams->nr_polar_aPrime, (polarParams->payloadBits+polarParams->crcParityBits)); - #ifdef DEBUG_POLAR_ENCODER_DCI - printf("[polar_encoder_dci] crc: 0x%08x\n", polarParams->crcBit); - for (int i=0; i<32; i++) - { - printf("%d\n",((polarParams->crcBit)>>i)&1); - } - #endif - //(a to b) - // - // Bytewise operations - // - uint8_t arrayInd = ceil(polarParams->payloadBits / 8.0); - for (int i=0; inr_polar_B[j+(i*8)] = ((polarParams->nr_polar_aPrime[3+i]>>(7-j)) & 1); - } - } - for (int i=0; i<((polarParams->payloadBits)%8); i++) { - polarParams->nr_polar_B[i+(arrayInd-1)*8] = ((polarParams->nr_polar_aPrime[3+(arrayInd-1)]>>(7-i)) & 1); - } - for (int i=0; i<8; i++) { - polarParams->nr_polar_B[polarParams->payloadBits+i] = ((polarParams->crcBit)>>(31-i))&1; - } - //Scrambling (b to c) - for (int i=0; i<16; i++) { - polarParams->nr_polar_B[polarParams->payloadBits+8+i] = - ( (((polarParams->crcBit)>>(23-i))&1) + ((n_RNTI>>(15-i))&1) ) % 2; - }*/ #ifdef DEBUG_POLAR_ENCODER_DCI printf("[polar_encoder_dci] B: "); - for (int i = 0; i < polarParams->K; i++) printf("%d-", polarParams->nr_polar_B[i]); - printf("\n"); #endif //Interleaving (c to c') - nr_polar_interleaver(polarParams->nr_polar_B, - polarParams->nr_polar_CPrime, - polarParams->interleaving_pattern, - polarParams->K); + nr_polar_interleaver(polarParams->nr_polar_B, polarParams->nr_polar_CPrime, polarParams->interleaving_pattern, polarParams->K); //Bit insertion (c' to u) nr_polar_bit_insertion(polarParams->nr_polar_CPrime, polarParams->nr_polar_U, @@ -268,13 +224,11 @@ void polar_encoder_dci(uint32_t *in, polarParams->n_pc); //Encoding (u to d) nr_matrix_multiplication_uint8_1D_uint8_2D(polarParams->nr_polar_U, - polarParams->G_N, - polarParams->nr_polar_D, - polarParams->N, - polarParams->N); - - for (uint16_t i = 0; i < polarParams->N; i++) - polarParams->nr_polar_D[i] = (polarParams->nr_polar_D[i] % 2); + polarParams->G_N, + polarParams->nr_polar_D, + polarParams->N, + polarParams->N); + for (uint16_t i = 0; i < polarParams->N; i++) polarParams->nr_polar_D[i] = (polarParams->nr_polar_D[i] % 2); //Rate matching //Sub-block interleaving (d to y) and Bit selection (y to e) @@ -288,16 +242,11 @@ void polar_encoder_dci(uint32_t *in, nr_byte2bit_uint8_32(polarParams->nr_polar_E, polarParams->encoderLength, out); #ifdef DEBUG_POLAR_ENCODER_DCI printf("[polar_encoder_dci] E: "); - for (int i = 0; i < polarParams->encoderLength; i++) printf("%d-", polarParams->nr_polar_E[i]); uint8_t outputInd = ceil(polarParams->encoderLength / 32.0); printf("\n[polar_encoder_dci] out: "); - - for (int i = 0; i < outputInd; i++) { - printf("[%d]->0x%08x\t", i, out[i]); - } - + for (int i = 0; i < outputInd; i++) printf("[%d]->0x%08x\t", i, out[i]); #endif } diff --git a/openair1/PHY/CODING/nrSmallBlock/decodeSmallBlock.c b/openair1/PHY/CODING/nrSmallBlock/decodeSmallBlock.c index 8b53944455..3dd570cc18 100644 --- a/openair1/PHY/CODING/nrSmallBlock/decodeSmallBlock.c +++ b/openair1/PHY/CODING/nrSmallBlock/decodeSmallBlock.c @@ -48,7 +48,7 @@ uint16_t decodeSmallBlock(int8_t *in, uint8_t len){ int16_t Rhat[NR_SMALL_BLOCK_CODED_BITS] = {0}, Rhatabs[NR_SMALL_BLOCK_CODED_BITS] = {0}; uint16_t maxVal; uint8_t maxInd = 0; - int jmax = (1<<(len-1)); + uint8_t jmax = (1<<(len-1)); for (int j = 0; j < jmax; ++j) for (int k = 0; k < NR_SMALL_BLOCK_CODED_BITS; ++k) Rhat[j] += in[k] * hadamard32InterleavedTransposed[j][k]; diff --git a/openair1/PHY/CODING/nr_polar_init.c b/openair1/PHY/CODING/nr_polar_init.c index dd0056b3b5..f158d44303 100644 --- a/openair1/PHY/CODING/nr_polar_init.c +++ b/openair1/PHY/CODING/nr_polar_init.c @@ -21,19 +21,16 @@ /*!\file PHY/CODING/nr_polar_init.h * \brief - * \author Turker Yilmaz + * \author Turker Yilmaz, Raymond Knopp * \date 2018 * \version 0.1 * \company EURECOM - * \email turker.yilmaz@eurecom.fr + * \email turker.yilmaz@eurecom.fr, raymond.knopp@eurecom.fr * \note * \warning */ -#include "nrPolar_tools/nr_polar_defs.h" -#include "PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h" -#include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h" -#include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" +#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/NR_TRANSPORT/nr_dci.h" static int intcmp(const void *p1,const void *p2) { @@ -95,7 +92,9 @@ static void nr_polar_init(t_nrPolar_params * *polarParams, } newPolarInitNode->K = newPolarInitNode->payloadBits + newPolarInitNode->crcParityBits; // Number of bits to encode. - newPolarInitNode->N = nr_polar_output_length(newPolarInitNode->K, newPolarInitNode->encoderLength, newPolarInitNode->n_max); + newPolarInitNode->N = nr_polar_output_length(newPolarInitNode->K, + newPolarInitNode->encoderLength, + newPolarInitNode->n_max); newPolarInitNode->n = log2(newPolarInitNode->N); newPolarInitNode->G_N = nr_polar_kronecker_power_matrices(newPolarInitNode->n); //polar_encoder vectors: @@ -182,9 +181,9 @@ void nr_polar_print_polarParams(t_nrPolar_params *polarParams) { return; } -t_nrPolar_params *nr_polar_params ( int8_t messageType, - uint16_t messageLength, - uint8_t aggregation_level) { +t_nrPolar_params *nr_polar_params (int8_t messageType, + uint16_t messageLength, + uint8_t aggregation_level) { static t_nrPolar_params *polarList = NULL; nr_polar_init(&polarList, messageType,messageLength,aggregation_level); t_nrPolar_params *polarParams=polarList; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.h b/openair1/PHY/NR_TRANSPORT/nr_dci.h index 21fcd06c09..f53f5be282 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.h @@ -25,8 +25,6 @@ #include "PHY/defs_gNB.h" #include "PHY/NR_REFSIG/nr_refsig.h" -typedef unsigned __int128 uint128_t; - uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format, nfapi_nr_rnti_type_e rnti_type, uint16_t N_RB, diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.h b/openair1/PHY/NR_TRANSPORT/nr_dlsch.h index 06969eded0..102062f698 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.h @@ -96,6 +96,8 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch); void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch); +void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch); + int nr_dlsch_encoding(unsigned char *a, uint8_t subframe, NR_gNB_DLSCH_t *dlsch, diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index ace93e4ee3..bd6acb16d3 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -171,6 +171,104 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8 return(NULL); } +void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch) +{ + unsigned char i, j; + + if (ulsch) { + ulsch->harq_mask = 0; + ulsch->bundling = 0; + ulsch->beta_offset_cqi_times8 = 0; + ulsch->beta_offset_ri_times8 = 0; + ulsch->beta_offset_harqack_times8 = 0; + ulsch->Msg3_active = 0; + ulsch->Msg3_flag = 0; + ulsch->Msg3_subframe = 0; + ulsch->Msg3_frame = 0; + ulsch->rnti = 0; + ulsch->rnti_type = 0; + ulsch->cyclicShift = 0; + ulsch->cooperation_flag = 0; + ulsch->Mlimit = 0; + ulsch->max_ldpc_iterations = 0; + ulsch->last_iteration_cnt = 0; + ulsch->num_active_cba_groups = 0; + for (i=0;icba_rnti[i] = 0; + for (i=0;iharq_process_id[i] = 0; + + for (i=0; iharq_processes[i]){ + /// Nfapi ULSCH PDU + //nfapi_nr_ul_config_ulsch_pdu ulsch_pdu; + ulsch->harq_processes[i]->frame=0; + ulsch->harq_processes[i]->subframe=0; + ulsch->harq_processes[i]->round=0; + ulsch->harq_processes[i]->TPC=0; + ulsch->harq_processes[i]->mimo_mode=0; + ulsch->harq_processes[i]->dci_alloc=0; + ulsch->harq_processes[i]->rar_alloc=0; + ulsch->harq_processes[i]->status=0; + ulsch->harq_processes[i]->subframe_scheduling_flag=0; + ulsch->harq_processes[i]->subframe_cba_scheduling_flag=0; + ulsch->harq_processes[i]->phich_active=0; + ulsch->harq_processes[i]->phich_ACK=0; + ulsch->harq_processes[i]->previous_first_rb=0; + ulsch->harq_processes[i]->handled=0; + ulsch->harq_processes[i]->delta_TF=0; + + ulsch->harq_processes[i]->TBS=0; + /// Pointer to the payload (38.212 V15.4.0 section 5.1) + //uint8_t *b; + ulsch->harq_processes[i]->B=0; + /// Pointers to code blocks after code block segmentation and CRC attachment (38.212 V15.4.0 section 5.2.2) + //uint8_t *c[MAX_NUM_NR_ULSCH_SEGMENTS]; + ulsch->harq_processes[i]->K=0; + ulsch->harq_processes[i]->F=0; + ulsch->harq_processes[i]->C=0; + /// Pointers to code blocks after LDPC coding (38.212 V15.4.0 section 5.3.2) + //int16_t *d[MAX_NUM_NR_ULSCH_SEGMENTS]; + /// LDPC processing buffer + //t_nrLDPC_procBuf* p_nrLDPC_procBuf[MAX_NUM_NR_ULSCH_SEGMENTS]; + ulsch->harq_processes[i]->Z=0; + /// code blocks after bit selection in rate matching for LDPC code (38.212 V15.4.0 section 5.4.2.1) + //int16_t e[MAX_NUM_NR_DLSCH_SEGMENTS][3*8448]; + ulsch->harq_processes[i]->E; + ulsch->harq_processes[i]->G; + + + ulsch->harq_processes[i]->n_DMRS=0; + ulsch->harq_processes[i]->n_DMRS2=0; + ulsch->harq_processes[i]->previous_n_DMRS=0; + + + ulsch->harq_processes[i]->cqi_crc_status=0; + for (j=0;jharq_processes[i]->o[j]=0; + ulsch->harq_processes[i]->uci_format=0; + ulsch->harq_processes[i]->Or1=0; + ulsch->harq_processes[i]->Or2=0; + ulsch->harq_processes[i]->o_RI[0]=0; ulsch->harq_processes[i]->o_RI[1]=0; + ulsch->harq_processes[i]->O_RI=0; + ulsch->harq_processes[i]->o_ACK[0]=0; ulsch->harq_processes[i]->o_ACK[1]=0; + ulsch->harq_processes[i]->o_ACK[2]=0; ulsch->harq_processes[i]->o_ACK[3]=0; + ulsch->harq_processes[i]->O_ACK=0; + ulsch->harq_processes[i]->V_UL_DAI=0; + /// "q" sequences for CQI/PMI (for definition see 36-212 V8.6 2009-03, p.27) + //int8_t q[MAX_CQI_PAYLOAD]; + ulsch->harq_processes[i]->o_RCC=0; + /// coded and interleaved CQI bits + //int8_t o_w[(MAX_CQI_BITS+8)*3]; + /// coded CQI bits + //int8_t o_d[96+((MAX_CQI_BITS+8)*3)]; + for (j=0;jharq_processes[i]->q_ACK[j]=0; + for (j=0;jharq_processes[i]->q_RI[j]=0; + /// Temporary h sequence to flag PUSCH_x/PUSCH_y symbols which are not scrambled + //uint8_t h[MAX_NUM_CHANNEL_BITS]; + /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) + //int16_t w[MAX_NUM_ULSCH_SEGMENTS][3*(6144+64)]; + } + } + } +} uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, uint8_t UE_id, @@ -608,4 +706,4 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ulsch->last_iteration_cnt = ret; return(ret); -} \ No newline at end of file +} diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 70a34f2c66..7abca59014 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -39,6 +39,7 @@ #include "PHY/CODING/nrLDPC_encoder/defs.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h" #include "common/utils/LOG/vcd_signal_dumper.h" +#include "PHY/NR_TRANSPORT/nr_dlsch.h" @@ -92,7 +93,7 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL, int number_of_harq_pids, u { NR_UE_ULSCH_t *ulsch; - unsigned char exit_flag = 0,i,j,r; + unsigned char exit_flag = 0,i,r; unsigned char bw_scaling =1; switch (N_RB_UL) { @@ -211,7 +212,6 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, uint32_t Tbslbrm; uint8_t nb_re_dmrs; uint16_t length_dmrs; - int i; float Coderate; /////////// diff --git a/openair1/SCHED_NR/fapi_nr_l1.h b/openair1/SCHED_NR/fapi_nr_l1.h index 66eb0fada7..1cd268c3eb 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.h +++ b/openair1/SCHED_NR/fapi_nr_l1.h @@ -32,7 +32,9 @@ #include "PHY/defs_gNB.h" #include "PHY/phy_extern.h" -#include "PHY/LTE_TRANSPORT/transport_proto.h" +//#include "PHY/LTE_TRANSPORT/transport_proto.h" +//#include "PHY/NR_TRANSPORT/nr_transport_common_proto.h +#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "SCHED/sched_eNB.h" #include "SCHED/sched_common.h" #include "SCHED_NR/sched_nr.h" diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 1404fb79f4..b1502c7852 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -494,7 +494,7 @@ int main(int argc, char **argv) { unsigned char *test_input_bit = malloc16(sizeof(unsigned char) * 16 * 68 * 384); unsigned int errors_bit = 0; test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); - estimated_output = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); + //estimated_output = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); NR_UE_DLSCH_t *dlsch0_ue = UE->dlsch[0][0][0]; NR_DL_UE_HARQ_t *harq_process = dlsch0_ue->harq_processes[harq_pid]; diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index c9a8d58b04..4cdf4bed38 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -42,11 +42,13 @@ #include "PHY/MODULATION/modulation_UE.h" #include "PHY/INIT/phy_init.h" #include "PHY/NR_TRANSPORT/nr_transport.h" -//#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" +#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" +//openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h #include "SCHED_NR/sched_nr.h" #include "SCHED_NR_UE/fapi_nr_ue_l1.h" #include "SCHED_NR/fapi_nr_l1.h" +#include "SCHED_NR_UE/defs.h" #include "LAYER2/NR_MAC_gNB/nr_mac_gNB.h" #include "LAYER2/NR_MAC_UE/mac_defs.h" @@ -58,6 +60,7 @@ #include "LAYER2/NR_MAC_UE/mac_proto.h" //#include "LAYER2/NR_MAC_gNB/mac_proto.h" //#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h" +#include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" #include "RRC/NR/MESSAGES/asn1_msg.h" @@ -515,7 +518,7 @@ int main(int argc, char **argv) gNB_mac = RC.nrmac[0]; config_common(0,0,Nid_cell,78,ssb_pattern,(uint64_t)3640000000L,N_RB_DL); - config_nr_mib(0,0,1,kHz30,0,0,0,0); + config_nr_mib(0,0,1,kHz30,0,0,0,0,0); nr_l2_init_ue(); UE_mac = get_mac_inst(0); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index f9d157ace5..e485b4ba41 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -387,20 +387,20 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, // Note: This should not be done in the MAC! for (int ii=0; iiulsch[ii]; + NR_gNB_ULSCH_t *ulsch = RC.gNB[module_idP][CC_id]->ulsch[ii][0]; if((ulsch != NULL) && (ulsch->rnti == rnti)){ LOG_I(MAC, "clean_eNb_ulsch UE %x \n", rnti); - clean_eNb_ulsch(ulsch); + clean_gNB_ulsch(ulsch); } } for (int ii=0; iidlsch[ii][0]; - if((dlsch != NULL) && (dlsch->rnti == rnti)){ - LOG_I(MAC, "clean_eNb_dlsch UE %x \n", rnti); - LOG_E(PHY,"Calling with wrong paramter type\n"); - clean_eNb_dlsch(dlsch); - } + NR_gNB_DLSCH_t *dlsch = RC.gNB[module_idP][CC_id]->dlsch[ii][0]; + if((dlsch != NULL) && (dlsch->rnti == rnti)){ + LOG_I(MAC, "clean_eNb_dlsch UE %x \n", rnti); + LOG_E(PHY,"Calling with wrong parameter type\n"); + clean_gNB_dlsch(dlsch); + } } for(int j = 0; j < 10; j++){ diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 99452c4c7a..6d55ec8139 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -53,10 +53,12 @@ void config_nr_mib(int Mod_idP, void config_common(int Mod_idP, int CC_idP, + int Nid_cell, int nr_bandP, + uint64_t ssb_pattern, uint64_t dl_CarrierFreqP, uint32_t dl_BandwidthP - ); + ); int rrc_mac_config_req_gNB(module_id_t Mod_idP, int CC_id, @@ -89,6 +91,10 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP); +void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, + frame_t frameP, + sub_frame_t slotP); + void nr_configure_css_dci_initial(nfapi_nr_dl_config_pdcch_parameters_rel15_t* pdcch_params, nr_scs_e scs_common, diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 6cd15fd32b..456f06a5ed 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -171,8 +171,4 @@ typedef struct gNB_MAC_INST_s { time_stats_t schedule_pch; } gNB_MAC_INST; -void nr_schedule_css_dlsch_phytest(module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP); - #endif /*__LAYER2_NR_MAC_GNB_H__ */ From 0aec6f7aa17e0b4b7f640eac2157bba81b2d0457 Mon Sep 17 00:00:00 2001 From: yilmazt Date: Sun, 14 Apr 2019 18:39:35 +0200 Subject: [PATCH 10/15] A couple minor warning removals --- openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_dlsch.h | 5 +++++ openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c index 1371cbee1a..9858f16cb0 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c @@ -36,7 +36,7 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "assertions.h" -#include " +#include //input [a_31 a_30 ... a_0] //output [f_31 f_30 ... f_0] [f_63 f_62 ... f_32] ... diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.h b/openair1/PHY/NR_TRANSPORT/nr_dlsch.h index 102062f698..f5f1ba3d0a 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.h @@ -67,6 +67,11 @@ void nr_pdsch_codeword_scrambling(uint8_t *in, uint32_t n_RNTI, uint32_t* out); +void nr_modulation(uint32_t *in, + uint16_t length, + nr_mod_t modulation_type, + int16_t *out); + void nr_pdsch_codeword_modulation(uint32_t *in, uint8_t Qm, uint32_t length, diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index bd6acb16d3..f9d8291423 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -232,8 +232,8 @@ void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch) ulsch->harq_processes[i]->Z=0; /// code blocks after bit selection in rate matching for LDPC code (38.212 V15.4.0 section 5.4.2.1) //int16_t e[MAX_NUM_NR_DLSCH_SEGMENTS][3*8448]; - ulsch->harq_processes[i]->E; - ulsch->harq_processes[i]->G; + ulsch->harq_processes[i]->E=0; + ulsch->harq_processes[i]->G=0; ulsch->harq_processes[i]->n_DMRS=0; @@ -303,7 +303,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, int16_t z [68*384]; int8_t l [68*384]; - int16_t inv_d [68*384]; + //int16_t inv_d [68*384]; uint8_t kc; uint8_t Ilbrm = 0; uint32_t Tbslbrm = 950984; From 463164a4c393eef41492f901d847555ebe080bb4 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sun, 14 Apr 2019 22:41:39 +0200 Subject: [PATCH 11/15] removal of unnecessary include files in fapi_nr_l1.h. --- openair1/SCHED_NR/fapi_nr_l1.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/openair1/SCHED_NR/fapi_nr_l1.h b/openair1/SCHED_NR/fapi_nr_l1.h index 1cd268c3eb..71ef6039f3 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.h +++ b/openair1/SCHED_NR/fapi_nr_l1.h @@ -32,11 +32,6 @@ #include "PHY/defs_gNB.h" #include "PHY/phy_extern.h" -//#include "PHY/LTE_TRANSPORT/transport_proto.h" -//#include "PHY/NR_TRANSPORT/nr_transport_common_proto.h -#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" -#include "SCHED/sched_eNB.h" -#include "SCHED/sched_common.h" #include "SCHED_NR/sched_nr.h" #include "nfapi_nr_interface.h" From 52a420bbede64ab986327fb13568e55c84b45d58 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Thu, 11 Apr 2019 22:45:42 +0200 Subject: [PATCH 12/15] increasing NB_PATTERN_FILES in ci script to account for new smallblocktest --- ci-scripts/oai-ci-vm-tool | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci-scripts/oai-ci-vm-tool b/ci-scripts/oai-ci-vm-tool index ed43e26729..3d9fb87cba 100755 --- a/ci-scripts/oai-ci-vm-tool +++ b/ci-scripts/oai-ci-vm-tool @@ -252,7 +252,7 @@ case $key in VM_NAME=ci-phy-sim ARCHIVES_LOC=phy_sim LOG_PATTERN=.Rel15.txt - NB_PATTERN_FILES=9 + NB_PATTERN_FILES=10 BUILD_OPTIONS="--phy_simulators" VM_MEMORY=8192 RUN_OPTIONS="./run_exec_autotests.bash -g \"01510*\" -q -np -b" @@ -331,7 +331,7 @@ case $key in VM_NAME=ci-phy-sim ARCHIVES_LOC=phy_sim LOG_PATTERN=.Rel15.txt - NB_PATTERN_FILES=9 + NB_PATTERN_FILES=10 BUILD_OPTIONS="--phy_simulators" VM_MEMORY=8192 RUN_OPTIONS="./run_exec_autotests.bash -g \"01510*\" -q -np -b" From 2624dca2fe0ed174e2cfe621396de3f39ec4a1cc Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Fri, 12 Apr 2019 02:56:31 +0200 Subject: [PATCH 13/15] fixing test_case_list --- cmake_targets/autotests/test_case_list.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml index a6c2a97056..792e46cec6 100644 --- a/cmake_targets/autotests/test_case_list.xml +++ b/cmake_targets/autotests/test_case_list.xml @@ -1123,6 +1123,11 @@ (Test2: 6 bits), (Test3: 7 bits), (Test4: 11 bits) + + $OPENAIR_DIR/cmake_targets/build_oai + --phy_simulators -c + $OPENAIR_DIR/cmake_targets/autotests/tools/free_mem.bash + $OPENAIR_DIR/targets/bin/smallblocktest.Rel15 -l 3 -s -4 -d 1 -i 10000 -l 6 -s -4 -d 1 -i 10000 @@ -1135,7 +1140,7 @@ - + execution nr_ulschsim Test cases. (Test1: 106 PRB), (Test2: 217 PRB), From 75f131ad540b7644c829924aee79311249da3a72 Mon Sep 17 00:00:00 2001 From: yilmazt Date: Mon, 15 Apr 2019 21:49:28 +0200 Subject: [PATCH 14/15] --phy_simulators warning removals, except for nr_dlsim. Polar coding old implementation's approximation and a priori information options needs to be corrected or removed --- openair1/PHY/CODING/TESTBENCH/polartest.c | 71 ++++++++++++++----- .../nrPolar_tools/nr_polar_decoding_tools.c | 10 +-- .../PHY/CODING/nrPolar_tools/nr_polar_defs.h | 13 +++- openair1/PHY/INIT/lte_init_ue.c | 4 +- openair1/PHY/INIT/nr_init_ue.c | 6 +- openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h | 2 +- openair1/PHY/NR_TRANSPORT/nr_dci.c | 1 + openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 3 +- openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c | 10 +-- openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c | 9 +-- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 8 +-- .../PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 2 +- .../NR_UE_TRANSPORT/nr_dlsch_demodulation.c | 22 +++--- .../NR_UE_TRANSPORT/nr_transport_proto_ue.h | 15 ++++ .../PHY/NR_UE_TRANSPORT/nr_transport_ue.h | 2 +- .../PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 11 +-- openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c | 12 ++-- openair1/SIMULATION/NR_PHY/dlschsim.c | 43 +++++------ openair1/SIMULATION/NR_PHY/pbchsim.c | 50 ++++++------- openair1/SIMULATION/NR_PHY/ulschsim.c | 37 +++++----- openair2/LAYER2/MAC/config_ue.c | 3 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 1 + 22 files changed, 201 insertions(+), 134 deletions(-) diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index 49e71abbc9..32371df315 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -26,12 +26,13 @@ int main(int argc, char *argv[]) { double SNR, SNR_lin; int16_t nBitError = 0; // -1 = Decoding failed (All list entries have failed the CRC checks). uint32_t decoderState=0, blockErrorState=0; //0 = Success, -1 = Decoding failed, 1 = Block Error. - uint16_t testLength = NR_POLAR_PBCH_PAYLOAD_BITS, coderLength = NR_POLAR_PBCH_E, blockErrorCumulative=0, bitErrorCumulative=0; + uint16_t testLength = NR_POLAR_PBCH_PAYLOAD_BITS, coderLength = NR_POLAR_PBCH_E; + uint16_t blockErrorCumulative=0, bitErrorCumulative=0, aPrioriLength=0; double timeEncoderCumulative = 0, timeDecoderCumulative = 0; - uint8_t aggregation_level = 8, decoderListSize = 8, pathMetricAppr = 0, logFlag = 0; + uint8_t aggregation_level = 8, decoderListSize = 8, pathMetricAppr = 0, logFlag = 0, aPrioriFlag=0; uint16_t rnti=0; - while ((arguments = getopt (argc, argv, "s:d:f:m:i:l:a:hqgFL:K:")) != -1) + while ((arguments = getopt (argc, argv, "s:d:f:m:i:l:a:p:hqgFL:k:")) != -1) switch (arguments) { case 's': SNRstart = atof(optarg); @@ -63,6 +64,8 @@ int main(int argc, char *argv[]) { pathMetricAppr = (uint8_t) atoi(optarg); break; + + case 'q': decoder_int16 = 1; break; @@ -86,7 +89,7 @@ int main(int argc, char *argv[]) { } break; - case 'K': + case 'k': testLength=atoi(optarg); if (testLength < 12 || testLength > 60) { printf("Illegal packet bitlength %d \n",testLength); @@ -94,10 +97,19 @@ int main(int argc, char *argv[]) { } break; + case 'p': + aPrioriLength = (uint8_t) atoi(optarg); + if (aPrioriLength > testLength){ + printf("A priori information(%d) cannot be larger than test length(%d)\n",aPrioriLength, testLength); + exit(-1); + } + aPrioriFlag = 1; + break; + case 'h': printf("./polartest\nOptions\n-h Print this help\n-s SNRstart (dB)\n-d SNRinc (dB)\n-f SNRstop (dB)\n-m [0=PBCH|1=DCI|2=UCI]\n" "-i Number of iterations\n-l decoderListSize\n-a pathMetricAppr\n-q Flag for optimized coders usage\n-F Flag for test results logging\n" - "-L aggregation level (for DCI)\n-K packet_length (bits) for DCI/UCI\n"); + "-L aggregation level (for DCI)\n-k packet_length (bits) for DCI/UCI\n-p (Only for PBCH for now) A priori information length used in polar decoder\n"); exit(-1); break; @@ -171,6 +183,12 @@ if (logFlag){ double modulatedInput[coderLength]; //channel input double channelOutput[coderLength]; //add noise int16_t channelOutput_int16[coderLength]; + + //A priori knowledge about the payload is assumed according to "aPrioriFlag". + double aPrioriArray[testLength]; + uint8_t testInputByte[testLength]; + uint16_t aPrioriInd[aPrioriLength]; + t_nrPolar_params *currentPtr = nr_polar_params(polarMessageType, testLength, aggregation_level); #ifdef DEBUG_DCI_POLAR_PARAMS @@ -214,11 +232,6 @@ if (logFlag){ return 0; #endif - // We assume no a priori knowledge available about the payload. - double aPrioriArray[currentPtr->payloadBits]; - - for (int i=0; ipayloadBits; i++) aPrioriArray[i] = NAN; - for (SNR = SNRstart; SNR <= SNRstop; SNR += SNRinc) { printf("SNR %f\n",SNR); SNR_lin = pow(10, SNR/10); @@ -232,10 +245,22 @@ if (logFlag){ } testInput[i] |= ( ((uint32_t) (rand()%2)) &1); } + //Generate random a priori information in "aPrioriArray", if "aPrioriFlag" is set. + if (aPrioriFlag){ + nr_bit2byte_uint32_8(testInput, testLength, testInputByte); + for (int i=0; i0x%08x\n", testInput[0]); - //for (int i=0; i<32; i++) printf("%d-",(testInput[0]>>i)&1); printf("\n"); + for (int i=0; i<32; i++) printf("testInput:%d-testInputByte:%d-aPrioriArray:%f\n",(testInput[0]>>i)&1, testInputByte[i], aPrioriArray[i]); #endif int len_mod64=currentPtr->payloadBits&63; ((uint64_t *)testInput)[currentPtr->payloadBits/64]&=((((uint64_t)1)< PBCH, 1 --> DCI, -1 --> UCI - if (polarMessageType == 0) - decoderState = polar_decoder(channelOutput, - estimatedOutput, - currentPtr, - decoderListSize, - NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION); - else if (polarMessageType == 1) + if (polarMessageType == 0) { + if (aPrioriFlag) { + decoderState = polar_decoder_aPriori(channelOutput, + estimatedOutput, + currentPtr, + decoderListSize, + NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION, + aPrioriArray); + } else { + decoderState = polar_decoder(channelOutput, + estimatedOutput, + currentPtr, + decoderListSize, + NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION); + } + } else if (polarMessageType == 1) { decoderState = polar_decoder_dci(channelOutput, estimatedOutput, currentPtr, decoderListSize, NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION, rnti); + } } stop_meas(&timeDecoder); diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c index 38f78bc47b..11aa5d98a4 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c @@ -97,12 +97,12 @@ void updatePathMetric(double *pathMetric, uint8_t approximation) { if (approximation) { //eq. (12) - for (uint8_t i=0; ialpha; int16_t *alpha_l=node->left->alpha; int16_t *betal = node->left->beta; @@ -390,7 +390,7 @@ void applyFtoleft(t_nrPolar_params *pp, decoder_node_t *node) { } } -void applyGtoright(t_nrPolar_params *pp,decoder_node_t *node) { +void applyGtoright(const t_nrPolar_params *pp,decoder_node_t *node) { int16_t *alpha_v=node->alpha; int16_t *alpha_r=node->right->alpha; @@ -461,7 +461,7 @@ void applyGtoright(t_nrPolar_params *pp,decoder_node_t *node) { int16_t all1[16] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; -void computeBeta(t_nrPolar_params *pp,decoder_node_t *node) { +void computeBeta(const t_nrPolar_params *pp,decoder_node_t *node) { int16_t *betav = node->beta; int16_t *betal = node->left->beta; diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index b104e550c6..68e7543d5d 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -175,8 +175,17 @@ int8_t polar_decoder_dci(double *input, uint8_t pathMetricAppr, uint16_t n_RNTI); -void generic_polar_decoder(const t_nrPolar_params *, - decoder_node_t *); +void generic_polar_decoder(const t_nrPolar_params *pp, + decoder_node_t *node); + +void applyFtoleft(const t_nrPolar_params *pp, + decoder_node_t *node); + +void applyGtoright(const t_nrPolar_params *pp, + decoder_node_t *node); + +void computeBeta(const t_nrPolar_params *pp, + decoder_node_t *node); void build_decoder_tree(t_nrPolar_params *pp); void build_polar_tables(t_nrPolar_params *polarParams); diff --git a/openair1/PHY/INIT/lte_init_ue.c b/openair1/PHY/INIT/lte_init_ue.c index bcdd782073..9c9d67bdc2 100644 --- a/openair1/PHY/INIT/lte_init_ue.c +++ b/openair1/PHY/INIT/lte_init_ue.c @@ -355,7 +355,9 @@ void phy_config_dedicated_scell_ue(uint8_t Mod_id, #endif -void phy_config_harq_ue(module_id_t Mod_id,int CC_id,uint8_t eNB_id, +void phy_config_harq_ue(module_id_t Mod_id, + int CC_id, + uint8_t eNB_id, uint16_t max_harq_tx ) { diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index b2be51f6a2..f5f6ca1523 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -357,8 +357,10 @@ void phy_config_dedicated_scell_ue(uint8_t Mod_id, } #endif -void phy_config_harq_ue(module_id_t Mod_id,int CC_id,uint8_t eNB_id, - uint16_t max_harq_tx ) +void phy_config_harq_ue(module_id_t Mod_id, + int CC_id, + uint8_t eNB_id, + uint16_t max_harq_tx) { int num_of_threads,num_of_code_words; diff --git a/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h b/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h index 98e6f90a53..4c433a5683 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h +++ b/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h @@ -194,7 +194,7 @@ typedef struct { /// allocated CBA RNTI uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP]; /// UL max-harq-retransmission - uint8_t Mlimit; + uint16_t Mlimit; } LTE_UE_ULSCH_t; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 929ac823dd..15e31d9728 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -31,6 +31,7 @@ */ #include "nr_dci.h" +#include "nr_dlsch.h" //#define DEBUG_PDCCH_DMRS //#define DEBUG_DCI diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index e4bec93ddf..dd11cd7867 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -64,8 +64,7 @@ void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m } if (pdcch_params->cr_mapping_type == NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED) { - AssertFatal((N_reg%(bsize*R))==0, "CCE to REG interleaving: Invalid configuration leading to non integer C (N_reg %us, bsize %d R %d)\n", - N_reg, bsize, R); + AssertFatal((N_reg%(bsize*R))==0,"CCE to REG interleaving: Invalid configuration leading to non integer C (N_reg %us, bsize %d R %d)\n",N_reg, bsize, R); C = N_reg/(bsize*R); } diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index 50e836fe58..0a2927d881 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -282,8 +282,8 @@ int nr_dlsch_encoding(unsigned char *a, uint32_t A, Z, F=0; uint32_t *pz = &Z; uint8_t mod_order = rel15.modulation_order; - uint16_t Kr=0,r,r_offset=0,Kr_bytes; - uint8_t *d_tmp[MAX_NUM_DLSCH_SEGMENTS]; + uint16_t Kr=0,r,r_offset=0; + //uint8_t *d_tmp[MAX_NUM_DLSCH_SEGMENTS]; uint8_t BG=1; uint32_t E; uint8_t Ilbrm = 0; @@ -354,13 +354,16 @@ int nr_dlsch_encoding(unsigned char *a, } Kr = dlsch->harq_processes[harq_pid]->K; +#ifdef DEBUG_DLSCH_CODING + uint16_t Kr_bytes; Kr_bytes = Kr>>3; +#endif //printf("segment Z %d k %d Kr %d BG %d\n", *pz,dlsch->harq_processes[harq_pid]->K,Kr,BG); //start_meas(te_stats); for (r=0; rharq_processes[harq_pid]->C; r++) { - d_tmp[r] = &dlsch->harq_processes[harq_pid]->d[r][0]; + //d_tmp[r] = &dlsch->harq_processes[harq_pid]->d[r][0]; //channel_input[r] = &dlsch->harq_processes[harq_pid]->d[r][0]; #ifdef DEBUG_DLSCH_CODING printf("Encoder: B %d F %d \n",dlsch->harq_processes[harq_pid]->B, dlsch->harq_processes[harq_pid]->F); @@ -393,7 +396,6 @@ int nr_dlsch_encoding(unsigned char *a, //stop_meas(te_stats); //printf("end ldpc encoder -- output\n"); - //write_output("enc_input0.m","enc_in0",&dlsch->harq_processes[harq_pid]->c[0][0],Kr_bytes,1,4); #ifdef DEBUG_DLSCH_CODING write_output("enc_input0.m","enc_in0",&dlsch->harq_processes[harq_pid]->c[0][0],Kr_bytes,1,4); write_output("enc_output0.m","enc0",&dlsch->harq_processes[harq_pid]->d[0][0],(3*8*Kr_bytes)+12,1,4); diff --git a/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c b/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c index 9fb73fa994..83d0d72b28 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c @@ -112,12 +112,9 @@ void nr_get_tbs(nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu, nfapi_nr_dl_config_pdcch_parameters_rel15_t params_rel15 = dci_pdu.pdcch_params_rel15; nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_rel15 = &dlsch_pdu->dlsch_pdu_rel15; uint8_t rnti_type = params_rel15.rnti_type; - uint8_t dci_format = params_rel15.dci_format; - uint8_t ss_type = params_rel15.search_space_type; uint8_t N_PRB_oh = ((rnti_type==NFAPI_NR_RNTI_SI)||(rnti_type==NFAPI_NR_RNTI_RA)||(rnti_type==NFAPI_NR_RNTI_P))? 0 : \ (config.pdsch_config.x_overhead.value); uint8_t N_PRB_DMRS = (config.pdsch_config.dmrs_type.value == NFAPI_NR_DMRS_TYPE1)?6:4; //This only works for antenna port 1000 - uint8_t mcs_table = config.pdsch_config.mcs_table.value; uint8_t N_sh_symb = dlsch_rel15->nb_symbols; uint8_t Imcs = dlsch_rel15->mcs_idx; uint16_t N_RE_prime = NR_NB_SC_PER_RB*N_sh_symb - N_PRB_DMRS - N_PRB_oh; @@ -126,7 +123,11 @@ void nr_get_tbs(nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu, uint16_t N_RE, Ninfo, Ninfo_prime, C, TBS=0, R; uint8_t table_idx, Qm, n, scale; - table_idx = 1; //get_table_idx(mcs_table, dci_format, rnti_type, ss_type); + /*uint8_t mcs_table = config.pdsch_config.mcs_table.value; + uint8_t ss_type = params_rel15.search_space_type; + uint8_t dci_format = params_rel15.dci_format; + get_table_idx(mcs_table, dci_format, rnti_type, ss_type);*/ + table_idx = 1; scale = ((table_idx==2)&&((Imcs==20)||(Imcs==26)))?11:10; N_RE = min(156, N_RE_prime)*dlsch_rel15->n_prb; diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index f01a5ef60a..9b309983b1 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -332,7 +332,9 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, //uint8_t rb_count_bit; uint8_t i, j, aarx, bitcnt_coreset_freq_dom=0; int32_t *dl_ch0, *dl_ch0_ext, *rxF, *rxF_ext; +#ifdef NR_PDCCH_DCI_DEBUG int nushiftmod3 = frame_parms->nushift % 3; +#endif uint8_t symbol_mod; symbol_mod = (symbol >= (7 - frame_parms->Ncp)) ? symbol - (7 - frame_parms->Ncp) : symbol; c_rb = n_BWP_start; // c_rb is the common resource block: RB within the BWP @@ -809,8 +811,6 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, // indicates the number of active CORESETs for the current BWP to decode PDCCH: max is 3 (this variable is not useful here, to be removed) //uint8_t coreset_nbr_act; // indicates the number of REG contained in the PDCCH (number of RBs * number of symbols, in CORESET) - uint8_t coreset_nbr_reg; - uint32_t coreset_C; uint32_t coreset_nbr_rb = 0; // for (int j=0; j < coreset_nbr_act; j++) { // for each active CORESET (max number of active CORESETs in a BWP is 3), @@ -829,9 +829,9 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> coreset_freq_dom=(%ld,%lx), coreset_nbr_rb=%d\n", coreset_freq_dom,coreset_freq_dom,coreset_nbr_rb); #endif - coreset_nbr_reg = coreset_time_dur * coreset_nbr_rb; - coreset_C = (uint32_t)(coreset_nbr_reg / (reg_bundle_size_L * coreset_interleaver_size_R)); #ifdef NR_PDCCH_DCI_DEBUG + uint8_t coreset_nbr_reg = coreset_time_dur * coreset_nbr_rb; + uint32_t coreset_C = (uint32_t)(coreset_nbr_reg / (reg_bundle_size_L * coreset_interleaver_size_R)); printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> coreset_nbr_rb=%d, coreset_nbr_reg=%d, coreset_C=(%d/(%d*%d))=%d\n", coreset_nbr_rb, coreset_nbr_reg, coreset_nbr_reg, reg_bundle_size_L,coreset_interleaver_size_R, coreset_C); #endif diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index e56ccd8af7..f534c2d543 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -231,7 +231,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, int16_t z [68*384]; int8_t l [68*384]; //__m128i l; - int16_t inv_d [68*384]; + //int16_t inv_d [68*384]; uint8_t kc; uint8_t Ilbrm = 0; uint32_t Tbslbrm = 950984; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index c99d2ea61b..6bdd153aa5 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -1118,9 +1118,10 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, if (rx_type==rx_IC_dual_stream) { nr_dlsch_layer_demapping(pdsch_vars[eNB_id]->llr, - dlsch[0]->harq_processes[harq_pid]->Nl, - dlsch[0]->harq_processes[harq_pid]->G, - pdsch_vars[eNB_id]->layer_llr); + dlsch[0]->harq_processes[harq_pid]->Nl, + dlsch[0]->harq_processes[harq_pid]->Qm, + dlsch[0]->harq_processes[harq_pid]->G, + pdsch_vars[eNB_id]->layer_llr); } #if UE_TIMING_TRACE @@ -2590,17 +2591,18 @@ unsigned short nr_dlsch_extract_rbs_dual(int **rxdataF, int prb,nb_rb=0; unsigned short k; //int prb_off,prb_off2; - int skip_half=0,l;//sss_symb,pss_symb=0,nsymb + //int skip_half=0,l,sss_symb,pss_symb=0,nsymb; int i,aarx; int32_t *dl_ch0,*dl_ch0p,*dl_ch0_ext,*dl_ch1,*dl_ch1p,*dl_ch1_ext,*rxF,*rxF_ext; - int symbol_mod,pilots=0,j=0; - unsigned char *pmi_loc; + int pilots=0,j=0; + //int symbol_mod; + //unsigned char *pmi_loc; pilots = (symbol==2) ? 1 : 0; //to updated from config k = frame_parms->first_carrier_offset + 516; //0 //nsymb = (frame_parms->Ncp==NORMAL) ? 14:12; - l=symbol; + //l=symbol; for (aarx=0; aarxnb_antennas_rx; aarx++) { @@ -2612,7 +2614,7 @@ unsigned short nr_dlsch_extract_rbs_dual(int **rxdataF, dl_ch1 = &dl_ch_estimates[2+aarx][0]; } - pmi_loc = pmi_ext; + //pmi_loc = pmi_ext; // pointers to extracted RX signals and channel estimates rxF_ext = &rxdataF_ext[aarx][symbol*(nb_rb_pdsch*12)]; @@ -2620,13 +2622,13 @@ unsigned short nr_dlsch_extract_rbs_dual(int **rxdataF, dl_ch1_ext = &dl_ch_estimates_ext[2+aarx][symbol*(nb_rb_pdsch*12)]; for (prb=0; prbN_RB_DL; prb++) { - skip_half=0; + //skip_half=0; if ((frame_parms->N_RB_DL&1) == 0) { // even number of RBs // For second half of RBs skip DC carrier if (k>=frame_parms->ofdm_symbol_size) { - rxF = &rxdataF[aarx][(symbol*(frame_parms->ofdm_symbol_size))]; + rxF = &rxdataF[aarx][(symbol*(frame_parms->ofdm_symbol_size))]; k=k-(frame_parms->ofdm_symbol_size); } 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 48cf637529..ae6716711c 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -1793,6 +1793,21 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, uint16_t n_RB_DLBWP, uint16_t crc_scrambled_values[TOTAL_NBR_SCRAMBLED_VALUES]); +void nr_dlsch_dual_stream_correlation_core(int **dl_ch_estimates_ext, + int **dl_ch_estimates_ext_i, + int **dl_ch_rho_ext, + unsigned char n_tx, + unsigned char n_rx, + unsigned char output_shift, + int length, + int start_point); + +void nr_dlsch_layer_demapping(int16_t **llr_cw, + uint8_t Nl, + uint8_t mod_order, + uint16_t length, + int16_t **llr_layers); + /**@}*/ #endif diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index 2facd85bab..7d2abd9993 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -246,7 +246,7 @@ typedef struct { /// allocated CBA RNTI //uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP]; /// UL max-harq-retransmission - uint8_t Mlimit; + uint16_t Mlimit; } NR_UE_ULSCH_t; typedef struct { diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 7abca59014..95ca86959f 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -204,8 +204,8 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, uint32_t A, Z, F; uint32_t *pz; uint8_t mod_order; - uint16_t Kr,r,r_offset,Kr_bytes; - uint8_t *d_tmp[MAX_NUM_DLSCH_SEGMENTS]; + uint16_t Kr,r,r_offset; + //uint8_t *d_tmp[MAX_NUM_DLSCH_SEGMENTS]; uint8_t BG; uint32_t E; uint8_t Ilbrm; @@ -311,8 +311,10 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, } Kr = harq_process->K; +#ifdef DEBUG_DLSCH_CODING + uint16_t Kr_bytes; Kr_bytes = Kr>>3; - +#endif /////////// ///////////////////////////////////////////////////////////////////////////////////// @@ -325,7 +327,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, //start_meas(te_stats); for (r=0; rC; r++) { - d_tmp[r] = &harq_process->d[r][0]; + //d_tmp[r] = &harq_process->d[r][0]; //channel_input[r] = &harq_process->d[r][0]; #ifdef DEBUG_DLSCH_CODING printf("Encoder: B %d F %d \n",harq_process->B, harq_process->F); @@ -357,7 +359,6 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, //stop_meas(te_stats); //printf("end ldpc encoder -- output\n"); - //write_output("ulsch_enc_input0.m","enc_in0",&harq_process->c[0][0],Kr_bytes,1,4); #ifdef DEBUG_DLSCH_CODING write_output("ulsch_enc_input0.m","enc_in0",&harq_process->c[0][0],Kr_bytes,1,4); write_output("ulsch_enc_output0.m","enc0",&harq_process->d[0][0],(3*8*Kr_bytes)+12,1,4); diff --git a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c index 2327a5036b..41b055a7ff 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c @@ -990,7 +990,7 @@ void nr_uci_encoding(uint64_t payload, // A is the payload size, to be provided in function call uint8_t A = nr_bit; // L is the CRC size - uint8_t L; + //uint8_t L; // E is the rate matching output sequence length as given in TS 38.212 subclause 6.3.1.4.1 uint16_t E=0,E_init; @@ -1047,7 +1047,7 @@ void nr_uci_encoding(uint64_t payload, } *M_bit = E; - int I_seg; + //int I_seg; #ifdef DEBUG_NR_PUCCH_TX printf("\t\t [nr_uci_encoding] start function with fmt=%d, encoding A=%d bits into M_bit=%d (where nrofSymbols=%d,nrofPRB=%d)\n",fmt,A,*M_bit,nrofSymbols,nrofPRB); #endif @@ -1057,19 +1057,19 @@ void nr_uci_encoding(uint64_t payload, // CRC bits are not attached, and coding small block lengths (subclause 5.3.3) } else if (A>=12) { // procedure in subclause 6.3.1.2.1 (UCI encoded by Polar code -> subclause 6.3.1.3.1) - if ((A>=360 && E>=1088)||(A>=1013)) { + /*if ((A>=360 && E>=1088)||(A>=1013)) { I_seg = 1; } else { I_seg = 0; - } + }*/ - if (A>=20) { + /*if (A>=20) { // parity bits (subclause 5.2.1) computed by setting L=11 and using generator polynomial gCRC11(D) (subclause 5.1) L=11; } else if (A<=19) { // parity bits (subclause 5.2.1) computed by setting L=6 and using generator polynomial gCRC6(D) (subclause 5.1) L=6; - } + }*/ // code block segmentation and CRC attachment is performed according to subclause 5.2.1 // polar coding subclause 5.3.1 diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 76cd243b36..1a7a91f625 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -131,21 +131,22 @@ int main(int argc, char **argv) { // int sync_pos, sync_pos_slot; // FILE *rx_frame_file; FILE *output_fd = NULL; - uint8_t write_output_file = 0; + //uint8_t write_output_file = 0; // int subframe_offset; // char fname[40], vname[40]; int trial, n_trials = 1, n_errors = 0, n_false_positive = 0; - uint8_t transmission_mode = 1, n_tx = 1, n_rx = 1; + uint8_t n_tx = 1, n_rx = 1; + //uint8_t transmission_mode = 1; uint16_t Nid_cell = 0; channel_desc_t *gNB2UE; uint8_t extended_prefix_flag = 0; - int8_t interf1 = -21, interf2 = -21; + //int8_t interf1 = -21, interf2 = -21; FILE *input_fd = NULL, *pbch_file_fd = NULL; //char input_val_str[50],input_val_str2[50]; //uint16_t NB_RB=25; SCM_t channel_model = AWGN; //Rayleigh1_anticorr; uint16_t N_RB_DL = 106, mu = 1; - unsigned char frame_type = 0; + //unsigned char frame_type = 0; unsigned char pbch_phase = 0; int frame = 0, subframe = 0; int frame_length_complex_samples; @@ -176,7 +177,7 @@ int main(int argc, char **argv) { while ((c = getopt(argc, argv, "df:hpg:i:j:n:l:m:r:s:S:y:z:M:N:F:R:P:L:")) != -1) { switch (c) { - case 'f': + /*case 'f': write_output_file = 1; output_fd = fopen(optarg, "w"); @@ -185,11 +186,11 @@ int main(int argc, char **argv) { exit(-1); } - break; + break;*/ - case 'd': + /*case 'd': frame_type = 1; - break; + break;*/ case 'g': switch ((char) *optarg) { @@ -228,13 +229,13 @@ int main(int argc, char **argv) { break; - case 'i': + /*case 'i': interf1 = atoi(optarg); break; case 'j': interf2 = atoi(optarg); - break; + break;*/ case 'n': n_trials = atoi(optarg); @@ -331,33 +332,33 @@ int main(int argc, char **argv) { nb_rb = atoi(optarg); break; - case 'x': + /*case 'x': transmission_mode = atoi(optarg); - break; + break;*/ default: case 'h': printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", argv[0]); printf("-h This message\n"); printf("-p Use extended prefix mode\n"); - printf("-d Use TDD\n"); + //printf("-d Use TDD\n"); printf("-n Number of frames to simulate\n"); printf("-s Starting SNR, runs from SNR0 to SNR0 + 5 dB. If n_frames is 1 then just SNR is simulated\n"); printf("-S Ending SNR, runs from SNR0 to SNR1\n"); printf("-t Delay spread for multipath channel\n"); printf("-g [A,B,C,D,E,F,G] Use 3GPP SCM (A,B,C,D) or 36-101 (E-EPA,F-EVA,G-ETU) models (ignores delay spread and Ricean factor)\n"); - printf("-x Transmission mode (1,2,6 for the moment)\n"); + //printf("-x Transmission mode (1,2,6 for the moment)\n"); printf("-y Number of TX antennas used in eNB\n"); printf("-z Number of RX antennas used in UE\n"); - printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); - printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); - printf("-M Multiple SSB positions in burst\n"); + //printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); + //printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); + printf("-M Multiple SSB positions in burst\n"); printf("-N Nid_cell\n"); printf("-R N_RB_DL\n"); printf("-O oversampling factor (1,2,4,8,16)\n"); printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n"); - // printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); - printf("-f Output filename (.txt format) for Pe/SNR results\n"); + //printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); + //printf("-f Output filename (.txt format) for Pe/SNR results\n"); printf("-F Input filename (.txt format) for RX conformance testing\n"); exit(-1); break; @@ -493,7 +494,7 @@ int main(int argc, char **argv) { short *channel_output_fixed = malloc16(sizeof(short) * 16 * 68 * 384); short *channel_output_uncoded = malloc16(sizeof(unsigned short) * 16 * 68 * 384); double errors_bit_uncoded = 0; - unsigned char *estimated_output; + //unsigned char *estimated_output; unsigned char *estimated_output_bit; unsigned char *test_input_bit; unsigned int errors_bit = 0; @@ -514,7 +515,7 @@ int main(int argc, char **argv) { for (i = 0; i < TBS / 8; i++) test_input[i] = (unsigned char) rand(); - estimated_output = harq_process->b; + //estimated_output = harq_process->b; #ifdef DEBUG_DLSCHSIM for (i = 0; i < TBS / 8; i++) printf("test_input[i]=%d \n",test_input[i]); diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 61d4c486f5..4664af3b67 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -92,13 +92,13 @@ int main(int argc, char **argv) uint8_t snr1set=0; int **txdata; double **s_re,**s_im,**r_re,**r_im; - double iqim = 0.0; + //double iqim = 0.0; double ip =0.0; - unsigned char pbch_pdu[6]; + //unsigned char pbch_pdu[6]; // int sync_pos, sync_pos_slot; // FILE *rx_frame_file; FILE *output_fd = NULL; - uint8_t write_output_file=0; + //uint8_t write_output_file=0; //int result; //int freq_offset; // int subframe_offset; @@ -110,8 +110,8 @@ int main(int argc, char **argv) channel_desc_t *gNB2UE; - uint8_t extended_prefix_flag=0; - int8_t interf1=-21,interf2=-21; + //uint8_t extended_prefix_flag=0; + //int8_t interf1=-21,interf2=-21; FILE *input_fd=NULL,*pbch_file_fd=NULL; @@ -126,7 +126,7 @@ int main(int argc, char **argv) int N_RB_DL=273,mu=1; - unsigned char frame_type = 0; + //unsigned char frame_type = 0; unsigned char pbch_phase = 0; int frame=0; @@ -152,7 +152,7 @@ int main(int argc, char **argv) while ((c = getopt (argc, argv, "f:hA:pf:g:i:j:n:o:s:S:t:x:y:z:M:N:F:GR:dP:IL:")) != -1) { switch (c) { - case 'f': + /*case 'f': write_output_file=1; output_fd = fopen(optarg,"w"); @@ -161,11 +161,11 @@ int main(int argc, char **argv) exit(-1); } - break; + break;*/ - case 'd': + /*case 'd': frame_type = 1; - break; + break;*/ case 'g': switch((char)*optarg) { @@ -204,13 +204,13 @@ int main(int argc, char **argv) break; - case 'i': + /*case 'i': interf1=atoi(optarg); break; case 'j': interf2=atoi(optarg); - break; + break;*/ case 'n': n_trials = atoi(optarg); @@ -237,9 +237,9 @@ int main(int argc, char **argv) Td= atof(optarg); break; */ - case 'p': + /*case 'p': extended_prefix_flag=1; - break; + break;*/ /* case 'r': @@ -326,8 +326,8 @@ int main(int argc, char **argv) printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", argv[0]); printf("-h This message\n"); - printf("-p Use extended prefix mode\n"); - printf("-d Use TDD\n"); + //printf("-p Use extended prefix mode\n"); + //printf("-d Use TDD\n"); printf("-n Number of frames to simulate\n"); printf("-s Starting SNR, runs from SNR0 to SNR0 + 5 dB. If n_frames is 1 then just SNR is simulated\n"); printf("-S Ending SNR, runs from SNR0 to SNR1\n"); @@ -336,16 +336,16 @@ int main(int argc, char **argv) printf("-x Transmission mode (1,2,6 for the moment)\n"); printf("-y Number of TX antennas used in eNB\n"); printf("-z Number of RX antennas used in UE\n"); - printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); - printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); + //printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); + //printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); printf("-o Carrier frequency offset in Hz\n"); printf("-M Multiple SSB positions in burst\n"); printf("-N Nid_cell\n"); printf("-R N_RB_DL\n"); printf("-O oversampling factor (1,2,4,8,16)\n"); printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n"); - // printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); - printf("-f Output filename (.txt format) for Pe/SNR results\n"); + //printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); + //printf("-f Output filename (.txt format) for Pe/SNR results\n"); printf("-F Input filename (.txt format) for RX conformance testing\n"); exit (-1); break; @@ -537,10 +537,9 @@ int main(int argc, char **argv) if (output_fd) fwrite(txdata[0],sizeof(int32_t),frame_length_complex_samples,output_fd); - int txlev = signal_energy(&txdata[0][5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0], - frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples); - - // printf("txlev %d (%f)\n",txlev,10*log10(txlev)); + /*int txlev = signal_energy(&txdata[0][5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0], + frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples); + printf("txlev %d (%f)\n",txlev,10*log10(txlev));*/ for (i=0; iul_SCH_Config->retxBSR_Timer) { UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer = diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index cbbd4fcd15..bf07051507 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -48,6 +48,7 @@ #include "pdcp.h" #include "openair1/PHY/defs_gNB.h" +#include "openair1/PHY/NR_TRANSPORT/nr_dlsch.h" //Agent-related headers #include "flexran_agent_extern.h" From 5fa78b4d6e4d048f9ead364066614c423b6134bc Mon Sep 17 00:00:00 2001 From: yilmazt Date: Tue, 16 Apr 2019 17:24:58 +0200 Subject: [PATCH 15/15] Final --phy_simulators warning removals for this branch, and former polar coding function corrections --- common/utils/LOG/log.h | 6 +- openair1/PHY/CODING/TESTBENCH/polartest.c | 69 +---- .../PHY/CODING/TESTBENCH/smallblocktest.c | 12 +- openair1/PHY/CODING/crc_byte.c | 2 +- .../CODING/nrPolar_tools/nr_polar_decoder.c | 292 +----------------- .../nrPolar_tools/nr_polar_decoding_tools.c | 70 ++--- .../PHY/CODING/nrPolar_tools/nr_polar_defs.h | 24 +- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 5 +- openair1/PHY/defs_nr_common.h | 1 - openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 6 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 128 ++++---- .../SCHED_NR_UE/pucch_power_control_ue_nr.c | 25 +- openair1/SIMULATION/NR_PHY/dlsim.c | 65 ++-- openair2/GNB_APP/gnb_config.c | 6 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 27 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 2 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 4 +- openair2/RRC/NR/L2_nr_interface.c | 1 - openair2/RRC/NR/rrc_gNB.c | 15 +- 19 files changed, 209 insertions(+), 551 deletions(-) diff --git a/common/utils/LOG/log.h b/common/utils/LOG/log.h index 8390c3af25..b8a72ece7b 100644 --- a/common/utils/LOG/log.h +++ b/common/utils/LOG/log.h @@ -83,11 +83,11 @@ extern "C" { * @brief LOG defines 9 levels of messages for users. Importance of these levels decrease gradually from 0 to 8 * @{*/ # define OAILOG_DISABLE -1 /*!< \brief disable all LOG messages, cannot be used in LOG macros, use only in LOG module */ -# define OAILOG_ERR 0 /*!< \brief critical error conditions, impact on "must have" fuctinalities */ +# define OAILOG_ERR 0 /*!< \brief critical error conditions, impact on "must have" functionalities */ # define OAILOG_WARNING 1 /*!< \brief warning conditions, shouldn't happen but doesn't impact "must have" functionalities */ # define OAILOG_INFO 2 /*!< \brief informational messages most people don't need, shouldn't impact real-time behavior */ -# define OAILOG_DEBUG 3 /*!< \brief first level debug-level messages, for developers , may impact real-time behavior */ -# define OAILOG_TRACE 4 /*!< \brief second level debug-level messages, for developers ,likely impact real-time behavior*/ +# define OAILOG_DEBUG 3 /*!< \brief first level debug-level messages, for developers, may impact real-time behavior */ +# define OAILOG_TRACE 4 /*!< \brief second level debug-level messages, for developers, likely impact real-time behavior*/ #define NUM_LOG_LEVEL 5 /*!< \brief the number of message levels users have with LOG (OAILOG_DISABLE is not available to user as a level, so it is not included)*/ /* @}*/ diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index 32371df315..76cde6c3be 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -27,9 +27,9 @@ int main(int argc, char *argv[]) { int16_t nBitError = 0; // -1 = Decoding failed (All list entries have failed the CRC checks). uint32_t decoderState=0, blockErrorState=0; //0 = Success, -1 = Decoding failed, 1 = Block Error. uint16_t testLength = NR_POLAR_PBCH_PAYLOAD_BITS, coderLength = NR_POLAR_PBCH_E; - uint16_t blockErrorCumulative=0, bitErrorCumulative=0, aPrioriLength=0; + uint16_t blockErrorCumulative=0, bitErrorCumulative=0; double timeEncoderCumulative = 0, timeDecoderCumulative = 0; - uint8_t aggregation_level = 8, decoderListSize = 8, pathMetricAppr = 0, logFlag = 0, aPrioriFlag=0; + uint8_t aggregation_level = 8, decoderListSize = 8, logFlag = 0; uint16_t rnti=0; while ((arguments = getopt (argc, argv, "s:d:f:m:i:l:a:p:hqgFL:k:")) != -1) @@ -60,12 +60,6 @@ int main(int argc, char *argv[]) { decoderListSize = (uint8_t) atoi(optarg); break; - case 'a': - pathMetricAppr = (uint8_t) atoi(optarg); - break; - - - case 'q': decoder_int16 = 1; break; @@ -97,19 +91,10 @@ int main(int argc, char *argv[]) { } break; - case 'p': - aPrioriLength = (uint8_t) atoi(optarg); - if (aPrioriLength > testLength){ - printf("A priori information(%d) cannot be larger than test length(%d)\n",aPrioriLength, testLength); - exit(-1); - } - aPrioriFlag = 1; - break; - case 'h': printf("./polartest\nOptions\n-h Print this help\n-s SNRstart (dB)\n-d SNRinc (dB)\n-f SNRstop (dB)\n-m [0=PBCH|1=DCI|2=UCI]\n" - "-i Number of iterations\n-l decoderListSize\n-a pathMetricAppr\n-q Flag for optimized coders usage\n-F Flag for test results logging\n" - "-L aggregation level (for DCI)\n-k packet_length (bits) for DCI/UCI\n-p (Only for PBCH for now) A priori information length used in polar decoder\n"); + "-i Number of iterations\n-l decoderListSize\n-q Flag for optimized coders usage\n-F Flag for test results logging\n" + "-L aggregation level (for DCI)\n-k packet_length (bits) for DCI/UCI\n"); exit(-1); break; @@ -148,9 +133,9 @@ int main(int argc, char *argv[]) { if (logFlag){ time (¤tTime); #ifdef DEBUG_POLAR_TIMING - sprintf(fileName,"%s/TIMING_ListSize_%d_pmAppr_%d_Payload_%d_Itr_%d",folderName,decoderListSize,pathMetricAppr,testLength,iterations); + sprintf(fileName,"%s/TIMING_ListSize_%d_Payload_%d_Itr_%d", folderName, decoderListSize, testLength, iterations); #else - sprintf(fileName,"%s/_ListSize_%d_pmAppr_%d_Payload_%d_Itr_%d",folderName,decoderListSize,pathMetricAppr,testLength,iterations); + sprintf(fileName,"%s/_ListSize_%d_Payload_%d_Itr_%d", folderName, decoderListSize, testLength, iterations); #endif strftime(currentTimeInfo, 25, "_%Y-%m-%d-%H-%M-%S.csv", localtime(¤tTime)); strcat(fileName,currentTimeInfo); @@ -184,11 +169,6 @@ if (logFlag){ double channelOutput[coderLength]; //add noise int16_t channelOutput_int16[coderLength]; - //A priori knowledge about the payload is assumed according to "aPrioriFlag". - double aPrioriArray[testLength]; - uint8_t testInputByte[testLength]; - uint16_t aPrioriInd[aPrioriLength]; - t_nrPolar_params *currentPtr = nr_polar_params(polarMessageType, testLength, aggregation_level); #ifdef DEBUG_DCI_POLAR_PARAMS @@ -224,7 +204,7 @@ if (logFlag){ modulated_input[i]=(-1)/sqrt(2); channel_output[i] = modulated_input[i] + (gaussdouble(0.0,1.0) * (1/sqrt(2*SNR_lin))); } - decoderState = polar_decoder_dci(channel_output, dci_est, currentPtrDCI, NR_POLAR_DECODER_LISTSIZE, NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION, rnti); + decoderState = polar_decoder_dci(channel_output, dci_est, currentPtrDCI, NR_POLAR_DECODER_LISTSIZE, rnti); printf("dci_est: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", dci_est[0], dci_est[1], dci_est[2], dci_est[3]); free(encoder_outputByte); free(channel_output); @@ -245,22 +225,10 @@ if (logFlag){ } testInput[i] |= ( ((uint32_t) (rand()%2)) &1); } - //Generate random a priori information in "aPrioriArray", if "aPrioriFlag" is set. - if (aPrioriFlag){ - nr_bit2byte_uint32_8(testInput, testLength, testInputByte); - for (int i=0; i0x%08x\n", testInput[0]); - for (int i=0; i<32; i++) printf("testInput:%d-testInputByte:%d-aPrioriArray:%f\n",(testInput[0]>>i)&1, testInputByte[i], aPrioriArray[i]); #endif int len_mod64=currentPtr->payloadBits&63; ((uint64_t *)testInput)[currentPtr->payloadBits/64]&=((((uint64_t)1)< PBCH, 1 --> DCI, -1 --> UCI if (polarMessageType == 0) { - if (aPrioriFlag) { - decoderState = polar_decoder_aPriori(channelOutput, - estimatedOutput, - currentPtr, - decoderListSize, - NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION, - aPrioriArray); - } else { - decoderState = polar_decoder(channelOutput, - estimatedOutput, - currentPtr, - decoderListSize, - NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION); - } + decoderState = polar_decoder(channelOutput, + estimatedOutput, + currentPtr, + decoderListSize); } else if (polarMessageType == 1) { decoderState = polar_decoder_dci(channelOutput, estimatedOutput, currentPtr, decoderListSize, - NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION, rnti); } } @@ -379,8 +336,8 @@ if (logFlag){ } //Calculate error statistics for the SNR. - printf("[ListSize=%d, Appr=%d] SNR=%+8.3f, BLER=%9.6f, BER=%12.9f, t_Encoder=%9.3fus, t_Decoder=%9.3fus\n", - decoderListSize, pathMetricAppr, SNR, ((double)blockErrorCumulative/iterations), + printf("[ListSize=%d] SNR=%+8.3f, BLER=%9.6f, BER=%12.9f, t_Encoder=%9.3fus, t_Decoder=%9.3fus\n", + decoderListSize, SNR, ((double)blockErrorCumulative/iterations), ((double)bitErrorCumulative / (iterations*testLength)), (double)timeEncoder.diff/timeEncoder.trials/(cpu_freq_GHz*1000.0),(double)timeDecoder.diff/timeDecoder.trials/(cpu_freq_GHz*1000.0)); //(timeEncoderCumulative/iterations),timeDecoderCumulative/iterations); diff --git a/openair1/PHY/CODING/TESTBENCH/smallblocktest.c b/openair1/PHY/CODING/TESTBENCH/smallblocktest.c index 6278420d8a..ee1a228ab8 100644 --- a/openair1/PHY/CODING/TESTBENCH/smallblocktest.c +++ b/openair1/PHY/CODING/TESTBENCH/smallblocktest.c @@ -29,13 +29,14 @@ int main(int argc, char *argv[]) { reset_meas(&timeDecoder); randominit(0); - int arguments, iterations = 1000, matlabDebug = 0, messageLength = 11; + int arguments, iterations = 1000, messageLength = 11; + //int matlabDebug = 0; uint32_t testInput, encoderOutput, codingDifference, nBitError=0, blockErrorState = 0, blockErrorCumulative=0, bitErrorCumulative=0; uint16_t estimatedOutput; double SNRstart = -20.0, SNRstop = 5.0, SNRinc= 0.5; //dB double SNR, SNR_lin, sigma; double modulatedInput[NR_SMALL_BLOCK_CODED_BITS], channelOutput[NR_SMALL_BLOCK_CODED_BITS]; - int16_t channelOutput_int16[NR_SMALL_BLOCK_CODED_BITS]; + //int16_t channelOutput_int16[NR_SMALL_BLOCK_CODED_BITS]; int8_t channelOutput_int8[NR_SMALL_BLOCK_CODED_BITS]; unsigned char qbits=8; @@ -62,10 +63,10 @@ int main(int argc, char *argv[]) { iterations = atoi(optarg); break; - case 'm': + /*case 'm': matlabDebug = 1; //#define DEBUG_POLAR_MATLAB - break; + break;*/ case 'g': iterations = 1; @@ -75,7 +76,8 @@ int main(int argc, char *argv[]) { break; case 'h': - printf("./smallblocktest -s SNRstart -d SNRinc -f SNRstop -l messageLength -i iterations -m Matlab Debug\n"); + //printf("./smallblocktest -s SNRstart -d SNRinc -f SNRstop -l messageLength -i iterations -m Matlab Debug\n"); + printf("./smallblocktest -s SNRstart -d SNRinc -f SNRstop -l messageLength -i iterations\n"); exit(-1); default: diff --git a/openair1/PHY/CODING/crc_byte.c b/openair1/PHY/CODING/crc_byte.c index 60bddd87f0..ee5c302adb 100644 --- a/openair1/PHY/CODING/crc_byte.c +++ b/openair1/PHY/CODING/crc_byte.c @@ -228,7 +228,7 @@ crc8 (unsigned char * inptr, int bitlen) int check_crc(uint8_t* decoded_bytes, uint32_t n, uint32_t F, uint8_t crc_type) { uint32_t crc=0,oldcrc=0; - uint8_t crc_len,temp; + uint8_t crc_len=0; switch (crc_type) { case CRC24_A: diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c index 3c32de916e..66d0fc481c 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c @@ -42,8 +42,8 @@ int8_t polar_decoder(double *input, uint32_t *out, t_nrPolar_params *polarParams, - uint8_t listSize, - uint8_t pathMetricAppr) { + uint8_t listSize) +{ //Assumes no a priori knowledge. uint8_t ***bit = nr_alloc_uint8_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); uint8_t **bitUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True @@ -117,12 +117,12 @@ int8_t polar_decoder(double *input, uint8_t listIndex[2*listSize], copyIndex; for (uint16_t currentBit=0; currentBitN; currentBit++) { - updateLLR(llr, llrUpdated, bit, bitUpdated, currentListSize, currentBit, 0, polarParams->N, (polarParams->n+1), pathMetricAppr); + updateLLR(llr, llrUpdated, bit, bitUpdated, currentListSize, currentBit, 0, polarParams->N, (polarParams->n+1)); if (polarParams->information_bit_pattern[currentBit]==0) { //Frozen bit. - updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit, pathMetricAppr); //approximation=0 --> 11b, approximation=1 --> 12 + updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit); } else { //Information or CRC bit. - updatePathMetric2(pathMetric, llr, currentListSize, currentBit, pathMetricAppr); + updatePathMetric2(pathMetric, llr, currentListSize, currentBit); for (int i = 0; i < currentListSize; i++) { for (int j = 0; j < polarParams->N; j++) { @@ -296,286 +296,10 @@ int8_t polar_decoder(double *input, return(0); } -int8_t polar_decoder_aPriori(double *input, - uint32_t *out, - t_nrPolar_params *polarParams, - uint8_t listSize, - uint8_t pathMetricAppr, - double *aPrioriPayload) { - uint8_t ***bit = nr_alloc_uint8_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); - uint8_t **bitUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True - uint8_t **llrUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True - double ***llr = nr_alloc_double_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); - uint8_t **crcChecksum = nr_alloc_uint8_2D_array(polarParams->crcParityBits, 2*listSize); - double *pathMetric = malloc(sizeof(double)*(2*listSize)); - uint8_t *crcState = malloc(sizeof(uint8_t)*(2*listSize)); //0=False, 1=True - - for (int i=0; i<(2*listSize); i++) { - pathMetric[i] = 0; - crcState[i]=1; - } - - for (int i=0; iN; i++) { - llrUpdated[i][polarParams->n]=1; - bitUpdated[i][0]=((polarParams->information_bit_pattern[i]+1) % 2); - } - - uint8_t **extended_crc_generator_matrix = malloc(polarParams->K * sizeof(uint8_t *)); //G_P3 - uint8_t **tempECGM = malloc(polarParams->K * sizeof(uint8_t *)); //G_P2 - - for (int i = 0; i < polarParams->K; i++) { - extended_crc_generator_matrix[i] = malloc(polarParams->crcParityBits * sizeof(uint8_t)); - tempECGM[i] = malloc(polarParams->crcParityBits * sizeof(uint8_t)); - } - - for (int i=0; ipayloadBits; i++) { - for (int j=0; jcrcParityBits; j++) { - tempECGM[i][j]=polarParams->crc_generator_matrix[i][j]; - } - } - - for (int i=polarParams->payloadBits; iK; i++) { - for (int j=0; jcrcParityBits; j++) { - if( (i-polarParams->payloadBits) == j ) { - tempECGM[i][j]=1; - } else { - tempECGM[i][j]=0; - } - } - } - - for (int i=0; iK; i++) { - for (int j=0; jcrcParityBits; j++) { - extended_crc_generator_matrix[i][j]=tempECGM[polarParams->interleaving_pattern[i]][j]; - } - } - - //The index of the last 1-valued bit that appears in each column. - uint16_t last1ind[polarParams->crcParityBits]; - - for (int j=0; jcrcParityBits; j++) { - for (int i=0; iK; i++) { - if (extended_crc_generator_matrix[i][j]==1) last1ind[j]=i; - } - } - - double *d_tilde = malloc(sizeof(double) * polarParams->N); - nr_polar_rate_matching(input, d_tilde, polarParams->rate_matching_pattern, polarParams->K, polarParams->N, polarParams->encoderLength); - - for (int j = 0; j < polarParams->N; j++) llr[j][polarParams->n][0]=d_tilde[j]; - - /* - * SCL polar decoder. - */ - uint32_t nonFrozenBit=0; - uint8_t currentListSize=1; - uint8_t decoderIterationCheck=0; - int16_t checkCrcBits=-1; - uint8_t listIndex[2*listSize], copyIndex; - - for (uint16_t currentBit=0; currentBitN; currentBit++) { - updateLLR(llr, llrUpdated, bit, bitUpdated, currentListSize, currentBit, 0, polarParams->N, (polarParams->n+1), pathMetricAppr); - - if (polarParams->information_bit_pattern[currentBit]==0) { //Frozen bit. - updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit, pathMetricAppr); //approximation=0 --> 11b, approximation=1 --> 12 - } else { //Information or CRC bit. - if ( (polarParams->interleaving_pattern[nonFrozenBit] <= polarParams->payloadBits) && - (aPrioriPayload[polarParams->interleaving_pattern[nonFrozenBit]] == 0) ) { - //Information bit with known value of "0". - updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit, pathMetricAppr); - bitUpdated[currentBit][0]=1; //0=False, 1=True - } else if ( (polarParams->interleaving_pattern[nonFrozenBit] <= polarParams->payloadBits) && - (aPrioriPayload[polarParams->interleaving_pattern[nonFrozenBit]] == 1) ) { - //Information bit with known value of "1". - updatePathMetric(pathMetric, llr, currentListSize, 1, currentBit, pathMetricAppr); - - for (uint8_t i=0; icrcParityBits); - } else { - updatePathMetric2(pathMetric, llr, currentListSize, currentBit, pathMetricAppr); - - for (int i = 0; i < currentListSize; i++) { - for (int j = 0; j < polarParams->N; j++) { - for (int k = 0; k < (polarParams->n+1); k++) { - bit[j][k][i+currentListSize]=bit[j][k][i]; - llr[j][k][i+currentListSize]=llr[j][k][i]; - } - } - } - - for (int i = 0; i < currentListSize; i++) { - bit[currentBit][0][i]=0; - crcState[i+currentListSize]=crcState[i]; - } - - for (int i = currentListSize; i < 2*currentListSize; i++) bit[currentBit][0][i]=1; - - bitUpdated[currentBit][0]=1; - updateCrcChecksum2(crcChecksum, extended_crc_generator_matrix, currentListSize, nonFrozenBit, polarParams->crcParityBits); - currentListSize*=2; - - //Keep only the best "listSize" number of entries. - if (currentListSize > listSize) { - for (uint8_t i = 0; i < 2*listSize; i++) listIndex[i]=i; - - nr_sort_asc_double_1D_array_ind(pathMetric, listIndex, currentListSize); - //sort listIndex[listSize, ..., 2*listSize-1] in descending order. - uint8_t swaps, tempInd; - - for (uint8_t i = 0; i < listSize; i++) { - swaps = 0; - - for (uint8_t j = listSize; j < (2*listSize - i) - 1; j++) { - if (listIndex[j+1] > listIndex[j]) { - tempInd = listIndex[j]; - listIndex[j] = listIndex[j + 1]; - listIndex[j + 1] = tempInd; - swaps++; - } - } - - if (swaps == 0) - break; - } - - //First, backup the best "listSize" number of entries. - for (int k=(listSize-1); k>0; k--) { - for (int i=0; iN; i++) { - for (int j=0; j<(polarParams->n+1); j++) { - bit[i][j][listIndex[(2*listSize-1)-k]]=bit[i][j][listIndex[k]]; - llr[i][j][listIndex[(2*listSize-1)-k]]=llr[i][j][listIndex[k]]; - } - } - } - - for (int k=(listSize-1); k>0; k--) { - for (int i = 0; i < polarParams->crcParityBits; i++) { - crcChecksum[i][listIndex[(2*listSize-1)-k]] = crcChecksum[i][listIndex[k]]; - } - } - - for (int k=(listSize-1); k>0; k--) crcState[listIndex[(2*listSize-1)-k]]=crcState[listIndex[k]]; - - //Copy the best "listSize" number of entries to the first indices. - for (int k = 0; k < listSize; k++) { - if (k > listIndex[k]) { - copyIndex = listIndex[(2*listSize-1)-k]; - } else { //Use the backup. - copyIndex = listIndex[k]; - } - - for (int i = 0; i < polarParams->N; i++) { - for (int j = 0; j < (polarParams->n + 1); j++) { - bit[i][j][k] = bit[i][j][copyIndex]; - llr[i][j][k] = llr[i][j][copyIndex]; - } - } - } - - for (int k = 0; k < listSize; k++) { - if (k > listIndex[k]) { - copyIndex = listIndex[(2*listSize-1)-k]; - } else { //Use the backup. - copyIndex = listIndex[k]; - } - - for (int i = 0; i < polarParams->crcParityBits; i++) { - crcChecksum[i][k]=crcChecksum[i][copyIndex]; - } - } - - for (int k = 0; k < listSize; k++) { - if (k > listIndex[k]) { - copyIndex = listIndex[(2*listSize-1)-k]; - } else { //Use the backup. - copyIndex = listIndex[k]; - } - - crcState[k]=crcState[copyIndex]; - } - - currentListSize = listSize; - } - } - - for (int i=0; icrcParityBits; i++) { - if (last1ind[i]==nonFrozenBit) { - checkCrcBits=i; - break; - } - } - - if ( checkCrcBits > (-1) ) { - for (uint8_t i = 0; i < currentListSize; i++) { - if (crcChecksum[checkCrcBits][i]==1) { - crcState[i]=0; //0=False, 1=True - } - } - } - - for (uint8_t i = 0; i < currentListSize; i++) decoderIterationCheck+=crcState[i]; - - if (decoderIterationCheck==0) { - //perror("[SCL polar decoder] All list entries have failed the CRC checks."); - free(d_tilde); - free(pathMetric); - free(crcState); - nr_free_uint8_3D_array(bit, polarParams->N, (polarParams->n+1)); - nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1)); - nr_free_uint8_2D_array(crcChecksum, polarParams->crcParityBits); - return(-1); - } - - nonFrozenBit++; - decoderIterationCheck=0; - checkCrcBits=-1; - } - } - - for (uint8_t i = 0; i < 2*listSize; i++) listIndex[i]=i; - - nr_sort_asc_double_1D_array_ind(pathMetric, listIndex, currentListSize); - - for (uint8_t i = 0; i < fmin(listSize, (pow(2,polarParams->crcCorrectionBits)) ); i++) { - if ( crcState[listIndex[i]] == 1 ) { - for (int j = 0; j < polarParams->N; j++) polarParams->nr_polar_U[j]=bit[j][0][listIndex[i]]; - - //Extract the information bits (û to ĉ) - nr_polar_info_bit_extraction(polarParams->nr_polar_U, polarParams->nr_polar_CPrime, polarParams->information_bit_pattern, polarParams->N); - //Deinterleaving (ĉ to b) - nr_polar_deinterleaver(polarParams->nr_polar_CPrime, polarParams->nr_polar_B, polarParams->interleaving_pattern, polarParams->K); - - //Remove the CRC (â) - for (int j = 0; j < polarParams->payloadBits; j++) - polarParams->nr_polar_A[j]=polarParams->nr_polar_B[j]; - - break; - } - } - - free(d_tilde); - free(pathMetric); - free(crcState); - nr_free_uint8_3D_array(bit, polarParams->N, (polarParams->n+1)); - nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1)); - nr_free_uint8_2D_array(crcChecksum, polarParams->crcParityBits); - nr_free_uint8_2D_array(extended_crc_generator_matrix, polarParams->K); - nr_free_uint8_2D_array(tempECGM, polarParams->K); - /* - * Return bits. - */ - nr_byte2bit_uint8_32(polarParams->nr_polar_A, polarParams->payloadBits, out); - return(0); -} - - int8_t polar_decoder_dci(double *input, uint32_t *out, t_nrPolar_params *polarParams, uint8_t listSize, - uint8_t pathMetricAppr, uint16_t n_RNTI) { uint8_t ***bit = nr_alloc_uint8_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); uint8_t **bitUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True @@ -663,12 +387,12 @@ int8_t polar_decoder_dci(double *input, uint8_t listIndex[2*listSize], copyIndex; for (uint16_t currentBit=0; currentBitN; currentBit++) { - updateLLR(llr, llrUpdated, bit, bitUpdated, currentListSize, currentBit, 0, polarParams->N, (polarParams->n+1), pathMetricAppr); + updateLLR(llr, llrUpdated, bit, bitUpdated, currentListSize, currentBit, 0, polarParams->N, (polarParams->n+1)); if (polarParams->information_bit_pattern[currentBit]==0) { //Frozen bit. - updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit, pathMetricAppr); //approximation=0 --> 11b, approximation=1 --> 12 + updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit); } else { //Information or CRC bit. - updatePathMetric2(pathMetric, llr, currentListSize, currentBit, pathMetricAppr); + updatePathMetric2(pathMetric, llr, currentListSize, currentBit); for (int i = 0; i < currentListSize; i++) { for (int j = 0; j < polarParams->N; j++) { diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c index 11aa5d98a4..bf8a90e0d9 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c @@ -44,20 +44,19 @@ void updateLLR(double ***llr, uint16_t row, uint16_t col, uint16_t xlen, - uint8_t ylen, - uint8_t approximation) + uint8_t ylen) { uint16_t offset = (xlen/(pow(2,(ylen-col-1)))); for (uint8_t i=0; i= offset ) { if(bitU[row-offset][col]==0) updateBit(bit, bitU, listSize, (row-offset), col, xlen, ylen); - if(llrU[row-offset][col+1]==0) updateLLR(llr, llrU, bit, bitU, listSize, (row-offset), (col+1), xlen, ylen, approximation); - if(llrU[row][col+1]==0) updateLLR(llr, llrU, bit, bitU, listSize, row, (col+1), xlen, ylen, approximation); + if(llrU[row-offset][col+1]==0) updateLLR(llr, llrU, bit, bitU, listSize, (row-offset), (col+1), xlen, ylen); + if(llrU[row][col+1]==0) updateLLR(llr, llrU, bit, bitU, listSize, row, (col+1), xlen, ylen); llr[row][col][i] = (pow((-1),bit[row-offset][col][i])*llr[row-offset][col+1][i]) + llr[row][col+1][i]; } else { - if(llrU[row][col+1]==0) updateLLR(llr, llrU, bit, bitU, listSize, row, (col+1), xlen, ylen, approximation); - if(llrU[row+offset][col+1]==0) updateLLR(llr, llrU, bit, bitU, listSize, (row+offset), (col+1), xlen, ylen, approximation); - computeLLR(llr, row, col, i, offset, approximation); + if(llrU[row][col+1]==0) updateLLR(llr, llrU, bit, bitU, listSize, row, (col+1), xlen, ylen); + if(llrU[row+offset][col+1]==0) updateLLR(llr, llrU, bit, bitU, listSize, (row+offset), (col+1), xlen, ylen); + computeLLR(llr, row, col, i, offset); } } llrU[row][col]=1; @@ -90,51 +89,34 @@ void updateBit(uint8_t ***bit, } void updatePathMetric(double *pathMetric, - double ***llr, + double ***llr, uint8_t listSize, uint8_t bitValue, - uint16_t row, - uint8_t approximation) + uint16_t row) { - if (approximation) { //eq. (12) - for (uint8_t i=0; i<2*listSize; i++) { - if ((2*bitValue) != ( 1 - copysign(1.0,llr[row][0][i]) )) pathMetric[i] += fabs(llr[row][0][i]); - } - } else { //eq. (11b) - int8_t multiplier = (2*bitValue) - 1; - for (uint8_t i=0; i<2*listSize; i++) pathMetric[i] += log ( 1 + exp(multiplier*llr[row][0][i]) ) ; - } + int8_t multiplier = (2*bitValue) - 1; + for (uint8_t i=0; i eq. (8a) and (11b), 1 --> eq. (9) and (12) #define NR_POLAR_AGGREGATION_LEVEL_1_PRIME 149 //uint16_t #define NR_POLAR_AGGREGATION_LEVEL_2_PRIME 151 //uint16_t @@ -154,25 +153,16 @@ void polar_encoder_fast(uint64_t *A, int8_t polar_decoder(double *input, uint32_t *output, t_nrPolar_params *polarParams, - uint8_t listSize, - uint8_t pathMetricAppr); + uint8_t listSize); uint32_t polar_decoder_int16(int16_t *input, uint64_t *out, const t_nrPolar_params *polarParams); -int8_t polar_decoder_aPriori(double *input, - uint32_t *output, - t_nrPolar_params *polarParams, - uint8_t listSize, - uint8_t pathMetricAppr, - double *aPrioriPayload); - int8_t polar_decoder_dci(double *input, uint32_t *out, t_nrPolar_params *polarParams, uint8_t listSize, - uint8_t pathMetricAppr, uint16_t n_RNTI); void generic_polar_decoder(const t_nrPolar_params *pp, @@ -330,8 +320,7 @@ void updateLLR(double ***llr, uint16_t row, uint16_t col, uint16_t xlen, - uint8_t ylen, - uint8_t approximation); + uint8_t ylen); void updateBit(uint8_t ***bit, uint8_t **bitU, @@ -345,21 +334,18 @@ void updatePathMetric(double *pathMetric, double ***llr, uint8_t listSize, uint8_t bitValue, - uint16_t row, - uint8_t approximation); + uint16_t row); void updatePathMetric2(double *pathMetric, double ***llr, uint8_t listSize, - uint16_t row, - uint8_t approximation); + uint16_t row); void computeLLR(double ***llr, uint16_t row, uint16_t col, uint8_t i, - uint16_t offset, - uint8_t approximation); + uint16_t offset); void updateCrcChecksum(uint8_t **crcChecksum, uint8_t **crcGen, diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index dd11cd7867..b392506095 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -64,8 +64,9 @@ void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m } if (pdcch_params->cr_mapping_type == NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED) { - AssertFatal((N_reg%(bsize*R))==0,"CCE to REG interleaving: Invalid configuration leading to non integer C (N_reg %us, bsize %d R %d)\n",N_reg, bsize, R); - C = N_reg/(bsize*R); + uint16_t assertFatalCond = (N_reg%(bsize*R)); + AssertFatal(assertFatalCond == 0,"CCE to REG interleaving: Invalid configuration leading to non integer C (N_reg %us, bsize %d R %d)\n",N_reg, bsize, R); + C = N_reg/(bsize*R); } tmp = L * (( Y + (m*N_cce)/(L*M_s_max) + n_CI ) % CEILIDIV(N_cce,L)); diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 6adb2271e2..591d609454 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -333,5 +333,4 @@ typedef struct nr_band_info_s { nr_bandentry_t band_info[100]; } nr_band_info_t; - #endif diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 139d48ffa9..8a404b717c 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -56,7 +56,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ NR_UE_PDCCH *pdcch_vars2 = PHY_vars_UE_g[module_id][cc_id]->pdcch_vars[thread_id][0]; NR_UE_DLSCH_t *dlsch0 = PHY_vars_UE_g[module_id][cc_id]->dlsch[thread_id][0][0]; NR_UE_ULSCH_t *ulsch0 = PHY_vars_UE_g[module_id][cc_id]->ulsch[thread_id][0][0]; - NR_DL_FRAME_PARMS frame_parms = PHY_vars_UE_g[module_id][cc_id]->frame_parms; + //NR_DL_FRAME_PARMS frame_parms = PHY_vars_UE_g[module_id][cc_id]->frame_parms; PRACH_RESOURCES_t *prach_resources = PHY_vars_UE_g[module_id][cc_id]->prach_resources[0]; // PUCCH_ConfigCommon_nr_t *pucch_config_common = PHY_vars_UE_g[module_id][cc_id]->pucch_config_common_nr[0]; @@ -185,11 +185,11 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ if(ul_config->ul_config_list[i].pdu_type == FAPI_NR_UL_CONFIG_TYPE_PRACH){ // prach config pdu fapi_nr_ul_config_prach_pdu *prach_config_pdu = &ul_config->ul_config_list[i].prach_config_pdu; - frame_parms.prach_config_common.rootSequenceIndex = prach_config_pdu->root_sequence_index; + /*frame_parms.prach_config_common.rootSequenceIndex = prach_config_pdu->root_sequence_index; frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex = prach_config_pdu->prach_configuration_index; frame_parms.prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig = prach_config_pdu->zero_correlation_zone_config; frame_parms.prach_config_common.prach_ConfigInfo.highSpeedFlag = prach_config_pdu->restrictedset_config; - frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset = prach_config_pdu->prach_freq_offset; + frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset = prach_config_pdu->prach_freq_offset;*/ prach_resources->ra_PreambleIndex = prach_config_pdu->preamble_index; } } diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index c83074d8a2..a5ce07e883 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -1560,25 +1560,26 @@ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDUR #endif -void ue_ulsch_uespec_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag) { - - int harq_pid; - int frame_tx=proc->frame_tx; +void ue_ulsch_uespec_procedures(PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + uint8_t eNB_id, + uint8_t abstraction_flag) +{ int nr_tti_tx=proc->nr_tti_tx; - unsigned int input_buffer_length; - int i; - int aa; - int tx_amp; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_ULSCH_UESPEC,VCD_FUNCTION_IN); /* reset harq for tx of current rx slot because it is sure that transmission has already been achieved for this slot */ set_tx_harq_id(ue->ulsch[ue->current_thread_id[nr_tti_tx]][eNB_id][0], NR_MAX_HARQ_PROCESSES, proc->nr_tti_rx); +#if 0 + int frame_tx=proc->frame_tx; + int harq_pid; /* get harq pid related to this next tx slot */ harq_pid = get_tx_harq_id(ue->ulsch[ue->current_thread_id[nr_tti_tx]][eNB_id][0], nr_tti_tx); -#if 0 - + int tx_amp; + unsigned int input_buffer_length; int Mod_id = ue->Mod_id; int CC_id = ue->CC_id; uint8_t Msg3_flag=0; @@ -1599,9 +1600,9 @@ void ue_ulsch_uespec_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8 ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 1; if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->round==0) - generate_ue_ulsch_params_from_rar(ue, - proc, - eNB_id); + generate_ue_ulsch_params_from_rar(ue, + proc, + eNB_id); ue->ulsch[eNB_id]->power_offset = 14; LOG_D(PHY,"[UE %d][RAPROC] Frame %d: Setting Msg3_flag in nr_tti_rx %d, for harq_pid %d\n", @@ -1864,7 +1865,7 @@ void ue_ulsch_uespec_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8 #ifdef DEBUG_ULSCH LOG_D(PHY,"[UE] Frame %d, nr_tti_rx %d : ULSCH SDU (TX harq_pid %d) (%d bytes) : \n",frame_tx,nr_tti_tx,harq_pid, ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS>>3); - for (i=0; iulsch[eNB_id]->harq_processes[harq_pid]->TBS>>3; i++) + for (int i=0; iulsch[eNB_id]->harq_processes[harq_pid]->TBS>>3; i++) LOG_T(PHY,"%x.",ulsch_input_buffer[i]); LOG_T(PHY,"\n"); @@ -1874,7 +1875,7 @@ void ue_ulsch_uespec_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8 else { unsigned int taus(void); - for (i=0; iframe_parms, ue->ulsch[eNB_id]); - for (aa=0; aa<1/*frame_parms->nb_antennas_tx*/; aa++) + for (int aa=0; aa<1/*frame_parms->nb_antennas_tx*/; aa++) generate_drs_pusch(ue, proc, eNB_id, @@ -2670,22 +2671,18 @@ void phy_procedures_UE_S_TX(PHY_VARS_NR_UE *ue,uint8_t eNB_id,uint8_t abstractio #endif -void nr_ue_measurement_procedures( - uint16_t l, // symbol index of each slot [0..6] - PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - uint8_t eNB_id, - uint16_t slot, // slot index of each radio frame [0..19] - runmode_t mode) +void nr_ue_measurement_procedures(uint16_t l, // symbol index of each slot [0..6] + PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + uint8_t eNB_id, + uint16_t slot, // slot index of each radio frame [0..19] + runmode_t mode) { - LOG_D(PHY,"ue_measurement_procedures l %u Ncp %d\n",l,ue->frame_parms.Ncp); - NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; - - int nr_tti_rx = proc->nr_tti_rx; - #if 0 + NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; + int nr_tti_rx = proc->nr_tti_rx; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_MEASUREMENT_PROCEDURES, VCD_FUNCTION_IN); if (l==0) { @@ -2806,16 +2803,17 @@ void restart_phy(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc, uint8_t eNB_id,uint } #endif //(0) -void nr_ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc, uint8_t abstraction_flag) +void nr_ue_pbch_procedures(uint8_t eNB_id, + PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + uint8_t abstraction_flag) { - // int i; //int pbch_tx_ant=0; //uint8_t pbch_phase; int ret = 0; - uint16_t frame_tx; - static uint8_t first_run = 1; - uint8_t pbch_trials = 0; + //static uint8_t first_run = 1; + //uint8_t pbch_trials = 0; DevAssert(ue); @@ -2838,6 +2836,7 @@ void nr_ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * #ifdef DEBUG_PHY_PROC + uint16_t frame_tx; LOG_D(PHY,"[UE %d] frame %d, nr_tti_rx %d, Received PBCH (MIB): frame_tx %d. N_RB_DL %d\n", ue->Mod_id, frame_rx, @@ -2908,9 +2907,10 @@ unsigned int get_tx_amp(int power_dBm, int power_max_dBm, int N_RB_UL, int nb_rb #ifdef NR_PDCCH_SCHED -int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc) +int nr_ue_pdcch_procedures(uint8_t eNB_id, + PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc) { - // unsigned int dci_cnt=0, i; //removed for nr_ue_pdcch_procedures and added in the loop for nb_coreset_active #ifdef NR_PDCCH_SCHED_DEBUG printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_ue_pdcch_procedures() \n"); @@ -2940,7 +2940,7 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * pdcch_vars[eNB_id]->crnti = 0x1234; //to be check how to set when using loop memory uint16_t c_rnti=pdcch_vars[eNB_id]->crnti; - uint16_t cs_rnti=0,new_rnti=0,tc_rnti; + uint16_t cs_rnti=0,new_rnti=0,tc_rnti=0; uint16_t p_rnti=P_RNTI; uint16_t si_rnti=SI_RNTI; uint16_t ra_rnti=99; @@ -2958,10 +2958,10 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * #endif // p in TS 38.212 Subclause 10.1, for each active BWP the UE can deal with 3 different CORESETs (including coresetId 0 for common search space) - int nb_coreset_total = NR_NBR_CORESET_ACT_BWP; + //int nb_coreset_total = NR_NBR_CORESET_ACT_BWP; unsigned int dci_cnt=0; // this table contains 56 (NBR_NR_DCI_FIELDS) elements for each dci field and format described in TS 38.212. Each element represents the size in bits for each dci field - uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS] = {{0}}; + //uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS] = {{0}}; // this is the UL bandwidth part. FIXME! To be defined where this value comes from // uint16_t n_RB_ULBWP = 106; // this is the DL bandwidth part. FIXME! To be defined where this value comes from @@ -2970,7 +2970,7 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * // Up to 10 searchSpaces can be configured to UE (s<=10) for (nb_searchspace_active=0; nb_searchspace_activesearchSpace[nb_searchspace_active].searchSpaceId; + //int searchSpace_id = pdcch_vars2->searchSpace[nb_searchspace_active].searchSpaceId; #ifdef NR_PDCCH_SCHED_DEBUG @@ -3001,16 +3001,16 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * // the searchSpace indicates that we need to monitor PDCCH in current nr_tti_rx // get the parameters describing the current SEARCHSPACE // the CORESET id applicable to the current SearchSpace - int searchSpace_coreset_id = pdcch_vars2->searchSpace[nb_searchspace_active].controlResourceSetId; + //int searchSpace_coreset_id = pdcch_vars2->searchSpace[nb_searchspace_active].controlResourceSetId; // FIXME this variable is a bit string (14 bits) identifying every OFDM symbol in a slot. // at the moment we will not take into consideration this variable and we will consider that the OFDM symbol offset is always the first OFDM in a symbol uint16_t symbol_within_slot_mon = pdcch_vars2->searchSpace[nb_searchspace_active].monitoringSymbolWithinSlot; // get the remaining parameters describing the current SEARCHSPACE: // FIXME! To be defined where we get this information from - NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L1 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel1; + /*NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L1 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel1; NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L2 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel2; NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L4 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel4; NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L8 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel8; - NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L16 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel16; + NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L16 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel16;*/ // FIXME! A table of five enum elements // searchSpaceType indicates whether this is a common search space or a UE-specific search space //int searchSpaceType = pdcch_vars2->searchSpace[nb_searchspace_active].searchSpaceType.type; @@ -3127,9 +3127,8 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DCI_DECODING, VCD_FUNCTION_OUT); //LOG_D(PHY,"[UE %d][PUSCH] Frame %d nr_tti_rx %d PHICH RX\n",ue->Mod_id,frame_rx,nr_tti_rx); - - uint8_t *nCCE_current = &ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->nCCE[nr_tti_rx]; /* + uint8_t *nCCE_current = &ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->nCCE[nr_tti_rx]; uint8_t *nCCE_dest = &ue->pdcch_vars[next1_thread_id][eNB_id]->nCCE[nr_tti_rx]; uint8_t *nCCE_dest1 = &ue->pdcch_vars[next2_thread_id][eNB_id]->nCCE[nr_tti_rx]; memcpy(nCCE_dest, nCCE_current, sizeof(uint8_t)); @@ -3780,7 +3779,7 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, int frame_rx = proc->frame_rx; int nr_tti_rx = proc->nr_tti_rx; int ret=0, ret1=0; - int CC_id = ue->CC_id; + //int CC_id = ue->CC_id; NR_UE_PDSCH *pdsch_vars; uint8_t is_cw0_active = 0; uint8_t is_cw1_active = 0; @@ -3861,10 +3860,10 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, start_meas(&ue->dlsch_unscrambling_stats); #endif nr_dlsch_unscrambling(pdsch_vars->llr[0], - dlsch0->harq_processes[harq_pid]->G, - 0, - ue->frame_parms.Nid_cell, - dlsch0->rnti); + dlsch0->harq_processes[harq_pid]->G, + 0, + ue->frame_parms.Nid_cell, + dlsch0->rnti); #if UE_TIMING_TRACE @@ -3887,7 +3886,9 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, #endif #ifdef UE_DLSCH_PARALLELISATION - ret = nr_dlsch_decoding_mthread(ue,proc,eNB_id, + ret = nr_dlsch_decoding_mthread(ue, + proc, + eNB_id, pdsch_vars->llr[0], &ue->frame_parms, dlsch0, @@ -3898,6 +3899,7 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, harq_pid, pdsch==PDSCH?1:0, dlsch0->harq_processes[harq_pid]->TBS>256?1:0); + LOG_T(PHY,"UE_DLSCH_PARALLELISATION is defined, ret = %d\n", ret); #else ret = nr_dlsch_decoding(ue, pdsch_vars->llr[0], @@ -3910,6 +3912,7 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, harq_pid, pdsch==PDSCH?1:0,//proc->decoder_switch, dlsch0->harq_processes[harq_pid]->TBS>256?1:0); + LOG_T(PHY,"UE_DLSCH_PARALLELISATION is NOT defined, ret = %d\n", ret); //printf("start cW0 dlsch decoding\n"); #endif @@ -3964,7 +3967,9 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, #endif #ifdef UE_DLSCH_PARALLELISATION - ret1 = nr_dlsch_decoding_mthread(ue,proc, eNB_id, + ret1 = nr_dlsch_decoding_mthread(ue, + proc, + eNB_id, pdsch_vars->llr[1], &ue->frame_parms, dlsch1, @@ -3975,19 +3980,20 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, harq_pid, pdsch==PDSCH?1:0, dlsch1->harq_processes[harq_pid]->TBS>256?1:0); + LOG_T(PHY,"UE_DLSCH_PARALLELISATION is defined, ret1 = %d\n", ret1); #else - ret1 = nr_dlsch_decoding(ue, pdsch_vars->llr[1], &ue->frame_parms, dlsch1, dlsch1->harq_processes[harq_pid], frame_rx, - nb_symb_sch, + nb_symb_sch, nr_tti_rx, harq_pid, pdsch==PDSCH?1:0,//proc->decoder_switch, dlsch1->harq_processes[harq_pid]->TBS>256?1:0); + LOG_T(PHY,"UE_DLSCH_PARALLELISATION is NOT defined, ret1 = %d\n", ret1); printf("start cw1 dlsch decoding\n"); #endif @@ -4317,14 +4323,12 @@ void *UE_thread_slot1_dl_processing(void *arg) { -int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id, - uint8_t do_pdcch_flag,runmode_t mode) { - - - - int l,l2; - int pilot1; - +int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + uint8_t eNB_id, + uint8_t do_pdcch_flag, + runmode_t mode) +{ int frame_rx = proc->frame_rx; int nr_tti_rx = proc->nr_tti_rx; NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][0]; diff --git a/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c b/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c index debb0d4ed5..296d92969c 100644 --- a/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c +++ b/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c @@ -67,9 +67,19 @@ * *********************************************************************/ -int16_t get_pucch_tx_power_ue(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_t *proc, pucch_format_nr_t pucch_format, - int nb_of_prbs, int N_sc_ctrl_RB, int N_symb_PUCCH, int O_UCI, int O_SR, int O_CSI, int O_ACK, - int O_CRC, int n_HARQ_ACK) { +int16_t get_pucch_tx_power_ue(PHY_VARS_NR_UE *ue, + uint8_t gNB_id, + UE_nr_rxtx_proc_t *proc, + pucch_format_nr_t pucch_format, + int nb_of_prbs, + int N_sc_ctrl_RB, + int N_symb_PUCCH, + int O_UCI, + int O_SR, + int O_CSI, + int O_ACK, + int O_CRC, + int n_HARQ_ACK) { int16_t P_O_NOMINAL_PUCCH = ue->pucch_config_common_nr[gNB_id].p0_nominal; PUCCH_PowerControl_t *power_config = &ue->pucch_config_dedicated_nr[gNB_id].pucch_PowerControl; @@ -147,7 +157,6 @@ int16_t get_pucch_tx_power_ue(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_pro } } - int l = 0; int k2; if (power_config->twoPUCCH_PC_AdjustmentStates > 1) { @@ -156,11 +165,11 @@ int16_t get_pucch_tx_power_ue(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_pro } /* response to a detection by the UE of a DCI format 1_0 or DCI format 1_1 */ - int K_PUCCH = 0; + //int K_PUCCH = 0; if (O_ACK != 0) { /* it assumes that PDCCH is in the first symbol of receive slot FFS TDDO NR */ - int slots_gap = (proc->nr_tti_tx > proc->nr_tti_rx ? (proc->nr_tti_tx - proc->nr_tti_rx - 1) : ((proc->nr_tti_tx + ue->frame_parms.ttis_per_subframe) - proc->nr_tti_rx - 1)); - K_PUCCH = (slots_gap * (ue->frame_parms.symbols_per_tti)) - 1; + //int slots_gap = (proc->nr_tti_tx > proc->nr_tti_rx ? (proc->nr_tti_tx - proc->nr_tti_rx - 1) : ((proc->nr_tti_tx + ue->frame_parms.ttis_per_subframe) - proc->nr_tti_rx - 1)); + //K_PUCCH = (slots_gap * (ue->frame_parms.symbols_per_tti)) - 1; } else { /* field k2 is not present - to check k2 of pucch from upper layer FFS TDDO NR */ @@ -189,7 +198,7 @@ int16_t get_pucch_tx_power_ue(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_pro } while(ue->pusch_config.pusch_TimeDomainResourceAllocation[i] != NULL); k2 = k2_min; } - K_PUCCH = N_SYMB_SLOT * k2; /* the product of a number of symbols per slot and the minimum of the values provided by higher layer parameter k2 */ + //K_PUCCH = N_SYMB_SLOT * k2; /* the product of a number of symbols per slot and the minimum of the values provided by higher layer parameter k2 */ } int contributor = (10 * log10((double)(pow(2,(ue->frame_parms.numerology_index)) * nb_of_prbs))); diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index acf10b14e3..899868d2f6 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -128,45 +128,46 @@ int main(int argc, char **argv) char c; - int i,l,aa; + int i,aa;//,l; double sigma2, sigma2_dB=10,SNR,snr0=-2.0,snr1=2.0; uint8_t snr1set=0; int **txdata; double **s_re,**s_im,**r_re,**r_im; - double iqim = 0.0; - unsigned char pbch_pdu[6]; + //double iqim = 0.0; + //unsigned char pbch_pdu[6]; // int sync_pos, sync_pos_slot; // FILE *rx_frame_file; FILE *output_fd = NULL; - uint8_t write_output_file=0; + //uint8_t write_output_file=0; //int result; - int freq_offset; + //int freq_offset; // int subframe_offset; // char fname[40], vname[40]; - int trial,n_trials=1,n_errors,n_errors2,n_alamouti; + int trial,n_trials=1,n_errors=0; + //int n_errors2, n_alamouti; uint8_t transmission_mode = 1,n_tx=1,n_rx=1; uint16_t Nid_cell=0; uint64_t SSB_positions=0x01; channel_desc_t *gNB2UE; - uint32_t nsymb,tx_lev,tx_lev1 = 0,tx_lev2 = 0; - uint8_t extended_prefix_flag=0; - int8_t interf1=-21,interf2=-21; + //uint32_t nsymb,tx_lev,tx_lev1 = 0,tx_lev2 = 0; + //uint8_t extended_prefix_flag=0; + //int8_t interf1=-21,interf2=-21; FILE *input_fd=NULL,*pbch_file_fd=NULL; - char input_val_str[50],input_val_str2[50]; + //char input_val_str[50],input_val_str2[50]; - uint8_t frame_mod4,num_pdcch_symbols = 0; + //uint8_t frame_mod4,num_pdcch_symbols = 0; SCM_t channel_model=AWGN;//Rayleigh1_anticorr; - double pbch_sinr; - int pbch_tx_ant; + //double pbch_sinr; + //int pbch_tx_ant; int N_RB_DL=273,mu=1; uint64_t ssb_pattern = 0x01; - unsigned char frame_type = 0; + //unsigned char frame_type = 0; unsigned char pbch_phase = 0; int frame=0,slot=1; @@ -199,7 +200,7 @@ int main(int argc, char **argv) while ((c = getopt (argc, argv, "f:hA:pf:g:i:j:n:s:S:t:x:y:z:M:N:F:GR:dP:IL:")) != -1) { switch (c) { - case 'f': + /*case 'f': write_output_file=1; output_fd = fopen(optarg,"w"); @@ -207,12 +208,11 @@ int main(int argc, char **argv) printf("Error opening %s\n",optarg); exit(-1); } + break;*/ - break; - - case 'd': + /*case 'd': frame_type = 1; - break; + break;*/ case 'g': switch((char)*optarg) { @@ -251,13 +251,13 @@ int main(int argc, char **argv) break; - case 'i': + /*case 'i': interf1=atoi(optarg); break; case 'j': interf2=atoi(optarg); - break; + break;*/ case 'n': n_trials = atoi(optarg); @@ -279,9 +279,9 @@ int main(int argc, char **argv) Td= atof(optarg); break; */ - case 'p': + /*case 'p': extended_prefix_flag=1; - break; + break;*/ /* case 'r': @@ -368,8 +368,8 @@ int main(int argc, char **argv) printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", argv[0]); printf("-h This message\n"); - printf("-p Use extended prefix mode\n"); - printf("-d Use TDD\n"); + //printf("-p Use extended prefix mode\n"); + //printf("-d Use TDD\n"); printf("-n Number of frames to simulate\n"); printf("-s Starting SNR, runs from SNR0 to SNR0 + 5 dB. If n_frames is 1 then just SNR is simulated\n"); printf("-S Ending SNR, runs from SNR0 to SNR1\n"); @@ -378,15 +378,15 @@ int main(int argc, char **argv) printf("-x Transmission mode (1,2,6 for the moment)\n"); printf("-y Number of TX antennas used in eNB\n"); printf("-z Number of RX antennas used in UE\n"); - printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); - printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); + //printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); + //printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); printf("-M Multiple SSB positions in burst\n"); printf("-N Nid_cell\n"); printf("-R N_RB_DL\n"); printf("-O oversampling factor (1,2,4,8,16)\n"); printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n"); - // printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); - printf("-f Output filename (.txt format) for Pe/SNR results\n"); + //printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); + //printf("-f Output filename (.txt format) for Pe/SNR results\n"); printf("-F Input filename (.txt format) for RX conformance testing\n"); exit (-1); break; @@ -683,8 +683,8 @@ int main(int argc, char **argv) for (SNR=snr0; SNRul_config_request; - fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; + //fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; nr_phy_config_t *phy_config = &mac->phy_config; //ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.rnti = rnti; @@ -1149,7 +1154,7 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment( {0,4,7}, // row index 15 {0,8,4} // row index 16 }; - uint8_t table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1 + /*uint8_t table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1 {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?6:5}, // row index 1 {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?10:9}, // row index 2 {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?9:8}, // row index 3 @@ -1166,8 +1171,8 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment( {0,2,4}, // row index 14 {0,4,6}, // row index 15 {0,8,4} // row index 16 - }; - uint8_t table_5_1_2_1_1_4_time_dom_res_alloc_B[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1 + };*/ + /*uint8_t table_5_1_2_1_1_4_time_dom_res_alloc_B[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1 {0,2,2}, // row index 1 {0,4,2}, // row index 2 {0,6,2}, // row index 3 @@ -1184,8 +1189,8 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment( {0,(dmrs_typeA_pos == 0)?2:3,(dmrs_typeA_pos == 0)?12:11}, // row index 14 {1,2,4}, // row index 15 {0,0,0} // row index 16 - }; - uint8_t table_5_1_2_1_1_5_time_dom_res_alloc_C[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1 + };*/ + /*uint8_t table_5_1_2_1_1_5_time_dom_res_alloc_C[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1 {0,2,2}, // row index 1 {0,4,2}, // row index 2 {0,6,2}, // row index 3 @@ -1202,7 +1207,7 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment( {0,(dmrs_typeA_pos == 0)?2:3,(dmrs_typeA_pos == 0)?12:11}, // row index 14 {0,0,6}, // row index 15 {0,2,6} // row index 16 - }; + };*/ uint8_t mu_pusch = 1; // definition table j Table 6.1.2.1.1-4 uint8_t j = (mu_pusch==3)?3:(mu_pusch==2)?2:1; @@ -1224,7 +1229,7 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment( {j+3,0,14}, // row index 15 {j+3,0,10} // row index 16 }; - uint8_t table_6_1_2_1_1_3_time_dom_res_alloc_A_extCP[16][3]={ // for PUSCH from TS 38.214 subclause 6.1.2.1.1 + /*uint8_t table_6_1_2_1_1_3_time_dom_res_alloc_A_extCP[16][3]={ // for PUSCH from TS 38.214 subclause 6.1.2.1.1 {j, 0,8}, // row index 1 {j, 0,12}, // row index 2 {j, 0,10}, // row index 3 @@ -1241,7 +1246,7 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment( {j, 8,4}, // row index 14 {j+3,0,8}, // row index 15 {j+3,0,10} // row index 16 - }; + };*/ /* * TS 38.214 subclause 5.1.2.1 Resource allocation in time domain (downlink) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index bf07051507..02c27930d3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -336,7 +336,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, rnti = UE_RNTI(module_idP, i); CC_id = UE_PCCID(module_idP, i); - int spf = get_spf(cfg); + //int spf = get_spf(cfg); if (((frameP&127) == 0) && (slotP == 0)) { LOG_I(MAC, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 5a57bc2846..ce18158f18 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -203,8 +203,8 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, int dl_carrier_bandwidth = cfg->rf_config.dl_carrier_bandwidth.value; // everything here is hard-coded to 30 kHz - int scs = get_dlscs(cfg); - int slots_per_frame = get_spf(cfg); + //int scs = get_dlscs(cfg); + //int slots_per_frame = get_spf(cfg); for (CC_id=0; CC_id>4)&0x3f); #ifdef DEBUG_RRC - int i; LOG_I(RRC,"[eNB %d] mac_rrc_data_req to SRB ID=%d\n",Mod_idP,Srb_id); #endif diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 801673b2ef..6b1ded3b1e 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -141,19 +141,18 @@ void rrc_gNB_process_SgNBAdditionRequest( void rrc_gNB_generate_SgNBAdditionRequestAcknowledge( const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP - ){ - - uint8_t size; - uint8_t buffer[100]; - int CC_id = ue_context_pP->ue_context.primaryCC_id; - OCTET_STRING_t *secondaryCellGroup; + rrc_gNB_ue_context_t *const ue_context_pP) +{ + //uint8_t size; + //uint8_t buffer[100]; + //int CC_id = ue_context_pP->ue_context.primaryCC_id; + //OCTET_STRING_t *secondaryCellGroup; NR_CellGroupConfig_t *cellGroupconfig; struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_BearerToAddModList; struct NR_MAC_CellGroupConfig *mac_CellGroupConfig; struct NR_PhysicalCellGroupConfig *physicalCellGroupConfig; struct NR_SpCellConfig *spCellConfig; - struct NR_CellGroupConfig__sCellToAddModList *sCellToAddModList; + //struct NR_CellGroupConfig__sCellToAddModList *sCellToAddModList; cellGroupconfig = CALLOC(1,sizeof(NR_CellGroupConfig_t)); cellGroupconfig->rlc_BearerToAddModList = CALLOC(1,sizeof(struct NR_CellGroupConfig__rlc_BearerToAddModList));