Commit a94b0562 authored by Matthieu Kanj's avatar Matthieu Kanj

bug fix in broadcast channel

parent 4af1970f
......@@ -92,6 +92,8 @@ void ccode_encode_NB_IoT (int32_t numbits,
\brief This function initializes the generator polynomials for an LTE convolutional code.*/
void ccodelte_init_NB_IoT(void);
void ccodelte_init2_NB_IoT(void);
/*!\fn void crcTableInit(void)
\brief This function initializes the different crc tables.*/
void crcTableInit_NB_IoT (void);
......
......@@ -1652,8 +1652,8 @@ void phy_init_lte_top_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms)
//ccodedot11_init();
//ccodedot11_init_inv();
//ccodelte_init();
ccodelte_init_NB_IoT();
ccodelte_init2_NB_IoT();
//ccodelte_init_inv();
//treillis_table_init();
......
......@@ -44,6 +44,7 @@
#include "PHY/TOOLS/time_meas_NB_IoT.h"
unsigned char ccodelte_table2_NB_IoT[128];
unsigned short glte2_NB_IoT[] = { 0133, 0171, 0165 };
void ccode_encode_npdsch_NB_IoT (int32_t numbits,
uint8_t *inPtr,
......@@ -86,10 +87,7 @@ void ccode_encode_npdsch_NB_IoT (int32_t numbits,
int dlsch_encoding_NB_IoT(unsigned char *a,
NB_IoT_eNB_DLSCH_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)
time_stats_t_NB_IoT *rm_stats,
time_stats_t_NB_IoT *te_stats,
time_stats_t_NB_IoT *i_stats)
unsigned int G) // G (number of available RE) is implicitly multiplied by 2 (since only QPSK modulation)
{
unsigned int 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
......@@ -97,7 +95,7 @@ int dlsch_encoding_NB_IoT(unsigned char *a,
uint8_t RCC;
A = dlsch->harq_process.TBS; // 680
dlsch->harq_process.length_e = G*Nsf; // G*Nsf (number_of_subframes) = total number of bits to transmit
dlsch->harq_process.length_e = G*Nsf; // G*Nsf (number_of_subframes) = total number of bits to transmit G=236
int32_t numbits = A+24;
......@@ -114,17 +112,43 @@ int dlsch_encoding_NB_IoT(unsigned char *a,
memcpy(dlsch->harq_process.b,a,numbits/8);
memset(dlsch->harq_process.d,LTE_NULL_NB_IoT,96);
start_meas_NB_IoT(te_stats);
ccode_encode_npdsch_NB_IoT(numbits, dlsch->harq_process.b, dlsch->harq_process.d+96, crc); // step 1 Tail-biting convolutional coding
stop_meas_NB_IoT(te_stats);
ccode_encode_npdsch_NB_IoT(numbits, dlsch->harq_process.b, dlsch->harq_process.d+96, crc); // step 1 Tail-biting convolutional coding
start_meas_NB_IoT(i_stats);
RCC = sub_block_interleaving_cc_NB_IoT(numbits,dlsch->harq_process.d+96,dlsch->harq_process.w); // step 2 interleaving
stop_meas_NB_IoT(i_stats);
RCC = sub_block_interleaving_cc_NB_IoT(numbits,dlsch->harq_process.d+96,dlsch->harq_process.w); // step 2 interleaving
start_meas_NB_IoT(rm_stats);
lte_rate_matching_cc_NB_IoT(RCC,dlsch->harq_process.length_e,dlsch->harq_process.w,dlsch->harq_process.e); // step 3 Rate Matching
stop_meas_NB_IoT(rm_stats);
lte_rate_matching_cc_NB_IoT(RCC,dlsch->harq_process.length_e,dlsch->harq_process.w,dlsch->harq_process.e); // step 3 Rate Matching
}
return(0);
}
/*************************************************************************
Functions to initialize the code tables
*************************************************************************/
/* Basic code table initialization for constraint length 7 */
/* Input in MSB, followed by state in 6 LSBs */
void ccodelte_init2_NB_IoT(void)
{
unsigned int i, j, k, sum;
for (i = 0; i < 128; i++) {
ccodelte_table2_NB_IoT[i] = 0;
/* Compute 3 output bits */
for (j = 0; j < 3; j++) {
sum = 0;
for (k = 0; k < 7; k++)
if ((i & glte2_NB_IoT[j]) & (1 << k))
sum++;
/* Write the sum modulo 2 in bit j */
ccodelte_table2_NB_IoT[i] |= (sum & 1) << j;
}
}
}
......@@ -15,16 +15,18 @@
//#include "PHY/defs.h"
//#include "PHY/defs_NB_IoT.h"
//#include "PHY/extern_NB_IoT.h"
#include "PHY/impl_defs_lte.h"
//#include "PHY/CODING/defs_nb_iot.h"
//#include "PHY/CODING/extern.h"
//#include "PHY/CODING/lte_interleaver_inline.h"
#include "PHY/LTE_TRANSPORT/defs_NB_IoT.h"
#include "PHY/LTE_TRANSPORT/proto_NB_IoT.h"
#include "PHY/impl_defs_lte_NB_IoT.h"
#include "PHY/impl_defs_top_NB_IoT.h"
//#include "defs.h"
//#include "UTIL/LOG/vcd_signal_dumper.h"
int allocate_REs_in_RB_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
int allocate_REs_in_RB_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,
int32_t **txdataF,
uint32_t *jj,
uint32_t symbol_offset,
......@@ -32,9 +34,10 @@ int allocate_REs_in_RB_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
uint8_t pilots,
int16_t amp,
unsigned short id_offset,
uint8_t pilot_shift,
uint32_t *re_allocated) // not used variable ??!!
{
MIMO_mode_NB_IoT_t mimo_mode = (frame_parms->mode1_flag==1)? SISO_NB_IoT:ALAMOUTI_NB_IoT;
MIMO_mode_t mimo_mode = (frame_parms->mode1_flag==1)? SISO:ALAMOUTI;
uint32_t tti_offset,aa;
uint8_t re;
......@@ -50,10 +53,10 @@ int allocate_REs_in_RB_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
tti_offset = symbol_offset + re; // symbol_offset = 512 * L , re_offset = 512 - 3*12 , re
if (pilots != 1 || re%3 != id_offset) // if re is not a pilot
if (pilots != 1 || (re%6 != ((id_offset + 3*pilot_shift) % 6) ) ) // if re is not a pilot
{
if (mimo_mode == SISO_NB_IoT) { //SISO mapping
if (mimo_mode == SISO) { //SISO mapping
*re_allocated = *re_allocated + 1; // variable incremented but never used
for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
......@@ -65,7 +68,7 @@ int allocate_REs_in_RB_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
}
*jj = *jj + 1;
} else if (mimo_mode == ALAMOUTI_NB_IoT) {
} else if (mimo_mode == ALAMOUTI) {
*re_allocated = *re_allocated + 1;
......@@ -114,7 +117,7 @@ int allocate_REs_in_RB_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
int dlsch_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, // control region size for LTE , values between 0..3, (0 for stand-alone / 1, 2 or 3 for in-band)
NB_IoT_eNB_DLSCH_t *dlsch0,
int G, // number of bits per subframe
......@@ -126,29 +129,34 @@ int dlsch_modulation_NB_IoT(int32_t **txdataF,
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;
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<=8) || (l>=11 && l<=13))
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 % 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)));
} 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
......@@ -160,6 +168,7 @@ int dlsch_modulation_NB_IoT(int32_t **txdataF,
pilots,
amp,
id_offset,
pilot_shift,
&re_allocated);
}
......
......@@ -166,7 +166,7 @@ int generate_npbch(NB_IoT_eNB_NPBCH_t *eNB_npbch,
bzero(npbch_a,5); // initializing input data stream , filling with zeros
bzero(eNB_npbch->npbch_e,npbch_E); // filling with "0" the table pbch_e[1600]
memset(eNB_npbch->npbch_d,LTE_NULL_NB_IoT,96); // filling with "2" the first 96 elements of table pbch_d[216]
/*
for (i=0; i<5; i++) // set input bits stream
{
if (i != 4)
......@@ -176,14 +176,15 @@ int generate_npbch(NB_IoT_eNB_NPBCH_t *eNB_npbch,
npbch_a[5-i-1]= npbch_pdu[i] & 0x03;
}
}
*/
/*
for (i=0; i<5; i++) // set input bits stream
{
npbch_a[i] = npbch_pdu[i]; // in LTE 24 bits with 3 bytes, but in NB_IoT 34 bits will require 4 bytes+2 bits !! to verify
}
*/
if (frame_parms->mode1_flag == 1) // setting CRC mask depending on the number of used eNB antennas
amask = 0x0000;
else {
......
......@@ -86,6 +86,18 @@ int allocate_npbch_REs_in_RB(LTE_DL_FRAME_PARMS *frame_parms,
unsigned short id_offset,
uint32_t *re_allocated);
// NPDSCH
int 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,
uint8_t pilots,
int16_t amp,
unsigned short id_offset,
uint8_t pilot_shift,
uint32_t *re_allocated);
int generate_npbch(NB_IoT_eNB_NPBCH_t *eNB_npbch,
int32_t **txdataF,
......@@ -213,13 +225,20 @@ unsigned char get_Qm_ul_NB_IoT(unsigned char I_MCS, uint8_t N_sc_RU);
@returns status
*/
int dlsch_modulation_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_eNB_DLSCH_t *dlsch0,
int G, // number of bits per subframe
unsigned npdsch_data_subframe, // subframe index of the data table of npdsch channel (G*Nsf) , values are between 0..Nsf
unsigned short NB_IoT_RB_ID);
int32_t dlsch_encoding_NB_IoT(unsigned char *a,
NB_IoT_eNB_DLSCH_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)
time_stats_t_NB_IoT *rm_stats,
time_stats_t_NB_IoT *te_stats,
time_stats_t_NB_IoT *i_stats);
unsigned int G); // G (number of available RE) is implicitly multiplied by 2 (since only QPSK modulation)
void rx_ulsch_NB_IoT(PHY_VARS_eNB_NB_IoT *phy_vars_eNB,
eNB_rxtx_proc_NB_IoT_t *proc,
......
......@@ -506,6 +506,7 @@ typedef struct PHY_VARS_eNB_s {
/////////////// NB-IoT testing ////////////////////////////
NB_IoT_eNB_NPBCH_t npbch;
NB_IoT_eNB_NDLSCH_t *ndlsch[NUMBER_OF_UE_MAX];
//////////////////// END /////////////////////////////////
......
......@@ -373,7 +373,7 @@ uint8_t do_SIB1_NB_IoT(uint8_t Mod_id, int CC_id,
*nrs_CRS_PowerOffset= 0;
(*sib1_NB_IoT)->nrs_CRS_PowerOffset_r13 = nrs_CRS_PowerOffset;
*/
*eutraControlRegionSize = 1;
*eutraControlRegionSize = 2;
(*sib1_NB_IoT)->eutraControlRegionSize_r13 = eutraControlRegionSize;
#ifdef XER_PRINT //generate xml files
xer_fprint(stdout, &asn_DEF_BCCH_DL_SCH_Message_NB, (void*)bcch_message);
......
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