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
......@@ -24,15 +24,15 @@ unsigned short glte_NB_IoT[] = { 0133, 0171, 0165 }; // {A,B} //renaimed but is
An optional 8-bit CRC (3GPP) can be added.
Trellis tail-biting is included here
*************************************************************************/
void ccode_encode_NB_IoT (int32_t numbits,
uint8_t add_crc,
uint8_t *inPtr,
uint8_t *outPtr,
uint16_t rnti)
void ccode_encode_NB_IoT (int32_t numbits,
uint8_t add_crc,
uint8_t *inPtr,
uint8_t *outPtr,
uint16_t rnti)
{
uint32_t state;
uint32_t state;
uint8_t c, out, first_bit;
int8_t shiftbit=0;
int8_t shiftbit=0;
uint16_t c16;
uint16_t next_last_byte=0;
uint32_t crc=0;
......@@ -42,23 +42,27 @@ 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);
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];
next_last_byte = numbits>>3;
first_bit = (numbits-6)&7;
c = inPtr[next_last_byte-1];
}
// Perform Tail-biting
// 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);
if ((c&(1<<(7-first_bit-shiftbit))) != 0)
state |= (1<<shiftbit);
}
state = state & 0x3f; // true initial state of Tail-biting CCode
......@@ -69,20 +73,19 @@ 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) {
state |= 64;
}
state >>= 1;
out = ccodelte_table_NB_IoT[state];
if ((c&(1<<shiftbit)) != 0) {
state |= 64;
}
*outPtr++ = out & 1;
*outPtr++ = (out>>1)&1;
*outPtr++ = (out>>2)&1;
out = ccodelte_table_NB_IoT[state];
*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,18 +94,18 @@ 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) {
state |= 64;
}
state >>= 1;
out = ccodelte_table_NB_IoT[state];
if ((c16&(1<<shiftbit)) != 0) {
state |= 64;
}
*outPtr++ = out & 1;
*outPtr++ = (out>>1)&1;
*outPtr++ = (out>>2)&1;
out = ccodelte_table_NB_IoT[state];
*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,14 +36,14 @@
//#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
unsigned int poly24b_NB_IoT = 0x80006300; // 1000 0000 0000 0000 0110 0011 D^24 + D^23 + D^6 + D^5 + D + 1
unsigned int poly16_NB_IoT = 0x10210000; // 0001 0000 0010 0001 D^16 + D^12 + D^5 + 1
unsigned int poly12_NB_IoT = 0x80F00000; // 1000 0000 1111 D^12 + D^11 + D^3 + D^2 + D + 1
unsigned int poly8_NB_IoT = 0x9B000000; // 1001 1011 D^8 + D^7 + D^4 + D^3 + D + 1
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
unsigned int poly24b_NB_IoT = 0x80006300; // 1000 0000 0000 0000 0110 0011 D^24 + D^23 + D^6 + D^5 + D + 1
unsigned int poly16_NB_IoT = 0x10210000; // 0001 0000 0010 0001 D^16 + D^12 + D^5 + 1
unsigned int poly12_NB_IoT = 0x80F00000; // 1000 0000 1111 D^12 + D^11 + D^3 + D^2 + D + 1
unsigned int poly8_NB_IoT = 0x9B000000; // 1001 1011 D^8 + D^7 + D^4 + D^3 + D + 1
/*********************************************************
For initialization && verification purposes,
......@@ -52,22 +52,26 @@ 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;
unsigned int i, crc = 0, c;
while (octetlen-- > 0) {
c = (*inputptr++) << 24;
c = (*inputptr++) << 24;
for (i = 8; i != 0; i--) {
if ((1 << 31) & (c ^ crc))
crc = (crc << 1) ^ poly;
else
crc <<= 1;
for (i = 8; i != 0; i--) {
c <<= 1;
}
if ((1 << 31) & (c ^ crc))
crc = (crc << 1) ^ poly;
else
crc <<= 1;
c <<= 1;
}
}
return crc;
......@@ -86,15 +90,16 @@ static unsigned char crc8Table_NB_IoT[256];
void crcTableInit_NB_IoT (void)
{
unsigned char c = 0;
unsigned char c = 0;
do {
crc24aTable_NB_IoT[c] = crcbit_NB_IoT (&c, 1, poly24a_NB_IoT);
crc24bTable_NB_IoT[c] = crcbit_NB_IoT (&c, 1, poly24b_NB_IoT);
crc16Table_NB_IoT[c] = (unsigned short) (crcbit_NB_IoT (&c, 1, poly16_NB_IoT) >> 16);
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);
crc24aTable_NB_IoT[c] = crcbit_NB_IoT (&c, 1, poly24a_NB_IoT);
crc24bTable_NB_IoT[c] = crcbit_NB_IoT (&c, 1, poly24b_NB_IoT);
crc16Table_NB_IoT[c] = (unsigned short) (crcbit_NB_IoT (&c, 1, poly16_NB_IoT) >> 16);
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,22 +107,24 @@ 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;
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)];
crc = (crc << 8) ^ crc24aTable_NB_IoT[(*inptr++) ^ (crc >> 24)];
}
if (resbit > 0)
crc = (crc << resbit) ^ crc24aTable_NB_IoT[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))];
crc = (crc << resbit) ^ crc24aTable_NB_IoT[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))];
return crc;
}
......@@ -126,41 +133,47 @@ unsigned int crc24b_NB_IoT (unsigned char * inptr, int bitlen)
{
int octetlen, resbit;
unsigned int crc = 0;
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)];
crc = (crc << 8) ^ crc24bTable_NB_IoT[(*inptr++) ^ (crc >> 24)];
}
if (resbit > 0)
crc = (crc << resbit) ^ crc24bTable_NB_IoT[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))];
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;
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 ?
......@@ -26,44 +27,44 @@ static uint32_t bitrev_cc_NB_IoT[32] = {1,17,9,25,5,21,13,29,3,19,11,27,7,23,15,
uint32_t sub_block_interleaving_cc_NB_IoT(uint32_t D, uint8_t *d,uint8_t *w)
{
uint32_t RCC = (D>>5), ND, ND3; // D = 50 ,
uint32_t row,col,Kpi,index;
uint32_t index3,k;
uint32_t RCC = (D>>5), ND, ND3; // D = 50 ,
uint32_t row,col,Kpi,index;
uint32_t index3,k;
if ((D&0x1f) > 0)
RCC++;
if ((D&0x1f) > 0)
RCC++;
Kpi = (RCC<<5); // Kpi = 32
ND = Kpi - D;
ND3 = ND*3; // ND3 = ND*3 = 18 *3 = 54
k=0;
Kpi = (RCC<<5); // Kpi = 32
ND = Kpi - D;
ND3 = ND*3; // ND3 = ND*3 = 18 *3 = 54
k=0;
for (col=0; col<32; col++) {
for (col=0; col<32; col++) {
index = bitrev_cc_NB_IoT[col];
index3 = 3*index;
index = bitrev_cc_NB_IoT[col];
index3 = 3*index;
for (row=0; row<RCC; row++) {
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];
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];
index3+=96;
index+=32;
k++;
index3+=96;
index+=32;
k++;
}
}
}
return(RCC);
return(RCC);
}
uint32_t lte_rate_matching_cc_NB_IoT(uint32_t RCC, // RRC = 2
uint16_t E, // E = 1600
uint8_t *w, // length
uint8_t *e) // length 1600
uint32_t lte_rate_matching_cc_NB_IoT(uint32_t RCC, // RRC = 2
uint16_t E, // E = 1600
uint8_t *w, // length
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 "openair2/PHY_INTERFACE/IF_Module_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
......@@ -189,12 +189,12 @@ void phy_config_mib_eNB_NB_IoT(int Mod_id,
//
//}
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)
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)
{
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);
......@@ -349,37 +349,36 @@ void phy_config_sib2_eNB_NB_IoT(uint8_t Mod_id,
void phy_config_dedicated_eNB_NB_IoT(uint8_t Mod_id,
int CC_id,
uint16_t rnti,
extra_phyConfig_t *extra_parms)
void phy_config_dedicated_eNB_NB_IoT(uint8_t Mod_id,
int CC_id,
uint16_t rnti,
extra_phyConfig_t *extra_parms)
{
PHY_VARS_eNB_NB_IoT *eNB = PHY_vars_eNB_NB_IoT_g[Mod_id][CC_id];
NB_IoT_eNB_NPDCCH_t *npdcch;
uint8_t UE_id = find_ue_NB_IoT(rnti,eNB);
PHY_VARS_eNB_NB_IoT *eNB = PHY_vars_eNB_NB_IoT_g[Mod_id][CC_id];
NB_IoT_eNB_NPDCCH_t *npdcch;
uint8_t UE_id = find_ue_NB_IoT(rnti,eNB);
if (UE_id == -1) {
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
//
//configure UE specific parameters for NPDCCH Search Space
if (eNB->npdcch[UE_id]) {
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 {
} else {
LOG_E(PHY,"[eNB %d] Received NULL radioResourceConfigDedicated from eNB %d\n",Mod_id, UE_id);
return;
}
}
}
......
......@@ -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
......@@ -38,15 +40,17 @@ void lte_gold_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,uint32_t lte_gold_table_
@param p antenna index
@param RB_IoT_ID the ID of the RB dedicated for NB_IoT
*/
int lte_dl_cell_spec_NB_IoT(PHY_VARS_eNB_NB_IoT *phy_vars_eNB,
int32_t *output,
short amp,
unsigned char Ns,
unsigned char l,
unsigned char p,
unsigned short RB_IoT_ID);
unsigned int lte_gold_generic_NB_IoT(unsigned int *x1, unsigned int *x2, unsigned char reset);
int lte_dl_cell_spec_NB_IoT(PHY_VARS_eNB_NB_IoT *phy_vars_eNB,
int32_t *output,
short amp,
unsigned char Ns,
unsigned char l,
unsigned char p,
unsigned short RB_IoT_ID);
unsigned int lte_gold_generic_NB_IoT(unsigned int *x1,
unsigned int *x2,
unsigned char reset);
#endif
......@@ -12,26 +12,27 @@
* \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,
int32_t *output,
short amp,
unsigned char Ns,
unsigned char l,
unsigned char p,
unsigned short RB_IoT_ID) // the ID of the RB dedicated for NB_IoT
int lte_dl_cell_spec_NB_IoT(PHY_VARS_eNB_NB_IoT *phy_vars_eNB,
int32_t *output,
short amp,
unsigned char Ns,
unsigned char l,
unsigned char p,
unsigned short RB_IoT_ID) // the ID of the RB dedicated for NB_IoT
{
unsigned char nu,m;
unsigned short k,a;
unsigned short NB_IoT_start,bandwidth_even_odd;
int32_t qpsk[4];
unsigned char nu,m;
unsigned short k,a;
unsigned short NB_IoT_start,bandwidth_even_odd;
int32_t qpsk[4];
a = (amp*ONE_OVER_SQRT2_Q15_NB_IoT)>>15;
((short *)&qpsk[0])[0] = a;
......
......@@ -13,20 +13,18 @@
*/
//#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
{
unsigned char ns,l,Ncp=1;
unsigned int n,x1,x2;
unsigned int n,x1,x2;
for (ns=0; ns<20; ns++) {
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"
......@@ -57,17 +59,17 @@ static uint8_t w[2][3*3*(MAX_DCI_SIZE_BITS_NB_IoT+16)];
void dci_encoding_NB_IoT(uint8_t *a[2], // Array of two DCI pdus, even if one DCI is to transmit , the number of DCI is indicated in dci_number
uint8_t A, // Length of array a (in number of bytes)(es 4 bytes = 32 bits) is a parameter fixed
uint16_t E, // E should equals to G (number of available bits in one RB)
uint8_t *e[2], // *e should be e[2][G]
uint16_t rnti[2], // RNTI for UE specific or common search space
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
void dci_encoding_NB_IoT(uint8_t *a[2], // Array of two DCI pdus, even if one DCI is to transmit , the number of DCI is indicated in dci_number
uint8_t A, // Length of array a (in number of bytes)(es 4 bytes = 32 bits) is a parameter fixed
uint16_t E, // E should equals to G (number of available bits in one RB)
uint8_t *e[2], // *e should be e[2][G]
uint16_t rnti[2], // RNTI for UE specific or common search space
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 D = (A + 16);
uint8_t D = (A + 16);
uint32_t RCC;
uint8_t occupation_size=1;
uint8_t occupation_size=1;
// encode dci
if(dci_number == 1)
{
......@@ -109,10 +111,10 @@ void npdcch_scrambling_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
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;
uint32_t x1, x2, s=0;
uint8_t reset;
uint8_t occupation_size=1;
int i,k=0;
uint32_t x1, x2, s=0;
uint8_t reset;
uint8_t occupation_size=1;
reset = 1;
......@@ -178,11 +180,12 @@ 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;
uint8_t first_re,last_re;
int32_t tmp_sample1,tmp_sample2,tmp_sample3,tmp_sample4;
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,tmp_sample3,tmp_sample4;
gain_lin_QPSK = (int16_t)((amp*ONE_OVER_SQRT2_Q15_NB_IoT)>>15);
first_re=0;
......@@ -413,12 +416,13 @@ int dci_modulation_NB_IoT(int32_t **txdataF,
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
{
uint32_t jj=0;
uint32_t re_allocated,symbol_offset;
uint16_t l;
uint8_t id_offset,pilots=0;
unsigned short bandwidth_even_odd;
unsigned short NB_IoT_start, RB_IoT_ID;
uint32_t jj=0;
uint32_t re_allocated,symbol_offset;
uint16_t l;
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
......@@ -475,10 +479,10 @@ uint8_t generate_dci_top_NB_IoT(NB_IoT_eNB_NPDCCH_t *npdcch,
{
int i, G;
int i, G;
//temporary variable
uint16_t rnti[2];
uint8_t L = 0;
uint8_t L = 0;
/* PARAMETERS may not needed
......
......@@ -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
......@@ -53,11 +55,11 @@ void add_dci_NB_IoT(DCI_PDU_NB_IoT *DCI_pdu,void *pdu,rnti_t rnti,unsigned char
//put the pdu
memcpy(&DCI_pdu->dci_alloc[DCI_pdu->Num_dci].dci_pdu[0],pdu,dci_size_bytes);
//configure the dci alloc
DCI_pdu->dci_alloc[DCI_pdu->Num_dci].dci_length = dci_size_bits;
DCI_pdu->dci_alloc[DCI_pdu->Num_dci].L = aggregation;
DCI_pdu->dci_alloc[DCI_pdu->Num_dci].rnti = rnti;
DCI_pdu->dci_alloc[DCI_pdu->Num_dci].format = dci_fmt;
DCI_pdu->npdcch_start_symbol = npdcch_start_symbol;
DCI_pdu->dci_alloc[DCI_pdu->Num_dci].dci_length = dci_size_bits;
DCI_pdu->dci_alloc[DCI_pdu->Num_dci].L = aggregation;
DCI_pdu->dci_alloc[DCI_pdu->Num_dci].rnti = rnti;
DCI_pdu->dci_alloc[DCI_pdu->Num_dci].format = dci_fmt;
DCI_pdu->npdcch_start_symbol = npdcch_start_symbol;
DCI_pdu->Num_dci++;
......@@ -65,14 +67,14 @@ void add_dci_NB_IoT(DCI_PDU_NB_IoT *DCI_pdu,void *pdu,rnti_t rnti,unsigned char
}
int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
eNB_rxtx_proc_NB_IoT_t *proc,
DCI_CONTENT *DCI_Content,
uint16_t rnti,
DCI_format_NB_IoT_t dci_format,
uint8_t UE_id,
uint8_t aggregation,
uint8_t npdcch_start_symbol)
int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
eNB_rxtx_proc_NB_IoT_t *proc,
DCI_CONTENT *DCI_Content,
uint16_t rnti,
DCI_format_NB_IoT_t dci_format,
uint8_t UE_id,
uint8_t aggregation,
uint8_t npdcch_start_symbol)
{
void *ULSCH_DCI_NB_IoT = NULL;
......@@ -141,20 +143,21 @@ int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
//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 generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
int frame,
uint8_t subframe,
DCI_CONTENT *DCI_Content,
uint16_t rnti,
DCI_format_NB_IoT_t dci_format,
NB_IoT_eNB_NDLSCH_t *ndlsch,
NB_IoT_DL_FRAME_PARMS *frame_parms,
uint8_t aggregation,
uint8_t npdcch_start_symbol)
int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
int frame,
uint8_t subframe,
DCI_CONTENT *DCI_Content,
uint16_t rnti,
DCI_format_NB_IoT_t dci_format,
NB_IoT_eNB_NDLSCH_t *ndlsch,
NB_IoT_DL_FRAME_PARMS *frame_parms,
uint8_t aggregation,
uint8_t npdcch_start_symbol)
{
NB_IoT_DL_eNB_HARQ_t* ndlsch_harq = ndlsch->harq_process;
void *DLSCH_DCI_NB_IoT = NULL;
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));
......@@ -232,15 +235,15 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
ndlsch->active = 0; //will be activated by the corresponding NDSLCH pdu
// use this value to configure PHY both harq_processes and resource mapping.
ndlsch_harq->scheduling_delay = Sched_delay;
ndlsch_harq->resource_assignment = resource_to_subframe[ResAssign]; //from Isf of DCI to the number of subframe
ndlsch_harq->repetition_number = RepNum;
ndlsch_harq->scheduling_delay = Sched_delay;
ndlsch_harq->resource_assignment = resource_to_subframe[ResAssign]; //from Isf of DCI to the number of subframe
ndlsch_harq->repetition_number = RepNum;
ndlsch_harq->dci_subframe_repetitions = DCIRep;
ndlsch_harq->modulation = 2; //QPSK
ndlsch_harq->modulation = 2; //QPSK
if(ndlsch_harq->round == 0) //this should be set from initialization (init-lte)
ndlsch_harq->status = ACTIVE;
ndlsch_harq->mcs = mcs;
ndlsch_harq->status = ACTIVE_NB_IoT;
ndlsch_harq->mcs = mcs;
/*
* TS 36.213 ch 16.4.1.5
......@@ -248,8 +251,8 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
* ISF = ResAssign
*/
ndlsch_harq->TBS = TBStable_NB_IoT[mcs][ResAssign];
ndlsch_harq->subframe = subframe;
ndlsch_harq->TBS = TBStable_NB_IoT[mcs][ResAssign];
ndlsch_harq->subframe = subframe;
//ndlsch_harq->B; we don-t have now my is given when we receive the dlsch data
//ndlsch->error_treshold
......@@ -298,21 +301,22 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
/*Now configure the ndlsch structure*/
ndlsch->subframe_tx[subframe] = 1; // check if it's OK
ndlsch->rnti = rnti; //we store the RNTI (e.g. for RNTI will be used later)
ndlsch->active = 0;//will be activated by the corresponding NDSLCH pdu
ndlsch->rnti = rnti; //we store the RNTI (e.g. for RNTI will be used later)
ndlsch->active = 0;//will be activated by the corresponding NDSLCH pdu
// use this value to configure PHY both harq_processes and resource mapping.
ndlsch_harq->scheduling_delay = Sched_delay;
ndlsch_harq->resource_assignment = resource_to_subframe[ResAssign]; //from Isf of DCI to the number of subframe
ndlsch_harq->repetition_number = RepNum;
ndlsch_harq->scheduling_delay = Sched_delay;
ndlsch_harq->resource_assignment = resource_to_subframe[ResAssign]; //from Isf of DCI to the number of subframe
ndlsch_harq->repetition_number = RepNum;
ndlsch_harq->dci_subframe_repetitions = DCIRep;
ndlsch_harq->modulation = 2; //QPSK
ndlsch_harq->modulation = 2; //QPSK
if(ndlsch_harq->round == 0){ //this should be set from initialization (init-lte)
ndlsch_harq->status = ACTIVE;
ndlsch_harq->mcs = mcs;
ndlsch_harq->TBS = TBStable_NB_IoT[mcs][ResAssign]; // this table should be rewritten for nb-iot
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
}
ndlsch_harq->frame = frame;
ndlsch_harq->frame = frame;
ndlsch_harq->subframe = subframe;
......
......@@ -136,314 +136,318 @@
//} 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;
typedef struct {
/// NB-IoT
SCH_status_NB_IoT_t status;
SCH_status_NB_IoT_t status;
/// The scheduling the NPDCCH and the NPDSCH transmission TS 36.213 Table 16.4.1-1
uint8_t scheduling_delay;
uint8_t scheduling_delay;
/// The number of the subframe to transmit the NPDSCH Table TS 36.213 Table 16.4.1.3-1 (Nsf) (NB. in this case is not the index Isf)
uint8_t resource_assignment;
uint8_t resource_assignment;
/// is the index that determined the repeat number of NPDSCH through table TS 36.213 Table 16.4.1.3-2 / for SIB1-NB Table 16.4.1.3-3
uint8_t repetition_number;
uint8_t repetition_number;
/// Determined the ACK/NACK delay and the subcarrier allocation TS 36.213 Table 16.4.2
uint8_t HARQ_ACK_resource;
uint8_t HARQ_ACK_resource;
/// Determined the repetition number value 0-3 (2 biut carried by the FAPI NPDCCH)
uint8_t dci_subframe_repetitions;
uint8_t dci_subframe_repetitions;
/// modulation always QPSK Qm = 2
uint8_t modulation;
uint8_t modulation;
/// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
uint8_t e[MAX_NUM_CHANNEL_BITS_NB_IoT];
uint8_t e[MAX_NUM_CHANNEL_BITS_NB_IoT];
/// data after scrambling
uint8_t s_e[MAX_NUM_CHANNEL_BITS_NB_IoT];
uint8_t s_e[MAX_NUM_CHANNEL_BITS_NB_IoT];
//length of the table e
uint16_t length_e; // new parameter
uint16_t length_e; // new parameter
/// Tail-biting convolutional coding outputs
uint8_t d[96+(3*(24+MAX_DL_SIZE_BITS_NB_IoT))]; // new parameter
uint8_t d[96+(3*(24+MAX_DL_SIZE_BITS_NB_IoT))]; // new parameter
/// Sub-block interleaver outputs
uint8_t w[3*3*(MAX_DL_SIZE_BITS_NB_IoT+24)]; // new parameter
uint8_t w[3*3*(MAX_DL_SIZE_BITS_NB_IoT+24)]; // new parameter
/// Status Flag indicating for this DLSCH (idle,active,disabled)
//SCH_status_t status;
/// Transport block size
uint32_t TBS;
uint32_t TBS;
/// The payload + CRC size in bits, "B" from 36-212
uint32_t B;
uint32_t B;
/// Pointer to the payload
uint8_t *b;
uint8_t *b;
///pdu of the ndlsch message
uint8_t*pdu;
uint8_t *pdu;
/// Frame where current HARQ round was sent
uint32_t frame;
uint32_t frame;
/// Subframe where current HARQ round was sent
uint32_t subframe;
uint32_t subframe;
/// Index of current HARQ round for this DLSCH
uint8_t round;
uint8_t round;
/// MCS format for this NDLSCH , TS 36.213 Table 16.4.1.5
uint8_t mcs;
uint8_t mcs;
// we don't have code block segmentation / crc attachment / concatenation in NB-IoT R13 36.212 6.4.2
// we don't have beamforming in NB-IoT
//this index will be used mainly for SI message buffer
uint8_t pdu_buffer_index;
uint8_t pdu_buffer_index;
} NB_IoT_DL_eNB_HARQ_t;
typedef struct { // LTE_eNB_DLSCH_t
/// TX buffers for UE-spec transmission (antenna ports 5 or 7..14, prior to precoding)
uint32_t *txdataF[8];
uint32_t *txdataF[8];
/// Allocated RNTI (0 means DLSCH_t is not currently used)
uint16_t rnti;
uint16_t rnti;
/// Active flag for baseband transmitter processing
uint8_t active;
uint8_t active;
/// Indicator of TX activation per subframe. Used during PUCCH detection for ACK/NAK.
uint8_t subframe_tx[10];
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];
uint8_t nCCE[10];
/// Current HARQ process id
uint8_t current_harq_pid;
uint8_t current_harq_pid;
/// Process ID's per subframe. Used to associate received ACKs on PUSCH/PUCCH to DLSCH harq process ids
uint8_t harq_ids[10];
uint8_t harq_ids[10];
/// Window size (in outgoing transport blocks) for fine-grain rate adaptation
uint8_t ra_window_size;
uint8_t ra_window_size;
/// First-round error threshold for fine-grain rate adaptation
uint8_t error_threshold;
uint8_t error_threshold;
/// Pointers to 8 HARQ processes for the DLSCH
NB_IoT_DL_eNB_HARQ_t harq_process;
NB_IoT_DL_eNB_HARQ_t harq_process;
/// circular list of free harq PIDs (the oldest come first)
/// (10 is arbitrary value, must be > to max number of DL HARQ processes in LTE)
int harq_pid_freelist[10];
int harq_pid_freelist[10];
/// the head position of the free list (if list is free then head=tail)
int head_freelist;
int head_freelist;
/// the tail position of the free list
int tail_freelist;
int tail_freelist;
/// Number of soft channel bits
uint32_t G;
uint32_t G;
/// Codebook index for this dlsch (0,1,2,3)
uint8_t codebook_index;
uint8_t codebook_index;
/// Maximum number of HARQ processes (for definition see 36-212 V8.6 2009-03, p.17)
uint8_t Mdlharq;
uint8_t Mdlharq;
/// Maximum number of HARQ rounds
uint8_t Mlimit;
uint8_t Mlimit;
/// MIMO transmission mode indicator for this sub-frame (for definition see 36-212 V8.6 2009-03, p.17)
uint8_t Kmimo;
uint8_t Kmimo;
/// Nsoft parameter related to UE Category
uint32_t Nsoft;
uint32_t Nsoft;
/// amplitude of PDSCH (compared to RS) in symbols without pilots
int16_t sqrt_rho_a;
int16_t sqrt_rho_a;
/// amplitude of PDSCH (compared to RS) in symbols containing pilots
int16_t sqrt_rho_b;
int16_t sqrt_rho_b;
} NB_IoT_eNB_DLSCH_t;
typedef struct {
/// HARQ process id
uint8_t harq_id;
uint8_t harq_id;
/// ACK bits (after decoding) 0:NACK / 1:ACK / 2:DTX
uint8_t ack;
uint8_t ack;
/// send status (for PUCCH)
uint8_t send_harq_status;
uint8_t send_harq_status;
/// nCCE (for PUCCH)
uint8_t nCCE;
uint8_t nCCE;
/// DAI value detected from DCI1/1a/1b/1d/2/2a/2b/2c. 0xff indicates not touched
uint8_t vDAI_DL;
uint8_t vDAI_DL;
/// DAI value detected from DCI0/4. 0xff indicates not touched
uint8_t vDAI_UL;
uint8_t vDAI_UL;
} harq_status_NB_IoT_t;
typedef struct {
/// UL RSSI per receive antenna
int32_t UL_rssi[NB_ANTENNAS_RX];
int32_t UL_rssi[NB_ANTENNAS_RX];
/// PUCCH1a/b power (digital linear)
uint32_t Po_PUCCH;
uint32_t Po_PUCCH;
/// PUCCH1a/b power (dBm)
int32_t Po_PUCCH_dBm;
int32_t Po_PUCCH_dBm;
/// PUCCH1 power (digital linear), conditioned on below threshold
uint32_t Po_PUCCH1_below;
uint32_t Po_PUCCH1_below;
/// PUCCH1 power (digital linear), conditioned on above threshold
uint32_t Po_PUCCH1_above;
uint32_t Po_PUCCH1_above;
/// Indicator that Po_PUCCH has been updated by PHY
int32_t Po_PUCCH_update;
int32_t Po_PUCCH_update;
/// DL Wideband CQI index (2 TBs)
uint8_t DL_cqi[2];
uint8_t DL_cqi[2];
/// DL Subband CQI index (from HLC feedback)
uint8_t DL_subband_cqi[2][13];
uint8_t DL_subband_cqi[2][13];
/// DL PMI Single Stream
uint16_t DL_pmi_single;
uint16_t DL_pmi_single;
/// DL PMI Dual Stream
uint16_t DL_pmi_dual;
uint16_t DL_pmi_dual;
/// Current RI
uint8_t rank;
uint8_t rank;
/// CRNTI of UE
uint16_t crnti; ///user id (rnti) of connected UEs
uint16_t crnti; ///user id (rnti) of connected UEs
/// Initial timing offset estimate from PRACH for RAR
int32_t UE_timing_offset;
int32_t UE_timing_offset;
/// Timing advance estimate from PUSCH for MAC timing advance signalling
int32_t timing_advance_update;
int32_t timing_advance_update;
/// Current mode of UE (NOT SYCHED, RAR, PUSCH)
UE_MODE_NB_IoT_t mode;
UE_MODE_NB_IoT_t mode;
/// Current sector where UE is attached
uint8_t sector;
uint8_t sector;
/// dlsch l2 errors
uint32_t dlsch_l2_errors[8];
uint32_t dlsch_l2_errors[8];
/// dlsch trials per harq and round
uint32_t dlsch_trials[8][8];
uint32_t dlsch_trials[8][8];
/// dlsch ACK/NACK per hard_pid and round
uint32_t dlsch_ACK[8][8];
uint32_t dlsch_NAK[8][8];
uint32_t dlsch_ACK[8][8];
uint32_t dlsch_NAK[8][8];
/// ulsch l2 errors per harq_pid
uint32_t ulsch_errors[8];
uint32_t ulsch_errors[8];
/// ulsch l2 consecutive errors per harq_pid
uint32_t ulsch_consecutive_errors; //[8];
uint32_t ulsch_consecutive_errors; //[8];
/// ulsch trials/errors/fer per harq and round
uint32_t nulsch_decoding_attempts[8][8];
uint32_t ulsch_round_errors[8][8];
uint32_t ulsch_decoding_attempts_last[8][8];
uint32_t ulsch_round_errors_last[8][8];
uint32_t ulsch_round_fer[8][8];
uint32_t sr_received;
uint32_t sr_total;
uint32_t nulsch_decoding_attempts[8][8];
uint32_t ulsch_round_errors[8][8];
uint32_t ulsch_decoding_attempts_last[8][8];
uint32_t ulsch_round_errors_last[8][8];
uint32_t ulsch_round_fer[8][8];
uint32_t sr_received;
uint32_t sr_total;
/// dlsch sliding count and total errors in round 0 are used to compute the dlsch_mcs_offset
uint32_t dlsch_sliding_cnt;
uint32_t dlsch_NAK_round0;
int8_t dlsch_mcs_offset;
uint32_t dlsch_sliding_cnt;
uint32_t dlsch_NAK_round0;
int8_t dlsch_mcs_offset;
/// Target mcs1 after rate-adaptation (used by MAC layer scheduler)
uint8_t dlsch_mcs1;
uint8_t dlsch_mcs1;
/// Target mcs2 after rate-adaptation (used by MAC layer scheduler)
uint8_t dlsch_mcs2;
uint8_t dlsch_mcs2;
/// Total bits received from MAC on PDSCH
int total_TBS_MAC;
int total_TBS_MAC;
/// Total bits acknowledged on PDSCH
int total_TBS;
int total_TBS;
/// Total bits acknowledged on PDSCH (last interval)
int total_TBS_last;
int total_TBS_last;
/// Bitrate on the PDSCH [bps]
unsigned int dlsch_bitrate;
unsigned int dlsch_bitrate;
// unsigned int total_transmitted_bits;
} NB_IoT_eNB_UE_stats;
typedef struct {
/// Indicator of first transmission
uint8_t first_tx;
uint8_t first_tx;
/// Last Ndi received for this process on DCI (used for C-RNTI only)
uint8_t DCINdi;
uint8_t DCINdi;
/// DLSCH status flag indicating
//SCH_status_t status;
/// Transport block size
uint32_t TBS;
uint32_t TBS;
/// The payload + CRC size in bits
uint32_t B;
uint32_t B;
/// Pointer to the payload
uint8_t *b;
uint8_t *b;
/// Pointers to transport block segments
uint8_t *c[MAX_NUM_DLSCH_SEGMENTS_NB_IoT];
uint8_t *c[MAX_NUM_DLSCH_SEGMENTS_NB_IoT];
/// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15)
uint32_t RTC[MAX_NUM_DLSCH_SEGMENTS_NB_IoT];
uint32_t RTC[MAX_NUM_DLSCH_SEGMENTS_NB_IoT];
/// Index of current HARQ round for this DLSCH
uint8_t round;
uint8_t round;
/// MCS format for this DLSCH
uint8_t mcs;
uint8_t mcs;
/// Qm (modulation order) for this DLSCH
uint8_t Qm;
uint8_t Qm;
/// Redundancy-version of the current sub-frame
uint8_t rvidx;
uint8_t rvidx;
/// MIMO mode for this DLSCH
// MIMO_mode_t mimo_mode;
/// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
int16_t w[MAX_NUM_DLSCH_SEGMENTS_NB_IoT][3*(6144+64)];
int16_t w[MAX_NUM_DLSCH_SEGMENTS_NB_IoT][3*(6144+64)];
/// for abstraction soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
double w_abs[MAX_NUM_DLSCH_SEGMENTS_NB_IoT][3*(6144+64)];
double w_abs[MAX_NUM_DLSCH_SEGMENTS_NB_IoT][3*(6144+64)];
/// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
int16_t *d[MAX_NUM_DLSCH_SEGMENTS_NB_IoT];
int16_t *d[MAX_NUM_DLSCH_SEGMENTS_NB_IoT];
/// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9)
uint32_t C;
uint32_t C;
/// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Cminus;
uint32_t Cminus;
/// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Cplus;
uint32_t Cplus;
/// Number of bits in "small" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Kminus;
uint32_t Kminus;
/// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Kplus;
uint32_t Kplus;
/// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t F;
uint32_t F;
/// Number of MIMO layers (streams) (for definition see 36-212 V8.6 2009-03, p.17)
uint8_t Nl;
uint8_t Nl;
/// current delta_pucch
int8_t delta_PUCCH;
int8_t delta_PUCCH;
/// Number of soft channel bits
uint32_t G;
uint32_t G;
/// Current Number of RBs
uint16_t nb_rb;
uint16_t nb_rb;
/// Current subband PMI allocation
uint16_t pmi_alloc;
uint16_t pmi_alloc;
/// Current RB allocation (even slots)
uint32_t rb_alloc_even[4];
uint32_t rb_alloc_even[4];
/// Current RB allocation (odd slots)
uint32_t rb_alloc_odd[4];
uint32_t rb_alloc_odd[4];
/// distributed/localized flag
//vrb_t vrb_type;
/// downlink power offset field
uint8_t dl_power_off;
uint8_t dl_power_off;
/// trials per round statistics
uint32_t trials[8];
uint32_t trials[8];
/// error statistics per round
uint32_t errors[8];
uint32_t errors[8];
/// codeword this transport block is mapped to
uint8_t codeword;
uint8_t codeword;
} NB_IoT_DL_UE_HARQ_t;
typedef struct {
/// RNTI
uint16_t rnti;
uint16_t rnti;
/// Active flag for DLSCH demodulation
uint8_t active;
uint8_t active;
/// Transmission mode
uint8_t mode1_flag;
uint8_t mode1_flag;
/// amplitude of PDSCH (compared to RS) in symbols without pilots
int16_t sqrt_rho_a;
int16_t sqrt_rho_a;
/// amplitude of PDSCH (compared to RS) in symbols containing pilots
int16_t sqrt_rho_b;
int16_t sqrt_rho_b;
/// Current HARQ process id threadRx Odd and threadRx Even
uint8_t current_harq_pid;
uint8_t current_harq_pid;
/// Current subband antenna selection
uint32_t antenna_alloc;
uint32_t antenna_alloc;
/// Current subband RI allocation
uint32_t ri_alloc;
uint32_t ri_alloc;
/// Current subband CQI1 allocation
uint32_t cqi_alloc1;
uint32_t cqi_alloc1;
/// Current subband CQI2 allocation
uint32_t cqi_alloc2;
uint32_t cqi_alloc2;
/// saved subband PMI allocation from last PUSCH/PUCCH report
uint16_t pmi_alloc;
uint16_t pmi_alloc;
/// HARQ-ACKs
harq_status_NB_IoT_t harq_ack;
harq_status_NB_IoT_t harq_ack;
/// Pointers to up to 8 HARQ processes
NB_IoT_DL_UE_HARQ_t *harq_process;
NB_IoT_DL_UE_HARQ_t *harq_process;
/// Maximum number of HARQ processes(for definition see 36-212 V8.6 2009-03, p.17
uint8_t Mdlharq;
uint8_t Mdlharq;
/// MIMO transmission mode indicator for this sub-frame (for definition see 36-212 V8.6 2009-03, p.17)
uint8_t Kmimo;
uint8_t Kmimo;
/// Nsoft parameter related to UE Category
uint32_t Nsoft;
uint32_t Nsoft;
/// Maximum number of Turbo iterations
uint8_t max_turbo_iterations;
uint8_t max_turbo_iterations;
/// number of iterations used in last turbo decoding
uint8_t last_iteration_cnt;
uint8_t last_iteration_cnt;
/// accumulated tx power adjustment for PUCCH
int8_t g_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,
......@@ -463,18 +468,18 @@ typedef enum
typedef struct {
rnti_NB_IoT_t rnti;
rnti_NB_IoT_t rnti;
//array containing the pdus of DCI
uint8_t *a[2];
uint8_t *a[2];
//Array containing encoded DCI data
uint8_t *e[2];
uint8_t *e[2];
//UE specific parameters
uint16_t npdcch_NumRepetitions;
uint16_t npdcch_NumRepetitions;
uint16_t repetition_number;
uint16_t repetition_number;
//indicate the corresponding subframe within the repetition (set to 0 when a new NPDCCH pdu is received)
uint16_t repetition_idx;
uint16_t repetition_idx;
// uint16_t npdcch_Offset_USS;
// uint16_t npdcch_StartSF_USS;
......@@ -486,12 +491,11 @@ typedef struct {
typedef struct{
//Number of repetitions (R) for common search space (RAR and PAGING)
uint16_t number_repetition_RA;
uint16_t number_repetition_PAg;
uint16_t number_repetition_RA;
uint16_t number_repetition_PAg;
//index of the current subframe among the repetition (set to 0 when we receive the new NPDCCH)
uint16_t repetition_idx_RA;
uint16_t repetition_idx_Pag;
uint16_t repetition_idx_RA;
uint16_t repetition_idx_Pag;
}NB_IoT_eNB_COMMON_NPDCCH_t;
......@@ -499,30 +503,32 @@ uint16_t repetition_idx_Pag;
typedef struct {
/// Length of DCI in bits
uint8_t dci_length;
uint8_t dci_length;
/// Aggregation level only 1,2 in NB-IoT
uint8_t L;
uint8_t L;
/// Position of first CCE of the dci
int firstCCE;
int firstCCE;
/// flag to indicate that this is a RA response
boolean_NB_IoT_t ra_flag;
boolean_NB_IoT_t ra_flag;
/// rnti
rnti_NB_IoT_t rnti;
rnti_NB_IoT_t rnti;
/// Format
DCI_format_NB_IoT_t format;
DCI_format_NB_IoT_t format;
/// DCI pdu
uint8_t dci_pdu[8];
uint8_t dci_pdu[8];
} DCI_ALLOC_NB_IoT_t;
typedef struct {
//delete the count for the DCI numbers,NUM_DCI_MAX should set to 2
uint32_t num_npdcch_symbols;
uint32_t num_npdcch_symbols;
///indicates the starting OFDM symbol in the first slot of a subframe k for the NPDCCH transmission
/// see FAPI/NFAPI specs Table 4-45
uint8_t npdcch_start_symbol;
uint8_t Num_dci;
DCI_ALLOC_NB_IoT_t dci_alloc[2] ;
uint8_t npdcch_start_symbol;
uint8_t Num_dci;
DCI_ALLOC_NB_IoT_t dci_alloc[2] ;
} DCI_PDU_NB_IoT;
......@@ -530,255 +536,241 @@ typedef struct {
typedef struct {
/// TX buffers for UE-spec transmission (antenna ports 5 or 7..14, prior to precoding)
int32_t *txdataF[8];
int32_t *txdataF[8];
/// dl channel estimates (estimated from ul channel estimates)
int32_t **calib_dl_ch_estimates;
int32_t **calib_dl_ch_estimates;
/// Allocated RNTI (0 means DLSCH_t is not currently used)
uint16_t rnti;
uint16_t rnti;
/// Active flag for baseband transmitter processing
uint8_t active;
uint8_t active;
/// Indicator of TX activation per subframe. Used during PUCCH detection for ACK/NAK.
uint8_t subframe_tx[10];
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];
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;
NB_IoT_DL_eNB_HARQ_t *harq_process;
/// Number of soft channel bits
uint32_t G;
uint32_t G;
/// Maximum number of HARQ rounds
uint8_t Mlimit;
uint8_t Mlimit;
/// Nsoft parameter related to UE Category
uint32_t Nsoft;
uint32_t Nsoft;
/// amplitude of PDSCH (compared to RS) in symbols without pilots
int16_t sqrt_rho_a;
int16_t sqrt_rho_a;
/// amplitude of PDSCH (compared to RS) in symbols containing pilots
int16_t sqrt_rho_b;
int16_t sqrt_rho_b;
///NB-IoT
/// may use in the npdsch_procedures
uint16_t scrambling_sequence_intialization;
uint16_t scrambling_sequence_intialization;
/// number of cell specific TX antenna ports assumed by the UE
uint8_t nrs_antenna_ports;
uint8_t nrs_antenna_ports;
//This indicate the current subframe within the subframe interval between the NPDSCH transmission (Nsf*Nrep)
uint16_t sf_index;
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;
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;
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;
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;
ndlsch_flag_t ndlsch_type;
} NB_IoT_eNB_NDLSCH_t;
typedef struct {
/// Length of CQI data under RI=1 assumption(bits)
uint8_t Or1;
uint8_t Or1;
/// Rank information
uint8_t o_RI[2];
uint8_t o_RI[2];
/// Format of CQI data
UCI_format_NB_IoT_t uci_format;
UCI_format_NB_IoT_t uci_format;
/// The value of DAI in DCI format 0
uint8_t V_UL_DAI;
uint8_t V_UL_DAI;
/// Pointer to CQI data
uint8_t o[MAX_CQI_BYTES_NB_IoT];
uint8_t o[MAX_CQI_BYTES_NB_IoT];
/// CQI CRC status
uint8_t cqi_crc_status;
uint8_t cqi_crc_status;
/// PHICH active flag
uint8_t phich_active;
uint8_t phich_active;
/// PHICH ACK
uint8_t phich_ACK;
uint8_t phich_ACK;
/// Length of rank information (bits)
uint8_t O_RI;
uint8_t O_RI;
/// First Allocated RB
uint16_t first_rb;
uint16_t first_rb;
/// Current Number of RBs
uint16_t nb_rb;
uint16_t nb_rb;
/// Determined the subcarrier allocation for the NPUSCH.(15, 3.75 KHz)
uint8_t subcarrier_indication;
uint8_t subcarrier_indication;
/// Determined the number of resource unit for the NPUSCH
uint8_t resource_assignment;
uint8_t resource_assignment;
/// Determined the scheduling delay for NPUSCH
uint8_t scheduling_delay;
uint8_t scheduling_delay;
/// The number of the repetition number for NPUSCH Transport block
uint8_t repetition_number;
uint8_t repetition_number;
/// Determined the repetition number value 0-3
uint8_t dci_subframe_repetitions;
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;
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)
uint8_t rar_alloc;
uint8_t rar_alloc;
/// Status Flag indicating for this ULSCH (idle,active,disabled)
SCH_status_NB_IoT_t status;
SCH_status_NB_IoT_t status;
/// Subframe scheduling indicator (i.e. Transmission opportunity indicator)
uint8_t subframe_scheduling_flag;
uint8_t subframe_scheduling_flag;
/// Transport block size
uint32_t TBS;
uint32_t TBS;
/// The payload + CRC size in bits
uint32_t B;
uint32_t B;
/// Number of soft channel bits
uint32_t G;
uint32_t G;
/// Pointer to ACK
uint8_t o_ACK[4];
uint8_t o_ACK[4];
/// Length of ACK information (bits)
uint8_t O_ACK;
/// 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)
uint8_t O_ACK;
/// 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)
/// 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)));
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)
int8_t q[MAX_CQI_PAYLOAD_NB_IoT];
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)
int8_t q[MAX_CQI_PAYLOAD_NB_IoT];
/// number of coded CQI bits after interleaving
uint8_t o_RCC;
uint8_t o_RCC;
/// coded and interleaved CQI bits
int8_t o_w[(MAX_CQI_BITS_NB_IoT+8)*3];
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;
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;
uint32_t Cminus;
/// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Cplus;
uint32_t Cplus;
/// Number of bits in "small" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Kminus;
uint32_t Kminus;
/// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Kplus;
uint32_t Kplus;
/// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t F;
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;
uint8_t *b;
/// Current Number of Symbols
uint8_t Nsymb_pusch;
uint8_t Nsymb_pusch;
/// Index of current HARQ round for this ULSCH
uint8_t round;
uint8_t round;
/// MCS format for this ULSCH
uint8_t mcs;
uint8_t mcs;
/// Redundancy-version of the current sub-frame (value 0->RV0,value 1 ->RV2)
uint8_t rvidx;
uint8_t rvidx;
/// Msc_initial, Initial number of subcarriers for ULSCH (36-212, v8.6 2009-03, p.26-27)
uint16_t Msc_initial;
uint16_t Msc_initial;
/// Nsymb_initial, Initial number of symbols for ULSCH (36-212, v8.6 2009-03, p.26-27)
uint8_t Nsymb_initial;
uint8_t Nsymb_initial;
/// n_DMRS for cyclic shift of DMRS (36.213 Table 9.1.2-2)
uint8_t n_DMRS;
uint8_t n_DMRS;
/// n_DMRS for cyclic shift of DMRS (36.213 Table 9.1.2-2) - previous scheduling
/// This is needed for PHICH generation which
/// is done after a new scheduling
uint8_t previous_n_DMRS;
uint8_t previous_n_DMRS;
/// n_DMRS 2 for cyclic shift of DMRS (36.211 Table 5.5.1.1.-1)
uint8_t n_DMRS2;
uint8_t n_DMRS2;
/// Flag to indicate that this ULSCH is for calibration information sent from UE (i.e. no MAC SDU to pass up)
// int calibration_flag;
/// delta_TF for power control
int32_t delta_TF;
int32_t delta_TF;
} NB_IoT_UL_eNB_HARQ_t;
typedef struct {
/// Pointers to 8 HARQ processes for the ULSCH
NB_IoT_UL_eNB_HARQ_t *harq_process;
NB_IoT_UL_eNB_HARQ_t *harq_process;
/// Maximum number of HARQ rounds
uint8_t Mlimit;
uint8_t Mlimit;
/// Value 0 = npush format 1 (data) value 1 = npusch format 2 (ACK/NAK)
uint8_t npusch_format;
uint8_t npusch_format;
/// Flag to indicate that eNB awaits UE Msg3
uint8_t Msg3_active;
uint8_t Msg3_active;
/// Flag to indicate that eNB should decode UE Msg3
uint8_t Msg3_flag;
uint8_t Msg3_flag;
/// Subframe for Msg3
uint8_t Msg3_subframe;
uint8_t Msg3_subframe;
/// Frame for Msg3
uint32_t Msg3_frame;
uint32_t Msg3_frame;
/// RNTI attributed to this ULSCH
uint16_t rnti;
uint16_t rnti;
/// cyclic shift for DM RS
uint8_t cyclicShift;
uint8_t cyclicShift;
/// cooperation flag
uint8_t cooperation_flag;
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;
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;
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;
uint8_t HARQ_ACK_resource;
} NB_IoT_eNB_NULSCH_t;
typedef struct {
/// Pointers to 8 HARQ processes for the ULSCH
NB_IoT_UL_eNB_HARQ_t *harq_process;
NB_IoT_UL_eNB_HARQ_t *harq_process;
/// Maximum number of HARQ rounds
uint8_t Mlimit;
uint8_t Mlimit;
/// Maximum number of iterations used in eNB turbo decoder
uint8_t max_turbo_iterations;
uint8_t max_turbo_iterations;
/// ACK/NAK Bundling flag
uint8_t bundling;
uint8_t bundling;
/// beta_offset_cqi times 8
uint16_t beta_offset_cqi_times8;
uint16_t beta_offset_cqi_times8;
/// beta_offset_ri times 8
uint16_t beta_offset_ri_times8;
uint16_t beta_offset_ri_times8;
/// beta_offset_harqack times 8
uint16_t beta_offset_harqack_times8;
uint16_t beta_offset_harqack_times8;
/// Flag to indicate that eNB awaits UE Msg3
uint8_t Msg3_active;
uint8_t Msg3_active;
/// Flag to indicate that eNB should decode UE Msg3
uint8_t Msg3_flag;
uint8_t Msg3_flag;
/// Subframe for Msg3
uint8_t Msg3_subframe;
uint8_t Msg3_subframe;
/// Frame for Msg3
uint32_t Msg3_frame;
uint32_t Msg3_frame;
/// RNTI attributed to this ULSCH
uint16_t rnti;
uint16_t rnti;
/// cyclic shift for DM RS
uint8_t cyclicShift;
uint8_t cyclicShift;
/// cooperation flag
uint8_t cooperation_flag;
uint8_t cooperation_flag;
/// num active cba group
uint8_t num_active_cba_groups;
uint8_t num_active_cba_groups;
/// allocated CBA RNTI for this ulsch
uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP];
uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP];
#ifdef LOCALIZATION
/// epoch timestamp in millisecond
int32_t reference_timestamp_ms;
int32_t reference_timestamp_ms;
/// aggregate physical states every n millisecond
int32_t aggregation_period_ms;
int32_t aggregation_period_ms;
/// a set of lists used for localization
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;
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;
......@@ -786,15 +778,15 @@ typedef struct {
typedef struct {
//the 2 LSB of the hsfn (the MSB are indicated by the SIB1-NB)
uint16_t h_sfn_lsb;
uint16_t h_sfn_lsb;
uint8_t npbch_d[96+(3*(16+NPBCH_A))];
uint8_t npbch_w[3*3*(16+NPBCH_A)];
uint8_t npbch_e[1600];
uint8_t npbch_d[96+(3*(16+NPBCH_A))];
uint8_t npbch_w[3*3*(16+NPBCH_A)];
uint8_t npbch_e[1600];
///pdu of the npbch message
uint8_t *pdu;
} NB_IoT_eNB_NPBCH_t;
uint8_t *pdu;
} 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,12 +34,12 @@ 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;
first_bit = 2;
c = ((uint8_t*)&crc)[0];
state = 0;
first_bit = 2;
c = ((uint8_t*)&crc)[0];
// Perform Tail-biting
// get bits from last byte of input (or crc)
for (shiftbit = 0 ; shiftbit <(8-first_bit) ; shiftbit++) {
......@@ -74,19 +73,21 @@ 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
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
crc = crc24a_NB_IoT(a,A)>>8; // CRC calculation (24 bits CRC)
// CRC attachment to payload
a[A>>3] = ((uint8_t*)&crc)[2];
a[A>>3] = ((uint8_t*)&crc)[2];
a[1+(A>>3)] = ((uint8_t*)&crc)[1];
a[2+(A>>3)] = ((uint8_t*)&crc)[0];
......
......@@ -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;
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;
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,24 +123,25 @@ 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 re_allocated,symbol_offset;
uint16_t l;
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;
uint32_t jj = 0;
uint32_t re_allocated,symbol_offset;
uint16_t l;
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
bandwidth_even_odd = frame_parms->N_RB_DL % 2; // 0 even, 1 odd
RB_IoT_ID = NB_IoT_RB_ID;
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))
{
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,
......@@ -31,11 +33,11 @@ void dlsch_scrambling_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
uint8_t Nf, // Nf is the frame number (0..9)
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;
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;
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
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
s = lte_gold_generic_NB_IoT(&x1, &x2, 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;
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
......@@ -125,19 +128,20 @@ int generate_npbch(NB_IoT_eNB_NPBCH_t *eNB_npbch,
uint8_t frame_mod64,
unsigned short NB_IoT_RB_ID)
{
int i, l;
int id_offset;
uint32_t npbch_D,npbch_E;
uint8_t npbch_a[5]; // 34/8 =4.25 => 4 bytes and 2 bits
uint8_t RCC;
unsigned short bandwidth_even_odd;
unsigned short NB_IoT_start, RB_IoT_ID;
uint32_t pilots;
uint32_t jj=0;
uint32_t re_allocated=0;
uint32_t symbol_offset;
uint16_t amask=0;
npbch_D = 16+NPBCH_A;
int i, l;
int id_offset;
uint32_t npbch_D,npbch_E;
uint8_t npbch_a[5]; // 34/8 =4.25 => 4 bytes and 2 bits
uint8_t RCC;
unsigned short bandwidth_even_odd;
unsigned short NB_IoT_start, RB_IoT_ID;
uint32_t pilots;
uint32_t jj=0;
uint32_t re_allocated=0;
uint32_t symbol_offset;
uint16_t amask=0;
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 {
......@@ -220,14 +224,17 @@ void npbch_scrambling(NB_IoT_DL_FRAME_PARMS *frame_parms,
uint8_t *npbch_e,
uint32_t length) // 1600
{
int i;
uint8_t reset;
uint32_t x1, x2, s=0;
int i;
uint8_t reset;
uint32_t x1, x2, s=0;
reset = 1;
x2 = frame_parms->Nid_cell;
x2 = frame_parms->Nid_cell;
for (i=0; i<length; i++) {
if ((i&0x1f)==0) {
s = lte_gold_generic_NB_IoT(&x1, &x2, reset);
s = lte_gold_generic_NB_IoT(&x1, &x2, reset);
reset = 0;
}
npbch_e[i] = (npbch_e[i]&1) ^ ((s>>(i&0x1f))&1);
......
......@@ -21,20 +21,20 @@
//or #include "PHY/defs_nb_iot.h"
#include "PHY/LTE_REFSIG/primary_synch_NB_IoT.h"
int generate_npss_NB_IoT(int32_t **txdataF,
short amp,
NB_IoT_DL_FRAME_PARMS *frame_parms,
unsigned short symbol_offset, // symbol_offset should equal to 3 for NB-IoT
unsigned short slot_offset,
unsigned short RB_IoT_ID) // new attribute (values are between 0.. Max_RB_number-1), it does not exist for LTE
int generate_npss_NB_IoT(int32_t **txdataF,
short amp,
NB_IoT_DL_FRAME_PARMS *frame_parms,
unsigned short symbol_offset, // symbol_offset should equal to 3 for NB-IoT
unsigned short slot_offset,
unsigned short RB_IoT_ID) // new attribute (values are between 0.. Max_RB_number-1), it does not exist for LTE
{
unsigned short c,aa,a,s;
unsigned short slot_id;
short *primary_sync;
unsigned short NB_IoT_start; // Index of the first RE in the RB dedicated for NB-IoT
unsigned short bandwidth_even_odd;
unsigned short c,aa,a,s;
unsigned short slot_id;
short *primary_sync;
unsigned short NB_IoT_start; // Index of the first RE in the RB dedicated for NB-IoT
unsigned short bandwidth_even_odd;
slot_id = slot_offset; // The id(0..19) of the slot including the NPSS signal // For NB-IoT, slod_id should be 10 (SF5)
slot_id = slot_offset; // The id(0..19) of the slot including the NPSS signal // For NB-IoT, slod_id should be 10 (SF5)
primary_sync = primary_synch_NB_IoT; // primary_synch_NB_IoT[264] of primary_synch_NB_IoT.h
// Signal amplitude
......
......@@ -12,30 +12,32 @@
* \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,
int16_t amp,
NB_IoT_DL_FRAME_PARMS *frame_parms,
uint16_t symbol_offset, // symbol_offset = 3 for NB-IoT
uint16_t slot_offset,
unsigned short frame_number, // new attribute (Get value from higher layer), it does not exist for LTE
unsigned short RB_IoT_ID) // new attribute (values are between 0.. Max_RB_number-1), it does not exist for LTE
int generate_sss_NB_IoT(int32_t **txdataF,
int16_t amp,
NB_IoT_DL_FRAME_PARMS *frame_parms,
uint16_t symbol_offset, // symbol_offset = 3 for NB-IoT
uint16_t slot_offset,
unsigned short frame_number, // new attribute (Get value from higher layer), it does not exist for LTE
unsigned short RB_IoT_ID) // new attribute (values are between 0.. Max_RB_number-1), it does not exist for LTE
{
uint8_t aa,Nid_NB_IoT,Nid2,f,q,s,c,u;
int16_t *d;
uint16_t n_f;
unsigned short a;
uint16_t slot_id; // slot_id = 17 in NB_IoT
unsigned short bandwidth_even_odd;
unsigned short NB_IoT_start;
uint8_t aa,Nid_NB_IoT,Nid2,f,q,s,c,u;
int16_t *d;
uint16_t n_f;
unsigned short a;
uint16_t slot_id; // slot_id = 17 in NB_IoT
unsigned short bandwidth_even_odd;
unsigned short NB_IoT_start;
n_f = frame_number;
n_f = frame_number;
Nid_NB_IoT = frame_parms->Nid_cell; // supposing Cell_Id of LTE = Cell_Id of NB-IoT // if different , NB_IOT_DL_FRAME_PARMS should be includes as attribute
f = (n_f/2) % 4; // f = 0, 1, 2, 3
......
......@@ -16,98 +16,99 @@
#include "PHY/defs_NB_IoT.h"
#include "PHY/LTE_REFSIG/defs_NB_IoT.h"
void generate_pilots_NB_IoT(PHY_VARS_eNB_NB_IoT *phy_vars_eNB,
int32_t **txdataF,
int16_t amp,
uint16_t Ntti, // Ntti = 10
unsigned short RB_IoT_ID, // RB reserved for NB-IoT
unsigned short With_NSSS) // With_NSSS = 1; if the frame include a sub-Frame with NSSS signal
void generate_pilots_NB_IoT(PHY_VARS_eNB_NB_IoT *phy_vars_eNB,
int32_t **txdataF,
int16_t amp,
uint16_t Ntti, // Ntti = 10
unsigned short RB_IoT_ID, // RB reserved for NB-IoT
unsigned short With_NSSS) // With_NSSS = 1; if the frame include a sub-Frame with NSSS signal
{
NB_IoT_DL_FRAME_PARMS *frame_parms = &phy_vars_eNB->frame_parms_NB_IoT;
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
uint8_t first_pilot,second_pilot;
Nsymb = 14;
first_pilot = 5; // first pilot position
second_pilot = 6; // second pilot position
for (tti=0; tti<Ntti; tti++) { // loop on sub-frames
tti_offset = tti*frame_parms->ofdm_symbol_size*Nsymb; // begins with 0
tti_offset = tti*frame_parms->ofdm_symbol_size*Nsymb; // begins with 0
samples_per_symbol = frame_parms->ofdm_symbol_size; // ex. 512
slot_offset = (tti*2)%20; // 0, 2, 4, ....... 18
slot_offset = (tti*2)%20; // 0, 2, 4, ....... 18
if((slot_offset != 10) && ((With_NSSS*slot_offset) != 18)) { // condition to avoid NPSS and NSSS signals
//Generate Pilots for slot 0 and 1
//antenna 0 symbol 5 slot 0
//antenna 0 symbol 5 slot 0
lte_dl_cell_spec_NB_IoT(phy_vars_eNB,
&txdataF[0][tti_offset + (first_pilot*samples_per_symbol)], // tti_offset 512 x 32 bits
amp,
RB_IoT_ID,
slot_offset,
0, //p
0);
&txdataF[0][tti_offset + (first_pilot*samples_per_symbol)], // tti_offset 512 x 32 bits
amp,
RB_IoT_ID,
slot_offset,
0, //p
0);
//antenna 0 symbol 6 slot 0
//antenna 0 symbol 6 slot 0
lte_dl_cell_spec_NB_IoT(phy_vars_eNB,&txdataF[0][tti_offset + (second_pilot*samples_per_symbol)],
amp,
RB_IoT_ID,
slot_offset,
1,
0);
amp,
RB_IoT_ID,
slot_offset,
1,
0);
//antenna 0 symbol 5 slot 1
//antenna 0 symbol 5 slot 1
lte_dl_cell_spec_NB_IoT(phy_vars_eNB,&txdataF[0][tti_offset + (7*samples_per_symbol) + (first_pilot*samples_per_symbol)],
amp,
RB_IoT_ID,
1+slot_offset,
0,
0);
amp,
RB_IoT_ID,
1+slot_offset,
0,
0);
//antenna 0 symbol 6 slot 1
//antenna 0 symbol 6 slot 1
lte_dl_cell_spec_NB_IoT(phy_vars_eNB,&txdataF[0][tti_offset + (7*samples_per_symbol) + (second_pilot*samples_per_symbol)],
amp,
RB_IoT_ID,
1+slot_offset,
1,
0);
amp,
RB_IoT_ID,
1+slot_offset,
1,
0);
if (frame_parms->nb_antennas_tx > 1) { // Pilots generation with two antennas
// antenna 1 symbol 5 slot 0
// antenna 1 symbol 5 slot 0
lte_dl_cell_spec_NB_IoT(phy_vars_eNB,&txdataF[1][tti_offset + (first_pilot*samples_per_symbol)],
amp,
RB_IoT_ID,
slot_offset,
0,
1);
amp,
RB_IoT_ID,
slot_offset,
0,
1);
// antenna 1 symbol 6 slot 0
// antenna 1 symbol 6 slot 0
lte_dl_cell_spec_NB_IoT(phy_vars_eNB,&txdataF[1][tti_offset + (second_pilot*samples_per_symbol)],
amp,
RB_IoT_ID,
slot_offset,
1,
1);
amp,
RB_IoT_ID,
slot_offset,
1,
1);
//antenna 1 symbol 5 slot 1
//antenna 1 symbol 5 slot 1
lte_dl_cell_spec_NB_IoT(phy_vars_eNB,&txdataF[1][tti_offset + (7*samples_per_symbol) + (first_pilot*samples_per_symbol)],
amp,
RB_IoT_ID,
1+slot_offset,
0,
1);
amp,
RB_IoT_ID,
1+slot_offset,
0,
1);
// antenna 1 symbol 6 slot 1
// antenna 1 symbol 6 slot 1
lte_dl_cell_spec_NB_IoT(phy_vars_eNB,&txdataF[1][tti_offset + (7*samples_per_symbol) + (second_pilot*samples_per_symbol)],
amp,
RB_IoT_ID,
1+slot_offset,
1,
1);
amp,
RB_IoT_ID,
1+slot_offset,
1,
1);
}
}
}
......
......@@ -32,104 +32,110 @@
#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
int generate_npss_NB_IoT(int32_t **txdataF,
short amp,
NB_IoT_DL_FRAME_PARMS *frame_parms,
unsigned short symbol_offset, // symbol_offset should equal to 3 for NB-IoT
unsigned short slot_offset,
unsigned short RB_IoT_ID); // new attribute (values are between 0.. Max_RB_number-1), it does not exist for LTE
int generate_npss_NB_IoT(int32_t **txdataF,
short amp,
NB_IoT_DL_FRAME_PARMS *frame_parms,
unsigned short symbol_offset, // symbol_offset should equal to 3 for NB-IoT
unsigned short slot_offset,
unsigned short RB_IoT_ID); // new attribute (values are between 0.. Max_RB_number-1), it does not exist for LTE
//NSSS
int generate_sss_NB_IoT(int32_t **txdataF,
int16_t amp,
NB_IoT_DL_FRAME_PARMS *frame_parms,
uint16_t symbol_offset, // symbol_offset = 3 for NB-IoT
uint16_t slot_offset,
unsigned short frame_number, // new attribute (Get value from higher layer), it does not exist for LTE
unsigned short RB_IoT_ID); // new attribute (values are between 0.. Max_RB_number-1), it does not exist for LTE
int generate_sss_NB_IoT(int32_t **txdataF,
int16_t amp,
NB_IoT_DL_FRAME_PARMS *frame_parms,
uint16_t symbol_offset, // symbol_offset = 3 for NB-IoT
uint16_t slot_offset,
unsigned short frame_number, // new attribute (Get value from higher layer), it does not exist for LTE
unsigned short RB_IoT_ID); // new attribute (values are between 0.. Max_RB_number-1), it does not exist for LTE
//NRS
void generate_pilots_NB_IoT(PHY_VARS_eNB_NB_IoT *phy_vars_eNB,
int32_t **txdataF,
int16_t amp,
uint16_t Ntti, // Ntti = 10
unsigned short RB_IoT_ID, // RB reserved for NB-IoT
unsigned short With_NSSS); // With_NSSS = 1; if the frame include a sub-Frame with NSSS signal
void generate_pilots_NB_IoT(PHY_VARS_eNB_NB_IoT *phy_vars_eNB,
int32_t **txdataF,
int16_t amp,
uint16_t Ntti, // Ntti = 10
unsigned short RB_IoT_ID, // RB reserved for NB-IoT
unsigned short With_NSSS); // With_NSSS = 1; if the frame include a sub-Frame with NSSS signal
//NPBCH
int allocate_npbch_REs_in_RB(NB_IoT_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,
uint32_t *re_allocated);
int generate_npbch(NB_IoT_eNB_NPBCH_t *eNB_npbch,
int32_t **txdataF,
int amp,
NB_IoT_DL_FRAME_PARMS *frame_parms,
uint8_t *npbch_pdu,
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);
int allocate_npbch_REs_in_RB(NB_IoT_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,
uint32_t *re_allocated);
int generate_npbch(NB_IoT_eNB_NPBCH_t *eNB_npbch,
int32_t **txdataF,
int amp,
NB_IoT_DL_FRAME_PARMS *frame_parms,
uint8_t *npbch_pdu,
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);
// Functions below implement 36-211 and 36-212
/*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,
unsigned char dci_size_bytes,
unsigned char aggregation,
unsigned char dci_size_bits,
unsigned char dci_fmt,
uint8_t npdcch_start_symbol);
void add_dci_NB_IoT(DCI_PDU_NB_IoT *DCI_pdu,
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,
DCI_CONTENT *DCI_Content,
uint16_t rnti,
DCI_format_NB_IoT_t dci_format,
uint8_t UE_id,
uint8_t aggregation,
uint8_t npdcch_start_symbol);
int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
eNB_rxtx_proc_NB_IoT_t *proc,
DCI_CONTENT *DCI_Content,
uint16_t rnti,
DCI_format_NB_IoT_t dci_format,
uint8_t UE_id,
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,
uint8_t subframe,
DCI_CONTENT *DCI_Content,
uint16_t rnti,
DCI_format_NB_IoT_t dci_format,
NB_IoT_eNB_NDLSCH_t *ndlsch,
NB_IoT_DL_FRAME_PARMS *frame_parms,
uint8_t aggregation,
uint8_t npdcch_start_symbol);
int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
int frame,
uint8_t subframe,
DCI_CONTENT *DCI_Content,
uint16_t rnti,
DCI_format_NB_IoT_t dci_format,
NB_IoT_eNB_NDLSCH_t *ndlsch,
NB_IoT_DL_FRAME_PARMS *frame_parms,
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 Num_dci,
DCI_ALLOC_NB_IoT_t *dci_alloc,
int16_t amp,
NB_IoT_DL_FRAME_PARMS *fp,
int32_t **txdataF,
uint32_t subframe,
uint8_t npdcch_start_symbol);
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,
NB_IoT_DL_FRAME_PARMS *fp,
int32_t **txdataF,
uint32_t subframe,
uint8_t npdcch_start_symbol);
/*!
\brief Decoding of PUSCH/ACK/RI/ACK from 36-212.
......@@ -142,20 +148,21 @@ uint8_t generate_dci_top_NB_IoT(NB_IoT_eNB_NPDCCH_t* npdcch,
@param llr8_flag If 1, indicate that the 8-bit turbo decoder should be used
@returns 0 on success
*/
unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB_NB_IoT *phy_vars_eNB,
eNB_rxtx_proc_NB_IoT_t *proc,
uint8_t UE_id,
uint8_t control_only_flag,
uint8_t Nbundled,
uint8_t llr8_flag);
unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB_NB_IoT *phy_vars_eNB,
eNB_rxtx_proc_NB_IoT_t *proc,
uint8_t UE_id,
uint8_t control_only_flag,
uint8_t Nbundled,
uint8_t llr8_flag);
//NB-IoT version
NB_IoT_eNB_NDLSCH_t *new_eNB_dlsch_NB_IoT(//unsigned char Kmimo,
//unsigned char Mdlharq,
uint32_t Nsoft,
//unsigned char N_RB_DL,
uint8_t abstraction_flag,
NB_IoT_DL_FRAME_PARMS* frame_parms);
//unsigned char Mdlharq,
uint32_t Nsoft,
//unsigned char N_RB_DL,
uint8_t abstraction_flag,
NB_IoT_DL_FRAME_PARMS* frame_parms);
NB_IoT_eNB_NULSCH_t *new_eNB_ulsch_NB(uint8_t abstraction_flag);
......
......@@ -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"
......@@ -335,4 +337,5 @@ HLC_subband_cqi_mcs_CBA_20MHz;
#define MAX_CQI_BYTES (sizeof(HLC_subband_cqi_rank2_2A_20MHz))
#define MAX_ACK_PAYLOAD 18
#define MAX_RI_PAYLOAD 6
*/
\ No newline at end of file
*/
#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