From aed7cdf158dbe5766e68a0864ebba0deb91f7b9e Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Wed, 4 Jul 2018 16:04:59 +0200 Subject: [PATCH] PBCH scrambling fix --- openair1/PHY/NR_TRANSPORT/nr_pbch.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c index fd07a4c2de..24f9234e75 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c @@ -136,7 +136,7 @@ void nr_pbch_scrambling(uint32_t Nid, uint8_t *pbch_a, uint32_t length) { - uint8_t reset; + uint8_t reset, offset; uint32_t x1, x2, s=0; uint64_t tmp=0; uint8_t M = length - 3; // case Lmax = 4--> 29 @@ -146,22 +146,18 @@ void nr_pbch_scrambling(uint32_t Nid, x2 = Nid; // The Gold sequence is shifted by nushift* M, so we skip (nushift*M /32) double words - for (int i=0; i<(nushift*M)>>5; i++) { + for (int i=0; i<(uint16_t)ceil((nushift*M)/5); i++) { s = lte_gold_generic(&x1, &x2, reset); reset = 0; } - tmp = (uint64_t)s; - s = lte_gold_generic(&x1, &x2, reset); - tmp^=(uint64_t)(s<<32); - tmp>>=((nushift*M)&0x1f); - s = (uint32_t)(tmp); + offset = (nushift*M)&0x1f; for (int i=0; i>(i&0x1f))&1); + pbch_a[i] = (pbch_a[i]&1) ^ ((s>>((i+offset)&0x1f))&1); } }