Commit d89602c8 authored by hongzhi wang's avatar hongzhi wang

UE adding polar decoder

parent 742700fa
......@@ -40,7 +40,7 @@
int8_t polar_decoder(
double *input,
uint32_t *out,
uint8_t *out,
t_nrPolar_paramsPtr polarParams,
uint8_t listSize,
uint8_t pathMetricAppr)
......@@ -274,7 +274,7 @@ int8_t polar_decoder(
/*
* Return bits.
*/
nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out);
//nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out);
return(0);
}
......
......@@ -112,7 +112,7 @@ void polar_encoder_dci(uint32_t *in,
uint16_t n_RNTI);
int8_t polar_decoder(double *input,
uint32_t *output,
uint8_t *output,
t_nrPolar_paramsPtr polarParams,
uint8_t listSize,
uint8_t pathMetricAppr);
......
......@@ -933,8 +933,9 @@ void nr_lte_ue_transport(PHY_VARS_UE *ue,int abstraction_flag) {
}*/
void phy_init_nr_top(NR_DL_FRAME_PARMS *frame_parms)
void phy_init_nr_top(PHY_VARS_NR_UE *ue)
{
NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
crcTableInit();
......@@ -960,7 +961,11 @@ void phy_init_nr_top(NR_DL_FRAME_PARMS *frame_parms)
generate_ul_reference_signal_sequences(SHRT_MAX);
// Polar encoder init for PBCH
nr_polar_init(&frame_parms->pbch_polar_params, 1);
//nr_polar_init(&frame_parms->pbch_polar_params, 1);
nr_polar_init(&ue->nrPolar_params,
NR_POLAR_PBCH_MESSAGE_TYPE,
NR_POLAR_PBCH_PAYLOAD_BITS,
NR_POLAR_PBCH_AGGREGATION_LEVEL);
//lte_sync_time_init(frame_parms);
......
......@@ -36,6 +36,7 @@
#endif
//#include "PHY/defs.h"
#include "PHY/defs_nr_UE.h"
#include "PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h"
//#include "PHY/extern.h"
//#include "SCHED/defs.h"
//#include "SIMULATION/TOOLS/defs.h" // for taus
......@@ -3719,67 +3720,34 @@ uint8_t generate_dci_top_emul(PHY_VARS_eNB *phy_vars_eNB,
void dci_decoding(uint8_t DCI_LENGTH,
uint8_t aggregation_level,
int8_t *e,
t_nrPolar_paramsPtr currentPtr,
double *e,
uint8_t *decoded_output)
{
uint8_t dummy_w_rx[3*(MAX_DCI_SIZE_BITS+16+64)];
int8_t w_rx[3*(MAX_DCI_SIZE_BITS+16+32)],d_rx[96+(3*(MAX_DCI_SIZE_BITS+16))];
int8_t decoderState=0;
uint16_t RCC;
uint16_t D=(DCI_LENGTH+16+64);
uint16_t coded_bits;
#ifdef DEBUG_DCI_DECODING
int32_t i;
#endif
if (aggregation_level>3) {
if (aggregation_level>16) {
LOG_I(PHY," dci.c: dci_decoding FATAL, illegal aggregation_level %d\n",aggregation_level);
return;
}
coded_bits = 72 * (1<<aggregation_level);
#ifdef DEBUG_DCI_DECODING
LOG_I(PHY," Doing DCI decoding for %d bits, DCI_LENGTH %d,coded_bits %d, e %p\n",3*(DCI_LENGTH+16),DCI_LENGTH,coded_bits,e);
#endif
// now do decoding
memset((void*)dummy_w_rx,0,3*D);
RCC = generate_dummy_w_cc(DCI_LENGTH+16,
dummy_w_rx);
#ifdef DEBUG_DCI_DECODING
LOG_I(PHY," Doing DCI Rate Matching RCC %d, w %p\n",RCC,w);
#endif
lte_rate_matching_cc_rx(RCC,coded_bits,w_rx,dummy_w_rx,e);
sub_block_deinterleaving_cc((uint32_t)(DCI_LENGTH+16),
&d_rx[96],
&w_rx[0]);
#ifdef DEBUG_DCI_DECODING
for (i=0; i<16+DCI_LENGTH; i++)
LOG_I(PHY," DCI %d : (%d,%d,%d)\n",i,*(d_rx+96+(3*i)),*(d_rx+97+(3*i)),*(d_rx+98+(3*i)));
#endif
memset(decoded_output,0,2+((16+DCI_LENGTH)>>3));
#ifdef DEBUG_DCI_DECODING
printf("Before Viterbi\n");
for (i=0; i<16+DCI_LENGTH; i++)
printf("%d : (%d,%d,%d)\n",i,*(d_rx+96+(3*i)),*(d_rx+97+(3*i)),*(d_rx+98+(3*i)));
decoderState = polar_decoder(e,
decoded_output,
currentPtr,
8,
0);
#endif
//debug_printf("Doing DCI Viterbi \n");
phy_viterbi_lte_sse2(d_rx+96,decoded_output,16+DCI_LENGTH);
//debug_printf("Done DCI Viterbi \n");
}
......@@ -3954,7 +3922,8 @@ void nr_dci_decoding_procedure0(int s,
NR_DCI_ALLOC_t *dci_alloc, //x
int16_t eNB_id, //x
uint8_t current_thread_id, //x
NR_DL_FRAME_PARMS *frame_parms, //x
NR_DL_FRAME_PARMS *frame_parms,
t_nrPolar_paramsPtr *nrPolar_params, //x
uint8_t mi,
uint16_t crc_scrambled_values[13], //x
uint8_t L,
......@@ -3974,6 +3943,7 @@ void nr_dci_decoding_procedure0(int s,
int L2 = (1 << L);
unsigned int Yk, nb_candidates = 0, i, m;
unsigned int CCEmap_cand;
double *polar_input = malloc (sizeof(double) * 108*L);
// A[p], p is the current active CORESET
uint16_t A[3]={39827,39829,39839};
......@@ -4171,7 +4141,12 @@ void nr_dci_decoding_procedure0(int s,
printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> ... we enter function dci_decoding(sizeof_bits=%d L=%d) -----\n",sizeof_bits,L);
printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> ... we have to replace this part of the code by polar decoding\n");
#endif
dci_decoding(sizeof_bits, L, &pdcch_vars[eNB_id]->e_rx[CCEind * 72], &dci_decoded_output[current_thread_id][0]);
//&pdcch_vars[eNB_id]->e_rx[CCEind * 54]
nr_polar_init(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, sizeof_bits, L);
t_nrPolar_paramsPtr currentPtr = nr_polar_params(*nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, sizeof_bits,L);
dci_decoding(sizeof_bits, L, currentPtr, polar_input, &dci_decoded_output[current_thread_id][0]);
/*
for (i=0;i<3+(sizeof_bits>>3);i++)
printf("dci_decoded_output[%d] => %x\n",i,dci_decoded_output[i]);
......@@ -5124,6 +5099,7 @@ uint8_t nr_dci_decoding_procedure(int s,
NR_UE_PDCCH **pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]];
NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
t_nrPolar_paramsPtr *nrPolar_params = &ue->nrPolar_params;
uint8_t mi;// = get_mi(&ue->frame_parms, nr_tti_rx);
// we need to initialize this values as crc is going to be compared with them
uint16_t c_rnti=pdcch_vars[eNB_id]->crnti;
......@@ -5223,7 +5199,7 @@ uint8_t nr_dci_decoding_procedure(int s,
css_dci_format,(1<<2));
#endif
old_dci_cnt = dci_cnt;
nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi,
nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi,
crc_scrambled_values, 2,
cformat0_0_and_1_0, uformat0_0_and_1_0,
format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt,
......@@ -5241,7 +5217,7 @@ uint8_t nr_dci_decoding_procedure(int s,
css_dci_format,(1<<3));
#endif
old_dci_cnt = dci_cnt;
nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi,
nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi,
crc_scrambled_values, 3,
cformat0_0_and_1_0, uformat0_0_and_1_0,
format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt,
......@@ -5259,7 +5235,7 @@ uint8_t nr_dci_decoding_procedure(int s,
css_dci_format,(1<<4));
#endif
old_dci_cnt = dci_cnt;
nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi,
nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi,
crc_scrambled_values, 4,
cformat0_0_and_1_0, uformat0_0_and_1_0,
format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt,
......@@ -5285,7 +5261,7 @@ uint8_t nr_dci_decoding_procedure(int s,
#endif
// for aggregation level 1. The number of candidates (nrofCandidates-SFI) will be calculated in function nr_dci_decoding_procedure0
old_dci_cnt = dci_cnt;
nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi,
nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi,
crc_scrambled_values, 0,
cformat2_0, uformat0_0_and_1_0,
format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt,
......@@ -5298,7 +5274,7 @@ uint8_t nr_dci_decoding_procedure(int s,
}
// for aggregation level 2. The number of candidates (nrofCandidates-SFI) will be calculated in function nr_dci_decoding_procedure0
old_dci_cnt = dci_cnt;
nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi,
nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi,
crc_scrambled_values, 1,
cformat2_0, uformat0_0_and_1_0,
format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt,
......@@ -5311,7 +5287,7 @@ uint8_t nr_dci_decoding_procedure(int s,
}
// for aggregation level 4. The number of candidates (nrofCandidates-SFI) will be calculated in function nr_dci_decoding_procedure0
old_dci_cnt = dci_cnt;
nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi,
nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi,
crc_scrambled_values, 2,
cformat2_0, uformat0_0_and_1_0,
format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt,
......@@ -5324,7 +5300,7 @@ uint8_t nr_dci_decoding_procedure(int s,
}
// for aggregation level 8. The number of candidates (nrofCandidates-SFI) will be calculated in function nr_dci_decoding_procedure0
old_dci_cnt = dci_cnt;
nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi,
nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi,
crc_scrambled_values, 3,
cformat2_0, uformat0_0_and_1_0,
format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt,
......@@ -5337,7 +5313,7 @@ uint8_t nr_dci_decoding_procedure(int s,
}
// for aggregation level 16. The number of candidates (nrofCandidates-SFI) will be calculated in function nr_dci_decoding_procedure0
old_dci_cnt = dci_cnt;
nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi,
nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi,
crc_scrambled_values, 4,
cformat2_0, uformat0_0_and_1_0,
format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt,
......@@ -5403,7 +5379,7 @@ uint8_t nr_dci_decoding_procedure(int s,
/*
* To be removed until here
*/
nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi,
nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi,
crc_scrambled_values, 0,
cformat0_0_and_1_0, uformat0_0_and_1_0,
format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt,
......@@ -5431,7 +5407,7 @@ uint8_t nr_dci_decoding_procedure(int s,
uss_dci_format,format_0_0_1_0_size_bits,format_0_0_1_0_size_bytes);
#endif
old_dci_cnt = dci_cnt;
nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi,
nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi,
crc_scrambled_values, 1,
cformat0_0_and_1_0, uformat0_0_and_1_0,
format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt,
......@@ -5448,7 +5424,7 @@ uint8_t nr_dci_decoding_procedure(int s,
uss_dci_format,format_0_0_1_0_size_bits,format_0_0_1_0_size_bytes);
#endif
old_dci_cnt = dci_cnt;
nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi,
nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi,
crc_scrambled_values, 2,
cformat0_0_and_1_0, uformat0_0_and_1_0,
format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt,
......@@ -5465,7 +5441,7 @@ uint8_t nr_dci_decoding_procedure(int s,
uss_dci_format,format_0_0_1_0_size_bits,format_0_0_1_0_size_bytes);
#endif
old_dci_cnt = dci_cnt;
nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi,
nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi,
crc_scrambled_values, 3,
cformat0_0_and_1_0, uformat0_0_and_1_0,
format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt,
......@@ -5482,7 +5458,7 @@ uint8_t nr_dci_decoding_procedure(int s,
uss_dci_format,format_0_0_1_0_size_bits,format_0_0_1_0_size_bytes);
#endif
old_dci_cnt = dci_cnt;
nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi,
nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi,
crc_scrambled_values, 4,
cformat0_0_and_1_0, uformat0_0_and_1_0,
format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt,
......
......@@ -535,16 +535,18 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
unsigned short idx_demod =0;
int8_t decoderState=0;
uint8_t decoderListSize = 8, pathMetricAppr = 0;
double aPrioriArray[frame_parms->pbch_polar_params.payloadBits]; // assume no a priori knowledge available about the payload.
memset(&pbch_a[0], 0, sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS);
//printf("nr_pbch_ue nid_cell %d\n",frame_parms->Nid_cell);
/*double aPrioriArray[frame_parms->pbch_polar_params.payloadBits]; // assume no a priori knowledge available about the payload.
for (int i=0; i<frame_parms->pbch_polar_params.payloadBits; i++) aPrioriArray[i] = NAN;*/
for (int i=0; i<frame_parms->pbch_polar_params.payloadBits; i++) aPrioriArray[i] = NAN;
int subframe_rx = proc->subframe_rx;
printf("ue->current_thread_id[subframe_rx] %d subframe_rx %d\n",ue->current_thread_id[subframe_rx], subframe_rx);
pbch_e_rx = &nr_ue_pbch_vars->llr[0];
// clear LLR buffer
......@@ -651,7 +653,8 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
//#endif
//polar decoding de-rate matching
decoderState = polar_decoder(demod_pbch_e, pbch_a, &frame_parms->pbch_polar_params, decoderListSize, pathMetricAppr);
t_nrPolar_paramsPtr currentPtr = nr_polar_params(&ue->nrPolar_params, NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL);
decoderState = polar_decoder(demod_pbch_e, pbch_a_b, currentPtr, decoderListSize, pathMetricAppr);
printf("polar decoder state %d\n", decoderState);
if(decoderState == -1)
return(decoderState);
......@@ -715,8 +718,3 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
return 0;
}
......@@ -1085,6 +1085,7 @@ typedef struct {
uint32_t dmrs_pbch_bitmap_nr[DMRS_PBCH_I_SSB][DMRS_PBCH_N_HF][DMRS_BITMAP_SIZE];
#endif
t_nrPolar_paramsPtr nrPolar_params;
/// PBCH DMRS sequence
uint32_t nr_gold_pbch[2][64][NR_PBCH_DMRS_LENGTH_DWORD];
......
......@@ -696,8 +696,8 @@ static void *UE_thread_rxn_txnp4(void *arg) {
UE->ul_indication.slot = 0; // to be fill
UE->ul_indication.frame = 0; // to be fill
// [TODO] mapping right after NR initial sync
//UE->ul_indication.frame = ;
//UE->ul_indication.slot = ;
UE->ul_indication.frame = proc->frame_rx;
UE->ul_indication.slot = proc->nr_tti_rx;
UE->if_inst->ul_indication(&UE->ul_indication);
}
......
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