Commit 571239f6 authored by Laurent THOMAS's avatar Laurent THOMAS

code review comments (incl. actual bugs)

parent a17007bf
...@@ -45,14 +45,15 @@ ...@@ -45,14 +45,15 @@
//#include "PHY_INTERFACE/defs.h" //#include "PHY_INTERFACE/defs.h"
#define PBCH_A 24 #define PBCH_A 24
#define PBCH_MAX_RE_PER_SYMBOL (20*12)
#define PBCH_MAX_RE (PBCH_MAX_RE_PER_SYMBOL*4)
#define print_shorts(s,x) printf("%s : %d,%d,%d,%d,%d,%d,%d,%d\n",s,((int16_t*)x)[0],((int16_t*)x)[1],((int16_t*)x)[2],((int16_t*)x)[3],((int16_t*)x)[4],((int16_t*)x)[5],((int16_t*)x)[6],((int16_t*)x)[7]) #define print_shorts(s,x) printf("%s : %d,%d,%d,%d,%d,%d,%d,%d\n",s,((int16_t*)x)[0],((int16_t*)x)[1],((int16_t*)x)[2],((int16_t*)x)[3],((int16_t*)x)[4],((int16_t*)x)[5],((int16_t*)x)[6],((int16_t*)x)[7])
static uint16_t nr_pbch_extract(int **rxdataF, static uint16_t nr_pbch_extract(int **rxdataF,
const int estimateSz, const int estimateSz,
struct complex16 dl_ch_estimates[][estimateSz], struct complex16 dl_ch_estimates[][estimateSz],
struct complex16 rxdataF_ext[][20*12*4], struct complex16 rxdataF_ext[][PBCH_MAX_RE_PER_SYMBOL],
struct complex16 dl_ch_estimates_ext[][20*12*4], struct complex16 dl_ch_estimates_ext[][PBCH_MAX_RE_PER_SYMBOL],
uint32_t symbol, uint32_t symbol,
uint32_t s_offset, uint32_t s_offset,
NR_DL_FRAME_PARMS *frame_parms) { NR_DL_FRAME_PARMS *frame_parms) {
...@@ -90,12 +91,11 @@ static uint16_t nr_pbch_extract(int **rxdataF, ...@@ -90,12 +91,11 @@ static uint16_t nr_pbch_extract(int **rxdataF,
(i!=(nushiftmod4+8))) { (i!=(nushiftmod4+8))) {
rxF_ext[j]=rxF[rx_offset]; rxF_ext[j]=rxF[rx_offset];
#ifdef DEBUG_PBCH #ifdef DEBUG_PBCH
printf("rxF ext[%d] = (%d,%d) rxF [%u]= (%d,%d)\n",(9*rb) + j, printf("rxF ext[%d] = (%d,%d) rxF [%u]= (%d,%d)\n",
((int16_t *)&rxF_ext[j])[0], (9*rb) + j,
((int16_t *)&rxF_ext[j])[1], rxF_ext[j].r, rxF_ext[j].i,
rx_offset, rx_offset,
((int16_t *)&rxF[rx_offset])[0], rxF[rx_offset].r,rxF[rx_offset].j;
((int16_t *)&rxF[rx_offset])[1]);
#endif #endif
j++; j++;
} }
...@@ -114,11 +114,9 @@ static uint16_t nr_pbch_extract(int **rxdataF, ...@@ -114,11 +114,9 @@ static uint16_t nr_pbch_extract(int **rxdataF,
rxF_ext[j]=rxF[rx_offset]; rxF_ext[j]=rxF[rx_offset];
#ifdef DEBUG_PBCH #ifdef DEBUG_PBCH
printf("rxF ext[%d] = (%d,%d) rxF [%u]= (%d,%d)\n",(rb<4) ? (9*rb) + j : (9*(rb-12))+j, printf("rxF ext[%d] = (%d,%d) rxF [%u]= (%d,%d)\n",(rb<4) ? (9*rb) + j : (9*(rb-12))+j,
((int16_t *)&rxF_ext[j])[0], rxF_ext[j].r, rxF_ext[j].i,
((int16_t *)&rxF_ext[j])[1],
rx_offset, rx_offset,
((int16_t *)&rxF[rx_offset])[0], rxF[rx_offset].r,rxF[rx_offset].j;
((int16_t *)&rxF[rx_offset])[1]);
#endif #endif
j++; j++;
} }
...@@ -137,7 +135,7 @@ static uint16_t nr_pbch_extract(int **rxdataF, ...@@ -137,7 +135,7 @@ static uint16_t nr_pbch_extract(int **rxdataF,
struct complex16 *dl_ch0 = &dl_ch_estimates[aarx][((symbol+s_offset)*(frame_parms->ofdm_symbol_size))]; struct complex16 *dl_ch0 = &dl_ch_estimates[aarx][((symbol+s_offset)*(frame_parms->ofdm_symbol_size))];
//printf("dl_ch0 addr %p\n",dl_ch0); //printf("dl_ch0 addr %p\n",dl_ch0);
struct complex16 *dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol*20*12]; struct complex16 *dl_ch0_ext = dl_ch_estimates_ext[aarx];
for (rb=0; rb<20; rb++) { for (rb=0; rb<20; rb++) {
j=0; j=0;
...@@ -149,15 +147,11 @@ static uint16_t nr_pbch_extract(int **rxdataF, ...@@ -149,15 +147,11 @@ static uint16_t nr_pbch_extract(int **rxdataF,
(i!=(nushiftmod4+8))) { (i!=(nushiftmod4+8))) {
dl_ch0_ext[j]=dl_ch0[i]; dl_ch0_ext[j]=dl_ch0[i];
#ifdef DEBUG_PBCH #ifdef DEBUG_PBCH
if ((rb==0) && (i<2)) if ((rb==0) && (i<2))
printf("dl ch0 ext[%d] = (%d,%d) dl_ch0 [%d]= (%d,%d)\n",j, printf("dl ch0 ext[%d] = (%d,%d) dl_ch0 [%d]= (%d,%d)\n",j,
((int16_t *)&dl_ch0_ext[j])[0], dl_ch0_ext[j].r, dl_ch0_ext[j].i,
((int16_t *)&dl_ch0_ext[j])[1],
i, i,
((int16_t *)&dl_ch0[i])[0], dl_ch0[j].r, dl_ch0[j].i,
((int16_t *)&dl_ch0[i])[1]);
#endif #endif
j++; j++;
} }
...@@ -174,11 +168,9 @@ static uint16_t nr_pbch_extract(int **rxdataF, ...@@ -174,11 +168,9 @@ static uint16_t nr_pbch_extract(int **rxdataF,
dl_ch0_ext[j]=dl_ch0[i]; dl_ch0_ext[j]=dl_ch0[i];
#ifdef DEBUG_PBCH #ifdef DEBUG_PBCH
printf("dl ch0 ext[%d] = (%d,%d) dl_ch0 [%d]= (%d,%d)\n",j, printf("dl ch0 ext[%d] = (%d,%d) dl_ch0 [%d]= (%d,%d)\n",j,
((int16_t *)&dl_ch0_ext[j])[0], dl_ch0_ext[j].r, dl_ch0_ext[j].i,
((int16_t *)&dl_ch0_ext[j])[1],
i, i,
((int16_t *)&dl_ch0[i])[0], dl_ch0[j].r, dl_ch0[j].i,
((int16_t *)&dl_ch0[i])[1]);
#endif #endif
j++; j++;
} }
...@@ -198,11 +190,10 @@ static uint16_t nr_pbch_extract(int **rxdataF, ...@@ -198,11 +190,10 @@ static uint16_t nr_pbch_extract(int **rxdataF,
//__m128i avg128; //__m128i avg128;
//compute average channel_level on each (TX,RX) antenna pair //compute average channel_level on each (TX,RX) antenna pair
int nr_pbch_channel_level(struct complex16 dl_ch_estimates_ext[][20*12*4], int nr_pbch_channel_level(struct complex16 dl_ch_estimates_ext[][PBCH_MAX_RE_PER_SYMBOL],
NR_DL_FRAME_PARMS *frame_parms, NR_DL_FRAME_PARMS *frame_parms,
uint32_t symbol) { int nb_re) {
int16_t rb, nb_rb=20; int16_t nb_rb=nb_re/12;
uint8_t aarx;
#if defined(__x86_64__) || defined(__i386__) #if defined(__x86_64__) || defined(__i386__)
__m128i avg128; __m128i avg128;
__m128i *dl_ch128; __m128i *dl_ch128;
...@@ -212,22 +203,23 @@ int nr_pbch_channel_level(struct complex16 dl_ch_estimates_ext[][20*12*4], ...@@ -212,22 +203,23 @@ int nr_pbch_channel_level(struct complex16 dl_ch_estimates_ext[][20*12*4],
#endif #endif
int avg1=0,avg2=0; int avg1=0,avg2=0;
for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { for (int aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
//clear average level //clear average level
#if defined(__x86_64__) || defined(__i386__) #if defined(__x86_64__) || defined(__i386__)
avg128 = _mm_setzero_si128(); avg128 = _mm_setzero_si128();
dl_ch128=(__m128i *)&dl_ch_estimates_ext[aarx][symbol*20*12]; dl_ch128=(__m128i *)dl_ch_estimates_ext[aarx];
#elif defined(__arm__) #elif defined(__arm__)
avg128 = vdupq_n_s32(0); avg128 = vdupq_n_s32(0);
dl_ch128=(int16x8_t *)&dl_ch_estimates_ext[aarx][symbol*20*12]; dl_ch128=(int16x8_t *)dl_ch_estimates_ext[aarx];
#endif #endif
for (rb=0; rb<nb_rb; rb++) { for (int rb=0; rb<nb_rb; rb++) {
#if defined(__x86_64__) || defined(__i386__) #if defined(__x86_64__) || defined(__i386__)
avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[0],dl_ch128[0])); avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[0],dl_ch128[0]));
avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[1],dl_ch128[1])); avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[1],dl_ch128[1]));
avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[2],dl_ch128[2])); avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[2],dl_ch128[2]));
#elif defined(__arm__) #elif defined(__arm__)
abort();
// to be filled in // to be filled in
#endif #endif
dl_ch128+=3; dl_ch128+=3;
...@@ -250,37 +242,21 @@ int nr_pbch_channel_level(struct complex16 dl_ch_estimates_ext[][20*12*4], ...@@ -250,37 +242,21 @@ int nr_pbch_channel_level(struct complex16 dl_ch_estimates_ext[][20*12*4],
//LOG_I(PHY,"Channel level : %d, %d\n",avg1, avg2); //LOG_I(PHY,"Channel level : %d, %d\n",avg1, avg2);
} }
#if defined(__x86_64__) || defined(__i386__)
_mm_empty();
_m_empty();
#endif
return(avg2); return(avg2);
} }
static void nr_pbch_channel_compensation(struct complex16 rxdataF_ext[][20*12*4], static void nr_pbch_channel_compensation(struct complex16 rxdataF_ext[][PBCH_MAX_RE_PER_SYMBOL],
struct complex16 dl_ch_estimates_ext[][20*12*4], struct complex16 dl_ch_estimates_ext[][PBCH_MAX_RE_PER_SYMBOL],
int cols, int nb_re,
struct complex16 rxdataF_comp[][cols], struct complex16 rxdataF_comp[][PBCH_MAX_RE_PER_SYMBOL],
NR_DL_FRAME_PARMS *frame_parms, NR_DL_FRAME_PARMS *frame_parms,
uint32_t symbol, uint8_t output_shift) {
uint8_t output_shift) {
AssertFatal((symbol > 0 && symbol < 4),
"symbol %d is illegal for PBCH DM-RS\n",
symbol);
// printf("comp: symbol %d : nb_re %d\n",symbol,nb_re);
for (int aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { for (int aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
vect128 *dl_ch128 = (vect128 *)&dl_ch_estimates_ext[aarx][symbol*20*12]; vect128 *dl_ch128 = (vect128 *)dl_ch_estimates_ext[aarx];
vect128 *rxdataF128 = (vect128 *)rxdataF_ext[aarx]; vect128 *rxdataF128 = (vect128 *)rxdataF_ext[aarx];
vect128 *rxdataF_comp128 = (vect128 *)rxdataF_comp[aarx]; vect128 *rxdataF_comp128 = (vect128 *)rxdataF_comp[aarx];
/*
printf("ch compensation dl_ch ext addr %p \n", &dl_ch_estimates_ext[aarx][symbol*20*12]);
printf("rxdataf ext addr %p symbol %d\n", rxdataF_ext[aarx], symbol);
printf("rxdataf_comp addr %p\n",&rxdataF_comp[aarx][symbol*20*12]);
*/
for (int re=0; re<cols; re+=12) { for (int re=0; re<nb_re; re+=12) {
*rxdataF_comp128++ = mulByConjugate128(rxdataF128++, dl_ch128++, output_shift); *rxdataF_comp128++ = mulByConjugate128(rxdataF128++, dl_ch128++, output_shift);
*rxdataF_comp128++ = mulByConjugate128(rxdataF128++, dl_ch128++, output_shift); *rxdataF_comp128++ = mulByConjugate128(rxdataF128++, dl_ch128++, output_shift);
*rxdataF_comp128++ = mulByConjugate128(rxdataF128++, dl_ch128++, output_shift); *rxdataF_comp128++ = mulByConjugate128(rxdataF128++, dl_ch128++, output_shift);
...@@ -453,10 +429,8 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -453,10 +429,8 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
for (symbol=1; symbol<4; symbol++) { for (symbol=1; symbol<4; symbol++) {
const uint16_t nb_re=symbol == 2 ? 72 : 180; const uint16_t nb_re=symbol == 2 ? 72 : 180;
struct complex16 rxdataF_ext[frame_parms->nb_antennas_rx][20*12*4]; struct complex16 rxdataF_ext[frame_parms->nb_antennas_rx][PBCH_MAX_RE_PER_SYMBOL];
struct complex16 rxdataF_comp[frame_parms->nb_antennas_rx][nb_re]; struct complex16 dl_ch_estimates_ext[frame_parms->nb_antennas_rx][PBCH_MAX_RE_PER_SYMBOL];
//was dl_ch_estimates[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*7*2*sizeof(int)*(fp->ofdm_symbol_size) );
struct complex16 dl_ch_estimates_ext[frame_parms->nb_antennas_rx][20*12*4];
memset(dl_ch_estimates_ext,0, sizeof dl_ch_estimates_ext); memset(dl_ch_estimates_ext,0, sizeof dl_ch_estimates_ext);
nr_pbch_extract(nr_ue_common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF, nr_pbch_extract(nr_ue_common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF,
estimateSz, estimateSz,
...@@ -474,20 +448,20 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -474,20 +448,20 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
if (symbol == 1) { if (symbol == 1) {
max_h = nr_pbch_channel_level(dl_ch_estimates_ext, max_h = nr_pbch_channel_level(dl_ch_estimates_ext,
frame_parms, frame_parms,
symbol); nb_re);
log2_maxh = 3+(log2_approx(max_h)/2); log2_maxh = 3+(log2_approx(max_h)/2);
} }
#ifdef DEBUG_PBCH #ifdef DEBUG_PBCH
LOG_I(PHY,"[PHY] PBCH log2_maxh = %d (%d)\n",nr_ue_pbch_vars->log2_maxh,max_h); LOG_I(PHY,"[PHY] PBCH log2_maxh = %d (%d)\n",nr_ue_pbch_vars->log2_maxh,max_h);
#endif #endif
struct complex16 rxdataF_comp[frame_parms->nb_antennas_rx][PBCH_MAX_RE_PER_SYMBOL];
nr_pbch_channel_compensation(rxdataF_ext, nr_pbch_channel_compensation(rxdataF_ext,
dl_ch_estimates_ext, dl_ch_estimates_ext,
nb_re, nb_re,
rxdataF_comp, rxdataF_comp,
frame_parms, frame_parms,
symbol, log2_maxh); // log2_maxh+I0_shift
log2_maxh); // log2_maxh+I0_shift
/*if (frame_parms->nb_antennas_rx > 1) /*if (frame_parms->nb_antennas_rx > 1)
pbch_detection_mrc(frame_parms, pbch_detection_mrc(frame_parms,
...@@ -502,19 +476,12 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -502,19 +476,12 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
return(-1); return(-1);
} }
*/ */
if (symbol==2) { int nb=symbol==2 ? 144 : 360;
nr_pbch_quantize(pbch_e_rx+pbch_e_rx_idx, nr_pbch_quantize(pbch_e_rx+pbch_e_rx_idx,
(short *)rxdataF_comp[0], (short *)rxdataF_comp[0],
144); nb);
memcpy(pbch_unClipped+pbch_e_rx_idx, rxdataF_comp[0], 144*sizeof(int16_t)); memcpy(pbch_unClipped+pbch_e_rx_idx, rxdataF_comp[0], nb*sizeof(int16_t));
pbch_e_rx_idx+=144; pbch_e_rx_idx+=nb;
} else {
nr_pbch_quantize(pbch_e_rx+pbch_e_rx_idx,
(short *)rxdataF_comp[0],
360);
memcpy(pbch_unClipped+pbch_e_rx_idx, rxdataF_comp[0], 144*sizeof(int16_t));
pbch_e_rx_idx+=360;
}
} }
// legacy code use int16, but it is complex16 // legacy code use int16, but it is complex16
...@@ -522,15 +489,11 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -522,15 +489,11 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
UEscopeCopy(ue, pbchLlr, pbch_e_rx, sizeof(int16_t), frame_parms->nb_antennas_rx, pbch_e_rx_idx); UEscopeCopy(ue, pbchLlr, pbch_e_rx, sizeof(int16_t), frame_parms->nb_antennas_rx, pbch_e_rx_idx);
#ifdef DEBUG_PBCH #ifdef DEBUG_PBCH
write_output("rxdataF_comp.m","rxFcomp",rxdataF_comp[0],240*3,1,1); write_output("rxdataF_comp.m","rxFcomp",rxdataF_comp[0],240*3,1,1);
#endif
//demod_pbch_e = nr_ue_pbch_vars->demod_pbch_e;
// FT?? cppcheck fix - pbch_a = nr_ue_pbch_vars->pbch_a;
#ifdef DEBUG_PBCH
short *p = (short *)rxdataF_comp[0]); short *p = (short *)rxdataF_comp[0]);
for (int cnt = 0; cnt < 864 ; cnt++) for (int cnt = 0; cnt < 864 ; cnt++)
printf("pbch rx llr %d\n",*(pbch_e_rx+cnt)); printf("pbch rx llr %d\n",*(pbch_e_rx+cnt));
#endif #endif
//un-scrambling //un-scrambling
M = NR_POLAR_PBCH_E; M = NR_POLAR_PBCH_E;
...@@ -538,34 +501,39 @@ printf("pbch rx llr %d\n",*(pbch_e_rx+cnt)); ...@@ -538,34 +501,39 @@ printf("pbch rx llr %d\n",*(pbch_e_rx+cnt));
uint32_t unscrambling_mask = (Lmax==64)?0x100006D:0x1000041; uint32_t unscrambling_mask = (Lmax==64)?0x100006D:0x1000041;
uint32_t pbch_a_interleaved=0; uint32_t pbch_a_interleaved=0;
uint32_t pbch_a_prime=0; uint32_t pbch_a_prime=0;
nr_pbch_unscrambling(nr_ue_pbch_vars,pbch_e_rx,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_E,0,0, pbch_a_prime, &pbch_a_interleaved); nr_pbch_unscrambling(nr_ue_pbch_vars, pbch_e_rx, frame_parms->Nid_cell, nushift, M, NR_POLAR_PBCH_E,
0, 0, pbch_a_prime, &pbch_a_interleaved);
//polar decoding de-rate matching //polar decoding de-rate matching
const t_nrPolar_params *currentPtr = nr_polar_params( NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL,1,&ue->polarList); const t_nrPolar_params *currentPtr = nr_polar_params( NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS,
uint64_t tmp=pbch_a_prime; NR_POLAR_PBCH_AGGREGATION_LEVEL,1,&ue->polarList);
decoderState = polar_decoder_int16(pbch_e_rx,&tmp,0,currentPtr); uint64_t tmp=pbch_a_prime;
pbch_a_prime=tmp; decoderState = polar_decoder_int16(pbch_e_rx,&tmp,0,currentPtr);
pbch_a_prime=tmp;
if(decoderState) return(decoderState); if(decoderState)
return(decoderState);
// printf("polar decoder output 0x%08x\n",pbch_a_prime); // printf("polar decoder output 0x%08x\n",pbch_a_prime);
// Decoder reversal // Decoder reversal
uint32_t a_reversed=0; uint32_t a_reversed=0;
for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS; i++) for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS; i++)
a_reversed |= (((uint64_t)pbch_a_prime>>i)&1)<<(31-i); a_reversed |= (((uint64_t)pbch_a_prime>>i)&1)<<(31-i);
pbch_a_prime = a_reversed; pbch_a_prime = a_reversed;
//payload un-scrambling //payload un-scrambling
M = (Lmax == 64)? (NR_POLAR_PBCH_PAYLOAD_BITS - 6) : (NR_POLAR_PBCH_PAYLOAD_BITS - 3); M = (Lmax == 64)? (NR_POLAR_PBCH_PAYLOAD_BITS - 6) : (NR_POLAR_PBCH_PAYLOAD_BITS - 3);
nushift = ((pbch_a_prime>>24)&1) ^ (((pbch_a_prime>>6)&1)<<1); nushift = ((pbch_a_prime>>24)&1) ^ (((pbch_a_prime>>6)&1)<<1);
nr_pbch_unscrambling(nr_ue_pbch_vars,pbch_e_rx,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_PAYLOAD_BITS,1,unscrambling_mask,pbch_a_prime, &pbch_a_interleaved); pbch_a_interleaved=0;
nr_pbch_unscrambling(nr_ue_pbch_vars, pbch_e_rx, frame_parms->Nid_cell, nushift, M, NR_POLAR_PBCH_PAYLOAD_BITS,
1, unscrambling_mask, pbch_a_prime, &pbch_a_interleaved);
//printf("nushift %d sfn 3rd %d 2nd %d", nushift,((pbch_a_prime>>6)&1), ((pbch_a_prime>>24)&1) ); //printf("nushift %d sfn 3rd %d 2nd %d", nushift,((pbch_a_prime>>6)&1), ((pbch_a_prime>>24)&1) );
//payload deinterleaving //payload deinterleaving
//uint32_t in=0; //uint32_t in=0;
uint32_t out=0; uint32_t out=0;
for (int i=0; i<32; i++) { for (int i=0; i<32; i++) {
out |= ((pbch_a_interleaved>>i)&1)<<(pbch_deinterleaving_pattern[i]); out |= ((pbch_a_interleaved>>i)&1)<<(pbch_deinterleaving_pattern[i]);
#ifdef DEBUG_PBCH #ifdef DEBUG_PBCH
printf("i %d in 0x%08x out 0x%08x ilv %d (in>>i)&1) 0x%08x\n", i, pbch_a_interleaved, out, pbch_deinterleaving_pattern[i], (pbch_a_interleaved>>i)&1); printf("i %d in 0x%08x out 0x%08x ilv %d (in>>i)&1) 0x%08x\n", i, pbch_a_interleaved, out, pbch_deinterleaving_pattern[i], (pbch_a_interleaved>>i)&1);
#endif #endif
...@@ -575,16 +543,16 @@ a_reversed |= (((uint64_t)pbch_a_prime>>i)&1)<<(31-i); ...@@ -575,16 +543,16 @@ a_reversed |= (((uint64_t)pbch_a_prime>>i)&1)<<(31-i);
result->xtra_byte = (out>>24)&0xff; result->xtra_byte = (out>>24)&0xff;
for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS; i++) for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS; i++)
payload |= ((out>>i)&1)<<(NR_POLAR_PBCH_PAYLOAD_BITS-i-1); payload |= ((out>>i)&1)<<(NR_POLAR_PBCH_PAYLOAD_BITS-i-1);
for (int i=0; i<3; i++) for (int i=0; i<3; i++)
result->decoded_output[i] = (uint8_t)((payload>>((3-i)<<3))&0xff); result->decoded_output[i] = (uint8_t)((payload>>((3-i)<<3))&0xff);
frame_parms->half_frame_bit = (result->xtra_byte>>4)&0x01; // computing the half frame index from the extra byte frame_parms->half_frame_bit = (result->xtra_byte>>4)&0x01; // computing the half frame index from the extra byte
frame_parms->ssb_index = i_ssb; // ssb index corresponds to i_ssb for Lmax = 4,8 frame_parms->ssb_index = i_ssb; // ssb index corresponds to i_ssb for Lmax = 4,8
if (Lmax == 64) { // for Lmax = 64 ssb index 4th,5th and 6th bits are in extra byte if (Lmax == 64) { // for Lmax = 64 ssb index 4th,5th and 6th bits are in extra byte
for (int i=0; i<3; i++) for (int i=0; i<3; i++)
frame_parms->ssb_index += (((result->xtra_byte>>(7-i))&0x01)<<(3+i)); frame_parms->ssb_index += (((result->xtra_byte>>(7-i))&0x01)<<(3+i));
} }
...@@ -596,8 +564,8 @@ result->decoded_output[i] = (uint8_t)((payload>>((3-i)<<3))&0xff); ...@@ -596,8 +564,8 @@ result->decoded_output[i] = (uint8_t)((payload>>((3-i)<<3))&0xff);
uint8_t frame_number_4lsb = 0; uint8_t frame_number_4lsb = 0;
for (int i=0; i<4; i++) for (int i=0; i<4; i++)
frame_number_4lsb |= ((result->xtra_byte>>i)&1)<<(3-i); frame_number_4lsb |= ((result->xtra_byte>>i)&1)<<(3-i);
proc->decoded_frame_rx = frame_number_4lsb; proc->decoded_frame_rx = frame_number_4lsb;
#ifdef DEBUG_PBCH #ifdef DEBUG_PBCH
printf("xtra_byte %x payload %x\n", xtra_byte, payload); printf("xtra_byte %x payload %x\n", xtra_byte, payload);
......
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