Commit 93e5f48a authored by Laurent THOMAS's avatar Laurent THOMAS

simplify polar codec interface

parent d01218a4
...@@ -176,7 +176,7 @@ if (logFlag){ ...@@ -176,7 +176,7 @@ if (logFlag){
double channelOutput[coderLength]; //add noise double channelOutput[coderLength]; //add noise
int16_t channelOutput_int16[coderLength]; 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 #ifdef DEBUG_DCI_POLAR_PARAMS
uint32_t dci_pdu[4]; uint32_t dci_pdu[4];
...@@ -211,7 +211,8 @@ if (logFlag){ ...@@ -211,7 +211,8 @@ if (logFlag){
modulated_input[i]=(-1)/sqrt(2); modulated_input[i]=(-1)/sqrt(2);
channel_output[i] = modulated_input[i] + (gaussdouble(0.0,1.0) * (1/sqrt(2*SNR_lin))); 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]); 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(encoder_outputByte);
free(channel_output); free(channel_output);
...@@ -244,13 +245,13 @@ if (logFlag){ ...@@ -244,13 +245,13 @@ if (logFlag){
start_meas(&timeEncoder); start_meas(&timeEncoder);
if (decoder_int16==1) { 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); //polar_encoder_fast((uint64_t*)testInput, (uint64_t*)encoderOutput,0,0,currentPtr);
} else { //0 --> PBCH, 1 --> DCI, -1 --> UCI } else { //0 --> PBCH, 1 --> DCI, -1 --> UCI
if (polarMessageType == 0) if (polarMessageType == 0)
polar_encoder(testInput, encoderOutput, currentPtr); polar_encoder(testInput, encoderOutput, polarMessageType, testLength, aggregation_level);
else if (polarMessageType == 1) else if (polarMessageType == 1)
polar_encoder_dci(testInput, encoderOutput, currentPtr, rnti); polar_encoder_dci(testInput, encoderOutput, rnti, polarMessageType, testLength, aggregation_level);
} }
stop_meas(&timeEncoder); stop_meas(&timeEncoder);
...@@ -281,19 +282,20 @@ if (logFlag){ ...@@ -281,19 +282,20 @@ if (logFlag){
start_meas(&timeDecoder); start_meas(&timeDecoder);
if (decoder_int16==1) { 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 } else { //0 --> PBCH, 1 --> DCI, -1 --> UCI
if (polarMessageType == 0) { if (polarMessageType == 0) {
decoderState = polar_decoder(channelOutput, decoderState = polar_decoder(channelOutput,
estimatedOutput, estimatedOutput,
currentPtr, decoderListSize,
decoderListSize); polarMessageType, testLength, aggregation_level);
} else if (polarMessageType == 1) { } else if (polarMessageType == 1) {
decoderState = polar_decoder_dci(channelOutput, decoderState = polar_decoder_dci(channelOutput,
estimatedOutput, estimatedOutput,
currentPtr,
decoderListSize, decoderListSize,
rnti); rnti,
polarMessageType, testLength, aggregation_level);
} }
} }
stop_meas(&timeDecoder); stop_meas(&timeDecoder);
...@@ -362,6 +364,5 @@ if (logFlag){ ...@@ -362,6 +364,5 @@ if (logFlag){
print_meas(&timeEncoder,"polar_encoder",NULL,NULL); print_meas(&timeEncoder,"polar_encoder",NULL,NULL);
print_meas(&timeDecoder,"polar_decoder",NULL,NULL); print_meas(&timeDecoder,"polar_decoder",NULL,NULL);
if (logFlag) fclose(logFile); if (logFlag) fclose(logFile);
nr_polar_delete(currentPtr);
return (0); return (0);
} }
...@@ -58,9 +58,13 @@ static inline void updateCrcChecksum2(int xlen, ...@@ -58,9 +58,13 @@ static inline void updateCrcChecksum2(int xlen,
int8_t polar_decoder(double *input, int8_t polar_decoder(double *input,
uint32_t *out, 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. //Assumes no a priori knowledge.
uint8_t bit[polarParams->N][polarParams->n+1][2*listSize]; uint8_t bit[polarParams->N][polarParams->n+1][2*listSize];
memset(bit,0,sizeof bit); memset(bit,0,sizeof bit);
...@@ -302,9 +306,13 @@ int8_t polar_decoder(double *input, ...@@ -302,9 +306,13 @@ int8_t polar_decoder(double *input,
int8_t polar_decoder_dci(double *input, int8_t polar_decoder_dci(double *input,
uint32_t *out, uint32_t *out,
const t_nrPolar_params *polarParams,
uint8_t listSize, 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]; uint8_t bit[polarParams->N][polarParams->n+1][2*listSize];
memset(bit,0,sizeof bit); memset(bit,0,sizeof bit);
uint8_t bitUpdated[polarParams->N][polarParams->n+1]; //0=False, 1=True 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) { ...@@ -596,8 +604,11 @@ void init_polar_deinterleaver_table(t_nrPolar_params *polarParams) {
uint32_t polar_decoder_int16(int16_t *input, uint32_t polar_decoder_int16(int16_t *input,
uint64_t *out, uint64_t *out,
uint8_t ones_flag, 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); 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); 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 { ...@@ -79,9 +79,9 @@ typedef struct decoder_tree_t_s {
struct nrPolar_params { struct nrPolar_params {
//messageType: 0=PBCH, 1=DCI, -1=UCI //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 n_max;
uint8_t i_il; uint8_t i_il;
uint8_t i_seg; uint8_t i_seg;
...@@ -138,34 +138,46 @@ typedef struct nrPolar_params t_nrPolar_params; ...@@ -138,34 +138,46 @@ typedef struct nrPolar_params t_nrPolar_params;
void polar_encoder(uint32_t *input, void polar_encoder(uint32_t *input,
uint32_t *output, 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, void polar_encoder_dci(uint32_t *in,
uint32_t *out, 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 polar_encoder_fast(uint64_t *A,
void *out, void *out,
int32_t crcmask, int32_t crcmask,
uint8_t ones_flag, 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, int8_t polar_decoder(double *input,
uint32_t *output, 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, uint32_t polar_decoder_int16(int16_t *input,
uint64_t *out, uint64_t *out,
uint8_t ones_flag, 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, int8_t polar_decoder_dci(double *input,
uint32_t *out, uint32_t *out,
const t_nrPolar_params *polarParams,
uint8_t listSize, 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, void generic_polar_decoder(const t_nrPolar_params *pp,
decoder_node_t *node); decoder_node_t *node);
...@@ -183,13 +195,12 @@ void build_decoder_tree(t_nrPolar_params *pp); ...@@ -183,13 +195,12 @@ void build_decoder_tree(t_nrPolar_params *pp);
void build_polar_tables(t_nrPolar_params *polarParams); void build_polar_tables(t_nrPolar_params *polarParams);
void init_polar_deinterleaver_table(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, t_nrPolar_params *nr_polar_params (int8_t messageType,
uint16_t messageLength, uint16_t messageLength,
uint8_t aggregation_level, uint8_t aggregation_level,
int decoder_flag, int decoder_flag);
t_nrPolar_params **polarList_ext);
uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level); uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level);
...@@ -333,5 +344,4 @@ static inline void nr_polar_deinterleaver(uint8_t *input, ...@@ -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]; for (int i=0; i<size; i++) output[pattern[i]]=input[i];
} }
void delete_decoder_tree(t_nrPolar_params *); void delete_decoder_tree(t_nrPolar_params *);
void nr_polar_delete(t_nrPolar_params *);
#endif #endif
...@@ -43,7 +43,10 @@ ...@@ -43,7 +43,10 @@
void polar_encoder(uint32_t *in, void polar_encoder(uint32_t *in,
uint32_t *out, 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 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); 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, ...@@ -154,8 +157,12 @@ void polar_encoder(uint32_t *in,
void polar_encoder_dci(uint32_t *in, void polar_encoder_dci(uint32_t *in,
uint32_t *out, 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 #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]); 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 #endif
...@@ -418,7 +425,11 @@ void polar_encoder_fast(uint64_t *A, ...@@ -418,7 +425,11 @@ void polar_encoder_fast(uint64_t *A,
void *out, void *out,
int32_t crcmask, int32_t crcmask,
uint8_t ones_flag, 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 > 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->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); AssertFatal(polarParams->payloadBits < 65, "payload bits = %d > 64, is not supported yet\n",polarParams->payloadBits);
......
...@@ -33,10 +33,20 @@ ...@@ -33,10 +33,20 @@
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
#include "PHY/NR_TRANSPORT/nr_dci.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) { static int intcmp(const void *p1,const void *p2) {
return(*(int16_t *)p1 > *(int16_t *)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); delete_decoder_tree(polarParams);
//From build_polar_tables() //From build_polar_tables()
for (int k=0; k < polarParams->K + polarParams->n_pc; k++) for (int k=0; k < polarParams->K + polarParams->n_pc; k++)
...@@ -68,20 +78,36 @@ void nr_polar_delete(t_nrPolar_params * polarParams) { ...@@ -68,20 +78,36 @@ void nr_polar_delete(t_nrPolar_params * polarParams) {
free(polarParams); free(polarParams);
} }
static void nr_polar_init(t_nrPolar_params * *polarParams, static void nr_polar_delete(void) {
int8_t messageType, 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, uint16_t messageLength,
uint8_t aggregation_level, uint8_t aggregation_level,
int decoder_flag) { int decoder_flag) {
t_nrPolar_params *currentPtr = *polarParams; // The lock is weak, because we never delete in the list, only at exit time
uint16_t aggregation_prime = (messageType >= 2) ? aggregation_level : nr_polar_aggregation_prime(aggregation_level); // 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. //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)); //LOG_D(PHY,"Looking for index %d\n",(messageType * messageLength * aggregation_prime));
if (currentPtr->idx == (messageType * messageLength * aggregation_prime)) return; if (currentPtr->idx == PolarKey ) {
else currentPtr = currentPtr->nextPtr; 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); // printf("currentPtr %p (polarParams %p)\n",currentPtr,polarParams);
...@@ -90,7 +116,7 @@ static void nr_polar_init(t_nrPolar_params * *polarParams, ...@@ -90,7 +116,7 @@ static void nr_polar_init(t_nrPolar_params * *polarParams,
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); // 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; 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);
...@@ -212,7 +238,8 @@ static void nr_polar_init(t_nrPolar_params * *polarParams, ...@@ -212,7 +238,8 @@ static void nr_polar_init(t_nrPolar_params * *polarParams,
nr_polar_channel_interleaver_pattern(newPolarInitNode->channel_interleaver_pattern, nr_polar_channel_interleaver_pattern(newPolarInitNode->channel_interleaver_pattern,
newPolarInitNode->i_bil, newPolarInitNode->i_bil,
newPolarInitNode->encoderLength); newPolarInitNode->encoderLength);
if (decoder_flag == 1) build_decoder_tree(newPolarInitNode); if (decoder_flag == 1)
build_decoder_tree(newPolarInitNode);
build_polar_tables(newPolarInitNode); build_polar_tables(newPolarInitNode);
init_polar_deinterleaver_table(newPolarInitNode); init_polar_deinterleaver_table(newPolarInitNode);
//printf("decoder tree nodes %d\n",newPolarInitNode->tree.num_nodes); //printf("decoder tree nodes %d\n",newPolarInitNode->tree.num_nodes);
...@@ -220,21 +247,22 @@ static void nr_polar_init(t_nrPolar_params * *polarParams, ...@@ -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"); AssertFatal(1 == 0, "[nr_polar_init] New t_nrPolar_params * could not be created");
} }
//Fixme: the list is not thread safe newPolarInitNode->nextPtr=PolarList;
//The defect is not critical: we always append (never delete items) and adding two times the same is fine PolarList=newPolarInitNode;
newPolarInitNode->nextPtr=*polarParams; pthread_mutex_unlock(&PolarListMutex);
*polarParams=newPolarInitNode; return newPolarInitNode;
return;
} }
void nr_polar_print_polarParams(t_nrPolar_params *polarParams) { void nr_polar_print_polarParams() {
uint8_t i = 0; uint8_t i = 0;
if (polarParams == NULL) { if (PolarList == NULL) {
printf("polarParams is empty.\n"); printf("polarParams is empty.\n");
} else { } else {
t_nrPolar_params * polarParams=PolarList;
while (polarParams != NULL) { 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; polarParams = polarParams->nextPtr;
i++; i++;
} }
...@@ -243,31 +271,6 @@ void nr_polar_print_polarParams(t_nrPolar_params *polarParams) { ...@@ -243,31 +271,6 @@ void nr_polar_print_polarParams(t_nrPolar_params *polarParams) {
return; 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) { uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level) {
if (aggregation_level == 0) return 0; if (aggregation_level == 0) return 0;
else if (aggregation_level == 1) return NR_POLAR_AGGREGATION_LEVEL_1_PRIME; 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, ...@@ -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 Nid = dci_pdu->ScramblingId;
uint16_t scrambling_RNTI = dci_pdu->ScramblingRNTI; uint16_t scrambling_RNTI = dci_pdu->ScramblingRNTI;
t_nrPolar_params *currentPtr = nr_polar_params(NR_POLAR_DCI_MESSAGE_TYPE, polar_encoder_fast((uint64_t*)dci_pdu->Payload, (void*)encoder_output, n_RNTI, 1,
dci_pdu->PayloadSizeBits, NR_POLAR_DCI_MESSAGE_TYPE, dci_pdu->PayloadSizeBits, dci_pdu->AggregationLevel);
dci_pdu->AggregationLevel,
0,NULL);
polar_encoder_fast((uint64_t*)dci_pdu->Payload, (void*)encoder_output, n_RNTI,1,currentPtr);
#ifdef DEBUG_CHANNEL_CODING #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("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", 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, ...@@ -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); a_reversed |= (((uint64_t)pbch->pbch_a_prime>>i)&1)<<(31-i);
/// CRC, coding and rate matching /// 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_encoder_fast (&a_reversed, (void*)pbch->pbch_e, 0, 0, polar); NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL);
nr_polar_delete(polar);
#ifdef DEBUG_PBCH_ENCODING #ifdef DEBUG_PBCH_ENCODING
printf("Channel coding:\n"); printf("Channel coding:\n");
......
...@@ -1538,7 +1538,6 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, ...@@ -1538,7 +1538,6 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
} }
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][2]; __m64 *rp_re[Prx2][2];
__m64 *rp2_re[Prx2][2]; __m64 *rp2_re[Prx2][2];
__m64 *rp_im[Prx2][2]; __m64 *rp_im[Prx2][2];
...@@ -1665,7 +1664,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, ...@@ -1665,7 +1664,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
} // half_prb } // half_prb
} // symb } // symb
// run polar decoder on llrs // 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]); LOG_D(PHY,"UCI decoderState %d, payload[0] %llu\n",decoderState,(unsigned long long)decodedPayload[0]);
if (decoderState>0) decoderState=1; if (decoderState>0) decoderState=1;
corr_dB = dB_fixed64(corr); corr_dB = dB_fixed64(corr);
......
...@@ -832,14 +832,18 @@ void nr_pdcch_unscrambling(int16_t *z, ...@@ -832,14 +832,18 @@ void nr_pdcch_unscrambling(int16_t *z,
/* This function compares the received DCI bits with /* This function compares the received DCI bits with
* re-encoded DCI bits and returns the number of mismatched bits * re-encoded DCI bits and returns the number of mismatched bits
*/ */
uint16_t nr_dci_false_detection(uint64_t *dci, static uint16_t nr_dci_false_detection(uint64_t *dci,
int16_t *soft_in, int16_t *soft_in,
const t_nrPolar_params *polar_param,
int encoded_length, int encoded_length,
int rnti) { int rnti,
int8_t messageType,
uint16_t messageLength,
uint8_t aggregation_level
) {
uint32_t encoder_output[NR_MAX_DCI_SIZE_DWORD]; 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; uint8_t *enout_p = (uint8_t*)encoder_output;
uint16_t x = 0; uint16_t x = 0;
...@@ -886,7 +890,6 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, ...@@ -886,7 +890,6 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
if (dci_found==1) continue; if (dci_found==1) continue;
int dci_length = rel15->dci_length_options[k]; int dci_length = rel15->dci_length_options[k];
uint64_t dci_estimation[2]= {0}; 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", 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]]); 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, ...@@ -901,11 +904,10 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
} }
} }
#endif #endif
uint16_t crc = polar_decoder_int16(tmp_e, uint16_t crc = polar_decoder_int16(tmp_e,
dci_estimation, dci_estimation,
1, 1,
currentPtrDCI); NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L);
n_rnti = rel15->rnti; n_rnti = rel15->rnti;
LOG_D(PHY, "(%i.%i) dci indication (rnti %x,dci format %s,n_CCE %d,payloadSize %d)\n", 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, ...@@ -913,7 +915,7 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
if (crc == n_rnti) { 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", 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); 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; ue->dci_thres = (ue->dci_thres + mb) / 2;
if (mb > (ue->dci_thres+20)) { 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); 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, ...@@ -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); nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_E,0,0);
//polar decoding de-rate matching //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,
decoderState = polar_decoder_int16(pbch_e_rx,(uint64_t *)&nr_ue_pbch_vars->pbch_a_prime,0,currentPtr); NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL);
nr_polar_delete(currentPtr);
if(decoderState) return(decoderState); if(decoderState) return(decoderState);
...@@ -602,12 +601,12 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -602,12 +601,12 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
#endif #endif
nr_downlink_indication_t dl_indication; nr_downlink_indication_t dl_indication;
fapi_nr_rx_indication_t rx_ind; //Fixme: on the heap to please the mandatory free in nr_ue_ul_indication()
memset(&rx_ind, 0, sizeof(rx_ind)); fapi_nr_rx_indication_t *rx_ind=calloc(sizeof(*rx_ind),1);
uint16_t number_pdus = 1; uint16_t number_pdus = 1;
nr_fill_dl_indication(&dl_indication, NULL, &rx_ind, proc, ue, gNB_id); 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_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) if (ue->if_inst && ue->if_inst->dl_indication)
ue->if_inst->dl_indication(&dl_indication, NULL); ue->if_inst->dl_indication(&dl_indication, NULL);
......
...@@ -946,12 +946,10 @@ static void nr_uci_encoding(uint64_t payload, ...@@ -946,12 +946,10 @@ static void nr_uci_encoding(uint64_t payload,
AssertFatal(nrofPRB<=16,"Number of PRB >16\n"); AssertFatal(nrofPRB<=16,"Number of PRB >16\n");
} else if (A>=12) { } else if (A>=12) {
AssertFatal(A<65,"Polar encoding not supported yet for UCI with more than 64 bits\n"); 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, polar_encoder_fast(&payload, b, 0,0,
NR_POLAR_UCI_PUCCH_MESSAGE_TYPE,
A, A,
nrofPRB, nrofPRB);
1,
NULL);
polar_encoder_fast(&payload, b, 0,0,currentPtr);
} }
} }
......
...@@ -779,7 +779,7 @@ typedef struct PHY_VARS_gNB_s { ...@@ -779,7 +779,7 @@ typedef struct PHY_VARS_gNB_s {
/// statistics for ULSCH measurement collection /// statistics for ULSCH measurement collection
NR_gNB_SCH_STATS_t ulsch_stats[NUMBER_OF_NR_SCH_STATS_MAX]; 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]; NR_gNB_UCI_STATS_t uci_stats[NUMBER_OF_NR_UCI_STATS_MAX];
t_nrPolar_params *uci_polarParams; t_nrPolar_params **polarParams;
/// SRS variables /// SRS variables
nr_srs_info_t *nr_srs_info[NUMBER_OF_NR_SRS_MAX]; nr_srs_info_t *nr_srs_info[NUMBER_OF_NR_SRS_MAX];
......
...@@ -814,7 +814,6 @@ typedef struct { ...@@ -814,7 +814,6 @@ typedef struct {
fapi_nr_config_request_t nrUE_config; 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_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_PBCH *pbch_vars[NUMBER_OF_CONNECTED_gNB_MAX];
NR_UE_PDCCH *pdcch_vars[RX_NB_TH_MAX][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 { ...@@ -387,8 +387,6 @@ struct NR_DL_FRAME_PARMS {
uint8_t N_ssb; uint8_t N_ssb;
/// SSB index /// SSB index
uint8_t ssb_index; uint8_t ssb_index;
/// PBCH polar encoder params
t_nrPolar_params pbch_polar_params;
/// OFDM symbol offset divisor for UL /// OFDM symbol offset divisor for UL
uint32_t ofdm_offset_divisor; uint32_t ofdm_offset_divisor;
}; };
......
...@@ -465,7 +465,6 @@ int main(int argc, char **argv) ...@@ -465,7 +465,6 @@ int main(int argc, char **argv)
mcs=table2_mcs[actual_payload+shift]; 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 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; startingPRB_intraSlotHopping = N_RB_DL-1;
uint32_t hopping_id = Nid_cell; uint32_t hopping_id = Nid_cell;
...@@ -728,8 +727,6 @@ int main(int argc, char **argv) ...@@ -728,8 +727,6 @@ int main(int argc, char **argv)
break; break;
} }
} }
if (gNB->uci_polarParams)
nr_polar_delete(gNB->uci_polarParams);
free_channel_desc_scm(UE2gNB); free_channel_desc_scm(UE2gNB);
term_freq_channel(); term_freq_channel();
......
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