Commit 8ae993ae authored by hongzhi wang's avatar hongzhi wang

ue add nr pbch unscrambling

parent 227216f0
...@@ -95,6 +95,8 @@ int pbch_detection(PHY_VARS_NR_UE *ue, runmode_t mode) ...@@ -95,6 +95,8 @@ int pbch_detection(PHY_VARS_NR_UE *ue, runmode_t mode)
pbch_decoded = 0; pbch_decoded = 0;
printf("pbch_detection nid_cell %d\n",frame_parms->Nid_cell);
//for (frame_mod4=0; frame_mod4<4; frame_mod4++) { //for (frame_mod4=0; frame_mod4<4; frame_mod4++) {
pbch_tx_ant = nr_rx_pbch(ue, pbch_tx_ant = nr_rx_pbch(ue,
&ue->proc.proc_rxtx[0], &ue->proc.proc_rxtx[0],
...@@ -265,6 +267,7 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) ...@@ -265,6 +267,7 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode)
nr_gold_pbch(ue); nr_gold_pbch(ue);
ret = pbch_detection(ue,mode); ret = pbch_detection(ue,mode);
ret = -1;
// write_output("rxdata2.m","rxd2",ue->common_vars.rxdata[0],10*frame_parms->samples_per_tti,1,1); // write_output("rxdata2.m","rxd2",ue->common_vars.rxdata[0],10*frame_parms->samples_per_tti,1,1);
#ifdef DEBUG_INITIAL_SYNCH #ifdef DEBUG_INITIAL_SYNCH
......
...@@ -394,6 +394,8 @@ void nr_pbch_unscrambling(NR_DL_FRAME_PARMS *frame_parms, ...@@ -394,6 +394,8 @@ void nr_pbch_unscrambling(NR_DL_FRAME_PARMS *frame_parms,
uint8_t reset; uint8_t reset;
uint32_t x1, x2, s=0; uint32_t x1, x2, s=0;
printf("unscramb nid_cell %d\n",frame_parms->Nid_cell);
reset = 1; reset = 1;
// x1 is set in first call to lte_gold_generic // x1 is set in first call to lte_gold_generic
x2 = frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.6.1 x2 = frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.6.1
...@@ -402,12 +404,13 @@ void nr_pbch_unscrambling(NR_DL_FRAME_PARMS *frame_parms, ...@@ -402,12 +404,13 @@ void nr_pbch_unscrambling(NR_DL_FRAME_PARMS *frame_parms,
for (i=0; i<length; i++) { for (i=0; i<length; i++) {
if (i%32==0) { if (i%32==0) {
s = lte_gold_generic(&x1, &x2, reset); s = lte_gold_generic(&x1, &x2, reset);
// printf("lte_gold[%d]=%x\n",i,s); printf("lte_gold[%d]=%x\n",i,s);
reset = 0; reset = 0;
} }
if (((s>>(i%32))&1)==0) printf("s = %d\n",((s>>(i%32))&1) );
pbch_a[i] = -pbch_a[i]; if (((s>>(i%32))&1)==1)
pbch_a[i] = 1-pbch_a[i];
} }
} }
...@@ -449,7 +452,7 @@ void nr_pbch_alamouti(NR_DL_FRAME_PARMS *frame_parms, ...@@ -449,7 +452,7 @@ void nr_pbch_alamouti(NR_DL_FRAME_PARMS *frame_parms,
} }
void nr_pbch_quantize(int16_t *pbch_llr16, void nr_pbch_quantize(int8_t *pbch_llr8,
int16_t *pbch_llr, int16_t *pbch_llr,
uint16_t len) uint16_t len)
{ {
...@@ -462,7 +465,7 @@ void nr_pbch_quantize(int16_t *pbch_llr16, ...@@ -462,7 +465,7 @@ void nr_pbch_quantize(int16_t *pbch_llr16,
else if (pbch_llr[i]<-8) else if (pbch_llr[i]<-8)
pbch_llr8[i]=-8; pbch_llr8[i]=-8;
else*/ else*/
pbch_llr16[i] = (char)(pbch_llr[i]); pbch_llr8[i] = (char)(pbch_llr[i]);
} }
} }
...@@ -487,9 +490,10 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -487,9 +490,10 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue,
int max_h=0; int max_h=0;
int symbol,i; int symbol,i;
uint8_t pbch_a[64]; //uint8_t pbch_a[64];
uint8_t *pbch_a = malloc(sizeof(uint8_t) * 32); ;
int16_t *pbch_e_rx; int8_t *pbch_e_rx;
uint8_t *decoded_output = nr_ue_pbch_vars->decoded_output; uint8_t *decoded_output = nr_ue_pbch_vars->decoded_output;
uint16_t crc; uint16_t crc;
//short nr_demod_table[8] = {0,0,0,1,1,0,1,1}; //short nr_demod_table[8] = {0,0,0,1,1,0,1,1};
...@@ -504,6 +508,11 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -504,6 +508,11 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue,
memset(&channelOutput[0], 0, sizeof(double) * 864); memset(&channelOutput[0], 0, sizeof(double) * 864);
memset(&estimatedOutput[0], 0, sizeof(uint8_t) * 32); memset(&estimatedOutput[0], 0, sizeof(uint8_t) * 32);
memset(&pbch_a[0], 0, sizeof(uint8_t) * 32);
frame_parms->Nid_cell = 100;
printf("nr_pbch_ue nid_cell %d\n",frame_parms->Nid_cell);
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; int subframe_rx = proc->subframe_rx;
...@@ -600,17 +609,20 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -600,17 +609,20 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue,
//polar decoding de-rate matching //polar decoding de-rate matching
decoderState = polar_decoder(demod_pbch_e, estimatedOutput, &frame_parms->pbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr); decoderState = polar_decoder(demod_pbch_e, pbch_a, &frame_parms->pbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr);
//memset(pbch_a,0,((16+NR_POLAR_PBCH_PAYLOAD_BITS)>>3)); for (i=0; i<32 /*(NR_POLAR_PBCH_PAYLOAD_BITS>>3)*/; i++)
printf("pbch_a[%d] = %d \n", i,pbch_a[i]);
//un-scrambling //un-scrambling
// nr_pbch_unscrambling(frame_parms, nr_pbch_unscrambling(frame_parms,pbch_a,NR_POLAR_PBCH_PAYLOAD_BITS);
// pbch_a,
// NR_POLAR_PBCH_PAYLOAD_BITS); for (i=0; i<32 /*(NR_POLAR_PBCH_PAYLOAD_BITS>>3)*/; i++)
printf("after unscrambling pbch_a[%d] = %d \n", i,pbch_a[i]);
// Fix byte endian // Fix byte endian
for (i=0; i<32 /*(NR_POLAR_PBCH_PAYLOAD_BITS>>3)*/; i++) //for (i=0; i<32 /*(NR_POLAR_PBCH_PAYLOAD_BITS>>3)*/; i++)
printf("estimated output[%d] = %d \n", i,estimatedOutput[i]); // printf("estimated output[%d] = %d \n", i,estimatedOutput[i]);
//decoded_output[(NR_POLAR_PBCH_PAYLOAD_BITS>>3)-i-1] = pbch_a[i]; //decoded_output[(NR_POLAR_PBCH_PAYLOAD_BITS>>3)-i-1] = pbch_a[i];
//#ifdef DEBUG_PBCH //#ifdef DEBUG_PBCH
......
...@@ -61,6 +61,8 @@ ...@@ -61,6 +61,8 @@
#include "T.h" #include "T.h"
extern double cpuf; extern double cpuf;
static nfapi_config_request_t config_t;
static nfapi_config_request_t* config =&config_t;
#define FRAME_PERIOD 100000000ULL #define FRAME_PERIOD 100000000ULL
#define DAQ_PERIOD 66667ULL #define DAQ_PERIOD 66667ULL
...@@ -413,7 +415,7 @@ static void *UE_thread_synch(void *arg) { ...@@ -413,7 +415,7 @@ static void *UE_thread_synch(void *arg) {
//UE->rfdevice.trx_set_gains_func(&openair0,&openair0_cfg[0]); //UE->rfdevice.trx_set_gains_func(&openair0,&openair0_cfg[0]);
//UE->rfdevice.trx_stop_func(&UE->rfdevice); //UE->rfdevice.trx_stop_func(&UE->rfdevice);
// sleep(1); // sleep(1);
nr_init_frame_parms_ue(&UE->frame_parms); nr_init_frame_parms_ue(config,&UE->frame_parms);
/*if (UE->rfdevice.trx_start_func(&UE->rfdevice) != 0 ) { /*if (UE->rfdevice.trx_start_func(&UE->rfdevice) != 0 ) {
LOG_E(HW,"Could not start the device\n"); LOG_E(HW,"Could not start the device\n");
oai_exit=1; oai_exit=1;
......
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