Commit 1300a341 authored by Matthieu Kanj's avatar Matthieu Kanj

MIB update

parent 27f044de
......@@ -83,79 +83,52 @@ void ccode_encode_npdsch_NB_IoT (int32_t numbits,
}
}
int dlsch_encoding_NB_IoT(unsigned char *a,
NB_IoT_eNB_NDLSCH_t *dlsch,
uint8_t Nsf, // number of subframes required for npdsch pdu transmission calculated from Isf (3GPP spec table)
unsigned int G) // G (number of available RE) is implicitly multiplied by 2 (since only QPSK modulation)
NB_IoT_eNB_NDLSCH_t *dlsch,
uint8_t Nsf, // number of subframes required for npdsch pdu transmission calculated from Isf (3GPP spec table)
unsigned int G) // G (number of available RE) is implicitly multiplied by 2 (since only QPSK modulation)
{
unsigned int crc = 1;
uint32_t crc = 1;
//unsigned char harq_pid = dlsch->current_harq_pid; // to check during implementation if harq_pid is required in the NB_IoT_eNB_DLSCH_t structure in defs_NB_IoT.h
uint8_t option1,option2,option3,option4;
unsigned int A;
uint8_t RCC;
//uint8_t npbch_a[21];
//bzero(npbch_a,21);
uint8_t npbch_a[85];
uint8_t npbch_a[85];
uint8_t npbch_a_crc[88];
bzero(npbch_a,85);
bzero(npbch_a_crc,88);
A = 680;
//A = dlsch->harq_process_sib1.TBS; // 680
//A = 19*8; // 680
A = 680;
dlsch->length_e = G*Nsf; // G*Nsf (number_of_subframes) = total number of bits to transmit G=236
int32_t numbits = A+24;
for (int i=0; i<19; i++)
{
npbch_a[i] = a[i];
}
for (int i=0; i<19; i++)
{
npbch_a[i] = a[i];
}
crc = crc24a_NB_IoT(npbch_a,A)>>8;
//crc = crc24a_NB_IoT(a,A)>>8; // CRC calculation (24 bits CRC)
crc = crc24a_NB_IoT(npbch_a,A)>>8;
for (int j=0; j<85; j++)
{
npbch_a_crc[j] = npbch_a[j];
}
for (int j=0; j<85; j++)
{
npbch_a_crc[j] = npbch_a[j];
}
// CRC attachment to payload
/*a[A>>3] = ((uint8_t*)&crc)[2];
a[1+(A>>3)] = ((uint8_t*)&crc)[1];
a[2+(A>>3)] = ((uint8_t*)&crc)[0];*/
npbch_a_crc[85] = ((uint8_t*)&crc)[2];
npbch_a_crc[86] = ((uint8_t*)&crc)[1];
npbch_a_crc[87] = ((uint8_t*)&crc)[0];
npbch_a_crc[85] = ((uint8_t*)&crc)[2];
npbch_a_crc[86] = ((uint8_t*)&crc)[1];
npbch_a_crc[87] = ((uint8_t*)&crc)[0];
dlsch->B = numbits; // The length of table b in bits
/*for (int i=0; i<21; i++) // to uncomment if option 2
{
npbch_a[i] = a[i];
}
*/
//memcpy(dlsch->b,a,numbits/8); // comment if option 2
memset(dlsch->d,LTE_NULL_NB_IoT,96);
for (int i=0; i<21; i++) // to uncomment if option 2
{
npbch_a[21-i-1] = a[i];
}
//ccode_encode_npdsch_NB_IoT(numbits, dlsch->b, dlsch->d+96, crc); // step 1 Tail-biting convolutional coding
// to uncomment if option 2
//ccode_encode_npdsch_NB_IoT(numbits,npbch_a, dlsch->d+96, crc);
ccode_encode_npdsch_NB_IoT(numbits,npbch_a_crc,dlsch->d+96,crc);
// sib1_w = 19*8*3*3=1368
RCC = sub_block_interleaving_cc_NB_IoT(numbits,dlsch->d+96,dlsch->w); // step 2 interleaving
// length e = 1888
lte_rate_matching_cc_NB_IoT(RCC,dlsch->length_e,dlsch->w,dlsch->e); // step 3 Rate Matching
return(0);
}
......
......@@ -56,6 +56,8 @@ typedef struct {
int frame_tx;
/// frame to act upon for reception
int frame_rx;
uint16_t HFN;
/// \brief Instance count for RXn-TXnp4 processing thread.
/// \internal This variable is protected by \ref mutex_rxtx.
int instance_cnt_rxtx;
......
......@@ -225,15 +225,28 @@ void common_signal_procedures_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
NB_IoT_eNB_NDLSCH_t *sib1 = &eNB->ndlsch_SIB1;
int **txdataF = eNB->common_vars.txdataF[0];
int subframe = proc->subframe_tx;
int frame = proc->frame_tx;
uint32_t frame = proc->frame_tx;
//uint16_t Ntti = 10; //ntti = 10
int RB_IoT_ID=2 ; // XXX should be initialized (RB reserved for NB-IoT, PRB index)
int RB_IoT_ID=22 ; // XXX should be initialized (RB reserved for NB-IoT, PRB index)
int With_NSSS=0; // With_NSSS = 1; if the frame include a sub-Frame with NSSS signal
uint8_t *npbch_pdu = get_NB_IoT_MIB();
uint8_t *sib1_pdu = get_NB_IoT_SIB1();
uint32_t hyper_frame=proc->HFN;
////////////////////////////////////////////////////////////////////////////////////
rrc_eNB_carrier_data_NB_IoT_t *carrier = &eNB_rrc_inst_NB_IoT->carrier[0];
if(frame%64==0 && subframe ==0)
{//printf("dooooo MIB");
do_MIB_NB_IoT(carrier,1,frame,hyper_frame);
/* for(int i = 0; i<5;i++)
printf("%02X ",eNB_rrc_inst_NB_IoT->carrier[0].MIB_NB_IoT[i]);
printf("\n");*/
}
/////////////////////////////////////////////////////////////////////////////////
//uint8_t *control_region_size = get_NB_IoT_SIB1_eutracontrolregionsize();
int G=0;
rrc_eNB_carrier_data_NB_IoT_t *carrier = &eNB_rrc_inst_NB_IoT->carrier[0];
//NSSS only happened in the even frame
if(frame%2==0)
......@@ -268,16 +281,14 @@ void common_signal_procedures_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
RB_IoT_ID);
}
uint8_t *npbch_pdu = get_NB_IoT_MIB();
uint8_t *sib1_pdu = get_NB_IoT_SIB1();
generate_pilots_NB_IoT(eNB,
txdataF,
AMP,
subframe,
RB_IoT_ID,
With_NSSS);
if(subframe == 0)
{
generate_npbch(broadcast_str,
txdataF,
AMP,
......@@ -289,7 +300,7 @@ void common_signal_procedures_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
if(subframe == 4 && (frame%2==0) && (frame%32<16) )
if((subframe == 4) && (frame%2==0) && (frame%32<16) ) ////if((subframe != 0) && (subframe != 4) && (subframe != 9) )
{
if( frame%32 == 0 )
{
......@@ -312,13 +323,28 @@ void common_signal_procedures_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
3, // control region size for LTE , values between 0..3, (0 for stand-alone / 1, 2 or 3 for in-band)
sib1,
236, // number of bits per subframe
((frame%32)/2), ///npdsch_data_subframe, data per subframe // subframe index of the data table of npdsch channel (G*Nsf) , values are between 0..Nsf
((frame%32)/2),///npdsch_data_subframe, data per subframe//subframe index of the data table of npdsch channel (G*Nsf) ((frame%32)/2),values are between 0..Nsf
RB_IoT_ID);
}
generate_pilots_NB_IoT(eNB,
txdataF,
AMP,
subframe,
RB_IoT_ID,
With_NSSS);
if(frame==1023 && subframe==9)
{
//printf("%d",hyper_frame);
if(proc->HFN==1023)
{
proc->HFN=0;
}else{
proc->HFN++;
}
}
}
......
......@@ -95,9 +95,9 @@ int errno;
/*do_MIB_NB_NB_IoT*/
uint8_t do_MIB_NB_IoT(
rrc_eNB_carrier_data_NB_IoT_t *carrier,
uint16_t N_RB_DL,//may not needed--> for NB_IoT only 1 PRB is used
uint32_t frame,
rrc_eNB_carrier_data_NB_IoT_t *carrier,
uint16_t N_RB_DL,//may not needed--> for NB_IoT only 1 PRB is used
uint32_t frame,
uint32_t hyper_frame)
{
asn_enc_rval_t enc_rval;
......@@ -115,11 +115,14 @@ uint8_t do_MIB_NB_IoT(
*
* NOTE: in OAI never modify the SIB messages!!??
*/
//printf("Frame %d",frame);
//printf("HFN %d",hyper_frame);
//XXX check if correct the bit assignment
uint8_t sfn_MSB = (uint8_t)((frame>>6) & 0x0f); // all the 4 bits are set to 1
uint8_t hsfn_LSB = (uint8_t)(hyper_frame & 0x3); //2 bits set to 1 (0x3 = 0011)
uint8_t sfn_MSB = (uint8_t)((frame>>2) & 0xf0);//(uint8_t)((frame>>6) & 0x0f); // all the 4 bits are set to 1
uint8_t hsfn_LSB = (uint8_t)((hyper_frame<<6) & 0xc0);///(uint8_t)(hyper_frame & 0x03); //2 bits set to 1 (0x3 = 0011)
uint16_t spare=0; //11 bits --> use uint16
//printf("Frame %d",sfn_MSB);
//printf("HFN %d",hsfn_LSB);
mib_NB_IoT->message.systemFrameNumber_MSB_r13.buf = &sfn_MSB;
mib_NB_IoT->message.systemFrameNumber_MSB_r13.size = 1; //if expressed in byte
......@@ -141,11 +144,11 @@ uint8_t do_MIB_NB_IoT(
//to be decided
mib_NB_IoT->message.operationModeInfo_r13.present = MasterInformationBlock_NB__operationModeInfo_r13_PR_inband_SamePCI_r13;
mib_NB_IoT->message.operationModeInfo_r13.choice.inband_SamePCI_r13.eutra_CRS_SequenceInfo_r13 = 5; /// TODO: take into account RB_index of NB-IoT
mib_NB_IoT->message.operationModeInfo_r13.choice.inband_SamePCI_r13.eutra_CRS_SequenceInfo_r13 = 8; /// TODO: take into account RB_index of NB-IoT
printf("[MIB] Intialization of frame information ,sfn_MSB %x, hsfn_LSB %x\n",
(uint32_t)sfn_MSB,
(uint32_t)hsfn_LSB);
// printf("[MIB] Intialization of frame information ,sfn_MSB %x, hsfn_LSB %x\n",
// (uint32_t)sfn_MSB,
// (uint32_t)hsfn_LSB);
enc_rval = uper_encode_to_buffer(&asn_DEF_BCCH_BCH_Message_NB,
(void*)mib_NB_IoT,
......
......@@ -54,7 +54,7 @@ PHY_VARS_eNB* init_lte_eNB(LTE_DL_FRAME_PARMS *frame_parms,
PHY_vars_eNB->frame_parms.Nid_cell = Nid_cell; ///////((Nid_cell/3)*3)+((eNB_id+Nid_cell)%3);
PHY_vars_eNB->frame_parms.nushift = PHY_vars_eNB->frame_parms.Nid_cell%6;
// for NB-IoT testing
PHY_vars_eNB->ndlsch_SIB1.si_rnti = 0xfff4;
PHY_vars_eNB->ndlsch_SIB1.si_rnti = 0xffff;
////////////////////////////
phy_init_lte_eNB(PHY_vars_eNB,0,abstraction_flag);
......
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