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

MIB interleaving correction

parent 80e0c46b
...@@ -143,6 +143,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, ...@@ -143,6 +143,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
} }
nr_init_pdcch_dmrs(gNB, cfg->sch_config.physical_cell_id.value); nr_init_pdcch_dmrs(gNB, cfg->sch_config.physical_cell_id.value);
nr_init_pbch_interleaver(gNB->nr_pbch_interleaver);
/* /*
lte_gold(fp,gNB->lte_gold_table,fp->Nid_cell); lte_gold(fp,gNB->lte_gold_table,fp->Nid_cell);
......
...@@ -39,9 +39,11 @@ ...@@ -39,9 +39,11 @@
//#define DEBUG_PBCH_ENCODING //#define DEBUG_PBCH_ENCODING
//#define DEBUG_PBCH_DMRS //#define DEBUG_PBCH_DMRS
//extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT];
#include "PHY/NR_REFSIG/nr_mod_table.h" #include "PHY/NR_REFSIG/nr_mod_table.h"
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};
int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs, int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs,
int32_t **txdataF, int32_t **txdataF,
int16_t amp, int16_t amp,
...@@ -163,7 +165,7 @@ void nr_pbch_scrambling(NR_gNB_PBCH *pbch, ...@@ -163,7 +165,7 @@ void nr_pbch_scrambling(NR_gNB_PBCH *pbch,
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<(uint16_t)ceil(((float)nushift*M)/32); i++) { for (int i=0; i<(uint16_t)ceil(((float)nushift*M)/32); i++) {
s = lte_gold_generic(&x1, &x2, reset); s = lte_gold_generic(&x1, &x2, reset);
reset = 0; reset = 0;
} }
// Scrambling is now done with offset (nushift*M)%32 // Scrambling is now done with offset (nushift*M)%32
...@@ -188,21 +190,19 @@ s = lte_gold_generic(&x1, &x2, reset); ...@@ -188,21 +190,19 @@ s = lte_gold_generic(&x1, &x2, reset);
} }
} }
// This portion of code is temporarily kept until the optimized version is validated uint8_t nr_pbch_init_interleaver(uint8_t *interleaver) {
uint8_t nr_pbch_payload_interleaving_pattern[32] = {16, 23, 18, 17, 8, 30, 10, 6, 24, 7, 0, 5, 3, 2, 1, 4, uint8_t j_sfn=0, j_hrf=10, j_ssb=11, j_other=14;
9, 11, 12, 13, 14, 15, 19, 20, 21, 22, 25, 26, 27, 28, 29, 31}; memset((void*)interleaver,0, NR_POLAR_PBCH_PAYLOAD_BITS);
uint8_t nr_pbch_payload_interleaver(uint8_t i) { for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS; i++)
uint8_t j_sfn=6, j_hrf=10, j_ssb=11, j_other=14; if ((i<6)||(23<i && i<28)) //Sfn bits
*(interleaver+j_sfn++) = *(nr_pbch_payload_interleaving_pattern+i);
if (24<=i && i<=27) //Sfn bits else if (i==28) // Hrf bit
return nr_pbch_payload_interleaving_pattern[j_sfn + i -24]; *(interleaver+j_hrf) = *(nr_pbch_payload_interleaving_pattern+i);
else if (i==28) // Hrf bit else if (i>28) // Ssb bits
return nr_pbch_payload_interleaving_pattern[j_hrf]; *(interleaver+j_ssb) = *(nr_pbch_payload_interleaving_pattern+i);
else if (29<=i) // Ssb bits else
return nr_pbch_payload_interleaving_pattern[j_ssb + (i-29)]; *(interleaver+j_other) = *(nr_pbch_payload_interleaving_pattern+i);
else
return nr_pbch_payload_interleaving_pattern[(j_other + i)&0x1f];
} }
/*This pattern takes into account the adjustments for the field specific counters j_sfn, j_hrf, j_ssb and j_other*/ /*This pattern takes into account the adjustments for the field specific counters j_sfn, j_hrf, j_ssb and j_other*/
...@@ -212,6 +212,7 @@ uint8_t nr_pbch_payload_interleaver(uint8_t i) { ...@@ -212,6 +212,7 @@ uint8_t nr_pbch_payload_interleaver(uint8_t i) {
int nr_generate_pbch(NR_gNB_PBCH *pbch, int nr_generate_pbch(NR_gNB_PBCH *pbch,
t_nrPolar_paramsPtr polar_params, t_nrPolar_paramsPtr polar_params,
uint8_t *pbch_pdu, uint8_t *pbch_pdu,
uint8_t *interleaver,
int32_t **txdataF, int32_t **txdataF,
int16_t amp, int16_t amp,
uint8_t ssb_start_symbol, uint8_t ssb_start_symbol,
...@@ -269,10 +270,10 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, ...@@ -269,10 +270,10 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch,
for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS>>3; i++) for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS>>3; i++)
in |= (uint32_t)(pbch->pbch_a[i]<<((3-i)<<3)); in |= (uint32_t)(pbch->pbch_a[i]<<((3-i)<<3));
for (int i=0; i<32; i++) { for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS; i++) {
pbch->pbch_a_interleaved |= ((in>>i)&1)<<(nr_pbch_payload_interleaver(i));//nr_pbch_payload_interleaving_pattern[i] pbch->pbch_a_interleaved |= ((in>>i)&1)<<(*(interleaver+i));
#ifdef DEBUG_PBCH_ENCODING #ifdef DEBUG_PBCH_ENCODING
printf("i %d in 0x%08x out 0x%08x ilv %d (in>>i)&1) %d\n", i, in, pbch->pbch_a_interleaved, nr_pbch_payload_interleaver(i), (in>>i)&1); printf("i %d in 0x%08x out 0x%08x ilv %d (in>>i)&1) %d\n", i, in, pbch->pbch_a_interleaved, *(interleaver+i), (in>>i)&1);
#endif #endif
} }
......
...@@ -86,6 +86,7 @@ void nr_pbch_scrambling(NR_gNB_PBCH *pbch, ...@@ -86,6 +86,7 @@ void nr_pbch_scrambling(NR_gNB_PBCH *pbch,
int nr_generate_pbch(NR_gNB_PBCH *pbch, int nr_generate_pbch(NR_gNB_PBCH *pbch,
t_nrPolar_paramsPtr polar_params, t_nrPolar_paramsPtr polar_params,
uint8_t *pbch_pdu, uint8_t *pbch_pdu,
uint8_t *interleaver,
int32_t **txdataF, int32_t **txdataF,
int16_t amp, int16_t amp,
uint8_t ssb_start_symbol, uint8_t ssb_start_symbol,
......
...@@ -315,6 +315,9 @@ typedef struct PHY_VARS_gNB_s { ...@@ -315,6 +315,9 @@ typedef struct PHY_VARS_gNB_s {
/// PBCH DMRS sequence /// PBCH DMRS sequence
uint32_t nr_gold_pbch_dmrs[2][64][NR_PBCH_DMRS_LENGTH_DWORD]; uint32_t nr_gold_pbch_dmrs[2][64][NR_PBCH_DMRS_LENGTH_DWORD];
/// PBCH interleaver
uint8_t nr_pbch_interleaver[NR_POLAR_PBCH_PAYLOAD_BITS];
/// PDCCH DMRS sequence /// PDCCH DMRS sequence
uint32_t ***nr_gold_pdcch_dmrs; uint32_t ***nr_gold_pdcch_dmrs;
......
...@@ -146,7 +146,15 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int subframe) { ...@@ -146,7 +146,15 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int subframe) {
gNB->pbch_configured = 0; gNB->pbch_configured = 0;
} }
nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[n_hf][ssb_index],txdataF, AMP_OVER_2, ssb_start_symbol, cfg, fp); nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[n_hf][ssb_index],txdataF, AMP_OVER_2, ssb_start_symbol, cfg, fp);
nr_generate_pbch(&gNB->pbch, gNB->nrPolar_params, pbch_pdu, txdataF, AMP_OVER_2, ssb_start_symbol, n_hf, Lmax, ssb_index, frame, cfg, fp); nr_generate_pbch(&gNB->pbch,
gNB->nrPolar_params,
pbch_pdu,
gNB->nr_pbch_interleaver,
txdataF,
AMP_OVER_2,
ssb_start_symbol,
n_hf,Lmax,ssb_index,
frame, cfg, fp);
} }
} }
......
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