From ea20869372ae666ef5c60b20525d4add9d75648e Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Wed, 19 Jun 2019 22:15:56 +0200 Subject: [PATCH] fixing nr_pbchsim --- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 14 +++++++------- openair1/PHY/defs_nr_UE.h | 2 ++ openair1/SIMULATION/NR_PHY/pbchsim.c | 7 +++---- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 1854277150..641b27b081 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -566,8 +566,8 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, } uint32_t payload = 0; - uint8_t xtra_byte = 0; - xtra_byte = (out>>24)&0xff; + //uint8_t xtra_byte = 0; + nr_ue_pbch_vars->xtra_byte = (out>>24)&0xff; for (int i=0; i>i)&1)<<(NR_POLAR_PBCH_PAYLOAD_BITS-i-1); @@ -575,18 +575,18 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, for (int i=0; i<3; i++) decoded_output[i] = (uint8_t)((payload>>((3-i)<<3))&0xff); - n_hf = ((xtra_byte>>4)&0x01); // computing the half frame index from the extra byte + n_hf = ((nr_ue_pbch_vars->xtra_byte>>4)&0x01); // computing the half frame index from the extra byte 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 for (int i=0; i<3; i++) - ssb_index += (((xtra_byte>>(7-i))&0x01)<<(3+i)); + ssb_index += (((nr_ue_pbch_vars->xtra_byte>>(7-i))&0x01)<<(3+i)); } ue->symbol_offset = nr_get_ssb_start_symbol(frame_parms, ssb_index, n_hf); #ifdef DEBUG_PBCH - printf("xtra_byte %x payload %x\n", xtra_byte, payload); + printf("xtra_byte %x payload %x\n", nr_ue_pbch_vars->xtra_byte, payload); for (int i=0; i<(NR_POLAR_PBCH_PAYLOAD_BITS>>3); i++) { // printf("unscrambling pbch_a[%d] = %x \n", i,pbch_a[i]); @@ -604,8 +604,8 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, dl_indication.cc_id=proc->CC_id; rx_ind.rx_indication_body[0].pdu_type = FAPI_NR_RX_PDU_TYPE_MIB; - rx_ind.rx_indication_body[0].mib_pdu.pdu = &decoded_output[0]; - rx_ind.rx_indication_body[0].mib_pdu.additional_bits = xtra_byte; + rx_ind.rx_indication_body[0].mib_pdu.pdu = &decoded_output[0]; //not good as it is pointing to a memory that can change + rx_ind.rx_indication_body[0].mib_pdu.additional_bits = nr_ue_pbch_vars->xtra_byte; rx_ind.rx_indication_body[0].mib_pdu.ssb_index = i_ssb; // confirm with TCL rx_ind.rx_indication_body[0].mib_pdu.ssb_length = Lmax; // confirm with TCL rx_ind.rx_indication_body[0].mib_pdu.cell_id = frame_parms->Nid_cell; // confirm with TCL diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index a14e674720..821bfec7df 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -817,6 +817,8 @@ typedef struct { /// \brief Pointer to PBCH decoded output. /// - first index: ? [0..63] (hard coded) uint8_t *decoded_output; + /// \brief PBCH additional bits + uint8_t xtra_byte; /// \brief Total number of PDU errors. uint32_t pdu_errors; /// \brief Total number of PDU errors 128 frames ago. diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 775710bb60..1b8f64d71f 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -637,10 +637,10 @@ int main(int argc, char **argv) uint8_t gNB_xtra_byte=0; for (int i=0; i<8; i++) gNB_xtra_byte |= ((gNB->pbch.pbch_a>>(31-i))&1)<<(7-i); - - payload_ret = (UE->rx_ind.rx_indication_body->mib_pdu.additional_bits == gNB_xtra_byte); + + payload_ret = (UE->pbch_vars[0]->xtra_byte == gNB_xtra_byte); for (i=0;i<3;i++){ - payload_ret += (UE->rx_ind.rx_indication_body->mib_pdu.pdu[i] == gNB->pbch_pdu[2-i]); + payload_ret += (UE->pbch_vars[0]->decoded_output[i] == gNB->pbch_pdu[2-i]); //printf("pdu byte %d gNB: 0x%02x UE: 0x%02x\n",i,gNB->pbch_pdu[i], UE->rx_ind.rx_indication_body->mib_pdu.pdu[i]); } //printf("xtra byte gNB: 0x%02x UE: 0x%02x\n",gNB_xtra_byte, UE->rx_ind.rx_indication_body->mib_pdu.additional_bits); @@ -656,7 +656,6 @@ int main(int argc, char **argv) if (((float)n_errors/(float)n_trials <= target_error_rate) && (n_errors_payload==0)) { printf("PBCH test OK\n"); - printf("Synchronization obtained for i_ssb = %d\n",UE->rx_ind.rx_indication_body[0].mib_pdu.ssb_index); break; }