Commit e1fa6be7 authored by laurent's avatar laurent

issue 403

parent d383cd52
...@@ -158,9 +158,7 @@ int main(int argc, char *argv[]) { ...@@ -158,9 +158,7 @@ int main(int argc, char *argv[]) {
int16_t channelOutput_int16[coderLength]; int16_t channelOutput_int16[coderLength];
t_nrPolar_paramsPtr nrPolar_params = NULL, currentPtr = NULL; t_nrPolar_params currentPtr = nr_polar_params(polarMessageType, testLength, aggregation_level);
nr_polar_init(&nrPolar_params, polarMessageType, testLength, aggregation_level);
currentPtr = nr_polar_params(nrPolar_params, polarMessageType, testLength, aggregation_level);
#ifdef DEBUG_DCI_POLAR_PARAMS #ifdef DEBUG_DCI_POLAR_PARAMS
uint32_t dci_pdu[4]; uint32_t dci_pdu[4];
...@@ -173,8 +171,7 @@ int main(int argc, char *argv[]) { ...@@ -173,8 +171,7 @@ int main(int argc, char *argv[]) {
uint16_t size=41; uint16_t size=41;
uint16_t rnti=3; uint16_t rnti=3;
aggregation_level=8; aggregation_level=8;
nr_polar_init(&nrPolar_params, 1, size, aggregation_level); t_nrPolar_params * currentPtrDCI=nr_polar_params(1, size, aggregation_level);
t_nrPolar_paramsPtr currentPtrDCI=nr_polar_params(nrPolar_params, 1, size, aggregation_level);
polar_encoder_dci(dci_pdu, encoder_output, currentPtrDCI, rnti); polar_encoder_dci(dci_pdu, encoder_output, currentPtrDCI, rnti);
for (int i=0;i<54;i++) for (int i=0;i<54;i++)
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
int8_t polar_decoder( int8_t polar_decoder(
double *input, double *input,
uint8_t *out, uint8_t *out,
t_nrPolar_paramsPtr polarParams, t_nrPolar_params * polarParams,
uint8_t listSize, uint8_t listSize,
uint8_t pathMetricAppr) uint8_t pathMetricAppr)
{ {
...@@ -282,7 +282,7 @@ int8_t polar_decoder( ...@@ -282,7 +282,7 @@ int8_t polar_decoder(
int8_t polar_decoder_aPriori(double *input, int8_t polar_decoder_aPriori(double *input,
uint32_t *out, uint32_t *out,
t_nrPolar_paramsPtr polarParams, t_nrPolar_params * polarParams,
uint8_t listSize, uint8_t listSize,
uint8_t pathMetricAppr, uint8_t pathMetricAppr,
double *aPrioriPayload) double *aPrioriPayload)
...@@ -538,7 +538,7 @@ int8_t polar_decoder_aPriori(double *input, ...@@ -538,7 +538,7 @@ int8_t polar_decoder_aPriori(double *input,
int8_t polar_decoder_aPriori_timing(double *input, int8_t polar_decoder_aPriori_timing(double *input,
uint32_t *out, uint32_t *out,
t_nrPolar_paramsPtr polarParams, t_nrPolar_params * polarParams,
uint8_t listSize, uint8_t listSize,
uint8_t pathMetricAppr, uint8_t pathMetricAppr,
double *aPrioriPayload, double *aPrioriPayload,
...@@ -793,7 +793,7 @@ int8_t polar_decoder_aPriori_timing(double *input, ...@@ -793,7 +793,7 @@ int8_t polar_decoder_aPriori_timing(double *input,
int8_t polar_decoder_dci(double *input, int8_t polar_decoder_dci(double *input,
uint32_t *out, uint32_t *out,
t_nrPolar_paramsPtr polarParams, t_nrPolar_params * polarParams,
uint8_t listSize, uint8_t listSize,
uint8_t pathMetricAppr, uint8_t pathMetricAppr,
uint16_t n_RNTI) uint16_t n_RNTI)
...@@ -1073,7 +1073,7 @@ void init_polar_deinterleaver_table(t_nrPolar_params *polarParams) { ...@@ -1073,7 +1073,7 @@ 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,
t_nrPolar_params *polarParams) const t_nrPolar_params *polarParams)
{ {
......
...@@ -136,42 +136,41 @@ struct nrPolar_params { ...@@ -136,42 +136,41 @@ struct nrPolar_params {
decoder_tree_t tree; decoder_tree_t tree;
} __attribute__ ((__packed__)); } __attribute__ ((__packed__));
typedef struct nrPolar_params t_nrPolar_params; typedef struct nrPolar_params t_nrPolar_params;
typedef t_nrPolar_params *t_nrPolar_paramsPtr;
void polar_encoder(uint32_t *input, void polar_encoder(uint32_t *input,
uint32_t *output, uint32_t *output,
t_nrPolar_paramsPtr polarParams); t_nrPolar_params* polarParams);
void polar_encoder_dci(uint32_t *in, void polar_encoder_dci(uint32_t *in,
uint32_t *out, uint32_t *out,
t_nrPolar_paramsPtr polarParams, t_nrPolar_params* polarParams,
uint16_t n_RNTI); uint16_t n_RNTI);
void polar_encoder_fast(uint64_t *A, void polar_encoder_fast(uint64_t *A,
uint32_t *out, uint32_t *out,
int32_t crcmask, int32_t crcmask,
t_nrPolar_paramsPtr polarParams); t_nrPolar_params* polarParams);
int8_t polar_decoder(double *input, int8_t polar_decoder(double *input,
uint8_t *output, uint8_t *output,
t_nrPolar_paramsPtr polarParams, t_nrPolar_params* polarParams,
uint8_t listSize, uint8_t listSize,
uint8_t pathMetricAppr); uint8_t pathMetricAppr);
uint32_t polar_decoder_int16(int16_t *input, uint32_t polar_decoder_int16(int16_t *input,
uint64_t *out, uint64_t *out,
t_nrPolar_params *polarParams); const t_nrPolar_params *polarParams);
int8_t polar_decoder_aPriori(double *input, int8_t polar_decoder_aPriori(double *input,
uint32_t *output, uint32_t *output,
t_nrPolar_paramsPtr polarParams, t_nrPolar_params* polarParams,
uint8_t listSize, uint8_t listSize,
uint8_t pathMetricAppr, uint8_t pathMetricAppr,
double *aPrioriPayload); double *aPrioriPayload);
int8_t polar_decoder_aPriori_timing(double *input, int8_t polar_decoder_aPriori_timing(double *input,
uint32_t *output, uint32_t *output,
t_nrPolar_paramsPtr polarParams, t_nrPolar_params* polarParams,
uint8_t listSize, uint8_t listSize,
uint8_t pathMetricAppr, uint8_t pathMetricAppr,
double *aPrioriPayload, double *aPrioriPayload,
...@@ -180,7 +179,7 @@ int8_t polar_decoder_aPriori_timing(double *input, ...@@ -180,7 +179,7 @@ int8_t polar_decoder_aPriori_timing(double *input,
int8_t polar_decoder_dci(double *input, int8_t polar_decoder_dci(double *input,
uint32_t *out, uint32_t *out,
t_nrPolar_paramsPtr polarParams, t_nrPolar_params* polarParams,
uint8_t listSize, uint8_t listSize,
uint8_t pathMetricAppr, uint8_t pathMetricAppr,
uint16_t n_RNTI); uint16_t n_RNTI);
...@@ -189,18 +188,12 @@ void generic_polar_decoder(t_nrPolar_params *, ...@@ -189,18 +188,12 @@ void generic_polar_decoder(t_nrPolar_params *,
decoder_node_t *); decoder_node_t *);
void build_decoder_tree(t_nrPolar_params *pp); void build_decoder_tree(t_nrPolar_params *pp);
void build_polar_tables(t_nrPolar_paramsPtr 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_init(t_nrPolar_paramsPtr *polarParams, void nr_polar_print_polarParams(t_nrPolar_params* polarParams);
int8_t messageType,
uint16_t messageLength,
uint8_t aggregation_level);
void nr_polar_print_polarParams(t_nrPolar_paramsPtr polarParams); t_nrPolar_params * nr_polar_params ( int8_t messageType,
t_nrPolar_paramsPtr nr_polar_params (t_nrPolar_paramsPtr polarParams,
int8_t messageType,
uint16_t messageLength, uint16_t messageLength,
uint8_t aggregation_level); uint8_t aggregation_level);
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
void polar_encoder(uint32_t *in, void polar_encoder(uint32_t *in,
uint32_t *out, uint32_t *out,
t_nrPolar_paramsPtr polarParams) t_nrPolar_params * polarParams)
{ {
if (polarParams->idx == 0){//PBCH if (polarParams->idx == 0){//PBCH
/* /*
...@@ -151,7 +151,7 @@ nr_bit2byte_uint32_8_t((uint32_t*)&B, polarParams->K, polarParams->nr_polar_B);* ...@@ -151,7 +151,7 @@ nr_bit2byte_uint32_8_t((uint32_t*)&B, polarParams->K, polarParams->nr_polar_B);*
void polar_encoder_dci(uint32_t *in, void polar_encoder_dci(uint32_t *in,
uint32_t *out, uint32_t *out,
t_nrPolar_paramsPtr polarParams, t_nrPolar_params * polarParams,
uint16_t n_RNTI) uint16_t n_RNTI)
{ {
#ifdef DEBUG_POLAR_ENCODER_DCI #ifdef DEBUG_POLAR_ENCODER_DCI
...@@ -284,9 +284,9 @@ void polar_encoder_dci(uint32_t *in, ...@@ -284,9 +284,9 @@ void polar_encoder_dci(uint32_t *in,
#endif #endif
} }
static inline void polar_rate_matching(t_nrPolar_paramsPtr polarParams,void *in,void *out) __attribute__((always_inline)); static inline void polar_rate_matching(t_nrPolar_params * polarParams,void *in,void *out) __attribute__((always_inline));
static inline void polar_rate_matching(t_nrPolar_paramsPtr polarParams,void *in,void *out) { static inline void polar_rate_matching(t_nrPolar_params * polarParams,void *in,void *out) {
if (polarParams->groupsize == 8) if (polarParams->groupsize == 8)
for (int i=0;i<polarParams->encoderLength>>3;i++) ((uint8_t*)out)[i] = ((uint8_t *)in)[polarParams->rm_tab[i]]; for (int i=0;i<polarParams->encoderLength>>3;i++) ((uint8_t*)out)[i] = ((uint8_t *)in)[polarParams->rm_tab[i]];
...@@ -296,7 +296,7 @@ static inline void polar_rate_matching(t_nrPolar_paramsPtr polarParams,void *in, ...@@ -296,7 +296,7 @@ static inline void polar_rate_matching(t_nrPolar_paramsPtr polarParams,void *in,
} }
} }
void build_polar_tables(t_nrPolar_paramsPtr polarParams) { void build_polar_tables(t_nrPolar_params * polarParams) {
// build table b -> c' // build table b -> c'
...@@ -388,7 +388,7 @@ void build_polar_tables(t_nrPolar_paramsPtr polarParams) { ...@@ -388,7 +388,7 @@ void build_polar_tables(t_nrPolar_paramsPtr polarParams) {
void polar_encoder_fast(uint64_t *A, void polar_encoder_fast(uint64_t *A,
uint32_t *out, uint32_t *out,
int32_t crcmask, int32_t crcmask,
t_nrPolar_paramsPtr polarParams) { t_nrPolar_params * polarParams) {
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);
......
...@@ -41,12 +41,12 @@ static int intcmp(const void *p1,const void *p2) { ...@@ -41,12 +41,12 @@ 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_init(t_nrPolar_paramsPtr *polarParams, static void nr_polar_init(t_nrPolar_params * *polarParams,
int8_t messageType, int8_t messageType,
uint16_t messageLength, uint16_t messageLength,
uint8_t aggregation_level) uint8_t aggregation_level)
{ {
t_nrPolar_paramsPtr currentPtr = *polarParams; t_nrPolar_params * currentPtr = *polarParams;
uint16_t aggregation_prime = nr_polar_aggregation_prime(aggregation_level); uint16_t aggregation_prime = 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.
...@@ -58,7 +58,7 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, ...@@ -58,7 +58,7 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams,
// printf("currentPtr %p (polarParams %p)\n",currentPtr,polarParams); // printf("currentPtr %p (polarParams %p)\n",currentPtr,polarParams);
//Else, initialize and add node to the end of the linked list. //Else, initialize and add node to the end of the linked list.
t_nrPolar_paramsPtr newPolarInitNode = malloc(sizeof(t_nrPolar_params)); t_nrPolar_params * newPolarInitNode = malloc(sizeof(t_nrPolar_params));
if (newPolarInitNode != NULL) { if (newPolarInitNode != NULL) {
...@@ -170,30 +170,15 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, ...@@ -170,30 +170,15 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams,
//printf("decoder tree nodes %d\n",newPolarInitNode->tree.num_nodes); //printf("decoder tree nodes %d\n",newPolarInitNode->tree.num_nodes);
} else { } else {
AssertFatal(1 == 0, "[nr_polar_init] New t_nrPolar_paramsPtr could not be created"); AssertFatal(1 == 0, "[nr_polar_init] New t_nrPolar_params * could not be created");
} }
currentPtr = *polarParams; newPolarInitNode->nextPtr=*polarParams;
//If polarParams is empty: *polarParams=newPolarInitNode;
if (currentPtr == NULL)
{
*polarParams = newPolarInitNode;
//printf("Creating first polarParams entry index %d, %p\n",newPolarInitNode->idx,*polarParams);
return;
}
//Else, add node to the end of the linked list.
while (currentPtr->nextPtr != NULL) {
currentPtr = currentPtr->nextPtr;
}
currentPtr->nextPtr= newPolarInitNode;
printf("Adding new polarParams entry to list index %d,%p\n",
newPolarInitNode->idx,
currentPtr->nextPtr);
return; return;
} }
void nr_polar_print_polarParams(t_nrPolar_paramsPtr polarParams) void nr_polar_print_polarParams(t_nrPolar_params * polarParams)
{ {
uint8_t i = 0; uint8_t i = 0;
if (polarParams == NULL) { if (polarParams == NULL) {
...@@ -208,23 +193,22 @@ void nr_polar_print_polarParams(t_nrPolar_paramsPtr polarParams) ...@@ -208,23 +193,22 @@ void nr_polar_print_polarParams(t_nrPolar_paramsPtr polarParams)
return; return;
} }
t_nrPolar_paramsPtr nr_polar_params (t_nrPolar_paramsPtr polarParams, t_nrPolar_params * nr_polar_params ( int8_t messageType,
int8_t messageType,
uint16_t messageLength, uint16_t messageLength,
uint8_t aggregation_level) uint8_t aggregation_level)
{ {
t_nrPolar_paramsPtr currentPtr = NULL; static t_nrPolar_params * polarList = NULL;
nr_polar_init(&polarList, messageType,messageLength,aggregation_level);
t_nrPolar_params * polarParams=polarList;
const int tag=messageType * messageLength * nr_polar_aggregation_prime(aggregation_level);
while (polarParams != NULL) { while (polarParams != NULL) {
if (polarParams->idx == if (polarParams->idx == tag)
(messageType * messageLength * (nr_polar_aggregation_prime(aggregation_level)) )) { return polarParams;
currentPtr = polarParams;
break;
} else {
polarParams = polarParams->nextPtr; polarParams = polarParams->nextPtr;
} }
} AssertFatal(false,"Polar Init tables internal failure\n");
return currentPtr; return NULL;
} }
uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level) uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level)
......
...@@ -126,11 +126,6 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, ...@@ -126,11 +126,6 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
nr_init_pbch_dmrs(gNB); nr_init_pbch_dmrs(gNB);
// Polar encoder init for PBCH // Polar encoder init for PBCH
nr_polar_init(&gNB->nrPolar_params,
NR_POLAR_PBCH_MESSAGE_TYPE,
NR_POLAR_PBCH_PAYLOAD_BITS,
NR_POLAR_PBCH_AGGREGATION_LEVEL);
//PDCCH DMRS init //PDCCH DMRS init
gNB->nr_gold_pdcch_dmrs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t**)); gNB->nr_gold_pdcch_dmrs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t**));
uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs; uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs;
......
...@@ -159,7 +159,6 @@ void nr_pdcch_scrambling(uint32_t *in, ...@@ -159,7 +159,6 @@ void nr_pdcch_scrambling(uint32_t *in,
} }
uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars,
t_nrPolar_paramsPtr *nrPolar_params,
uint32_t **gold_pdcch_dmrs, uint32_t **gold_pdcch_dmrs,
int32_t* txdataF, int32_t* txdataF,
int16_t amp, int16_t amp,
...@@ -249,8 +248,7 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, ...@@ -249,8 +248,7 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars,
uint16_t Nid = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? uint16_t Nid = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)?
pdcch_params.scrambling_id : config.sch_config.physical_cell_id.value; pdcch_params.scrambling_id : config.sch_config.physical_cell_id.value;
nr_polar_init(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); t_nrPolar_params * currentPtr = nr_polar_params(NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L);
t_nrPolar_paramsPtr currentPtr = nr_polar_params(*nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L);
polar_encoder_fast(dci_alloc.dci_pdu, encoder_output, pdcch_params.rnti,currentPtr); polar_encoder_fast(dci_alloc.dci_pdu, encoder_output, pdcch_params.rnti,currentPtr);
......
...@@ -33,7 +33,6 @@ uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format, ...@@ -33,7 +33,6 @@ uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format,
nfapi_nr_config_request_t* config); nfapi_nr_config_request_t* config);
uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars,
t_nrPolar_paramsPtr *nrPolar_params,
uint32_t **gold_pdcch_dmrs, uint32_t **gold_pdcch_dmrs,
int32_t* txdataF, int32_t* txdataF,
int16_t amp, int16_t amp,
......
...@@ -225,7 +225,6 @@ void nr_init_pbch_interleaver(uint8_t *interleaver) { ...@@ -225,7 +225,6 @@ void nr_init_pbch_interleaver(uint8_t *interleaver) {
} }
int nr_generate_pbch(NR_gNB_PBCH *pbch, int nr_generate_pbch(NR_gNB_PBCH *pbch,
t_nrPolar_paramsPtr polar_params,
uint8_t *pbch_pdu, uint8_t *pbch_pdu,
uint8_t *interleaver, uint8_t *interleaver,
int32_t *txdataF, int32_t *txdataF,
...@@ -307,7 +306,9 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, ...@@ -307,7 +306,9 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch,
/// CRC, coding and rate matching /// CRC, coding and rate matching
polar_encoder_fast (&a_reversed, (uint32_t*)pbch->pbch_e, 0, polar_params); polar_encoder_fast (&a_reversed, (uint32_t*)pbch->pbch_e, 0,
nr_polar_params( NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL)
);
#ifdef DEBUG_PBCH_ENCODING #ifdef DEBUG_PBCH_ENCODING
printf("Channel coding:\n"); printf("Channel coding:\n");
for (int i=0; i<NR_POLAR_PBCH_E_DWORD; i++) for (int i=0; i<NR_POLAR_PBCH_E_DWORD; i++)
......
...@@ -85,7 +85,6 @@ void nr_pbch_scrambling(NR_gNB_PBCH *pbch, ...@@ -85,7 +85,6 @@ void nr_pbch_scrambling(NR_gNB_PBCH *pbch,
@returns 0 on success @returns 0 on success
*/ */
int nr_generate_pbch(NR_gNB_PBCH *pbch, int nr_generate_pbch(NR_gNB_PBCH *pbch,
t_nrPolar_paramsPtr polar_params,
uint8_t *pbch_pdu, uint8_t *pbch_pdu,
uint8_t *interleaver, uint8_t *interleaver,
int32_t *txdataF, int32_t *txdataF,
......
...@@ -1136,7 +1136,6 @@ void nr_dci_decoding_procedure0(int s, ...@@ -1136,7 +1136,6 @@ void nr_dci_decoding_procedure0(int s,
int coreset_nbr_cce_per_symbol=0; int coreset_nbr_cce_per_symbol=0;
t_nrPolar_paramsPtr nrPolar_params = pdcch_vars[eNB_id]->nrPolar_params;
#ifdef NR_PDCCH_DCI_DEBUG #ifdef NR_PDCCH_DCI_DEBUG
printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> format_found is %d \n", *format_found); printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> format_found is %d \n", *format_found);
...@@ -1364,9 +1363,7 @@ void nr_dci_decoding_procedure0(int s, ...@@ -1364,9 +1363,7 @@ void nr_dci_decoding_procedure0(int s,
uint64_t dci_estimation[2]={0}; uint64_t dci_estimation[2]={0};
nr_polar_init(&nrPolar_params, 1, sizeof_bits, L2); const t_nrPolar_params* currentPtrDCI=nr_polar_params(1, sizeof_bits, L2);
t_nrPolar_paramsPtr currentPtrDCI=nr_polar_params(nrPolar_params, 1, sizeof_bits, L2);
decoderState = polar_decoder_int16(&pdcch_vars[eNB_id]->e_rx[CCEind*9*6*2], decoderState = polar_decoder_int16(&pdcch_vars[eNB_id]->e_rx[CCEind*9*6*2],
dci_estimation, dci_estimation,
currentPtrDCI); currentPtrDCI);
......
...@@ -566,15 +566,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -566,15 +566,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
//polar decoding de-rate matching //polar decoding de-rate matching
const t_nrPolar_params *currentPtr = nr_polar_params( NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL);
nr_polar_init(&nr_ue_pbch_vars->nrPolar_params,
NR_POLAR_PBCH_MESSAGE_TYPE,
NR_POLAR_PBCH_PAYLOAD_BITS,
NR_POLAR_PBCH_AGGREGATION_LEVEL);
AssertFatal(nr_ue_pbch_vars->nrPolar_params != NULL,"nr_ue_pbch_vars->nrPolar_params is null\n");
t_nrPolar_params *currentPtr = nr_polar_params(nr_ue_pbch_vars->nrPolar_params, NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL);
decoderState = polar_decoder_int16(pbch_e_rx,(uint64_t*)&nr_ue_pbch_vars->pbch_a_prime,currentPtr); decoderState = polar_decoder_int16(pbch_e_rx,(uint64_t*)&nr_ue_pbch_vars->pbch_a_prime,currentPtr);
......
...@@ -391,7 +391,6 @@ typedef struct PHY_VARS_gNB_s { ...@@ -391,7 +391,6 @@ typedef struct PHY_VARS_gNB_s {
Sched_Rsp_t Sched_INFO; Sched_Rsp_t Sched_INFO;
NR_gNB_PDCCH pdcch_vars; NR_gNB_PDCCH pdcch_vars;
NR_gNB_PBCH pbch; NR_gNB_PBCH pbch;
t_nrPolar_paramsPtr nrPolar_params;
LTE_eNB_PHICH phich_vars[2]; LTE_eNB_PHICH phich_vars[2];
NR_gNB_COMMON common_vars; NR_gNB_COMMON common_vars;
......
...@@ -892,7 +892,6 @@ typedef struct { ...@@ -892,7 +892,6 @@ typedef struct {
//Check for specific DCIFormat and AgregationLevel //Check for specific DCIFormat and AgregationLevel
uint8_t dciFormat; uint8_t dciFormat;
uint8_t agregationLevel; uint8_t agregationLevel;
t_nrPolar_paramsPtr nrPolar_params;
#ifdef NR_PDCCH_DEFS_NR_UE #ifdef NR_PDCCH_DEFS_NR_UE
int nb_searchSpaces; int nb_searchSpaces;
// CORESET structure, where maximum number of CORESETs to be handled is 3 (according to 38.331 V15.1.0) // CORESET structure, where maximum number of CORESETs to be handled is 3 (according to 38.331 V15.1.0)
...@@ -933,8 +932,6 @@ typedef struct { ...@@ -933,8 +932,6 @@ typedef struct {
/// \brief Pointer to PBCH decoded output. /// \brief Pointer to PBCH decoded output.
/// - first index: ? [0..63] (hard coded) /// - first index: ? [0..63] (hard coded)
uint8_t *decoded_output; uint8_t *decoded_output;
/// polar decoder parameters
t_nrPolar_paramsPtr nrPolar_params;
/// \brief Total number of PDU errors. /// \brief Total number of PDU errors.
uint32_t pdu_errors; uint32_t pdu_errors;
/// \brief Total number of PDU errors 128 frames ago. /// \brief Total number of PDU errors 128 frames ago.
......
...@@ -149,7 +149,6 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) { ...@@ -149,7 +149,6 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) {
nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[n_hf][ssb_index],txdataF[0], AMP, ssb_start_symbol, cfg, fp); nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[n_hf][ssb_index],txdataF[0], AMP, ssb_start_symbol, cfg, fp);
nr_generate_pbch(&gNB->pbch, nr_generate_pbch(&gNB->pbch,
gNB->nrPolar_params,
pbch_pdu, pbch_pdu,
gNB->nr_pbch_interleaver, gNB->nr_pbch_interleaver,
txdataF[0], txdataF[0],
...@@ -201,7 +200,6 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, ...@@ -201,7 +200,6 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB,
if (nfapi_mode == 0 || nfapi_mode == 1){ if (nfapi_mode == 0 || nfapi_mode == 1){
nr_generate_dci_top(gNB->pdcch_vars, nr_generate_dci_top(gNB->pdcch_vars,
&gNB->nrPolar_params,
gNB->nr_gold_pdcch_dmrs[slot], gNB->nr_gold_pdcch_dmrs[slot],
gNB->common_vars.txdataF[0], gNB->common_vars.txdataF[0],
AMP, *fp, *cfg); AMP, *fp, *cfg);
......
...@@ -82,6 +82,17 @@ void removeCirBuf(rfsimulator_state_t *bridge, int sock) { ...@@ -82,6 +82,17 @@ void removeCirBuf(rfsimulator_state_t *bridge, int sock) {
bridge->buf[sock].conn_sock=-1; bridge->buf[sock].conn_sock=-1;
} }
void socketError(rfsimulator_state_t *bridge, int sock) {
if (bridge->buf[sock].conn_sock!=-1) {
LOG_W(HW,"Lost socket \n");
removeCirBuf(bridge, sock);
if (bridge->typeStamp==MAGICUE)
exit(1);
}
}
#define helpTxt "\ #define helpTxt "\
\x1b[31m\ \x1b[31m\
rfsimulator: error: you have to run one UE and one eNB\n\ rfsimulator: error: you have to run one UE and one eNB\n\
...@@ -108,32 +119,28 @@ void setblocking(int sock, enum blocking_t active) { ...@@ -108,32 +119,28 @@ void setblocking(int sock, enum blocking_t active) {
static bool flushInput(rfsimulator_state_t *t); static bool flushInput(rfsimulator_state_t *t);
int fullwrite(int fd, void *_buf, int count, rfsimulator_state_t *t) { void fullwrite(int fd, void *_buf, int count, rfsimulator_state_t *t) {
char *buf = _buf; char *buf = _buf;
int ret = 0;
int l; int l;
setblocking(fd, notBlocking); setblocking(fd, notBlocking);
while (count) { while (count) {
l = write(fd, buf, count); l = write(fd, buf, count);
if (l <= 0) { if (l <= 0) {
if (errno==EINTR) if (errno==EINTR)
continue; continue;
if(errno==EAGAIN) { if(errno==EAGAIN) {
flushInput(t); flushInput(t);
continue; continue;
} } else
else return;
return -1;
} }
count -= l; count -= l;
buf += l; buf += l;
ret += l;
} }
return ret;
} }
int server_start(openair0_device *device) { int server_start(openair0_device *device) {
...@@ -143,9 +150,12 @@ int server_start(openair0_device *device) { ...@@ -143,9 +150,12 @@ int server_start(openair0_device *device) {
int enable = 1; int enable = 1;
AssertFatal(setsockopt(t->listen_sock, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)) == 0, ""); AssertFatal(setsockopt(t->listen_sock, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)) == 0, "");
struct sockaddr_in addr = { struct sockaddr_in addr = {
sin_family: AF_INET, sin_family:
sin_port: htons(PORT), AF_INET,
sin_addr: { s_addr: INADDR_ANY } sin_port:
htons(PORT),
sin_addr:
{ s_addr: INADDR_ANY }
}; };
bind(t->listen_sock, (struct sockaddr *)&addr, sizeof(addr)); bind(t->listen_sock, (struct sockaddr *)&addr, sizeof(addr));
AssertFatal(listen(t->listen_sock, 5) == 0, ""); AssertFatal(listen(t->listen_sock, 5) == 0, "");
...@@ -162,9 +172,12 @@ int start_ue(openair0_device *device) { ...@@ -162,9 +172,12 @@ int start_ue(openair0_device *device) {
int sock; int sock;
AssertFatal((sock = socket(AF_INET, SOCK_STREAM, 0)) >= 0, ""); AssertFatal((sock = socket(AF_INET, SOCK_STREAM, 0)) >= 0, "");
struct sockaddr_in addr = { struct sockaddr_in addr = {
sin_family: AF_INET, sin_family:
sin_port: htons(PORT), AF_INET,
sin_addr: { s_addr: INADDR_ANY } sin_port:
htons(PORT),
sin_addr:
{ s_addr: INADDR_ANY }
}; };
addr.sin_addr.s_addr = inet_addr(t->ip); addr.sin_addr.s_addr = inet_addr(t->ip);
bool connected=false; bool connected=false;
...@@ -195,8 +208,7 @@ int rfsimulator_write(openair0_device *device, openair0_timestamp timestamp, voi ...@@ -195,8 +208,7 @@ int rfsimulator_write(openair0_device *device, openair0_timestamp timestamp, voi
if (ptr->conn_sock >= 0 ) { if (ptr->conn_sock >= 0 ) {
transferHeader header= {t->typeStamp, nsamps, nbAnt, timestamp}; transferHeader header= {t->typeStamp, nsamps, nbAnt, timestamp};
int n=-1; fullwrite(ptr->conn_sock,&header, sizeof(header), t);
AssertFatal( fullwrite(ptr->conn_sock,&header, sizeof(header), t) == sizeof(header), "");
sample_t tmpSamples[nsamps][nbAnt]; sample_t tmpSamples[nsamps][nbAnt];
for(int a=0; a<nbAnt; a++) { for(int a=0; a<nbAnt; a++) {
...@@ -206,13 +218,8 @@ int rfsimulator_write(openair0_device *device, openair0_timestamp timestamp, voi ...@@ -206,13 +218,8 @@ int rfsimulator_write(openair0_device *device, openair0_timestamp timestamp, voi
tmpSamples[s][a]=in[s]; tmpSamples[s][a]=in[s];
} }
n = fullwrite(ptr->conn_sock, (void *)tmpSamples, sampleToByte(nsamps,nbAnt), t); if (ptr->conn_sock >= 0 )
fullwrite(ptr->conn_sock, (void *)tmpSamples, sampleToByte(nsamps,nbAnt), t);
if (n != sampleToByte(nsamps,nbAnt) ) {
LOG_E(HW,"rfsimulator: write error ret %d (wanted %ld) error %s\n", n, sampleToByte(nsamps,nbAnt), strerror(errno));
abort();
}
} }
} }
...@@ -241,17 +248,11 @@ static bool flushInput(rfsimulator_state_t *t) { ...@@ -241,17 +248,11 @@ static bool flushInput(rfsimulator_state_t *t) {
int conn_sock; int conn_sock;
AssertFatal( (conn_sock = accept(t->listen_sock,NULL,NULL)) != -1, ""); AssertFatal( (conn_sock = accept(t->listen_sock,NULL,NULL)) != -1, "");
setblocking(conn_sock, notBlocking); setblocking(conn_sock, notBlocking);
allocCirBuf(t, conn_sock); allocCirBuf(t, conn_sock);
LOG_I(HW,"A ue connected\n"); LOG_I(HW,"A ue connected\n");
} else { } else {
if ( events[nbEv].events & (EPOLLHUP | EPOLLERR | EPOLLRDHUP) ) { if ( events[nbEv].events & (EPOLLHUP | EPOLLERR | EPOLLRDHUP) ) {
LOG_W(HW,"Lost socket\n"); socketError(t,fd);
removeCirBuf(t, fd);
if (t->typeStamp==MAGICUE)
exit(1);
continue; continue;
} }
...@@ -292,7 +293,8 @@ static bool flushInput(rfsimulator_state_t *t) { ...@@ -292,7 +293,8 @@ static bool flushInput(rfsimulator_state_t *t) {
AssertFatal( (t->typeStamp == MAGICUE && b->th.magic==MAGICeNB) || AssertFatal( (t->typeStamp == MAGICUE && b->th.magic==MAGICeNB) ||
(t->typeStamp == MAGICeNB && b->th.magic==MAGICUE), "Socket Error in protocol"); (t->typeStamp == MAGICeNB && b->th.magic==MAGICUE), "Socket Error in protocol");
b->headerMode=false; b->headerMode=false;
b->alreadyRead=true; b->alreadyRead=true;
if ( b->lastReceivedTS != b->th.timestamp) { if ( b->lastReceivedTS != b->th.timestamp) {
int nbAnt= b->th.nbAnt; int nbAnt= b->th.nbAnt;
...@@ -331,7 +333,10 @@ static bool flushInput(rfsimulator_state_t *t) { ...@@ -331,7 +333,10 @@ static bool flushInput(rfsimulator_state_t *t) {
} }
int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, void **samplesVoid, int nsamps, int nbAnt) { int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, void **samplesVoid, int nsamps, int nbAnt) {
if (nbAnt != 1) { LOG_E(HW, "rfsimulator: only 1 antenna tested\n"); exit(1); } if (nbAnt != 1) {
LOG_E(HW, "rfsimulator: only 1 antenna tested\n");
exit(1);
}
rfsimulator_state_t *t = device->priv; rfsimulator_state_t *t = device->priv;
LOG_D(HW, "Enter rfsimulator_read, expect %d samples, will release at TS: %ld\n", nsamps, t->nextTimestamp+nsamps); LOG_D(HW, "Enter rfsimulator_read, expect %d samples, will release at TS: %ld\n", nsamps, t->nextTimestamp+nsamps);
...@@ -351,7 +356,6 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo ...@@ -351,7 +356,6 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
t->nextTimestamp+=nsamps; t->nextTimestamp+=nsamps;
LOG_W(HW,"Generated void samples for Rx: %ld\n", t->nextTimestamp); LOG_W(HW,"Generated void samples for Rx: %ld\n", t->nextTimestamp);
*ptimestamp = t->nextTimestamp-nsamps; *ptimestamp = t->nextTimestamp-nsamps;
return nsamps; return nsamps;
} }
...@@ -443,8 +447,8 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { ...@@ -443,8 +447,8 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
} }
rfsimulator->typeStamp = strncasecmp(rfsimulator->ip,"enb",3) == 0 ? rfsimulator->typeStamp = strncasecmp(rfsimulator->ip,"enb",3) == 0 ?
MAGICeNB: MAGICeNB:
MAGICUE; MAGICUE;
LOG_I(HW,"rfsimulator: running as %s\n", rfsimulator-> typeStamp == MAGICeNB ? "eNB" : "UE"); LOG_I(HW,"rfsimulator: running as %s\n", rfsimulator-> typeStamp == MAGICeNB ? "eNB" : "UE");
device->trx_start_func = rfsimulator->typeStamp == MAGICeNB ? device->trx_start_func = rfsimulator->typeStamp == MAGICeNB ?
server_start : server_start :
......
This diff is collapsed.
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