Commit aed7cdf1 authored by Guy De Souza's avatar Guy De Souza

PBCH scrambling fix

parent eba95e3f
...@@ -136,7 +136,7 @@ void nr_pbch_scrambling(uint32_t Nid, ...@@ -136,7 +136,7 @@ void nr_pbch_scrambling(uint32_t Nid,
uint8_t *pbch_a, uint8_t *pbch_a,
uint32_t length) uint32_t length)
{ {
uint8_t reset; uint8_t reset, offset;
uint32_t x1, x2, s=0; uint32_t x1, x2, s=0;
uint64_t tmp=0; uint64_t tmp=0;
uint8_t M = length - 3; // case Lmax = 4--> 29 uint8_t M = length - 3; // case Lmax = 4--> 29
...@@ -146,22 +146,18 @@ void nr_pbch_scrambling(uint32_t Nid, ...@@ -146,22 +146,18 @@ void nr_pbch_scrambling(uint32_t Nid,
x2 = Nid; x2 = Nid;
// The Gold sequence is shifted by nushift* M, so we skip (nushift*M /32) double words // 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); s = lte_gold_generic(&x1, &x2, reset);
reset = 0; reset = 0;
} }
tmp = (uint64_t)s; offset = (nushift*M)&0x1f;
s = lte_gold_generic(&x1, &x2, reset);
tmp^=(uint64_t)(s<<32);
tmp>>=((nushift*M)&0x1f);
s = (uint32_t)(tmp);
for (int i=0; i<length; i++) { for (int i=0; i<length; i++) {
if ((i&0x1f)==0) { if (((i+offset)&0x1f)==0) {
s = lte_gold_generic(&x1, &x2, reset); s = lte_gold_generic(&x1, &x2, reset);
reset = 0; reset = 0;
} }
pbch_a[i] = (pbch_a[i]&1) ^ ((s>>(i&0x1f))&1); pbch_a[i] = (pbch_a[i]&1) ^ ((s>>((i+offset)&0x1f))&1);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment