Commit 31127b37 authored by Nick Ho's avatar Nick Ho

Fix mapping parameters && preamble simulator

parent b08cf2ee
...@@ -216,6 +216,7 @@ int generate_NDLSCH_NB_IoT(NB_IoT_eNB_NDLSCH_t *RAR, ...@@ -216,6 +216,7 @@ int generate_NDLSCH_NB_IoT(NB_IoT_eNB_NDLSCH_t *RAR,
if( RAR->active == 1 ) if( RAR->active == 1 )
{ {
LOG_I(PHY,"[Frame: %d][Subframe: %d]sent RAR\n",frame,subframe);
uint8_t *RAR_pdu = RAR->harq_process->pdu; uint8_t *RAR_pdu = RAR->harq_process->pdu;
uint32_t rep = RAR->repetition_number; uint32_t rep = RAR->repetition_number;
uint8_t eutra_control_region = 3; uint8_t eutra_control_region = 3;
...@@ -281,7 +282,7 @@ int generate_NDLSCH_NB_IoT(NB_IoT_eNB_NDLSCH_t *RAR, ...@@ -281,7 +282,7 @@ int generate_NDLSCH_NB_IoT(NB_IoT_eNB_NDLSCH_t *RAR,
RAR->counter_current_sf_repetition =0; RAR->counter_current_sf_repetition =0;
} else { } else {
//printf("RAR done\n");
RAR->active = 0; RAR->active = 0;
done =1; done =1;
} }
...@@ -308,6 +309,7 @@ int generate_NDLSCH_NB_IoT(NB_IoT_eNB_NDLSCH_t *RAR, ...@@ -308,6 +309,7 @@ int generate_NDLSCH_NB_IoT(NB_IoT_eNB_NDLSCH_t *RAR,
if (Nsf == RAR->pointer_to_subframe) if (Nsf == RAR->pointer_to_subframe)
{ {
//printf("RAR done\n");
RAR->active = 0; RAR->active = 0;
done =1; done =1;
} }
...@@ -339,7 +341,7 @@ int generate_NPDCCH_NB_IoT(NB_IoT_eNB_NPDCCH_t *DCI, ...@@ -339,7 +341,7 @@ int generate_NPDCCH_NB_IoT(NB_IoT_eNB_NPDCCH_t *DCI,
if( DCI->active[i] == 1) if( DCI->active[i] == 1)
{ {
LOG_I(PHY,"[Frame: %d][Subframe: %d]sent DCI\n",frame,subframe);
uint8_t *DCI_pdu = DCI->pdu[i]; uint8_t *DCI_pdu = DCI->pdu[i];
uint32_t rep = DCI->dci_repetitions[i]; /// repetition number uint32_t rep = DCI->dci_repetitions[i]; /// repetition number
uint8_t eutra_control_region = 3; uint8_t eutra_control_region = 3;
...@@ -392,6 +394,7 @@ int generate_NPDCCH_NB_IoT(NB_IoT_eNB_NPDCCH_t *DCI, ...@@ -392,6 +394,7 @@ int generate_NPDCCH_NB_IoT(NB_IoT_eNB_NPDCCH_t *DCI,
if(DCI->counter_repetition_number[i] == 0) if(DCI->counter_repetition_number[i] == 0)
{ {
//printf("DCI REP done\n");
DCI->active[i] = 0; DCI->active[i] = 0;
done =1; done =1;
} }
......
...@@ -144,6 +144,62 @@ int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB, ...@@ -144,6 +144,62 @@ int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
//map the Isf (DCI param) to the number of subframes (Nsf) //map the Isf (DCI param) to the number of subframes (Nsf)
int resource_to_subframe[8] = {1,2,3,4,5,6,8,10}; int resource_to_subframe[8] = {1,2,3,4,5,6,8,10};
int Scheddly_less_128[8] = {0,4,8,12,16,32,64,128};
int Scheddly_bigger_128[8] = {0,16,32,64,128,256,512,1024};
int Irep_to_Nrep[16] = {1,2,4,8,16,32,64,128,192,256,384,512,768,1024,1536,2048};
int Idelay_to_K0(uint8_t Sched_delay, int Rmax)
{
int k0=0;
if(Rmax <128)
{
k0 = Scheddly_less_128[Sched_delay];
}else if(Rmax >=128)
{
k0 = Scheddly_bigger_128[Sched_delay];
}
return k0;
}
int DCIrep_to_real_rep(uint8_t DCI_rep, int Rmax)
{
int R=0;
if(Rmax == 1)
{
if(DCI_rep == 0)
R = 1;
}else if (Rmax == 2)
{
if(DCI_rep == 0)
R = 1;
else if(DCI_rep == 1)
R = 2;
}else if (Rmax == 4)
{
if(DCI_rep == 0)
R = 1;
else if(DCI_rep == 1)
R = 2;
else if(DCI_rep == 2)
R = 4;
}else if (Rmax >= 8)
{
if(DCI_rep == 0)
R = Rmax/8;
else if(DCI_rep == 1)
R = Rmax/4;
else if(DCI_rep == 2)
R = Rmax/2;
else if(DCI_rep == 3)
R = Rmax;
}
return R;
}
int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB, int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
int frame, int frame,
uint8_t subframe, uint8_t subframe,
...@@ -243,10 +299,13 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB, ...@@ -243,10 +299,13 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
ndlcch->active[ncce_index] = 1; //will be activated by the corresponding NDSLCH pdu ndlcch->active[ncce_index] = 1; //will be activated by the corresponding NDSLCH pdu
// use this value to configure PHY both harq_processes and resource mapping. // use this value to configure PHY both harq_processes and resource mapping.
ndlcch->scheduling_delay[ncce_index] = Sched_delay; ndlcch->scheduling_delay[ncce_index] = Idelay_to_K0(Sched_delay,32);
ndlcch->resource_assignment[ncce_index] = resource_to_subframe[ResAssign]; //from Isf of DCI to the number of subframe ndlcch->resource_assignment[ncce_index] = resource_to_subframe[ResAssign]; //from Isf of DCI to the number of subframe
ndlcch->repetition_number[ncce_index] = RepNum; // repetition number for NPDSCH ndlcch->repetition_number[ncce_index] = Irep_to_Nrep[RepNum]; // repetition number for NPDSCH
ndlcch->dci_repetitions[ncce_index] = DCIRep; ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax ndlcch->dci_repetitions[ncce_index] = DCIrep_to_real_rep(DCIRep,32); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax
//printf("dci_repetitions: %d\n",ndlcch->dci_repetitions[ncce_index]);
ndlcch->modulation[ncce_index] = 2; //QPSK ndlcch->modulation[ncce_index] = 2; //QPSK
//// ////////////////////////////////////////////////if(ndlcch->round == 0) //this should be set from initialization (init-lte) //// ////////////////////////////////////////////////if(ndlcch->round == 0) //this should be set from initialization (init-lte)
...@@ -261,7 +320,7 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB, ...@@ -261,7 +320,7 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
ndlcch->TBS[ncce_index] = TBStable_NB_IoT[mcs][ResAssign]; ndlcch->TBS[ncce_index] = TBStable_NB_IoT[mcs][ResAssign];
//ndlcch->subframe[ncce_index] = subframe; //ndlcch->subframe[ncce_index] = subframe;
ndlcch->counter_repetition_number[ncce_index] = DCIRep; ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax ndlcch->counter_repetition_number[ncce_index] = DCIrep_to_real_rep(DCIRep,32); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax
//ndlsch_harq->B; we don-t have now my is given when we receive the dlsch data //ndlsch_harq->B; we don-t have now my is given when we receive the dlsch data
//ndlsch->error_treshold //ndlsch->error_treshold
//ndlsch->G?? //ndlsch->G??
...@@ -320,10 +379,10 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB, ...@@ -320,10 +379,10 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
ndlcch->active[ncce_index] = 1;//will be activated by the corresponding NDSLCH pdu ndlcch->active[ncce_index] = 1;//will be activated by the corresponding NDSLCH pdu
// use this value to configure PHY both harq_processes and resource mapping. // use this value to configure PHY both harq_processes and resource mapping.
ndlcch->scheduling_delay[ncce_index] = Sched_delay; ndlcch->scheduling_delay[ncce_index] = Idelay_to_K0(Sched_delay,32);
ndlcch->resource_assignment[ncce_index] = resource_to_subframe[ResAssign]; //from Isf of DCI to the number of subframe ndlcch->resource_assignment[ncce_index] = resource_to_subframe[ResAssign]; //from Isf of DCI to the number of subframe
ndlcch->repetition_number[ncce_index] = RepNum; ndlcch->repetition_number[ncce_index] = Irep_to_Nrep[RepNum]; // repetition number for NPDSCH
ndlcch->dci_repetitions[ncce_index] = DCIRep; // ????????????? mapping with the table in spec, take into account Rmax ndlcch->dci_repetitions[ncce_index] = DCIrep_to_real_rep(DCIRep,32); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax
ndlcch->modulation[ncce_index] = 2; //QPSK ndlcch->modulation[ncce_index] = 2; //QPSK
//if(ndlcch->round == 0){ //this should be set from initialization (init-lte) //if(ndlcch->round == 0){ //this should be set from initialization (init-lte)
...@@ -333,7 +392,7 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB, ...@@ -333,7 +392,7 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
ndlcch->pdu[ncce_index] = DLSCH_DCI_NB_IoT; ndlcch->pdu[ncce_index] = DLSCH_DCI_NB_IoT;
ndlcch->counter_repetition_number[ncce_index] = DCIRep; ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax ndlcch->counter_repetition_number[ncce_index] = DCIrep_to_real_rep(DCIRep,32); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax
//} //}
//ndlcch->frame[ncce_index] = frame; //ndlcch->frame[ncce_index] = frame;
//ndlcch->subframe[ncce_index] = subframe; //ndlcch->subframe[ncce_index] = subframe;
...@@ -376,7 +435,7 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB, ...@@ -376,7 +435,7 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
((DCIN2_Pag_t *)DLSCH_DCI_NB_IoT)->DCIRep =DCIRep; ((DCIN2_Pag_t *)DLSCH_DCI_NB_IoT)->DCIRep =DCIRep;
add_dci_NB_IoT(eNB->DCI_pdu,DLSCH_DCI_NB_IoT,rnti,sizeof(DCIN2_Pag_t),aggregation,sizeof_DCIN2_Pag_t,DCIFormatN2_Pag,npdcch_start_symbol); //add_dci_NB_IoT(eNB->DCI_pdu,DLSCH_DCI_NB_IoT,rnti,sizeof(DCIN2_Pag_t),aggregation,sizeof_DCIN2_Pag_t,DCIFormatN2_Pag,npdcch_start_symbol);
// use this value to configure PHY both harq_processes and resource mapping. // use this value to configure PHY both harq_processes and resource mapping.
break; break;
...@@ -390,7 +449,7 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB, ...@@ -390,7 +449,7 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
// compute DL power control parameters // compute DL power control parameters
free(DLSCH_DCI_NB_IoT); //free(DLSCH_DCI_NB_IoT);
return(0); return(0);
} }
......
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
#include "PHY/INIT/defs_NB_IoT.h" #include "PHY/INIT/defs_NB_IoT.h"
int Irep_to_Nrep_x[16] = {1,2,4,8,16,32,64,128,192,256,384,512,768,1024,1536,2048};
void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB *eNB, void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB *eNB,
eNB_rxtx_proc_t *proc, eNB_rxtx_proc_t *proc,
...@@ -212,12 +214,12 @@ void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB *eNB, ...@@ -212,12 +214,12 @@ void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB *eNB,
eNB->ndlsch_RAR->rnti_type = rel13->rnti_type; eNB->ndlsch_RAR->rnti_type = rel13->rnti_type;
eNB->ndlsch_RAR->resource_assignment = rel13->resource_assignment; // for NDLSCH // this value point to --> number of subframes needed eNB->ndlsch_RAR->resource_assignment = rel13->resource_assignment; // for NDLSCH // this value point to --> number of subframes needed
eNB->ndlsch_RAR->repetition_number = rel13->repetition_number; eNB->ndlsch_RAR->repetition_number = Irep_to_Nrep_x[rel13->repetition_number];
eNB->ndlsch_RAR->modulation = rel13->modulation; eNB->ndlsch_RAR->modulation = rel13->modulation;
eNB->ndlsch_RAR->number_of_subframes_for_resource_assignment = rel13->number_of_subframes_for_resource_assignment; // for NDLSCH //table 16.4.1.3-1 // TS 36.213 eNB->ndlsch_RAR->number_of_subframes_for_resource_assignment = rel13->number_of_subframes_for_resource_assignment; // for NDLSCH //table 16.4.1.3-1 // TS 36.213
eNB->ndlsch_RAR->counter_repetition_number = rel13->repetition_number; eNB->ndlsch_RAR->counter_repetition_number = Irep_to_Nrep_x[rel13->repetition_number];
eNB->ndlsch_RAR->counter_current_sf_repetition = 0; eNB->ndlsch_RAR->counter_current_sf_repetition = 0;
eNB->ndlsch_RAR->pointer_to_subframe = 0; eNB->ndlsch_RAR->pointer_to_subframe = 0;
...@@ -244,12 +246,12 @@ void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB *eNB, ...@@ -244,12 +246,12 @@ void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB *eNB,
eNB->ndlsch_RAR->rnti_type = rel13->rnti_type; eNB->ndlsch_RAR->rnti_type = rel13->rnti_type;
eNB->ndlsch_RAR->resource_assignment = rel13->resource_assignment ; // for NDLSCH // this value point to --> number of subframes needed eNB->ndlsch_RAR->resource_assignment = rel13->resource_assignment ; // for NDLSCH // this value point to --> number of subframes needed
eNB->ndlsch_RAR->repetition_number = rel13->repetition_number; eNB->ndlsch_RAR->repetition_number = Irep_to_Nrep_x[rel13->repetition_number];
eNB->ndlsch_RAR->modulation = rel13->modulation; eNB->ndlsch_RAR->modulation = rel13->modulation;
eNB->ndlsch_RAR->number_of_subframes_for_resource_assignment = rel13->number_of_subframes_for_resource_assignment; // for NDLSCH //table 16.4.1.3-1 // TS 36.213 eNB->ndlsch_RAR->number_of_subframes_for_resource_assignment = rel13->number_of_subframes_for_resource_assignment; // for NDLSCH //table 16.4.1.3-1 // TS 36.213
eNB->ndlsch_RAR->counter_repetition_number = rel13->repetition_number; eNB->ndlsch_RAR->counter_repetition_number = Irep_to_Nrep_x[rel13->repetition_number];
eNB->ndlsch_RAR->counter_current_sf_repetition = 0; eNB->ndlsch_RAR->counter_current_sf_repetition = 0;
eNB->ndlsch_RAR->pointer_to_subframe = 0; eNB->ndlsch_RAR->pointer_to_subframe = 0;
......
...@@ -234,7 +234,7 @@ void common_signal_procedures_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) ...@@ -234,7 +234,7 @@ void common_signal_procedures_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
uint32_t hyper_frame=proc->HFN; uint32_t hyper_frame=proc->HFN;
//fp->flag_free_sf =0; fp->flag_free_sf =0;
//////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////
/* /*
rrc_eNB_carrier_data_NB_IoT_t *carrier = &eNB_rrc_inst_NB_IoT->carrier[0]; rrc_eNB_carrier_data_NB_IoT_t *carrier = &eNB_rrc_inst_NB_IoT->carrier[0];
...@@ -787,6 +787,9 @@ void generate_eNB_dlsch_params_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t * proc,n ...@@ -787,6 +787,9 @@ void generate_eNB_dlsch_params_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t * proc,n
npdcch = eNB->npdcch_DCI; npdcch = eNB->npdcch_DCI;
LOG_I(PHY,"Generating pdcch params for DCIN1 RAR and packing DCI\n");
//LOG_I(PHY,"Rep of DCI is : %d\n",DCI_Content->DCIN1_RAR.RepNum);
//LOG_I(PHY,"Generating dlsch params for RA_RNTI and packing DCI\n"); //LOG_I(PHY,"Generating dlsch params for RA_RNTI and packing DCI\n");
generate_eNB_dlsch_params_from_dci_NB_IoT(eNB, generate_eNB_dlsch_params_from_dci_NB_IoT(eNB,
frame, frame,
......
...@@ -2,15 +2,49 @@ ...@@ -2,15 +2,49 @@
#include "LAYER2/MAC/proto_NB_IoT.h" #include "LAYER2/MAC/proto_NB_IoT.h"
#include "LAYER2/MAC/extern_NB_IoT.h" #include "LAYER2/MAC/extern_NB_IoT.h"
int tmp =0;
void simulate_preamble(UL_IND_NB_IoT_t *UL_INFO, int CE, int sc)
{
UL_INFO->nrach_ind.number_of_initial_scs_detected = 1;
UL_INFO->nrach_ind.nrach_pdu_list[0].nrach_indication_rel13.initial_sc = sc;
UL_INFO->nrach_ind.nrach_pdu_list[0].nrach_indication_rel13.timing_advance = 0;
UL_INFO->nrach_ind.nrach_pdu_list[0].nrach_indication_rel13.nrach_ce_level = CE;
}
void enable_preamble_simulation(UL_IND_NB_IoT_t *UL_INFO,int i)
{
if(i == 1)
{
// simulate preamble session
if(UL_INFO->frame==60 && UL_INFO->subframe==2 && tmp==0)
{
simulate_preamble(UL_INFO,0,2);
tmp++;
}
if(UL_INFO->frame==100 && UL_INFO->subframe==2 && tmp==1)
{
simulate_preamble(UL_INFO,1,13);
tmp++;
}
if(UL_INFO->frame==60 && UL_INFO->subframe==2 && tmp==2)
{
simulate_preamble(UL_INFO,2,26);
tmp++;
}
}
}
// Sched_INFO as a input for the scheduler // Sched_INFO as a input for the scheduler
void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO) void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
{ {
int i=0; int i=0;
uint32_t abs_subframe; uint32_t abs_subframe;
Sched_Rsp_NB_IoT_t *SCHED_info = &mac_inst->Sched_INFO;; Sched_Rsp_NB_IoT_t *SCHED_info = &mac_inst->Sched_INFO;
//UE_TEMPLATE_NB_IoT *UE_info; //UE_TEMPLATE_NB_IoT *UE_info;
enable_preamble_simulation(UL_INFO,1);
//If there is a preamble, do the initiate RA procedure //If there is a preamble, do the initiate RA procedure
if(UL_INFO->nrach_ind.number_of_initial_scs_detected>0) if(UL_INFO->nrach_ind.number_of_initial_scs_detected>0)
{ {
......
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