From 826b7304e68623f0010218d16cb203dd65fa5077 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Fri, 7 Dec 2018 21:05:57 +0100 Subject: [PATCH 1/2] Revert "PBCH new format" This reverts commit a63c08d37c89dd96c6ec615bd162eb31cc32e413. --- openair1/PHY/NR_TRANSPORT/nr_pbch.c | 30 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c index be9fad4336..213e23cc45 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c @@ -183,15 +183,15 @@ void nr_pbch_scrambling(NR_gNB_PBCH *pbch, if (!encoded) { /// 1st Scrambling for (int i = 0; i < length; ++i) { - if ((unscrambling_mask>>(31-i))&1) - pbch->pbch_a_prime ^= ((pbch->pbch_a_interleaved>>(31-i))&1)<<(31-i); + if ((unscrambling_mask>>i)&1) + pbch->pbch_a_prime ^= ((pbch->pbch_a_interleaved>>i)&1)<pbch_a_prime ^= (((pbch->pbch_a_interleaved>>(31-i))&1) ^ ((s>>((k+offset)&0x1f))&1))<<(31-i); + pbch->pbch_a_prime ^= (((pbch->pbch_a_interleaved>>i)&1) ^ ((s>>((k+offset)&0x1f))&1))<pbch_a=0; for (int i=0; ipbch_a |= ((pbch_pdu[2-(i>>3)]>>(7-(i&7)))&1)<<(NR_PBCH_PDU_BITS-i-1); + pbch->pbch_a |= ((pbch_pdu[2-(i>>3)]>>(7-(i&7)))&1)<pbch_a |= ((sfn>>(3-i))&1)<<(7-i); // resp. 4th, 3rd, 2nd ans 1st lsb of sfn + pbch->pbch_a |= ((sfn>>(3-i))&1)<<(24+i); // resp. 4th, 3rd, 2nd ans 1st lsb of sfn - pbch->pbch_a |= n_hf<<3; // half frame index bit + pbch->pbch_a |= n_hf<<28; // half frame index bit if (Lmax == 64) for (int i=0; i<3; i++) - pbch->pbch_a |= ((ssb_index>>(5-i))&1)<<(2-i); // resp. 6th, 5th and 4th bits of ssb_index + pbch->pbch_a |= ((ssb_index>>(5-i))&1)<<(29+i); // resp. 6th, 5th and 4th bits of ssb_index else - pbch->pbch_a |= ((config->sch_config.ssb_subcarrier_offset.value>>4)&1)<<2; //MSB of k_SSB (bit index 4) + pbch->pbch_a |= ((config->sch_config.ssb_subcarrier_offset.value>>4)&1)<<29; //MSB of k_SSB (bit index 4) LOG_I(PHY,"After extra byte: pbch_a = 0x%08x\n",pbch->pbch_a); @@ -294,7 +294,7 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, #endif // Scrambling - unscrambling_mask = (Lmax ==64)? 0xB6000080:0x82000080; + unscrambling_mask = (Lmax ==64)? 0x100006D:0x1000041; M = (Lmax == 64)? (NR_POLAR_PBCH_PAYLOAD_BITS - 6) : (NR_POLAR_PBCH_PAYLOAD_BITS - 3); nushift = (((sfn>>2)&1)<<1) ^ ((sfn>>1)&1); pbch->pbch_a_prime = 0; From 173801704e3d2daec49dd438a1833333f00a4642 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Fri, 7 Dec 2018 14:30:48 +0100 Subject: [PATCH 2/2] Bit reversal. Working PBCH version --- openair1/PHY/NR_TRANSPORT/nr_pbch.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c index 213e23cc45..6d38814b75 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c @@ -226,6 +226,7 @@ void nr_init_pbch_interleaver(uint8_t *interleaver) { *(interleaver+i) = *(nr_pbch_payload_interleaving_pattern+j_hrf); else // Ssb bits:3 *(interleaver+i) = *(nr_pbch_payload_interleaving_pattern+j_ssb++); + } int nr_generate_pbch(NR_gNB_PBCH *pbch, @@ -250,6 +251,7 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, uint16_t M; uint8_t nushift; uint32_t unscrambling_mask; + uint64_t a_reversed=0; LOG_I(PHY, "PBCH generation started\n"); @@ -304,8 +306,14 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, printf("pbch_a_prime: 0x%08x\n", pbch->pbch_a_prime); #endif + + // Encoder reversal + for (int i=0; ipbch_a_prime>>i)&1)<<(31-i); + + /// CRC, coding and rate matching - polar_encoder_fast ((uint64_t*)&pbch->pbch_a_prime, (uint32_t*)pbch->pbch_e, 0, polar_params); + polar_encoder_fast (&a_reversed, (uint32_t*)pbch->pbch_e, 0, polar_params); #ifdef DEBUG_PBCH_ENCODING printf("Channel coding:\n"); for (int i=0; i