Commit 0e3d87b4 authored by Raymond Knopp's avatar Raymond Knopp

format 2 up to 64 bits tested for 8 and 16 PRBs PUCCH format

parent 613d1e8c
...@@ -1498,7 +1498,7 @@ typedef struct ...@@ -1498,7 +1498,7 @@ typedef struct
//for dci_pusch_pdu //for dci_pusch_pdu
typedef struct typedef struct
{ {
uint8_t pdu_bit_map; uint8_t pduBitmap;
uint32_t handle; uint32_t handle;
uint16_t rnti; uint16_t rnti;
uint8_t ul_cqi; uint8_t ul_cqi;
...@@ -1513,7 +1513,7 @@ typedef struct ...@@ -1513,7 +1513,7 @@ typedef struct
//for PUCCH PDU Format 0/1 //for PUCCH PDU Format 0/1
typedef struct typedef struct
{ {
uint8_t pdu_bit_map; uint8_t pduBitmap;
uint32_t handle; uint32_t handle;
uint16_t rnti; uint16_t rnti;
uint8_t pucch_format;//PUCCH format Value: 0 -> 1 0: PUCCH Format0 1: PUCCH Format1 uint8_t pucch_format;//PUCCH format Value: 0 -> 1 0: PUCCH Format0 1: PUCCH Format1
...@@ -1529,7 +1529,7 @@ typedef struct ...@@ -1529,7 +1529,7 @@ typedef struct
//PUCCH PDU Format 2/3/4 //PUCCH PDU Format 2/3/4
typedef struct typedef struct
{ {
uint8_t pdu_bit_map; uint8_t pduBitmap;
uint32_t handle; uint32_t handle;
uint16_t rnti; uint16_t rnti;
uint8_t pucch_format;//PUCCH format Value: 0 -> 2 0: PUCCH Format2 1: PUCCH Format3 2: PUCCH Format4 uint8_t pucch_format;//PUCCH format Value: 0 -> 2 0: PUCCH Format2 1: PUCCH Format3 2: PUCCH Format4
......
...@@ -43,11 +43,12 @@ static void nr_polar_init(t_nrPolar_params * *polarParams, ...@@ -43,11 +43,12 @@ static void nr_polar_init(t_nrPolar_params * *polarParams,
uint8_t aggregation_level, uint8_t aggregation_level,
int decoder_flag) { int decoder_flag) {
t_nrPolar_params *currentPtr = *polarParams; t_nrPolar_params *currentPtr = *polarParams;
uint16_t aggregation_prime = nr_polar_aggregation_prime(aggregation_level); uint16_t aggregation_prime = (messageType >= 2) ? aggregation_level : nr_polar_aggregation_prime(aggregation_level);
//Parse the list. If the node is already created, return without initialization. //Parse the list. If the node is already created, return without initialization.
while (currentPtr != NULL) { while (currentPtr != NULL) {
//printf("currentPtr->idx %d, (%d,%d)\n",currentPtr->idx,currentPtr->payloadBits,currentPtr->encoderLength); //printf("currentPtr->idx %d, (%d,%d)\n",currentPtr->idx,currentPtr->payloadBits,currentPtr->encoderLength);
LOG_D(PHY,"Looking for index %d\n",(messageType * messageLength * aggregation_prime));
if (currentPtr->idx == (messageType * messageLength * aggregation_prime)) return; if (currentPtr->idx == (messageType * messageLength * aggregation_prime)) return;
else currentPtr = currentPtr->nextPtr; else currentPtr = currentPtr->nextPtr;
} }
...@@ -57,6 +58,7 @@ static void nr_polar_init(t_nrPolar_params * *polarParams, ...@@ -57,6 +58,7 @@ static void nr_polar_init(t_nrPolar_params * *polarParams,
t_nrPolar_params *newPolarInitNode = calloc(sizeof(t_nrPolar_params),1); t_nrPolar_params *newPolarInitNode = calloc(sizeof(t_nrPolar_params),1);
if (newPolarInitNode != NULL) { if (newPolarInitNode != NULL) {
LOG_D(PHY,"Setting new polarParams index %d, messageType %d, messageLength %d, aggregation_prime %d\n",(messageType * messageLength * aggregation_prime),messageType,messageLength,aggregation_prime);
newPolarInitNode->idx = (messageType * messageLength * aggregation_prime); newPolarInitNode->idx = (messageType * messageLength * aggregation_prime);
newPolarInitNode->nextPtr = NULL; newPolarInitNode->nextPtr = NULL;
//printf("newPolarInitNode->idx %d, (%d,%d,%d:%d)\n",newPolarInitNode->idx,messageType,messageLength,aggregation_prime,aggregation_level); //printf("newPolarInitNode->idx %d, (%d,%d,%d:%d)\n",newPolarInitNode->idx,messageType,messageLength,aggregation_prime,aggregation_level);
...@@ -116,6 +118,7 @@ static void nr_polar_init(t_nrPolar_params * *polarParams, ...@@ -116,6 +118,7 @@ static void nr_polar_init(t_nrPolar_params * *polarParams,
newPolarInitNode->payloadBits = messageLength; newPolarInitNode->payloadBits = messageLength;
newPolarInitNode->crcCorrectionBits = NR_POLAR_PUCCH_CRC_ERROR_CORRECTION_BITS; newPolarInitNode->crcCorrectionBits = NR_POLAR_PUCCH_CRC_ERROR_CORRECTION_BITS;
//newPolarInitNode->crc_generator_matrix=crc24c_generator_matrix(newPolarInitNode->payloadBits+newPolarInitNode->crcParityBits);//G_P //newPolarInitNode->crc_generator_matrix=crc24c_generator_matrix(newPolarInitNode->payloadBits+newPolarInitNode->crcParityBits);//G_P
LOG_D(PHY,"New polar node, encoderLength %d, aggregation_level %d\n",newPolarInitNode->encoderLength,aggregation_level);
} else { } else {
AssertFatal(1 == 0, "[nr_polar_init] Incorrect Message Type(%d)", messageType); AssertFatal(1 == 0, "[nr_polar_init] Incorrect Message Type(%d)", messageType);
} }
...@@ -219,16 +222,19 @@ t_nrPolar_params *nr_polar_params (int8_t messageType, ...@@ -219,16 +222,19 @@ t_nrPolar_params *nr_polar_params (int8_t messageType,
nr_polar_init(polarList_ext != NULL ? polarList_ext : &polarList, nr_polar_init(polarList_ext != NULL ? polarList_ext : &polarList,
messageType,messageLength,aggregation_level,decoding_flag); messageType,messageLength,aggregation_level,decoding_flag);
t_nrPolar_params *polarParams=polarList_ext != NULL ? *polarList_ext : polarList; t_nrPolar_params *polarParams=polarList_ext != NULL ? *polarList_ext : polarList;
const int tag=messageType * messageLength * nr_polar_aggregation_prime(aggregation_level); const int tag=messageType * messageLength * (messageType>=2 ? aggregation_level : nr_polar_aggregation_prime(aggregation_level));
while (polarParams != NULL) { while (polarParams != NULL) {
LOG_D(PHY,"nr_polar_params : tag %d (from nr_polar_init %d)\n",tag,polarParams->idx);
if (polarParams->idx == tag) if (polarParams->idx == tag)
return polarParams; return polarParams;
polarParams = polarParams->nextPtr; polarParams = polarParams->nextPtr;
} }
AssertFatal(false,"Polar Init tables internal failure\n"); AssertFatal(false,"Polar Init tables internal failure, no polarParams found\n");
return NULL; return NULL;
} }
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
#include "T.h" #include "T.h"
#define DEBUG_NR_PUCCH_RX 1 //#define DEBUG_NR_PUCCH_RX 1
int get_pucch0_cs_lut_index(PHY_VARS_gNB *gNB,nfapi_nr_pucch_pdu_t* pucch_pdu) { int get_pucch0_cs_lut_index(PHY_VARS_gNB *gNB,nfapi_nr_pucch_pdu_t* pucch_pdu) {
...@@ -326,7 +326,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, ...@@ -326,7 +326,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
index=maxpos; index=maxpos;
#endif #endif
// first bit of bitmap for sr presence and second bit for acknack presence // first bit of bitmap for sr presence and second bit for acknack presence
uci_pdu->pdu_bit_map = pucch_pdu->sr_flag | ((pucch_pdu->bit_len_harq>0)<<1); uci_pdu->pduBitmap = pucch_pdu->sr_flag | ((pucch_pdu->bit_len_harq>0)<<1);
uci_pdu->pucch_format = 0; // format 0 uci_pdu->pucch_format = 0; // format 0
uci_pdu->ul_cqi = 0xff; // currently not valid uci_pdu->ul_cqi = 0xff; // currently not valid
uci_pdu->timing_advance = 0xffff; // currently not valid uci_pdu->timing_advance = 0xffff; // currently not valid
...@@ -872,6 +872,7 @@ __m256i *pucch2_lut[9]={pucch2_3bit, ...@@ -872,6 +872,7 @@ __m256i *pucch2_lut[9]={pucch2_3bit,
pucch2_11bit}; pucch2_11bit};
__m64 pucch2_polar_4bit[16]; __m64 pucch2_polar_4bit[16];
__m128i pucch2_polar_llr_num_lut[256],pucch2_polar_llr_den_lut[256];
void init_pucch2_luts() { void init_pucch2_luts() {
...@@ -964,6 +965,50 @@ void init_pucch2_luts() { ...@@ -964,6 +965,50 @@ void init_pucch2_luts() {
bit = (i&0x8) > 0 ? -1 : 1; bit = (i&0x8) > 0 ? -1 : 1;
*lut_i = _mm_insert_pi16(*lut_i,bit,3); *lut_i = _mm_insert_pi16(*lut_i,bit,3);
} }
for (int i=0;i<256;i++) {
__m128i *lut_num_i=&pucch2_polar_llr_num_lut[i];
__m128i *lut_den_i=&pucch2_polar_llr_den_lut[i];
bit = (i&0x1) > 0 ? 0 : 1;
*lut_num_i = _mm_insert_epi16(*lut_num_i,bit,0);
*lut_den_i = _mm_insert_epi16(*lut_den_i,1-bit,0);
bit = (i&0x10) > 0 ? 0 : 1;
*lut_num_i = _mm_insert_epi16(*lut_num_i,bit,1);
*lut_den_i = _mm_insert_epi16(*lut_den_i,1-bit,1);
bit = (i&0x2) > 0 ? 0 : 1;
*lut_num_i = _mm_insert_epi16(*lut_num_i,bit,2);
*lut_den_i = _mm_insert_epi16(*lut_den_i,1-bit,2);
bit = (i&0x20) > 0 ? 0 : 1;
*lut_num_i = _mm_insert_epi16(*lut_num_i,bit,3);
*lut_den_i = _mm_insert_epi16(*lut_den_i,1-bit,3);
bit = (i&0x4) > 0 ? 0 : 1;
*lut_num_i = _mm_insert_epi16(*lut_num_i,bit,4);
*lut_den_i = _mm_insert_epi16(*lut_den_i,1-bit,4);
bit = (i&0x40) > 0 ? 0 : 1;
*lut_num_i = _mm_insert_epi16(*lut_num_i,bit,5);
*lut_den_i = _mm_insert_epi16(*lut_den_i,1-bit,5);
bit = (i&0x8) > 0 ? 0 : 1;
*lut_num_i = _mm_insert_epi16(*lut_num_i,bit,6);
*lut_den_i = _mm_insert_epi16(*lut_den_i,1-bit,6);
bit = (i&0x80) > 0 ? 0 : 1;
*lut_num_i = _mm_insert_epi16(*lut_num_i,bit,7);
*lut_den_i = _mm_insert_epi16(*lut_den_i,1-bit,7);
printf("i %d, lut_num (%d,%d,%d,%d,%d,%d,%d,%d)\n",i,
((int16_t *)lut_num_i)[0],
((int16_t *)lut_num_i)[1],
((int16_t *)lut_num_i)[2],
((int16_t *)lut_num_i)[3],
((int16_t *)lut_num_i)[4],
((int16_t *)lut_num_i)[5],
((int16_t *)lut_num_i)[6],
((int16_t *)lut_num_i)[7]);
}
} }
...@@ -976,6 +1021,8 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, ...@@ -976,6 +1021,8 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms;
pucch_GroupHopping_t pucch_GroupHopping = pucch_pdu->group_hop_flag + (pucch_pdu->sequence_hop_flag<<1); pucch_GroupHopping_t pucch_GroupHopping = pucch_pdu->group_hop_flag + (pucch_pdu->sequence_hop_flag<<1);
AssertFatal(pucch_pdu->nr_of_symbols==1 || pucch_pdu->nr_of_symbols==2, AssertFatal(pucch_pdu->nr_of_symbols==1 || pucch_pdu->nr_of_symbols==2,
"Illegal number of symbols for PUCCH 2 %d\n",pucch_pdu->nr_of_symbols); "Illegal number of symbols for PUCCH 2 %d\n",pucch_pdu->nr_of_symbols);
...@@ -1291,10 +1338,12 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, ...@@ -1291,10 +1338,12 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
printf("\n"); printf("\n");
#endif #endif
} }
AssertFatal(pucch_pdu->bit_len_csi_part1 + pucch_pdu->bit_len_csi_part2 == 0,"no csi for now\n"); int nb_bit = pucch_pdu->bit_len_harq+pucch_pdu->sr_flag+pucch_pdu->bit_len_csi_part1+pucch_pdu->bit_len_csi_part2;
AssertFatal((pucch_pdu->bit_len_harq+pucch_pdu->sr_flag > 2 ) && (pucch_pdu->bit_len_harq+pucch_pdu->sr_flag < 65),"illegal length (%d,%d)\n",pucch_pdu->bit_len_harq,pucch_pdu->sr_flag); AssertFatal(nb_bit > 2 && nb_bit< 65,"illegal length (%d : %d,%d,%d,%d)\n",nb_bit,pucch_pdu->bit_len_harq,pucch_pdu->sr_flag,pucch_pdu->bit_len_csi_part1,pucch_pdu->bit_len_csi_part2);
int nb_bit = pucch_pdu->bit_len_harq+pucch_pdu->sr_flag;
uint64_t decodedPayload[2];
uint8_t corr_dB;
int decoderState=2;
if (nb_bit < 12) { // short blocklength case if (nb_bit < 12) { // short blocklength case
__m256i *rp_re[Prx2]; __m256i *rp_re[Prx2];
__m256i *rp2_re[Prx2]; __m256i *rp2_re[Prx2];
...@@ -1371,31 +1420,19 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, ...@@ -1371,31 +1420,19 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
cw_ML=cw; cw_ML=cw;
} }
} }
uint8_t corr_dB = dB_fixed64((uint64_t)corr); corr_dB = dB_fixed64((uint64_t)corr);
LOG_D(PHY,"cw_ML %d, metric %d dB\n",cw_ML,corr_dB); LOG_D(PHY,"cw_ML %d, metric %d dB\n",cw_ML,corr_dB);
uci_pdu->harq.harq_bit_len = pucch_pdu->bit_len_harq; decodedPayload[0]=(uint64_t)cw_ML;
int harq_bytes=pucch_pdu->bit_len_harq>>3;
if ((pucch_pdu->bit_len_harq&7) > 0) harq_bytes++;
uci_pdu->harq.harq_payload = (nfapi_nr_harq_t*)malloc(harq_bytes);
uci_pdu->harq.harq_crc = 2;
for (int i=0;i<harq_bytes;i++) {
uci_pdu->harq.harq_payload[i] = cw_ML & 255;
cw_ML>>=8;
}
if (pucch_pdu->sr_flag == 1) {
uci_pdu->sr.sr_bit_len = 1;
uci_pdu->sr.sr_payload = malloc(1);
uci_pdu->sr.sr_payload[0] = cw_ML;
}
} }
else { // polar coded case else { // polar coded case
t_nrPolar_params *currentPtr = nr_polar_params(2,nb_bit,pucch_pdu->prb_size,1,&gNB->uci_polarParams);
__m64 *rp_re[Prx2]; __m64 *rp_re[Prx2];
__m64 *rp2_re[Prx2]; __m64 *rp2_re[Prx2];
__m64 *rp_im[Prx2]; __m64 *rp_im[Prx2];
__m64 *rp2_im[Prx2]; __m64 *rp2_im[Prx2];
__m128i llrs[pucch_pdu->prb_size*2];
for (int aa=0;aa<Prx;aa++) { for (int aa=0;aa<Prx;aa++) {
rp_re[aa] = (__m64*)r_re_ext[aa]; rp_re[aa] = (__m64*)r_re_ext[aa];
rp_im[aa] = (__m64*)r_im_ext[aa]; rp_im[aa] = (__m64*)r_im_ext[aa];
...@@ -1404,20 +1441,25 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, ...@@ -1404,20 +1441,25 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
} }
__m64 prod_re[Prx2],prod_im[Prx2]; __m64 prod_re[Prx2],prod_im[Prx2];
for (int cw=0;cw<16;cw++) {
#ifdef DEBUG_NR_PUCCH_RX #ifdef DEBUG_NR_PUCCH_RX
for (int cw=0;cw<16;cw++) {
printf("cw %d:",cw); printf("cw %d:",cw);
for (int i=0;i<4;i++) { for (int i=0;i<4;i++) {
printf("%d,", printf("%d,",
((int16_t*)&pucch2_polar_4bit[cw])[i>>1]); ((int16_t*)&pucch2_polar_4bit[cw])[i>>1]);
} }
printf("\n"); printf("\n");
}
#endif #endif
}
// non-coherent LLR computation on groups of 4 REs (half-PRBs) // non-coherent LLR computation on groups of 4 REs (half-PRBs)
int32_t corr_re,corr_im,corr_tmp; int32_t corr_re,corr_im,corr_tmp;
__m128i corr16,llr_num,llr_den;
uint64_t corr;
for (int half_prb=0;half_prb<(2*pucch_pdu->prb_size);half_prb++) { for (int half_prb=0;half_prb<(2*pucch_pdu->prb_size);half_prb++) {
llr_num=_mm_set1_epi16(0);llr_den=_mm_set1_epi16(0);
for (int cw=0;cw<256;cw++) { for (int cw=0;cw<256;cw++) {
corr_tmp=0; corr_tmp=0;
for (int aa=0;aa<Prx;aa++) { for (int aa=0;aa<Prx;aa++) {
...@@ -1429,11 +1471,16 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, ...@@ -1429,11 +1471,16 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
prod_im[aa] = _mm_hadds_pi16(prod_im[aa],prod_im[aa]); prod_im[aa] = _mm_hadds_pi16(prod_im[aa],prod_im[aa]);
prod_re[aa] = _mm_hadds_pi16(prod_re[aa],prod_re[aa]);// 0+1+2+3 prod_re[aa] = _mm_hadds_pi16(prod_re[aa],prod_re[aa]);// 0+1+2+3
prod_im[aa] = _mm_hadds_pi16(prod_im[aa],prod_im[aa]); prod_im[aa] = _mm_hadds_pi16(prod_im[aa],prod_im[aa]);
// this is for UL CQI measurement
if (cw==0) corr += ((int64_t)corr32_re[half_prb>>2][aa]*corr32_re[half_prb>>2][aa])+
((int64_t)corr32_im[half_prb>>2][aa]*corr32_im[half_prb>>2][aa]);
corr_re = ( corr32_re[half_prb>>2][aa]/(2*nc_group_size*4/2)+((int16_t*)(&prod_re[aa]))[0]); corr_re = ( corr32_re[half_prb>>2][aa]/(2*nc_group_size*4/2)+((int16_t*)(&prod_re[aa]))[0]);
corr_im = ( corr32_im[half_prb>>2][aa]/(2*nc_group_size*4/2)+((int16_t*)(&prod_im[aa]))[0]); corr_im = ( corr32_im[half_prb>>2][aa]/(2*nc_group_size*4/2)+((int16_t*)(&prod_im[aa]))[0]);
corr_tmp += corr_re*corr_re + corr_im*corr_im; corr_tmp += corr_re*corr_re + corr_im*corr_im;
/*
LOG_D(PHY,"pucch2 half_prb %d cw %d (%d,%d) aa %d: (%d,%d,%d,%d,%d,%d,%d,%d)x(%d,%d,%d,%d,%d,%d,%d,%d) (%d,%d)+(%d,%d) = (%d,%d) => %d\n", LOG_D(PHY,"pucch2 half_prb %d cw %d (%d,%d) aa %d: (%d,%d,%d,%d,%d,%d,%d,%d)x(%d,%d,%d,%d,%d,%d,%d,%d) (%d,%d)+(%d,%d) = (%d,%d) => %d\n",
half_prb,cw,cw&15,cw>>4,aa, half_prb,cw,cw&15,cw>>4,aa,
((int16_t*)&pucch2_polar_4bit[cw&15])[0],((int16_t*)&pucch2_polar_4bit[cw>>4])[0], ((int16_t*)&pucch2_polar_4bit[cw&15])[0],((int16_t*)&pucch2_polar_4bit[cw>>4])[0],
...@@ -1450,11 +1497,115 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, ...@@ -1450,11 +1497,115 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
corr_re, corr_re,
corr_im, corr_im,
corr_tmp); corr_tmp);
*/
} }
corr16 = _mm_set1_epi16((int16_t)(corr_tmp>>8));
/*
LOG_D(PHY,"half_prb %d cw %d corr16 %d\n",half_prb,cw,corr_tmp>>8);
*/
llr_num = _mm_max_epi16(_mm_mullo_epi16(corr16,pucch2_polar_llr_num_lut[cw]),llr_num);
llr_den = _mm_max_epi16(_mm_mullo_epi16(corr16,pucch2_polar_llr_den_lut[cw]),llr_den);
/*
LOG_D(PHY,"lut_num (%d,%d,%d,%d,%d,%d,%d,%d)\n",
((int16_t*)&pucch2_polar_llr_num_lut[cw])[0],
((int16_t*)&pucch2_polar_llr_num_lut[cw])[1],
((int16_t*)&pucch2_polar_llr_num_lut[cw])[2],
((int16_t*)&pucch2_polar_llr_num_lut[cw])[3],
((int16_t*)&pucch2_polar_llr_num_lut[cw])[4],
((int16_t*)&pucch2_polar_llr_num_lut[cw])[5],
((int16_t*)&pucch2_polar_llr_num_lut[cw])[6],
((int16_t*)&pucch2_polar_llr_num_lut[cw])[7]);
LOG_D(PHY,"llr_num (%d,%d,%d,%d,%d,%d,%d,%d)\n",
((int16_t*)&llr_num)[0],
((int16_t*)&llr_num)[1],
((int16_t*)&llr_num)[2],
((int16_t*)&llr_num)[3],
((int16_t*)&llr_num)[4],
((int16_t*)&llr_num)[5],
((int16_t*)&llr_num)[6],
((int16_t*)&llr_num)[7]);
LOG_D(PHY,"llr_den (%d,%d,%d,%d,%d,%d,%d,%d)\n",
((int16_t*)&llr_den)[0],
((int16_t*)&llr_den)[1],
((int16_t*)&llr_den)[2],
((int16_t*)&llr_den)[3],
((int16_t*)&llr_den)[4],
((int16_t*)&llr_den)[5],
((int16_t*)&llr_den)[6],
((int16_t*)&llr_den)[7]);
*/
} }
// compute llrs
llrs[half_prb] = _mm_subs_epi16(llr_num,llr_den);
LOG_D(PHY,"llrs[%d] : (%d,%d,%d,%d,%d,%d,%d,%d)\n",
half_prb,
((int16_t*)&llrs[half_prb])[0],
((int16_t*)&llrs[half_prb])[1],
((int16_t*)&llrs[half_prb])[2],
((int16_t*)&llrs[half_prb])[3],
((int16_t*)&llrs[half_prb])[4],
((int16_t*)&llrs[half_prb])[5],
((int16_t*)&llrs[half_prb])[6],
((int16_t*)&llrs[half_prb])[7]);
} // half_prb } // half_prb
AssertFatal(1==0,"stopping here\n"); // run polar decoder on llrs
decoderState = polar_decoder_int16((int16_t*)llrs, decodedPayload, 0, currentPtr);
LOG_D(PHY,"UCI decoderState %d, payload[0] %llux\n",decoderState,(unsigned long long)decodedPayload[0]);
if (decoderState>0) decoderState=1;
corr_dB = dB_fixed64(corr);
LOG_D(PHY,"metric %d dB\n",corr_dB);
}
uci_pdu->harq.harq_bit_len = pucch_pdu->bit_len_harq;
uci_pdu->pduBitmap=0;
uci_pdu->rnti=pucch_pdu->rnti;
uci_pdu->handle=pucch_pdu->handle;
uci_pdu->pucch_format=0;
uci_pdu->ul_cqi=corr_dB;
// need to fill these field!
uci_pdu->timing_advance=31;
uci_pdu->rssi=0;
if (pucch_pdu->bit_len_harq>0) {
int harq_bytes=pucch_pdu->bit_len_harq>>3;
if ((pucch_pdu->bit_len_harq&7) > 0) harq_bytes++;
uci_pdu->pduBitmap|=1;
uci_pdu->harq.harq_payload = (uint8_t*)malloc(harq_bytes);
uci_pdu->harq.harq_crc = decoderState > 0 ? 1 : 0;
int i=0;
for (;i<harq_bytes-1;i++) {
uci_pdu->harq.harq_payload[i] = decodedPayload[0] & 255;
decodedPayload[0]>>=8;
}
uci_pdu->harq.harq_payload[i] = decodedPayload[0] & ((1<<(pucch_pdu->bit_len_harq&7))-1);
decodedPayload[0] >>= pucch_pdu->bit_len_harq;
}
if (pucch_pdu->sr_flag == 1) {
uci_pdu->pduBitmap|=2;
uci_pdu->sr.sr_bit_len = 1;
uci_pdu->sr.sr_payload = malloc(1);
uci_pdu->sr.sr_payload[0] = decodedPayload[0]&1;
decodedPayload[0]>>1;
}
// csi
if (pucch_pdu->bit_len_csi_part1>0) {
uci_pdu->pduBitmap|=4;
int csi_part1_bytes=pucch_pdu->bit_len_csi_part1>>3;
if ((pucch_pdu->bit_len_csi_part1&7) > 0) csi_part1_bytes++;
uci_pdu->csi_part1.csi_part1_payload = (uint8_t*)malloc(csi_part1_bytes);
uci_pdu->csi_part1.csi_part1_crc = decoderState > 0 ? 1 : 0;
int i=0;
for (;i<csi_part1_bytes-1;i++) {
uci_pdu->csi_part1.csi_part1_payload[i] = decodedPayload[0] & 255;
decodedPayload[0]>>=8;
}
uci_pdu->csi_part1.csi_part1_payload[i] = decodedPayload[0] & ((1<<(pucch_pdu->bit_len_csi_part1&7))-1);
decodedPayload[0] >>= pucch_pdu->bit_len_csi_part1;
}
if (pucch_pdu->bit_len_csi_part2>0) {
uci_pdu->pduBitmap|=8;
}
} // n_bit > 11
} }
...@@ -798,8 +798,8 @@ void nr_generate_pucch1_old(PHY_VARS_NR_UE *ue, ...@@ -798,8 +798,8 @@ void nr_generate_pucch1_old(PHY_VARS_NR_UE *ue,
} }
#endif //0 #endif //0
inline void nr_pucch2_3_4_scrambling(uint16_t M_bit,uint16_t rnti,uint16_t n_id,uint32_t B,uint8_t *btilde) __attribute__((always_inline)); inline void nr_pucch2_3_4_scrambling(uint16_t M_bit,uint16_t rnti,uint16_t n_id,uint64_t *B64,uint8_t *btilde) __attribute__((always_inline));
inline void nr_pucch2_3_4_scrambling(uint16_t M_bit,uint16_t rnti,uint16_t n_id,uint32_t B,uint8_t *btilde) { inline void nr_pucch2_3_4_scrambling(uint16_t M_bit,uint16_t rnti,uint16_t n_id,uint64_t *B64,uint8_t *btilde) {
uint32_t x1, x2, s=0; uint32_t x1, x2, s=0;
int i; int i;
uint8_t c; uint8_t c;
...@@ -807,14 +807,26 @@ inline void nr_pucch2_3_4_scrambling(uint16_t M_bit,uint16_t rnti,uint16_t n_id, ...@@ -807,14 +807,26 @@ inline void nr_pucch2_3_4_scrambling(uint16_t M_bit,uint16_t rnti,uint16_t n_id,
//x2 = (rnti) + ((uint32_t)(1+nr_tti_tx)<<16)*(1+(fp->Nid_cell<<1)); //x2 = (rnti) + ((uint32_t)(1+nr_tti_tx)<<16)*(1+(fp->Nid_cell<<1));
x2 = ((rnti)<<15)+n_id; x2 = ((rnti)<<15)+n_id;
#ifdef DEBUG_NR_PUCCH_TX #ifdef DEBUG_NR_PUCCH_TX
printf("\t\t [nr_pucch2_3_4_scrambling] gold sequence s=%x\n",s); printf("\t\t [nr_pucch2_3_4_scrambling] gold sequence s=%x, M_bit %d\n",s,M_bit);
#endif #endif
uint8_t *btildep=btilde; uint8_t *btildep=btilde;
int M_bit2=M_bit > 31 ? 32 : (M_bit&31), M_bit3=M_bit; int M_bit2=M_bit > 31 ? 32 : (M_bit&31), M_bit3=M_bit;
uint32_t B;
for (int iprime=0;iprime<=(M_bit>>5);iprime++,btildep+=32) { for (int iprime=0;iprime<=(M_bit>>5);iprime++,btildep+=32) {
s = lte_gold_generic(&x1, &x2, (iprime==0) ? 1 : 0); s = lte_gold_generic(&x1, &x2, (iprime==0) ? 1 : 0);
B=((uint32_t*)B64)[iprime];
for (int n=0;n<M_bit2;n+=8)
LOG_D(PHY,"PUCCH2 encoded %d : %d,%d,%d,%d,%d,%d,%d,%d\n",n,
(B>>n)&1,
(B>>(n+1))&1,
(B>>(n+2))&1,
(B>>(n+3))&1,
(B>>(n+4))&1,
(B>>(n+5))&1,
(B>>(n+6))&1,
(B>>(n+7))&1
);
for (i=0; i<M_bit2; i++) { for (i=0; i<M_bit2; i++) {
c = (uint8_t)((s>>i)&1); c = (uint8_t)((s>>i)&1);
btildep[i] = (((B>>i)&1) ^ c); btildep[i] = (((B>>i)&1) ^ c);
...@@ -946,7 +958,7 @@ void nr_generate_pucch2(PHY_VARS_NR_UE *ue, ...@@ -946,7 +958,7 @@ void nr_generate_pucch2(PHY_VARS_NR_UE *ue,
printf("\t [nr_generate_pucch2] start function at slot(nr_tti_tx)=%d with payload=%lu and nr_bit=%d\n",nr_tti_tx, payload, nr_bit); printf("\t [nr_generate_pucch2] start function at slot(nr_tti_tx)=%d with payload=%lu and nr_bit=%d\n",nr_tti_tx, payload, nr_bit);
#endif #endif
// b is the block of bits transmitted on the physical channel after payload coding // b is the block of bits transmitted on the physical channel after payload coding
uint64_t b; uint64_t b[16]; // limit to 1024-bit encoded length
// M_bit is the number of bits of block b (payload after encoding) // M_bit is the number of bits of block b (payload after encoding)
uint16_t M_bit; uint16_t M_bit;
nr_uci_encoding(payload,nr_bit,pucch_format2_nr,0,nrofSymbols,nrofPRB,1,0,0,&b,&M_bit); nr_uci_encoding(payload,nr_bit,pucch_format2_nr,0,nrofSymbols,nrofPRB,1,0,0,&b,&M_bit);
......
...@@ -667,6 +667,8 @@ typedef struct PHY_VARS_gNB_s { ...@@ -667,6 +667,8 @@ typedef struct PHY_VARS_gNB_s {
NR_gNB_ULSCH_t *ulsch[NUMBER_OF_NR_ULSCH_MAX][2]; // [Nusers times][2 codewords] NR_gNB_ULSCH_t *ulsch[NUMBER_OF_NR_ULSCH_MAX][2]; // [Nusers times][2 codewords]
NR_gNB_DLSCH_t *dlsch_SI,*dlsch_ra,*dlsch_p; NR_gNB_DLSCH_t *dlsch_SI,*dlsch_ra,*dlsch_p;
NR_gNB_DLSCH_t *dlsch_PCH; NR_gNB_DLSCH_t *dlsch_PCH;
t_nrPolar_params *uci_polarParams;
uint8_t pbch_configured; uint8_t pbch_configured;
char gNB_generate_rar; char gNB_generate_rar;
......
...@@ -457,6 +457,8 @@ int main(int argc, char **argv) ...@@ -457,6 +457,8 @@ int main(int argc, char **argv)
pucch_GroupHopping_t PUCCH_GroupHopping=UE->pucch_config_common_nr->pucch_GroupHopping; pucch_GroupHopping_t PUCCH_GroupHopping=UE->pucch_config_common_nr->pucch_GroupHopping;
uint32_t hopping_id=UE->pucch_config_common_nr->hoppingId; uint32_t hopping_id=UE->pucch_config_common_nr->hoppingId;
uint32_t dmrs_scrambling_id = 0, data_scrambling_id=0; uint32_t dmrs_scrambling_id = 0, data_scrambling_id=0;
t_nrPolar_params *currentPtr;
if(format==0){ if(format==0){
// for now we are not considering SR just HARQ-ACK // for now we are not considering SR just HARQ-ACK
if (nr_bit ==0) if (nr_bit ==0)
...@@ -467,7 +469,8 @@ int main(int argc, char **argv) ...@@ -467,7 +469,8 @@ int main(int argc, char **argv)
mcs=table2_mcs[actual_payload]; mcs=table2_mcs[actual_payload];
else AssertFatal(1==0,"Either nr_bit %d or sr_flag %d must be non-zero\n"); else AssertFatal(1==0,"Either nr_bit %d or sr_flag %d must be non-zero\n");
} }
else if (format == 2 && nr_bit > 11) gNB->uci_polarParams = nr_polar_params(2, nr_bit, nrofPRB, 1, NULL);
for(SNR=snr0;SNR<=snr1;SNR=SNR+1){ for(SNR=snr0;SNR<=snr1;SNR=SNR+1){
ack_nack_errors=0; ack_nack_errors=0;
n_errors = 0; n_errors = 0;
...@@ -506,6 +509,8 @@ int main(int argc, char **argv) ...@@ -506,6 +509,8 @@ int main(int argc, char **argv)
pucch_pdu.group_hop_flag = PUCCH_GroupHopping&1; pucch_pdu.group_hop_flag = PUCCH_GroupHopping&1;
pucch_pdu.sequence_hop_flag = (PUCCH_GroupHopping>>1)&1; pucch_pdu.sequence_hop_flag = (PUCCH_GroupHopping>>1)&1;
pucch_pdu.bit_len_harq = nr_bit; pucch_pdu.bit_len_harq = nr_bit;
pucch_pdu.bit_len_csi_part1 = 0;
pucch_pdu.bit_len_csi_part2 = 0;
pucch_pdu.sr_flag = sr_flag; pucch_pdu.sr_flag = sr_flag;
pucch_pdu.nr_of_symbols = nrofSymbols; pucch_pdu.nr_of_symbols = nrofSymbols;
pucch_pdu.hopping_id = hopping_id; pucch_pdu.hopping_id = hopping_id;
...@@ -534,7 +539,9 @@ int main(int argc, char **argv) ...@@ -534,7 +539,9 @@ int main(int argc, char **argv)
pucch_pdu.subcarrier_spacing = 1; pucch_pdu.subcarrier_spacing = 1;
pucch_pdu.group_hop_flag = PUCCH_GroupHopping&1; pucch_pdu.group_hop_flag = PUCCH_GroupHopping&1;
pucch_pdu.sequence_hop_flag = (PUCCH_GroupHopping>>1)&1; pucch_pdu.sequence_hop_flag = (PUCCH_GroupHopping>>1)&1;
pucch_pdu.bit_len_harq = nr_bit; pucch_pdu.bit_len_csi_part1 = nr_bit;
pucch_pdu.bit_len_harq = 0;
pucch_pdu.bit_len_csi_part2 = 0;
pucch_pdu.sr_flag = 0; pucch_pdu.sr_flag = 0;
pucch_pdu.nr_of_symbols = nrofSymbols; pucch_pdu.nr_of_symbols = nrofSymbols;
pucch_pdu.hopping_id = hopping_id; pucch_pdu.hopping_id = hopping_id;
...@@ -545,14 +552,15 @@ int main(int argc, char **argv) ...@@ -545,14 +552,15 @@ int main(int argc, char **argv)
pucch_pdu.dmrs_scrambling_id = dmrs_scrambling_id; pucch_pdu.dmrs_scrambling_id = dmrs_scrambling_id;
pucch_pdu.data_scrambling_id = data_scrambling_id; pucch_pdu.data_scrambling_id = data_scrambling_id;
nr_decode_pucch2(gNB,nr_tti_tx,&uci_pdu,&pucch_pdu); nr_decode_pucch2(gNB,nr_tti_tx,&uci_pdu,&pucch_pdu);
int harq_bytes=pucch_pdu.bit_len_harq>>3; int csi_part1_bytes=pucch_pdu.bit_len_csi_part1>>3;
if ((pucch_pdu.bit_len_harq&7) > 0) harq_bytes++; if ((pucch_pdu.bit_len_csi_part1&7) > 0) csi_part1_bytes++;
for (int i=0;i<harq_bytes;i++) for (int i=0;i<csi_part1_bytes;i++) {
if (uci_pdu.harq.harq_payload[i] != ((int8_t*)&actual_payload)[i]) { if (uci_pdu.csi_part1.csi_part1_payload[i] != ((uint8_t*)&actual_payload)[i]) {
ack_nack_errors++; ack_nack_errors++;
break; break;
} }
free(uci_pdu.harq.harq_payload); }
free(uci_pdu.csi_part1.csi_part1_payload);
} }
n_errors=((actual_payload^payload_received)&1)+(((actual_payload^payload_received)&2)>>1)+(((actual_payload^payload_received)&4)>>2)+n_errors; n_errors=((actual_payload^payload_received)&1)+(((actual_payload^payload_received)&2)>>1)+(((actual_payload^payload_received)&4)>>2)+n_errors;
......
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