Commit 858502c1 authored by Guy De Souza's avatar Guy De Souza

MIB decoding fixes UE

parent 6143fc30
...@@ -160,7 +160,7 @@ void nr_pbch_scrambling(NR_gNB_PBCH *pbch, ...@@ -160,7 +160,7 @@ void nr_pbch_scrambling(NR_gNB_PBCH *pbch,
uint8_t reset, offset; uint8_t reset, offset;
uint32_t x1, x2, s=0; uint32_t x1, x2, s=0;
uint32_t *pbch_e = pbch->pbch_e; uint32_t *pbch_e = pbch->pbch_e;
//uint32_t unscrambling_mask = 0x100006D;
reset = 1; reset = 1;
// x1 is set in lte_gold_generic // x1 is set in lte_gold_generic
x2 = Nid; x2 = Nid;
...@@ -171,9 +171,9 @@ void nr_pbch_scrambling(NR_gNB_PBCH *pbch, ...@@ -171,9 +171,9 @@ void nr_pbch_scrambling(NR_gNB_PBCH *pbch,
} }
// Scrambling is now done with offset (nushift*M)%32 // Scrambling is now done with offset (nushift*M)%32
offset = (nushift*M)&0x1f; offset = (nushift*M)&0x1f;
//#ifdef DEBUG_PBCH_ENCODING #ifdef DEBUG_PBCH_ENCODING
printf("Scrambling params: nushift %d M %d length %d encoded %d offset %d mask 0x%08x\n", nushift, M, length, encoded, offset, unscrambling_mask); printf("Scrambling params: nushift %d M %d length %d encoded %d offset %d mask 0x%08x\n", nushift, M, length, encoded, offset, unscrambling_mask);
//#endif #endif
for (int i=0; i<length; i++) { for (int i=0; i<length; i++) {
if (((i+offset)&0x1f)==0) { if (((i+offset)&0x1f)==0) {
...@@ -241,11 +241,11 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, ...@@ -241,11 +241,11 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch,
pbch->pbch_a=0; pbch->pbch_a=0;
for (int i=0; i<NR_PBCH_PDU_BITS; i++) for (int i=0; i<NR_PBCH_PDU_BITS; i++)
pbch->pbch_a |= ((pbch_pdu[2-(i>>3)]>>(7-(i&7)))&1)<<i; pbch->pbch_a |= ((pbch_pdu[2-(i>>3)]>>(7-(i&7)))&1)<<i;
//#ifdef DEBUG_PBCH_ENCODING #ifdef DEBUG_PBCH_ENCODING
for (int i=0; i<3; i++) for (int i=0; i<3; i++)
printf("pbch_pdu[%d]: 0x%02x\n", i, pbch_pdu[i]); printf("pbch_pdu[%d]: 0x%02x\n", i, pbch_pdu[i]);
printf("PBCH payload = 0x%08x\n",pbch->pbch_a); printf("PBCH payload = 0x%08x\n",pbch->pbch_a);
//#endif #endif
// Extra byte generation // Extra byte generation
for (int i=0; i<4; i++) for (int i=0; i<4; i++)
...@@ -265,9 +265,9 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, ...@@ -265,9 +265,9 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch,
for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS; i++) { for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS; i++) {
pbch->pbch_a_interleaved |= ((pbch->pbch_a>>i)&1)<<(*(interleaver+i)); pbch->pbch_a_interleaved |= ((pbch->pbch_a>>i)&1)<<(*(interleaver+i));
//#ifdef DEBUG_PBCH_ENCODING #ifdef DEBUG_PBCH_ENCODING
printf("i %d out 0x%08x ilv %d (in>>i)&1) %d\n", i, pbch->pbch_a_interleaved, *(interleaver+i), (pbch->pbch_a>>i)&1); printf("i %d out 0x%08x ilv %d (in>>i)&1) %d\n", i, pbch->pbch_a_interleaved, *(interleaver+i), (pbch->pbch_a>>i)&1);
//#endif #endif
} }
#ifdef DEBUG_PBCH_ENCODING #ifdef DEBUG_PBCH_ENCODING
...@@ -276,7 +276,7 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, ...@@ -276,7 +276,7 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch,
#endif #endif
// Scrambling // Scrambling
unscrambling_mask = (Lmax ==64)? 0x100006D:0x1000021; unscrambling_mask = (Lmax ==64)? 0x100006D:0x1000041;
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 = (((sfn>>2)&1)<<1) ^ ((sfn>>1)&1); nushift = (((sfn>>2)&1)<<1) ^ ((sfn>>1)&1);
pbch->pbch_a_prime = 0; pbch->pbch_a_prime = 0;
......
...@@ -436,14 +436,13 @@ void nr_pbch_unscrambling(NR_UE_PBCH *pbch, ...@@ -436,14 +436,13 @@ void nr_pbch_unscrambling(NR_UE_PBCH *pbch,
uint8_t nushift, uint8_t nushift,
uint16_t M, uint16_t M,
uint16_t length, uint16_t length,
uint8_t bitwise) uint8_t bitwise,
uint32_t unscrambling_mask)
{ {
uint8_t reset, offset; uint8_t reset, offset;
uint32_t x1, x2, s=0; uint32_t x1, x2, s=0;
int16_t *demod_pbch_e = pbch->llr; int16_t *demod_pbch_e = pbch->llr;
uint32_t unscrambling_mask = 0x100006D;
reset = 1; reset = 1;
// x1 is set in first call to lte_gold_generic // x1 is set in first call to lte_gold_generic
...@@ -507,7 +506,7 @@ unsigned char sign(int8_t x) { ...@@ -507,7 +506,7 @@ unsigned char sign(int8_t x) {
} }
*/ */
uint8_t pbch_deinterleaving_pattern[32] = {28,6,31,30,7,29,25,27,4,8,24,9,10,11,12,13,0,3,2,14,15,16,17,1,26,18,19,20,21,22,5,23}; uint8_t pbch_deinterleaving_pattern[32] = {28,0,31,30,7,29,25,27,5,8,24,9,10,11,12,13,1,4,3,14,15,16,17,2,26,18,19,20,21,22,30,23};
int nr_rx_pbch( PHY_VARS_NR_UE *ue, int nr_rx_pbch( PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc, UE_nr_rxtx_proc_t *proc,
...@@ -647,7 +646,8 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -647,7 +646,8 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
//un-scrambling //un-scrambling
M = NR_POLAR_PBCH_E; M = NR_POLAR_PBCH_E;
nushift = (Lmax==4)? ssb_index&3 : ssb_index&7; nushift = (Lmax==4)? ssb_index&3 : ssb_index&7;
nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_E,0); uint32_t unscrambling_mask = (Lmax==64)?0x100006D:0x1000041;
nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_E,0,0);
...@@ -664,18 +664,18 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -664,18 +664,18 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
if(decoderState == -1) if(decoderState == -1)
return(decoderState); return(decoderState);
//printf("polar decoder output 0x%08x\n",nr_ue_pbch_vars->pbch_a_prime); printf("polar decoder output 0x%08x\n",nr_ue_pbch_vars->pbch_a_prime);
//payload un-scrambling //payload un-scrambling
memset(&nr_ue_pbch_vars->pbch_a_interleaved, 0, sizeof(uint32_t) ); memset(&nr_ue_pbch_vars->pbch_a_interleaved, 0, sizeof(uint32_t) );
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 = ((nr_ue_pbch_vars->pbch_a_prime>>6)&1) ^ (((nr_ue_pbch_vars->pbch_a_prime>>24)&1)<<1); nushift = ((nr_ue_pbch_vars->pbch_a_prime>>24)&1) ^ (((nr_ue_pbch_vars->pbch_a_prime>>6)&1)<<1);
nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_PAYLOAD_BITS,1); nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_PAYLOAD_BITS,1,unscrambling_mask);
printf("nushift %d sfn 3rd %d 2nd %d", nushift,((nr_ue_pbch_vars->pbch_a_prime>>6)&1), ((nr_ue_pbch_vars->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 |= ((nr_ue_pbch_vars->pbch_a_interleaved>>i)&1)<<(pbch_deinterleaving_pattern[i]); out |= ((nr_ue_pbch_vars->pbch_a_interleaved>>i)&1)<<(pbch_deinterleaving_pattern[i]);
#ifdef DEBUG_PBCH #ifdef DEBUG_PBCH
...@@ -683,14 +683,18 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -683,14 +683,18 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
#endif #endif
} }
for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS>>3; i++) uint32_t payload = 0;
decoded_output[i] = (uint8_t)((out>>(i<<3))&0xff); uint8_t xtra_byte = 0;
xtra_byte = (out>>24)&0xff;
for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS; i++)
payload |= ((out>>i)&1)<<(NR_POLAR_PBCH_PAYLOAD_BITS-i-1);
// Fix byte endian for (int i=0; i<3; i++)
// for (i=0; i<(NR_POLAR_PBCH_PAYLOAD_BITS>>3); i++) decoded_output[i] = (uint8_t)((payload>>((3-i)<<3))&0xff);
// decoded_output[(NR_POLAR_PBCH_PAYLOAD_BITS>>3)-i-1] = pbch_a[i];
#ifdef DEBUG_PBCH #ifdef DEBUG_PBCH
printf("xtra_byte %x payload %x\n", xtra_byte, payload);
for (i=0; i<(NR_POLAR_PBCH_PAYLOAD_BITS>>3); i++){ for (i=0; i<(NR_POLAR_PBCH_PAYLOAD_BITS>>3); i++){
// printf("unscrambling pbch_a[%d] = %x \n", i,pbch_a[i]); // printf("unscrambling pbch_a[%d] = %x \n", i,pbch_a[i]);
printf("[PBCH] decoder payload[%d] = %x\n",i,decoded_output[i]); printf("[PBCH] decoder payload[%d] = %x\n",i,decoded_output[i]);
...@@ -703,7 +707,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -703,7 +707,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
ue->rx_ind.rx_indication_body = (fapi_nr_rx_indication_body_t *)malloc(sizeof(fapi_nr_rx_indication_body_t)); ue->rx_ind.rx_indication_body = (fapi_nr_rx_indication_body_t *)malloc(sizeof(fapi_nr_rx_indication_body_t));
ue->rx_ind.rx_indication_body->pdu_type = FAPI_NR_RX_PDU_TYPE_MIB; ue->rx_ind.rx_indication_body->pdu_type = FAPI_NR_RX_PDU_TYPE_MIB;
ue->rx_ind.rx_indication_body->mib_pdu.pdu = &decoded_output[0]; ue->rx_ind.rx_indication_body->mib_pdu.pdu = &decoded_output[0];
ue->rx_ind.rx_indication_body->mib_pdu.additional_bits = decoded_output[3]; ue->rx_ind.rx_indication_body->mib_pdu.additional_bits = xtra_byte;
ue->rx_ind.rx_indication_body->mib_pdu.ssb_index = ssb_index; // confirm with TCL ue->rx_ind.rx_indication_body->mib_pdu.ssb_index = ssb_index; // confirm with TCL
ue->rx_ind.rx_indication_body->mib_pdu.ssb_length = Lmax; // confirm with TCL ue->rx_ind.rx_indication_body->mib_pdu.ssb_length = Lmax; // confirm with TCL
ue->rx_ind.rx_indication_body->mib_pdu.cell_id = frame_parms->Nid_cell; // confirm with TCL ue->rx_ind.rx_indication_body->mib_pdu.cell_id = frame_parms->Nid_cell; // confirm with TCL
......
...@@ -169,7 +169,7 @@ int8_t nr_ue_phy_config_request(nr_phy_config_t *phy_config){ ...@@ -169,7 +169,7 @@ int8_t nr_ue_phy_config_request(nr_phy_config_t *phy_config){
printf("dmrs type A position: %d\n", phy_config->config_req.pbch_config.dmrs_type_a_position); printf("dmrs type A position: %d\n", phy_config->config_req.pbch_config.dmrs_type_a_position);
printf("pdcch config sib1: %d\n", phy_config->config_req.pbch_config.pdcch_config_sib1); printf("pdcch config sib1: %d\n", phy_config->config_req.pbch_config.pdcch_config_sib1);
printf("cell barred: %d\n", phy_config->config_req.pbch_config.cell_barred); printf("cell barred: %d\n", phy_config->config_req.pbch_config.cell_barred);
printf("intra frequcney reselection: %d\n", phy_config->config_req.pbch_config.intra_frequency_reselection); printf("intra frequency reselection: %d\n", phy_config->config_req.pbch_config.intra_frequency_reselection);
printf("system frame number: %d\n", phy_config->config_req.pbch_config.system_frame_number); printf("system frame number: %d\n", phy_config->config_req.pbch_config.system_frame_number);
printf("ssb index: %d\n", phy_config->config_req.pbch_config.ssb_index); printf("ssb index: %d\n", phy_config->config_req.pbch_config.ssb_index);
printf("half frame bit: %d\n", phy_config->config_req.pbch_config.half_frame_bit); printf("half frame bit: %d\n", phy_config->config_req.pbch_config.half_frame_bit);
......
...@@ -64,12 +64,14 @@ int8_t nr_ue_decode_mib( ...@@ -64,12 +64,14 @@ int8_t nr_ue_decode_mib(
AssertFatal(mac->mib != NULL, "nr_ue_decode_mib() mac->mib == NULL\n"); AssertFatal(mac->mib != NULL, "nr_ue_decode_mib() mac->mib == NULL\n");
//if(mac->mib != NULL){ //if(mac->mib != NULL){
uint32_t frame = (mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused); uint16_t frame = (mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused);
uint32_t frame_number_4lsb = (uint32_t)(extra_bits & 0xf); // extra bits[0:3] uint16_t frame_number_4lsb = 0;
uint32_t half_frame_bit = (uint32_t)(( extra_bits >> 4 ) & 0x1 ); // extra bits[4] for (int i=0; i<4; i++)
uint32_t ssb_subcarrier_offset_msb = (uint32_t)(( extra_bits >> 5 ) & 0x1 ); // extra bits[5] frame_number_4lsb |= ((extra_bits>>i)&1)<<(3-i);
uint8_t half_frame_bit = ( extra_bits >> 4 ) & 0x1; // extra bits[4]
uint8_t ssb_subcarrier_offset_msb = ( extra_bits >> 5 ) & 0x1; // extra bits[5]
uint32_t ssb_subcarrier_offset = mac->mib->ssb_SubcarrierOffset; uint8_t ssb_subcarrier_offset = (uint8_t)mac->mib->ssb_SubcarrierOffset;
//uint32_t ssb_index = 0; // TODO: ssb_index should obtain from L1 in case Lssb != 64 //uint32_t ssb_index = 0; // TODO: ssb_index should obtain from L1 in case Lssb != 64
...@@ -92,7 +94,7 @@ int8_t nr_ue_decode_mib( ...@@ -92,7 +94,7 @@ int8_t nr_ue_decode_mib(
printf("dmrs type A position: %d\n", (int)mac->mib->dmrs_TypeA_Position); printf("dmrs type A position: %d\n", (int)mac->mib->dmrs_TypeA_Position);
printf("pdcch config sib1: %d\n", (int)mac->mib->pdcch_ConfigSIB1); printf("pdcch config sib1: %d\n", (int)mac->mib->pdcch_ConfigSIB1);
printf("cell barred: %d\n", (int)mac->mib->cellBarred); printf("cell barred: %d\n", (int)mac->mib->cellBarred);
printf("intra frequcney reselection: %d\n", (int)mac->mib->intraFreqReselection); printf("intra frequency reselection: %d\n", (int)mac->mib->intraFreqReselection);
printf("half frame bit(extra bits): %d\n", (int)half_frame_bit); printf("half frame bit(extra bits): %d\n", (int)half_frame_bit);
printf("ssb index(extra bits): %d\n", (int)ssb_index); printf("ssb index(extra bits): %d\n", (int)ssb_index);
#endif #endif
...@@ -108,7 +110,6 @@ int8_t nr_ue_decode_mib( ...@@ -108,7 +110,6 @@ int8_t nr_ue_decode_mib(
}else{ //NR_MIB__subCarrierSpacingCommon_scs30or120 }else{ //NR_MIB__subCarrierSpacingCommon_scs30or120
scs_pdcch = scs_30kHz; scs_pdcch = scs_30kHz;
} }
scs_pdcch = 2;
channel_bandwidth_t min_channel_bw = bw_40MHz; // deafult for testing channel_bandwidth_t min_channel_bw = bw_40MHz; // deafult for testing
......
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