Commit 671309ef authored by Matthieu Kanj's avatar Matthieu Kanj

improve structure of NPUSCH

parent c18281fa
...@@ -390,6 +390,14 @@ void descrambling_NPUSCH_data_NB_IoT(LTE_DL_FRAME_PARMS *fp, ...@@ -390,6 +390,14 @@ void descrambling_NPUSCH_data_NB_IoT(LTE_DL_FRAME_PARMS *fp,
uint8_t rx_subframe, uint8_t rx_subframe,
uint32_t rx_frame); uint32_t rx_frame);
void descrambling_NPUSCH_ack_NB_IoT(LTE_DL_FRAME_PARMS *fp,
int32_t *y_msg5,
int32_t *llr_msg5,
uint32_t rnti_tmp,
uint16_t *counter_ack,
uint8_t rx_subframe,
uint32_t rx_frame);
void decode_NPUSCH_msg_NB_IoT(PHY_VARS_eNB *eNB, void decode_NPUSCH_msg_NB_IoT(PHY_VARS_eNB *eNB,
LTE_DL_FRAME_PARMS *fp, LTE_DL_FRAME_PARMS *fp,
eNB_rxtx_proc_t *proc, eNB_rxtx_proc_t *proc,
......
...@@ -1470,7 +1470,35 @@ void descrambling_NPUSCH_data_NB_IoT(LTE_DL_FRAME_PARMS *fp, ...@@ -1470,7 +1470,35 @@ void descrambling_NPUSCH_data_NB_IoT(LTE_DL_FRAME_PARMS *fp,
} }
} }
///////////////////////////////////////////////////////////////////////////////////////////////////////////
void descrambling_NPUSCH_ack_NB_IoT(LTE_DL_FRAME_PARMS *fp,
int32_t *y_msg5,
int32_t *llr_msg5,
uint32_t rnti_tmp,
uint16_t *counter_ack,
uint8_t rx_subframe,
uint32_t rx_frame)
{
int l = 0;
uint32_t x1, x2, s=0;
uint8_t reset = 1;
x2 = (rnti_tmp<<14) + (rx_subframe<<9) + ((rx_frame%2)<<13) + fp->Nid_cell;
s = lte_gold_generic(&x1, &x2, reset);
reset = 0;
for (l=0;l<16;l++)
{
if (((s>>(l%32))&1)==1) //xor
{
y_msg5[l] = -llr_msg5[l];
} else {
y_msg5[l] = llr_msg5[l];
}
*counter_ack += (y_msg5[l]>>31)&1;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
...@@ -1494,17 +1522,12 @@ void decode_NPUSCH_msg_NB_IoT(PHY_VARS_eNB *eNB, ...@@ -1494,17 +1522,12 @@ void decode_NPUSCH_msg_NB_IoT(PHY_VARS_eNB *eNB,
unsigned int A = (ulsch_harq->TBS)*8; unsigned int A = (ulsch_harq->TBS)*8;
uint8_t rvdx = ulsch_harq->rvidx; uint8_t rvdx = ulsch_harq->rvidx;
unsigned int j,j2; //i2, unsigned int j,j2;
int iprime; int iprime;
int r,Kr; int r,Kr;
//unsigned int sumKr=0;
unsigned int G,H,Hprime,Hpp,Cmux,Rmux_prime; // Q_CQI,Q_RI=0 unsigned int G,H,Hprime,Hpp,Cmux,Rmux_prime; // Q_CQI,Q_RI=0
uint32_t x1, x2, s=0;
int16_t y[6*14*1200] __attribute__((aligned(32))); int16_t y[6*14*1200] __attribute__((aligned(32)));
uint8_t ytag[14*1200]; uint8_t ytag[14*1200];
uint8_t reset;
uint8_t counter_ack; // ack counter for decision ack/nack
int32_t counter_ack_soft;
if (npusch_format == 0) if (npusch_format == 0)
{ {
...@@ -1535,11 +1558,8 @@ void decode_NPUSCH_msg_NB_IoT(PHY_VARS_eNB *eNB, ...@@ -1535,11 +1558,8 @@ void decode_NPUSCH_msg_NB_IoT(PHY_VARS_eNB *eNB,
ulsch_harq->G = G; ulsch_harq->G = G;
H = G ; H = G ;
Hprime = H/Qm; Hprime = H/Qm;
// Demultiplexing/Deinterleaving of PUSCH/ACK/RI/CQI
Hpp = Hprime; Hpp = Hprime;
// Cmux = (ulsch_harq->Nsymb_UL-1)*ulsch_harq->Nslot_UL; // see definition in 36.212, Section 6.3.2, but not consistent with definition Cmux = (7-pilots_slot) * N_UL_slots * Nsc_RU; // 6*16; /////(ulsch_harq->Nsymb_UL)*ulsch_harq->Nslot_UL;
// of RU in 36.211, Section 10.1.2.3. Maybe prefer the following:
Cmux = (7-pilots_slot) * N_UL_slots * Nsc_RU; // 6*16; //////////////(ulsch_harq->Nsymb_UL)*ulsch_harq->Nslot_UL; // * N_RU **********
Rmux_prime = Hpp/Cmux; Rmux_prime = Hpp/Cmux;
// Clear "tag" interleaving matrix to allow for CQI/DATA identification // Clear "tag" interleaving matrix to allow for CQI/DATA identification
memset(ytag,0,Cmux*Rmux_prime); memset(ytag,0,Cmux*Rmux_prime);
...@@ -1579,7 +1599,6 @@ void decode_NPUSCH_msg_NB_IoT(PHY_VARS_eNB *eNB, ...@@ -1579,7 +1599,6 @@ void decode_NPUSCH_msg_NB_IoT(PHY_VARS_eNB *eNB,
uint8_t crc_type; uint8_t crc_type;
int offset = 0; int offset = 0;
int16_t dummy_w[MAX_NUM_ULSCH_SEGMENTS_NB_IoT][3*(6144+64)]; int16_t dummy_w[MAX_NUM_ULSCH_SEGMENTS_NB_IoT][3*(6144+64)];
//NB_IoT_UL_eNB_HARQ_t *ulsch_harq = ulsch_NB_IoT[0]->harq_process; ///
int ret = 1; int ret = 1;
unsigned int E; unsigned int E;
...@@ -1710,95 +1729,72 @@ void decode_NPUSCH_msg_NB_IoT(PHY_VARS_eNB *eNB, ...@@ -1710,95 +1729,72 @@ void decode_NPUSCH_msg_NB_IoT(PHY_VARS_eNB *eNB,
} }
fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,1,1); // indicate ACK to MAC fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,1,1); // indicate ACK to MAC
//fill_rx_indication_NB_IoT(eNB,i,frame,subframe); // indicate SDU to MAC
fill_rx_indication_NB_IoT(eNB,proc,npusch_format,ulsch_NB_IoT->Msg3_flag,1); fill_rx_indication_NB_IoT(eNB,proc,npusch_format,ulsch_NB_IoT->Msg3_flag,1);
printf(" MSG3 OK"); printf(" MSG3 OK");
//return 1;
} else { } else {
fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,0,0); // indicate NAK to MAC fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,0,0); // indicate NAK to MAC
//fill_rx_indication_NB_IoT(eNB,i,frame,subframe); // indicate SDU to MAC
fill_rx_indication_NB_IoT(eNB,proc,npusch_format,ulsch_NB_IoT->Msg3_flag,0); fill_rx_indication_NB_IoT(eNB,proc,npusch_format,ulsch_NB_IoT->Msg3_flag,0);
printf(" MSG3 NOT OK"); printf(" MSG3 NOT OK");
//return 0;
} }
}//////////// r loop end //////////// } //////////// r loop end ////////////
} else { //////////////////////////////////// ACK ////////////////////////////// } else { //////////////////////////////////// ACK //////////////////////////////
int32_t llr_msg5[16]; int32_t llr_msg5[16];
int32_t y_msg5[16]; int32_t y_msg5[16];
int16_t *llrp2; int16_t *llrp2;
int l=0; int l = 0;
uint16_t counter_ack = 0; // ack counter for decision ack/nack
llrp2 = (int16_t*)&pusch_vars->llr[0]; llrp2 = (int16_t*)&pusch_vars->llr[0];
for (l=0;l<16;l++) /// Add real and imaginary parts of BPSK constellation for (l=0;l<16;l++) // putting reanl and im over 32 bits /// Add real and imaginary parts of BPSK constellation
{ {
llr_msg5[l] = llrp2[l<<1] + llrp2[(l<<1)+1]; llr_msg5[l] = llrp2[l<<1] + llrp2[(l<<1)+1];
} }
x2 = (rnti_tmp<<14) + (ulsch_NB_IoT->Msg3_subframe<<9) + ((ulsch_NB_IoT->Msg3_frame%2)<<13) + fp->Nid_cell; descrambling_NPUSCH_ack_NB_IoT(fp,
reset = 1; y_msg5,
s = lte_gold_generic(&x1, &x2, reset); llr_msg5,
reset = 0; rnti_tmp,
counter_ack = 0; &counter_ack,
for (l=0;l<16;l++) ulsch_NB_IoT->Msg3_subframe,
{ ulsch_NB_IoT->Msg3_frame);
//printf("\n s = %d \n",(s_msg5>>(l%32))&1);
if (((s>>(l%32))&1)==1) //xor
{
y_msg5[l] = -llr_msg5[l];
} else {
y_msg5[l] = llr_msg5[l];
}
counter_ack += (y_msg5[l]>>31)&1;
}
/// Decision ACK/NACK /// Decision ACK/NACK
printf("\n\n\n"); printf("\n\n\n");
if (counter_ack>8) //hard decision if (counter_ack>8) //hard decision
{ {
printf(" decoded msg5: ACK ");
fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,1,1); // indicate ACK to MAC fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,1,1); // indicate ACK to MAC
//fill_rx_indication_NB_IoT(eNB,i,frame,subframe); // indicate SDU to MAC
fill_rx_indication_NB_IoT(eNB,proc,npusch_format,ulsch_NB_IoT->Msg3_flag,1); fill_rx_indication_NB_IoT(eNB,proc,npusch_format,ulsch_NB_IoT->Msg3_flag,1);
//return 1; printf(" decoded msg5: ACK ");
} else if (counter_ack<8) { //hard decision } else if (counter_ack<8) { //hard decision
printf(" decoded msg5: NACK ");
fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,0,0); // indicate NAK to MAC fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,0,0); // indicate NAK to MAC
//fill_rx_indication_NB_IoT(eNB,i,frame,subframe); // indicate SDU to MAC
fill_rx_indication_NB_IoT(eNB,proc,npusch_format,ulsch_NB_IoT->Msg3_flag,0); fill_rx_indication_NB_IoT(eNB,proc,npusch_format,ulsch_NB_IoT->Msg3_flag,0);
//return 0; printf(" decoded msg5: NACK ");
} else { //when equality (8 bits 0 vs 8 bits 1), soft decision } else { //when equality (8 bits 0 vs 8 bits 1), soft decision
counter_ack_soft=0; int32_t counter_ack_soft = 0;
for (l=0;l<16;l++) for (l=0;l<16;l++)
{ {
counter_ack_soft += y_msg5[l]; counter_ack_soft += y_msg5[l];
} }
if (counter_ack_soft>=0) if (counter_ack_soft>=0) // decision
{ {
printf(" decoded msg5 (soft): ACK ");
fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,1,1); // indicate ACK to MAC fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,1,1); // indicate ACK to MAC
//fill_rx_indication_NB_IoT(eNB,i,frame,subframe); // indicate SDU to MAC
fill_rx_indication_NB_IoT(eNB,proc,npusch_format,ulsch_NB_IoT->Msg3_flag,1); fill_rx_indication_NB_IoT(eNB,proc,npusch_format,ulsch_NB_IoT->Msg3_flag,1);
//return 1; printf(" decoded msg5 (soft): ACK ");
} else { } else {
printf(" decoded msg5 (soft): NACK ");
fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,0,0); // indicate NAK to MAC fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,0,0); // indicate NAK to MAC
//fill_rx_indication_NB_IoT(eNB,i,frame,subframe); // indicate SDU to MAC
fill_rx_indication_NB_IoT(eNB,proc,npusch_format,ulsch_NB_IoT->Msg3_flag,1); fill_rx_indication_NB_IoT(eNB,proc,npusch_format,ulsch_NB_IoT->Msg3_flag,1);
//return 0; printf(" decoded msg5 (soft): NACK ");
} }
} }
printf("\n\n\n"); printf("\n\n\n"); // end decision for ACK/NACK
} }
///// if last sf of the word ///// if last sf of the word
......
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