Commit 302159fc authored by Ting-An Lin's avatar Ting-An Lin

nprach funcitons added

parent f83cca43
......@@ -1063,10 +1063,11 @@ add_dependencies(SCHED_LIB rrc_flag)
# Physical Channel Procedures Scheduling for NB-IoT
################################"
set(SCHED_SRC_NB_IoT
#${OPENAIR1_DIR}/SCHED_NBIOT/fapi_l1.c
# ${OPENAIR1_DIR}/SCHED_NBIOT/fapi_l1.c
${OPENAIR1_DIR}/SCHED_NBIOT/phy_procedures_lte_eNb_NB_IoT.c
${OPENAIR1_DIR}/SCHED_NBIOT/IF_Module_L1_primitives_NB_IoT.c
#${OPENAIR1_DIR}/SCHED/phy_procedures_lte_common.c
${OPENAIR1_DIR}/SCHED_NBIOT/phy_procedures_lte_common_NB_IoT.c
# ${OPENAIR1_DIR}/SCHED/phy_procedures_lte_common.c
)
add_library(SCHED_NB_IoT_LIB ${SCHED_SRC_NB_IoT})
add_dependencies(SCHED_NB_IoT_LIB rrc_flag)
......@@ -1157,17 +1158,6 @@ set(PHY_TURBOIF
add_library(coding MODULE ${PHY_TURBOSRC} )
set(PHY_SRC_COMMON
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/SIB_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/dci_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/dlsch_coding_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/dlsch_modulation_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/dlsch_scrambling_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/lte_mcs_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/ulsch_demodulation_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/lte_Isc_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/nprach_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_ESTIMATION/lte_ul_channel_estimation_NB_IoT.c
${OPENAIR1_DIR}/PHY/CODING/lte_segmentation_NB_IoT.c
${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dci_tools_common.c
${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/lte_mcs.c
# ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/slss.c
......@@ -1187,16 +1177,24 @@ set(PHY_SRC_COMMON
${OPENAIR1_DIR}/PHY/MODULATION/ofdm_mod.c
${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_sync_time.c
${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_dl_cell_spec.c
${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_dl_cell_spec_NB_IoT.c
${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_dl_uespec.c
${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_gold.c
${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_gold_mbsfn.c
${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_dl_mbsfn.c
${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_ul_ref.c
${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_ul_ref_NB_IoT.c
${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_gold_NB_IoT.c
${OPENAIR1_DIR}/PHY/CODING/lte_segmentation.c
${OPENAIR1_DIR}/PHY/CODING/ccoding_byte.c
${OPENAIR1_DIR}/PHY/CODING/ccoding_byte_lte.c
${OPENAIR1_DIR}/PHY/CODING/3gpplte_sse.c
${OPENAIR1_DIR}/PHY/CODING/ccoding_byte_NB_IoT.c
${OPENAIR1_DIR}/PHY/CODING/lte_rate_matching_NB_IoT.c
${OPENAIR1_DIR}/PHY/CODING/crc_byte.c
${OPENAIR1_DIR}/PHY/CODING/crc_byte_NB_IoT.c
${OPENAIR1_DIR}/PHY/CODING/3gpplte_sse.c
${OPENAIR1_DIR}/PHY/CODING/3gpplte_turbo_decoder_sse_16bit.c
${OPENAIR1_DIR}/PHY/CODING/3gpplte.c
${PHY_TURBOIF}
${OPENAIR1_DIR}/PHY/CODING/lte_rate_matching.c
${OPENAIR1_DIR}/PHY/CODING/viterbi.c
......@@ -1218,6 +1216,22 @@ set(PHY_SRC_COMMON
)
set(PHY_SRC
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/SIB_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/dci_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/dlsch_coding_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/dlsch_modulation_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/dlsch_scrambling_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/lte_mcs_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/ulsch_demodulation_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/lte_Isc_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/nprach_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/nsss_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/npbch_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/pilots_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/npss_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/dci_tools_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_ESTIMATION/lte_ul_channel_estimation_NB_IoT.c
${OPENAIR1_DIR}/PHY/CODING/lte_segmentation_NB_IoT.c
${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pss.c
${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/sss.c
${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/sss_gen.c
......@@ -2125,7 +2139,7 @@ add_dependencies(lte-softmodem rrc_flag s1ap_flag x2_flag)
target_link_libraries (lte-softmodem
-Wl,--start-group
RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP X2AP_LIB X2AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB PHY_COMMON PHY PHY_RU LFDS L2
RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP X2AP_LIB X2AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_NB_IoT_LIB SCHED_LIB SCHED_RU_LIB PHY PHY_COMMON PHY_RU LFDS L2
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB} LFDS7
NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
-Wl,--end-group z dl)
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file PHY/LTE_CODING/ccoding_byte_NB_IoT.c
* \Fucntions for CRC attachment and tail-biting convolutional coding for NPBCH channel, TS 36-212, V13.4.0 2017-02
* \author M. KANJ
* \date 2017
* \version 0.0
* \company bcom
* \email: matthieu.kanj@b-com.com
* \note
* \warning
*/
#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
/*************************************************************************
Encodes for an arbitrary convolutional code of rate 1/3
with a constraint length of 7 bits.
The inputs are bit packed in octets (from MSB to LSB).
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)
{
uint32_t state;
uint8_t c, out, first_bit;
int8_t shiftbit=0;
uint16_t c16;
uint16_t next_last_byte=0;
uint32_t crc=0;
/* The input bit is shifted in position 8 of the state.
Shiftbit will take values between 1 and 8 */
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];
}
// 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);
}
state = state & 0x3f; // true initial state of Tail-biting CCode
state<<=1; // because of loop structure in CCode
while (numbits > 0) { // Tail-biting is applied to input bits , input 34 bits , output 102 bits
c = *inPtr++;
for (shiftbit = 7; (shiftbit>=0) && (numbits>0); shiftbit--,numbits--) {
state >>= 1;
if ((c&(1<<shiftbit)) != 0) {
state |= 64;
}
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
if (add_crc == 2) {
c16 = (uint16_t)(crc>>16);
for (shiftbit = 15; (shiftbit>=0); shiftbit--) {
state >>= 1;
if ((c16&(1<<shiftbit)) != 0) {
state |= 64;
}
out = ccodelte_table_NB_IoT[state];
*outPtr++ = out & 1;
*outPtr++ = (out>>1)&1;
*outPtr++ = (out>>2)&1;
}
}
}
/*************************************************************************
Functions to initialize the code tables
*************************************************************************/
/* Basic code table initialization for constraint length 7 */
/* Input in MSB, followed by state in 6 LSBs */
void ccodelte_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 */
for (j = 0; j < 3; j++) {
sum = 0;
for (k = 0; k < 7; k++)
if ((i & glte_NB_IoT[j]) & (1 << k))
sum++;
/* Write the sum modulo 2 in bit j */
ccodelte_table_NB_IoT[i] |= (sum & 1) << j;
}
}
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/* file: crc_byte.c
purpose: generate 3GPP LTE CRCs. Byte-oriented implementation of CRC's
author: raymond.knopp@eurecom.fr, matthieu.kanj@b-com.com
date: 07/2017
*/
#ifndef USER_MODE
#define __NO_VERSION__
#endif
//#include "PHY/types.h"
//#include "defs.h" // to delete in final code version
#include "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
/*********************************************************
For initialization && verification purposes,
bit by bit implementation with any polynomial
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 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;
}
}
return crc;
}
/*********************************************************
crc table initialization
*********************************************************/
static unsigned int crc24aTable_NB_IoT[256];
static unsigned int crc24bTable_NB_IoT[256];
static unsigned short crc16Table_NB_IoT[256];
static unsigned short crc12Table_NB_IoT[256];
static unsigned char crc8Table_NB_IoT[256];
void crcTableInit_NB_IoT (void)
{
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);
} while (++c);
}
/*********************************************************
Byte by byte implementations,
assuming initial byte is 0 padded (in MSB) if necessary
*********************************************************/
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) {
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;
}
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)
{
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;
}
unsigned int crc8_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 = crc8Table_NB_IoT[(*inptr++) ^ (crc >> 24)] << 24;
}
if (resbit > 0)
crc = (crc << resbit) ^ (crc8Table_NB_IoT[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))] << 24);
return crc;
}
//#ifdef DEBUG_CRC
/*******************************************************************/
/**
Test code
********************************************************************/
// #include <stdio.h>
// main()
// {
// unsigned char test[] = "Thebigredfox";
// crcTableInit();
// printf("%x\n", crcbit(test, sizeof(test) - 1, poly24));
// printf("%x\n", crc24(test, (sizeof(test) - 1)*8));
// printf("%x\n", crcbit(test, sizeof(test) - 1, poly8));
// printf("%x\n", crc8(test, (sizeof(test) - 1)*8));
// }
//#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/* file: PHY/CODING/defs.h
purpose: Top-level definitions, data types and function prototypes for openairinterface coding blocks
author: raymond.knopp@eurecom.fr
date: 21.10.2009
*/
#ifndef __CODING_DEFS__H__
#define __CODING_DEFS__H__
#include <stdint.h>
#ifndef NO_OPENAIR1
#include "PHY/defs.h"
#else
#include "PHY/TOOLS/time_meas.h"
#endif
#define CRC24_A 0
#define CRC24_B 1
#define CRC16 2
#define CRC8 3
#define MAX_TURBO_ITERATIONS_MBSFN 8
#define MAX_TURBO_ITERATIONS 4
#define LTE_NULL 2
/** @addtogroup _PHY_CODING_BLOCKS_
* @{
*/
/** \fn lte_segmentation(uint8_t *input_buffer,
uint8_t **output_buffers,
uint32_t B,
uint32_t *C,
uint32_t *Cplus,
uint32_t *Cminus,
uint32_t *Kplus,
uint32_t *Kminus,
uint32_t *F)
\brief This function implements the LTE transport block segmentation algorithm from 36-212, V8.6 2009-03.
@param input_buffer
@param output_buffers
@param B
@param C
@param Cplus
@param Cminus
@param Kplus
@param Kminus
@param F
*/
int32_t lte_segmentation(uint8_t *input_buffer,
uint8_t **output_buffers,
uint32_t B,
uint32_t *C,
uint32_t *Cplus,
uint32_t *Cminus,
uint32_t *Kplus,
uint32_t *Kminus,
uint32_t *F);
/** \fn int16_t estimate_ue_tx_power(uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs)
\brief this functions calculates the delta MCS in dB based on the lte_segmentation function
\param tbs transport block size
\param nb_rb number of required rb
\param control_only a flag for the type of data
\param ncp cyclic prefix
\param use_srs a flag indicating the use of srs in the current SF
\returns ue_tx_power estimated ue tx power = delat_ mcs + bw_factor
*/
int16_t estimate_ue_tx_power(uint32_t tbs,
uint32_t nb_rb,
uint8_t control_only,
lte_prefix_type_t ncp,
uint8_t use_srs);
/** \fn uint32_t sub_block_interleaving_turbo(uint32_t D, uint8_t *d,uint8_t *w)
\brief This is the subblock interleaving algorithm from 36-212 (Release 8, 8.6 2009-03), pages 15-16.
This function takes the d-sequence and generates the w-sequence. The nu-sequence from 36-212 is implicit.
\param D Number of systematic bits plus 4 (plus 4 for termination)
\param d Pointer to input (d-sequence, turbo code output)
\param w Pointer to output (w-sequence, interleaver output)
\returns Interleaving matrix cardinality (\f$K_{\pi}\f$ from 36-212)
*/
uint32_t sub_block_interleaving_turbo(uint32_t D, uint8_t *d,uint8_t *w);
/** \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 8, 8.6 2009-03), pages 15-16.
This function takes the d-sequence and generates the w-sequence. The nu-sequence from 36-212 is implicit.
\param D Number of input bits
\param d Pointer to input (d-sequence, convolutional code output)
\param w Pointer to output (w-sequence, interleaver output)
\returns Interleaving matrix cardinality (\f$K_{\pi}\f$ from 36-212)
*/
uint32_t sub_block_interleaving_cc(uint32_t D, uint8_t *d,uint8_t *w);
/** \fn void sub_block_deinterleaving_turbo(uint32_t D, int16_t *d,int16_t *w)
\brief This is the subblock deinterleaving algorithm from 36-212 (Release 8, 8.6 2009-03), pages 15-16.
This function takes the w-sequence and generates the d-sequence. The nu-sequence from 36-212 is implicit.
\param D Number of systematic bits plus 4 (plus 4 for termination)
\param d Pointer to output (d-sequence, turbo code output)
\param w Pointer to input (w-sequence, interleaver output)
*/
void sub_block_deinterleaving_turbo(uint32_t D, int16_t *d,int16_t *w);
/** \fn void sub_block_deinterleaving_cc(uint32_t D, int8_t *d,int8_t *w)
\brief This is the subblock deinterleaving algorithm for convolutionally-coded data from 36-212 (Release 8, 8.6 2009-03), pages 15-16.
This function takes the w-sequence and generates the d-sequence. The nu-sequence from 36-212 is implicit.
\param D Number of input bits
\param d Pointer to output (d-sequence, turbo code output)
\param w Pointer to input (w-sequence, interleaver output)
*/
void sub_block_deinterleaving_cc(uint32_t D,int8_t *d,int8_t *w);
/** \fn generate_dummy_w(uint32_t D, uint8_t *w,uint8_t F)
\brief This function generates a dummy interleaved sequence (first row) for receiver, in order to identify
the NULL positions used to make the matrix complete.
\param D Number of systematic bits plus 4 (plus 4 for termination)
\param w This is the dummy sequence (first row), it will contain zeros and at most 31 "LTE_NULL" values
\param F Number of filler bits due added during segmentation
\returns Interleaving matrix cardinality (\f$K_{\pi}\f$ from 36-212)
*/
uint32_t generate_dummy_w(uint32_t D, uint8_t *w, uint8_t F);
/** \fn generate_dummy_w_cc(uint32_t D, uint8_t *w)
\brief This function generates a dummy interleaved sequence (first row) for receiver (convolutionally-coded data), in order to identify the NULL positions used to make the matrix complete.
\param D Number of systematic bits plus 4 (plus 4 for termination)
\param w This is the dummy sequence (first row), it will contain zeros and at most 31 "LTE_NULL" values
\returns Interleaving matrix cardinality (\f$K_{\pi}\f$ from 36-212)
*/
uint32_t generate_dummy_w_cc(uint32_t D, uint8_t *w);
/** \fn uint32_t lte_rate_matching_turbo(uint32_t RTC,
uint32_t G,
uint8_t *w,
uint8_t *e,
uint8_t C,
uint32_t Nsoft,
uint8_t Mdlharq,
uint8_t Kmimo,
uint8_t rvidx,
uint8_t Qm,
uint8_t Nl,
uint8_t r)
\brief This is the LTE rate matching algorithm for Turbo-coded channels (e.g. DLSCH,ULSCH). It is taken directly from 36-212 (Rel 8 8.6, 2009-03), pages 16-18 )
\param RTC R^TC_subblock from subblock interleaver (number of rows in interleaving matrix) for up to 8 segments
\param G This the number of coded transport bits allocated in sub-frame
\param w This is a pointer to the w-sequence (second interleaver output)
\param e This is a pointer to the e-sequence (rate matching output, channel input/output bits)
\param C Number of segments (codewords) in the sub-frame
\param Nsoft Total number of soft bits (from UE capabilities in 36-306)
\param Mdlharq Number of HARQ rounds
\param Kmimo MIMO capability for this DLSCH (0 = no MIMO)
\param rvidx round index (0-3)
\param Qm modulation order (2,4,6)
\param Nl number of layers (1,2)
\param r segment number
\returns \f$E\f$, the number of coded bits per segment */
uint32_t lte_rate_matching_turbo(uint32_t RTC,
uint32_t G,
uint8_t *w,
uint8_t *e,
uint8_t C,
uint32_t Nsoft,
uint8_t Mdlharq,
uint8_t Kmimo,
uint8_t rvidx,
uint8_t Qm,
uint8_t Nl,
uint8_t r,
uint8_t nb_rb,
uint8_t m);
/**
\brief This is the LTE rate matching algorithm for Convolutionally-coded channels (e.g. BCH,DCI,UCI). It is taken directly from 36-212 (Rel 8 8.6, 2009-03), pages 16-18 )
\param RCC R^CC_subblock from subblock interleaver (number of rows in interleaving matrix) for up to 8 segments
\param E Number of coded channel bits
\param w This is a pointer to the w-sequence (second interleaver output)
\param e This is a pointer to the e-sequence (rate matching output, channel input/output bits)
\returns \f$E\f$, the number of coded bits per segment */
uint32_t lte_rate_matching_cc(uint32_t RCC,
uint16_t E,
uint8_t *w,
uint8_t *e);
/**
\brief This is the LTE rate matching algorithm for Turbo-coded channels (e.g. DLSCH,ULSCH). It is taken directly from 36-212 (Rel 8 8.6, 2009-03), pages 16-18 )
\param RTC R^TC_subblock from subblock interleaver (number of rows in interleaving matrix)
\param G This the number of coded transport bits allocated in sub-frame
\param w This is a pointer to the soft w-sequence (second interleaver output) with soft-combined outputs from successive HARQ rounds
\param dummy_w This is the first row of the interleaver matrix for identifying/discarding the "LTE-NULL" positions
\param soft_input This is a pointer to the soft channel output
\param C Number of segments (codewords) in the sub-frame
\param Nsoft Total number of soft bits (from UE capabilities in 36-306)
\param Mdlharq Number of HARQ rounds
\param Kmimo MIMO capability for this DLSCH (0 = no MIMO)
\param rvidx round index (0-3)
\param clear 1 means clear soft buffer (start of HARQ round)
\param Qm modulation order (2,4,6)
\param Nl number of layers (1,2)
\param r segment number
\param E_out the number of coded bits per segment
\returns 0 on success, -1 on failure
*/
int lte_rate_matching_turbo_rx(uint32_t RTC,
uint32_t G,
int16_t *w,
uint8_t *dummy_w,
int16_t *soft_input,
uint8_t C,
uint32_t Nsoft,
uint8_t Mdlharq,
uint8_t Kmimo,
uint8_t rvidx,
uint8_t clear,
uint8_t Qm,
uint8_t Nl,
uint8_t r,
uint32_t *E_out);
uint32_t lte_rate_matching_turbo_rx_abs(uint32_t RTC,
uint32_t G,
double *w,
uint8_t *dummy_w,
double *soft_input,
uint8_t C,
uint32_t Nsoft,
uint8_t Mdlharq,
uint8_t Kmimo,
uint8_t rvidx,
uint8_t clear,
uint8_t Qm,
uint8_t Nl,
uint8_t r,
uint32_t *E_out);
/**
\brief This is the LTE rate matching algorithm for Convolutionally-coded channels (e.g. BCH,DCI,UCI). It is taken directly from 36-212 (Rel 8 8.6, 2009-03), pages 16-18 )
\param RCC R^CC_subblock from subblock interleaver (number of rows in interleaving matrix)
\param E This the number of coded bits allocated for channel
\param w This is a pointer to the soft w-sequence (second interleaver output) with soft-combined outputs from successive HARQ rounds
\param dummy_w This is the first row of the interleaver matrix for identifying/discarding the "LTE-NULL" positions
\param soft_input This is a pointer to the soft channel output
\returns \f$E\f$, the number of coded bits per segment
*/
void lte_rate_matching_cc_rx(uint32_t RCC,
uint16_t E,
int8_t *w,
uint8_t *dummy_w,
int8_t *soft_input);
/** \fn void ccodedot11_encode(uint32_t numbytes,uint8_t *inPtr,uint8_t *outPtr,uint8_t puncturing)
\brief This function implements a rate 1/2 constraint length 7 convolutional code.
@param numbytes Number of bytes to encode
@param inPtr Pointer to input buffer
@param outPtr Pointer to output buffer
@param puncturing Puncturing pattern (Not used at present, to be removed)
*/
void ccodedot11_encode (uint32_t numbytes,
uint8_t *inPtr,
uint8_t *outPtr,
uint8_t puncturing);
/*!\fn void ccodedot11_init(void)
\brief This function initializes the generator polynomials for an 802.11 convolutional code.*/
void ccodedot11_init(void);
/*!\fn void ccodedot11_init_inv(void)
\brief This function initializes the trellis structure for decoding an 802.11 convolutional code.*/
void ccodedot11_init_inv(void);
/*!\fn void teillis_table_init(void)
\brief This function initializes the trellis structure for 3GPP LTE Turbo code.*/
void treillis_table_init(void);
/*\fn void threegpplte_turbo_encoder(uint8_t *input,uint16_t input_length_bytes,uint8_t *output,uint8_t F,uint16_t interleaver_f1,uint16_t interleaver_f2)
\brief This function implements a rate 1/3 8-state parralel concatenated turbo code (3GPP-LTE).
@param input Pointer to input buffer
@param input_length_bytes Number of bytes to encode
@param output Pointer to output buffer
@param F Number of filler bits at input
@param interleaver_f1 F1 generator
@param interleaver_f2 F2 generator
*/
void threegpplte_turbo_encoder(uint8_t *input,
uint16_t input_length_bytes,
uint8_t *output,
uint8_t F,
uint16_t interleaver_f1,
uint16_t interleaver_f2);
/** \fn void ccodelte_encode(int32_t numbits,uint8_t add_crc, uint8_t *inPtr,uint8_t *outPtr,uint16_t rnti)
\brief This function implements the LTE convolutional code of rate 1/3
with a constraint length of 7 bits. The inputs are bit packed in octets
(from MSB to LSB). Trellis tail-biting is included here.
@param numbits Number of bits to encode
@param add_crc crc to be appended (8 bits) if add_crc = 1
@param inPtr Pointer to input buffer
@param outPtr Pointer to output buffer
@param rnti RNTI for CRC scrambling
*/
void
ccodelte_encode (int32_t numbits,
uint8_t add_crc,
uint8_t *inPtr,
uint8_t *outPtr,
uint16_t rnti);
/*!\fn void ccodelte_init(void)
\brief This function initializes the generator polynomials for an LTE convolutional code.*/
void ccodelte_init(void);
/*!\fn void ccodelte_init_inv(void)
\brief This function initializes the trellis structure for decoding an LTE convolutional code.*/
void ccodelte_init_inv(void);
/*!\fn void ccodelte_init(void)
\brief This function initializes the generator polynomials for an DAB convolutional code (first 3 bits).*/
void ccodedab_init(void);
/*!\fn void ccodelte_init_inv(void)
\brief This function initializes the trellis structure for decoding an DAB convolutional code (first 3 bits).*/
void ccodedab_init_inv(void);
/*!\fn void crcTableInit(void)
\brief This function initializes the different crc tables.*/
void crcTableInit (void);
/*!\fn void init_td8(void)
\brief This function initializes the tables for 8-bit LLR Turbo decoder.*/
void init_td8 (void);
/*!\fn void init_td16(void)
\brief This function initializes the tables for 16-bit LLR Turbo decoder.*/
void init_td16 (void);
#ifdef __AVX2__
/*!\fn void init_td8(void)
\brief This function initializes the tables for 8-bit LLR Turbo decoder (AVX2).*/
void init_td8avx2 (void);
/*!\fn void init_td16(void)
\brief This function initializes the tables for 16-bit LLR Turbo decoder (AVX2).*/
void init_td16avx2 (void);
#endif
/*!\fn uint32_t crc24a(uint8_t *inPtr, int32_t bitlen)
\brief This computes a 24-bit crc ('a' variant for overall transport block)
based on 3GPP UMTS/LTE specifications.
@param inPtr Pointer to input byte stream
@param bitlen length of inputs in bits
*/
uint32_t crc24a (uint8_t *inPtr, int32_t bitlen);
/*!\fn uint32_t crc24b(uint8_t *inPtr, int32_t bitlen)
\brief This computes a 24-bit crc ('b' variant for transport-block segments)
based on 3GPP UMTS/LTE specifications.
@param inPtr Pointer to input byte stream
@param bitlen length of inputs in bits
*/
uint32_t crc24b (uint8_t *inPtr, int32_t bitlen);
/*!\fn uint32_t crc16(uint8_t *inPtr, int32_t bitlen)
\brief This computes a 16-bit crc based on 3GPP UMTS specifications.
@param inPtr Pointer to input byte stream
@param bitlen length of inputs in bits*/
uint32_t crc16 (uint8_t *inPtr, int32_t bitlen);
/*!\fn uint32_t crc12(uint8_t *inPtr, int32_t bitlen)
\brief This computes a 12-bit crc based on 3GPP UMTS specifications.
@param inPtr Pointer to input byte stream
@param bitlen length of inputs in bits*/
uint32_t crc12 (uint8_t *inPtr, int32_t bitlen);
/*!\fn uint32_t crc8(uint8_t *inPtr, int32_t bitlen)
\brief This computes a 8-bit crc based on 3GPP UMTS specifications.
@param inPtr Pointer to input byte stream
@param bitlen length of inputs in bits*/
uint32_t crc8 (uint8_t *inPtr, int32_t bitlen);
/*!\fn void phy_viterbi_dot11_sse2(int8_t *y, uint8_t *decoded_bytes, uint16_t n,int offset,int traceback)
\brief This routine performs a SIMD optmized Viterbi decoder for the 802.11 64-state convolutional code. It can be
run in segments with final trace back after last segment.
@param y Pointer to soft input (coded on 8-bits but should be limited to 4-bit precision to avoid overflow)
@param decoded_bytes Pointer to decoded output
@param n Length of input/trellis depth in bits for this run
@param offset offset in receive buffer for segment on which to operate
@param traceback flag to indicate that traceback should be performed*/
void phy_viterbi_dot11_sse2(int8_t *y,uint8_t *decoded_bytes,uint16_t n);
/*!\fn void phy_viterbi_lte_sse2(int8_t *y, uint8_t *decoded_bytes, uint16_t n)
\brief This routine performs a SIMD optmized Viterbi decoder for the LTE 64-state tail-biting convolutional code.
@param y Pointer to soft input (coded on 8-bits but should be limited to 4-bit precision to avoid overflow)
@param decoded_bytes Pointer to decoded output
@param n Length of input/trellis depth in bits*/
//void phy_viterbi_lte_sse2(int8_t *y,uint8_t *decoded_bytes,uint16_t n);
void phy_viterbi_lte_sse2(int8_t *y,uint8_t *decoded_bytes,uint16_t n);
/*!\fn void phy_generate_viterbi_tables(void)
\brief This routine initializes metric tables for the optimized Viterbi decoder.
*/
void phy_generate_viterbi_tables( void );
/*!\fn void phy_generate_viterbi_tables_lte(void)
\brief This routine initializes metric tables for the optimized LTE Viterbi decoder.
*/
void phy_generate_viterbi_tables_lte( void );
/*!\fn int32_t rate_matching(uint32_t N_coded,
uint32_t N_input,
uint8_t *inPtr,
uint8_t N_bps,
uint32_t off)
\brief This routine performs random puncturing of a coded sequence.
@param N_coded Number of coding bits to be output
@param N_input Number of input bits
@param *inPtr Pointer to coded input
@param N_bps Number of modulation bits per symbol (1,2,4)
@param off Offset for seed
*/
int32_t rate_matching(uint32_t N_coded,
uint32_t N_input,
uint8_t *inPtr,
uint8_t N_bps,
uint32_t off);
int32_t rate_matching_lte(uint32_t N_coded,
uint32_t N_input,
uint8_t *inPtr,
uint32_t off);
/*!
\brief This routine performs max-logmap detection for the 3GPP turbo code (with termination). It is optimized for SIMD processing and 16-bit
LLR arithmetic, and requires SSE2,SSSE3 and SSE4.1 (gcc >=4.3 and appropriate CPU)
@param y LLR input (16-bit precision)
@param decoded_bytes Pointer to decoded output
@param n number of coded bits (including tail bits)
@param max_iterations The maximum number of iterations to perform
@param interleaver_f1 F1 generator
@param interleaver_f2 F2 generator
@param crc_type Length of 3GPPLTE crc (CRC24a,CRC24b,CRC16,CRC8)
@param F Number of filler bits at start of packet
@returns number of iterations used (this is 1+max if incorrect crc or if crc_len=0)
*/
uint8_t phy_threegpplte_turbo_decoder16(int16_t *y,
uint8_t *decoded_bytes,
uint16_t n,
uint16_t interleaver_f1,
uint16_t interleaver_f2,
uint8_t max_iterations,
uint8_t crc_type,
uint8_t F,
time_stats_t *init_stats,
time_stats_t *alpha_stats,
time_stats_t *beta_stats,
time_stats_t *gamma_stats,
time_stats_t *ext_stats,
time_stats_t *intl1_stats,
time_stats_t *intl2_stats);
uint8_t phy_threegpplte_turbo_decoder16avx2(int16_t *y,
int16_t *y2,
uint8_t *decoded_bytes,
uint8_t *decoded_bytes2,
uint16_t n,
uint16_t interleaver_f1,
uint16_t interleaver_f2,
uint8_t max_iterations,
uint8_t crc_type,
uint8_t F,
time_stats_t *init_stats,
time_stats_t *alpha_stats,
time_stats_t *beta_stats,
time_stats_t *gamma_stats,
time_stats_t *ext_stats,
time_stats_t *intl1_stats,
time_stats_t *intl2_stats);
/*!
\brief This routine performs max-logmap detection for the 3GPP turbo code (with termination). It is optimized for SIMD processing and 8-bit
LLR arithmetic, and requires SSE2,SSSE3 and SSE4.1 (gcc >=4.3 and appropriate CPU)
@param y LLR input (16-bit precision)
@param decoded_bytes Pointer to decoded output
@param n number of coded bits (including tail bits)
@param max_iterations The maximum number of iterations to perform
@param interleaver_f1 F1 generator
@param interleaver_f2 F2 generator
@param crc_type Length of 3GPPLTE crc (CRC24a,CRC24b,CRC16,CRC8)
@param F Number of filler bits at start of packet
@returns number of iterations used (this is 1+max if incorrect crc or if crc_len=0)
*/
uint8_t phy_threegpplte_turbo_decoder8(int16_t *y,
uint8_t *decoded_bytes,
uint16_t n,
uint16_t interleaver_f1,
uint16_t interleaver_f2,
uint8_t max_iterations,
uint8_t crc_type,
uint8_t F,
time_stats_t *init_stats,
time_stats_t *alpha_stats,
time_stats_t *beta_stats,
time_stats_t *gamma_stats,
time_stats_t *ext_stats,
time_stats_t *intl1_stats,
time_stats_t *intl2_stats);
uint8_t phy_threegpplte_turbo_decoder_scalar(int16_t *y,
uint8_t *decoded_bytes,
uint16_t n,
uint16_t interleaver_f1,
uint16_t interleaver_f2,
uint8_t max_iterations,
uint8_t crc_type,
uint8_t F,
uint8_t inst);
/** @} */
uint32_t crcbit (uint8_t * ,
int32_t,
uint32_t);
int16_t reverseBits(int32_t ,int32_t);
void phy_viterbi_dot11(int8_t *,uint8_t *,uint16_t);
#endif
/***********************************************************************
**********************************************************************/
/*! \file PHY/LTE_CODING/lte_rate_matching_NB_IoT.c
* \Procedures for rate matching/interleaving for NB-IoT (turbo-coded transport channels) (TX/RX), TS 36-212, V13.4.0 2017-02
* \author M. KANJ
* \date 2017
* \version 0.0
* \company bcom
* \email: matthieu.kanj@b-com.com
* \note
* \warning
*/
/* // check if this ifdef MAIN is required for NB-IoT
#ifdef MAIN
#include <stdio.h>
#include <stdlib.h>
#endif
*/
//#include "PHY/CODING/defs_NB_IoT.h"
#include "PHY/defs_L1_NB_IoT.h"
//#include "assertions.h"
//#include "PHY/LTE_REFSIG/defs_NB_IoT.h" // does this file is needed ?
static uint32_t bitrev_cc_NB_IoT[32] = {1,17,9,25,5,21,13,29,3,19,11,27,7,23,15,31,0,16,8,24,4,20,12,28,2,18,10,26,6,22,14,30};
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;
if ((D&0x1f) > 0)
RCC++;
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++) {
index = bitrev_cc_NB_IoT[col];
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];
index3+=96;
index+=32;
k++;
}
}
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 ind=0,k;
uint16_t Kw = 3*(RCC<<5); // 3*64 = 192
for (k=0; k<E; k++) {
while(w[ind] == LTE_NULL_NB_IoT) {
ind++;
if (ind==Kw)
ind=0;
}
e[k] = w[ind];
ind++;
if (ind==Kw)
ind=0;
}
return(E);
}
//******************* below functions related to uplink transmission , to be reviwed *********
// this function should be adapted to NB-IoT , this deinterleaving is for LTE
void sub_block_deinterleaving_cc_NB_IoT(uint32_t D,int8_t *d,int8_t *w)
{
//WANG_Hao uint32_t RCC = (D>>5), ND, ND3;
uint32_t RCC = (D>>5);
ptrdiff_t ND, ND3;
uint32_t row,col,Kpi,index;
//WANG_Hao uint32_t index3,k;
ptrdiff_t index3;
uint32_t k;
if ((D&0x1f) > 0)
RCC++;
Kpi = (RCC<<5);
// Kpi3 = Kpi*3;
ND = Kpi - D;
ND3 = ND*3;
k=0;
for (col=0; col<32; col++) {
index = bitrev_cc_NB_IoT[col];
index3 = 3*index;
for (row=0; row<RCC; row++) {
d[index3-ND3] = w[k];
d[index3-ND3+1] = w[Kpi+k];
d[index3-ND3+2] = w[(Kpi<<1)+k];
index3+=96;
index+=32;
k++;
}
}
}
void lte_rate_matching_cc_rx_NB_IoT(uint32_t RCC,
uint16_t E,
int8_t *w,
uint8_t *dummy_w,
int8_t *soft_input)
{
uint32_t ind=0,k;
uint16_t Kw = 3*(RCC<<5);
uint32_t acc=1;
int16_t w16[Kw];
memset(w,0,Kw);
memset(w16,0,Kw*sizeof(int16_t));
for (k=0; k<E; k++) {
while(dummy_w[ind] == LTE_NULL_NB_IoT) {
ind++;
if (ind==Kw)
ind=0;
}
w16[ind] += soft_input[k];
ind++;
if (ind==Kw) {
ind=0;
acc++;
}
}
// rescale
for (ind=0; ind<Kw; ind++) {
// w16[ind]=(w16[ind]/acc);
if (w16[ind]>7)
w[ind]=7;
else if (w16[ind]<-8)
w[ind]=-8;
else
w[ind]=(int8_t)w16[ind];
}
}
uint32_t generate_dummy_w_cc_NB_IoT(uint32_t D, uint8_t *w)
{
uint32_t RCC = (D>>5), ND;
uint32_t col,Kpi,index;
int32_t k;
if ((D&0x1f) > 0)
RCC++;
Kpi = (RCC<<5);
// Kpi3 = Kpi*3;
ND = Kpi - D;
// copy d02 to dD2 (for mod Kpi operation from clause (4), p.16 of 36.212
k=0;
for (col=0; col<32; col++) {
index = bitrev_cc_NB_IoT[col];
if (index<ND) {
w[k] = LTE_NULL_NB_IoT;
w[Kpi+k] = LTE_NULL_NB_IoT;
w[(Kpi<<1)+k] = LTE_NULL_NB_IoT;
}
k+=RCC;
}
return(RCC);
}
/***********************************************************************
**********************************************************************/
/*! \file PHY/LTE_REFSIG/lte_dl_cell_spec_NB_IoT.c
* \function called by pilots_NB_IoT.c , TS 36-211, V13.4.0 2017-02
* \author M. KANJ
* \date 2017
* \version 0.0
* \company bcom
* \email: matthieu.kanj@b-com.com
* \note
* \warning
*/
/* check if this is required for NB-IoT
#ifdef USER_MODE
#include <stdio.h>
#include <stdlib.h>
#endif
*/
#include "PHY/LTE_REFSIG/defs_NB_IoT.h"
#include "PHY/defs_L1_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
{
unsigned char nu,m;
unsigned char mprime,mprime_dword,mprime_qpsk_symb;
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;
((short *)&qpsk[0])[1] = a;
((short *)&qpsk[1])[0] = -a;
((short *)&qpsk[1])[1] = a;
((short *)&qpsk[2])[0] = a;
((short *)&qpsk[2])[1] = -a;
((short *)&qpsk[3])[0] = -a;
((short *)&qpsk[3])[1] = -a;
if ((p==0) && (l==0) )
nu = 0;
else if ((p==0) && (l>0))
nu = 3;
else if ((p==1) && (l==0))
nu = 3;
else if ((p==1) && (l>0))
nu = 0;
else {
printf("lte_dl_cell_spec_NB_IoT: p %d, l %d -> ERROR\n",p,l);
return(-1);
}
//mprime = 110 - eNB->frame_parms.N_RB_DL;
mprime = 109;
// testing if the total number of RBs is even or odd
bandwidth_even_odd = phy_vars_eNB->frame_parms.N_RB_DL % 2; // 0 even, 1 odd
//mprime = 0; // mprime = 0,1 for NB_IoT // for LTE , maximum number of resources blocks (110) - the total number of RB in the selected bandwidth (.... 15 , 25 , 50, 100)
k = (nu + phy_vars_eNB->frame_parms.nushift)%6;
if(RB_IoT_ID < (phy_vars_eNB->frame_parms.N_RB_DL/2))
{ //XXX this mod operation is not valid since the second member is not an integer but double (for the moment i put a cast)
NB_IoT_start = phy_vars_eNB->frame_parms.ofdm_symbol_size - 12*(phy_vars_eNB->frame_parms.N_RB_DL/2) - (bandwidth_even_odd*6) + 12*(RB_IoT_ID%((int)(ceil(phy_vars_eNB->frame_parms.N_RB_DL/(float)2))));
} else {
//XXX invalid mod operation (put a cast for the moment)
NB_IoT_start = 1 + (bandwidth_even_odd*6) + 12*(RB_IoT_ID%((int)(ceil(phy_vars_eNB->frame_parms.N_RB_DL/(float)2))));
}
k+=NB_IoT_start;
DevAssert( Ns < 20 );
DevAssert( l < 2 );
for (m=0; m<2; m++) {
mprime_dword = mprime>>4;
mprime_qpsk_symb = mprime&0xf;
output[k] = qpsk[(phy_vars_eNB->lte_gold_table_NB_IoT[Ns][l][mprime_dword]>>(2*mprime_qpsk_symb)) & 3]; //TODO should be defined one for NB-IoT
mprime++;
k+=6;
}
return(0);
}
/////////////////////////////////////////////////////////////////////////
/*
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];
a = (amp*ONE_OVER_SQRT2_Q15_NB_IoT)>>15;
((short *)&qpsk[0])[0] = a;
((short *)&qpsk[0])[1] = a;
((short *)&qpsk[1])[0] = -a;
((short *)&qpsk[1])[1] = a;
((short *)&qpsk[2])[0] = a;
((short *)&qpsk[2])[1] = -a;
((short *)&qpsk[3])[0] = -a;
((short *)&qpsk[3])[1] = -a;
if ((p==0) && (l==0) )
nu = 0;
else if ((p==0) && (l>0))
nu = 3;
else if ((p==1) && (l==0))
nu = 3;
else if ((p==1) && (l>0))
nu = 0;
else {
printf("lte_dl_cell_spec_NB_IoT: p %d, l %d -> ERROR\n",p,l);
return(-1);
}
// testing if the total number of RBs is even or odd
bandwidth_even_odd = phy_vars_eNB->frame_parms.N_RB_DL % 2; // 0 even, 1 odd
//mprime = 0; // mprime = 0,1 for NB_IoT // for LTE , maximum number of resources blocks (110) - the total number of RB in the selected bandwidth (.... 15 , 25 , 50, 100)
k = (nu + phy_vars_eNB->frame_parms.nushift)%6;
if(RB_IoT_ID < (phy_vars_eNB->frame_parms.N_RB_DL/2))
{ //XXX this mod operation is not valid since the second member is not an integer but double (for the moment i put a cast)
NB_IoT_start = phy_vars_eNB->frame_parms.ofdm_symbol_size - 12*(phy_vars_eNB->frame_parms.N_RB_DL/2) - (bandwidth_even_odd*6) + 12*(RB_IoT_ID%((int)(ceil(phy_vars_eNB->frame_parms.N_RB_DL/(float)2))));
} else {
//XXX invalid mod operation (put a cast for the moment)
NB_IoT_start = (bandwidth_even_odd*6) + 12*(RB_IoT_ID%((int)(ceil(phy_vars_eNB->frame_parms.N_RB_DL/(float)2))));
}
k+=NB_IoT_start;
DevAssert( Ns < 20 );
DevAssert( l < 2 );
for (m=0; m<2; m++) {
output[k] = qpsk[(phy_vars_eNB->lte_gold_table_NB_IoT[Ns][l][0]) & 3]; //TODO should be defined one for NB-IoT
k+=6;
}
return(0);
}
*/
\ No newline at end of file
/***********************************************************************
**********************************************************************/
/*! \file PHY/LTE_REFSIG/lte_gold_NB_IoT.c
* \function called by lte_dl_cell_spec_NB_IoT.c , TS 36-211, V13.4.0 2017-02
* \author M. KANJ
* \date 2017
* \version 0.0
* \company bcom
* \email: matthieu.kanj@b-com.com
* \note
* \warning
*/
//#include "defs.h"
#include "PHY/LTE_REFSIG/defs_NB_IoT.h"
#include "../impl_defs_lte_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;
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
x1 = 1+ (1<<31);
x2 = x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31);
// skip first 50 double words (1600 bits)
for (n=1; n<50; n++) {
x1 = (x1>>1) ^ (x1>>4);
x1 = x1 ^ (x1<<31) ^ (x1<<28);
x2 = (x2>>1) ^ (x2>>2) ^ (x2>>3) ^ (x2>>4);
x2 = x2 ^ (x2<<31) ^ (x2<<30) ^ (x2<<29) ^ (x2<<28);
}
for (n=0; n<14; n++) {
x1 = (x1>>1) ^ (x1>>4);
x1 = x1 ^ (x1<<31) ^ (x1<<28);
x2 = (x2>>1) ^ (x2>>2) ^ (x2>>3) ^ (x2>>4);
x2 = x2 ^ (x2<<31) ^ (x2<<30) ^ (x2<<29) ^ (x2<<28);
lte_gold_table_NB_IoT[ns][l][n] = x1^x2;
}
}
}
}
// \brief gold sequenquence generator
//\param x1
//\param x2 this should be set to c_init if reset=1
//\param reset resets the generator
//\return 32 bits of the gold sequence
unsigned int lte_gold_generic_NB_IoT(unsigned int *x1, unsigned int *x2, unsigned char reset)
{
int n;
if (reset) {
*x1 = 1+ (1<<31);
*x2=*x2 ^ ((*x2 ^ (*x2>>1) ^ (*x2>>2) ^ (*x2>>3))<<31);
for (n=1; n<50; n++) {
*x1 = (*x1>>1) ^ (*x1>>4);
*x1 = *x1 ^ (*x1<<31) ^ (*x1<<28);
*x2 = (*x2>>1) ^ (*x2>>2) ^ (*x2>>3) ^ (*x2>>4);
*x2 = *x2 ^ (*x2<<31) ^ (*x2<<30) ^ (*x2<<29) ^ (*x2<<28);
}
}
*x1 = (*x1>>1) ^ (*x1>>4);
*x1 = *x1 ^ (*x1<<31) ^ (*x1<<28);
*x2 = (*x2>>1) ^ (*x2>>2) ^ (*x2>>3) ^ (*x2>>4);
*x2 = *x2 ^ (*x2<<31) ^ (*x2<<30) ^ (*x2<<29) ^ (*x2<<28);
return(*x1^*x2);
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file PHY/LTE_REFSIG/lte_ul_ref_NB_IoT.c
* \function called by lte_dl_cell_spec_NB_IoT.c , TS 36-211, V13.4.0 2017-02
* \author: Vincent Savaux
* \date 2018
* \version 0.0
* \company b<>com
* \email: vincent.savaux@b-com.com
* \note
* \warning
*/
#ifdef MAIN
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#endif
// #include "defs.h"
#include "PHY/LTE_REFSIG/defs_NB_IoT.h"
#include "PHY/defs_L1_NB_IoT.h"
#include "lte_refsig.h"
// uint16_t dftsizes[33] = {12,24,36,48,60,72,96,108,120,144,180,192,216,240,288,300,324,360,384,432,480,540,576,600,648,720,864,900,960,972,1080,1152,1200};
// uint16_t ref_primes[33] = {11,23,31,47,59,71,89,107,113,139,179,191,211,239,283,293,317,359,383,431,479,523,571,599,647,719,863,887,953,971,1069,1151,1193};
uint16_t sequence_length[4] = {100,100,100,100}; //the "32" value corresponds to the max gold sequence length
// int16_t *ul_ref_sigs[30][33];
int16_t *ul_ref_sigs_rx_NB_IoT[30][4]; //these contain the sequences in repeated format and quantized to QPSK ifdef IFFT_FPGA
int16_t *ul_ref_sigs_f2_rx_NB_IoT[16]; //this table contain the 16 possible pilots for format 2 NPUSCH
uint16_t u_max[4] = {16,12,14,30}; // maximum u value, see 36.211, Section 10.1.4
/* 36.211 table 5.5.1.2-1 */
char ref12_NB_IoT[360] = {-1,1,3,-3,3,3,1,1,3,1,-3,3,1,1,3,3,3,-1,1,-3,-3,1,-3,3,1,1,-3,-3,-3,-1,-3,-3,1,-3,1,-1,-1,1,1,1,1,-1,-3,-3,1,-3,3,-1,-1,3,1,-1,1,-1,-3,-1,1,-1,1,3,1,-3,3,-1,-1,1,1,-1,-1,3,-3,1,-1,3,-3,-3,-3,3,1,-1,3,3,-3,1,-3,-1,-1,-1,1,-3,3,-1,1,-3,3,1,1,-3,3,1,-1,-1,-1,1,1,3,-1,1,1,-3,-1,3,3,-1,-3,1,1,1,1,1,-1,3,-1,1,1,-3,-3,-1,-3,-3,3,-1,3,1,-1,-1,3,3,-3,1,3,1,3,3,1,-3,1,1,-3,1,1,1,-3,-3,-3,1,3,3,-3,3,-3,1,1,3,-1,-3,3,3,-3,1,-1,-3,-1,3,1,3,3,3,-1,1,3,-1,1,-3,-1,-1,1,1,3,1,-1,-3,1,3,1,-1,1,3,3,3,-1,-1,3,-1,-3,1,1,3,-3,3,-3,-3,3,1,3,-1,-3,3,1,1,-3,1,-3,-3,-1,-1,1,-3,-1,3,1,3,1,-1,-1,3,-3,-1,-3,-1,-1,-3,1,1,1,1,3,1,-1,1,-3,-1,-1,3,-1,1,-3,-3,-3,-3,-3,1,-1,-3,1,1,-3,-3,-3,-3,-1,3,-3,1,-3,3,1,1,-1,-3,-1,-3,1,-1,1,3,-1,1,1,1,3,1,3,3,-1,1,-1,-3,-3,1,1,-3,3,3,1,3,3,1,-3,-1,-1,3,1,3,-3,-3,3,-3,1,-1,-1,3,-1,-3,-3,-1,-3,-1,-3,3,1,-1,1,3,-3,-3,-1,3,-3,3,-1,3,3,-3,3,3,-1,-1,3,-3,-3,-1,-1,-3,-1,3,-3,3,1,-1};
/* 36.211 table 5.5.1.2-2 */
// char ref24[720] = {
// -1,3,1,-3,3,-1,1,3,-3,3,1,3,-3,3,1,1,-1,1,3,-3,3,-3,-1,-3,-3,3,-3,-3,-3,1,-3,-3,3,-1,1,1,1,3,1,-1,3,-3,-3,1,3,1,1,-3,3,-1,3,3,1,1,-3,3,3,3,3,1,-1,3,-1,1,1,-1,-3,-1,-1,1,3,3,-1,-3,1,1,3,-3,1,1,-3,-1,-1,1,3,1,3,1,-1,3,1,1,-3,-1,-3,-1,-1,-1,-1,-3,-3,-1,1,1,3,3,-1,3,-1,1,-1,-3,1,-1,-3,-3,1,-3,-1,-1,-3,1,1,3,-1,1,3,1,-3,1,-3,1,1,-1,-1,3,-1,-3,3,-3,-3,-3,1,1,1,1,-1,-1,3,-3,-3,3,-3,1,-1,-1,1,-1,1,1,-1,-3,-1,1,-1,3,-1,-3,-3,3,3,-1,-1,-3,-1,3,1,3,1,3,1,1,-1,3,1,-1,1,3,-3,-1,-1,1,-3,1,3,-3,1,-1,-3,3,-3,3,-1,-1,-1,-1,1,-3,-3,-3,1,-3,-3,-3,1,-3,1,1,-3,3,3,-1,-3,-1,3,-3,3,3,3,-1,1,1,-3,1,-1,1,1,-3,1,1,-1,1,-3,-3,3,-1,3,-1,-1,-3,-3,-3,-1,-3,-3,1,-1,1,3,3,-1,1,-1,3,1,3,3,-3,-3,1,3,1,-1,-3,-3,-3,3,3,-3,3,3,-1,-3,3,-1,1,-3,1,1,3,3,1,1,1,-1,-1,1,-3,3,-1,1,1,-3,3,3,-1,-3,3,-3,-1,-3,-1,3,-1,-1,-1,-1,-3,-1,3,3,1,-1,1,3,3,3,-1,1,1,-3,1,3,-1,-3,3,-3,-3,3,1,3,1,-3,3,1,3,1,1,3,3,-1,-1,-3,1,-3,-1,3,1,1,3,-1,-1,1,-3,1,3,-3,1,-1,-3,-1,3,1,3,1,-1,-3,-3,-1,-1,-3,-3,-3,-1,-1,-3,3,-1,-1,-1,-1,1,1,-3,3,1,3,3,1,-1,1,-3,1,-3,1,1,-3,-1,1,3,-1,3,3,-1,-3,1,-1,-3,3,3,3,-1,1,1,3,-1,-3,-1,3,-1,-1,-1,1,1,1,1,1,-1,3,-1,-3,1,1,3,-3,1,-3,-1,1,1,-3,-3,3,1,1,-3,1,3,3,1,-1,-3,3,-1,3,3,3,-3,1,-1,1,-1,-3,-1,1,3,-1,3,-3,-3,-1,-3,3,-3,-3,-3,-1,-1,-3,-1,-3,3,1,3,-3,-1,3,-1,1,-1,3,-3,1,-1,-3,-3,1,1,-1,1,-1,1,-1,3,1,-3,-1,1,-1,1,-1,-1,3,3,-3,-1,1,-3,-3,-1,-3,3,1,-1,-3,-1,-3,-3,3,-3,3,-3,-1,1,3,1,-3,1,3,3,-1,-3,-1,-1,-1,-1,3,3,3,1,3,3,-3,1,3,-1,3,-1,3,3,-3,3,1,-1,3,3,1,-1,3,3,-1,-3,3,-3,-1,-1,3,-1,3,-1,-1,1,1,1,1,-1,-1,-3,-1,3,1,-1,1,-1,3,-1,3,1,1,-1,-1,-3,1,1,-3,1,3,-3,1,1,-3,-3,-1,-1,-3,-1,1,3,1,1,-3,-1,-1,-3,3,-3,3,1,-3,3,-3,1,-1,1,-3,1,1,1,-1,-3,3,3,1,1,3,-1,-3,-1,-1,-1,3,1,-3,-3,-1,3,-3,-1,-3,-1,-3,-1,-1,-3,-1,-1,1,-3,-1,-1,1,-1,-3,1,1,-3,1,-3,-3,3,1,1,-1,3,-1,-1,1,1,-1,-1,-3,-1,3,-1,3,-1,1,3,1,-1,3,1,3,-3,-3,1,-1,-1,1,3
// };
// 36.211, Section 10.1.4.1.2, Table 10.1.4.1.2-1
char ref3[36] = {1, -3, -3, 1, -3, -1, 1, -3, 3, 1, -1, -1, 1, -1, 1, 1, -1, 3, 1, 1, -3, 1, 1, -1, 1, 1, 3, 1, 3, -1, 1, 3, 1, 1, 3, 3 };
// 36.211, Section 10.1.4.1.2, Table 10.1.4.1.2-2
char ref6[84] = {1, 1, 1, 1, 3, -3, 1, 1, 3, 1, -3, 3, 1, -1, -1, -1, 1, -3, 1, -1, 3, -3, -1, -1, 1, 3, 1, -1, -1, 3, 1, -3, -3, 1, 3, 1, -1, -1, 1, -3, -3, -1,
-1, -1, -1, 3, -3, -1, 3, -1, 1, -3, -3, 3, 3, -1, 3, -3, -1, 1, 3, -3, 3, -1, 3, 3, -3, 1, 3, 1, -3, -1, -3, 1, -3, 3, -3, -1, -3, 3, -3, 1, 1, -3};
// NB-IoT: 36.211, Section 10.1.4.1.1, Table 10.1.4.1.1-1
int16_t w_n[256] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
1, 1,-1,-1, 1, 1,-1,-1, 1, 1,-1,-1, 1, 1,-1,-1,
1,-1,-1, 1, 1,-1,-1, 1, 1,-1,-1, 1, 1,-1,-1, 1,
1, 1, 1, 1,-1,-1,-1,-1, 1, 1, 1, 1,-1,-1,-1,-1,
1,-1, 1,-1,-1, 1,-1, 1, 1,-1, 1,-1,-1, 1,-1, 1,
1, 1,-1,-1,-1,-1, 1, 1, 1, 1,-1,-1,-1,-1, 1, 1,
1,-1,-1, 1,-1, 1, 1,-1, 1,-1,-1, 1,-1, 1, 1,-1,
1, 1, 1, 1, 1, 1, 1, 1,-1,-1,-1,-1,-1,-1,-1,-1,
1,-1, 1,-1, 1,-1, 1,-1,-1, 1,-1, 1,-1, 1,-1, 1,
1, 1,-1,-1, 1, 1,-1,-1,-1,-1, 1, 1,-1,-1, 1, 1,
1,-1,-1, 1, 1,-1,-1, 1,-1, 1, 1,-1,-1, 1, 1,-1,
1, 1, 1, 1,-1,-1,-1,-1,-1,-1,-1,-1, 1, 1, 1, 1,
1,-1, 1,-1,-1, 1,-1, 1,-1, 1,-1, 1, 1,-1, 1,-1,
1, 1,-1,-1,-1,-1, 1, 1,-1,-1, 1, 1, 1, 1,-1,-1,
1,-1,-1, 1,-1, 1, 1,-1,-1, 1, 1,-1, 1,-1,-1, 1
};
// void generate_ul_ref_sigs(void)
// {
// double qbar,phase;
// unsigned int u,v,Msc_RS,q,m,n;
// // These are the Zadoff-Chu sequences (for RB 3-100)
// for (Msc_RS=2; Msc_RS<33; Msc_RS++) {
// for (u=0; u<30; u++) {
// for (v=0; v<2; v++) {
// qbar = ref_primes[Msc_RS] * (u+1)/(double)31;
// ul_ref_sigs[u][v][Msc_RS] = (int16_t*)malloc16(2*sizeof(int16_t)*dftsizes[Msc_RS]);
// if ((((int)floor(2*qbar))&1) == 0)
// q = (int)(floor(qbar+.5)) - v;
// else
// q = (int)(floor(qbar+.5)) + v;
// #ifdef MAIN
// printf("Msc_RS %d (%d), u %d, v %d -> q %d (qbar %f)\n",Msc_RS,dftsizes[Msc_RS],u,v,q,qbar);
// #endif
// for (n=0; n<dftsizes[Msc_RS]; n++) {
// m=n%ref_primes[Msc_RS];
// phase = (double)q*m*(m+1)/ref_primes[Msc_RS];
// ul_ref_sigs[u][v][Msc_RS][n<<1] =(int16_t)(floor(32767*cos(M_PI*phase)));
// ul_ref_sigs[u][v][Msc_RS][1+(n<<1)] =-(int16_t)(floor(32767*sin(M_PI*phase)));
// #ifdef MAIN
// if (Msc_RS<5)
// printf("(%d,%d) ",ul_ref_sigs[u][v][Msc_RS][n<<1],ul_ref_sigs[u][v][Msc_RS][1+(n<<1)]);
// #endif
// }
// #ifdef MAIN
// if (Msc_RS<5)
// printf("\n");
// #endif
// }
// }
// }
// // These are the sequences for RB 1
// for (u=0; u<30; u++) {
// ul_ref_sigs[u][0][0] = (int16_t*)malloc16(2*sizeof(int16_t)*dftsizes[0]);
// for (n=0; n<dftsizes[0]; n++) {
// ul_ref_sigs[u][0][0][n<<1] =(int16_t)(floor(32767*cos(M_PI*ref12[(u*12) + n]/4)));
// ul_ref_sigs[u][0][0][1+(n<<1)]=(int16_t)(floor(32767*sin(M_PI*ref12[(u*12) + n]/4)));
// }
// }
// // These are the sequences for RB 2
// for (u=0; u<30; u++) {
// ul_ref_sigs[u][0][1] = (int16_t*)malloc16(2*sizeof(int16_t)*dftsizes[1]);
// for (n=0; n<dftsizes[1]; n++) {
// ul_ref_sigs[u][0][1][n<<1] =(int16_t)(floor(32767*cos(M_PI*ref24[(u*24) + n]/4)));
// ul_ref_sigs[u][0][1][1+(n<<1)]=(int16_t)(floor(32767*sin(M_PI*ref24[(u*24) + n]/4)));
// }
// }
// }
/*void generate_ul_ref_sigs_rx_NB_IoT(void)
{
unsigned int u,index_Nsc_RU,n; // Vincent: index_Nsc_RU 0,1,2,3 ---> number of sc 1,3,6,12
uint8_t npusch_format = 1; // NB-IoT: format 1 (data), or 2: ack. Should be defined in higher layer
int16_t a;
int16_t qpsk[2];
unsigned int x1, x2=35; // NB-IoT: defined in 36.211, Section 10.1.4.1.1
int16_t ref_sigs_sc1[2*sequence_length[0]];
uint32_t s;
a = (ONE_OVER_SQRT2_Q15_NB_IoT)>>15;
qpsk[0] = a;
qpsk[1] = -a;
s = lte_gold_generic_NB_IoT(&x1, &x2, 1);
for (index_Nsc_RU=0; index_Nsc_RU<4; index_Nsc_RU++) {
for (u=0; u<u_max[index_Nsc_RU]; u++) {
// ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU] = (int16_t*)malloc16(2*sizeof(int16_t)*sequence_length[index_Nsc_RU]);
switch (index_Nsc_RU){
case 0: // 36.211, Section 10.1.4.1.1
ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU] = (int16_t*)malloc(sizeof(int16_t)*(2*sequence_length[index_Nsc_RU]*12+24)); // *12 is mandatory to fit channel estimation functions
// NB-IoT: for same reason, +24 is added in order to fit the possible subcarrier start shift when index_Nsc_RU = 0, 1, 2 --> see ul_sc_start in channel estimation function
for (n=0; n<sequence_length[index_Nsc_RU]; n++) {
if (n!=0 && n%32==0)
{
s = lte_gold_generic_NB_IoT(&x1, &x2, 0);
}
ref_sigs_sc1[n<<1] = qpsk[(s>>(n%32))&1]*w_n[16*u+n%16];
// ref_sigs_sc1[1+(n<<1)] = qpsk[(s>>n)&1]*w_n[16*u+n%16];
ref_sigs_sc1[1+(n<<1)] = ref_sigs_sc1[n<<1];
}
if (npusch_format==1){
for (n=0; n<sequence_length[index_Nsc_RU]; n++) {
// ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU][n<<1] = ref_sigs_sc1[n<<1];
// ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU][1+(n<<1)]= ref_sigs_sc1[1+(n<<1)];
ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU][12*(n<<1)+24] = ref_sigs_sc1[n<<1]; // ul_ref_sigs_rx_NB_IoT is filled every 12 RE, real part
ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU][1+12*(n<<1)+24]= ref_sigs_sc1[1+(n<<1)]; // ul_ref_sigs_rx_NB_IoT is filled every 12 RE, imaginary part
}
}
if (npusch_format==2){// NB-IoT: to be implemented
printf("Not coded yet\n");
}
break;
case 1: // 36.211, Section 10.1.4.1.2
ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU] = (int16_t*)malloc(sizeof(int16_t)*(2*12+24)); // *12 is mandatory to fit channel estimation functions
for (n=0; n<sequence_length[index_Nsc_RU]; n++) {
// ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU][n<<1] = (int16_t)(floor(32767*cos(M_PI*ref3[(u*3) + n]/4 + alpha3[threetnecyclicshift])));
// ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU][1+(n<<1)]= (int16_t)(floor(32767*sin(M_PI*ref3[(u*3) + n]/4 + alpha3[threetnecyclicshift])));
ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU][(n<<1)+24] = (int16_t)(floor(32767*cos(M_PI*ref3[(u*3) + n]/4 )));
ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU][1+(n<<1)+24]= (int16_t)(floor(32767*sin(M_PI*ref3[(u*3) + n]/4 )));
}
break;
case 2:
ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU] = (int16_t*)malloc(sizeof(int16_t)*(2*12+24)); // *12 is mandatory to fit channel estimation functions
for (n=0; n<sequence_length[index_Nsc_RU]; n++) {
// ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU][n<<1] = (int16_t)(floor(32767*cos(M_PI*ref6[(u*6) + n]/4 + alpha6[sixtonecyclichift])));
// ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU][1+(n<<1)]= (int16_t)(floor(32767*sin(M_PI*ref6[(u*6) + n]/4 + alpha6[sixtonecyclichift])));
ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU][(n<<1)+24] = (int16_t)(floor(32767*cos(M_PI*ref6[(u*6) + n]/4 )));
ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU][1+(n<<1)+24]= (int16_t)(floor(32767*sin(M_PI*ref6[(u*6) + n]/4 )));
}
break;
case 3:
ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU] = (int16_t*)malloc(sizeof(int16_t)*(2*12+24)); // *12 is mandatory to fit channel estimation functions
for (n=0; n<sequence_length[index_Nsc_RU]; n++) {
ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU][n<<1] = (int16_t)(floor(32767*cos(M_PI*ref12_NB_IoT[(u*12) + n]/4)));
ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU][1+(n<<1)]= (int16_t)(floor(32767*sin(M_PI*ref12_NB_IoT[(u*12) + n]/4)));
}
break;
}
}
}
}*/
void generate_ul_ref_sigs_rx_NB_IoT(void)
{
unsigned int u,index_Nsc_RU,n,m; // Vincent: index_Nsc_RU 0,1,2,3 ---> number of sc 1,3,6,12
//uint8_t npusch_format = 1; // NB-IoT: format 1 (data), or 2: ack. Should be defined in higher layer
int16_t a;
int16_t qpsk[2];
unsigned int x1, x2; // NB-IoT: defined in 36.211, Section 10.1.4.1.1
int16_t ref_sigs_sc1[2*sequence_length[0]]; // this is for format 1
//int16_t ref_sigs_sc1_f2[2*sequence_length[0]]; // this is for format 2
uint32_t s;
a = ONE_OVER_SQRT2_Q15_NB_IoT;
qpsk[0] = a;
qpsk[1] = -a;
//printf("\n\n\n in generate_ul_ref_sigs_rx_NB_IoT %d \n\n\n",a);
for (index_Nsc_RU=0; index_Nsc_RU<4; index_Nsc_RU++)
{
for (u=0; u<u_max[index_Nsc_RU]; u++)
{
// ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU] = (int16_t*)malloc16(2*sizeof(int16_t)*sequence_length[index_Nsc_RU]);
switch (index_Nsc_RU)
{
case 0: // 36.211, Section 10.1.4.1.1
x2=35;
s = lte_gold_generic_NB_IoT(&x1, &x2, 1);
ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU] = (int16_t*)malloc(sizeof(int16_t)*(2*sequence_length[index_Nsc_RU]*12+24)); // *12 is mandatory to fit channel estimation functions
ul_ref_sigs_f2_rx_NB_IoT[u] = (int16_t*)malloc(sizeof(int16_t)*(2*12*12+24)); // first "*12" is mandatory to fit channel estimation functions; first "*12" is the length of pilot sequence for format 2
// NB-IoT: for same reason, +24 is added in order to fit the possible subcarrier start shift when index_Nsc_RU = 0, 1, 2 --> see ul_sc_start in channel estimation function
for (n=0; n<sequence_length[index_Nsc_RU]; n++)
{
if (n>0 && n%32==0)
{
s = lte_gold_generic_NB_IoT(&x1, &x2, 0);
}
ref_sigs_sc1[n<<1] = qpsk[(s>>(n%32))&1]*w_n[16*u+n%16];
// ref_sigs_sc1[1+(n<<1)] = qpsk[(s>>n)&1]*w_n[16*u+n%16];
ref_sigs_sc1[1+(n<<1)] = ref_sigs_sc1[n<<1];
}
for (n=0; n<sequence_length[index_Nsc_RU]; n++)
{
ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU][12*(n<<1)+24] = ref_sigs_sc1[n<<1]; // ul_ref_sigs_rx_NB_IoT is filled every 12 RE, real part
ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU][1+12*(n<<1)+24]= ref_sigs_sc1[1+(n<<1)]; // ul_ref_sigs_rx_NB_IoT is filled every 12 RE, imaginary part
}
for (n=0; n<4; n++)
{
for (m=0; m<3; m++)
{
ul_ref_sigs_f2_rx_NB_IoT[u][12*((3*n+m)<<1)+24] = ref_sigs_sc1[n<<1]; // ul_ref_sigs_rx_NB_IoT is filled every 12 RE, real part
ul_ref_sigs_f2_rx_NB_IoT[u][1+12*((3*n+m)<<1)+24] = ref_sigs_sc1[1+(n<<1)]; // ul_ref_sigs_rx_NB_IoT is filled every 12 RE, imaginary part
}
}
break;
}
}
}
}
void free_ul_ref_sigs_NB_IoT(void)
{
unsigned int u,index_Nsc_RU;
for (index_Nsc_RU=0; index_Nsc_RU<4; index_Nsc_RU++) {
for (u=0; u<30; u++) {
if (ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU])
free16(ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU],4*sizeof(int16_t)*sequence_length[index_Nsc_RU]);
}
}
}
// void free_ul_ref_sigs(void)
// {
// unsigned int u,index_Nsc_RU;
// for (index_Nsc_RU=0; index_Nsc_RU<4; index_Nsc_RU++) {
// for (u=0; u<30; u++) {
// if (ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU])
// free16(ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU],4*sizeof(int16_t)*sequence_length[index_Nsc_RU]);
// }
// }
// }
#ifdef MAIN
main()
{
//generate_ul_ref_sigs();
generate_ul_ref_sigs_rx();
free_ul_ref_sigs();
}
#endif
/***********************************************************************
**********************************************************************/
/*! \file PHY/LTE_REFSIG/primary_synch_NB_IoT.c
* \Narrowband Primary Synchronisation Signal(NPSS) for NB-IoT, TS 36-212, V13.4.0 2017-02
* \author M. KANJ
* \date 2017
* \version 0.0
* \company bcom
* \email: matthieu.kanj@b-com.com
* \note
* \warning
*/
// 12x11= 132 RE ( x 2= 264 since Re,Img).
// For the In-band case: the RE dedicated to LTE pilots are supposed to overwrite 16 REs of the NPSS signal.
short primary_synch_NB_IoT[264] = {32767,0,-31440,-9232,-21458,-24764,-4664,32433,-31440,9231,13611,29805,-31440,9231,-4664,32433,-21458,-24764,-31440,-9232,32767,-1,0,0,32767,0,-31440,-9232,-21458,-24764,-4664,32433,-31440,9231,13611,29805,-31440,9231,-4664,32433,-21458,-24764,-31440,-9232,32767,-1,0,0,32767,0,-31440,-9232,-21458,-24764,-4664,32433,-31440,9231,13611,29805,-31440,9231,-4664,32433,-21458,-24764,-31440,-9232,32767,-1,0,0,32767,0,-31440,-9232,-21458,-24764,-4664,32433,-31440,9231,13611,29805,-31440,9231,-4664,32433,-21458,-24764,-31440,-9232,32767,-1,0,0,-32767,0,31439,9231,21457,24763,4663,-32434,31439,-9232,-13612,-29806,31439,-9232,4663,-32434,21457,24763,31439,9231,-32767,0,0,0,-32767,0,31439,9231,21457,24763,4663,-32434,31439,-9232,-13612,-29806,31439,-9232,4663,-32434,21457,24763,31439,9231,-32767,0,0,0,32767,0,-31440,-9232,-21458,-24764,-4664,32433,-31440,9231,13611,29805,-31440,9231,-4664,32433,-21458,-24764,-31440,-9232,32767,-1,0,0,32767,0,-31440,-9232,-21458,-24764,-4664,32433,-31440,9231,13611,29805,-31440,9231,-4664,32433,-21458,-24764,-31440,-9232,32767,-1,0,0,32767,0,-31440,-9232,-21458,-24764,-4664,32433,-31440,9231,13611,29805,-31440,9231,-4664,32433,-21458,-24764,-31440,-9232,32767,-1,0,0,-32767,0,31439,9231,21457,24763,4663,-32434,31439,-9232,-13612,-29806,31439,-9232,4663,-32434,21457,24763,31439,9231,-32767,0,0,0,32767,0,-31440,-9232,-21458,-24764,-4664,32433,-31440,9231,13611,29805,-31440,9231,-4664,32433,-21458,-24764,-31440,-9232,32767,-1,0,0};
......@@ -39,9 +39,9 @@
#include "PHY/impl_defs_lte_NB_IoT.h"
#include "defs_NB_IoT.h"
//#include "PHY/LTE_TRANSPORT/proto_NB_IoT.h"
//#include "PHY/CODING/defs_NB_IoT.h"
#include "PHY/CODING/defs_NB_IoT.h"
#include "PHY/defs_L1_NB_IoT.h" // /LTE_TRANSPORT/defs_NB_IoT.h
//#include "PHY/LTE_REFSIG/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"
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file PHY/LTE_TRANSPORT/dci_tools.c
* \brief PHY Support routines (eNB/UE) for filling PDSCH/PUSCH/DLSCH/ULSCH data structures based on DCI PDUs generated by eNB MAC scheduler.
* \author R. Knopp
* \date 2011
* \version 0.1
* \company Eurecom
* \email: knopp@eurecom.fr
* \note
* \warning
*/
//#include "PHY/defs.h"
#include "PHY/impl_defs_lte_NB_IoT.h"
#include "PHY/extern_NB_IoT.h"
//#include "PHY/LTE_TRANSPORT/extern_NB_IoT.h"
#include "defs_NB_IoT.h"
/*
#ifdef DEBUG_DCI_TOOLS
#include "PHY/vars_NB_IoT.h"
#endif
*/
//#include "assertions.h"
//#include "dlsch_tbs_full.h"
#include "dlsch_tbs_full_NB_IoT.h"
//#define DEBUG_HARQ
//#include "LAYER2/MAC/extern_NB_IoT.h"
//#include "LAYER2/MAC/defs_NB_IoT.h"
#include "PHY/defs_L1_NB_IoT.h"
//#define DEBUG_DCI
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)
{
//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->Num_dci++;
LOG_D(MAC,"add ue specific dci format %d for rnti %x \n",dci_fmt,rnti);
}
//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 Scheddly_less_128[8] = {0,4,8,12,16,32,64,128};
int Scheddly_bigger_128[8] = {0,16,32,64,128,256,512,1024};
int Irep_to_Nrep[16] = {1,2,4,8,16,32,64,128,192,256,384,512,768,1024,1536,2048};
int Idelay_to_K0(uint8_t Sched_delay, int Rmax)
{
int k0=0;
if(Rmax <128)
{
k0 = Scheddly_less_128[Sched_delay];
}else if(Rmax >=128)
{
k0 = Scheddly_bigger_128[Sched_delay];
}
return k0;
}
int DCIrep_to_real_rep(uint8_t DCI_rep, int Rmax)
{
int R=0;
if(Rmax == 1)
{
if(DCI_rep == 0)
R = 1;
}else if (Rmax == 2)
{
if(DCI_rep == 0)
R = 1;
else if(DCI_rep == 1)
R = 2;
}else if (Rmax == 4)
{
if(DCI_rep == 0)
R = 1;
else if(DCI_rep == 1)
R = 2;
else if(DCI_rep == 2)
R = 4;
}else if (Rmax >= 8)
{
if(DCI_rep == 0)
R = Rmax/8;
else if(DCI_rep == 1)
R = Rmax/4;
else if(DCI_rep == 2)
R = Rmax/2;
else if(DCI_rep == 3)
R = Rmax;
}
return R;
}
int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
int frame,
uint8_t subframe,
DCI_CONTENT *DCI_Content,
uint16_t rnti,
NB_IoT_eNB_NPDCCH_t *ndlcch,
uint8_t aggregation,
uint8_t npdcch_start_symbol,
uint8_t ncce_index)
{
int tmp = 0;
int i = 0;
uint8_t *DCI_flip = NULL;
ncce_index = 0;
/// type = 0 => DCI Format N0, type = 1 => DCI Format N1, 1 bits
uint8_t type;
/// Subcarrier indication, 6 bits
uint8_t scind;
/// Resourse Assignment (RU Assignment), 3 bits
uint8_t ResAssign;
/// Modulation and Coding Scheme, 4 bits
uint8_t mcs;
/// New Data Indicator, 1 bits
uint8_t ndi;
/// Scheduling Delay, 2 bits
uint8_t Scheddly;
/// Repetition Number, 3 bits
uint8_t RepNum;
/// Redundancy version for HARQ (only use 0 and 2), 1 bits
uint8_t rv;
/// DCI subframe repetition Number, 2 bits
uint8_t DCIRep;
type = DCI_Content->DCIN0.type;
scind = DCI_Content->DCIN0.scind;
ResAssign = DCI_Content->DCIN0.ResAssign;
mcs = DCI_Content->DCIN0.mcs;
ndi = DCI_Content->DCIN0.ndi;
Scheddly = DCI_Content->DCIN0.Scheddly;
RepNum = DCI_Content->DCIN0.RepNum;
rv = DCI_Content->DCIN0.rv;
DCIRep = DCI_Content->DCIN0.DCIRep;
/*Now configure the npdcch structure*/
// ndlcch->ncce_index = NCCE_index;
// ndlcch->aggregation_level = aggregation;
ndlcch->A[ncce_index] = sizeof_DCIN0_t; // number of bits in DCI
ndlcch->rnti[ncce_index] = rnti; //we store the RNTI (e.g. for RNTI will be used later)
ndlcch->active[ncce_index] = 1; //will be activated by the corresponding NDSLCH pdu
ndlcch->dci_repetitions[ncce_index] = DCIrep_to_real_rep(DCIRep,16); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax
printf("dci_repetitions: %d, A = %d\n",ndlcch->dci_repetitions[ncce_index],ndlcch->A[ncce_index]);
DCI_flip = (uint8_t*)malloc(3*sizeof(uint8_t));
for(i=0; i<3; ++i){
DCI_flip[i] = 0x0;
}
DCI_flip[0] = (type << 7) | (scind << 1) | (ResAssign>>2);
DCI_flip[1] = (uint8_t)(ResAssign << 6) | (Scheddly << 4) | mcs;
DCI_flip[2] = (rv << 7) | (RepNum << 4) | (ndi << 3) |(DCIRep <<1);
ndlcch->pdu[ncce_index] = DCI_flip;
printf("DCI N0 content:");
for (tmp =0;tmp<3;tmp++)
printf("%d ",DCI_flip[tmp]);
printf("\n");
/*
* TS 36.213 ch 16.4.1.5
* ITBS is always set equivalent to IMCS for data
* ISF = ResAssign
*/
ndlcch->counter_repetition_number[ncce_index] = DCIrep_to_real_rep(DCIRep,16); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax
LOG_I(PHY,"DCI packing for N0 done \n");
}
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_NPDCCH_t *ndlcch,
NB_IoT_DL_FRAME_PARMS *frame_parms,
uint8_t aggregation, //////????? maybe add the ncce index ??????????
uint8_t npdcch_start_symbol,
uint8_t ncce_index)
{
// NB_IoT_eNB_NPDCCH_t *ndlcch = ;
int tmp = 0;
int i = 0;
uint8_t *DCI_flip = NULL;
//N1 parameters
//uint8_t ncce_index = 0;
/// type = 0 => DCI Format N0, type = 1 => DCI Format N1, 1 bits
uint8_t type = 0;
//NPDCCH order indicator (set to 0),1 bits
uint8_t orderIndicator = 0;
// Scheduling Delay, 3 bits
uint8_t Sched_delay = 0;
// Resourse Assignment (RU Assignment), 3 bits
uint8_t ResAssign = 0;//Isf
// Modulation and Coding Scheme, 4 bits
uint8_t mcs = 0;
// Repetition Number, 4 bits
uint8_t RepNum = 0;
// DCI subframe repetition Number, 2 bits
uint8_t DCIRep = 0;
// New Data Indicator,1 bits
uint8_t ndi = 0;
// HARQ-ACK resource,4 bits
uint8_t HARQackRes = 0;
//N2 parameters
//Direct indication information, 8 bits
uint8_t directIndInf= 0;
// Reserved information bits, 6 bits
uint8_t resInfoBits =0;
// printf("Generate eNB DCI, format %d, rnti %x (pdu %p)\n",dci_format,rnti,dci_pdu);
switch (dci_format) {
// Impossible to have a DCI N0, we have condition before
case DCIFormatN0:
return(-1);
break;
case DCIFormatN1_RAR: // This is DLSCH allocation for control traffic (no NDI and no ACK/NACK resource for RAR DCI)
/*Packed DCI here-------------------------------------------*/
type = DCI_Content->DCIN1_RAR.type;
orderIndicator = DCI_Content->DCIN1_RAR.orderIndicator;
Sched_delay = DCI_Content->DCIN1_RAR.Scheddly;
ResAssign = DCI_Content->DCIN1_RAR.ResAssign;
mcs = DCI_Content->DCIN1_RAR.mcs;
RepNum = DCI_Content->DCIN1_RAR.RepNum;
ndi = DCI_Content->DCIN1_RAR.ndi;
HARQackRes = DCI_Content->DCIN1_RAR.HARQackRes;
DCIRep = DCI_Content->DCIN1_RAR.DCIRep;
/*Now configure the npdcch structure*/
// ndlcch->ncce_index = NCCE_index;
// ndlcch->aggregation_level = aggregation;
ndlcch->A[ncce_index] = sizeof_DCIN1_RAR_t; // number of bits in DCI
//ndlcch->subframe_tx[subframe] = 1; // check if it's OK
ndlcch->rnti[ncce_index] = rnti; //we store the RNTI (e.g. for RNTI will be used later)
ndlcch->active[ncce_index] = 1; //will be activated by the corresponding NDSLCH pdu
// use this value to configure PHY both harq_processes and resource mapping.
ndlcch->scheduling_delay[ncce_index] = Idelay_to_K0(Sched_delay,4);
ndlcch->resource_assignment[ncce_index] = resource_to_subframe[ResAssign]; //from Isf of DCI to the number of subframe
ndlcch->repetition_number[ncce_index] = Irep_to_Nrep[RepNum]; // repetition number for NPDSCH
ndlcch->dci_repetitions[ncce_index] = DCIrep_to_real_rep(DCIRep,4); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax
//printf("dci_repetitions: %d, A = %d\n",ndlcch->dci_repetitions[ncce_index],ndlcch->A[ncce_index]);
ndlcch->modulation[ncce_index] = 2; //QPSK
//// ////////////////////////////////////////////////if(ndlcch->round == 0) //this should be set from initialization (init-lte)
//ndlcch->status[ncce_index] = ACTIVE_NB_IoT;
ndlcch->mcs[ncce_index] = mcs;
DCI_flip = (uint8_t*)malloc(3*sizeof(uint8_t));
for(i=0; i<3; ++i){
DCI_flip[i] = 0x0;
}
DCI_flip[0] = (type << 7) | (orderIndicator << 6) | (Sched_delay<<2) | ResAssign ;
DCI_flip[1] = (mcs << 4) | RepNum;
DCI_flip[2] = (ndi << 7) | (HARQackRes << 3) | (DCIRep <<1);
ndlcch->pdu[ncce_index] = DCI_flip;
printf("DCI N1 RAR PDU content:");
for (tmp =0;tmp<3;tmp++)
printf("%d ",DCI_flip[tmp]);
printf("\n");
/*
* TS 36.213 ch 16.4.1.5
* ITBS is always set equivalent to IMCS for data
* ISF = ResAssign
*/
ndlcch->TBS[ncce_index] = TBStable_NB_IoT[mcs][ResAssign];
//ndlcch->subframe[ncce_index] = subframe;
ndlcch->counter_repetition_number[ncce_index] = DCIrep_to_real_rep(DCIRep,4); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax
//ndlsch_harq->B; we don-t have now my is given when we receive the dlsch data
//ndlsch->error_treshold
//ndlsch->G??
//ndlsc->nsoft?? //set in new_eNB_dlsch (initialization)
//ndlsch-> sqrt_rho_a?? set in dlsch_modulation
//ndlsch-> sqrt_rho_b??? set in dlsch_modulation
LOG_I(PHY,"DCI packing for N1RAR done \n");
//set in new_eNB_dlsch (initialization)
/*
* Mlimit
* nsoft
* round
*/
break;
case DCIFormatN1: // for user data
type = DCI_Content->DCIN1.type;
orderIndicator = DCI_Content->DCIN1.orderIndicator;
Sched_delay = DCI_Content->DCIN1.Scheddly;
ResAssign = DCI_Content->DCIN1.ResAssign;
mcs = DCI_Content->DCIN1.mcs;
RepNum = DCI_Content->DCIN1.RepNum;
ndi = DCI_Content->DCIN1.ndi;
HARQackRes = DCI_Content->DCIN1.HARQackRes;
DCIRep = DCI_Content->DCIN1.DCIRep;
//add_dci_NB_IoT(eNB->DCI_pdu,DLSCH_DCI_NB_IoT,rnti,sizeof(DCIN1_t),aggregation,sizeof_DCIN1_t,DCIFormatN1,npdcch_start_symbol);
/*Now configure the npdcch structure*/
ndlcch->A[ncce_index] = sizeof_DCIN1_t; // number of bits in DCI
// ndlcch->ncce_index = NCCE_index;
// ndlcch->aggregation_level = aggregation;
//ndlcch->subframe_tx[subframe] = 1; // check if it's OK
ndlcch->rnti[ncce_index] = rnti; //we store the RNTI (e.g. for RNTI will be used later)
ndlcch->active[ncce_index] = 1;//will be activated by the corresponding NDSLCH pdu
// use this value to configure PHY both harq_processes and resource mapping.
ndlcch->scheduling_delay[ncce_index] = Idelay_to_K0(Sched_delay,4);
ndlcch->resource_assignment[ncce_index] = resource_to_subframe[ResAssign]; //from Isf of DCI to the number of subframe
ndlcch->repetition_number[ncce_index] = Irep_to_Nrep[RepNum]; // repetition number for NPDSCH
ndlcch->dci_repetitions[ncce_index] = DCIrep_to_real_rep(DCIRep,4); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax
ndlcch->modulation[ncce_index] = 2; //QPSK
//if(ndlcch->round == 0){ //this should be set from initialization (init-lte)
//ndlcch->status[ncce_index] = ACTIVE_NB_IoT;
ndlcch->mcs[ncce_index] = mcs;
ndlcch->TBS[ncce_index] = TBStable_NB_IoT[mcs][ResAssign]; // this table should be rewritten for nb-iot
//ndlcch->pdu[ncce_index] = DLSCH_DCI_NB_IoT;
DCI_flip = (uint8_t*)malloc(3*sizeof(uint8_t));
for(i=0; i<3; ++i){
DCI_flip[i] = 0x0;
}
DCI_flip[0] = (type << 7) | (orderIndicator << 6) | (Sched_delay<<2) | ResAssign ;
DCI_flip[1] = (mcs << 4) | RepNum;
DCI_flip[2] = (ndi << 7) | (HARQackRes << 3) | (DCIRep <<1);
//DCI_flip[0] = 129;
//DCI_flip[0] = DCI_tmp[2]*2;
//DCI_flip[1] = DCI_tmp[1]*2;
//DCI_flip[2] = DCI_tmp[0]*2;
//DCI_flip[2] = 4;
ndlcch->pdu[ncce_index] = DCI_flip;
printf("DCI N1 PDU content:");
for (tmp =0;tmp<3;tmp++)
printf("%d ",DCI_flip[tmp]);
printf("\n");
ndlcch->counter_repetition_number[ncce_index] = DCIrep_to_real_rep(DCIRep,4); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax
//}
//ndlcch->frame[ncce_index] = frame;
//ndlcch->subframe[ncce_index] = subframe;
break;
case DCIFormatN2_Ind: //MP: for the moment is not implemented
type = DCI_Content->DCIN2_Ind.type;
directIndInf = DCI_Content->DCIN2_Ind.directIndInf;
resInfoBits = DCI_Content->DCIN2_Ind.resInfoBits;
//add_dci_NB_IoT(eNB->DCI_pdu,DLSCH_DCI_NB_IoT,rnti,sizeof(DCIN2_Ind_t),aggregation,sizeof_DCIN2_Ind_t,DCIFormatN2_Ind,npdcch_start_symbol);
// use this value to configure PHY both harq_processes and resource mapping.
break;
case DCIFormatN2_Pag: //MP: for the moment is not implemented
type = DCI_Content->DCIN2_Pag.type;
ResAssign = DCI_Content->DCIN2_Pag.ResAssign;
mcs = DCI_Content->DCIN2_Pag.mcs;
RepNum = DCI_Content->DCIN2_Pag.RepNum;
DCIRep = DCI_Content->DCIN2_Pag.DCIRep;
//add_dci_NB_IoT(eNB->DCI_pdu,DLSCH_DCI_NB_IoT,rnti,sizeof(DCIN2_Pag_t),aggregation,sizeof_DCIN2_Pag_t,DCIFormatN2_Pag,npdcch_start_symbol);
// use this value to configure PHY both harq_processes and resource mapping.
break;
default:
LOG_E(PHY,"Unknown DCI format\n");
return(-1);
break;
}
// compute DL power control parameters
//free(DLSCH_DCI_NB_IoT);
return(0);
}
uint8_t subframe2harq_pid_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t subframe)
{
//MAC_xface_NB_IoT *mac_xface_NB_IoT; //test_xface
/*
#ifdef DEBUG_DCI
if (frame_parms->frame_type == TDD)
printf("dci_tools.c: subframe2_harq_pid, subframe %d for TDD configuration %d\n",subframe,frame_parms->tdd_config);
else
printf("dci_tools.c: subframe2_harq_pid, subframe %d for FDD \n",subframe);
#endif
*/
uint8_t ret = 255;
if (frame_parms->frame_type == FDD) {
ret = (((frame<<1)+subframe)&7);
} else {
switch (frame_parms->tdd_config) {
case 1:
if ((subframe==2) ||
(subframe==3) ||
(subframe==7) ||
(subframe==8))
switch (subframe) {
case 2:
case 3:
ret = (subframe-2);
break;
case 7:
case 8:
ret = (subframe-5);
break;
default:
LOG_E(PHY,"subframe2_harq_pid_NB_IoT, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config);
ret = (255);
break;
}
break;
case 2:
if ((subframe!=2) && (subframe!=7)) {
LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config);
//mac_xface_NB_IoT->macphy_exit("subframe2_harq_pid_NB_IoT, Illegal subframe");
ret = (255);
}
ret = (subframe/7);
break;
case 3:
if ((subframe<2) || (subframe>4)) {
LOG_E(PHY,"subframe2_harq_pid_NB_IoT, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config);
ret = (255);
}
ret = (subframe-2);
break;
case 4:
if ((subframe<2) || (subframe>3)) {
LOG_E(PHY,"subframe2_harq_pid_NB_IoT, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config);
ret = (255);
}
ret = (subframe-2);
break;
case 5:
if (subframe!=2) {
LOG_E(PHY,"subframe2_harq_pid_NB_IoT, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config);
ret = (255);
}
ret = (subframe-2);
break;
default:
LOG_E(PHY,"subframe2_harq_pid_NB_IoT, Unsupported TDD mode %d\n",frame_parms->tdd_config);
ret = (255);
}
}
if (ret == 255) {
LOG_E(PHY, "invalid harq_pid(%d) at SFN/SF = %d/%d\n", ret, frame, subframe);
//mac_xface_NB_IoT->macphy_exit("invalid harq_pid");
}
return ret;
}
......@@ -33,8 +33,9 @@
//#include "PHY/defs.h"
//#include "PHY/extern.h"
#include "PHY/impl_defs_lte_NB_IoT.h"
#include "PHY/NBIoT_TRANSPORT/proto_NB_IoT.h"
#include "proto_NB_IoT.h"
#include "PHY/NBIoT_TRANSPORT/extern_NB_IoT.h"
#include "vars_NB_IoT.h"
uint8_t get_Qm_UL_NB_IoT(unsigned char I_mcs, uint8_t N_sc_RU, uint8_t I_sc, uint8_t Msg3_flag)
......
/* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file PHY/LTE_TRANSPORT/npbch_NB_IoT.c
* \Fucntions for the generation of broadcast channel (NPBCH) for NB_IoT, TS 36-212, V13.4.0 2017-02
* \author M. KANJ, V. Savaux
* \date 2017
* \version 0.0
* \company bcom
* \email: matthieu.kanj@b-com.com , vincent.savaux@b-com.com
* \note
* \warning
*/
//#include "PHY/defs.h"
//#include "PHY/defs_NB_IoT.h"
//#include "PHY/CODING/extern.h"
//#include "PHY/CODING/lte_interleaver_inline.h"
//#include "extern_NB_IoT.h"
//#include "PHY/extern_NB_IoT.h"
//#include "PHY/sse_intrin.h"
#include "PHY/NBIoT_TRANSPORT/defs_NB_IoT.h"
#include "PHY/NBIoT_TRANSPORT/proto_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"
//#include "PHY/impl_defs_lte.h"
//#ifdef PHY_ABSTRACTION
//#include "SIMULATION/TOOLS/defs.h"
//#endif
//#ifdef OPENAIR2
//#include "PHY_INTERFACE/defs.h"
//#endif
#define NPBCH_A 34 // 34 for NB-IoT and 24 for LTE
int scrambling_npbch_REs_rel_13_5_0(NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **txdataF,
uint32_t *jj,
int l,
uint32_t symbol_offset,
uint8_t pilots,
unsigned short id_offset,
uint8_t *reset,
uint32_t *x1,
uint32_t *x2,
uint32_t *s,
uint8_t *flag_32)
{
uint32_t tti_offset,aa;
uint8_t re;
uint8_t first_re,last_re;
uint8_t c_even,c_odd;
int16_t theta_re,theta_im;
int16_t data_re[frame_parms->nb_antennas_tx],data_im[frame_parms->nb_antennas_tx];
uint32_t mem_jj=0;
first_re = 0;
last_re = 12;
for (re=first_re; re<last_re; re++) { // re varies between 0 and 12 sub-carriers
if ((*jj)%32 == 0 && *flag_32 == 0){
*s = lte_gold_generic_NB_IoT(x1, x2, *reset);
*reset = 0;
mem_jj = *jj;
}
c_even = (*s>>*jj)&1;
c_odd = (*s>>(*jj+1))&1;
if (c_even == c_odd){
if(c_even){
theta_re = 0;
theta_im = -32767;
}else{
theta_re = 32767;
theta_im = 0;
}
}else{
if(c_even){
theta_re = 0;
theta_im = 32767;
}else{
theta_re = -32767;
theta_im = 0;
}
}
tti_offset = symbol_offset + re; // symbol_offset = 512 * L , re_offset = 512 - 3*12 , re
if (pilots != 1 || re%3 != id_offset) // if re is not a pilot
{
for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
data_re[aa] = ((int16_t*)&txdataF[aa][tti_offset])[0];
data_im[aa] = ((int16_t*)&txdataF[aa][tti_offset])[1];
}
for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
((int16_t*)&txdataF[aa][tti_offset])[0] = (int16_t) (((int32_t) data_re[aa] * (int32_t) theta_re -
(int32_t) data_im[aa] * (int32_t) theta_im)>>15); //I //b_i
((int16_t*)&txdataF[aa][tti_offset])[1] = (int16_t) (((int32_t) data_im[aa] * (int32_t) theta_re +
(int32_t) data_re[aa] * (int32_t) theta_im)>>15); //Q //b_{i+1}
}
*jj = *jj + 2;
}
if (mem_jj == *jj) // avoid to shift lte_gold_generic_NB_IoT 2 times
{*flag_32 = 1;
}else
{*flag_32 = 0;
}
}
return(0);
}
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) // not used variable ??!!
{
MIMO_mode_t mimo_mode = (frame_parms->mode1_flag==1)?SISO:ALAMOUTI;
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;
for (re=first_re; re<last_re; re++) { // re varies between 0 and 12 sub-carriers
tti_offset = symbol_offset + re; // symbol_offset = 512 * L , re_offset = 512 - 3*12 , re
if (pilots != 1 || re%3 != id_offset) // if re is not a pilot
{
// diff_re = re%3 - id_offset;
if (mimo_mode == SISO) { //SISO mapping
*re_allocated = *re_allocated + 1; // variable incremented but never used
for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
((int16_t*)&txdataF[aa][tti_offset])[0] += (x0[*jj]==1) ? (-gain_lin_QPSK) : gain_lin_QPSK; //I //b_i
}
*jj = *jj + 1;
for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
((int16_t*)&txdataF[aa][tti_offset])[1] += (x0[*jj]==1) ? (-gain_lin_QPSK) : gain_lin_QPSK; //Q //b_{i+1}
}
*jj = *jj + 1;
} else if (mimo_mode == ALAMOUTI) {
*re_allocated = *re_allocated + 1;
((int16_t*)&tmp_sample1)[0] = (x0[*jj]==1) ? (-gain_lin_QPSK) : gain_lin_QPSK;
*jj=*jj+1;
((int16_t*)&tmp_sample1)[1] = (x0[*jj]==1) ? (-gain_lin_QPSK) : gain_lin_QPSK;
*jj=*jj+1;
// second antenna position n -> -x1*
((int16_t*)&tmp_sample2)[0] = (x0[*jj]==1) ? (gain_lin_QPSK) : -gain_lin_QPSK;
*jj=*jj+1;
((int16_t*)&tmp_sample2)[1] = (x0[*jj]==1) ? (-gain_lin_QPSK) : gain_lin_QPSK;
*jj=*jj+1;
// normalization for 2 tx antennas
((int16_t*)&txdataF[0][tti_offset])[0] += (int16_t)((((int16_t*)&tmp_sample1)[0]*ONE_OVER_SQRT2_Q15_NB_IoT)>>15);
((int16_t*)&txdataF[0][tti_offset])[1] += (int16_t)((((int16_t*)&tmp_sample1)[1]*ONE_OVER_SQRT2_Q15_NB_IoT)>>15);
((int16_t*)&txdataF[1][tti_offset])[0] += (int16_t)((((int16_t*)&tmp_sample2)[0]*ONE_OVER_SQRT2_Q15_NB_IoT)>>15);
((int16_t*)&txdataF[1][tti_offset])[1] += (int16_t)((((int16_t*)&tmp_sample2)[1]*ONE_OVER_SQRT2_Q15_NB_IoT)>>15);
// fill in the rest of the ALAMOUTI precoding
if ( pilots != 1 || (re+1)%3 != id_offset) {
((int16_t *)&txdataF[0][tti_offset+1])[0] += -((int16_t *)&txdataF[1][tti_offset])[0]; //x1
((int16_t *)&txdataF[0][tti_offset+1])[1] += ((int16_t *)&txdataF[1][tti_offset])[1];
((int16_t *)&txdataF[1][tti_offset+1])[0] += ((int16_t *)&txdataF[0][tti_offset])[0]; //x0*
((int16_t *)&txdataF[1][tti_offset+1])[1] += -((int16_t *)&txdataF[0][tti_offset])[1];
} else {
((int16_t *)&txdataF[0][tti_offset+2])[0] += -((int16_t *)&txdataF[1][tti_offset])[0]; //x1
((int16_t *)&txdataF[0][tti_offset+2])[1] += ((int16_t *)&txdataF[1][tti_offset])[1];
((int16_t *)&txdataF[1][tti_offset+2])[0] += ((int16_t *)&txdataF[0][tti_offset])[0]; //x0*
((int16_t *)&txdataF[1][tti_offset+2])[1] += -((int16_t *)&txdataF[0][tti_offset])[1];
re++; // skip pilots
*re_allocated = *re_allocated + 1;
}
re++; // adjacent carriers are taken care of by precoding
*re_allocated = *re_allocated + 1; // incremented variable but never used
}
}
}
return(0);
}
/**********************************************************
**********************************************************/
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,
uint8_t release_v13_5_0)
{
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;
///////////////////////////// for release 13.5.0 and above ////////////////////////
uint32_t ii=0;
uint8_t reset=1,flag_32=0;
uint32_t x1_v13_5_0, x2_v13_5_0 =0, s_v13_5_0 =0;
x2_v13_5_0 = (((frame_parms->Nid_cell+1) * (frame_mod64%8 + 1) * (frame_mod64%8 + 1) * (frame_mod64%8 + 1)) <<9) + frame_parms->Nid_cell;
//////////////////////////////////////////////////////////////////////////////////
frame_parms->flag_free_sf =1;
npbch_D = 16 + NPBCH_A;
npbch_E = 1600;
if (frame_mod64==0) {
bzero(npbch_a,5); // initializing input data stream , filling with zeros
bzero(eNB_npbch->npbch_e,npbch_E); // filling with "0" the table pbch_e[1600]
memset(eNB_npbch->npbch_d,LTE_NULL_NB_IoT,96); // filling with "2" the first 96 elements of table pbch_d[216]
for (i=0; i<5; i++) // set input bits stream
{
npbch_a[i] = npbch_pdu[i]; // in LTE 24 bits with 3 bytes, but in NB_IoT 34 bits will require 4 bytes+2 bits !! to verify
}
if (frame_parms->mode1_flag == 1) // setting CRC mask depending on the number of used eNB antennas
amask = 0x0000;
else {
switch (frame_parms->nb_antennas_tx) { // *****???? better replacing nb_antennas_tx_eNB by nb_antennas_tx_eNB_NB_IoT
case 1:
amask = 0x0000;
break;
case 2:
amask = 0xffff;
break;
}
}
ccode_encode_NB_IoT(NPBCH_A,2,npbch_a,eNB_npbch->npbch_d+96,amask); // step 1 CRC Attachment
RCC = sub_block_interleaving_cc_NB_IoT(npbch_D,eNB_npbch->npbch_d+96,eNB_npbch->npbch_w); // step 2 Channel Coding
lte_rate_matching_cc_NB_IoT(RCC,npbch_E,eNB_npbch->npbch_w,eNB_npbch->npbch_e); // step 3 Rate Matching
npbch_scrambling(frame_parms, // step 4 Scrambling
eNB_npbch->npbch_e,
npbch_E);
}
// testing if the total number of RBs is even or odd
bandwidth_even_odd = frame_parms->N_RB_DL % 2; // 0 even, 1 odd
RB_IoT_ID = NB_IoT_RB_ID;
// step 5, 6, 7 // modulation and mapping (slot 1, symbols 0..3)
for (l=3; l<14; l++) { // loop on OFDM symbols
if((l>=4 && l<=8) || (l>=11 && l<=13))
{
pilots =1;
} else {
pilots=0;
}
id_offset = frame_parms->Nid_cell % 3; // Cell_ID_NB_IoT % 3
if(RB_IoT_ID < (frame_parms->N_RB_DL/2))
{
NB_IoT_start = frame_parms->ofdm_symbol_size - 12*(frame_parms->N_RB_DL/2) - (bandwidth_even_odd*6) + 12*(RB_IoT_ID%(int)(ceil(frame_parms->N_RB_DL/(float)2)));
} else {
NB_IoT_start = 1 + (bandwidth_even_odd*6) + 12*(RB_IoT_ID%(int)(ceil(frame_parms->N_RB_DL/(float)2)));
}
symbol_offset = frame_parms->ofdm_symbol_size*l + NB_IoT_start; // symbol_offset = 512 * L + NB_IOT_RB start
allocate_npbch_REs_in_RB(frame_parms,
txdataF,
&jj,
symbol_offset,
&eNB_npbch->npbch_e[(frame_mod64/8)*(npbch_E>>3)],
pilots,
amp,
id_offset,
&re_allocated);
if(release_v13_5_0 == 1)
{
scrambling_npbch_REs_rel_13_5_0(frame_parms,
txdataF,
&ii,
l,
symbol_offset,
pilots,
id_offset,
&reset,
&x1_v13_5_0,
&x2_v13_5_0,
&s_v13_5_0,
&flag_32);
}
}
return(0);
}
/**********************************************************
**********************************************************/
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;
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;
}
npbch_e[i] = (npbch_e[i]&1) ^ ((s>>(i&0x1f))&1);
}
}
/* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file PHY/LTE_TRANSPORT/npss_NB_IoT.c
* \Generation of Narrowband Primary Synchronisation Signal(NPSS) for NB-IoT, TS 36-212, V13.4.0 2017-02
* \author M. KANJ
* \date 2017
* \version 0.0
* \company bcom
* \email: matthieu.kanj@b-com.com
* \note
* \warning
*/
//#include "PHY/defs.h"
///////////////#include "PHY/defs_nb_iot.h"
//#include "PHY/extern.h"
#include <math.h>
#include "proto_NB_IoT.h"
#include "PHY/impl_defs_lte_NB_IoT.h"
//#include "PHY/impl_defs_top_NB_IoT.h"
//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
{
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;
frame_parms->flag_free_sf =1;
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
a = (frame_parms->nb_antennas_tx == 1) ? amp: (amp*ONE_OVER_SQRT2_Q15_NB_IoT)>>15;
// Testing if the total number of RBs is even or odd (i.e. Identification of the bandwidth: 1.4, 3, 5, 10, ... MHz)
bandwidth_even_odd = frame_parms->N_RB_DL % 2; // 0 for even, 1 for odd
for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
if(RB_IoT_ID < (frame_parms->N_RB_DL/2))
{
NB_IoT_start = frame_parms->ofdm_symbol_size - 12*(frame_parms->N_RB_DL/2) - (bandwidth_even_odd*6) + 12*(RB_IoT_ID%(int)(ceil(frame_parms->N_RB_DL/(float)2)));
} else {
NB_IoT_start = 1 + (bandwidth_even_odd*6) + 12*(RB_IoT_ID%(int)(ceil(frame_parms->N_RB_DL/(float)2)));
}
// For the In-band or Stand-alone case the REs of NPSS signal have the same positions
for (s=0; s<11; s++ ) // loop on OFDM symbols
{
for (c=0; c<12; c++) { // loop on NB-IoT carriers
((short*)txdataF[aa])[2*( (slot_id*7*frame_parms->ofdm_symbol_size) + ((symbol_offset+s)*frame_parms->ofdm_symbol_size) + NB_IoT_start + c )] =
(a * primary_sync[2*c + (2*12*s)]) >> 15;
((short*)txdataF[aa])[2*( (slot_id*7*frame_parms->ofdm_symbol_size) + ((symbol_offset+s)*frame_parms->ofdm_symbol_size) + NB_IoT_start + c )+1] =
(a * primary_sync[2*c + (2*12*s) + 1]) >> 15;
}
}
}
return(0);
}
// int generate_npss_NB_IoT(int32_t **txdataF,
// short amp,
// LTE_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 UL_RB_ID_NB_IoT; // index of the NB-IoT RB
// unsigned char poffset=0, pilot=0; // poffset: base frequency offset of pilots; pilot: LTE pilot flag
// UL_RB_ID_NB_IoT = frame_parms->NB_IoT_RB_ID; // index of RB dedicated to NB-IoT
// 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
// a = (frame_parms->nb_antennas_tx == 1) ? amp: (amp*ONE_OVER_SQRT2_Q15_NB_IoT)>>15;
// // Testing if the total number of RBs is even or odd (i.e. Identification of the bandwidth: 1.4, 3, 5, 10, ... MHz)
// bandwidth_even_odd = frame_parms->N_RB_DL % 2; // 0 for even, 1 for odd
// for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
// if(RB_IoT_ID < (frame_parms->N_RB_DL/2))
// { // RB in first half (below DC)
// // NB_IoT_start = frame_parms->ofdm_symbol_size - 12*(frame_parms->N_RB_DL/2) - (bandwidth_even_odd*6) + 12*(RB_IoT_ID%(int)(ceil(frame_parms->N_RB_DL/(float)2)));
// NB_IoT_start = UL_RB_ID_NB_IoT*12 + frame_parms->first_carrier_offset;
// } else { // RB in the second half (above DC): DC is taken into account
// // NB_IoT_start = 1+ (bandwidth_even_odd*6) + 12*(RB_IoT_ID%(int)(ceil(frame_parms->N_RB_DL/(float)2)));
// NB_IoT_start = 1 + bandwidth_even_odd*6 + 6*(2*UL_RB_ID_NB_IoT - (frame_parms->N_RB_DL+bandwidth_even_odd));
// }
// // For the In-band or Stand-alone case the REs of NPSS signal have the same positions
// for (s=0; s<11; s++ ) // loop on OFDM symbols
// {
// // CRS (LTE pilot) position within subframe in time
// // Note that pilot position takes into account symbol_offset value
// if (frame_parms->mode1_flag==1){ // SISO mode
// if (s==1 || s==4 || s==8){
// pilot = 1;
// if (s==1 || s==8){
// poffset = 3;
// }
// }
// }
// if (pilot == 0){
// for (c=0; c<12; c++) { // loop on NB-IoT carriers
// ((short*)txdataF[aa])[2*( (slot_id*7*frame_parms->ofdm_symbol_size) + ((symbol_offset+s)*frame_parms->ofdm_symbol_size) + NB_IoT_start + c )] =
// (a * primary_sync[2*c + (2*12*s)]) >> 15;
// ((short*)txdataF[aa])[2*( (slot_id*7*frame_parms->ofdm_symbol_size) + ((symbol_offset+s)*frame_parms->ofdm_symbol_size) + NB_IoT_start + c )+1] =
// (a * primary_sync[2*c + (2*12*s) + 1]) >> 15;
// }
// }
// else{
// for (c=0; c<12; c++) { // loop on NB-IoT carriers
// if ((c!=(frame_parms->nushift+poffset)) &&
// (c!=((frame_parms->nushift+poffset+6)%12)))
// {
// ((short*)txdataF[aa])[2*( (slot_id*7*frame_parms->ofdm_symbol_size) + ((symbol_offset+s)*frame_parms->ofdm_symbol_size) + NB_IoT_start + c )] =
// (a * primary_sync[2*c + (2*12*s)]) >> 15;
// ((short*)txdataF[aa])[2*( (slot_id*7*frame_parms->ofdm_symbol_size) + ((symbol_offset+s)*frame_parms->ofdm_symbol_size) + NB_IoT_start + c )+1] =
// (a * primary_sync[2*c + (2*12*s) + 1]) >> 15;
// }
// }
// }
// pilot = 0;
// poffset = 0;
// }
// }
// return(0);
// }
/* (for LTE)
int generate_pss_emul(PHY_VARS_eNB_NB_IoT *phy_vars_eNb,uint8_t sect_id)
{
msg("[PHY] EMUL eNB generate_pss_emul eNB %d, sect_id %d\n",phy_vars_eNb->Mod_id,sect_id);
eNB_transport_info[phy_vars_eNb->Mod_id][phy_vars_eNb->CC_id].cntl.pss=sect_id;
return(0);
}
*/
/* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file PHY/LTE_TRANSPORT/nsss_NB_IoT.c
* \Generation of Narrowband Secondary Synchronisation Signal(NSSS) for NB-IoT, TS 36-212, V13.4.0 2017-02
* \author M. KANJ
* \date 2017
* \version 0.0
* \company bcom
* \email: matthieu.kanj@b-com.com
* \note
* \warning
*/
//#include <math.h>
#include "PHY/defs_L1_NB_IoT.h"
#include "proto_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/extern.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
{
uint8_t aa,Nid2,f,q,s,c,u;
int16_t *d;
uint16_t n_f,Nid_NB_IoT;
unsigned short a;
uint16_t slot_id; // slot_id = 17 in NB_IoT
unsigned short bandwidth_even_odd;
unsigned short NB_IoT_start;
frame_parms->flag_free_sf =1;
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
q = Nid_NB_IoT/126; // q = 0, 1, 2, 3
u = (Nid_NB_IoT % 126);
Nid2 = q*4 + f; // Nid2 = 0..15
switch (Nid2) {
case 0:
d = d0f0;
break;
case 1:
d = d0f1;
break;
case 2:
d = d0f2;
break;
case 3:
d = d0f3;
break;
case 4:
d = d1f0;
break;
case 5:
d = d1f1;
break;
case 6:
d = d1f2;
break;
case 7:
d = d1f3;
break;
case 8:
d = d2f0;
break;
case 9:
d = d2f1;
break;
case 10:
d = d2f2;
break;
case 11:
d = d2f3;
case 12:
d = d3f0;
break;
case 13:
d = d3f1;
break;
case 14:
d = d3f2;
break;
case 15:
d = d3f3;
break;
default:
msg("[NSSS] ERROR\n");
return(-1);
}
slot_id = slot_offset;
// Signal amplitude
a = (frame_parms->nb_antennas_tx == 1) ? amp: (amp*ONE_OVER_SQRT2_Q15_NB_IoT)>>15;
// Testing if the total number of RBs is even or odd (i.e. Identification of the bandwidth: 1.4, 3, 5, 10, ... MHz)
bandwidth_even_odd = frame_parms->N_RB_DL % 2; // 0 even, 1 odd
for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
if(RB_IoT_ID < (frame_parms->N_RB_DL/2))
{
NB_IoT_start = frame_parms->ofdm_symbol_size - 12*(frame_parms->N_RB_DL/2) - (bandwidth_even_odd*6) + 12*(RB_IoT_ID%(int)(ceil(frame_parms->N_RB_DL/(float)2)));
} else {
NB_IoT_start = 1 + (bandwidth_even_odd*6) + 12*(RB_IoT_ID%(int)(ceil(frame_parms->N_RB_DL/(float)2)));
}
// For the In-band or Stand-alone case the REs of NPSS signal have the same positions
for (s=0; s<11; s++ ) // loop on OFDM symbols
{
for (c=0; c<12; c++) { // loop on NB-IoT carriers
((short*)txdataF[aa])[2*( (slot_id*7*frame_parms->ofdm_symbol_size) + ((symbol_offset+s)*frame_parms->ofdm_symbol_size) + NB_IoT_start + c )] =
(a * d[(2*u*132) + (2*c) + (2*s*12) ]) >> 15;
((short*)txdataF[aa])[2*( (slot_id*7*frame_parms->ofdm_symbol_size) + ((symbol_offset+s)*frame_parms->ofdm_symbol_size) + NB_IoT_start + c )+1] =
(a * d[(2*u*132) + (2*c) + (2*s*12) + 1]) >> 15;
}
}
}
return(0);
}
int rx_nsss_NB_IoT(PHY_VARS_UE_NB_IoT *ue,int32_t *tot_metric)
{
uint8_t Nid2,q_est,u_est;
NB_IoT_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
int l,k,m;
int toto=0;
int16_t *d, *nsss_sf;
int32_t nsss_ext[2][132]; // up to 2 rx antennas ?
int32_t metric; // correlation metric
// we suppose we are in NSSS subframe, after DFT
// this could be changed in further version
for (l=0;l<11;l++){
toto = nsss_extract_NB_IoT(ue,frame_parms,nsss_ext,l);
}
// now do the Cell ID estimation based on the precomputed sequences in PHY/LTE_TRANSPORT/nsss_NB_IoT.h
*tot_metric = -99999999;
nsss_sf = (int16_t*)&nsss_ext[0][0];
for (Nid2=0;Nid2<16;Nid2++){
switch (Nid2) {
case 0:
d = d0f0;
break;
case 1:
d = d0f1;
break;
case 2:
d = d0f2;
break;
case 3:
d = d0f3;
break;
case 4:
d = d1f0;
break;
case 5:
d = d1f1;
break;
case 6:
d = d1f2;
break;
case 7:
d = d1f3;
break;
case 8:
d = d2f0;
break;
case 9:
d = d2f1;
break;
case 10:
d = d2f2;
break;
case 11:
d = d2f3;
case 12:
d = d3f0;
break;
case 13:
d = d3f1;
break;
case 14:
d = d3f2;
break;
case 15:
d = d3f3;
break;
default:
msg("[NSSS] ERROR\n");
return(-1);
}
for (k=0;k<126;k++){ // corresponds to u in standard
metric = 0;
for (m=0;m<132;m++){ // 132 resource elements in NSSS subframe
metric += (int32_t)d[(k*126+m)<<1] * (int32_t)nsss_sf[(k*126+m)<<1] +
(int32_t)d[((k*126+m)<<1)+1] * (int32_t)nsss_sf[((k*126+m)<<1)+1]; // real part of correlation
}
if (metric > *tot_metric){
q_est = Nid2/4;
u_est = k;
ue->frame_parms.Nid_cell = q_est*126 + u_est;
}
}
}
return(0);
}
int nsss_extract_NB_IoT(PHY_VARS_UE_NB_IoT *ue,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **nsss_ext,
int l)
{
uint8_t i,aarx;
unsigned short UL_RB_ID_NB_IoT; // index of RB dedicated to NB-IoT
int32_t *nsss_rxF,*nsssF_ext;
int32_t **rxdataF;
int first_symbol_offset = 3; // NSSS starts at third symbol in subframe
UL_RB_ID_NB_IoT = frame_parms->NB_IoT_RB_ID;
for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
rxdataF = ue->common_vars.common_vars_rx_data_per_thread[0].rxdataF; // Note that
nsssF_ext = &nsss_ext[aarx][l*12];
if (UL_RB_ID_NB_IoT <= (frame_parms->N_RB_DL>>1)) { // NB-IoT RB is in the first half
nsss_rxF = &rxdataF[aarx][(UL_RB_ID_NB_IoT*12 + frame_parms->first_carrier_offset + ((l+first_symbol_offset)*(frame_parms->ofdm_symbol_size)))];
}// For second half of RBs skip DC carrier
else{ // NB-IoT RB is in the second half
nsss_rxF = &rxdataF[aarx][(1 + 6*(2*UL_RB_ID_NB_IoT - frame_parms->N_RB_DL) + ((l+first_symbol_offset)*(frame_parms->ofdm_symbol_size)))];
//dl_ch0++;
}
for (i=0; i<12; i++) {
nsssF_ext[i]=nsss_rxF[i];
}
}
return(0);
}
/***********************************************************************
**********************************************************************/
/*! \file PHY/LTE_TRANSPORT/pilots_NB_IoT.c
* \Generation of Reference signal (RS) for NB-IoT, TS 36-211, V13.4.0 2017-02
* \author M. KANJ
* \date 2017
* \version 0.0
* \company bcom
* \email: matthieu.kanj@b-com.com
* \note
* \warning
*/
#include "PHY/defs_eNB.h"
//#include "PHY/defs.h"
//#include "PHY/defs_NB_IoT.h"
#include "PHY/impl_defs_lte_NB_IoT.h"
#include "PHY/LTE_REFSIG/defs_NB_IoT.h"
#include "proto_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 = 0..9
unsigned short RB_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;
uint16_t subframe = Ntti;
uint32_t tti_offset,slot_offset,Nsymb,samples_per_symbol; // tti,
uint8_t first_pilot,second_pilot;
unsigned short RB_IoT_ID = RB_ID;
Nsymb = 14;
first_pilot = 5; // first pilot position
second_pilot = 6; // second pilot position
slot_offset = (Ntti*2)%20;
if(subframe !=5 && ((With_NSSS*subframe)!= 9) ) // condition to avoid NPSS and NSSS signals
{
tti_offset = subframe*frame_parms->ofdm_symbol_size*Nsymb; // begins with 0
samples_per_symbol = frame_parms->ofdm_symbol_size; // ex. 512
//Generate Pilots for slot 0 and 1
//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,
slot_offset,
0,
0,
RB_IoT_ID);
//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,
slot_offset,
1,
0,
RB_IoT_ID);
//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,
1+slot_offset,
0,
0,
RB_IoT_ID);
//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,
1+slot_offset,
1,
0,
RB_IoT_ID);
if (frame_parms->nb_antennas_tx > 1) { // Pilots generation with two antennas
// 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,
slot_offset,
0,
1,
RB_IoT_ID);
// 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,
slot_offset,
1,
1,
RB_IoT_ID);
//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,
1+slot_offset,
0,
1,
RB_IoT_ID);
// 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,
1+slot_offset,
1,
1,
RB_IoT_ID);
}
}
}
//////////////////////////////////////////////////////
/*
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
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
samples_per_symbol = frame_parms->ofdm_symbol_size; // ex. 512
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
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);
//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);
//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);
//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);
if (frame_parms->nb_antennas_tx > 1) { // Pilots generation with two antennas
// 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);
// 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);
//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);
// 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);
}
}
}
}
*/
\ No newline at end of file
......@@ -32,8 +32,8 @@
* \note
* \warning
*/
#ifndef __LTE_TRANSPORT_PROTO_NB_IOT__H__
#define __LTE_TRANSPORT_PROTO_NB_IOT__H__
#ifndef __NBIOT_TRANSPORT_PROTO__H__
#define __NBIOT_TRANSPORT_PROTO__H__
#include "PHY/defs_L1_NB_IoT.h"
#include "PHY/impl_defs_lte.h"
......
......@@ -35,6 +35,7 @@
#include "defs_NB_IoT.h"
#include "extern_NB_IoT.h"
#include "PHY/CODING/lte_interleaver2.h"
#include "../CODING/defs.h"
#include "PHY/CODING/coding_extern.h"
#include "PHY/LTE_REFSIG/lte_refsig.h"
//#define DEBUG_ULSCH
......
......@@ -103,6 +103,7 @@
#define NB_BANDS_MAX_NB_IoT 8
#define bzero(s,n) (memset((s),0,(n)))
#ifdef OCP_FRAMEWORK
#include <enums.h>
......@@ -729,7 +730,7 @@ typedef struct PHY_VARS_eNB_NB_IoT_s {
//TODO: check what should be NUMBER_OF_UE_MAX_NB_IoT value
NB_IoT_eNB_NPBCH_t *npbch;
NB_IoT_eNB_NPDCCH_t *npdcch[NUMBER_OF_UE_MAX_NB_IoT];
NB_IoT_eNB_NDLSCH_t *ndlsch[NUMBER_OF_UE_MAX_NB_IoT][2];
NB_IoT_eNB_NDLSCH_t *ndlsch[NUMBER_OF_UE_MAX_NB_IoT];
NB_IoT_eNB_NULSCH_t *ulsch_NB_IoT[NUMBER_OF_UE_MAX_NB_IoT+1]; //nulsch[0] contains the RAR
NB_IoT_eNB_NDLSCH_t *ndlsch_SI,*ndlsch_ra, *ndlsch_SIB1;
......
......@@ -1188,5 +1188,217 @@ static inline int release_thread(pthread_mutex_t *mutex,int *instance_cnt,char *
return(0);
}
typedef struct {
/// Component Carrier index
uint8_t CC_id;
/// timestamp transmitted to HW
openair0_timestamp timestamp_tx;
/// subframe to act upon for transmission
int subframe_tx;
/// subframe to act upon for reception
int subframe_rx;
/// frame to act upon for transmission
int frame_tx;
/// frame to act upon for reception
int frame_rx;
uint16_t HFN;
/// \brief Instance count for RXn-TXnp4 processing thread.
/// \internal This variable is protected by \ref mutex_rxtx.
int instance_cnt_rxtx;
/// pthread structure for RXn-TXnp4 processing thread
pthread_t pthread_rxtx;
/// pthread attributes for RXn-TXnp4 processing thread
pthread_attr_t attr_rxtx;
/// condition variable for tx processing thread
pthread_cond_t cond_rxtx;
/// mutex for RXn-TXnp4 processing thread
pthread_mutex_t mutex_rxtx;
/// scheduling parameters for RXn-TXnp4 thread
struct sched_param sched_param_rxtx;
uint32_t ra_rnti_computed;
uint8_t dci_to_transmit;
uint32_t frame_dscr_msg3;
uint32_t subframe_dscr_msg3;
uint32_t frame_msg5;
uint32_t subframe_msg5;
uint8_t rar_to_transmit;
uint8_t subframe_SP;
uint8_t subframe_SP2;
int next_frame_tx;
int next_subframe_tx;
uint8_t SP;
uint8_t SP2;
uint8_t there_is_sib23;
int next_frame_tx_DCI;
int next_subframe_tx_DCI;
int subframe_delay;
int subframe_real;
uint32_t sheduling_info_rar;
uint8_t flag_scrambling;
uint8_t flag_msg3;
uint8_t counter_msg3;
uint32_t frame_msg3;
uint8_t flag_DCI_msg4;
uint8_t flag_msg4;
uint8_t counter_DCI_msg4;
uint8_t counter_msg4;
uint32_t frame_DCI_msg4;
uint32_t frame_msg4;
uint32_t subframe_DCI_msg4;
uint32_t subframe_msg4;
uint8_t guard;
uint8_t counter_msg5;
uint8_t remaining_dci;
uint8_t remaining_rar;
uint8_t flag_msg5;
uint32_t frame_dscr_msg5;
uint32_t subframe_dscr_msg5;
} eNB_rxtx_proc_NB_IOT_t;
/// Context data structure for eNB subframe processing
typedef struct eNB_proc_t_s {
/// Component Carrier index
uint8_t CC_id;
/// thread index
int thread_index;
/// timestamp received from HW
openair0_timestamp timestamp_rx;
/// timestamp to send to "slave rru"
openair0_timestamp timestamp_tx;
/// subframe to act upon for reception
int subframe_rx;
/// symbol mask for IF4p5 reception per subframe
uint32_t symbol_mask[10];
/// subframe to act upon for PRACH
int subframe_prach;
/// frame to act upon for reception
int frame_rx;
/// frame to act upon for transmission
int frame_tx;
/// frame offset for secondary eNBs (to correct for frame asynchronism at startup)
int frame_offset;
/// frame to act upon for PRACH
int frame_prach;
/// \internal This variable is protected by \ref mutex_fep.
int instance_cnt_fep;
/// \internal This variable is protected by \ref mutex_td.
int instance_cnt_td;
/// \internal This variable is protected by \ref mutex_te.
int instance_cnt_te;
/// \brief Instance count for FH processing thread.
/// \internal This variable is protected by \ref mutex_FH.
int instance_cnt_FH;
/// \brief Instance count for rx processing thread.
/// \internal This variable is protected by \ref mutex_prach.
int instance_cnt_prach;
// instance count for over-the-air eNB synchronization
int instance_cnt_synch;
/// \internal This variable is protected by \ref mutex_asynch_rxtx.
int instance_cnt_asynch_rxtx;
/// pthread structure for FH processing thread
pthread_t pthread_FH;
/// pthread structure for eNB single processing thread
pthread_t pthread_single;
/// pthread structure for asychronous RX/TX processing thread
pthread_t pthread_asynch_rxtx;
/// flag to indicate first RX acquisition
int first_rx;
/// flag to indicate first TX transmission
int first_tx;
/// pthread attributes for parallel fep thread
pthread_attr_t attr_fep;
/// pthread attributes for parallel turbo-decoder thread
pthread_attr_t attr_td;
/// pthread attributes for parallel turbo-encoder thread
pthread_attr_t attr_te;
/// pthread attributes for FH processing thread
pthread_attr_t attr_FH;
/// pthread attributes for single eNB processing thread
pthread_attr_t attr_single;
/// pthread attributes for prach processing thread
pthread_attr_t attr_prach;
/// pthread attributes for over-the-air synch thread
pthread_attr_t attr_synch;
/// pthread attributes for asynchronous RX thread
pthread_attr_t attr_asynch_rxtx;
/// scheduling parameters for parallel fep thread
struct sched_param sched_param_fep;
/// scheduling parameters for parallel turbo-decoder thread
struct sched_param sched_param_td;
/// scheduling parameters for parallel turbo-encoder thread
struct sched_param sched_param_te;
/// scheduling parameters for FH thread
struct sched_param sched_param_FH;
/// scheduling parameters for single eNB thread
struct sched_param sched_param_single;
/// scheduling parameters for prach thread
struct sched_param sched_param_prach;
/// scheduling parameters for over-the-air synchronization thread
struct sched_param sched_param_synch;
/// scheduling parameters for asynch_rxtx thread
struct sched_param sched_param_asynch_rxtx;
/// pthread structure for parallel fep thread
pthread_t pthread_fep;
/// pthread structure for parallel turbo-decoder thread
pthread_t pthread_td;
/// pthread structure for parallel turbo-encoder thread
pthread_t pthread_te;
/// pthread structure for PRACH thread
pthread_t pthread_prach;
/// pthread structure for eNB synch thread
pthread_t pthread_synch;
/// condition variable for parallel fep thread
pthread_cond_t cond_fep;
/// condition variable for parallel turbo-decoder thread
pthread_cond_t cond_td;
/// condition variable for parallel turbo-encoder thread
pthread_cond_t cond_te;
/// condition variable for FH thread
pthread_cond_t cond_FH;
/// condition variable for PRACH processing thread;
pthread_cond_t cond_prach;
// condition variable for over-the-air eNB synchronization
pthread_cond_t cond_synch;
/// condition variable for asynch RX/TX thread
pthread_cond_t cond_asynch_rxtx;
/// mutex for parallel fep thread
pthread_mutex_t mutex_fep;
/// mutex for parallel turbo-decoder thread
pthread_mutex_t mutex_td;
/// mutex for parallel turbo-encoder thread
pthread_mutex_t mutex_te;
/// mutex for FH
pthread_mutex_t mutex_FH;
/// mutex for PRACH thread
pthread_mutex_t mutex_prach;
// mutex for over-the-air eNB synchronization
pthread_mutex_t mutex_synch;
/// mutex for asynch RX/TX thread
pthread_mutex_t mutex_asynch_rxtx;
/// parameters for turbo-decoding worker thread
// td_params tdp;
/// parameters for turbo-encoding worker thread
// te_params tep;
/// set of scheduling variables RXn-TXnp4 threads
eNB_rxtx_proc_NB_IOT_t proc_rxtx[2];
/// number of slave threads
int num_slaves;
/// array of pointers to slaves
struct eNB_proc_t_s **slave_proc;
} eNB_proc_t;
#endif // __PHY_DEFS__H__
......@@ -40,7 +40,7 @@ extern int number_of_cards;
#ifndef OCP_FRAMEWORK
//extern PHY_VARS_eNB ***PHY_vars_eNB_g;
extern PHY_VARS_eNB ***PHY_vars_eNB_g;
extern RAN_CONTEXT_t RC;
extern LTE_DL_FRAME_PARMS *lte_frame_parms_g;
#else
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef __PHY_VARS_NB_IOT_H__
#define __PHY_VARS_NB_IOT_H__
#include "PHY/types_NB_IoT.h"
#include "PHY/defs_L1_NB_IoT.h"
/*
#ifndef USER_MODE
unsigned int RX_DMA_BUFFER[4][NB_ANTENNAS_RX];
unsigned int TX_DMA_BUFFER[4][NB_ANTENNAS_TX];
unsigned int DAQ_MBOX;
#endif
char* namepointer_chMag ;
char fmageren_name2[512];
char* namepointer_log2;
//PHY_CONFIG *PHY_config;
*/
/*
#include "PHY/LTE_REFSIG/primary_synch.h"
int16_t *primary_synch0_time;
int16_t *primary_synch1_time;
int16_t *primary_synch2_time;
*/
//#include "PHY/CODING/vars.h"
//PHY_VARS *PHY_vars;
#ifndef OCP_FRAMEWORK
PHY_VARS_UE_NB_IoT ***PHY_vars_UE_NB_IoT_g;
PHY_VARS_eNB_NB_IoT ***PHY_vars_eNB_NB_IoT_g;
PHY_VARS_RN_NB_IoT **PHY_vars_RN_NB_IoT_g;
//NB_IoT_DL_FRAME_PARMS *lte_frame_parms_g;
#else
PHY_VARS_UE_NB_IoT * PHY_vars_UE_NB_IoT_g[MAX_UE][MAX_NUM_CCs]={NULL};
PHY_vars_eNB_NB_IoT * PHY_vars_eNB_NB_IoT_g[MAX_eNB_NB_IoT][MAX_NUM_CCs]={NULL};
#endif
///*
//unsigned short rev[2048],rev_times4[8192],rev_half[1024];
//unsigned short rev256[256],rev512[512],rev1024[1024],rev4096[4096],rev2048[2048],rev8192[8192];
//*/
/*
char mode_string[4][20] = {"NOT SYNCHED","PRACH","RAR","PUSCH"};
#include "PHY/LTE_TRANSPORT/vars.h"
#include "SIMULATION/ETH_TRANSPORT/vars.h"
#ifndef OPENAIR2
unsigned char NB_eNB_INST=0;
unsigned char NB_UE_INST=0;
unsigned char NB_RN_INST=0;
unsigned char NB_INST=0;
#endif
*/
/*
unsigned int ULSCH_max_consecutive_errors = 20;
int number_of_cards;
int flag_LA=0;
int flagMag;
//extern channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX];
//extern double ABS_SINR_eff_BLER_table[MCS_COUNT][9][9];
//extern double ABS_beta[MCS_COUNT];odi
double sinr_bler_map[MCS_COUNT][2][MCS_TABLE_LENGTH_MAX];
int table_length[MCS_COUNT];
//double sinr_bler_map_up[MCS_COUNT][2][16];
//for MU-MIMO abstraction using MIESM
//this 2D arrarays contains SINR, MI and RBIR in rows 1, 2, and 3 respectively
double MI_map_4qam[3][162];
double MI_map_16qam[3][197];
double MI_map_64qam[3][227];
// here the first index is for transmission mode 1, 2, 5 and 6 whereas the second index is for the 16 sinr vaues corresponding to 16 CQIs
double sinr_to_cqi[4][16]= { {-2.5051, -2.5051, -1.7451, -0.3655, 1.0812, 2.4012, 3.6849, 6.6754, 8.3885, 8.7970, 12.0437, 14.4709, 15.7281, 17.2424, 17.2424, 17.2424},
{-2.2360, -2.2360, -1.3919, -0.0218, 1.5319, 2.9574, 4.3234, 6.3387, 8.9879, 9.5096, 12.6609, 14.0116, 16.4984, 18.1572, 18.1572, 18.1572},
{-1, -1.0000, -0.4198, -0.0140, 1.0362, 2.3520, 3.5793, 6.1136, 8.4836, 9.0858, 12.4723, 13.9128, 16.2054, 17.7392, 17.7392, 17.7392},
{ -4.1057, -4.1057, -3.3768, -2.2916, -1.1392, 0.1236, 1.2849, 3.1933, 5.9298, 6.4052, 9.6245, 10.9414, 13.5166, 14.9545, 14.9545, 14.9545}
};
//int cqi_to_mcs[16]={0, 0, 1, 3, 5, 7, 9, 13, 15, 16, 20, 23, 25, 27, 27, 27};
int cqi_to_mcs[16]= {0, 0, 1, 2, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 27, 28};
//for SNR to MI conversion 7 th order Polynomial coeff
double q_qam16[8]= {3.21151853033897e-10,5.55435952230651e-09,-2.30760065362117e-07,-6.25587743817859e-06,4.62251036452795e-06,0.00224150813158937,0.0393723140344367,0.245486379182639};
double q_qpsk[8]= {1.94491167814437e-09,8.40494123817774e-08,4.75527131198034e-07,-2.48946285301621e-05,-0.000347614016158364,0.00209252225437100,0.0742986115462510,0.488297879889425};
double q_qam64[8]= {2.25934026232206e-11,-1.45992206328306e-10,-3.70861183071900e-08,-1.22206071019319e-06,6.49115500399637e-06,0.00129828997837433,0.0259669554914859,0.166602901214898};
//for MI to SNR conversion 7 th order Polynomial coeff
double p_qpsk[8]= {5982.42405670359,-21568.1135917693,31293.9987036905,-23394.6795043871,9608.34750585489,-2158.15802349899,267.731968719036,-20.6145324295965};
double p_qam16[8]= {7862.12690694170,-28510.3207048338,41542.2150287122,-31088.3036957379,12690.1982361016,-2785.66604739984,326.595462489375,-18.9911849872089};
double p_qam64[8]= {8832.57933013696,-32119.1802555952,46914.2578990397,-35163.8150557183,14343.7419388853,-3126.61025510092,360.954930562237,-18.0358548533343};
// ideal CE MIESM
double beta1_dlsch_MI[6][MCS_COUNT] = { {1.1188, 0.3720, 0.3755, 0.9453, 0.5799, 0.5256, 0.5485, 0.5340, 0.5165, 0.5300, 0.6594, 0.5962, 0.4884, 0.4927, 0.3687, 0.4614, 0.4081, 0.2639,0.2935,0.2520,0.3709,0.2906,0.2612,0.2390}, {0.7138, 0.5533, 0.5533, 0.4828, 0.4998, 0.4843, 0.4942, 0.5323, 0.5142, 0.4756, 0.5792, 0.4167, 0.4445, 0.3942, 0.3789, 0.2756, 0.4456, 0.1650, 0.2254, 0.2353, 0.2097,0.2517,0.3242,1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1},{1.808065416202085, 1.754544945430673,1.902272019362616, 1.790054645392961, 1.563204092967629, 1.585258289348813, 1.579349443720310, 1.570650121437345, 1.545055626608596, 1.362229442426877, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33, 1,1,1,1,1,1,1},{0.7146, 0.4789, 0.5392, 0.5556, 0.4975, 0.4847, 0.4691, 0.5261, 0.5278, 0.4962, 0.4468, 0.4113, 0.4622, 0.4609, 0.3946, 0.3991, 0.3532, 0.2439, 0.1898, 0.2929, 0.2712, 0.3367, 0.3591, 0.2571}};
double beta2_dlsch_MI[6][MCS_COUNT] = { {1.1293, 0.3707, 0.3722, 0.9310, 0.5808, 0.5265, 0.5404, 0.5279, 0.5210, 0.5226, 0.6438, 0.5827, 0.4804, 0.4830, 0.3638, 0.4506, 0.4107, 0.2547, 0.2797, 0.2413, 0.3351, 0.2750, 0.2568, 0.2273}, {0.7028, 0.5503, 0.5503, 0.4815, 0.5006, 0.4764, 0.4810, 0.5124, 0.4964, 0.4485, 0.5497, 0.3971, 0.4239, 0.3701, 0.3494, 0.2630, 0.4053, 0.1505, 0.2001,0.2024,0.1788,0.2124,0.2668,1}, {1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1},{1.079518113138858, 1.105622953570353, 1.031337449900606, 1.073342032668810, 1.242636589110353, 1.255054927783647, 1.291463834317768, 1.317048698347491, 1.354485054187984, 0.338534029291017, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33,1, 1,1,1,1,1,1},{0.6980, 0.4694, 0.5379, 0.5483, 0.4982, 0.4737, 0.4611, 0.5051, 0.5020, 0.4672, 0.4357, 0.3957, 0.4389, 0.4344, 0.3645, 0.3661, 0.3301, 0.2179, 0.1730, 0.2536, 0.2389,0.2884,0.2936,0.2226}};
//real CE MIESM
////////
double beta1_dlsch_MI[6][MCS_COUNT] = { {1.32955, 0.59522, 0.54024, 0.98698, 0.81305, 0.76976, 0.69258, 0.69713, 0.70546, 0.69111, 0.81904, 0.72664, 0.79491, 0.72562, 0.53980, 0.33134, 0.50550, 0.40602,0.40281,0.47012,0.50510,0.23540,0.32045,1}, {0.59632, 1.08475, 1.02431, 1.07020, 0.90170, 0.97719, 0.95464, 0.92764, 0.86721, 0.85986, 0.64558, 0.80631, 0.82673, 0.82888, 0.87122, 0.77245, 0.29771, 0.43477, 0.55321, 0.61027, 0.56111, 0.57292, 0.39737,1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1},{1.808065416202085, 1.754544945430673,1.902272019362616, 1.790054645392961, 1.563204092967629, 1.585258289348813, 1.579349443720310, 1.570650121437345, 1.545055626608596, 1.362229442426877, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33, 1,1,1,1,1,1,1},{0.77532, 1.07544, 1.10571, 1.04099, 0.91638, 0.88644, 0.96405, 0.86709, 0.94066, 0.84430, 1.24478, 1.09665, 1.42604, 0.79541, 0.71847, 0.71604, 0.74561, 0.36431, 0.41536, 0.52175, 0.47096, 0.49977, 0.59728,1}};
double beta2_dlsch_MI[6][MCS_COUNT] = { {1.36875, 0.59304, 0.53870, 0.98239, 0.81637, 0.76847, 0.69842, 0.69885, 0.69967, 0.69826, 0.82660, 0.70559, 0.78404, 0.70670, 0.55393, 0.36893, 0.52225, 0.39752, 0.40494, 0.46239, 0.49247,0.26900,0.34504,1}, {0.43775, 0.78208, 0.72875, 0.77458, 0.64485, 0.69174, 0.66097, 0.63289, 0.59652, 0.61175, 0.44551, 0.56047, 0.57314, 0.57553, 0.58849, 0.52159, 0.21241, 0.30139, 0.37373, 0.32029, 0.37067, 0.36706, 0.27118,1}, {1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1},{1.079518113138858, 1.105622953570353, 1.031337449900606, 1.073342032668810, 1.242636589110353, 1.255054927783647, 1.291463834317768, 1.317048698347491, 1.354485054187984, 0.338534029291017, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33,1, 1,1,1,1,1,1},{0.54448, 0.73731, 0.79165, 0.74407, 0.68042, 0.64906, 0.71349, 0.62109, 0.65815, 0.60940, 0.90549, 0.78708, 1.03176, 0.58431, 0.53379, 0.51224, 0.52767, 0.26848, 0.29642, 0.36879, 0.34148, 0.35279,0.40633,1}};
////////
//ideal channel estimation values
//double beta1_dlsch[6][MCS_COUNT] = { {2.3814, 0.4956, 0.5273, 1.1708, 0.8014, 0.7889, 0.8111, 0.8139, 0.8124, 0.8479, 1.9280, 1.9664, 2.3857, 2.5147, 2.4511, 3.0158, 2.8643, 5.3013, 5.8594, 6.5372, 7.8073, 7.8030, 7.5295, 7.1320}, {0.5146, 0.5549, 0.7405, 0.6913, 0.7349, 0.7000, 0.7539, 0.7955, 0.8074, 0.7760, 1.8150, 1.6561, 1.9280, 2.3563, 2.6699, 2.3086, 3.1601, 4.5316, 5.2870, 6.0983, 6.5635, 7.7024, 9.9592, 6.6173}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {1.79358, 1.17908, 2.02600, 1.72040, 1.58618, 1.59039, 1.68111, 1.67062, 1.64911, 1.33274, 4.87800, 3.58797, 3.72338, 5.35700, 2.81752, 1.93472, 2.23259, 1,1,1,1,1,1,1}, {0.4445, 0.5918, 0.7118, 0.7115, 0.7284, 0.7202, 0.7117, 0.8111, 0.8239, 0.7907, 1.8456, 1.8144, 2.3830, 2.6634, 2.6129, 2.8127, 2.7372, 4.9424, 4.8763, 6.8413, 7.1493, 9.4180, 10.1230, 8.9613}};
//double beta2_dlsch[6][MCS_COUNT] = { {2.3639, 0.4952, 0.5207, 1.1572, 0.8026, 0.7864, 0.7996, 0.8034, 0.8200, 0.8367, 1.8701, 1.9212, 2.2947, 2.4472, 2.4091, 2.9479, 2.8973, 5.0591, 5.5134, 6.1483, 7.2166, 7.5177, 7.5704, 7.2248}, {0.5113, 0.5600, 0.7359, 0.6860, 0.7344, 0.6902, 0.7315, 0.7660, 0.7817, 0.7315, 1.7268, 1.5912, 1.8519, 2.2115, 2.4580, 2.1879, 2.9015, 4.1543, 4.6986, 5.3193, 5.6319, 6.5640, 8.2421, 5.6393}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {0.79479, 0.52872, 0.90005, 0.77170, 0.73220, 0.72060, 0.75433, 0.75451, 0.75989, 0.67655, 1.68525, 1.31100, 1.46573, 1.99843, 1.57293, 1.62852, 2.10636, 1,1,1,1,1,1,1}, {0.4398, 0.5823, 0.7094, 0.7043, 0.7282, 0.7041, 0.6979, 0.7762, 0.7871, 0.7469, 1.7752, 1.7443, 2.2266, 2.4767, 2.4146, 2.6040, 2.5708, 4.4488, 4.4944, 5.9630, 6.3740, 8.1097, 8.4210, 7.8027}};
/////////double beta1_dlsch[6][MCS_COUNT] = { {1.199175, 1.085656, 0.983872, 0.843789, 0.816093, 0.853078, 0.899236, 0.919665, 0.888673, 0.924181, 0.814176, 0.794108, 0.770653, 0.826266, 0.982043, 0.979621, 0.985176, 0.901741, 0.870311, 0.911303, 0.898923, 1.003359, 0.988535, 1.030639, 1.151038, 1.116939, 1.214118, 1.219148}, {0.5146, 0.5549, 0.7405, 0.6913, 0.7349, 0.7000, 0.7539, 0.7955, 0.8074, 0.7760, 1.8150, 1.6561, 1.9280, 2.3563, 2.6699, 2.3086, 3.1601, 4.5316, 5.2870, 6.0983, 6.5635, 7.7024, 9.9592, 6.6173}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {1.79358, 1.17908, 2.02600, 1.72040, 1.58618, 1.59039, 1.68111, 1.67062, 1.64911, 1.33274, 4.87800, 3.58797, 3.72338, 5.35700, 2.81752, 1.93472, 2.23259, 1,1,1,1,1,1,1}, {0.4445, 0.5918, 0.7118, 0.7115, 0.7284, 0.7202, 0.7117, 0.8111, 0.8239, 0.7907, 1.8456, 1.8144, 2.3830, 2.6634, 2.6129, 2.8127, 2.7372, 4.9424, 4.8763, 6.8413, 7.1493, 9.4180, 10.1230, 8.9613}};
/////////double beta2_dlsch[6][MCS_COUNT] = { {0.534622, 0.596561, 0.500838, 0.471721, 0.548218, 0.547974, 0.924245, 0.836484, 0.776917, 0.879691, 0.875722, 0.666933, 0.666393, 0.755377, 1.074985, 1.080290, 1.010914, 0.790892, 0.793435, 0.860249, 0.901508, 0.967060, 0.951372, 1.011493, 1.106151, 1.117076, 1.209397, 1.227790}, {0.5113, 0.5600, 0.7359, 0.6860, 0.7344, 0.6902, 0.7315, 0.7660, 0.7817, 0.7315, 1.7268, 1.5912, 1.8519, 2.2115, 2.4580, 2.1879, 2.9015, 4.1543, 4.6986, 5.3193, 5.6319, 6.5640, 8.2421, 5.6393}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {0.79479, 0.52872, 0.90005, 0.77170, 0.73220, 0.72060, 0.75433, 0.75451, 0.75989, 0.67655, 1.68525, 1.31100, 1.46573, 1.99843, 1.57293, 1.62852, 2.10636, 1,1,1,1,1,1,1}, {0.4398, 0.5823, 0.7094, 0.7043, 0.7282, 0.7041, 0.6979, 0.7762, 0.7871, 0.7469, 1.7752, 1.7443, 2.2266, 2.4767, 2.4146, 2.6040, 2.5708, 4.4488, 4.4944, 5.9630, 6.3740, 8.1097, 8.4210, 7.8027}};
//real channel estimation valus
///
double beta1_dlsch[6][MCS_COUNT] = { {2.50200, 0.84047, 0.78195, 1.37929, 1.16871, 1.11906, 1.06303, 1.07447, 1.11403, 1.09223, 2.82502, 2.87556, 3.51254, 3.62920, 3.53638, 2.35980, 3.74126, 8.66532, 7.31772, 9.86882, 10.64939, 6.75208, 9.50664, 13.63057}, {0.92257, 1, 1.80445, 1.43175, 1.42093, 1.37381, 1.45392, 1.47255, 1.47451, 1.41235, 3.9079, 3.38557, 4.13059, 4.93355, 4.97277, 6.04951, 5.88896, 8.68076, 10.23746, 12.37069, 5.50538, 17.29612, 17.95050, 13.27095}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {1.79255, 1.88213, 4.44226, 2.25150, 1.93710, 2.18504, 2.57389, 1.94322, 1.78515, 2.09265, 2.37459, 1.74442, 1.74346, 1.19705, 1.56149, 1.59604, 1.6, 1,1,1,1,1,1,1}, {0.93374, 1.40389, 1.36670, 1.38679, 1.35707, 1.26353, 1.32360, 1.40164, 1.51843, 1.34863, 3.45839, 3.13726, 3.94768, 4.21966, 4.60750, 4.97894, 5.40755, 8.12814, 10.59221, 12.96427, 13.37323, 14.27206, 16.61779, 17.19656}};
double beta2_dlsch[6][MCS_COUNT] = { {2.52163, 0.83231, 0.77472, 1.36536, 1.16829, 1.11186, 1.06287, 1.07292, 1.09946, 1.10650, 2.79174, 2.75655, 3.36651, 3.49011, 3.60903, 2.73517, 3.84009, 8.20312, 7.41739, 9.64081, 10.40911, 8.11765, 10.41923, 9.34300}, {0.67252, 0.8600, 1.28633, 1.01624, 1.03066, 0.97590, 1.02560, 1.01840, 1.00547, 0.97093, 2.72573, 2.33283, 2.86181, 3.40452, 3.47957, 4.08916, 3.97628, 6.14541, 7.11017, 8.42369, 4.04812, 11.42082, 11.57171, 9.28462}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {0.85784, 0.90361, 2.09766, 1.08385, 0.96300, 1.04432, 1.22763, 0.99249, 0.95544, 1.12333, 1.37924, 1.12913, 1.30644, 1.19253, 1.75488, 2.13813, 2.10636, 1,1,1,1,1,1,1}, {0.66288, 0.96402, 0.98545, 0.99386, 0.99981, 0.92678, 0.98978, 0.99600, 1.05538, 0.97777, 2.52504, 2.29338, 2.89631, 3.10812, 3.41916, 3.58671, 3.84166, 6.05254, 7.45821, 9.15812, 9.66330, 10.17852, 11.50519, 11.16299}};
///
#ifdef OCP_FRAMEWORK
#include <enums.h>
#else
char eNB_functions[6][20]={"eNodeB_3GPP","eNodeB_3GPP_BBU","NGFI_RCC_IF4p5","NGFI_RAI_IF4p5","NGFI_RRU_IF5","NGFI_RRU_IF4p5",};
char eNB_timing[2][20]={"synch_to_ext_device","synch_to_other"};
#endif
*/
/// lookup table for unscrambling in RX
int16_t unscrambling_lut_NB_IoT[65536*16] __attribute__((aligned(32)));
/*
/// lookup table for scrambling in TX
uint8_t scrambling_lut[65536*16] __attribute__((aligned(32)));
*/
#endif /*__PHY_VARS_H__ */
......@@ -41,7 +41,7 @@
//#include "PHY/extern.h"
#include "PHY/extern_NB_IoT.h"
#include "PHY/phy_extern.h"
#include "PHY/defs_eNB.h"
//#include "PHY/vars.h"
#include "PHY/INIT/defs_NB_IoT.h"
......@@ -281,8 +281,8 @@ void schedule_response_NB_IoT(Sched_Rsp_NB_IoT_t *Sched_INFO)
{
//LOG_I(PHY,"schedule_response_NB_IoT\n");
//XXX check if correct to take eNB like this
PHY_VARS_eNB *eNB = PHY_vars_eNB_g[0][Sched_INFO->CC_id];
eNB_rxtx_proc_t *proc = &eNB->proc.proc_rxtx[0];
PHY_VARS_eNB_NB_IoT *eNB = PHY_vars_eNB_NB_IoT_g[0][Sched_INFO->CC_id];
eNB_rxtx_proc_NB_IoT_t *proc = &eNB->proc.proc_rxtx[0];
NB_IoT_eNB_NPBCH_t *npbch;
///
int i;
......@@ -328,10 +328,10 @@ void schedule_response_NB_IoT(Sched_Rsp_NB_IoT_t *Sched_INFO)
}
/*clear the DCI allocation maps for new subframe*/
if(eNB->nulsch[i])
if(eNB->ulsch_NB_IoT[i])
{
eNB->nulsch[i]->harq_process->dci_alloc = 0; //flag for indicating that a DCI has been allocated for UL
eNB->nulsch[i]->harq_process->rar_alloc = 0; //Flag indicating that this ULSCH has been allocated by a RAR (for Msg3)
eNB->ulsch_NB_IoT[i]->harq_process->dci_alloc = 0; //flag for indicating that a DCI has been allocated for UL
eNB->ulsch_NB_IoT[i]->harq_process->rar_alloc = 0; //Flag indicating that this ULSCH has been allocated by a RAR (for Msg3)
//no phich for NB-IoT so no DMRS should be utilized
}
......@@ -536,7 +536,6 @@ void PHY_config_req_NB_IoT(PHY_Config_NB_IoT_t* config_INFO){
//MIB-NB configuration
phy_config_mib_eNB_NB_IoT(config_INFO->mod_id,
config_INFO->CC_id,
config_INFO->cfg->nfapi_config.rf_bands.rf_band[0],//eutraband
config_INFO->cfg->sch_config.physical_cell_id.value,
config_INFO->cfg->subframe_config.dl_cyclic_prefix_type.value,
......@@ -554,7 +553,6 @@ void PHY_config_req_NB_IoT(PHY_Config_NB_IoT_t* config_INFO){
{
//Common Configuration included in SIB2-NB
phy_config_sib2_eNB_NB_IoT(config_INFO->mod_id,
config_INFO->CC_id,
&config_INFO->cfg->nb_iot_config, // FIXME to be evaluated is should be passed a pointer
&config_INFO->cfg->rf_config,
&config_INFO->cfg->uplink_reference_signal_config,
......
......@@ -34,7 +34,7 @@ void generate_eNB_ulsch_params_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,eNB_rxtx_proc_NB_
void generate_eNB_dlsch_params_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,eNB_rxtx_proc_NB_IoT_t * proc,nfapi_dl_config_request_pdu_t *dl_config_pdu);
/*Process all the scheduling result from MAC and also common signals.*/
void phy_procedures_eNB_TX_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,eNB_rxtx_proc_NB_IoT_t *proc,relaying_type_t r_type,PHY_VARS_RN_NB_IoT *rn,int do_meas,int do_pdcch_flag);
void phy_procedures_eNB_TX_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,eNB_rxtx_proc_NB_IoT_t *proc,int do_meas);
int8_t find_ue_NB_IoT(uint16_t rnti, PHY_VARS_eNB_NB_IoT *eNB);
......
/*! \file phy_procedures_lte_eNB.c
* \brief Implementation of common utilities for eNB/UE procedures from 36.213 LTE specifications
* \author M. KANJ R. Knopp, F. Kaltenberger
* \date 2017
* \version 0.1
* \company Bcom & Eurecom
* \email: matthieu.kanj@b-com.com , knopp@eurecom.fr,florian.kaltenberger@eurecom.fr
* \note
* \warning
*/
#include "defs_NB_IoT.h"
#include "PHY/defs_L1_NB_IoT.h"
#include "PHY/impl_defs_lte_NB_IoT.h"
#include "PHY/extern_NB_IoT.h"
#include "PHY/vars_NB_IoT.h"
//#include "SCHED/defs_nb_iot.h"
//#include "SCHED/extern.h"
#ifdef LOCALIZATION
#include <sys/time.h>
#endif
/*
void get_Msg3_alloc(LTE_DL_FRAME_PARMS *frame_parms,
unsigned char current_subframe,
unsigned int current_frame,
unsigned int *frame,
unsigned char *subframe)
{
// Fill in other TDD Configuration!!!!
if (frame_parms->frame_type == FDD) {
*subframe = current_subframe+6;
if (*subframe>9) {
*subframe = *subframe-10;
*frame = (current_frame+1) & 1023;
} else {
*frame=current_frame;
}
} else { // TDD
if (frame_parms->tdd_config == 1) {
switch (current_subframe) {
case 0:
*subframe = 7;
*frame = current_frame;
break;
case 4:
*subframe = 2;
*frame = (current_frame+1) & 1023;
break;
case 5:
*subframe = 2;
*frame = (current_frame+1) & 1023;
break;
case 9:
*subframe = 7;
*frame = (current_frame+1) & 1023;
break;
}
} else if (frame_parms->tdd_config == 3) {
switch (current_subframe) {
case 0:
case 5:
case 6:
*subframe = 2;
*frame = (current_frame+1) & 1023;
break;
case 7:
*subframe = 3;
*frame = (current_frame+1) & 1023;
break;
case 8:
*subframe = 4;
*frame = (current_frame+1) & 1023;
break;
case 9:
*subframe = 2;
*frame = (current_frame+2) & 1023;
break;
}
} else if (frame_parms->tdd_config == 4) {
switch (current_subframe) {
case 0:
case 4:
case 5:
case 6:
*subframe = 2;
*frame = (current_frame+1) & 1023;
break;
case 7:
*subframe = 3;
*frame = (current_frame+1) & 1023;
break;
case 8:
case 9:
*subframe = 2;
*frame = (current_frame+2) & 1023;
break;
}
} else if (frame_parms->tdd_config == 5) {
switch (current_subframe) {
case 0:
case 4:
case 5:
case 6:
*subframe = 2;
*frame = (current_frame+1) & 1023;
break;
case 7:
case 8:
case 9:
*subframe = 2;
*frame = (current_frame+2) & 1023;
break;
}
}
}
}
void get_Msg3_alloc_ret(LTE_DL_FRAME_PARMS *frame_parms,
unsigned char current_subframe,
unsigned int current_frame,
unsigned int *frame,
unsigned char *subframe)
{
if (frame_parms->frame_type == FDD) {
// always retransmit in n+8 /
*subframe = current_subframe + 8;
if (*subframe > 9) {
*subframe = *subframe - 10;
*frame = (current_frame + 1) & 1023;
} else {
*frame = current_frame;
}
} else {
if (frame_parms->tdd_config == 1) {
// original PUSCH in 2, PHICH in 6 (S), ret in 2
// original PUSCH in 3, PHICH in 9, ret in 3
// original PUSCH in 7, PHICH in 1 (S), ret in 7
// original PUSCH in 8, PHICH in 4, ret in 8
*frame = (current_frame+1) & 1023;
} else if (frame_parms->tdd_config == 3) {
// original PUSCH in 2, PHICH in 8, ret in 2 next frame
// original PUSCH in 3, PHICH in 9, ret in 3 next frame
// original PUSCH in 4, PHICH in 0, ret in 4 next frame
*frame=(current_frame+1) & 1023;
} else if (frame_parms->tdd_config == 4) {
// original PUSCH in 2, PHICH in 8, ret in 2 next frame
// original PUSCH in 3, PHICH in 9, ret in 3 next frame
*frame=(current_frame+1) & 1023;
} else if (frame_parms->tdd_config == 5) {
// original PUSCH in 2, PHICH in 8, ret in 2 next frame
*frame=(current_frame+1) & 1023;
}
}
}
uint8_t get_Msg3_harq_pid(LTE_DL_FRAME_PARMS *frame_parms,
uint32_t frame,
unsigned char current_subframe)
{
uint8_t ul_subframe=0;
uint32_t ul_frame=0;
if (frame_parms->frame_type ==FDD) {
ul_subframe = (current_subframe>3) ? (current_subframe-4) : (current_subframe+6);
ul_frame = (current_subframe>3) ? ((frame+1)&1023) : frame;
} else {
switch (frame_parms->tdd_config) {
case 1:
switch (current_subframe) {
case 9:
case 0:
ul_subframe = 7;
break;
case 5:
case 7:
ul_subframe = 2;
break;
}
break;
case 3:
switch (current_subframe) {
case 0:
case 5:
case 6:
ul_subframe = 2;
break;
case 7:
ul_subframe = 3;
break;
case 8:
ul_subframe = 4;
break;
case 9:
ul_subframe = 2;
break;
}
break;
case 4:
switch (current_subframe) {
case 0:
case 5:
case 6:
case 8:
case 9:
ul_subframe = 2;
break;
case 7:
ul_subframe = 3;
break;
}
break;
case 5:
ul_subframe =2;
break;
default:
LOG_E(PHY,"get_Msg3_harq_pid: Unsupported TDD configuration %d\n",frame_parms->tdd_config);
mac_xface->macphy_exit("get_Msg3_harq_pid: Unsupported TDD configuration");
break;
}
}
return(subframe2harq_pid(frame_parms,ul_frame,ul_subframe));
}
unsigned char ul_ACK_subframe2_dl_subframe(LTE_DL_FRAME_PARMS *frame_parms,unsigned char subframe,unsigned char ACK_index)
{
if (frame_parms->frame_type == FDD) {
return((subframe<4) ? subframe+6 : subframe-4);
} else {
switch (frame_parms->tdd_config) {
case 3:
if (subframe == 2) { // ACK subframes 5 and 6
if (ACK_index==2)
return(1);
return(5+ACK_index);
} else if (subframe == 3) { // ACK subframes 7 and 8
return(7+ACK_index); // To be updated
} else if (subframe == 4) { // ACK subframes 9 and 0
return((9+ACK_index)%10);
} else {
LOG_E(PHY,"phy_procedures_lte_common.c/subframe2_dl_harq_pid: illegal subframe %d for tdd_config %d\n",
subframe,frame_parms->tdd_config);
return(0);
}
break;
case 4:
if (subframe == 2) { // ACK subframes 0, 4 and 5
//if (ACK_index==2)
// return(1); TBC
if (ACK_index==2)
return(0);
return(4+ACK_index);
} else if (subframe == 3) { // ACK subframes 6, 7 8 and 9
return(6+ACK_index); // To be updated
} else {
LOG_E(PHY,"phy_procedures_lte_common.c/subframe2_dl_harq_pid: illegal subframe %d for tdd_config %d\n",
subframe,frame_parms->tdd_config);
return(0);
}
break;
case 1:
if (subframe == 2) { // ACK subframes 5 and 6
return(5+ACK_index);
} else if (subframe == 3) { // ACK subframe 9
return(9); // To be updated
} else if (subframe == 7) { // ACK subframes 0 and 1
return(ACK_index); // To be updated
} else if (subframe == 8) { // ACK subframe 4
return(4); // To be updated
} else {
LOG_E(PHY,"phy_procedures_lte_common.c/ul_ACK_subframe2_dl_subframe: illegal subframe %d for tdd_config %d\n",
subframe,frame_parms->tdd_config);
return(0);
}
break;
}
}
return(0);
}
unsigned char ul_ACK_subframe2_M(LTE_DL_FRAME_PARMS *frame_parms,unsigned char subframe)
{
if (frame_parms->frame_type == FDD) {
return(1);
} else {
switch (frame_parms->tdd_config) {
case 3:
if (subframe == 2) { // ACK subframes 5 and 6
return(2); // should be 3
} else if (subframe == 3) { // ACK subframes 7 and 8
return(2); // To be updated
} else if (subframe == 4) { // ACK subframes 9 and 0
return(2);
} else {
LOG_E(PHY,"phy_procedures_lte_common.c/subframe2_dl_harq_pid: illegal subframe %d for tdd_config %d\n",
subframe,frame_parms->tdd_config);
return(0);
}
break;
case 4:
if (subframe == 2) { // ACK subframes 0,4 and 5
return(3); // should be 4
} else if (subframe == 3) { // ACK subframes 6,7,8 and 9
return(4);
} else {
LOG_E(PHY,"phy_procedures_lte_common.c/subframe2_dl_harq_pid: illegal subframe %d for tdd_config %d\n",
subframe,frame_parms->tdd_config);
return(0);
}
break;
case 5:
if (subframe == 2) { // ACK subframes 0,3,4,5,6,7,8 and 9
return(8); // should be 3
} else {
LOG_E(PHY,"phy_procedures_lte_common.c/subframe2_dl_harq_pid: illegal subframe %d for tdd_config %d\n",
subframe,frame_parms->tdd_config);
return(0);
}
break;
case 1:
if (subframe == 2) { // ACK subframes 5 and 6
return(2);
} else if (subframe == 3) { // ACK subframe 9
return(1); // To be updated
} else if (subframe == 7) { // ACK subframes 0 and 1
return(2); // To be updated
} else if (subframe == 8) { // ACK subframe 4
return(1); // To be updated
} else {
LOG_E(PHY,"phy_procedures_lte_common.c/subframe2_dl_harq_pid: illegal subframe %d for tdd_config %d\n",
subframe,frame_parms->tdd_config);
return(0);
}
break;
}
}
return(0);
}
// This function implements table 10.1-1 of 36-213, p. 69
// return the number 'Nbundled'
uint8_t get_reset_ack(LTE_DL_FRAME_PARMS *frame_parms,
harq_status_t *harq_ack,
unsigned char subframe_tx,
unsigned char subframe_rx,
unsigned char *o_ACK,
uint8_t *pN_bundled,
uint8_t cw_idx,
uint8_t do_reset) // 1 to reset ACK/NACK status : 0 otherwise
{
uint8_t status=0;
uint8_t subframe_ul=0xff, subframe_dl0=0xff, subframe_dl1=0xff,subframe_dl2=0xff, subframe_dl3=0xff;
// printf("get_ack: SF %d\n",subframe);
if (frame_parms->frame_type == FDD) {
if (subframe_tx < 4)
subframe_dl0 = subframe_tx + 6;
else
subframe_dl0 = subframe_tx - 4;
o_ACK[cw_idx] = harq_ack[subframe_dl0].ack;
status = harq_ack[subframe_dl0].send_harq_status;
//LOG_I(PHY,"dl subframe %d send_harq_status %d cw_idx %d, reset %d\n",subframe_dl0, status, cw_idx, do_reset);
if(do_reset)
harq_ack[subframe_dl0].send_harq_status = 0;
//printf("get_ack: Getting ACK/NAK for PDSCH (subframe %d) => %d\n",subframe_dl,o_ACK[0]);
} else {
switch (frame_parms->tdd_config) {
case 1:
if (subframe_tx == 2) { // ACK subframes 5,6
subframe_ul = 6;
subframe_dl0 = 5;
subframe_dl1 = 6;
} else if (subframe_tx == 3) { // ACK subframe 9
subframe_ul = 9;
subframe_dl0 = 9;
subframe_dl1 = 0xff;
} else if (subframe_tx == 4) { // nothing
subframe_ul = 0xff;
subframe_dl0 = 0xff; // invalid subframe number indicates ACK/NACK is not needed
subframe_dl1 = 0xff;
} else if (subframe_tx == 7) { // ACK subframes 0,1
subframe_ul = 1;
subframe_dl0 = 0;
subframe_dl1 = 1;
} else if (subframe_tx == 8) { // ACK subframes 4
subframe_ul = 4;
subframe_dl0 = 4;
subframe_dl1 = 0xff;
} else {
LOG_E(PHY,"phy_procedures_lte.c: get_ack, illegal subframe_tx %d for tdd_config %d\n",
subframe_tx,frame_parms->tdd_config);
return(0);
}
// report ACK/NACK status
o_ACK[cw_idx] = 1;
status = 0;
if ((subframe_dl0 < 10) && (harq_ack[subframe_dl0].send_harq_status)) {
o_ACK[cw_idx] &= harq_ack[subframe_dl0].ack;
status = harq_ack[subframe_dl0].send_harq_status;
}
if ((subframe_dl1 < 10) && (harq_ack[subframe_dl1].send_harq_status)) {
o_ACK[cw_idx] &= harq_ack[subframe_dl1].ack;
status = harq_ack[subframe_dl1].send_harq_status;
}
// report status = Nbundled
if (!status) {
o_ACK[cw_idx] = 0;
} else {
if (harq_ack[subframe_ul].vDAI_UL < 0xff) {
status = harq_ack[subframe_ul].vDAI_UL;
}
}
if (!do_reset && (subframe_ul < 10)) {
if ((subframe_dl0 < 10) && (subframe_dl1 < 10)) {
LOG_D(PHY,"ul-sf#%d vDAI_UL[sf#%d]=%d Nbundled=%d: dlsf#%d ACK=%d harq_status=%d vDAI_DL=%d, dlsf#%d ACK=%d harq_status=%d vDAI_DL=%d, o_ACK[0]=%d status=%d\n",
subframe_tx, subframe_ul, harq_ack[subframe_ul].vDAI_UL, status,
subframe_dl0, harq_ack[subframe_dl0].ack, harq_ack[subframe_dl0].send_harq_status, harq_ack[subframe_dl0].vDAI_DL,
subframe_dl1, harq_ack[subframe_dl1].ack, harq_ack[subframe_dl1].send_harq_status, harq_ack[subframe_dl1].vDAI_DL,
o_ACK[cw_idx], status);
} else if (subframe_dl0 < 10) {
LOG_D(PHY,"ul-sf#%d vDAI_UL[sf#%d]=%d Nbundled=%d: dlsf#%d ACK=%d status=%d vDAI_DL=%d, o_ACK[0]=%d status=%d\n",
subframe_tx, subframe_ul, harq_ack[subframe_ul].vDAI_UL, status,
subframe_dl0, harq_ack[subframe_dl0].ack, harq_ack[subframe_dl0].send_harq_status, harq_ack[subframe_dl0].vDAI_DL,
o_ACK[cw_idx], status);
}else if (subframe_dl1 < 10) {
LOG_D(PHY,"ul-sf#%d vDAI_UL[sf#%d]=%d Nbundled=%d: dlsf#%d ACK=%d status=%d vDAI_DL=%d, o_ACK[0]=%d status=%d\n",
subframe_tx, subframe_ul, harq_ack[subframe_ul].vDAI_UL, status,
subframe_dl1, harq_ack[subframe_dl1].ack, harq_ack[subframe_dl1].send_harq_status, harq_ack[subframe_dl1].vDAI_DL,
o_ACK[cw_idx], status);
}
}
// reset ACK/NACK status
if (do_reset) {
LOG_D(PHY,"ul-sf#%d ACK/NACK status resetting @ dci0-sf#%d, dci1x/2x-sf#%d, dci1x/2x-sf#%d\n", subframe_tx, subframe_ul, subframe_dl0, subframe_dl1);
if (subframe_ul < 10) {
harq_ack[subframe_ul].vDAI_UL = 0xff;
}
if (subframe_dl0 < 10) {
harq_ack[subframe_dl0].vDAI_DL = 0xff;
harq_ack[subframe_dl0].ack = 2;
harq_ack[subframe_dl0].send_harq_status = 0;
}
if (subframe_dl1 < 10) {
harq_ack[subframe_dl1].vDAI_DL = 0xff;
harq_ack[subframe_dl1].ack = 2;
harq_ack[subframe_dl1].send_harq_status = 0;
}
}
break;
case 3:
if (subframe_tx == 2) { // ACK subframes 5 and 6
subframe_dl0 = 5;
subframe_dl1 = 6;
subframe_ul = 2;
//printf("subframe_tx 2, TDD config 3: harq_ack[5] = %d (%d),harq_ack[6] = %d (%d)\n",harq_ack[5].ack,harq_ack[5].send_harq_status,harq_ack[6].ack,harq_ack[6].send_harq_status);
} else if (subframe_tx == 3) { // ACK subframes 7 and 8
subframe_dl0 = 7;
subframe_dl1 = 8;
subframe_ul = 3;
//printf("Subframe 3, TDD config 3: harq_ack[7] = %d,harq_ack[8] = %d\n",harq_ack[7].ack,harq_ack[8].ack);
//printf("status %d : o_ACK (%d,%d)\n", status,o_ACK[0],o_ACK[1]);
} else if (subframe_tx == 4) { // ACK subframes 9 and 0
subframe_dl0 = 9;
subframe_dl1 = 0;
subframe_ul = 4;
//printf("Subframe 4, TDD config 3: harq_ack[9] = %d,harq_ack[0] = %d\n",harq_ack[9].ack,harq_ack[0].ack);
} else {
LOG_E(PHY,"phy_procedures_lte.c: get_ack, illegal subframe_tx %d for tdd_config %d\n",
subframe_tx,frame_parms->tdd_config);
return(0);
}
// report ACK/NACK status
o_ACK[cw_idx] = 0;
if (harq_ack[subframe_dl0].send_harq_status == 1) {
o_ACK[cw_idx] = harq_ack[subframe_dl0].ack;
if (harq_ack[subframe_dl1].send_harq_status == 1)
o_ACK[cw_idx] &= harq_ack[subframe_dl1].ack;
} else if (harq_ack[subframe_dl1].send_harq_status == 1)
o_ACK[cw_idx] = harq_ack[subframe_dl1].ack;
pN_bundled[0] = harq_ack[subframe_rx].vDAI_UL;
status = harq_ack[subframe_dl0].send_harq_status + harq_ack[subframe_dl1].send_harq_status;
//LOG_D(PHY,"TDD Config3 UL Sfn %d, dl Sfn0 %d status %d o_Ack %d, dl Sfn1 %d status %d o_Ack %d subframe_rx %d N_bundled %d \n",
// subframe_tx, subframe_dl0, harq_ack[subframe_dl0].send_harq_status,harq_ack[subframe_dl0].ack,
// subframe_dl1, harq_ack[subframe_dl1].send_harq_status,harq_ack[subframe_dl1].ack, subframe_rx, pN_bundled[0]);
if (do_reset) {
// reset ACK/NACK status
harq_ack[subframe_dl0].ack = 2;
harq_ack[subframe_dl1].ack = 2;
harq_ack[subframe_dl0].send_harq_status = 0;
harq_ack[subframe_dl1].send_harq_status = 0;
}
break;
case 4:
if (subframe_tx == 2) { // ACK subframes 4, 5 and 0
subframe_dl0 = 0;
subframe_dl1 = 4;
subframe_dl2 = 5;
subframe_ul = 2;
//printf("subframe_tx 2, TDD config 3: harq_ack[5] = %d (%d),harq_ack[6] = %d (%d)\n",harq_ack[5].ack,harq_ack[5].send_harq_status,harq_ack[6].ack,harq_ack[6].send_harq_status);
} else if (subframe_tx == 3) { // ACK subframes 6, 7 8 and 9
subframe_dl0 = 7;
subframe_dl1 = 8;
subframe_dl2 = 9;
subframe_dl3 = 6;
subframe_ul = 3;
//printf("Subframe 3, TDD config 3: harq_ack[7] = %d,harq_ack[8] = %d\n",harq_ack[7].ack,harq_ack[8].ack);
//printf("status %d : o_ACK (%d,%d)\n", status,o_ACK[0],o_ACK[1]);
} else {
LOG_E(PHY,"phy_procedures_lte.c: get_ack, illegal subframe_tx %d for tdd_config %d\n",
subframe_tx,frame_parms->tdd_config);
return(0);
}
// report ACK/NACK status
o_ACK[cw_idx] = 0;
if (harq_ack[subframe_dl0].send_harq_status == 1)
o_ACK[cw_idx] = harq_ack[subframe_dl0].ack;
if (harq_ack[subframe_dl1].send_harq_status == 1)
o_ACK[cw_idx] &= harq_ack[subframe_dl1].ack;
if (harq_ack[subframe_dl2].send_harq_status == 1)
o_ACK[cw_idx] &= harq_ack[subframe_dl2].ack;
if (harq_ack[subframe_dl3].send_harq_status == 1)
o_ACK[cw_idx] &= harq_ack[subframe_dl3].ack;
pN_bundled[0] = harq_ack[subframe_rx].vDAI_UL;
status = harq_ack[subframe_dl0].send_harq_status + harq_ack[subframe_dl1].send_harq_status + harq_ack[subframe_dl2].send_harq_status + harq_ack[subframe_dl3].send_harq_status;
LOG_I(PHY,"TDD Config3 UL Sfn %d, dl Sfn0 %d status %d o_Ack %d, dl Sfn1 %d status %d o_Ack %d dl Sfn2 %d status %d o_Ack %d dl Sfn3 %d status %d o_Ack %d subframe_rx %d N_bundled %d status %d\n",
subframe_tx, subframe_dl0, harq_ack[subframe_dl0].send_harq_status,harq_ack[subframe_dl0].ack,
subframe_dl1, harq_ack[subframe_dl1].send_harq_status,harq_ack[subframe_dl1].ack,
subframe_dl2, harq_ack[subframe_dl2].send_harq_status,harq_ack[subframe_dl2].ack,
subframe_dl3, harq_ack[subframe_dl3].send_harq_status,harq_ack[subframe_dl3].ack,subframe_rx, pN_bundled[0], status);
if (do_reset) {
// reset ACK/NACK status
harq_ack[subframe_dl0].ack = 2;
harq_ack[subframe_dl1].ack = 2;
harq_ack[subframe_dl2].ack = 2;
harq_ack[subframe_dl3].ack = 2;
harq_ack[subframe_dl0].send_harq_status = 0;
harq_ack[subframe_dl1].send_harq_status = 0;
harq_ack[subframe_dl2].send_harq_status = 0;
harq_ack[subframe_dl3].send_harq_status = 0;
}
break;
}
}
//printf("status %d\n",status);
return(status);
}
uint8_t get_ack(LTE_DL_FRAME_PARMS *frame_parms,
harq_status_t *harq_ack,
unsigned char subframe_tx,
unsigned char subframe_rx,
unsigned char *o_ACK,
uint8_t cw_idx)
{
uint8_t N_bundled = 0;
return get_reset_ack(frame_parms, harq_ack, subframe_tx, subframe_rx, o_ACK, &N_bundled, cw_idx, 0);
}
uint8_t reset_ack(LTE_DL_FRAME_PARMS *frame_parms,
harq_status_t *harq_ack,
unsigned char subframe_tx,
unsigned char subframe_rx,
unsigned char *o_ACK,
uint8_t *pN_bundled,
uint8_t cw_idx)
{
return get_reset_ack(frame_parms, harq_ack, subframe_tx, subframe_rx, o_ACK, pN_bundled, cw_idx, 1);
}
uint8_t Np6[4]= {0,1,3,5};
uint8_t Np15[4]= {0,3,8,13};
uint8_t Np25[4]= {0,5,13,22};
uint8_t Np50[4]= {0,11,27,44};
uint8_t Np75[4]= {0,16,41,66};
uint8_t Np100[4]= {0,22,55,88};
// This is part of the PUCCH allocation procedure (see Section 10.1 36.213)
uint16_t get_Np(uint8_t N_RB_DL,uint8_t nCCE,uint8_t plus1)
{
uint8_t *Np;
switch (N_RB_DL) {
case 6:
Np=Np6;
break;
case 15:
Np=Np15;
break;
case 25:
Np=Np25;
break;
case 50:
Np=Np50;
break;
case 75:
Np=Np75;
break;
case 100:
Np=Np100;
break;
default:
LOG_E(PHY,"get_Np() FATAL: unsupported N_RB_DL %d\n",N_RB_DL);
return(0);
break;
}
if (nCCE>=Np[2])
return(Np[2+plus1]);
else if (nCCE>=Np[1])
return(Np[1+plus1]);
else
return(Np[0+plus1]);
}
lte_subframe_t subframe_select(LTE_DL_FRAME_PARMS *frame_parms,unsigned char subframe)
{
// if FDD return dummy value
if (frame_parms->frame_type == FDD)
return(SF_DL);
switch (frame_parms->tdd_config) {
case 1:
switch (subframe) {
case 0:
case 4:
case 5:
case 9:
return(SF_DL);
break;
case 2:
case 3:
case 7:
case 8:
return(SF_UL);
break;
default:
return(SF_S);
break;
}
case 3:
if ((subframe<1) || (subframe>=5))
return(SF_DL);
else if ((subframe>1) && (subframe < 5))
return(SF_UL);
else if (subframe==1)
return (SF_S);
else {
LOG_E(PHY,"[PHY_PROCEDURES_LTE] Unknown subframe number\n");
return(255);
}
case 4:
if ((subframe<1) || (subframe>=4))
return(SF_DL);
else if ((subframe>1) && (subframe < 4))
return(SF_UL);
else if (subframe==1)
return (SF_S);
else {
LOG_E(PHY,"[PHY_PROCEDURES_LTE] Unknown subframe number\n");
return(255);
}
case 5:
if ((subframe<1) || (subframe>=3))
return(SF_DL);
else if ((subframe>1) && (subframe < 3))
return(SF_UL);
else if (subframe==1)
return (SF_S);
else {
LOG_E(PHY,"[PHY_PROCEDURES_LTE] Unknown subframe number\n");
return(255);
}
break;
default:
LOG_E(PHY,"subframe %d Unsupported TDD configuration %d\n",subframe,frame_parms->tdd_config);
mac_xface->macphy_exit("subframe x Unsupported TDD configuration");
return(255);
}
}
dci_detect_mode_t dci_detect_mode_select(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe)
{
dci_detect_mode_t ret = 0;
static dci_detect_mode_t Table_8_2_3gpp_36_213[][10] = {
//subf0 , subf1 , subf2 , subf3 , subf4 , subf5 , subf6 , subf7 , subf8 , subf9
{UL_DL_DCI, UL_DL_DCI , NO_DCI , NO_DCI , NO_DCI , UL_DL_DCI , UL_DL_DCI , NO_DCI, NO_DCI , NO_DCI }, // tdd0
{DL_DCI , UL_DL_DCI , NO_DCI , NO_DCI , UL_DL_DCI , DL_DCI , UL_DL_DCI , NO_DCI, NO_DCI , UL_DL_DCI }, // tdd1
{DL_DCI , DL_DCI , NO_DCI , UL_DL_DCI , DL_DCI , DL_DCI , DL_DCI , NO_DCI, UL_DL_DCI , DL_DCI }, // tdd2
{UL_DL_DCI, DL_DCI , NO_DCI , NO_DCI , NO_DCI , DL_DCI , DL_DCI , DL_DCI, UL_DL_DCI , UL_DL_DCI }, // tdd3
{DL_DCI , DL_DCI , NO_DCI , NO_DCI , DL_DCI , DL_DCI , DL_DCI , DL_DCI, UL_DL_DCI , UL_DL_DCI }, // tdd4
{DL_DCI , DL_DCI , NO_DCI , DL_DCI , DL_DCI , DL_DCI , DL_DCI , DL_DCI, UL_DL_DCI , DL_DCI }, // tdd5
{UL_DL_DCI, UL_DL_DCI , NO_DCI , NO_DCI , NO_DCI , UL_DL_DCI , UL_DL_DCI , NO_DCI, NO_DCI , UL_DL_DCI }}; // tdd6
DevAssert(subframe>=0 && subframe<=9);
DevAssert((frame_parms->tdd_config)>=0 && (frame_parms->tdd_config)<=6);
if (frame_parms->frame_type == FDD) {
ret = UL_DL_DCI;
} else {
ret = Table_8_2_3gpp_36_213[frame_parms->tdd_config][subframe];
}
LOG_D(PHY, "subframe %d: detect UL_DCI=%d, detect DL_DCI=%d\n", subframe, (ret & UL_DCI)>0, (ret & DL_DCI)>0);
return ret;
}
lte_subframe_t get_subframe_direction(uint8_t Mod_id,uint8_t CC_id,uint8_t subframe)
{
return(subframe_select(&PHY_vars_eNB_g[Mod_id][CC_id]->frame_parms,subframe));
}
uint8_t phich_subframe_to_harq_pid(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t subframe)
{
//LOG_D(PHY,"phich_subframe_to_harq_pid.c: frame %d, subframe %d\n",frame,subframe);
return(subframe2harq_pid(frame_parms,
phich_frame2_pusch_frame(frame_parms,frame,subframe),
phich_subframe2_pusch_subframe(frame_parms,subframe)));
}
unsigned int is_phich_subframe(LTE_DL_FRAME_PARMS *frame_parms,unsigned char subframe)
{
if (frame_parms->frame_type == FDD) {
return(1);
} else {
switch (frame_parms->tdd_config) {
case 1:
if ((subframe == 1) || (subframe == 4) || (subframe == 6) || (subframe == 9))
return(1);
break;
case 3:
if ((subframe == 0) || (subframe == 8) || (subframe == 9))
return(1);
break;
case 4:
if ((subframe == 8) || (subframe == 9) )
return(1);
break;
case 5:
if (subframe == 8)
return(1);
break;
default:
return(0);
break;
}
}
return(0);
}
#ifdef LOCALIZATION
double aggregate_eNB_UE_localization_stats(PHY_VARS_eNB *phy_vars_eNB, int8_t UE_id, frame_t frame, sub_frame_t subframe, int32_t UE_tx_power_dB)
{
// parameters declaration
int8_t Mod_id, CC_id;
// int32_t harq_pid;
int32_t avg_power, avg_rssi, median_power, median_rssi, median_subcarrier_rss, median_TA, median_TA_update, ref_timestamp_ms, current_timestamp_ms;
char cqis[100], sub_powers[2048];
int len = 0, i;
struct timeval ts;
double sys_bw = 0;
uint8_t N_RB_DL;
LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
Mod_id = eNB->Mod_id;
CC_id = eNB->CC_id;
ref_timestamp_ms = eNB->ulsch[UE_id+1]->reference_timestamp_ms;
for (i=0; i<13; i++) {
len += sprintf(&cqis[len]," %d ", eNB->UE_stats[(uint32_t)UE_id].DL_subband_cqi[0][i]);
}
len = 0;
for (i=0; i<eNB->lte_eNB_pusch_vars[(uint32_t)UE_id]->active_subcarrier; i++) {
len += sprintf(&sub_powers[len]," %d ", eNB->lte_eNB_pusch_vars[(uint32_t)UE_id]->subcarrier_power[i]);
}
gettimeofday(&ts, NULL);
current_timestamp_ms = ts.tv_sec * 1000 + ts.tv_usec / 1000;
LOG_D(LOCALIZE, " PHY: [UE %x/%d -> eNB %d], timestamp %d, "
"frame %d, subframe %d"
"UE Tx power %d dBm, "
"RSSI ant1 %d dBm, "
"RSSI ant2 %d dBm, "
"pwr ant1 %d dBm, "
"pwr ant2 %d dBm, "
"Rx gain %d dB, "
"TA %d, "
"TA update %d, "
"DL_CQI (%d,%d), "
"Wideband CQI (%d,%d), "
"DL Subband CQI[13] %s \n",
// "timestamp %d, (%d active subcarrier) %s \n"
eNB->dlsch[(uint32_t)UE_id][0]->rnti, UE_id, Mod_id, current_timestamp_ms,
frame,subframe,
UE_tx_power_dB,
eNB->UE_stats[(uint32_t)UE_id].UL_rssi[0],
eNB->UE_stats[(uint32_t)UE_id].UL_rssi[1],
dB_fixed(eNB->lte_eNB_pusch_vars[(uint32_t)UE_id]->ulsch_power[0]),
dB_fixed(eNB->lte_eNB_pusch_vars[(uint32_t)UE_id]->ulsch_power[1]),
eNB->rx_total_gain_eNB_dB,
eNB->UE_stats[(uint32_t)UE_id].UE_timing_offset, // raw timing advance 1/sampling rate
eNB->UE_stats[(uint32_t)UE_id].timing_advance_update,
eNB->UE_stats[(uint32_t)UE_id].DL_cqi[0],eNB->UE_stats[(uint32_t)UE_id].DL_cqi[1],
eNB->measurements[Mod_id].wideband_cqi_dB[(uint32_t)UE_id][0],
eNB->measurements[Mod_id].wideband_cqi_dB[(uint32_t)UE_id][1],
cqis);
LOG_D(LOCALIZE, " PHY: timestamp %d, (%d active subcarrier) %s \n",
current_timestamp_ms,
eNB->lte_eNB_pusch_vars[(uint32_t)UE_id]->active_subcarrier,
sub_powers);
N_RB_DL = frame_parms->N_RB_DL;
switch (N_RB_DL) {
case 6:
sys_bw = 1.92;
break;
case 25:
sys_bw = 7.68;
break;
case 50:
sys_bw = 15.36;
break;
case 100:
sys_bw = 30.72;
break;
}
if ((current_timestamp_ms - ref_timestamp_ms > eNB->ulsch[UE_id+1]->aggregation_period_ms)) {
// check the size of one list to be sure there was a message transmitted during the defined aggregation period
// make the reference timestamp == current timestamp
eNB->ulsch[UE_id+1]->reference_timestamp_ms = current_timestamp_ms;
int i;
for (i=0; i<10; i++) {
median_power = calculate_median(&eNB->ulsch[UE_id+1]->loc_rss_list[i]);
del(&eNB->ulsch[UE_id+1]->loc_rss_list[i]);
median_rssi = calculate_median(&eNB->ulsch[UE_id+1]->loc_rssi_list[i]);
del(&eNB->ulsch[UE_id+1]->loc_rssi_list[i]);
median_subcarrier_rss = calculate_median(&eNB->ulsch[UE_id+1]->loc_subcarrier_rss_list[i]);
del(&eNB->ulsch[UE_id+1]->loc_subcarrier_rss_list[i]);
median_TA = calculate_median(&eNB->ulsch[UE_id+1]->loc_timing_advance_list[i]);
del(&eNB->ulsch[UE_id+1]->loc_timing_advance_list[i]);
median_TA_update = calculate_median(&eNB->ulsch[UE_id+1]->loc_timing_update_list[i]);
del(&eNB->ulsch[UE_id+1]->loc_timing_update_list[i]);
if (median_power != 0)
push_front(&eNB->ulsch[UE_id+1]->tot_loc_rss_list,median_power);
if (median_rssi != 0)
push_front(&eNB->ulsch[UE_id+1]->tot_loc_rssi_list,median_rssi);
if (median_subcarrier_rss != 0)
push_front(&eNB->ulsch[UE_id+1]->tot_loc_subcarrier_rss_list,median_subcarrier_rss);
if (median_TA != 0)
push_front(&eNB->ulsch[UE_id+1]->tot_loc_timing_advance_list,median_TA);
if (median_TA_update != 0)
push_front(&eNB->ulsch[UE_id+1]->tot_loc_timing_update_list,median_TA_update);
initialize(&eNB->ulsch[UE_id+1]->loc_rss_list[i]);
initialize(&eNB->ulsch[UE_id+1]->loc_subcarrier_rss_list[i]);
initialize(&eNB->ulsch[UE_id+1]->loc_rssi_list[i]);
initialize(&eNB->ulsch[UE_id+1]->loc_timing_advance_list[i]);
initialize(&eNB->ulsch[UE_id+1]->loc_timing_update_list[i]);
}
median_power = calculate_median(&eNB->ulsch[UE_id+1]->tot_loc_rss_list);
del(&eNB->ulsch[UE_id+1]->tot_loc_rss_list);
median_rssi = calculate_median(&eNB->ulsch[UE_id+1]->tot_loc_rssi_list);
del(&eNB->ulsch[UE_id+1]->tot_loc_rssi_list);
median_subcarrier_rss = calculate_median(&eNB->ulsch[UE_id+1]->tot_loc_subcarrier_rss_list);
del(&eNB->ulsch[UE_id+1]->tot_loc_subcarrier_rss_list);
median_TA = calculate_median(&eNB->ulsch[UE_id+1]->tot_loc_timing_advance_list);
del(&eNB->ulsch[UE_id+1]->tot_loc_timing_advance_list);
median_TA_update = calculate_median(&eNB->ulsch[UE_id+1]->tot_loc_timing_update_list);
del(&eNB->ulsch[UE_id+1]->tot_loc_timing_update_list);
initialize(&eNB->ulsch[UE_id+1]->tot_loc_rss_list);
initialize(&eNB->ulsch[UE_id+1]->tot_loc_subcarrier_rss_list);
initialize(&eNB->ulsch[UE_id+1]->tot_loc_rssi_list);
initialize(&eNB->ulsch[UE_id+1]->tot_loc_timing_advance_list);
initialize(&eNB->ulsch[UE_id+1]->tot_loc_timing_update_list);
double alpha = 2, power_distance, time_distance;
// distance = 10^((Ptx - Prx - A)/10alpha), A is a constance experimentally evaluated
// A includes the rx gain (eNB->rx_total_gain_eNB_dB) and hardware calibration
power_distance = pow(10, ((UE_tx_power_dB - median_power - eNB->rx_total_gain_eNB_dB + 133)/(10.0*alpha)));
// current measurements shows constant UE_timing_offset = 18
and timing_advance_update = 11 at 1m. at 5m, timing_advance_update = 12//
//time_distance = (double) 299792458*(eNB->UE_stats[(uint32_t)UE_id].timing_advance_update)/(sys_bw*1000000);
time_distance = (double) abs(eNB->UE_stats[(uint32_t)UE_id].timing_advance_update - 11) * 4.89;// (3 x 108 x 1 / (15000 x 2048)) / 2 = 4.89 m
eNB->UE_stats[(uint32_t)UE_id].distance.time_based = time_distance;
eNB->UE_stats[(uint32_t)UE_id].distance.power_based = power_distance;
LOG_D(LOCALIZE, " PHY agg [UE %x/%d -> eNB %d], timestamp %d, "
"frame %d, subframe %d "
"UE Tx power %d dBm, "
"median RSSI %d dBm, "
"median Power %d dBm, "
"Rx gain %d dB, "
"power estimated r = %0.3f, "
" TA %d, update %d "
"TA estimated r = %0.3f\n"
,eNB->dlsch[(uint32_t)UE_id][0]->rnti, UE_id, Mod_id, current_timestamp_ms,
frame, subframe,
UE_tx_power_dB,
median_rssi,
median_power,
eNB->rx_total_gain_eNB_dB,
power_distance,
eNB->UE_stats[(uint32_t)UE_id].UE_timing_offset, median_TA_update,
time_distance);
return 0;
} else {
avg_power = (dB_fixed(eNB->lte_eNB_pusch_vars[(uint32_t)UE_id]->ulsch_power[0]) + dB_fixed(eNB->lte_eNB_pusch_vars[(uint32_t)UE_id]->ulsch_power[1]))/2;
avg_rssi = (eNB->UE_stats[(uint32_t)UE_id].UL_rssi[0] + eNB->UE_stats[(uint32_t)UE_id].UL_rssi[1])/2;
push_front(&eNB->ulsch[UE_id+1]->loc_rss_list[subframe],avg_power);
push_front(&eNB->ulsch[UE_id+1]->loc_rssi_list[subframe],avg_rssi);
for (i=0; i<eNB->lte_eNB_pusch_vars[(uint32_t)UE_id]->active_subcarrier; i++) {
push_front(&eNB->ulsch[UE_id+1]->loc_subcarrier_rss_list[subframe], eNB->lte_eNB_pusch_vars[(uint32_t)UE_id]->subcarrier_power[i]);
}
push_front(&eNB->ulsch[UE_id+1]->loc_timing_advance_list[subframe], eNB->UE_stats[(uint32_t)UE_id].UE_timing_offset);
push_front(&eNB->ulsch[UE_id+1]->loc_timing_update_list[subframe], eNB->UE_stats[(uint32_t)UE_id].timing_advance_update);
return -1;
}
}
#endif
LTE_eNB_UE_stats* get_UE_stats(uint8_t Mod_id, uint8_t CC_id,uint16_t rnti)
{
int8_t UE_id;
if ((PHY_vars_eNB_g == NULL) || (PHY_vars_eNB_g[Mod_id] == NULL) || (PHY_vars_eNB_g[Mod_id][CC_id]==NULL)) {
LOG_E(PHY,"get_UE_stats: No eNB found (or not allocated) for Mod_id %d,CC_id %d\n",Mod_id,CC_id);
return NULL;
}
UE_id = find_ue(rnti, PHY_vars_eNB_g[Mod_id][CC_id]);
if (UE_id == -1) {
// LOG_E(PHY,"get_UE_stats: UE with rnti %x not found\n",rnti);
return NULL;
}
return(&PHY_vars_eNB_g[Mod_id][CC_id]->UE_stats[(uint32_t)UE_id]);
}
int8_t find_ue(uint16_t rnti, PHY_VARS_eNB *eNB)
{
uint8_t i;
for (i=0; i<NUMBER_OF_UE_MAX_NB_IoT; i++) {
if ((eNB->dlsch[i]) &&
(eNB->dlsch[i][0]) &&
(eNB->dlsch[i][0]->rnti==rnti)) {
return(i);
}
}
#ifdef CBA
for (i=0; i<NUM_MAX_CBA_GROUP; i++) {
if ((eNB->ulsch[i]) && // ue J is the representative of group j
(eNB->ulsch[i]->num_active_cba_groups) &&
(eNB->ulsch[i]->cba_rnti[i]== rnti))
return(i);
}
#endif
return(-1);
}
*/
int8_t find_ue_NB_IoT(uint16_t rnti, PHY_VARS_eNB_NB_IoT *eNB)
{
uint8_t i;
for (i=0; i<NUMBER_OF_UE_MAX_NB_IoT; i++) {
if ((eNB->ndlsch[i]) &&
(eNB->ndlsch[i]->rnti==rnti)) {
return(i);
}
}
return(-1);
}
NB_IoT_DL_FRAME_PARMS *get_NB_IoT_frame_parms(module_id_t Mod_id, uint8_t CC_id)
{
return(&PHY_vars_eNB_NB_IoT_g[Mod_id][CC_id]->frame_parms_NB_IoT);
}
/*
LTE_DL_FRAME_PARMS* get_lte_frame_parms(module_id_t Mod_id, uint8_t CC_id)
{
return(&PHY_vars_eNB_g[Mod_id][CC_id]->frame_parms);
}
MU_MIMO_mode *get_mu_mimo_mode (module_id_t Mod_id, uint8_t CC_id, rnti_t rnti)
{
int8_t UE_id = find_ue( rnti, PHY_vars_eNB_g[Mod_id][CC_id] );
if (UE_id == -1)
return 0;
return &PHY_vars_eNB_g[Mod_id][CC_id]->mu_mimo_mode[UE_id];
}
int is_srs_occasion_common(LTE_DL_FRAME_PARMS *frame_parms,int frame_tx,int subframe_tx)
{
uint8_t isSubframeSRS = 0; // SRS Cell Occasion
//ue->ulsch[eNB_id]->srs_active = 0;
//ue->ulsch[eNB_id]->Nsymb_pusch = 12-(frame_parms->Ncp<<1)- ue->ulsch[eNB_id]->srs_active;
if(frame_parms->soundingrs_ul_config_common.enabled_flag)
{
LOG_D(PHY," SRS SUBFRAMECONFIG: %d\n", frame_parms->soundingrs_ul_config_common.srs_SubframeConfig);
uint8_t TSFC;
uint16_t deltaTSFC; // bitmap
uint8_t srs_SubframeConfig;
// table resuming TSFC (Period) and deltaSFC (offset)
const uint16_t deltaTSFCTabType1[15][2] = { {1,1},{1,2},{2,2},{1,5},{2,5},{4,5},{8,5},{3,5},{12,5},{1,10},{2,10},{4,10},{8,10},{351,10},{383,10} }; // Table 5.5.3.3-2 3GPP 36.211 FDD
const uint16_t deltaTSFCTabType2[14][2] = { {2,5},{6,5},{10,5},{18,5},{14,5},{22,5},{26,5},{30,5},{70,10},{74,10},{194,10},{326,10},{586,10},{210,10} }; // Table 5.5.3.3-2 3GPP 36.211 TDD
srs_SubframeConfig = frame_parms->soundingrs_ul_config_common.srs_SubframeConfig;
if (FDD == frame_parms->frame_type)
{
// srs_SubframeConfig =< 14
deltaTSFC = deltaTSFCTabType1[srs_SubframeConfig][0];
TSFC = deltaTSFCTabType1[srs_SubframeConfig][1];
}
else
{
// srs_SubframeConfig =< 13
deltaTSFC = deltaTSFCTabType2[srs_SubframeConfig][0];
TSFC = deltaTSFCTabType2[srs_SubframeConfig][1];
}
// Sounding reference signal subframes are the subframes satisfying ns/2 mod TSFC (- deltaTSFC
uint16_t tmp = (subframe_tx % TSFC);
if((1<<tmp) & deltaTSFC)
{
// This is a Sounding reference signal subframes
isSubframeSRS = 1;
}
LOG_D(PHY," ISTDD: %d, TSFC: %d, deltaTSFC: %d, AbsSubframeTX: %d.%d\n", frame_parms->frame_type, TSFC, deltaTSFC, frame_tx, subframe_tx);
}
return(isSubframeSRS);
}
void compute_srs_pos(lte_frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset)
{
if(TDD == frameType)
{
if(isrs<10)
{
mac_xface->macphy_exit("2 ms SRS periodicity not supported");
}
if((isrs>9)&&(isrs<15))
{
*psrsPeriodicity=5;
*psrsOffset=isrs-10;
}
if((isrs>14)&&(isrs<25))
{
*psrsPeriodicity=10;
*psrsOffset=isrs-15;
}
if((isrs>24)&&(isrs<45))
{
*psrsPeriodicity=20;
*psrsOffset=isrs-25;
}
if((isrs>44)&&(isrs<85))
{
*psrsPeriodicity=40;
*psrsOffset=isrs-45;
}
if((isrs>84)&&(isrs<165))
{
*psrsPeriodicity=80;
*psrsOffset=isrs-85;
}
if((isrs>164)&&(isrs<325))
{
*psrsPeriodicity=160;
*psrsOffset=isrs-165;
}
if((isrs>324)&&(isrs<645))
{
*psrsPeriodicity=320;
*psrsOffset=isrs-325;
}
if(isrs>644)
{
mac_xface->macphy_exit("Isrs out of range");
}
}
else
{
if(isrs<2)
{
*psrsPeriodicity=2;
*psrsOffset=isrs;
}
if((isrs>1)&&(isrs<7))
{
*psrsPeriodicity=5;
*psrsOffset=isrs-2;
}
if((isrs>6)&&(isrs<17))
{
*psrsPeriodicity=10;
*psrsOffset=isrs-7;
}
if((isrs>16)&&(isrs<37))
{
*psrsPeriodicity=20;
*psrsOffset=isrs-17;
}
if((isrs>36)&&(isrs<77))
{
*psrsPeriodicity=40;
*psrsOffset=isrs-37;
}
if((isrs>76)&&(isrs<157))
{
*psrsPeriodicity=80;
*psrsOffset=isrs-77;
}
if((isrs>156)&&(isrs<317))
{
*psrsPeriodicity=160;
*psrsOffset=isrs-157;
}
if((isrs>316)&&(isrs<637))
{
*psrsPeriodicity=320;
*psrsOffset=isrs-317;
}
if(isrs>636)
{
mac_xface->macphy_exit("Isrs out of range");
}
}
}
*/
......@@ -32,8 +32,9 @@
#include "PHY/defs_eNB.h"
#include "PHY/defs_L1_NB_IoT.h"
#include "PHY/extern.h"
#include "PHY/LTE_ESTIMATION/defs_NB_IoT.h"
#include "PHY/phy_extern.h"
#include "PHY/defs_common.h"
#include "PHY/NBIoT_ESTIMATION/defs_NB_IoT.h"
#include "PHY/NBIoT_TRANSPORT/defs_NB_IoT.h"
#include "PHY/NBIoT_TRANSPORT/proto_NB_IoT.h"
//#include "PHY/extern_NB_IoT.h" //where we get the global Sched_Rsp_t structure filled
......@@ -45,10 +46,10 @@
#include "SCHED_NBIOT/defs_NB_IoT.h"
#include "openair2/RRC/NBIOT/proto_NB_IoT.h"
#include "openair2/RRC/NBIOT/extern_NB_IoT.h"
#include "RRC/LITE/MESSAGES/asn1_msg_NB_IoT.h"
//#include "RRC/LITE/MESSAGES/asn1_msg_NB_IoT.h"
#include "UTIL/LOG/log.h"
#include "UTIL/LOG/vcd_signal_dumper.h"
//#include "UTIL/LOG/log.h"
//#include "UTIL/LOG/vcd_signal_dumper.h"
#include "T.h"
......@@ -430,7 +431,7 @@ void phy_procedures_eNB_uespec_RX_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,eNB_rxtx_proc_
// the function called by l1 IF-Module
void generate_eNB_dlsch_params_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,eNB_rxtx_proc_NB_IOT_t * proc,nfapi_dl_config_request_pdu_t *dl_config_pdu)
void generate_eNB_dlsch_params_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,eNB_rxtx_proc_NB_IoT_t * proc,nfapi_dl_config_request_pdu_t *dl_config_pdu)
{
int UE_id = -1;
NB_IoT_DL_FRAME_PARMS *fp = &eNB->frame_parms_NB_IoT;
......@@ -852,7 +853,7 @@ void npdsch_procedures(PHY_VARS_eNB_NB_IoT *eNB,
}
extern int oai_exit;
extern volatile int oai_exit;
/*
* ASSUMPTION
......@@ -1116,6 +1117,7 @@ void phy_procedures_eNB_TX_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
//this should give only 1 result (since only 1 ndlsch procedure is activated at once) so we brak after the transmission
for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX_NB_IoT; UE_id++)
{
if(eNB->ndlsch[(uint8_t)UE_id] != NULL && eNB->ndlsch[(uint8_t)UE_id]->active == 1 && (eNB->ndlsch_SIB1->harq_process->status != ACTIVE_NB_IoT || subframe != 4)) //condition on sib1-NB
{
if(frame%2 == 0)//condition on NSSS (subframe 9 not available)
......@@ -1229,7 +1231,7 @@ void phy_procedures_eNB_TX_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
}
uint32_t rx_nprach_NB_IoT(PHY_VARS_eNB *eNB, int frame, uint8_t subframe, uint16_t *rnti, uint16_t *preamble_index, uint16_t *timing_advance) {
uint32_t rx_nprach_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB, int frame, uint8_t subframe, uint16_t *rnti, uint16_t *preamble_index, uint16_t *timing_advance) {
uint32_t estimated_TA;
//int frame,frame_mod; // subframe,
......@@ -1242,8 +1244,7 @@ uint32_t rx_nprach_NB_IoT(PHY_VARS_eNB *eNB, int frame, uint8_t subframe, uint16
}
void fill_crc_indication_NB_IoT(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe,uint8_t decode_flag) {
void fill_crc_indication_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,int UE_id,int frame,int subframe,uint8_t decode_flag) {
pthread_mutex_lock(&eNB->UL_INFO_mutex);
......@@ -1275,7 +1276,7 @@ void fill_crc_indication_NB_IoT(PHY_VARS_eNB *eNB,int UE_id,int frame,int subfra
pthread_mutex_unlock(&eNB->UL_INFO_mutex);
}
void fill_rx_indication_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,uint8_t data_or_control, uint8_t decode_flag)
void fill_rx_indication_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,eNB_rxtx_proc_NB_IoT_t *proc,uint8_t data_or_control, uint8_t decode_flag)
{
nfapi_rx_indication_pdu_t *pdu;
nfapi_nb_harq_indication_pdu_t *ack_ind; // &eNB->UL_INFO.nb_harq_ind.nb_harq_indication_body.nb_harq_pdu_list[0] // nb_harq_indication_fdd_rel13->harq_tb1
......@@ -1347,7 +1348,7 @@ void fill_rx_indication_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,uint8_t d
}
void prach_procedures_NB_IoT(PHY_VARS_eNB *eNB) {
void prach_procedures_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB) {
// LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
// uint16_t preamble_energy_list[64],preamble_delay_list[64];
// uint16_t preamble_max,preamble_energy_max;
......
......@@ -768,6 +768,8 @@ static void *eNB_thread_prach( void *param ) {
#endif
);
prach_procedures_NB_IoT(eNB);
if (release_thread(&proc->mutex_prach,&proc->instance_cnt_prach,"eNB_prach_thread") < 0) break;
}
......
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