From 5e7ce26c10843427f8a78690fb81ced3d3677965 Mon Sep 17 00:00:00 2001 From: Sakthi Date: Mon, 10 Aug 2020 19:14:14 +0200 Subject: [PATCH] more additions --- openair1/PHY/MODULATION/nr_modulation.c | 4 +--- openair1/PHY/NR_REFSIG/nr_gen_mod_table.c | 29 ++++++++++++++++------- openair1/PHY/NR_REFSIG/nr_mod_table.h | 5 +++- openair1/PHY/NR_TRANSPORT/nr_pbch.c | 10 ++++---- 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/openair1/PHY/MODULATION/nr_modulation.c b/openair1/PHY/MODULATION/nr_modulation.c index dc3934ffca..8905dcca38 100644 --- a/openair1/PHY/MODULATION/nr_modulation.c +++ b/openair1/PHY/MODULATION/nr_modulation.c @@ -22,8 +22,6 @@ #include "nr_modulation.h" #include "PHY/NR_REFSIG/nr_mod_table.h" -extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT]; - void nr_modulation(uint32_t *in, uint32_t length, uint16_t mod_order, @@ -114,7 +112,7 @@ void nr_modulation(uint32_t *in, return; case 8: - nr_mod_table32 = (int32_t*) nr_mod_table; + nr_mod_table32 = (int32_t*) nr_256qam_mod_table; for (i=0; i>(j*2))&1))*val*sqrt2*sqrt2; - nr_qpsk_byte_mod_table[i*8+(j*2)+1] = (short)(1-2*((i>>(j*2+1))&1))*val*sqrt2*sqrt2; - //printf("%d j%d\n",nr_qpsk_byte_mod_table[i*8+(j*2)],nr_qpsk_byte_mod_table[i*8+(j*2)+1]); - } - } +short nr_qpsk_mod_table[8] = {16384,16384,-16384,16384,16384,-16384,-16384,-16384}; +#if defined(__AVX2__) //QPSK m256 table = (short*) nr_qpsk_2byte_mod_table; for (i=0; i<65536; i++) { @@ -50,6 +44,18 @@ void nr_generate_modulation_table() { //printf("%d j%d\n",nr_qpsk_byte_mod_table[i*8+(j*2)],nr_qpsk_byte_mod_table[i*8+(j*2)+1]); } } +#elif defined(__SSE2__) + + //QPSK m128 + table = (short*) nr_qpsk_byte_mod_table; + for (i=0; i<256; i++) { + for (j=0; j<4; j++) { + table[i*8+(j*2)] = (short)(1-2*((i>>(j*2))&1))*val*sqrt2*sqrt2; + table[i*8+(j*2)+1] = (short)(1-2*((i>>(j*2+1))&1))*val*sqrt2*sqrt2; + //printf("%d j%d\n",nr_qpsk_byte_mod_table[i*8+(j*2)],nr_qpsk_byte_mod_table[i*8+(j*2)+1]); + } + } +#endif //16QAM for (i=0; i<256; i++) { @@ -69,5 +75,12 @@ void nr_generate_modulation_table() { //printf("%d j%d\n",table[i*4+(j*2)],table[i*4+(j*2)+1]); } } + + //256QAM + table = (short*) nr_256qam_mod_table; + for (i=0; i<256; i++) { + table[i*2] = (short)((1-2*(i&1))*(8-(1-2*((i>>2)&1))*(4-(1-2*((i>>4)&1))*(2-(1-2*((i>>6)&1))))))*val*sqrt170*sqrt2; + table[i*2+1] = (short)((1-2*((i>>1)&1))*(8-(1-2*((i>>3)&1))*(4-(1-2*((i>>5)&1))*(2-(1-2*((i>>7)&1))))))*val*sqrt170*sqrt2; + } } diff --git a/openair1/PHY/NR_REFSIG/nr_mod_table.h b/openair1/PHY/NR_REFSIG/nr_mod_table.h index d42f211e8e..4722ad7b7a 100644 --- a/openair1/PHY/NR_REFSIG/nr_mod_table.h +++ b/openair1/PHY/NR_REFSIG/nr_mod_table.h @@ -28,7 +28,8 @@ #define NR_MOD_TABLE_QAM16_OFFSET 7 #define NR_MOD_TABLE_QAM64_OFFSET 23 #define NR_MOD_TABLE_QAM256_OFFSET 87 -short nr_qpsk_mod_table[8] = {16384,16384,-16384,16384,16384,-16384,-16384,-16384}; + +short nr_qpsk_mod_table[8]; #if defined(__AVX2__) __m256i nr_qpsk_2byte_mod_table[65536]; @@ -39,4 +40,6 @@ __m128i nr_qpsk_byte_mod_table[2048]; int64_t nr_16qam_byte_mod_table[1024]; int64_t nr_64qam_mod_table[4096]; + +int32_t nr_256qam_mod_table[512]; #endif diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c index bc33d93811..13dd65d90e 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c @@ -40,7 +40,7 @@ //#define DEBUG_PBCH_ENCODING //#define DEBUG_PBCH_DMRS -extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT]; +extern short nr_qpsk_mod_table[8]; 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 @@ -62,8 +62,8 @@ int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs, /// QPSK modulation for (int m=0; m>5])>>((m<<1)&0x1f))&1)<<1) ^ (((gold_pbch_dmrs[((m<<1)+1)>>5])>>(((m<<1)+1)&0x1f))&1); - mod_dmrs[m<<1] = nr_mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; - mod_dmrs[(m<<1)+1] = nr_mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1]; + mod_dmrs[m<<1] = nr_qpsk_mod_table[idx<<1]; + mod_dmrs[(m<<1)+1] = nr_qpsk_mod_table[(idx<<1) + 1]; #ifdef DEBUG_PBCH_DMRS printf("m %d idx %d gold seq %d b0-b1 %d-%d mod_dmrs %d %d\n", m, idx, gold_pbch_dmrs[(m<<1)>>5], (((gold_pbch_dmrs[(m<<1)>>5])>>((m<<1)&0x1f))&1), (((gold_pbch_dmrs[((m<<1)+1)>>5])>>(((m<<1)+1)&0x1f))&1), mod_dmrs[(m<<1)], mod_dmrs[(m<<1)+1]); @@ -324,8 +324,8 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, /// QPSK modulation for (int i=0; i>1; i++) { idx = (((pbch->pbch_e[(i<<1)>>5]>>((i<<1)&0x1f))&1)<<1) ^ ((pbch->pbch_e[((i<<1)+1)>>5]>>(((i<<1)+1)&0x1f))&1); - mod_pbch_e[i<<1] = nr_mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; - mod_pbch_e[(i<<1)+1] = nr_mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1)+1]; + mod_pbch_e[i<<1] = nr_qpsk_mod_table[idx<<1]; + mod_pbch_e[(i<<1)+1] = nr_qpsk_mod_table[(idx<<1)+1]; #ifdef DEBUG_PBCH printf("i %d idx %d mod_pbch %d %d\n", i, idx, mod_pbch_e[2*i], mod_pbch_e[2*i+1]); #endif