Commit fc831af9 authored by Matthieu Kanj's avatar Matthieu Kanj

msg2 implementation

parent 892a4bd1
......@@ -35,7 +35,7 @@
#include <string.h>
#endif
//#include "PHY/defs.h"
//#include "PHY/LTE_TRANSPORT/dci_NB_IoT.h"
//#include "PHY/LTE_TRANSPORT/proto_NB_IoT.h"
//#include "PHY/CODING/defs_NB_IoT.h"
#include "PHY/defs_NB_IoT.h" // /LTE_TRANSPORT/defs_NB_IoT.h
//#include "PHY/LTE_REFSIG/defs_NB_IoT.h"
......@@ -104,14 +104,15 @@ void dci_encoding_NB_IoT(uint8_t *a[2], // Array of two DCI pdus, even if
///The scrambling sequence shall be initialised at the start of the search space and after every 4th NPDCCH subframes.
///
///
void npdcch_scrambling_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
uint8_t *e[2], // Input data
void npdcch_scrambling_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,
uint8_t *e, // Input data
int length, // Total number of bits to transmit in one subframe(case of DCI = G)
uint8_t Ns, //XXX we pass the subframe // Slot number (0..19)
uint8_t dci_number, // This variable should takes the 1 or 2 (1 for in case of one DCI, 2 in case of two DCI)
uint8_t agr_level) // Aggregation level
{
int i,k=0;
int i;
uint32_t x1, x2, s=0;
uint8_t reset;
uint8_t occupation_size=1;
......@@ -134,7 +135,7 @@ void npdcch_scrambling_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
s = lte_gold_generic_NB_IoT(&x1, &x2, reset);
reset = 0;
}
e[0][k] = (e[0][k]&1) ^ ((s>>(i&0x1f))&1);
e[i] = (e[i]&1) ^ ((s>>(i&0x1f))&1);
}
}else if(dci_number == 2 && occupation_size == 2) { // Case of two DCI
......@@ -148,7 +149,7 @@ void npdcch_scrambling_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
s = lte_gold_generic_NB_IoT(&x1, &x2, reset);
reset = 0;
}
e[0][k] = (e[0][k]&1) ^ ((s>>(i&0x1f))&1);
e[i] = (e[i]&1) ^ ((s>>(i&0x1f))&1);
}
// reset of the scrambling function
reset = 1;
......@@ -161,13 +162,13 @@ void npdcch_scrambling_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
s = lte_gold_generic_NB_IoT(&x1, &x2, reset);
reset = 0;
}
e[1][k] = (e[1][k]&1) ^ ((s>>(i&0x1f))&1);
e[i] = (e[i]&1) ^ ((s>>(i&0x1f))&1);
}
}
}
int dci_allocate_REs_in_RB_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
//// correction is needed to this function
int dci_allocate_REs_in_RB_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,
int32_t **txdataF,
uint32_t *jj,
uint32_t symbol_offset,
......@@ -409,17 +410,18 @@ int dci_allocate_REs_in_RB_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
int dci_modulation_NB_IoT(int32_t **txdataF,
int16_t amp,
NB_IoT_DL_FRAME_PARMS *frame_parms,
LTE_DL_FRAME_PARMS *frame_parms,
uint8_t control_region_size, //XXX we pass the npdcch_start_symbol // control region size for LTE , values between 0..3, (0 for stand-alone / 1, 2 or 3 for in-band)
uint8_t *e[2], // Input data
int G, // number of bits per subframe
uint8_t *e, // Input data
uint8_t dci_number, // This variable should takes the 1 or 2 (1 for in case of one DCI, 2 in case of two DCI)
uint8_t agr_level) // Aggregation level
uint8_t agr_level,
int RB_index,
int subframe) // Aggregation level
{
uint32_t jj=0;
uint32_t re_allocated,symbol_offset;
uint16_t l;
uint8_t id_offset,pilots=0;
uint8_t id_offset,pilot_shift,pilots=0;
unsigned short bandwidth_even_odd;
unsigned short NB_IoT_start, RB_IoT_ID;
......@@ -427,24 +429,50 @@ int dci_modulation_NB_IoT(int32_t **txdataF,
id_offset=0;
// testing if the total number of RBs is even or odd
bandwidth_even_odd = frame_parms->N_RB_DL % 2; // 0 even, 1 odd
RB_IoT_ID = frame_parms->NB_IoT_RB_ID;
//RB_IoT_ID = frame_parms->NB_IoT_RB_ID;
RB_IoT_ID = RB_index;
// step 5, 6, 7 // modulation and mapping (slot 1, symbols 0..3)
for (l=control_region_size; l<14; l++) { // loop on OFDM symbols
if((l>=4 && l<=8) || (l>=11 && l<=13))
for (l=control_region_size; l<14; l++) { // loop on OFDM symbols
if((l>=4 && l<=7) || (l>=11 && l<=13))
{
pilots =1;
pilots = 1;
if(l==4 || l==6 || l==11 || l==13)
{
pilot_shift = 1;
}
} else {
pilots=0;
pilots = 0;
}
id_offset = frame_parms->Nid_cell % 3; // Cell_ID_NB_IoT % 3
id_offset = frame_parms->Nid_cell % 6; // Cell_ID_NB_IoT % 6
if(RB_IoT_ID < (frame_parms->N_RB_DL/2))
{
NB_IoT_start = frame_parms->ofdm_symbol_size - 12*(frame_parms->N_RB_DL/2) - (bandwidth_even_odd*6) + 12*(RB_IoT_ID% (int)(ceil(frame_parms->N_RB_DL/(float)2)));
NB_IoT_start = frame_parms->ofdm_symbol_size - 12*(frame_parms->N_RB_DL/2) - (bandwidth_even_odd*6) + 12*(RB_IoT_ID % (int)(ceil(frame_parms->N_RB_DL/(float)2)));
} else {
NB_IoT_start = (bandwidth_even_odd*6) + 12*(RB_IoT_ID % (int)(ceil(frame_parms->N_RB_DL/(float)2)));
NB_IoT_start = 1 + (bandwidth_even_odd*6) + 12*(RB_IoT_ID % (int)(ceil(frame_parms->N_RB_DL/(float)2)));
}
symbol_offset = frame_parms->ofdm_symbol_size*l + NB_IoT_start; // symbol_offset = 512 * L + NB_IOT_RB start
dci_allocate_REs_in_RB_NB_IoT(frame_parms,
symbol_offset = (14*subframe*frame_parms->ofdm_symbol_size) + frame_parms->ofdm_symbol_size*l + NB_IoT_start; // symbol_offset = 512 * L + NB_IOT_RB start
allocate_REs_in_RB_NB_IoT(frame_parms,
txdataF,
&jj,
symbol_offset,
&e[0],
pilots,
amp,
id_offset,
pilot_shift,
&re_allocated);
}
// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_MODULATION, VCD_FUNCTION_OUT);
return (re_allocated);
}
//------------------------------------------------
// BCOM code functions npdcch end
//------------------------------------------------
/*dci_allocate_REs_in_RB_NB_IoT(frame_parms,
txdataF,
&jj,
symbol_offset,
......@@ -455,18 +483,8 @@ int dci_modulation_NB_IoT(int32_t **txdataF,
&re_allocated,
dci_number,
agr_level);
}
// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_MODULATION, VCD_FUNCTION_OUT);
return (re_allocated);
}
//------------------------------------------------
// BCOM code functions npdcch end
//------------------------------------------------
*/
uint8_t generate_dci_top_NB_IoT(NB_IoT_eNB_NPDCCH_t *npdcch,
uint8_t Num_dci,
......
......@@ -176,6 +176,37 @@ typedef struct {
} NB_IoT_DL_eNB_SIB_t;
typedef struct {
uint16_t si_rnti;
/// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
uint8_t e[236];
/// data after scrambling
uint8_t s_e[236];
//length of the table e
uint16_t length_e; // new parameter
/// Tail-biting convolutional coding outputs
uint8_t d[96+(3*(24+56))]; // new parameter
/// Sub-block interleaver outputs
uint8_t w[3*3*(56+24)]; // new parameter
/// Status Flag indicating for this DLSCH (idle,active,disabled)
//SCH_status_t status;
/// Transport block size
uint32_t TBS;
/// The payload + CRC size in bits, "B" from 36-212
uint32_t B;
/// Pointer to the payload
uint8_t *b;
///pdu of the ndlsch message
uint8_t *pdu;
/// Frame where current HARQ round was sent
uint32_t frame;
/// Subframe where current HARQ round was sent
uint32_t subframe;
uint8_t pdu_buffer_index;
} NB_IoT_DL_eNB_RAR_t;
typedef struct {
/// NB-IoT
SCH_status_NB_IoT_t status;
......@@ -590,7 +621,7 @@ typedef struct {
//////////////////////////////////////////////////////////////////////
NB_IoT_DL_eNB_SIB_t content_sib1;
NB_IoT_DL_eNB_SIB_t content_sib23;
NB_IoT_DL_eNB_RAR_t content_rar;
/// Number of soft channel bits
uint32_t G;
......@@ -833,5 +864,19 @@ typedef struct {
} NB_IoT_eNB_NPBCH_t;
#define NPDCCH_A 23
typedef struct {
//the 2 LSB of the hsfn (the MSB are indicated by the SIB1-NB)
uint16_t h_sfn_lsb;
uint8_t npdcch_d[2][96+(3*(16+NPDCCH_A))];
uint8_t npdcch_w[2][3*3*(16+NPDCCH_A)];
uint8_t npdcch_e[2][236];
///pdu of the npbch message
uint8_t pdu[2][3];
} NB_IoT_eNB_NPDCCH_temp_t;
#endif
......@@ -142,6 +142,69 @@ if(option ==1)
return(0);
}
///////////////////////////////////////////////////////////////////////////
////////////////////////////////temp function////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
int dlsch_encoding_rar_NB_IoT(unsigned char *a,
NB_IoT_DL_eNB_RAR_t *dlsch, //NB_IoT_eNB_NDLSCH_t
uint8_t Nsf, // number of subframes required for npdsch pdu transmission calculated from Isf (3GPP spec table)
unsigned int G,
uint8_t option) // G (number of available RE) is implicitly multiplied by 2 (since only QPSK modulation)
{
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[7];
uint8_t npbch_a_crc[10];
bzero(npbch_a,7);
bzero(npbch_a_crc,10);
A = 56;
dlsch->length_e = G; // G*Nsf (number_of_subframes) = total number of bits to transmit G=236
int32_t numbits = A+24;
if(option ==1)
{
for (int i=0; i<7; i++)
{
npbch_a[i] = a[i];
}
} else {
for (int i=0; i<33; i++)
{
npbch_a[i] = a[i];
}
}
crc = crc24a_NB_IoT(npbch_a,A)>>8;
for (int j=0; j<7; j++)
{
npbch_a_crc[j] = npbch_a[j];
}
npbch_a_crc[7] = ((uint8_t*)&crc)[2];
npbch_a_crc[8] = ((uint8_t*)&crc)[1];
npbch_a_crc[9] = ((uint8_t*)&crc)[0];
dlsch->B = numbits; // The length of table b in bits
//memcpy(dlsch->b,a,numbits/8); // comment if option 2
memset(dlsch->d,LTE_NULL_NB_IoT,96);
ccode_encode_npdsch_NB_IoT(numbits,npbch_a_crc,dlsch->d+96,crc);
RCC = sub_block_interleaving_cc_NB_IoT(numbits,dlsch->d+96,dlsch->w); // step 2 interleaving
lte_rate_matching_cc_NB_IoT(RCC,dlsch->length_e,dlsch->w,dlsch->e); // step 3 Rate Matching
return(0);
}
/*************************************************************************
Functions to initialize the code tables
......
......@@ -192,6 +192,72 @@ int dlsch_modulation_NB_IoT(int32_t **txdataF,
&re_allocated);
}
// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_MODULATION, VCD_FUNCTION_OUT);
return (re_allocated);
}
////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
////////////////////////////tmp functions /////////////////////////////////
int dlsch_modulation_rar_NB_IoT(int32_t **txdataF,
int16_t amp,
LTE_DL_FRAME_PARMS *frame_parms,
uint8_t control_region_size, // control region size for LTE , values between 0..3, (0 for stand-alone / 1, 2 or 3 for in-band)
NB_IoT_DL_eNB_RAR_t *dlsch0, //NB_IoT_eNB_NDLSCH_t
int G, // number of bits per subframe
unsigned int npdsch_data_subframe, // subframe index of the data table of npdsch channel (G*Nsf) , values are between 0..Nsf
unsigned int subframe,
unsigned short NB_IoT_RB_ID)
{
//uint8_t harq_pid = dlsch0->current_harq_pid;
//NB_IoT_DL_eNB_HARQ_t *dlsch0_harq = dlsch0->harq_processes[harq_pid];
uint32_t jj = 0;
uint32_t re_allocated,symbol_offset;
uint16_t l;
uint8_t id_offset,pilot_shift,pilots = 0;
unsigned short bandwidth_even_odd;
unsigned short NB_IoT_start, RB_IoT_ID;
re_allocated = 0;
id_offset = 0;
pilot_shift = 0;
// testing if the total number of RBs is even or odd
bandwidth_even_odd = frame_parms->N_RB_DL % 2; // 0 even, 1 odd
RB_IoT_ID = NB_IoT_RB_ID;
// step 5, 6, 7 // modulation and mapping (slot 1, symbols 0..3)
for (l=control_region_size; l<14; l++) { // loop on OFDM symbols
if((l>=4 && l<=7) || (l>=11 && l<=13))
{
pilots = 1;
if(l==4 || l==6 || l==11 || l==13)
{
pilot_shift = 1;
}
} else {
pilots = 0;
}
id_offset = frame_parms->Nid_cell % 6; // Cell_ID_NB_IoT % 6
if(RB_IoT_ID < (frame_parms->N_RB_DL/2))
{
NB_IoT_start = frame_parms->ofdm_symbol_size - 12*(frame_parms->N_RB_DL/2) - (bandwidth_even_odd*6) + 12*(RB_IoT_ID % (int)(ceil(frame_parms->N_RB_DL/(float)2)));
} else {
NB_IoT_start = 1 + (bandwidth_even_odd*6) + 12*(RB_IoT_ID % (int)(ceil(frame_parms->N_RB_DL/(float)2)));
}
symbol_offset = (14*subframe*frame_parms->ofdm_symbol_size) + frame_parms->ofdm_symbol_size*l + NB_IoT_start; // symbol_offset = 512 * L + NB_IOT_RB start
allocate_REs_in_RB_NB_IoT(frame_parms,
txdataF,
&jj,
symbol_offset,
&dlsch0->s_e[0],
pilots,
amp,
id_offset,
pilot_shift,
&re_allocated);
}
// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_MODULATION, VCD_FUNCTION_OUT);
return (re_allocated);
}
\ No newline at end of file
......@@ -74,3 +74,33 @@ void dlsch_sib_scrambling_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,
}
}
void dlsch_sib_scrambling_rar_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,
NB_IoT_DL_eNB_RAR_t *dlsch,
int tot_bits, // total number of bits to transmit
uint16_t Nf, // Nf is the frame number (0..9)
uint8_t Ns,
uint16_t rnti)
{
int i,j,k=0;
uint32_t x1,x2, s=0;
uint8_t *e = dlsch->e; //uint8_t *e=dlsch->harq_processes[dlsch->current_harq_pid]->e;
//x2 = (dlsch->si_rnti<<15) + (frame_parms->Nid_cell + 1) * ( (Nf % 61) + 1 ) ;
x2 = (rnti<<14) + ((Nf%2)<<13) + ((Ns>>1)<<9) + frame_parms->Nid_cell;
// for NPDSCH not carriying SIBs
//x2 = (dlsch->harq_process_sib1.rnti<<14) + ((Nf%2)<<13) + ((Ns>>1)<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 10.2.3.1
s = lte_gold_generic_NB_IoT(&x1, &x2, 1);
for (i=0; i<(1+(tot_bits>>5)); i++) {
for (j=0; j<32; j++,k++) {
dlsch->s_e[k] = (e[k]&1) ^ ((s>>j)&1);
}
s = lte_gold_generic_NB_IoT(&x1, &x2, 0);
}
}
......@@ -118,6 +118,12 @@ void dlsch_sib_scrambling_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,
uint16_t Nf,
uint8_t Ns);
void dlsch_sib_scrambling_rar_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,
NB_IoT_DL_eNB_RAR_t *dlsch,
int tot_bits, // total number of bits to transmit
uint16_t Nf, // Nf is the frame number (0..9)
uint8_t Ns,
uint16_t rnti);
/*
int scrambling_npbch_REs_rel_14(LTE_DL_FRAME_PARMS *frame_parms,
int32_t **txdataF,
......@@ -244,6 +250,36 @@ unsigned char get_Qm_ul_NB_IoT(unsigned char I_MCS, uint8_t N_sc_RU);
@returns status
*/
int dci_modulation_NB_IoT(int32_t **txdataF,
int16_t amp,
LTE_DL_FRAME_PARMS *frame_parms,
uint8_t control_region_size, //XXX we pass the npdcch_start_symbol // control region size for LTE , values between 0..3, (0 for stand-alone / 1, 2 or 3 for in-band)
uint8_t *e, // Input data
uint8_t dci_number, // This variable should takes the 1 or 2 (1 for in case of one DCI, 2 in case of two DCI)
uint8_t agr_level,
int RB_index,
int subframe);
int dci_allocate_REs_in_RB_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,
int32_t **txdataF,
uint32_t *jj,
uint32_t symbol_offset,
uint8_t *x0[2],
uint8_t pilots,
int16_t amp,
unsigned short id_offset,
uint32_t *re_allocated, // not used variable ??!!
uint8_t dci_number, // This variable should takes the 1 or 2 (1 for in case of one DCI, 2 in case of two DCI)
uint8_t agr_level);
void npdcch_scrambling_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,
uint8_t *e,
int length,
uint8_t Ns,
uint8_t dci_number,
uint8_t agr_level);
int dlsch_modulation_NB_IoT(int32_t **txdataF,
int16_t amp,
LTE_DL_FRAME_PARMS *frame_parms,
......@@ -254,13 +290,29 @@ int dlsch_modulation_NB_IoT(int32_t **txdataF,
unsigned int subframe,
unsigned short NB_IoT_RB_ID);
int dlsch_modulation_rar_NB_IoT(int32_t **txdataF,
int16_t amp,
LTE_DL_FRAME_PARMS *frame_parms,
uint8_t control_region_size, // control region size for LTE , values between 0..3, (0 for stand-alone / 1, 2 or 3 for in-band)
NB_IoT_DL_eNB_RAR_t *dlsch0, //NB_IoT_eNB_NDLSCH_t
int G, // number of bits per subframe
unsigned int npdsch_data_subframe, // subframe index of the data table of npdsch channel (G*Nsf) , values are between 0..Nsf
unsigned int subframe,
unsigned short NB_IoT_RB_ID);
int32_t dlsch_encoding_NB_IoT(unsigned char *a,
NB_IoT_DL_eNB_SIB_t *dlsch, // NB_IoT_eNB_NDLSCH_t
uint8_t Nsf, // number of subframes required for npdsch pdu transmission calculated from Isf (3GPP spec table)
unsigned int G,
uint8_t option); // G (number of available RE) is implicitly multiplied by 2 (since only QPSK modulation)
///////////////////////temp function ///////////////////////////////
int dlsch_encoding_rar_NB_IoT(unsigned char *a,
NB_IoT_DL_eNB_RAR_t *dlsch, //NB_IoT_eNB_NDLSCH_t
uint8_t Nsf, // number of subframes required for npdsch pdu transmission calculated from Isf (3GPP spec table)
unsigned int G,
uint8_t option);
/////////////////////////////////////////////////////////////////
void rx_ulsch_NB_IoT(PHY_VARS_eNB_NB_IoT *phy_vars_eNB,
eNB_rxtx_proc_NB_IoT_t *proc,
uint8_t eNB_id, // this is the effective sector id
......
......@@ -513,7 +513,8 @@ typedef struct PHY_VARS_eNB_s {
NB_IoT_eNB_NPBCH_t npbch;
NB_IoT_eNB_NDLSCH_t *ndlsch[NUMBER_OF_UE_MAX];
NB_IoT_eNB_NDLSCH_t ndlsch_SIB;
NB_IoT_eNB_NDLSCH_t ndlsch_rar;
NB_IoT_eNB_NPDCCH_temp_t npdcch_tmp;
////////////// For IF Module /////////////////////////////
IF_Module_NB_IoT_t *if_inst;
......
......@@ -76,6 +76,11 @@ typedef struct {
uint8_t dci_to_transmit;
uint8_t rar_to_transmit;
int next_frame_tx;
int next_subframe_tx;
uint32_t sheduling_info_rar;
uint8_t remaining_dci;
......
......@@ -495,7 +495,6 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
int subframe = proc->subframe_tx;
int frame = proc->frame_tx;
//int With_NSSS=0;
// NB-IoT synchro signals
......@@ -505,18 +504,292 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
//RA_template[i].RA_active=TRUE;
RA_TEMPLATE *RA_template = (RA_TEMPLATE *)&eNB_mac_inst[eNB->Mod_id].common_channels[eNB->CC_id].RA_template[0];
if( frame%2 ==0 && subframe ==1)
{
if( RA_template[0].generate_rar == 1 && proc->sheduling_info_rar != 1)
{
proc->ra_rnti_computed = RA_template[0].RA_rnti;
proc->dci_to_transmit =1;
proc->remaining_dci =4;
proc->sheduling_info_rar =1;
proc->rar_to_transmit =0;
//printf("detection ok in TX !!!!!!!!!!!!!!!!!");
//RA_template[0].generate_rar = 0;
//RA_template[0].RA_active = FALSE;
eNB->npdcch_tmp.pdu[0][0]=144; //90
eNB->npdcch_tmp.pdu[0][1]=66; //42
eNB->npdcch_tmp.pdu[0][2]=4; //4
}
}
if( RA_template[0].generate_rar == 1)
if(frame%4==0 && proc->dci_to_transmit ==1 && proc->remaining_dci >0)
{
NB_IoT_eNB_NPDCCH_temp_t *npdcch_struct = &eNB->npdcch_tmp;
if(subframe==2)
{
printf("\n DCI 2 sentttttt frame %d, subframe %d", frame, subframe);
printf("\n xxxxxxxxx RA-RNTI = %d xxxxxxxxxxxxxxx", RA_template[0].RA_rnti);
int32_t numbits = 23;
uint8_t RCC;
uint16_t npdcch_D = 16 + 23;
uint16_t npdcch_E = 236;
//uint16_t E = 200;
//uint8_t A = 3;
uint8_t agr_level = 2;
uint8_t dci_number=1;
uint8_t tab_a[3];
tab_a[0]= 144;
tab_a[1]= 66;
tab_a[2]= 4;
int RB_ID_IoT=22 ;
bzero(npdcch_struct->npdcch_e[0],npdcch_E);
memset(npdcch_struct->npdcch_d[0],LTE_NULL_NB_IoT,96);
ccode_encode_NB_IoT (numbits,2,tab_a,npdcch_struct->npdcch_d[0]+96,RA_template[0].RA_rnti);
RCC = sub_block_interleaving_cc_NB_IoT(npdcch_D,npdcch_struct->npdcch_d[0]+96,npdcch_struct->npdcch_w[0]);
lte_rate_matching_cc_NB_IoT(RCC,npdcch_E,npdcch_struct->npdcch_w[0],npdcch_struct->npdcch_e[0]);
npdcch_scrambling_NB_IoT(fp,npdcch_struct->npdcch_e[0],npdcch_E,(uint8_t)subframe*2,1,agr_level);
dci_modulation_NB_IoT(txdataF,AMP,fp,3,npdcch_struct->npdcch_e[0],1,2,22,subframe);
proc->remaining_dci--;
}
if(subframe ==3)
{
printf("\n DCI 3 sentttttt frame %d, subframe %d", frame, subframe);
dci_modulation_NB_IoT(txdataF,AMP,fp,3,npdcch_struct->npdcch_e,1,2,22,subframe);
proc->remaining_dci--;
}
if((subframe == 4) && (frame%2==0) && (frame%32>=16) )
{
printf("\n DCI 4 sentttttt frame %d, subframe %d", frame, subframe);
dci_modulation_NB_IoT(txdataF,AMP,fp,3,npdcch_struct->npdcch_e,1,2,22,subframe);
proc->remaining_dci--;
}
if(subframe ==6)
{
printf("\n DCI 6 sentttttt frame %d, subframe %d", frame, subframe);
dci_modulation_NB_IoT(txdataF,AMP,fp,3,npdcch_struct->npdcch_e,1,2,22,subframe);
proc->remaining_dci--;
if(proc->remaining_dci == 0)
{
proc->dci_to_transmit =0;
proc->rar_to_transmit =1;
proc->remaining_rar =4;
printf("xxxxx ERROR %d XXXXXX",proc->remaining_dci);
// uint8_t sib23x=0;
// uint8_t sib23v1x=0;
// uint8_t sib1v1x=0;
/* if( ((frame+1)%2==1) && ((frame+1)%64<16))
{
sib23x =1;
}*/
//if(sib23x ==1)
//{
/* if( ((frame+3)%2==1) && ((frame+3)%64<16))
{
sib23v1x =1;
}
if( ((frame+2)%2==0) && ((frame+2)%32<16))
{
sib1v1x =1;
}
if(sib23v1x ==1)
{
if(sib1v1x ==1)
{
proc->next_frame_tx=frame+4;
proc->next_subframe_tx=3;
}else{
proc->next_frame_tx=frame+4;
proc->next_subframe_tx=2;
}
} else {
if(sib1v1x ==1)
{
proc->next_frame_tx=frame+3;
proc->next_subframe_tx=3;
}else{
proc->next_frame_tx=frame+3;
proc->next_subframe_tx=2;
}
}
*/
///} else {
proc->next_frame_tx=frame+2;
proc->next_subframe_tx=1;
// }
}
}
if(subframe ==7)
{
printf("\n DCI 7 sentttttt frame %d, subframe %d", frame, subframe);
dci_modulation_NB_IoT(txdataF,AMP,fp,3,npdcch_struct->npdcch_e,1,2,22,subframe);
proc->remaining_dci--;
if(proc->remaining_dci == 0)
{
proc->dci_to_transmit =0;
proc->rar_to_transmit =1;
proc->remaining_rar =4;
/* uint8_t sib23=0;
uint8_t sib23v1=0;
uint8_t sib1v1=0;
if( ((frame+1)%2==1) && ((frame+1)%64<16))
{
sib23 =1;
}
if(sib23 ==1)
{
if( ((frame+3)%2==1) && ((frame+3)%64<16))
{
sib23v1 =1;
}
if( ((frame+2)%2==0) && ((frame+2)%32<16))
{
sib1v1 =1;
}
if(sib23v1 ==1)
{
if(sib1v1 ==1)
{
proc->next_frame_tx=frame+4;
proc->next_subframe_tx=3;
}else{
proc->next_frame_tx=frame+4;
proc->next_subframe_tx=2;
}
} else {
if(sib1v1 ==1)
{
proc->next_frame_tx=frame+3;
proc->next_subframe_tx=3;
}else{
proc->next_frame_tx=frame+3;
proc->next_subframe_tx=2;
}
}
} else {*/
proc->next_frame_tx=frame+2;
proc->next_subframe_tx=2;
// }
// uint32_t sheduling_info_rar;
}
}
}
if(subframe !=5 && subframe !=0)
{
if(proc->rar_to_transmit ==1 && proc->remaining_rar >0)
{
proc->ra_rnti_computed = RA_template[0].RA_rnti;
NB_IoT_DL_eNB_RAR_t *rar = &eNB->ndlsch_rar.content_rar;
uint8_t tab_rar[7];
tab_rar[0]=64;
tab_rar[1]=0;
tab_rar[2]=42;
tab_rar[3]=67;
tab_rar[4]=64;
tab_rar[5]=0; // 16
tab_rar[6]=5; // 5
//T-CRNTI =4101
if(proc->remaining_rar == 4)
{
dlsch_encoding_rar_NB_IoT(tab_rar,
rar,
8, ///// number_of_subframes_required
236,
1); //////////// G*2
dlsch_sib_scrambling_rar_NB_IoT(fp,
rar,
236,
frame,
subframe*2,
RA_template[0].RA_rnti);
}
printf("detection ok in TX !!!!!!!!!!!!!!!!!");
RA_template[0].generate_rar = 0;
RA_template[i].RA_active = FALSE;
if(frame == proc->next_frame_tx && subframe == proc->next_subframe_tx)
{
if(subframe == 4)
{
uint8_t sib1_exist =0;
if( ((frame)%2==0) && ((frame)%32<16))
{
sib1_exist =1;
}
if(sib1_exist == 1)
{
proc->next_subframe_tx =subframe+2;
} else {
printf("\n RAR sentttttt frame %d, subframe %d", frame, subframe);
dlsch_modulation_rar_NB_IoT(txdataF,
AMP,
fp,
3, // control region size for LTE , values between 0..3, (0 for stand-alone / 1, 2 or 3 for in-band)
rar,
236, // number of bits per subframe
frame, // unrequired
subframe,
22);
proc->remaining_rar--;
proc->next_subframe_tx =subframe+2;
}
} else {
printf("\n RAR sentttttt frame %d, subframe %d", frame, subframe);
dlsch_modulation_rar_NB_IoT(txdataF,
AMP,
fp,
3, // control region size for LTE , values between 0..3, (0 for stand-alone / 1, 2 or 3 for in-band)
rar,
236, // number of bits per subframe
frame, // unrequired
subframe,
22);
proc->remaining_rar--;
proc->next_subframe_tx =subframe+1;
}
}
}
}
/////////////////////////// END ///////////////////////////////////////
/*
......
......@@ -808,7 +808,7 @@ typedef struct {
/// DCI format for Msg4/ContRes (should be 1A)
uint8_t RA_dci_fmt2;
/// Flag to indicate the eNB should generate RAR. This is triggered by detection of PRACH
uint8_t generate_rar;
volatile uint8_t generate_rar;
/// Subframe where preamble was received
uint8_t preamble_subframe;
/// Subframe where Msg3 is to be sent
......@@ -820,7 +820,7 @@ typedef struct {
/// UE RNTI allocated during RAR
rnti_t rnti;
/// RA RNTI allocated from received PRACH
uint16_t RA_rnti;
volatile uint16_t RA_rnti;
/// Received preamble_index
uint8_t preamble_index;
/// Received UE Contention Resolution Identifier
......
......@@ -741,7 +741,7 @@ printf("MAC: msg4 acknowledged for rnti %x fsf %d/%d, let's configure it\n", RA_
void initiate_ra_proc(module_id_t module_idP, int CC_id,frame_t frameP, uint16_t preamble_index,int16_t timing_offset,uint8_t sect_id,sub_frame_t subframeP,
uint8_t f_id)
{
printf("xxxxxxxxxxxxxxxxxx LTE xxxxxxxxxxxxxxxxxxx");
uint8_t i;
RA_TEMPLATE *RA_template = (RA_TEMPLATE *)&eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[0];
......
......@@ -1012,7 +1012,7 @@ void initiate_ra_proc_NB_IoT(module_id_t module_idP, int CC_id,frame_t frameP, u
uint8_t i;
RA_TEMPLATE *RA_template = (RA_TEMPLATE *)&eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[0];
printf("xxxxxxxxxxxxxxxx NB-IoT xxxxxxxxxxxxxx");
for (i=0; i<NB_RA_PROC_MAX; i++) {
if (RA_template[i].RA_active==FALSE &&
RA_template[i].wait_ack_Msg4 == 0) {
......@@ -1022,17 +1022,19 @@ void initiate_ra_proc_NB_IoT(module_id_t module_idP, int CC_id,frame_t frameP, u
RA_template[i].generate_Msg4=0;
RA_template[i].wait_ack_Msg4=0;
RA_template[i].timing_offset=timing_offset;
RA_template[i].RA_rnti = 1 + (frameP/4);
RA_template[i].preamble_index = preamble_index;
/* TODO: find better procedure to allocate RNTI */
do {
/* do {
RA_template[i].rnti = taus();
loop++;
} while (loop != 100 &&
/* TODO: this is not correct, the rnti may be in use without
* being in the MAC yet. To be refined.
*/
!(find_UE_id(module_idP, RA_template[i].rnti) == -1 &&
/* !(find_UE_id(module_idP, RA_template[i].rnti) == -1 &&
/* 1024 and 60000 arbirarily chosen, not coming from standard */
RA_template[i].rnti >= 1024 && RA_template[i].rnti < 60000));
/* RA_template[i].rnti >= 1024 && RA_template[i].rnti < 60000));
if (loop == 100) {
printf("%s:%d:%s: FATAL ERROR! contact the authors\n", __FILE__, __LINE__, __FUNCTION__); abort(); }
......@@ -1041,7 +1043,7 @@ void initiate_ra_proc_NB_IoT(module_id_t module_idP, int CC_id,frame_t frameP, u
LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Activating RAR generation for process %d, rnti %x, RA_active %d\n",
module_idP,CC_id,frameP,i,RA_template[i].rnti,
RA_template[i].RA_active);
RA_template[i].RA_active);*/
return;
}
......
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