Commit 9b5d4c88 authored by Matthieu Kanj's avatar Matthieu Kanj

Code Separation for openair1/PHY/, (134 warnings)

parent 71780feb
......@@ -12,7 +12,7 @@
* \warning
*/
#include "defs_NB_IoT.h"
#include "PHY/CODING/defs_NB_IoT.h"
unsigned char ccodelte_table_NB_IoT[128]; // for transmitter
unsigned short glte_NB_IoT[] = { 0133, 0171, 0165 }; // {A,B} //renaimed but is exactly the same as the one in the old implementation
......@@ -42,12 +42,15 @@ void ccode_encode_NB_IoT (int32_t numbits,
state = 0;
if (add_crc == 2) {
crc = crc16_NB_IoT(inPtr,numbits); // crc is 2 bytes
// scramble with RNTI
crc ^= (((uint32_t)rnti)<<16); // XOR with crc
first_bit = 2;
c = (uint8_t)((crc>>16)&0xff);
} else {
next_last_byte = numbits>>3;
first_bit = (numbits-6)&7;
c = inPtr[next_last_byte-1];
......@@ -57,6 +60,7 @@ void ccode_encode_NB_IoT (int32_t numbits,
// get bits from last byte of input (or crc)
for (shiftbit = 0 ; shiftbit <(8-first_bit) ; shiftbit++) {
if ((c&(1<<(7-first_bit-shiftbit))) != 0)
state |= (1<<shiftbit);
}
......@@ -69,6 +73,7 @@ void ccode_encode_NB_IoT (int32_t numbits,
c = *inPtr++;
for (shiftbit = 7; (shiftbit>=0) && (numbits>0); shiftbit--,numbits--) {
state >>= 1;
if ((c&(1<<shiftbit)) != 0) {
......@@ -80,9 +85,7 @@ void ccode_encode_NB_IoT (int32_t numbits,
*outPtr++ = out & 1;
*outPtr++ = (out>>1)&1;
*outPtr++ = (out>>2)&1;
}
}
// now code 16-bit CRC for DCI // Tail-biting is applied to CRC bits , input 16 bits , output 48 bits
......@@ -91,6 +94,7 @@ void ccode_encode_NB_IoT (int32_t numbits,
c16 = (uint16_t)(crc>>16);
for (shiftbit = 15; (shiftbit>=0); shiftbit--) {
state >>= 1;
if ((c16&(1<<shiftbit)) != 0) {
......@@ -102,7 +106,6 @@ void ccode_encode_NB_IoT (int32_t numbits,
*outPtr++ = out & 1;
*outPtr++ = (out>>1)&1;
*outPtr++ = (out>>2)&1;
}
}
}
......@@ -119,6 +122,7 @@ void ccodelte_init_NB_IoT(void)
unsigned int i, j, k, sum;
for (i = 0; i < 128; i++) {
ccodelte_table_NB_IoT[i] = 0;
/* Compute 3 output bits */
......
......@@ -36,7 +36,7 @@
//#include "defs.h" // to delete in final code version
#include "defs_NB_IoT.h" //
#include "PHY/CODING/defs_NB_IoT.h" //
/*ref 36-212 v8.6.0 , pp 8-9 */
/* the highest degree is set by default */
unsigned int poly24a_NB_IoT = 0x864cfb00; //1000 0110 0100 1100 1111 1011 D^24 + D^23 + D^18 + D^17 + D^14 + D^11 + D^10 + D^7 + D^6 + D^5 + D^4 + D^3 + D + 1
......@@ -52,18 +52,22 @@ For initialization && verification purposes,
The first bit is in the MSB of each byte
*********************************************************/
unsigned int
crcbit_NB_IoT (unsigned char * inputptr, int octetlen, unsigned int poly)
unsigned int crcbit_NB_IoT (unsigned char * inputptr, int octetlen, unsigned int poly)
{
unsigned int i, crc = 0, c;
while (octetlen-- > 0) {
c = (*inputptr++) << 24;
for (i = 8; i != 0; i--) {
if ((1 << 31) & (c ^ crc))
crc = (crc << 1) ^ poly;
else
crc <<= 1;
c <<= 1;
......@@ -95,6 +99,7 @@ void crcTableInit_NB_IoT (void)
crc12Table_NB_IoT[c] = (unsigned short) (crcbit_NB_IoT (&c, 1, poly12_NB_IoT) >> 16);
crc8Table_NB_IoT[c] = (unsigned char) (crcbit_NB_IoT (&c, 1, poly8_NB_IoT) >> 24);
} while (++c);
}
/*********************************************************
......@@ -102,21 +107,23 @@ Byte by byte implementations,
assuming initial byte is 0 padded (in MSB) if necessary
*********************************************************/
unsigned int
crc24a_NB_IoT (unsigned char * inptr, int bitlen)
unsigned int crc24a_NB_IoT (unsigned char * inptr, int bitlen)
{
int octetlen, resbit;
unsigned int crc = 0;
octetlen = bitlen / 8; /* Change in octets */
resbit = (bitlen % 8);
while (octetlen-- > 0) {
// printf("in %x => crc %x\n",crc,*inptr);
crc = (crc << 8) ^ crc24aTable_NB_IoT[(*inptr++) ^ (crc >> 24)];
}
if (resbit > 0)
crc = (crc << resbit) ^ crc24aTable_NB_IoT[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))];
return crc;
......@@ -127,40 +134,46 @@ unsigned int crc24b_NB_IoT (unsigned char * inptr, int bitlen)
int octetlen, resbit;
unsigned int crc = 0;
octetlen = bitlen / 8; /* Change in octets */
resbit = (bitlen % 8);
while (octetlen-- > 0) {
crc = (crc << 8) ^ crc24bTable_NB_IoT[(*inptr++) ^ (crc >> 24)];
}
if (resbit > 0)
crc = (crc << resbit) ^ crc24bTable_NB_IoT[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))];
return crc;
}
unsigned int
crc16_NB_IoT (unsigned char * inptr, int bitlen)
unsigned int crc16_NB_IoT (unsigned char * inptr, int bitlen)
{
int octetlen, resbit;
unsigned int crc = 0;
octetlen = bitlen / 8; /* Change in octets */
resbit = (bitlen % 8);
while (octetlen-- > 0) {
crc = (crc << 8) ^ (crc16Table_NB_IoT[(*inptr++) ^ (crc >> 24)] << 16);
}
if (resbit > 0)
crc = (crc << resbit) ^ (crc16Table_NB_IoT[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))] << 16);
return crc;
}
#ifdef DEBUG_CRC
//#ifdef DEBUG_CRC
/*******************************************************************/
/**
Test code
......@@ -177,5 +190,5 @@ crc16_NB_IoT (unsigned char * inptr, int bitlen)
// printf("%x\n", crcbit(test, sizeof(test) - 1, poly8));
// printf("%x\n", crc8(test, (sizeof(test) - 1)*8));
// }
#endif
//#endif
......@@ -28,13 +28,15 @@
#ifndef OPENAIR1_PHY_CODING_DEFS_NB_IOT_H_
#define OPENAIR1_PHY_CODING_DEFS_NB_IOT_H_
#include <stdint.h>
#ifndef NO_OPENAIR1
#include "PHY/defs_NB_IoT.h"
#else
#include "PHY/TOOLS/time_meas.h"
#endif
#include <stdint.h> // for uint8/16/32_t
/* check if this ifndef is required for NB-IoT ?!
//#ifndef NO_OPENAIR1
//#include "PHY/defs_NB_IoT.h"
//#else
//#include "PHY/TOOLS/time_meas.h"
//#endif
*/
#define CRC24_A_NB_IoT 0
#define CRC24_B_NB_IoT 1
......@@ -44,7 +46,7 @@
//#define MAX_TURBO_ITERATIONS_MBSFN 8 // no MBSFN
#define MAX_TURBO_ITERATIONS_NB_IoT 4
#define LTE_NULL_NB_IoT 2
#define LTE_NULL_NB_IoT 2 // defined also in PHY/LTE_TRANSPORT/defs_NB_IoT.h
/** \fn uint32_t sub_block_interleaving_cc(uint32_t D, uint8_t *d,uint8_t *w)
\brief This is the subblock interleaving algorithm for convolutionally coded blocks from 36-212 (Release 13.4, 2017).
......
......@@ -12,13 +12,14 @@
* \warning
*/
/* // check if this ifdef MAIN is required for NB-IoT
#ifdef MAIN
#include <stdio.h>
#include <stdlib.h>
#endif
#include "PHY/defs_NB_IoT.h"
#include "assertions.h"
*/
#include "PHY/CODING/defs_NB_IoT.h"
//#include "assertions.h"
//#include "PHY/LTE_REFSIG/defs_NB_IoT.h" // does this file is needed ?
......@@ -44,6 +45,7 @@ uint32_t sub_block_interleaving_cc_NB_IoT(uint32_t D, uint8_t *d,uint8_t *w)
index3 = 3*index;
for (row=0; row<RCC; row++) {
w[k] = d[(int32_t)index3-(int32_t)ND3];
w[Kpi+k] = d[(int32_t)index3-(int32_t)ND3+1];
w[(Kpi<<1)+k] = d[(int32_t)index3-(int32_t)ND3+2];
......@@ -63,7 +65,6 @@ uint32_t lte_rate_matching_cc_NB_IoT(uint32_t RCC, // RRC = 2
uint8_t *e) // length 1600
{
uint32_t ind=0,k;
uint16_t Kw = 3*(RCC<<5); // 3*64 = 192
for (k=0; k<E; k++) {
......
......@@ -23,8 +23,9 @@
#ifndef __INIT_DEFS_NB_IOT__H__
#define __INIT_DEFS_NB_IOT__H__
#include "PHY/defs_NB_IoT.h"
//#include "PHY/defs_NB_IoT.h"
#include "openair2/PHY_INTERFACE/IF_Module_NB_IoT.h"
// nfapi_interface.h is required here, it is called through IF_Module_NB_IoT.h
//#include "SystemInformationBlockType2.h"
//#include "RadioResourceConfigCommonSIB.h"
......
......@@ -22,8 +22,8 @@
//#include "defs.h"
#include "SCHED/defs_NB_IoT.h"
//#include "PHY/extern.h"
#include "PHY/extern_NB_IoT.h"
//#include "RRC/LITE/proto_NB_IoT.h"
#include "PHY/extern_NB_IoT.h" // PHY/defs_NB_IoT.h is called here , log.h & LTE_TRANSPORT/defs_NB_IoT.h are included through PHY/defs_NB_IoT.h
#include "RRC/LITE/proto_NB_IoT.h" // for functions: from_earfcn_NB_IoT, get_uldl_offset_NB_IoT
//#include "SIMULATION/TOOLS/defs.h"
//#include "RadioResourceConfigCommonSIB.h"
//#include "RadioResourceConfigDedicated.h"
......@@ -31,15 +31,16 @@
//#include "LAYER2/MAC/extern.h"
//#include "MBSFN-SubframeConfigList.h"
//#include "UTIL/LOG/vcd_signal_dumper.h"
#define DEBUG_PHY
//#define DEBUG_PHY
#include "assertions.h"
#include <math.h>
//#include <math.h>
//NB-IoT
#include "defs_NB_IoT.h"
#include "RadioResourceConfigCommonSIB-NB-r13.h"
#include "RadioResourceConfigDedicated-NB-r13.h"
#include "openair2/PHY_INTERFACE/IF_Module_NB_IoT.h"
#include "PHY/INIT/defs_NB_IoT.h" // nfapi_interface.h & IF_Module_NB_IoT.h are included here
//#include "RadioResourceConfigCommonSIB-NB-r13.h"
//#include "RadioResourceConfigDedicated-NB-r13.h"
//#include "openair2/PHY_INTERFACE/IF_Module_NB_IoT.h"
//#include "openair2/RRC/LITE/proto_NB_IoT.h"
//extern uint16_t prach_root_sequence_map0_3[838];
//extern uint16_t prach_root_sequence_map4[138];
......@@ -67,8 +68,7 @@ void phy_config_mib_eNB_NB_IoT(int Mod_id,
NB_IoT_DL_FRAME_PARMS *fp = &PHY_vars_eNB_NB_IoT_g[Mod_id][CC_id]->frame_parms_NB_IoT;
LOG_I(PHY,"Configuring MIB-NB for instance %d, CCid %d : (band %d,Nid_cell %d,p %d,EARFCN %u)\n",
Mod_id, CC_id, eutra_band, Nid_cell, p_eNB,EARFCN);
LOG_I(PHY,"Configuring MIB-NB for instance %d, CCid %d : (band %d,Nid_cell %d,p %d,EARFCN %u)\n",Mod_id, CC_id, eutra_band, Nid_cell, p_eNB,EARFCN);
// fp->N_RB_DL
// fp->N_RB_UL also this two values need to be known when we are dealing with in-band and guard-band operating mode
......@@ -193,8 +193,8 @@ void phy_config_sib2_eNB_NB_IoT(uint8_t Mod_id,
int CC_id,
nfapi_config_NB_IoT_t *config,
nfapi_rf_config_t *rf_config,
nfapi_uplink_reference_signal_config_t* ul_nrs_config,
extra_phyConfig_t* extra_phy_parms)
nfapi_uplink_reference_signal_config_t *ul_nrs_config,
extra_phyConfig_t *extra_phy_parms)
{
NB_IoT_DL_FRAME_PARMS *fp = &PHY_vars_eNB_NB_IoT_g[Mod_id][CC_id]->frame_parms;
LOG_D(PHY,"[eNB%d] CCid %d: Applying config_NB_IoT from sib2_NB\n",Mod_id,CC_id);
......@@ -359,22 +359,21 @@ void phy_config_dedicated_eNB_NB_IoT(uint8_t Mod_id,
uint8_t UE_id = find_ue_NB_IoT(rnti,eNB);
if (UE_id == -1) {
LOG_E( PHY, "[eNB %"PRIu8"] find_ue() returns -1\n", Mod_id);
return;
}
//configure UE specific parameters for NPDCCH Search Space
//
if (eNB->npdcch[UE_id]) {
npdcch = eNB->npdcch[UE_id];
npdcch->rnti = rnti;
npdcch->npdcch_NumRepetitions = extra_parms->npdcch_NumRepetitions; //Rmax maybe is the only one needed
// npdcch->npdcch_Offset_USS = extra_parms->npdcch_Offset_USS;
// npdcch->npdcch_StartSF_USS = extra_parms->npdcch_StartSF_USS;
//npdcch->npdcch_Offset_USS = extra_parms->npdcch_Offset_USS;
//npdcch->npdcch_StartSF_USS = extra_parms->npdcch_StartSF_USS;
LOG_I(PHY,"phy_config_dedicated_eNB_NB_IoT: npdcch_NumRepetitions = %d\n",
npdcch->npdcch_NumRepetitions);
LOG_I(PHY,"phy_config_dedicated_eNB_NB_IoT: npdcch_NumRepetitions = %d\n",npdcch->npdcch_NumRepetitions);
} else {
LOG_E(PHY,"[eNB %d] Received NULL radioResourceConfigDedicated from eNB %d\n",Mod_id, UE_id);
......
......@@ -27,7 +27,9 @@
@param lte_gold_table pointer to table where sequences are stored
@param Nid_cell Cell Id for NB_IoT (to compute sequences for local and adjacent cells) */
void lte_gold_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,uint32_t lte_gold_table_NB_IoT[20][2][14],uint16_t Nid_cell);
void lte_gold_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
uint32_t lte_gold_table_NB_IoT[20][2][14],
uint16_t Nid_cell);
/*! \brief This function generates the Narrowband reference signal (NRS) sequence (36-211, Sec 6.10.1.1)
@param phy_vars_eNB Pointer to eNB variables
......@@ -47,6 +49,8 @@ int lte_dl_cell_spec_NB_IoT(PHY_VARS_eNB_NB_IoT *phy_vars_eNB,
unsigned short RB_IoT_ID);
unsigned int lte_gold_generic_NB_IoT(unsigned int *x1, unsigned int *x2, unsigned char reset);
unsigned int lte_gold_generic_NB_IoT(unsigned int *x1,
unsigned int *x2,
unsigned char reset);
#endif
......@@ -12,12 +12,13 @@
* \warning
*/
/* check if this is required for NB-IoT
#ifdef USER_MODE
#include <stdio.h>
#include <stdlib.h>
#endif
#include "defs_NB_IoT.h"
*/
#include "PHY/LTE_REFSIG/defs_NB_IoT.h"
#include "PHY/defs_NB_IoT.h"
int lte_dl_cell_spec_NB_IoT(PHY_VARS_eNB_NB_IoT *phy_vars_eNB,
......
......@@ -13,7 +13,7 @@
*/
//#include "defs.h"
#include "defs_NB_IoT.h"
#include "PHY/LTE_REFSIG/defs_NB_IoT.h"
void lte_gold_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,uint32_t lte_gold_table_NB_IoT[20][2][14],uint16_t Nid_cell) // Nid_cell = Nid_cell_NB_IoT
{
......@@ -24,9 +24,7 @@ void lte_gold_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,uint32_t lte_gold_table_
for (l=0; l<2; l++) {
x2 = Ncp +
(Nid_cell<<1) +
(((1+(Nid_cell<<1))*(1 + (l+5) + (7*(1+ns))))<<10); //cinit
x2 = Ncp + (Nid_cell<<1) + (((1+(Nid_cell<<1))*(1 + (l+5) + (7*(1+ns))))<<10); //cinit
x1 = 1+ (1<<31);
x2 = x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31);
......
......@@ -35,8 +35,10 @@
#include <string.h>
#endif
//#include "PHY/defs.h"
#include "PHY/defs_NB_IoT.h"
#include "PHY/LTE_REFSIG/defs_NB_IoT.h"
//#include "PHY/LTE_TRANSPORT/dci_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"
//#include "PHY/extern.h"
//////////#include "PHY/extern_NB_IoT.h"
//#include "SCHED/defs.h"
......@@ -178,6 +180,7 @@ int dci_allocate_REs_in_RB_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
uint8_t agr_level)
{
MIMO_mode_NB_IoT_t mimo_mode = (frame_parms->mode1_flag==1)?SISO_NB_IoT:ALAMOUTI_NB_IoT;
uint32_t tti_offset,aa;
uint8_t re;
int16_t gain_lin_QPSK;
......@@ -419,6 +422,7 @@ int dci_modulation_NB_IoT(int32_t **txdataF,
uint8_t id_offset,pilots=0;
unsigned short bandwidth_even_odd;
unsigned short NB_IoT_start, RB_IoT_ID;
re_allocated=0;
id_offset=0;
// testing if the total number of RBs is even or odd
......
......@@ -35,7 +35,7 @@
//#ifndef USER_MODE
//#include "PHY/types.h"
//#else
////////////////////////////////////////#include <stdint.h>
#include <stdint.h>
//#endif
typedef enum
......
......@@ -30,20 +30,22 @@
* \warning
*/
//#include "PHY/defs.h"
#include "PHY/extern_NB_IoT.h"
#include "PHY/LTE_TRANSPORT/extern_NB_IoT.h"
#include "SCHED/defs_NB_IoT.h"
//#include "PHY/extern_NB_IoT.h"
//#include "PHY/LTE_TRANSPORT/extern_NB_IoT.h"
//#include "SCHED/defs_NB_IoT.h"
/*
#ifdef DEBUG_DCI_TOOLS
#include "PHY/vars_NB_IoT.h"
#endif
#include "assertions.h"
*/
//#include "assertions.h"
//#include "dlsch_tbs_full.h"
#include "PHY/LTE_TRANSPORT/dlsch_tbs_full_NB_IoT.h"
//#define DEBUG_HARQ
#include "LAYER2/MAC/extern_NB_IoT.h"
#include "LAYER2/MAC/defs_NB_IoT.h"
//#include "LAYER2/MAC/extern_NB_IoT.h"
//#include "LAYER2/MAC/defs_NB_IoT.h"
#include "PHY/defs_NB_IoT.h"
//#define DEBUG_DCI
......@@ -153,8 +155,9 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
uint8_t npdcch_start_symbol)
{
NB_IoT_DL_eNB_HARQ_t* ndlsch_harq = ndlsch->harq_process;
NB_IoT_DL_eNB_HARQ_t *ndlsch_harq = ndlsch->harq_process;
void *DLSCH_DCI_NB_IoT = NULL;
eNB->DCI_pdu = (DCI_PDU_NB_IoT*) malloc(sizeof(DCI_PDU_NB_IoT));
......@@ -238,8 +241,8 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
ndlsch_harq->dci_subframe_repetitions = DCIRep;
ndlsch_harq->modulation = 2; //QPSK
if(ndlsch_harq->round == 0) //this should be set from initialization (init-lte)
ndlsch_harq->status = ACTIVE;
ndlsch_harq->status = ACTIVE_NB_IoT;
ndlsch_harq->mcs = mcs;
/*
......@@ -308,7 +311,8 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
ndlsch_harq->dci_subframe_repetitions = DCIRep;
ndlsch_harq->modulation = 2; //QPSK
if(ndlsch_harq->round == 0){ //this should be set from initialization (init-lte)
ndlsch_harq->status = ACTIVE;
ndlsch_harq->status = ACTIVE_NB_IoT;
ndlsch_harq->mcs = mcs;
ndlsch_harq->TBS = TBStable_NB_IoT[mcs][ResAssign]; // this table should be rewritten for nb-iot
}
......
......@@ -136,10 +136,12 @@
//} NB_IoT_DL_eNB_HARQ_t;
typedef enum {
SCH_IDLE_NB_IoT,
ACTIVE_NB_IoT,
CBA_ACTIVE_NB_IoT,
DISABLED_NB_IoT
} SCH_status_NB_IoT_t;
......@@ -178,7 +180,7 @@ typedef struct {
/// Pointer to the payload
uint8_t *b;
///pdu of the ndlsch message
uint8_t*pdu;
uint8_t *pdu;
/// Frame where current HARQ round was sent
uint32_t frame;
/// Subframe where current HARQ round was sent
......@@ -403,6 +405,7 @@ typedef struct {
uint32_t errors[8];
/// codeword this transport block is mapped to
uint8_t codeword;
} NB_IoT_DL_UE_HARQ_t;
typedef struct {
......@@ -444,6 +447,7 @@ typedef struct {
uint8_t last_iteration_cnt;
/// accumulated tx power adjustment for PUCCH
int8_t g_pucch;
} NB_IoT_UE_DLSCH_t;
//----------------------------------------------------------------------------------------------------------
......@@ -453,6 +457,7 @@ typedef struct {
//enum for distinguish the different type of ndlsch (may in the future will be not needed)
typedef enum
{
SIB1,
SI_Message,
RAR,
......@@ -492,7 +497,6 @@ uint16_t number_repetition_PAg;
uint16_t repetition_idx_RA;
uint16_t repetition_idx_Pag;
}NB_IoT_eNB_COMMON_NPDCCH_t;
......@@ -512,6 +516,7 @@ typedef struct {
DCI_format_NB_IoT_t format;
/// DCI pdu
uint8_t dci_pdu[8];
} DCI_ALLOC_NB_IoT_t;
......@@ -523,6 +528,7 @@ typedef struct {
uint8_t npdcch_start_symbol;
uint8_t Num_dci;
DCI_ALLOC_NB_IoT_t dci_alloc[2] ;
} DCI_PDU_NB_IoT;
......@@ -541,7 +547,6 @@ typedef struct {
uint8_t subframe_tx[10];
/// First CCE of last PDSCH scheduling per subframe. Again used during PUCCH detection for ACK/NAK.
uint8_t nCCE[10];
/*in NB-IoT there is only 1 HARQ process for each UE therefore no pid is required*/
/// The only HARQ process for the DLSCH
NB_IoT_DL_eNB_HARQ_t *harq_process;
......@@ -555,7 +560,6 @@ typedef struct {
int16_t sqrt_rho_a;
/// amplitude of PDSCH (compared to RS) in symbols containing pilots
int16_t sqrt_rho_b;
///NB-IoT
/// may use in the npdsch_procedures
uint16_t scrambling_sequence_intialization;
......@@ -564,23 +568,18 @@ typedef struct {
//This indicate the current subframe within the subframe interval between the NPDSCH transmission (Nsf*Nrep)
uint16_t sf_index;
///indicates the starting OFDM symbol in the first slot of a subframe k for the NPDSCH transmission
/// see FAPI/NFAPI specs Table 4-47
uint8_t npdsch_start_symbol;
/*SIB1-NB related parameters*/
///flag for indicate if the current frame is the start of a new SIB1-NB repetition within the SIB1-NB period (0 = FALSE, 1 = TRUE)
uint8_t sib1_rep_start;
///the number of the frame within the 16 continuous frame in which sib1-NB is transmitted (1-8 = 1st, 2nd ecc..) (0 = not foresees a transmission)
uint8_t relative_sib1_frame;
//Flag used to discern among different NDLSCH structures (SIB1,SI,RA,UE-spec)
//(used inside the ndlsch procedure for distinguish the different type of data to manage also in term of repetitions and transmission over more subframes
ndlsch_flag_t ndlsch_type;
} NB_IoT_eNB_NDLSCH_t;
typedef struct {
......@@ -616,7 +615,6 @@ typedef struct {
uint8_t repetition_number;
/// Determined the repetition number value 0-3
uint8_t dci_subframe_repetitions;
/// Flag indicating that this ULSCH has been allocated by a DCI (otherwise it is a retransmission based on PHICH NAK)
uint8_t dci_alloc;
/// Flag indicating that this ULSCH has been allocated by a RAR (otherwise it is a retransmission based on PHICH NAK or DCI)
......@@ -625,26 +623,24 @@ typedef struct {
SCH_status_NB_IoT_t status;
/// Subframe scheduling indicator (i.e. Transmission opportunity indicator)
uint8_t subframe_scheduling_flag;
/// Transport block size
uint32_t TBS;
/// The payload + CRC size in bits
uint32_t B;
/// Number of soft channel bits
uint32_t G;
/// Pointer to ACK
uint8_t o_ACK[4];
/// Length of ACK information (bits)
uint8_t O_ACK;
/// coded ACK bits
/// coded ACK bits
int16_t q_ACK[MAX_ACK_PAYLOAD_NB_IoT];
/// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9)
/// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9)
/// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
int16_t e[MAX_NUM_CHANNEL_BITS_NB_IoT] __attribute__((aligned(32)));
/// coded RI bits
int16_t q_RI[MAX_RI_PAYLOAD_NB_IoT];
/// "q" sequences for CQI/PMI (for definition see 36-212 V8.6 2009-03, p.27)
/// "q" sequences for CQI/PMI (for definition see 36-212 V8.6 2009-03, p.27)
int8_t q[MAX_CQI_PAYLOAD_NB_IoT];
/// number of coded CQI bits after interleaving
uint8_t o_RCC;
......@@ -652,7 +648,7 @@ typedef struct {
int8_t o_w[(MAX_CQI_BITS_NB_IoT+8)*3];
/// coded CQI bits
int8_t o_d[96+((MAX_CQI_BITS_NB_IoT+8)*3)];
///
uint32_t C;
/// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Cminus;
......@@ -664,22 +660,18 @@ typedef struct {
uint32_t Kplus;
/// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t F;
/// Temporary h sequence to flag PUSCH_x/PUSCH_y symbols which are not scrambled
//uint8_t h[MAX_NUM_CHANNEL_BITS];
/// Pointer to the payload
uint8_t *b;
/// Current Number of Symbols
uint8_t Nsymb_pusch;
/// Index of current HARQ round for this ULSCH
uint8_t round;
/// MCS format for this ULSCH
uint8_t mcs;
/// Redundancy-version of the current sub-frame (value 0->RV0,value 1 ->RV2)
uint8_t rvidx;
/// Msc_initial, Initial number of subcarriers for ULSCH (36-212, v8.6 2009-03, p.26-27)
uint16_t Msc_initial;
/// Nsymb_initial, Initial number of symbols for ULSCH (36-212, v8.6 2009-03, p.26-27)
......@@ -696,6 +688,7 @@ typedef struct {
// int calibration_flag;
/// delta_TF for power control
int32_t delta_TF;
} NB_IoT_UL_eNB_HARQ_t;
......@@ -704,7 +697,6 @@ typedef struct {
NB_IoT_UL_eNB_HARQ_t *harq_process;
/// Maximum number of HARQ rounds
uint8_t Mlimit;
/// Value 0 = npush format 1 (data) value 1 = npusch format 2 (ACK/NAK)
uint8_t npusch_format;
/// Flag to indicate that eNB awaits UE Msg3
......@@ -723,15 +715,14 @@ typedef struct {
uint8_t cooperation_flag;
/// (only in-band mode), indicate the resource block overlap the SRS configuration of LTE
uint8_t N_srs;
///
uint8_t scrambling_re_intialization_batch_index;
/// number of cell specific TX antenna ports assumed by the UE
uint8_t nrs_antenna_ports;
///
uint16_t scrambling_sequence_intialization;
///
uint16_t sf_index;
/// Determined the ACK/NACK delay and the subcarrier allocation TS 36.213 Table 16.4.2
uint8_t HARQ_ACK_resource;
......@@ -779,6 +770,7 @@ typedef struct {
struct list loc_rss_list[10], loc_rssi_list[10], loc_subcarrier_rss_list[10], loc_timing_advance_list[10], loc_timing_update_list[10];
struct list tot_loc_rss_list, tot_loc_rssi_list, tot_loc_subcarrier_rss_list, tot_loc_timing_advance_list, tot_loc_timing_update_list;
#endif
} NB_IoT_eNB_ULSCH_t;
......@@ -793,8 +785,8 @@ typedef struct {
uint8_t npbch_e[1600];
///pdu of the npbch message
uint8_t *pdu;
} NB_IoT_eNB_NPBCH_t;
} NB_IoT_eNB_NPBCH_t;
#endif
......@@ -11,20 +11,19 @@
* \note
* \warning
*/
#include <string.h>
//#include "PHY/defs.h"
#include "PHY/defs_NB_IoT.h"
#include "PHY/extern_NB_IoT.h"
//#include "PHY/defs_NB_IoT.h"
//#include "PHY/extern_NB_IoT.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 "SCHED/defs_NB_IoT.h"
//#include "PHY/LTE_TRANSPORT/proto_NB_IoT.h"
//#include "SCHED/defs_NB_IoT.h"
//#include "defs_nb_iot.h"
//#include "UTIL/LOG/vcd_signal_dumper.h"
//#include "PHY/LTE_TRANSPORT/defs_nb_iot.h" // newly added for NB_IoT
#include "PHY/TOOLS/time_meas_NB_IoT.h"
unsigned char ccodelte_table2_NB_IoT[128];
......@@ -35,7 +34,7 @@ void ccode_encode_npdsch_NB_IoT (int32_t numbits,
{
uint32_t state;
uint8_t c, out, first_bit;
int8_t shiftbit=0;
int8_t shiftbit = 0;
/* The input bit is shifted in position 8 of the state.
Shiftbit will take values between 1 and 8 */
state = 0;
......@@ -74,12 +73,14 @@ int dlsch_encoding_NB_IoT(unsigned char *a,
time_stats_t_NB_IoT *te_stats,
time_stats_t_NB_IoT *i_stats)
{
unsigned int crc=1;
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
unsigned int 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
int32_t numbits = A+24;
if (dlsch->harq_process.round == 0) { // This is a new packet
......
......@@ -11,14 +11,16 @@
* \note
* \warning
*/
#include <math.h>
//#include "PHY/defs.h"
#include "PHY/defs_NB_IoT.h"
//#include "PHY/defs_NB_IoT.h"
//#include "PHY/extern_NB_IoT.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/impl_defs_lte_NB_IoT.h"
#include "PHY/impl_defs_top_NB_IoT.h"
//#include "defs.h"
//#include "UTIL/LOG/vcd_signal_dumper.h"
......@@ -32,15 +34,17 @@ int allocate_REs_in_RB_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
unsigned short id_offset,
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_NB_IoT_t mimo_mode = (frame_parms->mode1_flag==1)? SISO_NB_IoT:ALAMOUTI_NB_IoT;
uint32_t tti_offset,aa;
uint8_t re;
int16_t gain_lin_QPSK;
uint8_t first_re,last_re;
int32_t tmp_sample1,tmp_sample2;
gain_lin_QPSK = (int16_t)((amp*ONE_OVER_SQRT2_Q15_NB_IoT)>>15);
first_re=0;
last_re=12;
first_re = 0;
last_re = 12;
for (re=first_re; re<last_re; re++) { // re varies between 0 and 12 sub-carriers
......@@ -119,14 +123,15 @@ int dlsch_modulation_NB_IoT(int32_t **txdataF,
{
//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 jj = 0;
uint32_t re_allocated,symbol_offset;
uint16_t l;
uint8_t id_offset,pilots=0;
uint8_t id_offset,pilots = 0;
unsigned short bandwidth_even_odd;
unsigned short NB_IoT_start, RB_IoT_ID;
re_allocated=0;
id_offset=0;
re_allocated = 0;
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 = NB_IoT_RB_ID;
......@@ -134,9 +139,9 @@ int dlsch_modulation_NB_IoT(int32_t **txdataF,
for (l=control_region_size; l<14; l++) { // loop on OFDM symbols
if((l>=4 && l<=8) || (l>=11 && l<=13))
{
pilots =1;
pilots = 1;
} else {
pilots=0;
pilots = 0;
}
id_offset = frame_parms->Nid_cell % 3; // Cell_ID_NB_IoT % 3
if(RB_IoT_ID < (frame_parms->N_RB_DL/2))
......@@ -146,6 +151,7 @@ int dlsch_modulation_NB_IoT(int32_t **txdataF,
NB_IoT_start = (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
allocate_REs_in_RB_NB_IoT(frame_parms,
txdataF,
&jj,
......
......@@ -15,7 +15,7 @@
//#define DEBUG_SCRAMBLING 1
//#include "PHY/defs.h"
#include "PHY/defs_NB_IoT.h"
//#include "PHY/defs_NB_IoT.h"
//#include "PHY/CODING/extern.h"
//#include "PHY/CODING/lte_interleaver_inline.h"
//#include "defs.h"
......@@ -24,6 +24,8 @@
//#include "UTIL/LOG/vcd_signal_dumper.h"
#include "PHY/LTE_TRANSPORT/defs_NB_IoT.h"
#include "PHY/impl_defs_lte_NB_IoT.h"
#include "PHY/LTE_REFSIG/defs_NB_IoT.h"
void dlsch_scrambling_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
NB_IoT_eNB_DLSCH_t *dlsch,
......@@ -32,8 +34,8 @@ void dlsch_scrambling_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
uint8_t Ns) // slot number (0..19)
{
int i,j,k=0;
uint32_t x1, x2, s=0;
uint8_t *e=dlsch->harq_process.e; //uint8_t *e=dlsch->harq_processes[dlsch->current_harq_pid]->e;
uint32_t x1,x2, s=0;
uint8_t *e = dlsch->harq_process.e; //uint8_t *e=dlsch->harq_processes[dlsch->current_harq_pid]->e;
x2 = (dlsch->rnti<<14) + ((Nf%2)<<13) + ((Ns>>1)<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 10.2.3.1
......
......@@ -13,16 +13,17 @@
*/
//#include "PHY/defs.h"
#include "PHY/defs_NB_IoT.h"
//#include "PHY/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 "extern_NB_IoT.h"
//#include "PHY/extern_NB_IoT.h"
//#include "PHY/sse_intrin.h"
#include "PHY/LTE_TRANSPORT/defs_NB_IoT.h"
#include "PHY/CODING/defs_NB_IoT.h"
#include "PHY/LTE_REFSIG/defs_NB_IoT.h"
#include "PHY/impl_defs_lte_NB_IoT.h"
#include "PHY/impl_defs_top_NB_IoT.h"
//#ifdef PHY_ABSTRACTION
//#include "SIMULATION/TOOLS/defs.h"
......@@ -45,14 +46,16 @@ int allocate_npbch_REs_in_RB(NB_IoT_DL_FRAME_PARMS *frame_parms,
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;
uint32_t tti_offset,aa;
uint8_t re;
int16_t gain_lin_QPSK;
uint8_t first_re,last_re;
int32_t tmp_sample1,tmp_sample2;
gain_lin_QPSK = (int16_t)((amp*ONE_OVER_SQRT2_Q15_NB_IoT)>>15);
first_re=0;
last_re=12;
first_re = 0;
last_re = 12;
for (re=first_re; re<last_re; re++) { // re varies between 0 and 12 sub-carriers
......@@ -137,7 +140,8 @@ int generate_npbch(NB_IoT_eNB_NPBCH_t *eNB_npbch,
uint32_t re_allocated=0;
uint32_t symbol_offset;
uint16_t amask=0;
npbch_D = 16+NPBCH_A;
npbch_D = 16 + NPBCH_A;
npbch_E = 1600;
if (frame_mod64==0) {
......@@ -147,7 +151,7 @@ int generate_npbch(NB_IoT_eNB_NPBCH_t *eNB_npbch,
for (i=0; i<5; i++) // set input bits stream
{
if (i !=4 )
if (i != 4)
{
npbch_a[5-i-1] = npbch_pdu[i]; // ????????/*****?? in LTE 24 bits with 3 bytes, but in NB_IoT 34 bits will require 4 bytes+2 bits !! to verify
} else {
......@@ -223,10 +227,13 @@ void npbch_scrambling(NB_IoT_DL_FRAME_PARMS *frame_parms,
int i;
uint8_t reset;
uint32_t x1, x2, s=0;
reset = 1;
x2 = frame_parms->Nid_cell;
for (i=0; i<length; i++) {
if ((i&0x1f)==0) {
s = lte_gold_generic_NB_IoT(&x1, &x2, reset);
reset = 0;
}
......
......@@ -12,11 +12,13 @@
* \warning
*/
//#include <math.h>
//#include "PHY/defs.h"
#include "PHY/defs_NB_IoT.h"
#include "PHY/defs_NB_IoT.h" // not can be replaced by impl_defs_lte_NB_IoT & impl_defs_top_NB_IoT if "msg" function is not used
//#include "defs.h"
//#include "PHY/extern_NB_IoT.h"
//#include "PHY/impl_defs_lte_NB_IoT.h"
//#include "PHY/impl_defs_top_NB_IoT.h"
#include "nsss_NB_IoT.h"
int generate_sss_NB_IoT(int32_t **txdataF,
......
......@@ -28,6 +28,7 @@ void generate_pilots_NB_IoT(PHY_VARS_eNB_NB_IoT *phy_vars_eNB,
uint32_t tti,tti_offset,slot_offset,Nsymb,samples_per_symbol;
uint8_t first_pilot,second_pilot;
Nsymb = 14;
first_pilot = 5; // first pilot position
second_pilot = 6; // second pilot position
......
......@@ -32,7 +32,7 @@
#ifndef __LTE_TRANSPORT_PROTO_NB_IOT__H__
#define __LTE_TRANSPORT_PROTO_NB_IOT__H__
#include "PHY/defs_NB_IoT.h"
#include <math.h>
//#include <math.h>
//NPSS
......@@ -75,6 +75,7 @@ int allocate_npbch_REs_in_RB(NB_IoT_DL_FRAME_PARMS *frame_parms,
unsigned short id_offset,
uint32_t *re_allocated);
int generate_npbch(NB_IoT_eNB_NPBCH_t *eNB_npbch,
int32_t **txdataF,
int amp,
......@@ -83,6 +84,7 @@ int generate_npbch(NB_IoT_eNB_NPBCH_t *eNB_npbch,
uint8_t frame_mod64,
unsigned short NB_IoT_RB_ID);
void npbch_scrambling(NB_IoT_DL_FRAME_PARMS *frame_parms,
uint8_t *npbch_e,
uint32_t length);
......@@ -92,13 +94,15 @@ void npbch_scrambling(NB_IoT_DL_FRAME_PARMS *frame_parms,
/*Function to pack the DCI*/
// newly added function for NB-IoT , does not exist for LTE
void add_dci_NB_IoT(DCI_PDU_NB_IoT *DCI_pdu,
void *pdu,rnti_t rnti,
void *pdu,
rnti_t rnti,
unsigned char dci_size_bytes,
unsigned char aggregation,
unsigned char dci_size_bits,
unsigned char dci_fmt,
uint8_t npdcch_start_symbol);
/*Use the UL DCI Information to configure PHY and also Pack the DCI*/
int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
eNB_rxtx_proc_NB_IoT_t *proc,
......@@ -109,6 +113,7 @@ int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
uint8_t aggregation,
uint8_t npdcch_start_symbol);
/*Use the DL DCI Information to configure PHY and also Pack the DCI*/
int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
int frame,
......@@ -121,8 +126,9 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
uint8_t aggregation,
uint8_t npdcch_start_symbol);
/*Function for DCI encoding, scrambling, modulation*/
uint8_t generate_dci_top_NB_IoT(NB_IoT_eNB_NPDCCH_t* npdcch,
uint8_t generate_dci_top_NB_IoT(NB_IoT_eNB_NPDCCH_t *npdcch,
uint8_t Num_dci,
DCI_ALLOC_NB_IoT_t *dci_alloc,
int16_t amp,
......@@ -157,6 +163,7 @@ NB_IoT_eNB_NDLSCH_t *new_eNB_dlsch_NB_IoT(//unsigned char Kmimo,
uint8_t abstraction_flag,
NB_IoT_DL_FRAME_PARMS* frame_parms);
NB_IoT_eNB_NULSCH_t *new_eNB_ulsch_NB(uint8_t abstraction_flag);
//5555
......
......@@ -19,7 +19,9 @@
* contact@openairinterface.org
*/
#include "PHY/types_NB_IoT.h"
#ifndef __UCI_NB_IOT__H__
#define __UCI_NB_IOT__H__
//#include "PHY/types_NB_IoT.h"
......@@ -336,3 +338,4 @@ HLC_subband_cqi_mcs_CBA_20MHz;
#define MAX_ACK_PAYLOAD 18
#define MAX_RI_PAYLOAD 6
*/
#endif
\ No newline at end of file
......@@ -9,7 +9,7 @@
#define __IF_MODULE_NB_IoT__H__
#include "nfapi_interface.h"
#include "openair1/PHY/LTE_TRANSPORT/defs_NB_IoT.h"
//#include "openair1/PHY/LTE_TRANSPORT/defs_NB_IoT.h"
#include "PhysicalConfigDedicated-NB-r13.h"
//#include "openair2/PHY_INTERFACE/IF_Module_NB_IoT.h"
#include "openair2/COMMON/platform_types.h"
......
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