From c94d7632e0b3e3b95b89785b4ddc30fdd16a83b7 Mon Sep 17 00:00:00 2001 From: Raymond Knopp <raymond.knopp@eurecom.fr> Date: Mon, 6 Jan 2020 23:04:52 +0100 Subject: [PATCH] debugging of nr_dlschsim, rate matching optimization --- openair1/PHY/CODING/coding_defs.h | 2 + openair1/PHY/CODING/nr_rate_matching.c | 299 +++++++++++++++++- openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c | 31 +- .../PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 27 +- .../NR_UE_TRANSPORT/nr_dlsch_demodulation.c | 2 +- .../PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 2 + openair1/SIMULATION/NR_PHY/dlschsim.c | 6 +- openair1/SIMULATION/NR_PHY/dlsim.c | 59 +--- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 6 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 15 +- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 6 +- openair2/LAYER2/NR_MAC_gNB/main.c | 3 +- openair2/NR_PHY_INTERFACE/NR_IF_Module.c | 19 +- 13 files changed, 357 insertions(+), 120 deletions(-) diff --git a/openair1/PHY/CODING/coding_defs.h b/openair1/PHY/CODING/coding_defs.h index 540fd3b2635..b5230d894dd 100644 --- a/openair1/PHY/CODING/coding_defs.h +++ b/openair1/PHY/CODING/coding_defs.h @@ -481,6 +481,8 @@ int nr_rate_matching_ldpc(uint8_t Ilbrm, uint8_t *w, uint8_t *e, uint8_t C, + uint32_t F, + uint32_t Foffset, uint8_t rvidx, uint32_t E); diff --git a/openair1/PHY/CODING/nr_rate_matching.c b/openair1/PHY/CODING/nr_rate_matching.c index 9d50b4678be..fcbdcdb269b 100644 --- a/openair1/PHY/CODING/nr_rate_matching.c +++ b/openair1/PHY/CODING/nr_rate_matching.c @@ -32,23 +32,281 @@ uint8_t index_k0[2][4] = {{0,17,33,56},{0,13,25,43}}; - void nr_interleaving_ldpc(uint32_t E, uint8_t Qm, uint8_t *e,uint8_t *f) { uint32_t EQm; EQm = E/Qm; memset(f,0,E*sizeof(uint8_t)); + uint8_t *e0,*e1,*e2,*e3,*e4,*e5,*e6,*e7; + uint8_t *fp; +#if 0 //def __AVX2__ + __m256i tmp0,tmp1,tmp2,tmp0b,tmp1b,tmp3,tmp4,tmp5; + __m256i *e0_256,*e1_256,*e2_256,*e3_256,*e4_256,*e5_256,*e6_256,*e7_256; + + __m256i *f_256=(__m256i *)f; + + uint8_t *fp2; + switch(Qm) { + case 2: + e0=e; + e1=e0+EQm; + e0_256=(__m256i *)e0; + e1_256=(__m256i *)e1; + for (int k=0,j=0;j<EQm>>5;j++,k+=2) { + f_256[k] = _mm256_unpacklo_epi8(e0_256[j],e1_256[j]); + f_256[k+1] = _mm256_unpackhi_epi8(e0_256[j],e1_256[j]); + } + break; + case 4: + e0=e; + e1=e0+EQm; + e2=e1+EQm; + e3=e2+EQm; + e0_256=(__m256i *)e0; + e1_256=(__m256i *)e1; + e2_256=(__m256i *)e2; + e3_256=(__m256i *)e3; + for (int k=0,j=0;j<EQm>>5;j++,k+=4) { + tmp0 = _mm256_unpacklo_epi8(e0_256[j],e1_256[j]); // e0(i) e1(i) e0(i+1) e1(i+1) .... e0(i+15) e1(i+15) + tmp1 = _mm256_unpacklo_epi8(e2_256[j],e3_256[j]); // e2(i) e3(i) e2(i+1) e3(i+1) .... e2(i+15) e3(i+15) + f_256[k] = _mm256_unpacklo_epi8(tmp0,tmp1); // e0(i) e1(i) e2(i) e3(i) ... e0(i+7) e1(i+7) e2(i+7) e3(i+7) + f_256[k+1] = _mm256_unpackhi_epi8(tmp0,tmp1); // e0(i+8) e1(i+8) e2(i+8) e3(i+8) ... e0(i+15) e1(i+15) e2(i+15) e3(i+15) + tmp0 = _mm256_unpackhi_epi8(e0_256[j],e1_256[j]); // e0(i+16) e1(i+16) e0(i+17) e1(i+17) .... e0(i+31) e1(i+31) + tmp1 = _mm256_unpackhi_epi8(e2_256[j],e3_256[j]); // e2(i+16) e3(i+16) e2(i+17) e3(i+17) .... e2(i+31) e3(i+31) + f_256[k+2] = _mm256_unpacklo_epi8(tmp0,tmp1); + f_256[k+3] = _mm256_unpackhi_epi8(tmp0,tmp1); + } + break; + case 6: + e0=e; + e1=e0+EQm; + e2=e1+EQm; + e3=e2+EQm; + e4=e3+EQm; + e5=e4+EQm; + e0_256=(__m256i *)e0; + e1_256=(__m256i *)e1; + e2_256=(__m256i *)e2; + e3_256=(__m256i *)e3; + e4_256=(__m256i *)e4; + e5_256=(__m256i *)e5; + + for (int j=0,k=0;j<EQm>>5;j++,k+=192) { + fp = f+k; + fp2 = fp+96; + + tmp0 = _mm256_unpacklo_epi8(e0_256[j],e1_256[j]); // e0(i) e1(i) e0(i+1) e1(i+1) .... e0(i+15) e1(i+15) + tmp1 = _mm256_unpacklo_epi8(e2_256[j],e3_256[j]); // e2(i) e3(i) e2(i+1) e3(i+1) .... e2(i+15) e3(i+15) + tmp0b = _mm256_unpacklo_epi16(tmp0,tmp1); // e0(i) e1(i) e2(i) e3(i) ... e0(i+7) e1(i+7) e2(i+7) e3(i+7) + tmp1b = _mm256_unpackhi_epi16(tmp0,tmp1); // e0(i+8) e1(i+8) e2(i+8) e3(i+8) ... e0(i+15) e1(i+15) e2(i+15) e3(i+15) + tmp0 = _mm256_unpacklo_epi8(e4_256[j],e5_256[j]); // e4(i) e5(i) e4(i+1) e5(i+1) .... e4(i+15) e5(i+15) + *((uint32_t*)fp) = _mm256_extract_epi32(tmp0b,0); + *((uint16_t*)(fp+4)) = _mm256_extract_epi16(tmp0,0); + *((uint32_t*)(fp+6)) = _mm256_extract_epi32(tmp0b,1); + *((uint16_t*)(fp+10)) = _mm256_extract_epi16(tmp0,1); + *((uint32_t*)(fp+12)) = _mm256_extract_epi32(tmp0b,2); + *((uint16_t*)(fp+16)) = _mm256_extract_epi16(tmp0,2); + *((uint32_t*)(fp+18)) = _mm256_extract_epi32(tmp0b,3); + *((uint16_t*)(fp+22)) = _mm256_extract_epi16(tmp0,3); + *((uint32_t*)(fp+24)) = _mm256_extract_epi32(tmp0b,4); + *((uint16_t*)(fp+26)) = _mm256_extract_epi16(tmp0,4); + *((uint32_t*)(fp+30)) = _mm256_extract_epi32(tmp0b,5); + *((uint16_t*)(fp+34)) = _mm256_extract_epi16(tmp0,5); + *((uint32_t*)(fp+36)) = _mm256_extract_epi32(tmp0,6); + *((uint16_t*)(fp+40)) = _mm256_extract_epi16(tmp0,6); + *((uint32_t*)(fp+42)) = _mm256_extract_epi32(tmp0b,7); + *((uint16_t*)(fp+46)) = _mm256_extract_epi16(tmp0,7); + + *((uint32_t*)(fp+48)) = _mm256_extract_epi32(tmp1b,0); + *((uint16_t*)(fp+52)) = _mm256_extract_epi16(tmp0,8); + *((uint32_t*)(fp+56)) = _mm256_extract_epi32(tmp1b,1); + *((uint16_t*)(fp+60)) = _mm256_extract_epi16(tmp0,9); + *((uint32_t*)(fp+62)) = _mm256_extract_epi32(tmp1b,2); + *((uint16_t*)(fp+66)) = _mm256_extract_epi16(tmp0,10); + *((uint32_t*)(fp+68)) = _mm256_extract_epi32(tmp1b,3); + *((uint16_t*)(fp+72)) = _mm256_extract_epi16(tmp0,11); + *((uint32_t*)(fp+74)) = _mm256_extract_epi32(tmp1b,4); + *((uint16_t*)(fp+76)) = _mm256_extract_epi16(tmp0,12); + *((uint32_t*)(fp+80)) = _mm256_extract_epi32(tmp1b,5); + *((uint16_t*)(fp+82)) = _mm256_extract_epi16(tmp0,13); + *((uint32_t*)(fp+86)) = _mm256_extract_epi32(tmp1b,6); + *((uint16_t*)(fp+90)) = _mm256_extract_epi16(tmp0,14); + *((uint32_t*)(fp+92)) = _mm256_extract_epi32(tmp1b,7); + *((uint16_t*)(fp+94)) = _mm256_extract_epi16(tmp0,15); + + tmp0 = _mm256_unpackhi_epi8(e0_256[j],e1_256[j]); // e0(i+16) e1(i+16) e0(i+17) e1(i+17) .... e0(i+31) e1(i+31) + tmp1 = _mm256_unpackhi_epi8(e2_256[j],e3_256[j]); // e2(i+16) e3(i+16) e2(i+17) e3(i+17) .... e2(i+31) e3(i+31) + tmp0b = _mm256_unpacklo_epi16(tmp0,tmp1); // e0(i+16) e1(i+16) e2(i+16) e3(i+16) ... e0(i+23) e1(i+23) e2(i+23) e3(i+23) + tmp1b = _mm256_unpackhi_epi16(tmp0,tmp1); // e0(i+24) e1(i+24) e2(i+24) e3(i+24) ... e0(i+31) e1(i+31) e2(i+31) e3(i+31) + tmp0 = _mm256_unpackhi_epi8(e4_256[j],e5_256[j]); // e4(i+16) e5(i+16) e4(i+17) e5(i+17) .... e4(i+31) e5(i+31) + *((uint32_t*)fp2) = _mm256_extract_epi32(tmp0b,0); + *((uint16_t*)(fp2+4)) = _mm256_extract_epi16(tmp0,0); + *((uint32_t*)(fp2+6)) = _mm256_extract_epi32(tmp0b,1); + *((uint16_t*)(fp2+10)) = _mm256_extract_epi16(tmp0,1); + *((uint32_t*)(fp2+12)) = _mm256_extract_epi32(tmp0b,2); + *((uint16_t*)(fp2+16)) = _mm256_extract_epi16(tmp0,2); + *((uint32_t*)(fp2+18)) = _mm256_extract_epi32(tmp0b,3); + *((uint16_t*)(fp2+22)) = _mm256_extract_epi16(tmp0,3); + *((uint32_t*)(fp2+24)) = _mm256_extract_epi32(tmp0b,4); + *((uint16_t*)(fp2+26)) = _mm256_extract_epi16(tmp0,4); + *((uint32_t*)(fp2+30)) = _mm256_extract_epi32(tmp0b,5); + *((uint16_t*)(fp2+34)) = _mm256_extract_epi16(tmp0,5); + *((uint32_t*)(fp2+36)) = _mm256_extract_epi32(tmp0,6); + *((uint16_t*)(fp2+40)) = _mm256_extract_epi16(tmp0,6); + *((uint32_t*)(fp2+42)) = _mm256_extract_epi32(tmp0b,7); + *((uint16_t*)(fp2+46)) = _mm256_extract_epi16(tmp0,7); + + *((uint32_t*)(fp2+48)) = _mm256_extract_epi32(tmp1b,0); + *((uint16_t*)(fp2+52)) = _mm256_extract_epi16(tmp0,8); + *((uint32_t*)(fp2+56)) = _mm256_extract_epi32(tmp1b,1); + *((uint16_t*)(fp2+60)) = _mm256_extract_epi16(tmp0,9); + *((uint32_t*)(fp2+62)) = _mm256_extract_epi32(tmp1b,2); + *((uint16_t*)(fp2+66)) = _mm256_extract_epi16(tmp0,10); + *((uint32_t*)(fp2+68)) = _mm256_extract_epi32(tmp1b,3); + *((uint16_t*)(fp2+72)) = _mm256_extract_epi16(tmp0,11); + *((uint32_t*)(fp2+74)) = _mm256_extract_epi32(tmp1b,4); + *((uint16_t*)(fp2+76)) = _mm256_extract_epi16(tmp0,12); + *((uint32_t*)(fp2+80)) = _mm256_extract_epi32(tmp1b,5); + *((uint16_t*)(fp2+82)) = _mm256_extract_epi16(tmp0,13); + *((uint32_t*)(fp2+86)) = _mm256_extract_epi32(tmp1b,6); + *((uint16_t*)(fp2+90)) = _mm256_extract_epi16(tmp0,14); + *((uint32_t*)(fp2+92)) = _mm256_extract_epi32(tmp1b,7); + *((uint16_t*)(fp2+94)) = _mm256_extract_epi16(tmp0,15); + } + break; + case 8: + e0=e; + e1=e0+EQm; + e2=e1+EQm; + e3=e2+EQm; + e4=e3+EQm; + e5=e4+EQm; + e6=e5+EQm; + e7=e6+EQm; + + e0_256=(__m256i *)e0; + e1_256=(__m256i *)e1; + e2_256=(__m256i *)e2; + e3_256=(__m256i *)e3; + e4_256=(__m256i *)e4; + e5_256=(__m256i *)e5; + e6_256=(__m256i *)e6; + e7_256=(__m256i *)e7; + for (int k=0,j=0;j<EQm>>5;j++,k+=8) { + tmp0 = _mm256_unpacklo_epi8(e0_256[j],e1_256[j]); // e0(i) e1(i) e0(i+1) e1(i+1) .... e0(i+15) e1(i+15) + tmp1 = _mm256_unpacklo_epi8(e2_256[j],e3_256[j]); // e2(i) e3(i) e2(i+1) e3(i+1) .... e2(i+15) e3(i+15) + tmp2 = _mm256_unpacklo_epi8(e4_256[j],e5_256[j]); // e4(i) e5(i) e4(i+1) e5(i+1) .... e4(i+15) e5(i+15) + tmp3 = _mm256_unpacklo_epi8(e6_256[j],e7_256[j]); // e6(i) e7(i) e6(i+1) e7(i+1) .... e6(i+15) e7(i+15) + tmp4 = _mm256_unpacklo_epi16(tmp0,tmp1); // e0(i) e1(i) e2(i) e3(i) ... e0(i+7) e1(i+7) e2(i+7) e3(i+7) + tmp5 = _mm256_unpacklo_epi16(tmp2,tmp3); // e4(i) e5(i) e6(i) e7(i) ... e4(i+7) e5(i+7) e6(i+7) e7(i+7) + f_256[k] = _mm256_unpacklo_epi16(tmp4,tmp5); // e0(i) e1(i) e2(i) e3(i) e4(i) e5(i) e6(i) e7(i)... e0(i+3) e1(i+3) e2(i+3) e3(i+3) e4(i+3) e5(i+3) e6(i+3) e7(i+3)) + f_256[k+1] = _mm256_unpackhi_epi16(tmp4,tmp5); // e0(i+4) e1(i+4) e2(i+4) e3(i+4) e4(i+4) e5(i+4) e6(i+4) e7(i+4)... e0(i+7) e1(i+7) e2(i+7) e3(i+7) e4(i+7) e5(i+7) e6(i+7) e7(i+7)) + + tmp4 = _mm256_unpackhi_epi16(tmp0,tmp1); // e0(i+8) e1(i+8) e2(i+8) e3(i+8) ... e0(i+15) e1(i+15) e2(i+15) e3(i+15) + tmp5 = _mm256_unpackhi_epi16(tmp2,tmp3); // e4(i+8) e5(i+8) e6(i+8) e7(i+8) ... e4(i+15) e5(i+15) e6(i+15) e7(i+15) + f_256[k+2] = _mm256_unpacklo_epi16(tmp4,tmp5); // e0(i+8) e1(i+8) e2(i+8) e3(i+8) e4(i+8) e5(i+8) e6(i+8) e7(i+8)... e0(i+11) e1(i+11) e2(i+11) e3(i+11) e4(i+11) e5(i+11) e6(i+11) e7(i+11)) + f_256[k+3] = _mm256_unpackhi_epi16(tmp4,tmp5); // e0(i+12) e1(i+12) e2(i+12) e3(i+12) e4(i+12) e5(i+12) e6(i+12) e7(i+12)... e0(i+15) e1(i+15) e2(i+15) e3(i+15) e4(i+15) e5(i+15) e6(i+15) e7(i+15)) + + tmp0 = _mm256_unpackhi_epi8(e0_256[j],e1_256[j]); // e0(i+16) e1(i+16) e0(i+17) e1(i+17) .... e0(i+31) e1(i+31) + tmp1 = _mm256_unpackhi_epi8(e2_256[j],e3_256[j]); // e2(i+16) e3(i+16) e2(i+17) e3(i+17) .... e2(i+31) e3(i+31) + tmp2 = _mm256_unpackhi_epi8(e4_256[j],e5_256[j]); // e4(i+16) e5(i+16) e4(i+17) e5(i+17) .... e4(i+31) e5(i+31) + tmp3 = _mm256_unpackhi_epi8(e6_256[j],e7_256[j]); // e6(i+16) e7(i+16) e6(i+17) e7(i+17) .... e6(i+31) e7(i+31) + tmp4 = _mm256_unpacklo_epi16(tmp0,tmp1); // e0(i+!6) e1(i+16) e2(i+16) e3(i+16) ... e0(i+23) e1(i+23) e2(i+23) e3(i+23) + tmp5 = _mm256_unpacklo_epi16(tmp2,tmp3); // e4(i+16) e5(i+16) e6(i+16) e7(i+16) ... e4(i+23) e5(i+23) e6(i+23) e7(i+23) + f_256[k+4] = _mm256_unpacklo_epi16(tmp4,tmp5); // e0(i+16) e1(i+16) e2(i+16) e3(i+16) e4(i+16) e5(i+16) e6(i+16) e7(i+16)... e0(i+19) e1(i+19) e2(i+19) e3(i+19) e4(i+19) e5(i+19) e6(i+19) e7(i+19)) + f_256[k+5] = _mm256_unpackhi_epi16(tmp4,tmp5); // e0(i+20) e1(i+20) e2(i+20) e3(i+20) e4(i+20) e5(i+20) e6(i+20) e7(i+20)... e0(i+23) e1(i+23) e2(i+23) e3(i+23) e4(i+23) e5(i+23) e6(i+23) e7(i+23)) + + tmp4 = _mm256_unpackhi_epi16(tmp0,tmp1); // e0(i+24) e1(i+24) e2(i+24) e3(i+24) ... e0(i+31) e1(i+31) e2(i+31) e3(i+31) + tmp5 = _mm256_unpackhi_epi16(tmp2,tmp3); // e4(i+24) e5(i+24) e6(i+24) e7(i+24) ... e4(i+31) e5(i+31) e6(i+31) e7(i+31) + f_256[k+6] = _mm256_unpacklo_epi16(tmp4,tmp5); // e0(i+24) e1(i+24) e2(i+24) e3(i+24) e4(i+24) e5(i+24) e6(i+24) e7(i+24)... e0(i+27) e1(i+27) e2(i+27) e3(i+27) e4(i+27) e5(i+27) e6(i+27) e7(i+27)) + f_256[k+7] = _mm256_unpackhi_epi16(tmp4,tmp5); // e0(i+28) e1(i+28) e2(i+28) e3(i+28) e4(i+28) e5(i+28) e6(i+28) e7(i+28)... e0(i+31) e1(i+31) e2(i+31) e3(i+31) e4(i+31) e5(i+31) e6(i+31) e7(i+31)) + } + break; + default: AssertFatal(1==0,"Should be here!\n"); + } - for (int j = 0; j< EQm; j++){ - for (int i = 0; i< Qm; i++){ +#else + //original unoptimized loops + /* + for (int j = 0; j< EQm; j++,j2+=2){ + for (int i = 0; i< Qm; i++){ f[(i+j*Qm)] = e[(i*EQm + j)]; } + } + */ + + int j2=0; + fp=f; + switch (Qm) { + case 2: + e0=e; + e1=e0+EQm; + for (int j = 0; j< EQm; j++,j2+=2){ + fp=&f[j2]; + fp[0] = e0[j]; + fp[1] = e1[j]; + } + break; + case 4: + e0=e; + e1=e0+EQm; + e2=e1+EQm; + e3=e2+EQm; + for (int j = 0; j< EQm; j++,j2+=4){ + fp=&f[j2]; + fp[0] = e0[j]; + fp[1] = e1[j]; + fp[2] = e2[j]; + fp[3] = e3[j]; + } + break; + case 6: + e0=e; + e1=e0+EQm; + e2=e1+EQm; + e3=e2+EQm; + e4=e3+EQm; + e5=e4+EQm; + fp = f; + for (int j = 0; j< EQm; j++){ + *fp++ = e0[j]; + *fp++ = e1[j]; + *fp++ = e2[j]; + *fp++ = e3[j]; + *fp++ = e4[j]; + *fp++ = e5[j]; + } + break; + case 8: + e0=e; + e1=e0+EQm; + e2=e1+EQm; + e3=e2+EQm; + e4=e3+EQm; + e5=e4+EQm; + e6=e5+EQm; + e7=e6+EQm; + for (int j = 0; j< EQm; j++,j2+=8){ + fp=&f[j2]; + fp[0] = e0[j]; + fp[1] = e1[j]; + fp[2] = e2[j]; + fp[3] = e3[j]; + fp[4] = e4[j]; + fp[5] = e5[j]; + fp[6] = e6[j]; + fp[7] = e7[j]; + } + break; + default: AssertFatal(1==0,"Should never be here!\n"); } - +#endif } + + void nr_deinterleaving_ldpc(uint32_t E, uint8_t Qm, int16_t *e,int16_t *f) { @@ -71,6 +329,8 @@ int nr_rate_matching_ldpc(uint8_t Ilbrm, uint8_t *w, uint8_t *e, uint8_t C, + uint32_t F, + uint32_t Foffset, uint8_t rvidx, uint32_t E) { @@ -94,21 +354,36 @@ int nr_rate_matching_ldpc(uint8_t Ilbrm, ind = (index_k0[BG-1][rvidx]*Ncb/N)*Z; #ifdef RM_DEBUG - printf("nr_rate_matching_ldpc: E %d, k0 %d, Ncb %d, rvidx %d\n", E, ind, Ncb, rvidx); + printf("nr_rate_matching_ldpc: E %d, F %d, Foffset %d, k0 %d, Ncb %d, rvidx %d\n", E, F, Foffset,ind, Ncb, rvidx); #endif + AssertFatal(Foffset <= E,"Foffset %d > E %d\n",Foffset,E); + AssertFatal(Foffset <= Ncb,"Foffset %d > Ncb %d\n",Foffset,Ncb); - k=0; + if (ind >= Foffset && ind < (F+Foffset)) ind = F+Foffset; - for (; (ind<Ncb)&&(k<E); ind++) { + if (ind < Foffset) { // case where we have some bits before the filler and the rest after + memcpy((void*)e,(void*)(w+ind),Foffset-ind); -#ifdef RM_DEBUG - printf("RM_TX k%d Ind: %d (%d)\n",k,ind,w[ind]); -#endif + if (E + F <= Ncb) { // E+F doesn't contain all coded bits + memcpy((void*)(e+Foffset-ind),(void*)(w+Foffset+F-ind),E-Foffset+ind); + k=E; + } + else { + memcpy((void*)(e+Foffset-ind),(void*)(w+Foffset+F),Ncb-Foffset-F); + k=Ncb-F-ind; + } + } + else { + if (E + F <= Ncb-ind) { //E+F doesn't contain all coded bits + memcpy((void*)(e+Foffset-ind),(void*)(w+Foffset+F-ind),E-Foffset+ind); + k=E; + } + else { - if (w[ind] != NR_NULL) e[k++]=w[ind]; + } } - while(k<E) { + while(k<E) { // case where we do repetitions (low mcs) for (ind=0; (ind<Ncb)&&(k<E); ind++) { #ifdef RM_DEBUG diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index 6df9bd099df..7d52ef04e34 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -305,13 +305,13 @@ int nr_dlsch_encoding(unsigned char *a, #ifdef DEBUG_DLSCH_CODING LOG_D(PHY,"encoding thinks this is a new packet \n"); #endif - /* + /* int i; LOG_D(PHY,"dlsch (tx): \n"); for (i=0;i<(A>>3);i++) - LOG_D(PHY,"%02x.",a[i]); + LOG_D(PHY,"%02x\n",a[i]); LOG_D(PHY,"\n"); - */ + */ if (A > 3824) { // Add 24-bit crc (polynomial A) to payload @@ -381,7 +381,7 @@ int nr_dlsch_encoding(unsigned char *a, LOG_D(PHY,"Encoder: B %d F %d \n",dlsch->harq_processes[harq_pid]->B, dlsch->harq_processes[harq_pid]->F); LOG_D(PHY,"start ldpc encoder segment %d/%d\n",r,dlsch->harq_processes[harq_pid]->C); LOG_D(PHY,"input %d %d %d %d %d \n", dlsch->harq_processes[harq_pid]->c[r][0], dlsch->harq_processes[harq_pid]->c[r][1], dlsch->harq_processes[harq_pid]->c[r][2],dlsch->harq_processes[harq_pid]->c[r][3], dlsch->harq_processes[harq_pid]->c[r][4]); - for (int cnt =0 ; cnt < 22*(*pz)/8; cnt ++){ + for (int cnt =0 ; cnt < 22*(*Zc)/8; cnt ++){ LOG_D(PHY,"%d ", dlsch->harq_processes[harq_pid]->c[r][cnt]); } LOG_D(PHY,"\n"); @@ -407,7 +407,7 @@ int nr_dlsch_encoding(unsigned char *a, for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) { - if (dlsch->harq_processes[harq_pid]->F>0) { + if (F>0) { for (int k=(Kr-F-2*(*Zc)); k<Kr-2*(*Zc); k++) { dlsch->harq_processes[harq_pid]->d[r][k] = NR_NULL; //if (k<(Kr-F+8)) @@ -415,13 +415,7 @@ int nr_dlsch_encoding(unsigned char *a, } } -#ifdef DEBUG_DLSCH_CODING - printf("Rate Matching, Code segment %d (coded bits (G) %u, unpunctured/repeated bits per code segment %d, mod_order %d, nb_rb %d)...\n", - r, - G, - Kr*3, - mod_order,nb_rb); -#endif + #ifdef DEBUG_DLSCH_CODING LOG_D(PHY,"rvidx in encoding = %d\n", rel15->rvIndex[0]); @@ -429,6 +423,17 @@ int nr_dlsch_encoding(unsigned char *a, E = nr_get_E(G, dlsch->harq_processes[harq_pid]->C, mod_order, rel15->nrOfLayers, r); +#ifdef DEBUG_DLSCH_CODING + printf("Rate Matching, Code segment %d/%d (coded bits (G) %u, E %d, Filler bits %d, Filler offset %d mod_order %d, nb_rb %d)...\n", + r, + dlsch->harq_processes[harq_pid]->C, + G, + E, + F, + Kr-F-2*(*Zc), + mod_order,nb_rb); +#endif + // for tbslbrm calculation according to 5.4.2.1 of 38.212 if (rel15->nrOfLayers < Nl) Nl = rel15->nrOfLayers; @@ -443,6 +448,8 @@ int nr_dlsch_encoding(unsigned char *a, dlsch->harq_processes[harq_pid]->d[r], dlsch->harq_processes[harq_pid]->e+r_offset, dlsch->harq_processes[harq_pid]->C, + F, + Kr-F-2*(*Zc), rel15->rvIndex[0], E); stop_meas(dlsch_rate_matching_stats); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index 611b20fa8bd..7c9bb3b6460 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -43,7 +43,7 @@ #include "executables/nr-uesoftmodem.h" #include "PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.h" #include "PHY/CODING/nrLDPC_decoder/nrLDPC_types.h" -//#define DEBUG_DLSCH_DECODING +//#define DEBUG_DLSCH_DECODING 1 //#define ENABLE_PHY_PAYLOAD_DEBUG 1 #define OAI_LDPC_MAX_NUM_LLR 27000//26112 // NR_LDPC_NCOL_BG1*NR_LDPC_ZMAX @@ -239,7 +239,6 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, } t_nrLDPC_procBuf** p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf; - AssertFatal(p_nrLDPC_procBuf[0]->llrProcBuf!=NULL,"Entry. llProcBuf is null!\n"); int16_t z [68*384]; int8_t l [68*384]; @@ -253,7 +252,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, double Coderate;// = 0.0; uint8_t dmrs_Type = harq_process->dmrsConfigType; - AssertFatal(dmrs_Type == NFAPI_NR_DMRS_TYPE1 || dmrs_Type == NFAPI_NR_DMRS_TYPE2,"Illegal dmrs_type %d\n",dmrs_Type); + AssertFatal(dmrs_Type == 1 || dmrs_Type == 2,"Illegal dmrs_type %d\n",dmrs_Type); uint8_t nb_re_dmrs = (dmrs_Type==1)?6:4; uint16_t dmrs_length = get_num_dmrs(harq_process->dlDmrsSymbPos); AssertFatal(dmrs_length == 1 || dmrs_length == 2,"Illegal dmrs_length %d\n",dmrs_length); @@ -315,7 +314,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, harq_process->G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, dmrs_length, harq_process->Qm,harq_process->Nl); G = harq_process->G; - LOG_D(PHY,"DLSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, harq_process->mcs, harq_process->Nl, nb_symb_sch,nb_rb); + LOG_D(PHY,"DLSCH Decoding, harq_pid %d TBS %d G %d nb_re_dmrs %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, nb_re_dmrs,harq_process->mcs, harq_process->Nl, nb_symb_sch,nb_rb); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_SEGMENTATION, VCD_FUNCTION_IN); @@ -431,14 +430,12 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_DEINTERLEAVING, VCD_FUNCTION_IN); - AssertFatal(p_nrLDPC_procBuf[r]->llrProcBuf!=NULL,"10. llProcBuf is null!\n"); nr_deinterleaving_ldpc(E, harq_process->Qm, harq_process->w[r], // [hna] w is e dlsch_llr+r_offset); - AssertFatal(p_nrLDPC_procBuf[r]->llrProcBuf!=NULL,"11. llProcBuf is null!\n"); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_DEINTERLEAVING, VCD_FUNCTION_OUT); @@ -472,7 +469,6 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, else Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,4,harq_process->C); - AssertFatal(p_nrLDPC_procBuf[r]->llrProcBuf!=NULL,"0. llProcBuf is null!\n"); if (nr_rate_matching_ldpc_rx(Ilbrm, Tbslbrm, @@ -498,7 +494,6 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, #endif } - AssertFatal(p_nrLDPC_procBuf[r]->llrProcBuf!=NULL,"1. llProcBuf is null!\n"); //for (int i =0; i<16; i++) // printf("rx output ratematching d[%d]= %d r_offset %d\n", i,harq_process->d[r][i], r_offset); @@ -508,12 +503,12 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, #ifdef DEBUG_DLSCH_DECODING if (r==0) { write_output("decoder_llr.m","decllr",dlsch_llr,G,1,0); - write_output("decoder_in.m","dec",&harq_process->d[0][0],(3*8*Kr_bytes)+12,1,0); + write_output("decoder_in.m","dec",&harq_process->d[0][0],E,1,0); } printf("decoder input(segment %u) :",r); int i; - for (i=0;i<(3*8*Kr_bytes)+12;i++) + for (i=0;i<E;i++) printf("%d : %d\n",i,harq_process->d[r][i]); printf("\n"); #endif @@ -566,13 +561,11 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, } vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_LDPC, VCD_FUNCTION_IN); - AssertFatal(p_nrLDPC_procBuf[r]->llrProcBuf!=NULL,"2. llProcBuf is null!\n"); no_iteration_ldpc = nrLDPC_decoder(p_decParams, (int8_t*)&pl[0], llrProcBuf, p_nrLDPC_procBuf[r], p_procTime); - AssertFatal(p_nrLDPC_procBuf[r]->llrProcBuf!=NULL,"3. llProcBuf is null!\n"); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_LDPC, VCD_FUNCTION_OUT); // Fixme: correct type is unsigned, but nrLDPC_decoder and all called behind use signed int @@ -587,7 +580,6 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, ret = 1 + dlsch->max_ldpc_iterations; } - AssertFatal(p_nrLDPC_procBuf[r]->llrProcBuf!=NULL,"4. llProcBuf is null!\n"); nb_total_decod++; if (no_iteration_ldpc > dlsch->max_ldpc_iterations){ @@ -604,7 +596,6 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, { harq_process->c[r][m]= (uint8_t) llrProcBuf[m]; } - AssertFatal(p_nrLDPC_procBuf[r]->llrProcBuf!=NULL,"5. llProcBuf is null!\n"); #ifdef DEBUG_DLSCH_DECODING //printf("output decoder %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]); @@ -667,7 +658,6 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, phy_vars_ue->Mod_id,nr_tti_rx,harq_pid,harq_process->status,harq_process->round,dlsch->Mdlharq,harq_process->TBS); } - AssertFatal(p_nrLDPC_procBuf[r]->llrProcBuf!=NULL,"Exit 1. llProcBuf is null!\n"); return((1 + dlsch->max_ldpc_iterations)); } else { //#if UE_DEBUG_TRACE @@ -707,12 +697,10 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, for (r=0; r<harq_process->C; r++) { - AssertFatal(p_nrLDPC_procBuf[0]->llrProcBuf!=NULL,"7. llProcBuf is null (r %d)!\n",r); memcpy(harq_process->b+offset, harq_process->c[r], Kr_bytes- - (harq_process->F>>3) -((harq_process->C>1)?3:0)); offset += (Kr_bytes - (harq_process->F>>3) - ((harq_process->C>1)?3:0)); - AssertFatal(p_nrLDPC_procBuf[0]->llrProcBuf!=NULL,"8. llProcBuf is null (r %d)!\n",r); #ifdef DEBUG_DLSCH_DECODING printf("Segment %u : Kr= %u bytes\n",r,Kr_bytes); @@ -744,7 +732,6 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, dlsch->last_iteration_cnt = ret; - AssertFatal(p_nrLDPC_procBuf[0]->llrProcBuf!=NULL,"Exit 2. llProcBuf is null!\n"); return(ret); } @@ -803,7 +790,7 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, double Coderate = 0.0; nfapi_nr_dl_config_dlsch_pdu_rel15_t *dl_config_pdu = &harq_processes[harq_pid]->dl_config_pdu uint8_t dmrs_type = dl_config_pdu->dmrsConfigType; - uint8_t nb_re_dmrs = (dmrs_type==NFAPI_NR_DMRS_TYPE1)?6:4; + uint8_t nb_re_dmrs = (dmrs_type==1)?6:4; uint16_t length_dmrs = get_num_dmrs(dl_config_pdu->dlDmrsSymbPos); uint32_t i,j; @@ -864,7 +851,7 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, G = harq_process->G; - LOG_D(PHY,"DLSCH Decoding main, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, harq_process->mcs, harq_process->Nl, nb_symb_sch,nb_rb); + LOG_D(PHY,"DLSCH Decoding main, harq_pid %d TBS %d G %d, nb_re_dmrs %d, length_dmrs %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, nb_re_dmrs, length_dmrs, harq_process->mcs, harq_process->Nl, nb_symb_sch,nb_rb); proc->decoder_main_available = 1; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index ad10d693ac3..8bf0cb66c40 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -427,7 +427,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, for (aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++) avgs = cmax(avgs,avg[(aatx<<1)+aarx]); - pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2)+1; + pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2)+3; } else if (dlsch0_harq->mimo_mode == NR_DUALSTREAM) { diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 6aff2971d80..f5576534163 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -396,6 +396,8 @@ opp_enabled=0; harq_process->d[r], harq_process->e+r_offset, harq_process->C, + F, + Kr-F-2*(*pz), harq_process->rvidx, E); diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 50b9c0ff060..cb92b7c5649 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -449,10 +449,11 @@ int main(int argc, char **argv) rel15->NrOfSymbols = nb_symb_sch; rel15->qamModOrder[0] = mod_order; rel15->nrOfLayers = Nl; - rel15->TBSize[0] = TBS; + rel15->TBSize[0] = TBS>>3; rel15->targetCodeRate[0] = rate; rel15->NrOfCodewords = 1; rel15->dmrsConfigType = NFAPI_NR_DMRS_TYPE1; + rel15->dlDmrsSymbPos = 4; double *modulated_input = malloc16(sizeof(double) * 16 * 68 * 384); // [hna] 16 segments, 68*Zc short *channel_output_fixed = malloc16(sizeof(short) * 16 * 68 * 384); short *channel_output_uncoded = malloc16(sizeof(unsigned short) * 16 * 68 * 384); @@ -473,7 +474,8 @@ int main(int argc, char **argv) harq_process->Qm = mod_order; harq_process->rvidx = rvidx; harq_process->R = rate; - harq_process->dmrsConfigType = NFAPI_NR_DMRS_TYPE1; + harq_process->dmrsConfigType = 1; + harq_process->dlDmrsSymbPos = 4; printf("harq process ue mcs = %d Qm = %d, symb %d\n", harq_process->mcs, harq_process->Qm, nb_symb_sch); unsigned char *test_input; test_input = (unsigned char *) malloc16(sizeof(unsigned char) * TBS / 8); diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 983c72b3e47..056f808be3a 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -186,8 +186,6 @@ int main(int argc, char **argv) int trial, n_trials = 1, n_errors = 0, n_false_positive = 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; @@ -206,25 +204,21 @@ int main(int argc, char **argv) int N_RB_DL=106,mu=1; nfapi_nr_dl_tti_pdsch_pdu_rel15_t dlsch_config; - uint16_t ssb_periodicity = 10; //unsigned char frame_type = 0; int frame=0,slot=1; int frame_length_complex_samples; int frame_length_complex_samples_no_prefix; - int slot_length_complex_samples_no_prefix; NR_DL_FRAME_PARMS *frame_parms; UE_nr_rxtx_proc_t UE_proc; NR_Sched_Rsp_t Sched_INFO; gNB_MAC_INST *gNB_mac; NR_UE_MAC_INST_t *UE_mac; int cyclic_prefix_type = NFAPI_CP_NORMAL; - int ret; int run_initial_sync=0; int do_pdcch_flag=1; - uint16_t cset_offset = 0; int loglvl=OAILOG_INFO; float target_error_rate = 0.01; @@ -238,10 +232,10 @@ int main(int argc, char **argv) randominit(0); - int mcsIndex_set=0,rbStart_set=0,rbSize_set=0,StartSymbolIndex_set=0,NrOfSymbols_set=0; + int mcsIndex_set=0,rbStart_set=0,rbSize_set=0; int print_perf = 0; - while ((c = getopt (argc, argv, "f:hA:pf:g:i:j:n:s:S:t:x:y:z:M:N:F:GR:dPIL:Eo:a:b:c:j:e:")) != -1) { + while ((c = getopt (argc, argv, "f:hA:pf:g:i:j:n:s:S:t:x:y:z:M:N:F:GR:dPIL:Ea:b:e:")) != -1) { switch (c) { /*case 'f': write_output_file=1; @@ -367,14 +361,6 @@ int main(int argc, char **argv) break; - case 'M': - SSB_positions = atoi(optarg); - break; - - case 'N': - Nid_cell = atoi(optarg); - break; - case 'R': N_RB_DL = atoi(optarg); break; @@ -408,9 +394,6 @@ int main(int argc, char **argv) css_flag=1; break; - case 'o': - cset_offset = atoi(optarg); - break; case 'a': dlsch_config.rbStart = atoi(optarg); @@ -422,16 +405,6 @@ int main(int argc, char **argv) rbSize_set=1; break; - case 'c': - dlsch_config.StartSymbolIndex = atoi(optarg); - StartSymbolIndex_set=1; - break; - - case 'j': - dlsch_config.NrOfSymbols = atoi(optarg); - NrOfSymbols_set=1; - break; - case 'e': dlsch_config.mcsIndex[0] = atoi(optarg); mcsIndex_set=1; @@ -454,8 +427,6 @@ int main(int argc, char **argv) printf("-z Number of RX antennas used in UE\n"); //printf("-i Relative strength of first intefering gNB (in dB) - cell_id mod 3 = 1\n"); //printf("-j Relative strength of second intefering gNB (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"); @@ -595,7 +566,6 @@ int main(int argc, char **argv) frame_length_complex_samples = frame_parms->samples_per_subframe*NR_NUMBER_OF_SUBFRAMES_PER_FRAME; frame_length_complex_samples_no_prefix = frame_parms->samples_per_subframe_wCP*NR_NUMBER_OF_SUBFRAMES_PER_FRAME; - slot_length_complex_samples_no_prefix = frame_parms->samples_per_slot_wCP; s_re = malloc(2*sizeof(double*)); s_im = malloc(2*sizeof(double*)); @@ -665,7 +635,7 @@ int main(int argc, char **argv) UE_mac->if_module = nr_ue_if_module_init(0); - unsigned int available_bits; + unsigned int available_bits=0; unsigned char *estimated_output_bit; unsigned char *test_input_bit; unsigned int errors_bit = 0; @@ -687,8 +657,6 @@ int main(int argc, char **argv) //Configure UE - uint32_t pdcch_ConfigSIB1 = 0; - uint32_t ssb_SubcarrierOffset = 0; rrc.carrier.MIB = (uint8_t*) malloc(4); rrc.carrier.sizeof_MIB = do_MIB_NR(&rrc,0); @@ -717,7 +685,6 @@ int main(int argc, char **argv) for (SNR = snr0; SNR < snr1; SNR += .2) { varArray_t *table_tx=initVarArray(1000,sizeof(double)); - varArray_t *table_tx_ifft=initVarArray(1000,sizeof(double)); reset_meas(&gNB->phy_proc_tx); // total gNB tx reset_meas(&gNB->dlsch_scrambling_stats); reset_meas(&gNB->dlsch_interleaving_stats); @@ -801,7 +768,9 @@ int main(int argc, char **argv) // if (n_trials==1) printf("txlev %d (%f)\n",txlev,10*log10((double)txlev)); - for (i=0; i<frame_length_complex_samples; i++) { + for (i=(slot * frame_parms->samples_per_slot); + i<((slot+1) * frame_parms->samples_per_slot); + i++) { for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) { r_re[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)]); r_im[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)+1]); @@ -812,11 +781,13 @@ int main(int argc, char **argv) nfapi_nr_dl_tti_pdsch_pdu_rel15_t rel15 = gNB_dlsch->harq_processes[0]->pdsch_pdu.pdsch_pdu_rel15; //AWGN - sigma2_dB = 10 * log10((double)txlev * (N_RB_DL/rel15.rbSize)) - SNR; + sigma2_dB = 10 * log10((double)txlev * ((double)UE->frame_parms.ofdm_symbol_size/(12*rel15.rbSize))) - SNR; sigma2 = pow(10, sigma2_dB/10); - if (n_trials==1) printf("sigma2 %f (%f dB), txlev %f (factor %f)\n",sigma2,sigma2_dB,10*log10((double)txlev* (N_RB_DL/rel15.rbSize)),(double)N_RB_DL/rel15.rbSize); + if (n_trials==1) printf("sigma2 %f (%f dB), txlev %f (factor %f)\n",sigma2,sigma2_dB,10*log10((double)txlev),(double)(double)UE->frame_parms.ofdm_symbol_size/(12*rel15.rbSize)); - for (i=0; i<frame_length_complex_samples; i++) { + for (i=(slot * frame_parms->samples_per_slot); + i<((slot+1) * frame_parms->samples_per_slot); + i++) { for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) { ((short*) UE->common_vars.rxdata[aa])[2*i] = (short) ((r_re[aa][i] + sqrt(sigma2/2)*gaussdouble(0.0,1.0))); ((short*) UE->common_vars.rxdata[aa])[2*i+1] = (short) ((r_im[aa][i] + sqrt(sigma2/2)*gaussdouble(0.0,1.0))); @@ -899,7 +870,7 @@ int main(int argc, char **argv) if (errors_scrambling > 0) { if (n_trials == 1) - printf("errors_scrambling = %d (trial %d)\n", errors_scrambling, trial); + printf("errors_scrambling = %d/%d (trial %d)\n", errors_scrambling, available_bits,trial); } if (errors_bit > 0) { @@ -935,7 +906,11 @@ int main(int argc, char **argv) if (print_perf==1) { - printf("\ngNB TX function statistics (per %d us slot)\n",1000>>*scc->ssbSubcarrierSpacing); + printf("\ngNB TX function statistics (per %d us slot, NPRB %d, mcs %d, TBS %d, Kr %d (Zc %d))\n", + 1000>>*scc->ssbSubcarrierSpacing,dlsch_config.rbSize,dlsch_config.mcsIndex[0], + gNB->dlsch[0][0]->harq_processes[0]->pdsch_pdu.pdsch_pdu_rel15.TBSize[0]<<3, + gNB->dlsch[0][0]->harq_processes[0]->K, + gNB->dlsch[0][0]->harq_processes[0]->K/((gNB->dlsch[0][0]->harq_processes[0]->pdsch_pdu.pdsch_pdu_rel15.TBSize[0]<<3)>3824?22:10)); printDistribution(&gNB->phy_proc_tx,table_tx,"PHY proc tx"); printStatIndent2(&gNB->dlsch_encoding_stats,"DLSCH encoding time"); printStatIndent3(&gNB->dlsch_segmentation_stats,"DLSCH segmentation time"); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index f1302fd1d18..73f51ed39a4 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -316,9 +316,9 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, protocol_ctxt_t ctxt; - int CC_id, i = -1; - NR_UE_list_t *UE_list = &RC.nrmac[module_idP]->UE_list; - rnti_t rnti; + int CC_id; + + NR_COMMON_channels_t *cc = RC.nrmac[module_idP]->common_channels; //nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config = NULL; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 0c425bdb05e..dd8c48fee01 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -249,9 +249,9 @@ int configure_fapi_dl_Tx(int Mod_idP, int *CCEIndex, nfapi_nr_dl_tti_request_body_t *dl_req, nfapi_nr_pdu_t *TX_req, - int *mcsIndex, - int *rbSize, - int *rbStart) { + uint8_t *mcsIndex, + uint16_t *rbSize, + uint16_t *rbStart) { gNB_MAC_INST *nr_mac = RC.nrmac[Mod_idP]; @@ -303,7 +303,7 @@ int configure_fapi_dl_Tx(int Mod_idP, pdsch_pdu_rel15->NrOfCodewords = 1; int mcs = (mcsIndex!=NULL) ? *mcsIndex : 9; - pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(mcsIndex,0); + pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(mcs,0); pdsch_pdu_rel15->qamModOrder[0] = 2; pdsch_pdu_rel15->mcsIndex[0] = mcs; pdsch_pdu_rel15->mcsTable[0] = 0; @@ -430,7 +430,7 @@ int configure_fapi_dl_Tx(int Mod_idP, // TX_req->TLVs[0].length = 8; // memcpy((void*)&TX_req->TLVs[0].value.direct[0],(void*)&cc[CC_id].RAR_pdu.payload[0],TX_req->TLVs[0].length); - return TBS/8; //Return TBS in bytes + return TBS; //Return TBS in bytes } void config_uldci(NR_BWP_Uplink_t *ubwp,nfapi_nr_pusch_pdu_t *pusch_pdu,nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15, dci_pdu_rel15_t *dci_pdu_rel15, int *dci_formats, int *rnti_types) { @@ -681,9 +681,10 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, dlsch_config!=NULL ? &dlsch_config->rbStart : NULL); // HOT FIX for all zero pdu problem // ------------------------------------------------------------------------------------------------ - + + LOG_D(MAC,"Filling %d bytes in DL_TX\n",TBS_bytes); for(int i = 0; i < TBS_bytes; i++) { // - ((uint8_t *)nr_mac->UE_list.DLSCH_pdu[0][0].payload[0])[i] = (unsigned char) rand(); + ((uint8_t *)nr_mac->UE_list.DLSCH_pdu[0][0].payload[0])[i] = (unsigned char) (lrand48()&0xff); //LOG_I(MAC, "%x. ", ((uint8_t *)nr_mac->UE_list.DLSCH_pdu[CC_id][0][0].payload[0])[i]); } #if defined(ENABLE_MAC_PAYLOAD_DEBUG) diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 8a021842650..3c1573fe271 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -70,9 +70,9 @@ int configure_fapi_dl_Tx(int Mod_id, int *CCEIndeces, nfapi_nr_dl_tti_request_body_t *dl_req, nfapi_nr_pdu_t *TX_req, - int *mcsIndex, - int *rbSize, - int *rbStart); + uint8_t *mcsIndex, + uint16_t *rbSize, + uint16_t *rbStart); void config_uldci(NR_BWP_Uplink_t *ubwp,nfapi_nr_pusch_pdu_t *pusch_pdu,nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15, dci_pdu_rel15_t *dci_pdu_rel15, int *dci_formats, int *rnti_types); void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index 43635b965ed..8c2d66af47a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -47,7 +47,7 @@ extern RAN_CONTEXT_t RC; void mac_top_init_gNB(void) { - module_id_t i,j; + module_id_t i; int list_el; NR_UE_list_t *UE_list; gNB_MAC_INST *nrmac; @@ -113,4 +113,5 @@ void mac_top_init_gNB(void) UE_list->active[list_el] = FALSE; } + srand48(0); } diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c index 329727ba944..1163ffa29e3 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c @@ -107,21 +107,6 @@ void handle_nr_sr(NR_UL_IND_t *UL_info) { } void handle_nr_cqi(NR_UL_IND_t *UL_info) { - if (nfapi_mode == 1) { - if (UL_info->cqi_ind.number_of_cqis>0) { - LOG_D(PHY,"UL_info->cqi_ind.number_of_cqis:%d\n", UL_info->cqi_ind.number_of_cqis); - nfapi_cqi_indication_t ind; - ind.header.message_id = NFAPI_RX_CQI_INDICATION; - ind.sfn_sf = UL_info->frame<<4 | UL_info->slot; - ind.cqi_indication_body = UL_info->cqi_ind; - - // oai_nfapi_cqi_indication(&ind); - - UL_info->cqi_ind.number_of_cqis=0; - } - } - else - { /* for (int i=0;i<UL_info->cqi_ind.number_of_cqis;i++) @@ -135,7 +120,7 @@ void handle_nr_cqi(NR_UL_IND_t *UL_info) { &UL_info->cqi_ind.cqi_pdu_list[i].ul_cqi_information); */ UL_info->cqi_ind.number_of_cqis=0; - } + } void handle_nr_harq(NR_UL_IND_t *UL_info) { @@ -300,7 +285,7 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) { sched_info->UL_dci_req = &mac->UL_dci_req[CC_id]; if ((mac->common_channels[CC_id].ServingCellConfigCommon->tdd_UL_DL_ConfigurationCommon==NULL) || - (is_nr_UL_slot(&mac->common_channels[CC_id],(sched_info->slot+sf_ahead)%spf)>0)) + (is_nr_UL_slot(mac->common_channels[CC_id].ServingCellConfigCommon,(sched_info->slot+sf_ahead)%spf)>0)) sched_info->UL_tti_req = &mac->UL_tti_req[CC_id]; else sched_info->UL_tti_req = NULL; -- GitLab