Improve code readability and fix the nr_polar_params() function
This commit is contained in:
@@ -85,10 +85,8 @@ static void nr_polar_delete(void) {
|
||||
pthread_mutex_unlock(&PolarListMutex);
|
||||
}
|
||||
|
||||
t_nrPolar_params * nr_polar_params(int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level,
|
||||
int decoder_flag) {
|
||||
t_nrPolar_params *nr_polar_params(int8_t messageType, uint16_t messageLength, uint8_t aggregation_level, int decoder_flag)
|
||||
{
|
||||
// The lock is weak, because we never delete in the list, only at exit time
|
||||
// therefore, returning t_nrPolar_params * from the list is safe for future usage
|
||||
pthread_mutex_lock(&PolarListMutex);
|
||||
@@ -123,8 +121,8 @@ t_nrPolar_params * nr_polar_params(int8_t messageType,
|
||||
newPolarInitNode->idx = PolarKey;
|
||||
newPolarInitNode->nextPtr = NULL;
|
||||
//printf("newPolarInitNode->idx %d, (%d,%d,%d:%d)\n",newPolarInitNode->idx,messageType,messageLength,aggregation_prime,aggregation_level);
|
||||
|
||||
if (messageType == 0) { //PBCH
|
||||
|
||||
if (messageType == NR_POLAR_PBCH_MESSAGE_TYPE) {
|
||||
newPolarInitNode->n_max = NR_POLAR_PBCH_N_MAX;
|
||||
newPolarInitNode->i_il = NR_POLAR_PBCH_I_IL;
|
||||
newPolarInitNode->i_seg = NR_POLAR_PBCH_I_SEG;
|
||||
@@ -135,9 +133,10 @@ t_nrPolar_params * nr_polar_params(int8_t messageType,
|
||||
newPolarInitNode->payloadBits = NR_POLAR_PBCH_PAYLOAD_BITS;
|
||||
newPolarInitNode->encoderLength = NR_POLAR_PBCH_E;
|
||||
newPolarInitNode->crcCorrectionBits = NR_POLAR_PBCH_CRC_ERROR_CORRECTION_BITS;
|
||||
newPolarInitNode->crc_generator_matrix = crc24c_generator_matrix(newPolarInitNode->payloadBits);//G_P
|
||||
newPolarInitNode->crc_generator_matrix = crc24c_generator_matrix(newPolarInitNode->payloadBits); // G_P
|
||||
//printf("Initializing polar parameters for PBCH (K %d, E %d)\n",newPolarInitNode->payloadBits,newPolarInitNode->encoderLength);
|
||||
} else if (messageType == 1) { //DCI
|
||||
|
||||
} else if (messageType == NR_POLAR_DCI_MESSAGE_TYPE) {
|
||||
newPolarInitNode->n_max = NR_POLAR_DCI_N_MAX;
|
||||
newPolarInitNode->i_il = NR_POLAR_DCI_I_IL;
|
||||
newPolarInitNode->i_seg = NR_POLAR_DCI_I_SEG;
|
||||
@@ -146,40 +145,55 @@ t_nrPolar_params * nr_polar_params(int8_t messageType,
|
||||
newPolarInitNode->i_bil = NR_POLAR_DCI_I_BIL;
|
||||
newPolarInitNode->crcParityBits = NR_POLAR_DCI_CRC_PARITY_BITS;
|
||||
newPolarInitNode->payloadBits = messageLength;
|
||||
newPolarInitNode->encoderLength = aggregation_level*108;
|
||||
newPolarInitNode->encoderLength = aggregation_level * 108;
|
||||
newPolarInitNode->crcCorrectionBits = NR_POLAR_DCI_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
|
||||
//printf("Initializing polar parameters for DCI (K %d, E %d, L %d)\n",newPolarInitNode->payloadBits,newPolarInitNode->encoderLength,aggregation_level);
|
||||
} else if (messageType == 2) { //UCI PUCCH2
|
||||
AssertFatal(aggregation_level>2,"Aggregation level (%d) for PUCCH 2 encoding is NPRB and should be > 2\n",aggregation_level);
|
||||
AssertFatal(messageLength>11,"Message length %d is too short for polar encoding of UCI\n",messageLength);
|
||||
newPolarInitNode->n_max = NR_POLAR_PUCCH_N_MAX;
|
||||
newPolarInitNode->i_il = NR_POLAR_PUCCH_I_IL;
|
||||
|
||||
} else if (messageType == NR_POLAR_UCI_PUCCH_MESSAGE_TYPE) {
|
||||
AssertFatal(aggregation_level > 2, "Aggregation level (%d) for PUCCH 2 encoding is NPRB and should be > 2\n", aggregation_level);
|
||||
AssertFatal(messageLength > 11, "Message length %d is too short for polar encoding of UCI\n", messageLength);
|
||||
|
||||
// TS 38.212 - Section 6.3.1.2.1 UCI encoded by Polar code
|
||||
int L = 0;
|
||||
if (messageLength >= 12 && messageLength <= 19) {
|
||||
L = 6;
|
||||
} else if (messageLength >= 20) {
|
||||
L = 11;
|
||||
} else {
|
||||
AssertFatal(1 == 0, "L = %i is an invalid value\n", L);
|
||||
}
|
||||
newPolarInitNode->encoderLength = aggregation_level * 16;
|
||||
|
||||
newPolarInitNode->i_seg = 0;
|
||||
|
||||
if ((messageLength >= 360 && newPolarInitNode->encoderLength >= 1088)||
|
||||
(messageLength >= 1013)) newPolarInitNode->i_seg = 1;
|
||||
|
||||
newPolarInitNode->crcParityBits = 11;
|
||||
newPolarInitNode->n_pc = 0;
|
||||
newPolarInitNode->n_pc_wm = 0;
|
||||
|
||||
if (messageLength < 20) {
|
||||
newPolarInitNode->crcParityBits = 6;
|
||||
newPolarInitNode->n_pc = 3;
|
||||
if ((newPolarInitNode->encoderLength - messageLength - 6 + 3) < 193) newPolarInitNode->n_pc_wm = 1;
|
||||
if ((messageLength >= 360 && newPolarInitNode->encoderLength >= 1088) || (messageLength >= 1013)) {
|
||||
newPolarInitNode->i_seg = 1;
|
||||
AssertFatal(1 == 0, "Segmentation is not supported yet (i_seg = %i)\n", newPolarInitNode->i_seg);
|
||||
}
|
||||
|
||||
|
||||
// TS 38.212 - Section 6.3.1.3.1 UCI encoded by Polar code
|
||||
newPolarInitNode->n_max = NR_POLAR_PUCCH_N_MAX;
|
||||
newPolarInitNode->i_il = NR_POLAR_PUCCH_I_IL;
|
||||
newPolarInitNode->crcParityBits = L;
|
||||
int Kr = messageLength + L;
|
||||
if (Kr >= 18 && Kr <= 25) {
|
||||
newPolarInitNode->n_pc = 3;
|
||||
if ((newPolarInitNode->encoderLength - Kr + 3) > 192) {
|
||||
newPolarInitNode->n_pc_wm = 1;
|
||||
} else {
|
||||
newPolarInitNode->n_pc_wm = 0;
|
||||
}
|
||||
} else if (Kr > 30) {
|
||||
newPolarInitNode->n_pc = 0;
|
||||
newPolarInitNode->n_pc_wm = 0;
|
||||
} else {
|
||||
AssertFatal(1 == 0, "Kr = %i is an invalid value\n", Kr);
|
||||
}
|
||||
|
||||
newPolarInitNode->i_bil = NR_POLAR_PUCCH_I_BIL;
|
||||
|
||||
newPolarInitNode->payloadBits = messageLength;
|
||||
newPolarInitNode->crcCorrectionBits = NR_POLAR_PUCCH_CRC_ERROR_CORRECTION_BITS;
|
||||
//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 {
|
||||
AssertFatal(1 == 0, "[nr_polar_init] Incorrect Message Type(%d)", messageType);
|
||||
}
|
||||
|
||||
@@ -1704,8 +1704,10 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
|
||||
((int16_t*)&llrs[half_prb])[7]);
|
||||
} // half_prb
|
||||
} // symb
|
||||
|
||||
// run polar decoder on llrs
|
||||
decoderState = polar_decoder_int16((int16_t*)llrs, decodedPayload, 0, 2,nb_bit,pucch_pdu->prb_size);
|
||||
decoderState = polar_decoder_int16((int16_t *)llrs, decodedPayload, 0, NR_POLAR_UCI_PUCCH_MESSAGE_TYPE, nb_bit, pucch_pdu->prb_size);
|
||||
|
||||
LOG_D(PHY,"UCI decoderState %d, payload[0] %llu\n",decoderState,(unsigned long long)decodedPayload[0]);
|
||||
if (decoderState>0) decoderState=1;
|
||||
corr_dB = dB_fixed64(corr);
|
||||
|
||||
Reference in New Issue
Block a user