simplify polar codec interface
This commit is contained in:
@@ -176,7 +176,7 @@ if (logFlag){
|
||||
double channelOutput[coderLength]; //add noise
|
||||
int16_t channelOutput_int16[coderLength];
|
||||
|
||||
t_nrPolar_params *currentPtr = nr_polar_params(polarMessageType, testLength, aggregation_level, 1, NULL);
|
||||
t_nrPolar_params *currentPtr = nr_polar_params(polarMessageType, testLength, aggregation_level, true);
|
||||
|
||||
#ifdef DEBUG_DCI_POLAR_PARAMS
|
||||
uint32_t dci_pdu[4];
|
||||
@@ -211,7 +211,8 @@ if (logFlag){
|
||||
modulated_input[i]=(-1)/sqrt(2);
|
||||
channel_output[i] = modulated_input[i] + (gaussdouble(0.0,1.0) * (1/sqrt(2*SNR_lin)));
|
||||
}
|
||||
decoderState = polar_decoder_dci(channel_output, dci_est, currentPtrDCI, NR_POLAR_DECODER_LISTSIZE, rnti);
|
||||
decoderState = polar_decoder_dci(channel_output, dci_est, NR_POLAR_DECODER_LISTSIZE, rnti,
|
||||
1, size, aggregation_level);
|
||||
printf("dci_est: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", dci_est[0], dci_est[1], dci_est[2], dci_est[3]);
|
||||
free(encoder_outputByte);
|
||||
free(channel_output);
|
||||
@@ -244,13 +245,13 @@ if (logFlag){
|
||||
|
||||
start_meas(&timeEncoder);
|
||||
if (decoder_int16==1) {
|
||||
polar_encoder_fast((uint64_t *)testInput, encoderOutput, 0, 0, currentPtr);
|
||||
polar_encoder_fast((uint64_t *)testInput, encoderOutput, 0, 0, polarMessageType, testLength, aggregation_level);
|
||||
//polar_encoder_fast((uint64_t*)testInput, (uint64_t*)encoderOutput,0,0,currentPtr);
|
||||
} else { //0 --> PBCH, 1 --> DCI, -1 --> UCI
|
||||
if (polarMessageType == 0)
|
||||
polar_encoder(testInput, encoderOutput, currentPtr);
|
||||
polar_encoder(testInput, encoderOutput, polarMessageType, testLength, aggregation_level);
|
||||
else if (polarMessageType == 1)
|
||||
polar_encoder_dci(testInput, encoderOutput, currentPtr, rnti);
|
||||
polar_encoder_dci(testInput, encoderOutput, rnti, polarMessageType, testLength, aggregation_level);
|
||||
}
|
||||
stop_meas(&timeEncoder);
|
||||
|
||||
@@ -281,19 +282,20 @@ if (logFlag){
|
||||
start_meas(&timeDecoder);
|
||||
|
||||
if (decoder_int16==1) {
|
||||
decoderState = polar_decoder_int16(channelOutput_int16, (uint64_t *)estimatedOutput, 0, currentPtr);
|
||||
decoderState = polar_decoder_int16(channelOutput_int16, (uint64_t *)estimatedOutput, 0,
|
||||
polarMessageType, testLength, aggregation_level);
|
||||
} else { //0 --> PBCH, 1 --> DCI, -1 --> UCI
|
||||
if (polarMessageType == 0) {
|
||||
decoderState = polar_decoder(channelOutput,
|
||||
estimatedOutput,
|
||||
currentPtr,
|
||||
decoderListSize);
|
||||
decoderState = polar_decoder(channelOutput,
|
||||
estimatedOutput,
|
||||
decoderListSize,
|
||||
polarMessageType, testLength, aggregation_level);
|
||||
} else if (polarMessageType == 1) {
|
||||
decoderState = polar_decoder_dci(channelOutput,
|
||||
estimatedOutput,
|
||||
currentPtr,
|
||||
decoderListSize,
|
||||
rnti);
|
||||
decoderState = polar_decoder_dci(channelOutput,
|
||||
estimatedOutput,
|
||||
decoderListSize,
|
||||
rnti,
|
||||
polarMessageType, testLength, aggregation_level);
|
||||
}
|
||||
}
|
||||
stop_meas(&timeDecoder);
|
||||
@@ -362,6 +364,5 @@ if (logFlag){
|
||||
print_meas(&timeEncoder,"polar_encoder",NULL,NULL);
|
||||
print_meas(&timeDecoder,"polar_decoder",NULL,NULL);
|
||||
if (logFlag) fclose(logFile);
|
||||
nr_polar_delete(currentPtr);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -58,9 +58,13 @@ static inline void updateCrcChecksum2(int xlen,
|
||||
|
||||
int8_t polar_decoder(double *input,
|
||||
uint32_t *out,
|
||||
const t_nrPolar_params *polarParams,
|
||||
uint8_t listSize)
|
||||
uint8_t listSize,
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level
|
||||
)
|
||||
{
|
||||
const t_nrPolar_params *polarParams=nr_polar_params(messageType, messageLength, aggregation_level, true);
|
||||
//Assumes no a priori knowledge.
|
||||
uint8_t bit[polarParams->N][polarParams->n+1][2*listSize];
|
||||
memset(bit,0,sizeof bit);
|
||||
@@ -302,9 +306,13 @@ int8_t polar_decoder(double *input,
|
||||
|
||||
int8_t polar_decoder_dci(double *input,
|
||||
uint32_t *out,
|
||||
const t_nrPolar_params *polarParams,
|
||||
uint8_t listSize,
|
||||
uint16_t n_RNTI) {
|
||||
uint16_t n_RNTI,
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level ) {
|
||||
const t_nrPolar_params *polarParams=nr_polar_params(messageType, messageLength, aggregation_level, true);
|
||||
|
||||
uint8_t bit[polarParams->N][polarParams->n+1][2*listSize];
|
||||
memset(bit,0,sizeof bit);
|
||||
uint8_t bitUpdated[polarParams->N][polarParams->n+1]; //0=False, 1=True
|
||||
@@ -596,8 +604,11 @@ void init_polar_deinterleaver_table(t_nrPolar_params *polarParams) {
|
||||
uint32_t polar_decoder_int16(int16_t *input,
|
||||
uint64_t *out,
|
||||
uint8_t ones_flag,
|
||||
const t_nrPolar_params *polarParams)
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level )
|
||||
{
|
||||
const t_nrPolar_params *polarParams=nr_polar_params(messageType, messageLength, aggregation_level, true);
|
||||
int16_t d_tilde[polarParams->N];// = malloc(sizeof(double) * polarParams->N);
|
||||
nr_polar_rate_matching_int16(input, d_tilde, polarParams->rate_matching_pattern, polarParams->K, polarParams->N, polarParams->encoderLength);
|
||||
|
||||
|
||||
@@ -79,9 +79,9 @@ typedef struct decoder_tree_t_s {
|
||||
|
||||
struct nrPolar_params {
|
||||
//messageType: 0=PBCH, 1=DCI, -1=UCI
|
||||
int idx; //idx = (messageType * messageLength * aggregation_prime);
|
||||
struct nrPolar_params *nextPtr;
|
||||
|
||||
struct nrPolar_params *nextPtr __attribute__((aligned(16)));
|
||||
uint32_t idx;
|
||||
uint8_t n_max;
|
||||
uint8_t i_il;
|
||||
uint8_t i_seg;
|
||||
@@ -138,34 +138,46 @@ typedef struct nrPolar_params t_nrPolar_params;
|
||||
|
||||
void polar_encoder(uint32_t *input,
|
||||
uint32_t *output,
|
||||
const t_nrPolar_params *polarParams);
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level);
|
||||
|
||||
void polar_encoder_dci(uint32_t *in,
|
||||
uint32_t *out,
|
||||
const t_nrPolar_params *polarParams,
|
||||
uint16_t n_RNTI);
|
||||
uint16_t n_RNTI,
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level);
|
||||
|
||||
void polar_encoder_fast(uint64_t *A,
|
||||
void *out,
|
||||
int32_t crcmask,
|
||||
uint8_t ones_flag,
|
||||
const t_nrPolar_params *polarParams);
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level);
|
||||
|
||||
int8_t polar_decoder(double *input,
|
||||
uint32_t *output,
|
||||
const t_nrPolar_params *polarParams,
|
||||
uint8_t listSize);
|
||||
uint8_t listSize,
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level);
|
||||
|
||||
uint32_t polar_decoder_int16(int16_t *input,
|
||||
uint64_t *out,
|
||||
uint8_t ones_flag,
|
||||
const t_nrPolar_params *polarParams);
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level);
|
||||
|
||||
int8_t polar_decoder_dci(double *input,
|
||||
uint32_t *out,
|
||||
const t_nrPolar_params *polarParams,
|
||||
uint8_t listSize,
|
||||
uint16_t n_RNTI);
|
||||
uint16_t n_RNTI,
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level);
|
||||
|
||||
void generic_polar_decoder(const t_nrPolar_params *pp,
|
||||
decoder_node_t *node);
|
||||
@@ -183,13 +195,12 @@ void build_decoder_tree(t_nrPolar_params *pp);
|
||||
void build_polar_tables(t_nrPolar_params *polarParams);
|
||||
void init_polar_deinterleaver_table(t_nrPolar_params *polarParams);
|
||||
|
||||
void nr_polar_print_polarParams(t_nrPolar_params *polarParams);
|
||||
void nr_polar_print_polarParams(void);
|
||||
|
||||
t_nrPolar_params *nr_polar_params (int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level,
|
||||
int decoder_flag,
|
||||
t_nrPolar_params **polarList_ext);
|
||||
int decoder_flag);
|
||||
|
||||
uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level);
|
||||
|
||||
@@ -333,5 +344,4 @@ static inline void nr_polar_deinterleaver(uint8_t *input,
|
||||
for (int i=0; i<size; i++) output[pattern[i]]=input[i];
|
||||
}
|
||||
void delete_decoder_tree(t_nrPolar_params *);
|
||||
void nr_polar_delete(t_nrPolar_params *);
|
||||
#endif
|
||||
|
||||
@@ -43,7 +43,10 @@
|
||||
|
||||
void polar_encoder(uint32_t *in,
|
||||
uint32_t *out,
|
||||
const t_nrPolar_params *polarParams) {
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level) {
|
||||
const t_nrPolar_params *polarParams=nr_polar_params(messageType, messageLength, aggregation_level, false);
|
||||
if (1) {//polarParams->idx == 0 || polarParams->idx == 1) { //PBCH or PDCCH
|
||||
/*
|
||||
uint64_t B = (((uint64_t)*in)&((((uint64_t)1)<<32)-1)) | (((uint64_t)crc24c((uint8_t*)in,polarParams->payloadBits)>>8)<<polarParams->payloadBits);
|
||||
@@ -154,8 +157,12 @@ void polar_encoder(uint32_t *in,
|
||||
|
||||
void polar_encoder_dci(uint32_t *in,
|
||||
uint32_t *out,
|
||||
const t_nrPolar_params *polarParams,
|
||||
uint16_t n_RNTI) {
|
||||
uint16_t n_RNTI,
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level) {
|
||||
const t_nrPolar_params *polarParams=nr_polar_params(messageType, messageLength, aggregation_level, false);
|
||||
|
||||
#ifdef DEBUG_POLAR_ENCODER_DCI
|
||||
printf("[polar_encoder_dci] in: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", in[0], in[1], in[2], in[3]);
|
||||
#endif
|
||||
@@ -418,7 +425,11 @@ void polar_encoder_fast(uint64_t *A,
|
||||
void *out,
|
||||
int32_t crcmask,
|
||||
uint8_t ones_flag,
|
||||
const t_nrPolar_params *polarParams) {
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level) {
|
||||
|
||||
const t_nrPolar_params *polarParams=nr_polar_params(messageType, messageLength, aggregation_level, false);
|
||||
// AssertFatal(polarParams->K > 32, "K = %d < 33, is not supported yet\n",polarParams->K);
|
||||
AssertFatal(polarParams->K < 129, "K = %d > 128, is not supported yet\n",polarParams->K);
|
||||
AssertFatal(polarParams->payloadBits < 65, "payload bits = %d > 64, is not supported yet\n",polarParams->payloadBits);
|
||||
|
||||
@@ -33,10 +33,20 @@
|
||||
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
|
||||
#include "PHY/NR_TRANSPORT/nr_dci.h"
|
||||
|
||||
#define PolarKey ((messageType<<24)|(messageLength<<8)|aggregation_level)
|
||||
static t_nrPolar_params * PolarList=NULL;
|
||||
static pthread_mutex_t PolarListMutex=PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static int intcmp(const void *p1,const void *p2) {
|
||||
return(*(int16_t *)p1 > *(int16_t *)p2);
|
||||
}
|
||||
void nr_polar_delete(t_nrPolar_params * polarParams) {
|
||||
|
||||
static void nr_polar_delete_list(t_nrPolar_params * polarParams) {
|
||||
if (!polarParams)
|
||||
return;
|
||||
if (polarParams->nextPtr)
|
||||
nr_polar_delete_list(polarParams->nextPtr);
|
||||
|
||||
delete_decoder_tree(polarParams);
|
||||
//From build_polar_tables()
|
||||
for (int k=0; k < polarParams->K + polarParams->n_pc; k++)
|
||||
@@ -68,20 +78,36 @@ void nr_polar_delete(t_nrPolar_params * polarParams) {
|
||||
free(polarParams);
|
||||
}
|
||||
|
||||
static void nr_polar_init(t_nrPolar_params * *polarParams,
|
||||
int8_t messageType,
|
||||
static void nr_polar_delete(void) {
|
||||
pthread_mutex_lock(&PolarListMutex);
|
||||
nr_polar_delete_list(PolarList);
|
||||
PolarList=NULL;
|
||||
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 *currentPtr = *polarParams;
|
||||
uint16_t aggregation_prime = (messageType >= 2) ? aggregation_level : nr_polar_aggregation_prime(aggregation_level);
|
||||
|
||||
// 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);
|
||||
if(!PolarList)
|
||||
atexit(nr_polar_delete);
|
||||
|
||||
t_nrPolar_params *currentPtr = PolarList;
|
||||
//Parse the list. If the node is already created, return without initialization.
|
||||
while (currentPtr != NULL) {
|
||||
//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;
|
||||
else currentPtr = currentPtr->nextPtr;
|
||||
if (currentPtr->idx == PolarKey ) {
|
||||
if (decoder_flag && !currentPtr->tree.root)
|
||||
build_decoder_tree(currentPtr);
|
||||
pthread_mutex_unlock(&PolarListMutex);
|
||||
return currentPtr ;
|
||||
}
|
||||
else
|
||||
currentPtr = currentPtr->nextPtr;
|
||||
}
|
||||
|
||||
// printf("currentPtr %p (polarParams %p)\n",currentPtr,polarParams);
|
||||
@@ -90,7 +116,7 @@ static void nr_polar_init(t_nrPolar_params * *polarParams,
|
||||
|
||||
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 = PolarKey;
|
||||
newPolarInitNode->nextPtr = NULL;
|
||||
//printf("newPolarInitNode->idx %d, (%d,%d,%d:%d)\n",newPolarInitNode->idx,messageType,messageLength,aggregation_prime,aggregation_level);
|
||||
|
||||
@@ -212,7 +238,8 @@ static void nr_polar_init(t_nrPolar_params * *polarParams,
|
||||
nr_polar_channel_interleaver_pattern(newPolarInitNode->channel_interleaver_pattern,
|
||||
newPolarInitNode->i_bil,
|
||||
newPolarInitNode->encoderLength);
|
||||
if (decoder_flag == 1) build_decoder_tree(newPolarInitNode);
|
||||
if (decoder_flag == 1)
|
||||
build_decoder_tree(newPolarInitNode);
|
||||
build_polar_tables(newPolarInitNode);
|
||||
init_polar_deinterleaver_table(newPolarInitNode);
|
||||
//printf("decoder tree nodes %d\n",newPolarInitNode->tree.num_nodes);
|
||||
@@ -220,21 +247,22 @@ static void nr_polar_init(t_nrPolar_params * *polarParams,
|
||||
AssertFatal(1 == 0, "[nr_polar_init] New t_nrPolar_params * could not be created");
|
||||
}
|
||||
|
||||
//Fixme: the list is not thread safe
|
||||
//The defect is not critical: we always append (never delete items) and adding two times the same is fine
|
||||
newPolarInitNode->nextPtr=*polarParams;
|
||||
*polarParams=newPolarInitNode;
|
||||
return;
|
||||
newPolarInitNode->nextPtr=PolarList;
|
||||
PolarList=newPolarInitNode;
|
||||
pthread_mutex_unlock(&PolarListMutex);
|
||||
return newPolarInitNode;
|
||||
}
|
||||
|
||||
void nr_polar_print_polarParams(t_nrPolar_params *polarParams) {
|
||||
void nr_polar_print_polarParams() {
|
||||
uint8_t i = 0;
|
||||
|
||||
if (polarParams == NULL) {
|
||||
if (PolarList == NULL) {
|
||||
printf("polarParams is empty.\n");
|
||||
} else {
|
||||
t_nrPolar_params * polarParams=PolarList;
|
||||
while (polarParams != NULL) {
|
||||
printf("polarParams[%d] = %d\n", i, polarParams->idx);
|
||||
printf("polarParams[%d] = %d, %d, %d\n", i,
|
||||
polarParams->idx>>24, (polarParams->idx>>8)&0xFFFF, polarParams->idx&0xFF);
|
||||
polarParams = polarParams->nextPtr;
|
||||
i++;
|
||||
}
|
||||
@@ -243,31 +271,6 @@ void nr_polar_print_polarParams(t_nrPolar_params *polarParams) {
|
||||
return;
|
||||
}
|
||||
|
||||
t_nrPolar_params *nr_polar_params (int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level,
|
||||
int decoding_flag,
|
||||
t_nrPolar_params **polarList_ext) {
|
||||
static t_nrPolar_params *polarList = NULL;
|
||||
nr_polar_init(polarList_ext != NULL ? polarList_ext : &polarList,
|
||||
messageType,messageLength,aggregation_level,decoding_flag);
|
||||
t_nrPolar_params *polarParams=polarList_ext != NULL ? *polarList_ext : polarList;
|
||||
const int tag=messageType * messageLength * (messageType>=2 ? aggregation_level : nr_polar_aggregation_prime(aggregation_level));
|
||||
|
||||
|
||||
|
||||
while (polarParams != NULL) {
|
||||
// LOG_D(PHY,"nr_polar_params : tag %d (from nr_polar_init %d)\n",tag,polarParams->idx);
|
||||
if (polarParams->idx == tag)
|
||||
return polarParams;
|
||||
|
||||
polarParams = polarParams->nextPtr;
|
||||
}
|
||||
|
||||
AssertFatal(false,"Polar Init tables internal failure, no polarParams found\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level) {
|
||||
if (aggregation_level == 0) return 0;
|
||||
else if (aggregation_level == 1) return NR_POLAR_AGGREGATION_LEVEL_1_PRIME;
|
||||
|
||||
@@ -130,11 +130,8 @@ void nr_generate_dci(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15,
|
||||
uint16_t Nid = dci_pdu->ScramblingId;
|
||||
uint16_t scrambling_RNTI = dci_pdu->ScramblingRNTI;
|
||||
|
||||
t_nrPolar_params *currentPtr = nr_polar_params(NR_POLAR_DCI_MESSAGE_TYPE,
|
||||
dci_pdu->PayloadSizeBits,
|
||||
dci_pdu->AggregationLevel,
|
||||
0,NULL);
|
||||
polar_encoder_fast((uint64_t*)dci_pdu->Payload, (void*)encoder_output, n_RNTI,1,currentPtr);
|
||||
polar_encoder_fast((uint64_t*)dci_pdu->Payload, (void*)encoder_output, n_RNTI, 1,
|
||||
NR_POLAR_DCI_MESSAGE_TYPE, dci_pdu->PayloadSizeBits, dci_pdu->AggregationLevel);
|
||||
#ifdef DEBUG_CHANNEL_CODING
|
||||
printf("polar rnti %x,length %d, L %d\n",n_RNTI, dci_pdu->PayloadSizeBits,pdcch_pdu_rel15->dci_pdu->AggregationLevel);
|
||||
printf("DCI PDU: [0]->0x%lx \t [1]->0x%lx\n",
|
||||
|
||||
@@ -298,9 +298,8 @@ int nr_generate_pbch(nfapi_nr_dl_tti_ssb_pdu *ssb_pdu,
|
||||
a_reversed |= (((uint64_t)pbch->pbch_a_prime>>i)&1)<<(31-i);
|
||||
|
||||
/// CRC, coding and rate matching
|
||||
t_nrPolar_params* polar = nr_polar_params(NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL, 0, NULL);
|
||||
polar_encoder_fast (&a_reversed, (void*)pbch->pbch_e, 0, 0, polar);
|
||||
nr_polar_delete(polar);
|
||||
polar_encoder_fast (&a_reversed, (void*)pbch->pbch_e, 0, 0,
|
||||
NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL);
|
||||
|
||||
#ifdef DEBUG_PBCH_ENCODING
|
||||
printf("Channel coding:\n");
|
||||
|
||||
@@ -1538,7 +1538,6 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
|
||||
}
|
||||
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][2];
|
||||
__m64 *rp2_re[Prx2][2];
|
||||
__m64 *rp_im[Prx2][2];
|
||||
@@ -1665,7 +1664,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
|
||||
} // half_prb
|
||||
} // symb
|
||||
// run polar decoder on llrs
|
||||
decoderState = polar_decoder_int16((int16_t*)llrs, decodedPayload, 0, currentPtr);
|
||||
decoderState = polar_decoder_int16((int16_t*)llrs, decodedPayload, 0, 2,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);
|
||||
|
||||
@@ -832,14 +832,18 @@ void nr_pdcch_unscrambling(int16_t *z,
|
||||
/* This function compares the received DCI bits with
|
||||
* re-encoded DCI bits and returns the number of mismatched bits
|
||||
*/
|
||||
uint16_t nr_dci_false_detection(uint64_t *dci,
|
||||
int16_t *soft_in,
|
||||
const t_nrPolar_params *polar_param,
|
||||
int encoded_length,
|
||||
int rnti) {
|
||||
static uint16_t nr_dci_false_detection(uint64_t *dci,
|
||||
int16_t *soft_in,
|
||||
int encoded_length,
|
||||
int rnti,
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level
|
||||
) {
|
||||
|
||||
uint32_t encoder_output[NR_MAX_DCI_SIZE_DWORD];
|
||||
polar_encoder_fast(dci, (void*)encoder_output, rnti, 1, (t_nrPolar_params *)polar_param);
|
||||
polar_encoder_fast(dci, (void*)encoder_output, rnti, 1,
|
||||
messageType, messageLength, aggregation_level);
|
||||
uint8_t *enout_p = (uint8_t*)encoder_output;
|
||||
uint16_t x = 0;
|
||||
|
||||
@@ -886,7 +890,6 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
|
||||
if (dci_found==1) continue;
|
||||
int dci_length = rel15->dci_length_options[k];
|
||||
uint64_t dci_estimation[2]= {0};
|
||||
const t_nrPolar_params *currentPtrDCI = nr_polar_params(NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L, 1, &ue->polarList);
|
||||
|
||||
LOG_D(PHY, "Trying DCI candidate %d of %d number of candidates, CCE %d (%d), L %d, length %d, format %s\n",
|
||||
j, rel15->number_of_candidates, CCEind, CCEind*9*6*2, L, dci_length,nr_dci_format_string[rel15->dci_format_options[k]]);
|
||||
@@ -901,11 +904,10 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
uint16_t crc = polar_decoder_int16(tmp_e,
|
||||
dci_estimation,
|
||||
1,
|
||||
currentPtrDCI);
|
||||
NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L);
|
||||
|
||||
n_rnti = rel15->rnti;
|
||||
LOG_D(PHY, "(%i.%i) dci indication (rnti %x,dci format %s,n_CCE %d,payloadSize %d)\n",
|
||||
@@ -913,7 +915,7 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
|
||||
if (crc == n_rnti) {
|
||||
LOG_D(PHY, "(%i.%i) Received dci indication (rnti %x,dci format %s,n_CCE %d,payloadSize %d,payload %llx)\n",
|
||||
proc->frame_rx, proc->nr_slot_rx,n_rnti,nr_dci_format_string[rel15->dci_format_options[k]],CCEind,dci_length,*(unsigned long long*)dci_estimation);
|
||||
uint16_t mb = nr_dci_false_detection(dci_estimation,tmp_e,currentPtrDCI,L*108,n_rnti);
|
||||
uint16_t mb = nr_dci_false_detection(dci_estimation,tmp_e,L*108,n_rnti, NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L);
|
||||
ue->dci_thres = (ue->dci_thres + mb) / 2;
|
||||
if (mb > (ue->dci_thres+20)) {
|
||||
LOG_W(PHY,"DCI false positive. Dropping DCI index %d. Mismatched bits: %d/%d. Current DCI threshold: %d\n",j,mb,L*108,ue->dci_thres);
|
||||
|
||||
@@ -533,9 +533,8 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
|
||||
|
||||
nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_E,0,0);
|
||||
//polar decoding de-rate matching
|
||||
t_nrPolar_params *currentPtr = nr_polar_params( NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL,1,&ue->polarList);
|
||||
decoderState = polar_decoder_int16(pbch_e_rx,(uint64_t *)&nr_ue_pbch_vars->pbch_a_prime,0,currentPtr);
|
||||
nr_polar_delete(currentPtr);
|
||||
decoderState = polar_decoder_int16(pbch_e_rx,(uint64_t *)&nr_ue_pbch_vars->pbch_a_prime,0,
|
||||
NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL);
|
||||
|
||||
if(decoderState) return(decoderState);
|
||||
|
||||
@@ -602,12 +601,12 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
|
||||
#endif
|
||||
|
||||
nr_downlink_indication_t dl_indication;
|
||||
fapi_nr_rx_indication_t rx_ind;
|
||||
memset(&rx_ind, 0, sizeof(rx_ind));
|
||||
//Fixme: on the heap to please the mandatory free in nr_ue_ul_indication()
|
||||
fapi_nr_rx_indication_t *rx_ind=calloc(sizeof(*rx_ind),1);
|
||||
uint16_t number_pdus = 1;
|
||||
|
||||
nr_fill_dl_indication(&dl_indication, NULL, &rx_ind, proc, ue, gNB_id);
|
||||
nr_fill_rx_indication(&rx_ind, FAPI_NR_RX_PDU_TYPE_SSB, gNB_id, ue, NULL, NULL, number_pdus, proc);
|
||||
nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id);
|
||||
nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_SSB, gNB_id, ue, NULL, NULL, number_pdus, proc);
|
||||
|
||||
if (ue->if_inst && ue->if_inst->dl_indication)
|
||||
ue->if_inst->dl_indication(&dl_indication, NULL);
|
||||
|
||||
@@ -946,12 +946,10 @@ static void nr_uci_encoding(uint64_t payload,
|
||||
AssertFatal(nrofPRB<=16,"Number of PRB >16\n");
|
||||
} else if (A>=12) {
|
||||
AssertFatal(A<65,"Polar encoding not supported yet for UCI with more than 64 bits\n");
|
||||
t_nrPolar_params *currentPtr = nr_polar_params(NR_POLAR_UCI_PUCCH_MESSAGE_TYPE,
|
||||
A,
|
||||
nrofPRB,
|
||||
1,
|
||||
NULL);
|
||||
polar_encoder_fast(&payload, b, 0,0,currentPtr);
|
||||
polar_encoder_fast(&payload, b, 0,0,
|
||||
NR_POLAR_UCI_PUCCH_MESSAGE_TYPE,
|
||||
A,
|
||||
nrofPRB);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -779,7 +779,7 @@ typedef struct PHY_VARS_gNB_s {
|
||||
/// statistics for ULSCH measurement collection
|
||||
NR_gNB_SCH_STATS_t ulsch_stats[NUMBER_OF_NR_SCH_STATS_MAX];
|
||||
NR_gNB_UCI_STATS_t uci_stats[NUMBER_OF_NR_UCI_STATS_MAX];
|
||||
t_nrPolar_params *uci_polarParams;
|
||||
t_nrPolar_params **polarParams;
|
||||
|
||||
/// SRS variables
|
||||
nr_srs_info_t *nr_srs_info[NUMBER_OF_NR_SRS_MAX];
|
||||
|
||||
@@ -814,7 +814,6 @@ typedef struct {
|
||||
|
||||
fapi_nr_config_request_t nrUE_config;
|
||||
|
||||
t_nrPolar_params *polarList;
|
||||
NR_UE_PDSCH *pdsch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX+1]; // two RxTx Threads
|
||||
NR_UE_PBCH *pbch_vars[NUMBER_OF_CONNECTED_gNB_MAX];
|
||||
NR_UE_PDCCH *pdcch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX];
|
||||
|
||||
@@ -387,8 +387,6 @@ struct NR_DL_FRAME_PARMS {
|
||||
uint8_t N_ssb;
|
||||
/// SSB index
|
||||
uint8_t ssb_index;
|
||||
/// PBCH polar encoder params
|
||||
t_nrPolar_params pbch_polar_params;
|
||||
/// OFDM symbol offset divisor for UL
|
||||
uint32_t ofdm_offset_divisor;
|
||||
};
|
||||
|
||||
@@ -465,7 +465,6 @@ int main(int argc, char **argv)
|
||||
mcs=table2_mcs[actual_payload+shift];
|
||||
else AssertFatal(1==0,"Either nr_bit %d or sr_flag %d must be non-zero\n", nr_bit, sr_flag);
|
||||
}
|
||||
else if (format == 2 && nr_bit > 11) gNB->uci_polarParams = nr_polar_params(2, nr_bit, nrofPRB, 1, NULL);
|
||||
|
||||
startingPRB_intraSlotHopping = N_RB_DL-1;
|
||||
uint32_t hopping_id = Nid_cell;
|
||||
@@ -728,8 +727,6 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (gNB->uci_polarParams)
|
||||
nr_polar_delete(gNB->uci_polarParams);
|
||||
free_channel_desc_scm(UE2gNB);
|
||||
term_freq_channel();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user