Commit af2cb07f authored by Nick Ho's avatar Nick Ho

L1 for RX, 5 warning in PHY

parent 771043a4
......@@ -1157,6 +1157,7 @@ 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/ulsch_demodulation_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
......
/*
* 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
*/
unsigned short f1f2mat_old[2*188] = {3, 10,
7, 12,
19, 42,
7, 16,
7, 18,
11, 20,
5, 22,
11, 24,
7, 26,
41, 84,
103, 90,
15, 32,
9, 34,
17, 108,
9, 38,
21, 120,
101, 84,
21, 44,
57, 46,
23, 48,
13, 50,
27, 52,
11, 36,
27, 56,
85, 58,
29, 60,
33, 62,
15, 32,
17, 198,
33, 68,
103, 210,
19, 36,
19, 74,
37, 76,
19, 78,
21, 120,
21, 82,
115, 84,
193, 86,
21, 44,
133, 90,
81, 46,
45, 94,
23, 48,
243, 98,
151, 40,
155, 102,
25, 52,
51, 106,
47, 72,
91, 110,
29, 168,
29, 114,
247, 58,
29, 118,
89, 180,
91, 122,
157, 62,
55, 84,
31, 64,
17, 66,
35, 68,
227, 420,
65, 96,
19, 74,
37, 76,
41, 234,
39, 80,
185, 82,
43, 252,
21, 86,
155, 44,
79, 120,
139, 92,
23, 94,
217, 48,
25, 98,
17, 80,
127, 102,
25, 52,
239, 106,
17, 48,
137, 110,
215, 112,
29, 114,
15, 58,
147, 118,
29, 60,
59, 122,
65, 124,
55, 84,
31, 64,
17, 66,
171, 204,
67, 140,
35, 72,
19, 74,
39, 76,
19, 78,
199, 240,
21, 82,
211, 252,
21, 86,
43, 88,
149, 60,
45, 92,
49, 846,
71, 48,
13, 28,
17, 80,
25, 102,
183, 104,
55, 954,
127, 96,
27, 110,
29, 112,
29, 114,
57, 116,
45, 354,
31, 120,
59, 610,
185, 124,
113, 420,
31, 64,
17, 66,
171, 136,
209, 420,
253, 216,
367, 444,
265, 456,
181, 468,
39, 80,
27, 164,
127, 504,
143, 172,
43, 88,
29, 300,
45, 92,
157, 188,
47, 96,
13, 28,
111, 240,
443, 204,
51, 104,
51, 212,
451, 192,
257, 220,
57, 336,
313, 228,
271, 232,
179, 236,
331, 120,
363, 244,
375, 248,
127, 168,
31, 64,
33, 130,
43, 264,
33, 134,
477, 408,
35, 138,
233, 280,
357, 142,
337, 480,
37, 146,
71, 444,
71, 120,
37, 152,
39, 462,
127, 234,
39, 158,
39, 80,
31, 96,
113, 902,
41, 166,
251, 336,
43, 170,
21, 86,
43, 174,
45, 176,
45, 178,
161, 120,
89, 182,
323, 184,
47, 186,
23, 94,
47, 190,
263, 480
};
/*
* 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.1 (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.h
* \brief typedefs for LTE DCI structures from 36-212, V8.6 2009-03. Limited to 5 MHz formats for the moment.Current LTE compliance V8.6 2009-03.
* \author R. Knopp
* \date 2011
* \version 0.1
* \company Eurecom
* \email: knopp@eurecom.fr
* \note
* \warning
*/
#ifndef __DCI_NB_IOT_H__
#define __DCI_NB_IOT_H__
//#ifndef USER_MODE
//#include "PHY/types.h"
//#else
#include <stdint.h>
//#endif
typedef enum
{
DCIFormatN0 = 0,
DCIFormatN1,
DCIFormatN1_RA,//is for initial RA procedure (semi-static information) so maybe is not needed
DCIFormatN1_RAR,
DCIFormatN2,
DCIFormatN2_Ind,
DCIFormatN2_Pag,
}DCI_format_NB_IoT_t;
/// DCI Format Type 0 (180 kHz, 23 bits)
struct DCIFormatN0{
/// 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;
};
typedef struct DCIFormatN0 DCIFormatN0_t;
/// DCI Format Type N1 for User data
struct DCIFormatN1{
/// type = 0 => DCI Format N0, type = 1 => DCI Format N1,1bits
uint8_t type;
//NPDCCH order indicator (set to 0), 1 bits
uint8_t orderIndicator;
// Scheduling Delay,3 bits
uint8_t Scheddly;
// Resourse Assignment (RU Assignment),3 bits
uint8_t ResAssign;
// Modulation and Coding Scheme,4 bits
uint8_t mcs;
// Repetition Number,4 bits
uint8_t RepNum;
// New Data Indicator,1 bits
uint8_t ndi;
// HARQ-ACK resource,4 bits
uint8_t HARQackRes;
// DCI subframe repetition Number,2 bits
uint8_t DCIRep;
};
typedef struct DCIFormatN1 DCIFormatN1_t;
/// DCI Format Type N1 for initial RA
struct DCIFormatN1_RA{
/// type = 0 => DCI Format N0, type = 1 => DCI Format N1, 1 bits
uint8_t type;
//NPDCCH order indicator (set to 0),1 bits
uint8_t orderIndicator;
// Start number of NPRACH repetiiton, 2 bits
uint8_t Scheddly;
// Subcarrier indication of NPRACH, 6 bits
uint8_t scind;
// All the remainging bits, 13 bits
uint8_t remaingingBits;
};
typedef struct DCIFormatN1_RA DCIFormatN1_RA_t;
/// DCI Format Type N1 for User data
struct DCIFormatN1_RAR{
/// type = 0 => DCI Format N0, type = 1 => DCI Format N1,1bits
uint8_t type;
//NPDCCH order indicator (set to 0), 1 bits
uint8_t orderIndicator;
// Scheduling Delay,3 bits
uint8_t Scheddly;
// Resourse Assignment (RU Assignment),3 bits
uint8_t ResAssign;
// Modulation and Coding Scheme,4 bits
uint8_t mcs;
// Repetition Number,4 bits
uint8_t RepNum;
// New Data Indicator,1 bits,reserved in the RAR
uint8_t ndi;
// HARQ-ACK resource,4 bits,reserved in the RAR
uint8_t HARQackRes;
// DCI subframe repetition Number,2 bits
uint8_t DCIRep;
};
typedef struct DCIFormatN1_RAR DCIFormatN1_RAR_t;
// DCI Format Type N2 for direct indication, 15 bits
struct DCIFormatN2_Ind{
//Flag for paging(1)/direct indication(0), set to 0,1 bits
uint8_t type;
//Direct indication information, 8 bits
uint8_t directIndInf;
// Reserved information bits, 6 bits
uint8_t resInfoBits;
};
typedef struct DCIFormatN2_Ind DCIFormatN2_Ind_t;
// DCI Format Type N2 for Paging, 15 bits
struct DCIFormatN2_Pag{
//Flag for paging(1)/direct indication(0), set to 1,1 bits
uint8_t type;
// Resourse Assignment (RU Assignment), 3 bits
uint8_t ResAssign;
// Modulation and Coding Scheme, 4 bits
uint8_t mcs;
// Repetition Number, 4 bits
uint8_t RepNum;
// Reserved 3 bits
uint8_t DCIRep;
};
typedef struct DCIFormatN2_Pag DCIFormatN2_Pag_t;
typedef union DCI_CONTENT {
//
DCIFormatN0_t DCIN0;
//
DCIFormatN1_t DCIN1;
//
DCIFormatN1_RA_t DCIN1_RA;
//
DCIFormatN1_RAR_t DCIN1_RAR;
//
DCIFormatN2_Ind_t DCIN2_Ind;
//
DCIFormatN2_Pag_t DCIN2_Pag;
}DCI_CONTENT;
/*Structure for packing*/
struct DCIN0{
/// DCI subframe repetition Number, 2 bits
uint8_t DCIRep:2;
/// New Data Indicator, 1 bits
uint8_t ndi:1;
/// Repetition Number, 3 bits
uint8_t RepNum:3;
/// Redundancy version for HARQ (only use 0 and 2), 1 bits
uint8_t rv:1;
/// Modulation and Coding Scheme, 4 bits
uint8_t mcs:4;
/// Scheduling Delay, 2 bits
uint8_t Scheddly:2;
/// Resourse Assignment (RU Assignment), 3 bits
uint8_t ResAssign:3;
/// Subcarrier indication, 6 bits
uint8_t scind:6;
/// type = 0 => DCI Format N0, type = 1 => DCI Format N1, 1 bits
uint8_t type:1;
} __attribute__ ((__packed__));
typedef struct DCIN0 DCIN0_t;
#define sizeof_DCIN0_t 23
struct DCIN1_RAR{
// DCI subframe repetition Number, 2 bits
uint8_t DCIRep:2;
// HARQ-ACK resource,4 bits
uint8_t HARQackRes:4;
// New Data Indicator,1 bits
uint8_t ndi:1;
// Repetition Number, 4 bits
uint8_t RepNum:4;
// Modulation and Coding Scheme, 4 bits
uint8_t mcs:4;
// Resourse Assignment (RU Assignment), 3 bits
uint8_t ResAssign:3;
// Scheduling Delay, 3 bits
uint8_t Scheddly:3;
//NPDCCH order indicator (set to 0),1 bits
uint8_t orderIndicator:1;
/// type = 0 => DCI Format N0, type = 1 => DCI Format N1, 1 bits
uint8_t type:1;
} __attribute__ ((__packed__));
typedef struct DCIN1_RAR DCIN1_RAR_t;
#define sizeof_DCIN1_RAR_t 23
struct DCIN1{
// DCI subframe repetition Number, 2 bits
uint8_t DCIRep:2;
// HARQ-ACK resource,4 bits
uint8_t HARQackRes:4;
// New Data Indicator,1 bits
uint8_t ndi:1;
// Repetition Number, 4 bits
uint8_t RepNum:4;
// Modulation and Coding Scheme, 4 bits
uint8_t mcs:4;
// Resourse Assignment (RU Assignment), 3 bits
uint8_t ResAssign:3;
// Scheduling Delay, 3 bits
uint8_t Scheddly:3;
//NPDCCH order indicator (set to 0),1 bits
uint8_t orderIndicator:1;
/// type = 0 => DCI Format N0, type = 1 => DCI Format N1, 1 bits
uint8_t type:1;
} __attribute__ ((__packed__));
typedef struct DCIN1 DCIN1_t;
#define sizeof_DCIN1_t 23
// DCI Format Type N2 for direct indication, 15 bits
struct DCIN2_Ind{
// Reserved information bits, 6 bits
uint8_t resInfoBits:6;
//Direct indication information, 8 bits
uint8_t directIndInf:8;
//Flag for paging(1)/direct indication(0), set to 0,1 bits
uint8_t type:1;
} __attribute__ ((__packed__));;
typedef struct DCIN2_Ind DCIN2_Ind_t;
#define sizeof_DCIN2_Ind_t 15
// DCI Format Type N2 for Paging, 15 bits
struct DCIN2_Pag{
// Reserved 3 bits
uint8_t DCIRep:3;
// Repetition Number, 4 bits
uint8_t RepNum:4;
// Modulation and Coding Scheme, 4 bits
uint8_t mcs:4;
// Resourse Assignment (RU Assignment), 3 bits
uint8_t ResAssign:3;
//Flag for paging(1)/direct indication(0), set to 1,1 bits
uint8_t type:1;
} __attribute__ ((__packed__));;
typedef struct DCIN2_Pag DCIN2_Pag_t;
#define sizeof_DCIN2_Pag_t 15
#define MAX_DCI_SIZE_BITS_NB_IoT 23
#endif
/*******************************************************************************
*******************************************************************************/
/*! \file PHY/LTE_TRANSPORT/defs_NB_IoT.h
* \brief data structures for NPDSCH/NDLSCH/NPUSCH/NULSCH physical and transport channel descriptors (TX/RX) of NB-IoT
* \author M. KANJ
* \date 2017
* \version 0.0
* \company bcom
* \email: matthieu.kanj@b-com.com
* \note
* \warning
*/
#ifndef __LTE_TRANSPORT_DEFS_NB_IOT__H__
#define __LTE_TRANSPORT_DEFS_NB_IOT__H__
////#include "PHY/defs.h"
//#include "PHY/defs_nb_iot.h"
#include "PHY/LTE_TRANSPORT/dci_NB_IoT.h"
#include "PHY/impl_defs_lte_NB_IoT.h"
#include "openair2/COMMON/platform_types.h"
//#include "dci.h"
#include "PHY/LTE_TRANSPORT/uci_NB_IoT.h"
//#include "dci.h"
//#include "uci.h"
//#ifndef STANDALONE_COMPILE
//#include "UTIL/LISTS/list.h"
//#endif
//#include "dci_nb_iot.h"
//#define MOD_TABLE_QPSK_OFFSET 1
//#define MOD_TABLE_16QAM_OFFSET 5
//#define MOD_TABLE_64QAM_OFFSET 21
//#define MOD_TABLE_PSS_OFFSET 85
//
//// structures below implement 36-211 and 36-212
//
//#define NSOFT 1827072
#define LTE_NULL_NB_IoT 2
//
//// maximum of 3 segments before each coding block if data length exceeds 6144 bits.
//
#define MAX_NUM_DLSCH_SEGMENTS_NB_IoT 16
//#define MAX_NUM_ULSCH_SEGMENTS MAX_NUM_DLSCH_SEGMENTS
//#define MAX_DLSCH_PAYLOAD_BYTES (MAX_NUM_DLSCH_SEGMENTS*768)
//#define MAX_ULSCH_PAYLOAD_BYTES (MAX_NUM_ULSCH_SEGMENTS*768)
//
//#define MAX_NUM_CHANNEL_BITS_NB_IOT (14*1200*6) // 14 symbols, 1200 REs, 12 bits/RE
//#define MAX_NUM_RE (14*1200)
//
//#if !defined(SI_RNTI)
//#define SI_RNTI (rnti_t)0xffff
//#endif
//#if !defined(M_RNTI)
//#define M_RNTI (rnti_t)0xfffd
//#endif
//#if !defined(P_RNTI)
//#define P_RNTI (rnti_t)0xfffe
//#endif
//#if !defined(CBA_RNTI)
//#define CBA_RNTI (rnti_t)0xfff4
//#endif
//#if !defined(C_RNTI)
//#define C_RNTI (rnti_t)0x1234
//#endif
//
//#define PMI_2A_11 0
//#define PMI_2A_1m1 1
//#define PMI_2A_1j 2
//#define PMI_2A_1mj 3
//
//// for NB-IoT
#define MAX_NUM_CHANNEL_BITS_NB_IoT 3360 //14 symbols * 12 sub-carriers * 10 SF * 2bits/RE // to check during real tests
#define MAX_DL_SIZE_BITS_NB_IoT 680 // in release 13 // in release 14 = 2048 // ??? **** not sure
////#define MAX_NUM_CHANNEL_BITS_NB_IOT 3*680 /// ??? ****not sure
//
//// to be created LTE_eNB_DLSCH_t --> is duplicated for each number of UE and then indexed in the table
//
//typedef struct { // LTE_DL_eNB_HARQ_t
// /// Status Flag indicating for this DLSCH (idle,active,disabled)
// SCH_status_t status;
// /// Transport block size
// uint32_t TBS;
// /// The payload + CRC size in bits, "B" from 36-212
// uint32_t B; // keep this parameter
// /// Pointer to the payload
// uint8_t *b; // keep this parameter
// /// Pointers to transport block segments
// //uint8_t *c[MAX_NUM_DLSCH_SEGMENTS];
// /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15)
// // uint32_t RTC[MAX_NUM_DLSCH_SEGMENTS];
// /// Frame where current HARQ round was sent
// uint32_t frame;
// /// Subframe where current HARQ round was sent
// uint32_t subframe;
// /// Index of current HARQ round for this DLSCH
// uint8_t round;
// /// MCS format for this DLSCH
// uint8_t mcs;
// /// Redundancy-version of the current sub-frame
// uint8_t rvidx;
// /// MIMO mode for this DLSCH
// MIMO_mode_t mimo_mode;
// /// Current RB allocation
// uint32_t rb_alloc[4];
// /// distributed/localized flag
// vrb_t vrb_type;
// /// Current subband PMI allocation
// uint16_t pmi_alloc;
// /// Current subband RI allocation
// uint32_t ri_alloc;
// /// Current subband CQI1 allocation
// uint32_t cqi_alloc1;
// /// Current subband CQI2 allocation
// uint32_t cqi_alloc2;
// /// Current Number of RBs
// uint16_t nb_rb;
// /// downlink power offset field
// uint8_t dl_power_off;
// /// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
// uint8_t e[MAX_NUM_CHANNEL_BITS_NB_IOT];
// /// data after scrambling
// uint8_t s_e[MAX_NUM_CHANNEL_BITS_NB_IOT];
// /// length of the table e
// uint16_t length_e // new parameter
// /// Tail-biting convolutional coding outputs
// uint8_t d[96+(3*(24+MAX_DL_SIZE_BITS_NB_IOT))]; // new parameter
// /// Sub-block interleaver outputs
// uint8_t w[3*3*(MAX_DL_SIZE_BITS_NB_IOT+24)]; // new parameter
// /// Number of MIMO layers (streams) (for definition see 36-212 V8.6 2009-03, p.17, TM3-4)
// uint8_t Nl;
// /// Number of layers for this PDSCH transmission (TM8-10)
// uint8_t Nlayers;
// /// First layer for this PSCH transmission
// uint8_t first_layer;
//} NB_IoT_DL_eNB_HARQ_t;
typedef enum {
SCH_IDLE_NB_IoT,
ACTIVE_NB_IoT,
CBA_ACTIVE_NB_IoT,
DISABLED_NB_IoT
} SCH_status_NB_IoT_t;
typedef struct {
/// NB-IoT
SCH_status_NB_IoT_t status;
/// The scheduling the NPDCCH and the NPDSCH transmission TS 36.213 Table 16.4.1-1
uint8_t scheduling_delay;
/// The number of the subframe to transmit the NPDSCH Table TS 36.213 Table 16.4.1.3-1 (Nsf) (NB. in this case is not the index Isf)
uint8_t resource_assignment;
/// is the index that determined the repeat number of NPDSCH through table TS 36.213 Table 16.4.1.3-2 / for SIB1-NB Table 16.4.1.3-3
uint8_t repetition_number;
/// Determined the ACK/NACK delay and the subcarrier allocation TS 36.213 Table 16.4.2
uint8_t HARQ_ACK_resource;
/// Determined the repetition number value 0-3 (2 biut carried by the FAPI NPDCCH)
uint8_t dci_subframe_repetitions;
/// modulation always QPSK Qm = 2
uint8_t modulation;
/// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
uint8_t e[MAX_NUM_CHANNEL_BITS_NB_IoT];
/// data after scrambling
uint8_t s_e[MAX_NUM_CHANNEL_BITS_NB_IoT];
//length of the table e
uint16_t length_e; // new parameter
/// Tail-biting convolutional coding outputs
uint8_t d[96+(3*(24+MAX_DL_SIZE_BITS_NB_IoT))]; // new parameter
/// Sub-block interleaver outputs
uint8_t w[3*3*(MAX_DL_SIZE_BITS_NB_IoT+24)]; // new parameter
/// Status Flag indicating for this DLSCH (idle,active,disabled)
//SCH_status_t status;
/// Transport block size
uint32_t TBS;
/// The payload + CRC size in bits, "B" from 36-212
uint32_t B;
/// Pointer to the payload
uint8_t *b;
///pdu of the ndlsch message
uint8_t *pdu;
/// Frame where current HARQ round was sent
uint32_t frame;
/// Subframe where current HARQ round was sent
uint32_t subframe;
/// Index of current HARQ round for this DLSCH
uint8_t round;
/// MCS format for this NDLSCH , TS 36.213 Table 16.4.1.5
uint8_t mcs;
// we don't have code block segmentation / crc attachment / concatenation in NB-IoT R13 36.212 6.4.2
// we don't have beamforming in NB-IoT
//this index will be used mainly for SI message buffer
uint8_t pdu_buffer_index;
} NB_IoT_DL_eNB_HARQ_t;
typedef struct { // LTE_eNB_DLSCH_t
/// TX buffers for UE-spec transmission (antenna ports 5 or 7..14, prior to precoding)
uint32_t *txdataF[8];
/// Allocated RNTI (0 means DLSCH_t is not currently used)
uint16_t rnti;
/// Active flag for baseband transmitter processing
uint8_t active;
/// Indicator of TX activation per subframe. Used during PUCCH detection for ACK/NAK.
uint8_t subframe_tx[10];
/// First CCE of last PDSCH scheduling per subframe. Again used during PUCCH detection for ACK/NAK.
uint8_t nCCE[10];
/// Current HARQ process id
uint8_t current_harq_pid;
/// Process ID's per subframe. Used to associate received ACKs on PUSCH/PUCCH to DLSCH harq process ids
uint8_t harq_ids[10];
/// Window size (in outgoing transport blocks) for fine-grain rate adaptation
uint8_t ra_window_size;
/// First-round error threshold for fine-grain rate adaptation
uint8_t error_threshold;
/// Pointers to 8 HARQ processes for the DLSCH
NB_IoT_DL_eNB_HARQ_t harq_process;
/// circular list of free harq PIDs (the oldest come first)
/// (10 is arbitrary value, must be > to max number of DL HARQ processes in LTE)
int harq_pid_freelist[10];
/// the head position of the free list (if list is free then head=tail)
int head_freelist;
/// the tail position of the free list
int tail_freelist;
/// Number of soft channel bits
uint32_t G;
/// Codebook index for this dlsch (0,1,2,3)
uint8_t codebook_index;
/// Maximum number of HARQ processes (for definition see 36-212 V8.6 2009-03, p.17)
uint8_t Mdlharq;
/// Maximum number of HARQ rounds
uint8_t Mlimit;
/// MIMO transmission mode indicator for this sub-frame (for definition see 36-212 V8.6 2009-03, p.17)
uint8_t Kmimo;
/// Nsoft parameter related to UE Category
uint32_t Nsoft;
/// amplitude of PDSCH (compared to RS) in symbols without pilots
int16_t sqrt_rho_a;
/// amplitude of PDSCH (compared to RS) in symbols containing pilots
int16_t sqrt_rho_b;
} NB_IoT_eNB_DLSCH_t;
typedef struct {
/// HARQ process id
uint8_t harq_id;
/// ACK bits (after decoding) 0:NACK / 1:ACK / 2:DTX
uint8_t ack;
/// send status (for PUCCH)
uint8_t send_harq_status;
/// nCCE (for PUCCH)
uint8_t nCCE;
/// DAI value detected from DCI1/1a/1b/1d/2/2a/2b/2c. 0xff indicates not touched
uint8_t vDAI_DL;
/// DAI value detected from DCI0/4. 0xff indicates not touched
uint8_t vDAI_UL;
} harq_status_NB_IoT_t;
typedef struct {
/// UL RSSI per receive antenna
int32_t UL_rssi[NB_ANTENNAS_RX];
/// PUCCH1a/b power (digital linear)
uint32_t Po_PUCCH;
/// PUCCH1a/b power (dBm)
int32_t Po_PUCCH_dBm;
/// PUCCH1 power (digital linear), conditioned on below threshold
uint32_t Po_PUCCH1_below;
/// PUCCH1 power (digital linear), conditioned on above threshold
uint32_t Po_PUCCH1_above;
/// Indicator that Po_PUCCH has been updated by PHY
int32_t Po_PUCCH_update;
/// DL Wideband CQI index (2 TBs)
uint8_t DL_cqi[2];
/// DL Subband CQI index (from HLC feedback)
uint8_t DL_subband_cqi[2][13];
/// DL PMI Single Stream
uint16_t DL_pmi_single;
/// DL PMI Dual Stream
uint16_t DL_pmi_dual;
/// Current RI
uint8_t rank;
/// CRNTI of UE
uint16_t crnti; ///user id (rnti) of connected UEs
/// Initial timing offset estimate from PRACH for RAR
int32_t UE_timing_offset;
/// Timing advance estimate from PUSCH for MAC timing advance signalling
int32_t timing_advance_update;
/// Current mode of UE (NOT SYCHED, RAR, PUSCH)
UE_MODE_NB_IoT_t mode;
/// Current sector where UE is attached
uint8_t sector;
/// dlsch l2 errors
uint32_t dlsch_l2_errors[8];
/// dlsch trials per harq and round
uint32_t dlsch_trials[8][8];
/// dlsch ACK/NACK per hard_pid and round
uint32_t dlsch_ACK[8][8];
uint32_t dlsch_NAK[8][8];
/// ulsch l2 errors per harq_pid
uint32_t ulsch_errors[8];
/// ulsch l2 consecutive errors per harq_pid
uint32_t ulsch_consecutive_errors; //[8];
/// ulsch trials/errors/fer per harq and round
uint32_t nulsch_decoding_attempts[8][8];
uint32_t ulsch_round_errors[8][8];
uint32_t ulsch_decoding_attempts_last[8][8];
uint32_t ulsch_round_errors_last[8][8];
uint32_t ulsch_round_fer[8][8];
uint32_t sr_received;
uint32_t sr_total;
/// dlsch sliding count and total errors in round 0 are used to compute the dlsch_mcs_offset
uint32_t dlsch_sliding_cnt;
uint32_t dlsch_NAK_round0;
int8_t dlsch_mcs_offset;
/// Target mcs1 after rate-adaptation (used by MAC layer scheduler)
uint8_t dlsch_mcs1;
/// Target mcs2 after rate-adaptation (used by MAC layer scheduler)
uint8_t dlsch_mcs2;
/// Total bits received from MAC on PDSCH
int total_TBS_MAC;
/// Total bits acknowledged on PDSCH
int total_TBS;
/// Total bits acknowledged on PDSCH (last interval)
int total_TBS_last;
/// Bitrate on the PDSCH [bps]
unsigned int dlsch_bitrate;
// unsigned int total_transmitted_bits;
} NB_IoT_eNB_UE_stats;
typedef struct {
/// Indicator of first transmission
uint8_t first_tx;
/// Last Ndi received for this process on DCI (used for C-RNTI only)
uint8_t DCINdi;
/// DLSCH status flag indicating
//SCH_status_t status;
/// Transport block size
uint32_t TBS;
/// The payload + CRC size in bits
uint32_t B;
/// Pointer to the payload
uint8_t *b;
/// Pointers to transport block segments
uint8_t *c[MAX_NUM_DLSCH_SEGMENTS_NB_IoT];
/// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15)
uint32_t RTC[MAX_NUM_DLSCH_SEGMENTS_NB_IoT];
/// Index of current HARQ round for this DLSCH
uint8_t round;
/// MCS format for this DLSCH
uint8_t mcs;
/// Qm (modulation order) for this DLSCH
uint8_t Qm;
/// Redundancy-version of the current sub-frame
uint8_t rvidx;
/// MIMO mode for this DLSCH
// MIMO_mode_t mimo_mode;
/// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
int16_t w[MAX_NUM_DLSCH_SEGMENTS_NB_IoT][3*(6144+64)];
/// for abstraction soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
double w_abs[MAX_NUM_DLSCH_SEGMENTS_NB_IoT][3*(6144+64)];
/// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
int16_t *d[MAX_NUM_DLSCH_SEGMENTS_NB_IoT];
/// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9)
uint32_t C;
/// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Cminus;
/// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Cplus;
/// Number of bits in "small" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Kminus;
/// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Kplus;
/// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t F;
/// Number of MIMO layers (streams) (for definition see 36-212 V8.6 2009-03, p.17)
uint8_t Nl;
/// current delta_pucch
int8_t delta_PUCCH;
/// Number of soft channel bits
uint32_t G;
/// Current Number of RBs
uint16_t nb_rb;
/// Current subband PMI allocation
uint16_t pmi_alloc;
/// Current RB allocation (even slots)
uint32_t rb_alloc_even[4];
/// Current RB allocation (odd slots)
uint32_t rb_alloc_odd[4];
/// distributed/localized flag
//vrb_t vrb_type;
/// downlink power offset field
uint8_t dl_power_off;
/// trials per round statistics
uint32_t trials[8];
/// error statistics per round
uint32_t errors[8];
/// codeword this transport block is mapped to
uint8_t codeword;
} NB_IoT_DL_UE_HARQ_t;
typedef struct {
/// RNTI
uint16_t rnti;
/// Active flag for DLSCH demodulation
uint8_t active;
/// Transmission mode
uint8_t mode1_flag;
/// amplitude of PDSCH (compared to RS) in symbols without pilots
int16_t sqrt_rho_a;
/// amplitude of PDSCH (compared to RS) in symbols containing pilots
int16_t sqrt_rho_b;
/// Current HARQ process id threadRx Odd and threadRx Even
uint8_t current_harq_pid;
/// Current subband antenna selection
uint32_t antenna_alloc;
/// Current subband RI allocation
uint32_t ri_alloc;
/// Current subband CQI1 allocation
uint32_t cqi_alloc1;
/// Current subband CQI2 allocation
uint32_t cqi_alloc2;
/// saved subband PMI allocation from last PUSCH/PUCCH report
uint16_t pmi_alloc;
/// HARQ-ACKs
harq_status_NB_IoT_t harq_ack;
/// Pointers to up to 8 HARQ processes
NB_IoT_DL_UE_HARQ_t *harq_process;
/// Maximum number of HARQ processes(for definition see 36-212 V8.6 2009-03, p.17
uint8_t Mdlharq;
/// MIMO transmission mode indicator for this sub-frame (for definition see 36-212 V8.6 2009-03, p.17)
uint8_t Kmimo;
/// Nsoft parameter related to UE Category
uint32_t Nsoft;
/// Maximum number of Turbo iterations
uint8_t max_turbo_iterations;
/// number of iterations used in last turbo decoding
uint8_t last_iteration_cnt;
/// accumulated tx power adjustment for PUCCH
int8_t g_pucch;
} NB_IoT_UE_DLSCH_t;
//----------------------------------------------------------------------------------------------------------
// NB-IoT
//----------------------------------------------------------------------------------------------------
//enum for distinguish the different type of ndlsch (may in the future will be not needed)
typedef enum
{
SIB1,
SI_Message,
RAR,
UE_Data
}ndlsch_flag_t;
typedef struct {
rnti_t rnti;
//array containing the pdus of DCI
uint8_t *a[2];
//Array containing encoded DCI data
uint8_t *e[2];
//UE specific parameters
uint16_t npdcch_NumRepetitions;
uint16_t repetition_number;
//indicate the corresponding subframe within the repetition (set to 0 when a new NPDCCH pdu is received)
uint16_t repetition_idx;
// uint16_t npdcch_Offset_USS;
// uint16_t npdcch_StartSF_USS;
}NB_IoT_eNB_NPDCCH_t;
typedef struct{
//Number of repetitions (R) for common search space (RAR and PAGING)
uint16_t number_repetition_RA;
uint16_t number_repetition_PAg;
//index of the current subframe among the repetition (set to 0 when we receive the new NPDCCH)
uint16_t repetition_idx_RA;
uint16_t repetition_idx_Pag;
}NB_IoT_eNB_COMMON_NPDCCH_t;
typedef struct {
/// Length of DCI in bits
uint8_t dci_length;
/// Aggregation level only 1,2 in NB-IoT
uint8_t L;
/// Position of first CCE of the dci
int firstCCE;
/// flag to indicate that this is a RA response
boolean_t ra_flag;
/// rnti
rnti_t rnti;
/// Format
DCI_format_NB_IoT_t format;
/// DCI pdu
uint8_t dci_pdu[8];
} DCI_ALLOC_NB_IoT_t;
typedef struct {
//delete the count for the DCI numbers,NUM_DCI_MAX should set to 2
uint32_t num_npdcch_symbols;
///indicates the starting OFDM symbol in the first slot of a subframe k for the NPDCCH transmission
/// see FAPI/NFAPI specs Table 4-45
uint8_t npdcch_start_symbol;
uint8_t Num_dci;
DCI_ALLOC_NB_IoT_t dci_alloc[2] ;
} DCI_PDU_NB_IoT;
typedef struct {
/// TX buffers for UE-spec transmission (antenna ports 5 or 7..14, prior to precoding)
int32_t *txdataF[8];
/// dl channel estimates (estimated from ul channel estimates)
int32_t **calib_dl_ch_estimates;
/// Allocated RNTI (0 means DLSCH_t is not currently used)
uint16_t rnti;
/// Active flag for baseband transmitter processing
uint8_t active;
/// Indicator of TX activation per subframe. Used during PUCCH detection for ACK/NAK.
uint8_t subframe_tx[10];
/// First CCE of last PDSCH scheduling per subframe. Again used during PUCCH detection for ACK/NAK.
uint8_t nCCE[10];
/*in NB-IoT there is only 1 HARQ process for each UE therefore no pid is required*/
/// The only HARQ process for the DLSCH
NB_IoT_DL_eNB_HARQ_t *harq_process;
/// Number of soft channel bits
uint32_t G;
/// Maximum number of HARQ rounds
uint8_t Mlimit;
/// Nsoft parameter related to UE Category
uint32_t Nsoft;
/// amplitude of PDSCH (compared to RS) in symbols without pilots
int16_t sqrt_rho_a;
/// amplitude of PDSCH (compared to RS) in symbols containing pilots
int16_t sqrt_rho_b;
///NB-IoT
/// may use in the npdsch_procedures
uint16_t scrambling_sequence_intialization;
/// number of cell specific TX antenna ports assumed by the UE
uint8_t nrs_antenna_ports;
//This indicate the current subframe within the subframe interval between the NPDSCH transmission (Nsf*Nrep)
uint16_t sf_index;
///indicates the starting OFDM symbol in the first slot of a subframe k for the NPDSCH transmission
/// see FAPI/NFAPI specs Table 4-47
uint8_t npdsch_start_symbol;
/*SIB1-NB related parameters*/
///flag for indicate if the current frame is the start of a new SIB1-NB repetition within the SIB1-NB period (0 = FALSE, 1 = TRUE)
uint8_t sib1_rep_start;
///the number of the frame within the 16 continuous frame in which sib1-NB is transmitted (1-8 = 1st, 2nd ecc..) (0 = not foresees a transmission)
uint8_t relative_sib1_frame;
//Flag used to discern among different NDLSCH structures (SIB1,SI,RA,UE-spec)
//(used inside the ndlsch procedure for distinguish the different type of data to manage also in term of repetitions and transmission over more subframes
ndlsch_flag_t ndlsch_type;
} NB_IoT_eNB_NDLSCH_t;
typedef struct {
/// Length of CQI data under RI=1 assumption(bits)
uint8_t Or1;
/// Rank information
uint8_t o_RI[2];
/// Format of CQI data
UCI_format_NB_IoT_t uci_format;
/// The value of DAI in DCI format 0
uint8_t V_UL_DAI;
/// Pointer to CQI data
uint8_t o[MAX_CQI_BYTES_NB_IoT];
/// CQI CRC status
uint8_t cqi_crc_status;
/// PHICH active flag
uint8_t phich_active;
/// PHICH ACK
uint8_t phich_ACK;
/// Length of rank information (bits)
uint8_t O_RI;
/// First Allocated RB
uint16_t first_rb;
/// Current Number of RBs
uint16_t nb_rb;
/// Determined the subcarrier allocation for the NPUSCH.(15, 3.75 KHz)
uint8_t subcarrier_indication;
/// Determined the number of resource unit for the NPUSCH
uint8_t resource_assignment;
/// Determined the scheduling delay for NPUSCH
uint8_t scheduling_delay;
/// The number of the repetition number for NPUSCH Transport block
uint8_t repetition_number;
/// Determined the repetition number value 0-3
uint8_t dci_subframe_repetitions;
/// Flag indicating that this ULSCH has been allocated by a DCI (otherwise it is a retransmission based on PHICH NAK)
uint8_t dci_alloc;
/// Flag indicating that this ULSCH has been allocated by a RAR (otherwise it is a retransmission based on PHICH NAK or DCI)
uint8_t rar_alloc;
/// Status Flag indicating for this ULSCH (idle,active,disabled)
SCH_status_NB_IoT_t status;
/// Subframe scheduling indicator (i.e. Transmission opportunity indicator)
uint8_t subframe_scheduling_flag;
/// Transport block size
uint32_t TBS;
/// The payload + CRC size in bits
uint32_t B;
/// Number of soft channel bits
uint32_t G;
/// Pointer to ACK
uint8_t o_ACK[4];
/// Length of ACK information (bits)
uint8_t O_ACK;
/// coded ACK bits
int16_t q_ACK[MAX_ACK_PAYLOAD_NB_IoT];
/// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9)
/// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
int16_t e[MAX_NUM_CHANNEL_BITS_NB_IoT] __attribute__((aligned(32)));
/// coded RI bits
int16_t q_RI[MAX_RI_PAYLOAD_NB_IoT];
/// "q" sequences for CQI/PMI (for definition see 36-212 V8.6 2009-03, p.27)
int8_t q[MAX_CQI_PAYLOAD_NB_IoT];
/// number of coded CQI bits after interleaving
uint8_t o_RCC;
/// coded and interleaved CQI bits
int8_t o_w[(MAX_CQI_BITS_NB_IoT+8)*3];
/// coded CQI bits
int8_t o_d[96+((MAX_CQI_BITS_NB_IoT+8)*3)];
///
uint32_t C;
/// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Cminus;
/// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Cplus;
/// Number of bits in "small" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Kminus;
/// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Kplus;
/// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t F;
/// Temporary h sequence to flag PUSCH_x/PUSCH_y symbols which are not scrambled
//uint8_t h[MAX_NUM_CHANNEL_BITS];
/// SRS active flag
uint8_t srs_active;
/// Pointer to the payload
uint8_t *b;
/// Current Number of Symbols
uint8_t Nsymb_pusch;
/// Index of current HARQ round for this ULSCH
uint8_t round;
/// MCS format for this ULSCH
uint8_t mcs;
/// Redundancy-version of the current sub-frame (value 0->RV0,value 1 ->RV2)
uint8_t rvidx;
/// Msc_initial, Initial number of subcarriers for ULSCH (36-212, v8.6 2009-03, p.26-27)
uint16_t Msc_initial;
/// Nsymb_initial, Initial number of symbols for ULSCH (36-212, v8.6 2009-03, p.26-27)
uint8_t Nsymb_initial;
/// n_DMRS for cyclic shift of DMRS (36.213 Table 9.1.2-2)
uint8_t n_DMRS;
/// n_DMRS for cyclic shift of DMRS (36.213 Table 9.1.2-2) - previous scheduling
/// This is needed for PHICH generation which
/// is done after a new scheduling
uint8_t previous_n_DMRS;
/// n_DMRS 2 for cyclic shift of DMRS (36.211 Table 5.5.1.1.-1)
uint8_t n_DMRS2;
/// Flag to indicate that this ULSCH is for calibration information sent from UE (i.e. no MAC SDU to pass up)
// int calibration_flag;
/// delta_TF for power control
int32_t delta_TF;
///////////////////////////////////////////// 4 parameter added by vincent ///////////////////////////////////////////////
// NB_IoT: Nsymb_UL and Nslot_UL are defined in 36.211, Section 10.1.2.3, Table 10.1.2.3-1
// The number of symbol in a resource unit is given by Nsymb_UL*Nslot_UL
uint8_t Nsymb_UL;
// Number of NPUSCH slots
uint8_t Nslot_UL;
// Number of subcarrier for NPUSH, can be 1, 3, 6, 12
uint8_t N_sc_RU;
// Index of UL NB_IoT resource block
uint32_t UL_RB_ID_NB_IoT;
// Subcarrier indication fields, obtained through DCI, Section 16.5.1.1 in 36.213
uint16_t I_sc;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
} NB_IoT_UL_eNB_HARQ_t;
typedef struct {
/// Pointers to the HARQ processes for the NULSCH
NB_IoT_UL_eNB_HARQ_t *harq_process;
/// Maximum number of HARQ rounds
uint8_t Mlimit;
/// Value 0 = npush format 1 (data) value 1 = npusch format 2 (ACK/NAK)
uint8_t npusch_format;
/// Flag to indicate that eNB awaits UE Msg3
uint8_t Msg3_active;
/// Flag to indicate that eNB should decode UE Msg3
uint8_t Msg3_flag;
/// Subframe for Msg3
uint8_t Msg3_subframe;
/// Frame for Msg3
uint32_t Msg3_frame;
/// RNTI attributed to this ULSCH
uint16_t rnti;
/// cyclic shift for DM RS
uint8_t cyclicShift;
/// cooperation flag
uint8_t cooperation_flag;
/// (only in-band mode), indicate the resource block overlap the SRS configuration of LTE
uint8_t N_srs;
///
uint8_t scrambling_re_intialization_batch_index;
/// number of cell specific TX antenna ports assumed by the UE
uint8_t nrs_antenna_ports;
///
uint16_t scrambling_sequence_intialization;
///
uint16_t sf_index;
/// Determined the ACK/NACK delay and the subcarrier allocation TS 36.213 Table 16.4.2
uint8_t HARQ_ACK_resource;
///////////// kept from LTE ///////////////////////////////////////////////////
/// Maximum number of iterations used in eNB turbo decoder
uint8_t max_turbo_iterations;
/// ACK/NAK Bundling flag
uint8_t bundling;
/// beta_offset_cqi times 8
uint16_t beta_offset_cqi_times8;
/// beta_offset_ri times 8
uint16_t beta_offset_ri_times8;
/// beta_offset_harqack times 8
uint16_t beta_offset_harqack_times8;
/// num active cba group
uint8_t num_active_cba_groups;
/// allocated CBA RNTI for this ulsch
uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP];
#ifdef LOCALIZATION
/// epoch timestamp in millisecond
int32_t reference_timestamp_ms;
/// aggregate physical states every n millisecond
int32_t aggregation_period_ms;
/// a set of lists used for localization
struct list loc_rss_list[10], loc_rssi_list[10], loc_subcarrier_rss_list[10], loc_timing_advance_list[10], loc_timing_update_list[10];
struct list tot_loc_rss_list, tot_loc_rssi_list, tot_loc_subcarrier_rss_list, tot_loc_timing_advance_list, tot_loc_timing_update_list;
#endif
} NB_IoT_eNB_NULSCH_t;
#define NPBCH_A 34
typedef struct {
//the 2 LSB of the hsfn (the MSB are indicated by the SIB1-NB)
uint16_t h_sfn_lsb;
uint8_t npbch_d[96+(3*(16+NPBCH_A))];
uint8_t npbch_w[3*3*(16+NPBCH_A)];
uint8_t npbch_e[1600];
///pdu of the npbch message
uint8_t *pdu;
} NB_IoT_eNB_NPBCH_t;
#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.1 (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/proto.h
* \brief Function prototypes for PHY physical/transport channel processing and generation V8.6 2009-03
* \author R. Knopp, F. Kaltenberger
* \date 2011
* \version 0.1
* \company Eurecom
* \email: knopp@eurecom.fr
* \note
* \warning
*/
#ifndef __LTE_TRANSPORT_PROTO_NB_IOT__H__
#define __LTE_TRANSPORT_PROTO_NB_IOT__H__
#include "PHY/defs_L1_NB_IoT.h"
//#include <math.h>
//NPSS
int generate_npss_NB_IoT(int32_t **txdataF,
short amp,
NB_IoT_DL_FRAME_PARMS *frame_parms,
unsigned short symbol_offset, // symbol_offset should equal to 3 for NB-IoT
unsigned short slot_offset,
unsigned short RB_IoT_ID); // new attribute (values are between 0.. Max_RB_number-1), it does not exist for LTE
//NSSS
int generate_sss_NB_IoT(int32_t **txdataF,
int16_t amp,
NB_IoT_DL_FRAME_PARMS *frame_parms,
uint16_t symbol_offset, // symbol_offset = 3 for NB-IoT
uint16_t slot_offset,
unsigned short frame_number, // new attribute (Get value from higher layer), it does not exist for LTE
unsigned short RB_IoT_ID); // new attribute (values are between 0.. Max_RB_number-1), it does not exist for LTE
//*****************Vincent part for Cell ID estimation from NSSS ******************//
int rx_nsss_NB_IoT(PHY_VARS_UE_NB_IoT *ue,int32_t *tot_metric);
int nsss_extract_NB_IoT(PHY_VARS_UE_NB_IoT *ue,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **nsss_ext,
int l);
//NRS
void generate_pilots_NB_IoT(PHY_VARS_eNB_NB_IoT *phy_vars_eNB,
int32_t **txdataF,
int16_t amp,
uint16_t Ntti, // Ntti = 10
unsigned short RB_IoT_ID, // RB reserved for NB-IoT
unsigned short With_NSSS); // With_NSSS = 1; if the frame include a sub-Frame with NSSS signal
//NPBCH
int allocate_npbch_REs_in_RB(NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **txdataF,
uint32_t *jj,
uint32_t symbol_offset,
uint8_t *x0,
uint8_t pilots,
int16_t amp,
unsigned short id_offset,
uint32_t *re_allocated);
int generate_npbch(NB_IoT_eNB_NPBCH_t *eNB_npbch,
int32_t **txdataF,
int amp,
NB_IoT_DL_FRAME_PARMS *frame_parms,
uint8_t *npbch_pdu,
uint8_t frame_mod64,
unsigned short NB_IoT_RB_ID);
void npbch_scrambling(NB_IoT_DL_FRAME_PARMS *frame_parms,
uint8_t *npbch_e,
uint32_t length);
// Functions below implement 36-211 and 36-212
/*Function to pack the DCI*/
// newly added function for NB-IoT , does not exist for LTE
void add_dci_NB_IoT(DCI_PDU_NB_IoT *DCI_pdu,
void *pdu,
rnti_t rnti,
unsigned char dci_size_bytes,
unsigned char aggregation,
unsigned char dci_size_bits,
unsigned char dci_fmt,
uint8_t npdcch_start_symbol);
/*Use the UL DCI Information to configure PHY and also Pack the DCI*/
int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
eNB_rxtx_proc_NB_IoT_t *proc,
DCI_CONTENT *DCI_Content,
uint16_t rnti,
DCI_format_NB_IoT_t dci_format,
uint8_t UE_id,
uint8_t aggregation,
uint8_t npdcch_start_symbol);
/*Use the DL DCI Information to configure PHY and also Pack the DCI*/
int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
int frame,
uint8_t subframe,
DCI_CONTENT *DCI_Content,
uint16_t rnti,
DCI_format_NB_IoT_t dci_format,
NB_IoT_eNB_NDLSCH_t *ndlsch,
NB_IoT_DL_FRAME_PARMS *frame_parms,
uint8_t aggregation,
uint8_t npdcch_start_symbol);
/*Function for DCI encoding, scrambling, modulation*/
uint8_t generate_dci_top_NB_IoT(NB_IoT_eNB_NPDCCH_t *npdcch,
uint8_t Num_dci,
DCI_ALLOC_NB_IoT_t *dci_alloc,
int16_t amp,
NB_IoT_DL_FRAME_PARMS *fp,
int32_t **txdataF,
uint32_t subframe,
uint8_t npdcch_start_symbol);
/*!
\brief Decoding of PUSCH/ACK/RI/ACK from 36-212.
@param phy_vars_eNB Pointer to eNB top-level descriptor
@param proc Pointer to RXTX proc variables
@param UE_id ID of UE transmitting this PUSCH
@param subframe Index of subframe for PUSCH
@param control_only_flag Receive PUSCH with control information only
@param Nbundled Nbundled parameter for ACK/NAK scrambling from 36-212/36-213
@param llr8_flag If 1, indicate that the 8-bit turbo decoder should be used
@returns 0 on success
*/
unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB_NB_IoT *phy_vars_eNB,
eNB_rxtx_proc_NB_IoT_t *proc,
uint8_t UE_id,
uint8_t control_only_flag,
uint8_t Nbundled,
uint8_t llr8_flag);
//NB-IoT version
NB_IoT_eNB_NDLSCH_t *new_eNB_dlsch_NB_IoT(//unsigned char Kmimo,
//unsigned char Mdlharq,
uint32_t Nsoft,
//unsigned char N_RB_DL,
uint8_t abstraction_flag,
NB_IoT_DL_FRAME_PARMS* frame_parms);
NB_IoT_eNB_NULSCH_t *new_eNB_ulsch_NB_IoT(uint8_t abstraction_flag);
uint8_t subframe2harq_pid_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t subframe);
/** \brief Compute Q (modulation order) based on I_MCS for PUSCH. Implements table 8.6.1-1 from 36.213.
@param I_MCS */
//uint8_t get_Qm_ul_NB_IoT(uint8_t I_MCS);
unsigned char get_Qm_ul_NB_IoT(unsigned char I_MCS, uint8_t N_sc_RU);
/** \fn dlsch_encoding(PHY_VARS_eNB *eNB,
uint8_t *input_buffer,
LTE_DL_FRAME_PARMS *frame_parms,
uint8_t num_pdcch_symbols,
LTE_eNB_DLSCH_t *dlsch,
int frame,
uint8_t subframe)
\brief This function performs a subset of the bit-coding functions for LTE as described in 36-212, Release 8.Support is limited to turbo-coded channels (DLSCH/ULSCH). The implemented functions are:
- CRC computation and addition
- Code block segmentation and sub-block CRC addition
- Channel coding (Turbo coding)
- Rate matching (sub-block interleaving, bit collection, selection and transmission
- Code block concatenation
@param eNB Pointer to eNB PHY context
@param input_buffer Pointer to input buffer for sub-frame
@param frame_parms Pointer to frame descriptor structure
@param num_pdcch_symbols Number of PDCCH symbols in this subframe
@param dlsch Pointer to dlsch to be encoded
@param frame Frame number
@param subframe Subframe number
@param rm_stats Time statistics for rate-matching
@param te_stats Time statistics for turbo-encoding
@param i_stats Time statistics for interleaving
@returns status
*/
int32_t dlsch_encoding_NB_IoT(unsigned char *a,
NB_IoT_eNB_DLSCH_t *dlsch,
uint8_t Nsf, // number of subframes required for npdsch pdu transmission calculated from Isf (3GPP spec table)
unsigned int G, // G (number of available RE) is implicitly multiplied by 2 (since only QPSK modulation)
time_stats_t *rm_stats,
time_stats_t *te_stats,
time_stats_t *i_stats);
void rx_ulsch_NB_IoT(PHY_VARS_eNB_NB_IoT *phy_vars_eNB,
eNB_rxtx_proc_NB_IoT_t *proc,
uint8_t eNB_id, // this is the effective sector id
uint8_t UE_id,
NB_IoT_eNB_NULSCH_t **ulsch,
uint8_t cooperation_flag);
void ulsch_extract_rbs_single_NB_IoT(int32_t **rxdataF,
int32_t **rxdataF_ext,
// uint32_t first_rb,
//uint32_t UL_RB_ID_NB_IoT, // index of UL NB_IoT resource block
uint8_t N_sc_RU, // number of subcarriers in UL
uint32_t I_sc, // subcarrier indication field
uint32_t nb_rb,
uint8_t l,
uint8_t Ns,
NB_IoT_DL_FRAME_PARMS *frame_parms);
void extract_CQI_NB_IoT(void *o,UCI_format_NB_IoT_t uci_format,NB_IoT_eNB_UE_stats *stats,uint8_t N_RB_DL, uint16_t * crnti, uint8_t * access_mode);
//*****************Vincent part for nprach ******************//
void RX_NPRACH_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB, int16_t *Rx_buffer);
uint32_t TA_estimation_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
int16_t *Rx_sub_sampled_buffer,
uint16_t sub_sampling_rate,
uint16_t FRAME_LENGTH_COMPLEX_SUB_SAMPLES,
uint32_t estimated_TA_coarse,
char coarse);
uint8_t NPRACH_detection_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB, int16_t *Rx_sub_sampled_buffer, uint16_t sub_sampling_rate, uint32_t FRAME_LENGTH_COMPLEX_SUB_SAMPLES);
int16_t* sub_sampling_NB_IoT(int16_t *input_buffer, uint32_t length_input, uint32_t *length_ouput, uint16_t sub_sampling_rate);
//************************************************************//
//*****************Vincent part for ULSCH demodulation ******************//
uint16_t get_UL_sc_start_NB_IoT(uint16_t I_sc);
void generate_grouphop_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms);
void init_ul_hopping_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms);
void rotate_single_carrier_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
uint8_t UE_id,
uint8_t symbol,
uint8_t Qm);
void fill_rbs_zeros_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
uint8_t UE_id,
uint8_t symbol);
int32_t ulsch_bpsk_llr_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
int16_t *ulsch_llr,
uint8_t symbol,
uint8_t uint8_t,
int16_t **llrp);
int32_t ulsch_qpsk_llr_NB_IoT(
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
int16_t *ulsch_llr,
uint8_t symbol,
uint8_t nb_rb,
int16_t **llrp);
void rotate_bpsk_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
uint8_t UE_id,
uint8_t symbol);
//************************************************************//
//************************************************************//
//*****************Vincent part for DLSCH demodulation ******************//
int rx_npdsch_NB_IoT(PHY_VARS_UE_NB_IoT *ue,
unsigned char eNB_id,
unsigned char eNB_id_i, //if this == ue->n_connected_eNB, we assume MU interference
uint32_t frame,
uint8_t subframe,
unsigned char symbol,
unsigned char first_symbol_flag,
unsigned char i_mod,
unsigned char harq_pid);
unsigned short dlsch_extract_rbs_single_NB_IoT(int **rxdataF,
int **dl_ch_estimates,
int **rxdataF_ext,
int **dl_ch_estimates_ext,
unsigned short pmi,
unsigned char *pmi_ext,
unsigned int *rb_alloc,
unsigned char symbol,
unsigned char subframe,
uint32_t frame,
uint32_t high_speed_flag,
NB_IoT_DL_FRAME_PARMS *frame_parms);
void dlsch_channel_level_NB_IoT(int **dl_ch_estimates_ext,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t *avg,
uint8_t symbol,
unsigned short nb_rb);
void dlsch_channel_compensation_NB_IoT(int **rxdataF_ext,
int **dl_ch_estimates_ext,
int **dl_ch_mag,
int **dl_ch_magb,
int **rxdataF_comp,
int **rho,
NB_IoT_DL_FRAME_PARMS *frame_parms,
unsigned char symbol,
uint8_t first_symbol_flag,
unsigned char mod_order,
unsigned short nb_rb,
unsigned char output_shift,
PHY_MEASUREMENTS_NB_IoT *measurements);
int dlsch_qpsk_llr_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
int16_t *dlsch_llr,
uint8_t symbol,
uint8_t first_symbol_flag,
uint16_t nb_rb,
int16_t **llr32p,
uint8_t beamforming_mode);
//************************************************************//
#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.1 (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 __UCI_NB_IOT__H__
#define __UCI_NB_IOT__H__
//#include "PHY/types_NB_IoT.h"
typedef enum {
ue_selected_NB_IoT,
wideband_cqi_rank1_2A_NB_IoT, //wideband_cqi_rank1_2A,
wideband_cqi_rank2_2A_NB_IoT, //wideband_cqi_rank2_2A,
HLC_subband_cqi_nopmi_NB_IoT, //HLC_subband_cqi_nopmi,
HLC_subband_cqi_rank1_2A_NB_IoT, //HLC_subband_cqi_rank1_2A,
HLC_subband_cqi_rank2_2A_NB_IoT, //HLC_subband_cqi_rank2_2A,
HLC_subband_cqi_modes123_NB_IoT, //HLC_subband_cqi_modes123
HLC_subband_cqi_mcs_CBA_NB_IoT, // MCS and RNTI, for contention-based acces
unknown_cqi_NB_IoT//
} UCI_format_NB_IoT_t;
// **********************************************1.5 MHz***************************************************************************
typedef struct __attribute__((packed))
{
uint32_t padding:16;
uint32_t pmi:12;
uint32_t cqi1:4;
}
wideband_cqi_rank1_2A_1_5MHz_NB_IoT ;
#define sizeof_wideband_cqi_rank1_2A_1_5MHz_NB_IoT 16
typedef struct __attribute__((packed))
{
uint16_t padding:2;
uint16_t pmi:6;
uint16_t cqi2:4;
uint16_t cqi1:4;
}
wideband_cqi_rank2_2A_1_5MHz_NB_IoT ;
#define sizeof_wideband_cqi_rank2_2A_1_5MHz_NB_IoT 14
typedef struct __attribute__((packed))
{
uint32_t padding:16;
uint32_t diffcqi1:12;
uint32_t cqi1:4;
}
HLC_subband_cqi_nopmi_1_5MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_nopmi_1_5MHz_NB_IoT 16
typedef struct __attribute__((packed))
{
uint32_t padding:14;
uint32_t pmi:2;
uint32_t diffcqi1:12;
uint32_t cqi1:4;
}
HLC_subband_cqi_rank1_2A_1_5MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_rank1_2A_1_5MHz_NB_IoT 18
typedef struct __attribute__((packed))
{
uint64_t padding:31;
uint64_t pmi:1;
uint64_t diffcqi2:12;
uint64_t cqi2:4;
uint64_t diffcqi1:12;
uint64_t cqi1:4;
}
HLC_subband_cqi_rank2_2A_1_5MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_rank2_2A_1_5MHz_NB_IoT 33
typedef struct __attribute__((packed))
{
uint32_t padding:16;
uint32_t diffcqi1:12;
uint32_t cqi1:4;
}
HLC_subband_cqi_modes123_1_5MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_modes123_1_5MHz_NB_IoT 16
typedef struct __attribute__((packed))
{
uint32_t padding:11;
uint32_t crnti:16;
uint32_t mcs:5;
}
HLC_subband_cqi_mcs_CBA_1_5MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz_NB_IoT 21
// **********************************************5 MHz***************************************************************************
typedef struct __attribute__((packed))
{
uint32_t padding:14;
uint32_t pmi:14;
uint32_t cqi1:4;
}
wideband_cqi_rank1_2A_5MHz_NB_IoT ;
#define sizeof_wideband_cqi_rank1_2A_5MHz_NB_IoT 18
typedef struct __attribute__((packed))
{
uint16_t padding:1;
uint16_t pmi:7;
uint16_t cqi2:4;
uint16_t cqi1:4;
}
wideband_cqi_rank2_2A_5MHz_NB_IoT ;
#define sizeof_wideband_cqi_rank2_2A_5MHz_NB_IoT 15
typedef struct __attribute__((packed))
{
uint32_t padding:14;
uint32_t diffcqi1:14;
uint32_t cqi1:4;
}
HLC_subband_cqi_nopmi_5MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_nopmi_5MHz_NB_IoT 18
typedef struct __attribute__((packed))
{
uint32_t padding:12;
uint32_t pmi:2;
uint32_t diffcqi1:14;
uint32_t cqi1:4;
}
HLC_subband_cqi_rank1_2A_5MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_rank1_2A_5MHz_NB_IoT 20
typedef struct __attribute__((packed))
{
uint64_t padding:27;
uint64_t pmi:1;
uint64_t diffcqi2:14;
uint64_t cqi2:4;
uint64_t diffcqi1:14;
uint64_t cqi1:4;
}
HLC_subband_cqi_rank2_2A_5MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_rank2_2A_5MHz_NB_IoT 37
typedef struct __attribute__((packed))
{
uint32_t padding:14;
uint32_t diffcqi1:14;
uint32_t cqi1:4;
}
HLC_subband_cqi_modes123_5MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_modes123_5MHz_NB_IoT 18
typedef struct __attribute__((packed))
{
uint32_t padding:11;
uint32_t crnti:16;
uint32_t mcs:5;
}
HLC_subband_cqi_mcs_CBA_5MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_mcs_CBA_5MHz_NB_IoT 21
// **********************************************10 MHz***************************************************************************
typedef struct __attribute__((packed))
{
uint32_t padding:10;
uint32_t pmi:18;
uint32_t cqi1:4;
}
wideband_cqi_rank1_2A_10MHz_NB_IoT ;
#define sizeof_wideband_cqi_rank1_2A_10MHz_NB_IoT 22
typedef struct __attribute__((packed))
{
uint32_t padding:15;
uint32_t pmi:9;
uint32_t cqi2:4;
uint32_t cqi1:4;
}
wideband_cqi_rank2_2A_10MHz_NB_IoT ;
#define sizeof_wideband_cqi_rank2_2A_10MHz_NB_IoT 17
typedef struct __attribute__((packed))
{
uint32_t padding:10;
uint32_t diffcqi1:18;
uint32_t cqi1:4;
}
HLC_subband_cqi_nopmi_10MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_nopmi_10MHz_NB_IoT 22
typedef struct __attribute__((packed))
{
uint32_t padding:8;
uint32_t pmi:2;
uint32_t diffcqi1:18;
uint32_t cqi1:4;
}
HLC_subband_cqi_rank1_2A_10MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_rank1_2A_10MHz_NB_IoT 24
typedef struct __attribute__((packed))
{
uint64_t padding:19;
uint64_t pmi:1;
uint64_t diffcqi2:18;
uint64_t cqi2:4;
uint64_t diffcqi1:18;
uint64_t cqi1:4;
}
HLC_subband_cqi_rank2_2A_10MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_rank2_2A_10MHz_NB_IoT 45
typedef struct __attribute__((packed))
{
uint32_t padding:10;
uint32_t diffcqi1:18;
uint32_t cqi1:4;
}
HLC_subband_cqi_modes123_10MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_modes123_10MHz_NB_IoT 22
typedef struct __attribute__((packed))
{
uint32_t padding:11;
uint32_t crnti:16;
uint32_t mcs:5;
}
HLC_subband_cqi_mcs_CBA_10MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_mcs_CBA_10MHz_NB_IoT 21
// **********************************************20 MHz***************************************************************************
typedef struct __attribute__((packed))
{
uint32_t padding:2;
uint32_t pmi:26;
uint32_t cqi1:4;
}
wideband_cqi_rank1_2A_20MHz_NB_IoT ;
#define sizeof_wideband_cqi_rank1_2A_20MHz_NB_IoT 20
typedef struct __attribute__((packed))
{
uint32_t padding:11;
uint32_t pmi:13;
uint32_t cqi2:4;
uint32_t cqi1:4;
}
wideband_cqi_rank2_2A_20MHz_NB_IoT ;
#define sizeof_wideband_cqi_rank2_2A_20MHz_NB_IoT 21
typedef struct __attribute__((packed))
{
uint32_t padding:2;
uint32_t diffcqi1:26;
uint32_t cqi1:4;
}
HLC_subband_cqi_nopmi_20MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_nopmi_20MHz_NB_IoT 30
typedef struct __attribute__((packed))
{
// uint32_t padding:12;
uint32_t pmi:2;
uint32_t diffcqi1:26;
uint32_t cqi1:4;
}
HLC_subband_cqi_rank1_2A_20MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_rank1_2A_20MHz_NB_IoT 32
typedef struct __attribute__((packed))
{
uint64_t padding:3;
uint64_t pmi:1;
uint64_t diffcqi2:26;
uint64_t cqi2:4;
uint64_t diffcqi1:26;
uint64_t cqi1:4;
}
HLC_subband_cqi_rank2_2A_20MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_rank2_2A_20MHz_NB_IoT 61
typedef struct __attribute__((packed))
{
uint32_t padding:2;
uint32_t diffcqi1:26;
uint32_t cqi1:4;
}
HLC_subband_cqi_modes123_20MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_modes123_20MHz_NB_IoT 30
typedef struct __attribute__((packed))
{
uint32_t padding:11;
uint32_t crnti:16;
uint32_t mcs:5;
}
HLC_subband_cqi_mcs_CBA_20MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_mcs_CBA_20MHz_NB_IoT 21
#define MAX_CQI_PAYLOAD_NB_IoT (sizeof(HLC_subband_cqi_rank2_2A_20MHz_NB_IoT)*8*20)
#define MAX_CQI_BITS_NB_IoT (sizeof(HLC_subband_cqi_rank2_2A_20MHz_NB_IoT)*8)
#define MAX_CQI_BYTES_NB_IoT (sizeof(HLC_subband_cqi_rank2_2A_20MHz_NB_IoT))
#define MAX_ACK_PAYLOAD_NB_IoT 18
#define MAX_RI_PAYLOAD_NB_IoT 6
#endif
\ No newline at end of file
/*
* 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 __LTE_ESTIMATION_DEFS_NB_IOT__H__
#define __LTE_ESTIMATION_DEFS_NB_IOT__H__
#include "PHY/defs_L1_NB_IoT.h"
/*
int lte_est_timing_advance(NB_IoT_DL_FRAME_PARMS *frame_parms,
NB_IoT_eNB_SRS *lte_eNb_srs,
unsigned int *eNb_id,
unsigned char clear,
unsigned char number_of_cards,
short coef);
*/
////////// Vincent: NB-IoT DL synchronization //////////////////////////////////////////////////
int lte_sync_time_init_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms );
void lte_sync_time_free_NB_IoT(void);
int lte_sync_time_NB_IoT(int **rxdata, ///rx data in time domain
NB_IoT_DL_FRAME_PARMS *frame_parms,
int *eNB_id);
void lte_sync_timefreq_NB_IoT(PHY_VARS_UE_NB_IoT *ue,int band,unsigned int DL_freq);
////////////////////////////////////////////////////////////////////////////////////////////////
int NB_IoT_est_timing_advance_pusch(PHY_VARS_eNB_NB_IoT* phy_vars_eNB,module_id_t UE_id);
////////// Vincent: NB-IoT specific adapted function for channel estimation ////////////////////
/*
int ul_channel_estimation_NB_IoT(PHY_VARS_eNB *eNB,
eNB_rxtx_proc_t *proc,
uint8_t eNB_id,
uint8_t UE_id,
unsigned char l,
unsigned char Ns,
uint8_t N_sc_RU,
uint8_t pilot_pos1,
uint8_t pilot_pos2,
uint8_t cooperation_flag); */
////////////////////////////////////////////////////////////////////////////////////////////////
int16_t lte_ul_freq_offset_estimation_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t *ul_ch_estimates,
uint16_t nb_rb);
void freq_equalization_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,
int **rxdataF_comp,
int **ul_ch_mag,
int **ul_ch_mag_b,
unsigned char symbol,
unsigned short Msc_RS,
unsigned char Qm);
/** @} */
#endif
......@@ -234,7 +234,6 @@ int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eN
/*Use the DL DCI Information to configure PHY and also Pack the DCI*/
int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
int frame,
uint8_t subframe,
DCI_CONTENT *DCI_Content,
......@@ -242,7 +241,7 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
DCI_format_NB_IoT_t dci_format,
NB_IoT_eNB_NPDCCH_t *ndlcch,
LTE_DL_FRAME_PARMS *frame_parms,
NB_IoT_DL_FRAME_PARMS *frame_parms,
uint8_t aggregation,
uint8_t npdcch_start_symbol,
uint8_t ncce_index);
......@@ -446,7 +445,7 @@ uint32_t turbo_decoding_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
uint8_t rx_subframe);
void decode_NPUSCH_msg_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
LTE_DL_FRAME_PARMS *fp,
NB_IoT_DL_FRAME_PARMS *fp,
eNB_rxtx_proc_NB_IoT_t *proc,
uint8_t npusch_format,
uint16_t N_SF_per_word,
......@@ -475,10 +474,10 @@ void ulsch_extract_rbs_single_NB_IoT(int32_t **rxdataF,
uint16_t N_sc_RU, // number of subcarriers in UL
uint8_t l,
uint8_t Ns,
LTE_DL_FRAME_PARMS *frame_parms);
NB_IoT_DL_FRAME_PARMS *frame_parms);
void ulsch_channel_level_NB_IoT(int32_t **drs_ch_estimates_ext,
LTE_DL_FRAME_PARMS *frame_parms,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t *avg,
uint16_t nb_rb);
......@@ -487,13 +486,13 @@ void ulsch_channel_compensation_NB_IoT(int32_t **rxdataF_ext,
int32_t **ul_ch_mag,
int32_t **ul_ch_magb,
int32_t **rxdataF_comp,
LTE_DL_FRAME_PARMS *frame_parms,
NB_IoT_DL_FRAME_PARMS *frame_parms,
uint8_t symbol,
uint8_t Qm,
uint16_t nb_rb,
uint8_t output_shift);
void lte_idft_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *z, uint16_t Msc_PUSCH);
void lte_idft_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,uint32_t *z, uint16_t Msc_PUSCH);
void extract_CQI_NB_IoT(void *o,UCI_format_NB_IoT_t uci_format,NB_IoT_eNB_UE_stats *stats,uint8_t N_RB_DL, uint16_t * crnti, uint8_t * access_mode);
......@@ -542,12 +541,12 @@ uint8_t get_UL_slots_per_RU_NB_IoT(uint8_t subcarrier_spacing, uint8_t subcarrie
//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
void generate_grouphop_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms);
void generate_grouphop_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms);
void init_ul_hopping_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms);
void rotate_single_carrier_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
LTE_DL_FRAME_PARMS *frame_parms,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
uint8_t eNB_id,
uint8_t symbol, //symbol within subframe
......@@ -558,14 +557,14 @@ void rotate_single_carrier_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
uint8_t option);
void fill_rbs_zeros_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
LTE_DL_FRAME_PARMS *frame_parms,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
uint16_t ul_sc_start,
uint8_t UE_id,
uint8_t symbol);
int32_t ulsch_bpsk_llr_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
LTE_DL_FRAME_PARMS *frame_parms,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
int16_t *ulsch_llr,
uint8_t symbol,
......@@ -574,7 +573,7 @@ int32_t ulsch_bpsk_llr_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
int16_t **llrp);
int32_t ulsch_qpsk_llr_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
LTE_DL_FRAME_PARMS *frame_parms,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
int16_t *ulsch_llr,
uint8_t symbol,
......@@ -584,7 +583,7 @@ int32_t ulsch_qpsk_llr_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
int16_t *llrp);
void rotate_bpsk_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
LTE_DL_FRAME_PARMS *frame_parms,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
uint16_t ul_sc_start,
......@@ -660,7 +659,7 @@ int ul_chest_tmp_NB_IoT(int32_t **rxdataF_ext,
uint16_t ul_sc_start,
uint8_t Qm,
uint16_t N_SF_per_word,
LTE_DL_FRAME_PARMS *frame_parms);
NB_IoT_DL_FRAME_PARMS *frame_parms);
/// Channel estimation for NPUSCH format 2
int ul_chest_tmp_f2_NB_IoT(int32_t **rxdataF_ext,
......@@ -672,7 +671,7 @@ int ul_chest_tmp_f2_NB_IoT(int32_t **rxdataF_ext,
uint8_t subframerx,
uint8_t Qm,
uint16_t ul_sc_start,
LTE_DL_FRAME_PARMS *frame_parms);
NB_IoT_DL_FRAME_PARMS *frame_parms);
void rotate_channel_sc_tmp_NB_IoT(int16_t *estimated_channel,
uint8_t l,
......@@ -687,7 +686,7 @@ int ul_chequal_tmp_NB_IoT(int32_t **rxdataF_ext,
int32_t **ul_ch_estimates,
uint8_t l, //symbol within slot
uint8_t Ns,
LTE_DL_FRAME_PARMS *frame_parms);
NB_IoT_DL_FRAME_PARMS *frame_parms);
///
////////////////////////////NB-IoT testing ///////////////////////////////
......
/*
* 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/ulsch_demodulation.c
* \brief Top-level routines for demodulating the PUSCH physical channel from 36.211 V8.6 2009-03
* \authors V. Savaux, M. Kanj
* \date 2018
* \version 0.1
* \company b<>com
* \email: vincent.savaux@b-com.com , matthieu.kanj@b-com.com
* \note
* \warning
*/
#include "PHY/defs_L1_NB_IoT.h"
#include "PHY/extern_NB_IoT.h"
#include "defs_NB_IoT.h"
#include "extern_NB_IoT.h"
#include "PHY/CODING/lte_interleaver2.h"
#include "PHY/CODING/coding_extern.h"
//#define DEBUG_ULSCH
//#include "PHY/sse_intrin.h"
#include "PHY/NBIoT_ESTIMATION/defs_NB_IoT.h"
#include "openair1/SCHED_NBIOT/defs_NB_IoT.h"
//#include "openair1/PHY/LTE_TRANSPORT/sc_rotation_NB_IoT.h"
#include "T.h"
//extern char* namepointer_chMag ;
//eren
//extern int **ulchmag_eren;
//eren
static short jitter[8] __attribute__ ((aligned(16))) = {1,0,0,1,0,1,1,0};
static short jitterc[8] __attribute__ ((aligned(16))) = {0,1,1,0,1,0,0,1};
#ifndef OFDMA_ULSCH
void lte_idft_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,uint32_t *z, uint16_t Msc_PUSCH)
{
#if defined(__x86_64__) || defined(__i386__)
__m128i idft_in128[3][1200],idft_out128[3][1200];
__m128i norm128;
#elif defined(__arm__)
int16x8_t idft_in128[3][1200],idft_out128[3][1200];
int16x8_t norm128;
#endif
int16_t *idft_in0=(int16_t*)idft_in128[0],*idft_out0=(int16_t*)idft_out128[0];
int16_t *idft_in1=(int16_t*)idft_in128[1],*idft_out1=(int16_t*)idft_out128[1];
int16_t *idft_in2=(int16_t*)idft_in128[2],*idft_out2=(int16_t*)idft_out128[2];
uint32_t *z0,*z1,*z2,*z3,*z4,*z5,*z6,*z7,*z8,*z9,*z10=NULL,*z11=NULL;
int i,ip;
// printf("Doing lte_idft for Msc_PUSCH %d\n",Msc_PUSCH);
// Normal prefix
z0 = z;
z1 = z0+(frame_parms->N_RB_DL*12);
z2 = z1+(frame_parms->N_RB_DL*12);
//pilot
z3 = z2+(2*frame_parms->N_RB_DL*12);
z4 = z3+(frame_parms->N_RB_DL*12);
z5 = z4+(frame_parms->N_RB_DL*12);
z6 = z5+(frame_parms->N_RB_DL*12);
z7 = z6+(frame_parms->N_RB_DL*12);
z8 = z7+(frame_parms->N_RB_DL*12);
//pilot
z9 = z8+(2*frame_parms->N_RB_DL*12);
z10 = z9+(frame_parms->N_RB_DL*12);
// srs
z11 = z10+(frame_parms->N_RB_DL*12);
// conjugate input
for (i=0; i<(Msc_PUSCH>>2); i++) {
#if defined(__x86_64__)||defined(__i386__)
*&(((__m128i*)z0)[i])=_mm_sign_epi16(*&(((__m128i*)z0)[i]),*(__m128i*)&conjugate2[0]);
*&(((__m128i*)z1)[i])=_mm_sign_epi16(*&(((__m128i*)z1)[i]),*(__m128i*)&conjugate2[0]);
*&(((__m128i*)z2)[i])=_mm_sign_epi16(*&(((__m128i*)z2)[i]),*(__m128i*)&conjugate2[0]);
*&(((__m128i*)z3)[i])=_mm_sign_epi16(*&(((__m128i*)z3)[i]),*(__m128i*)&conjugate2[0]);
*&(((__m128i*)z4)[i])=_mm_sign_epi16(*&(((__m128i*)z4)[i]),*(__m128i*)&conjugate2[0]);
*&(((__m128i*)z5)[i])=_mm_sign_epi16(*&(((__m128i*)z5)[i]),*(__m128i*)&conjugate2[0]);
*&(((__m128i*)z6)[i])=_mm_sign_epi16(*&(((__m128i*)z6)[i]),*(__m128i*)&conjugate2[0]);
*&(((__m128i*)z7)[i])=_mm_sign_epi16(*&(((__m128i*)z7)[i]),*(__m128i*)&conjugate2[0]);
*&(((__m128i*)z8)[i])=_mm_sign_epi16(*&(((__m128i*)z8)[i]),*(__m128i*)&conjugate2[0]);
*&(((__m128i*)z9)[i])=_mm_sign_epi16(*&(((__m128i*)z9)[i]),*(__m128i*)&conjugate2[0]);
// if (frame_parms->Ncp==NORMAL_NB_IoT) {
*&(((__m128i*)z10)[i])=_mm_sign_epi16(*&(((__m128i*)z10)[i]),*(__m128i*)&conjugate2[0]);
*&(((__m128i*)z11)[i])=_mm_sign_epi16(*&(((__m128i*)z11)[i]),*(__m128i*)&conjugate2[0]);
// }
#elif defined(__arm__)
*&(((int16x8_t*)z0)[i])=vmulq_s16(*&(((int16x8_t*)z0)[i]),*(int16x8_t*)&conjugate2[0]);
*&(((int16x8_t*)z1)[i])=vmulq_s16(*&(((int16x8_t*)z1)[i]),*(int16x8_t*)&conjugate2[0]);
*&(((int16x8_t*)z2)[i])=vmulq_s16(*&(((int16x8_t*)z2)[i]),*(int16x8_t*)&conjugate2[0]);
*&(((int16x8_t*)z3)[i])=vmulq_s16(*&(((int16x8_t*)z3)[i]),*(int16x8_t*)&conjugate2[0]);
*&(((int16x8_t*)z4)[i])=vmulq_s16(*&(((int16x8_t*)z4)[i]),*(int16x8_t*)&conjugate2[0]);
*&(((int16x8_t*)z5)[i])=vmulq_s16(*&(((int16x8_t*)z5)[i]),*(int16x8_t*)&conjugate2[0]);
*&(((int16x8_t*)z6)[i])=vmulq_s16(*&(((int16x8_t*)z6)[i]),*(int16x8_t*)&conjugate2[0]);
*&(((int16x8_t*)z7)[i])=vmulq_s16(*&(((int16x8_t*)z7)[i]),*(int16x8_t*)&conjugate2[0]);
*&(((int16x8_t*)z8)[i])=vmulq_s16(*&(((int16x8_t*)z8)[i]),*(int16x8_t*)&conjugate2[0]);
*&(((int16x8_t*)z9)[i])=vmulq_s16(*&(((int16x8_t*)z9)[i]),*(int16x8_t*)&conjugate2[0]);
// if (frame_parms->Ncp==NORMAL_NB_IoT) {
*&(((int16x8_t*)z10)[i])=vmulq_s16(*&(((int16x8_t*)z10)[i]),*(int16x8_t*)&conjugate2[0]);
*&(((int16x8_t*)z11)[i])=vmulq_s16(*&(((int16x8_t*)z11)[i]),*(int16x8_t*)&conjugate2[0]);
// }
#endif
}
for (i=0,ip=0; i<Msc_PUSCH; i++,ip+=4) {
((uint32_t*)idft_in0)[ip+0] = z0[i];
((uint32_t*)idft_in0)[ip+1] = z1[i];
((uint32_t*)idft_in0)[ip+2] = z2[i];
((uint32_t*)idft_in0)[ip+3] = z3[i];
((uint32_t*)idft_in1)[ip+0] = z4[i];
((uint32_t*)idft_in1)[ip+1] = z5[i];
((uint32_t*)idft_in1)[ip+2] = z6[i];
((uint32_t*)idft_in1)[ip+3] = z7[i];
((uint32_t*)idft_in2)[ip+0] = z8[i];
((uint32_t*)idft_in2)[ip+1] = z9[i];
// if (frame_parms->Ncp==0) {
((uint32_t*)idft_in2)[ip+2] = z10[i];
((uint32_t*)idft_in2)[ip+3] = z11[i];
// }
}
switch (Msc_PUSCH) {
case 12:
dft12((int16_t *)idft_in0,(int16_t *)idft_out0);
dft12((int16_t *)idft_in1,(int16_t *)idft_out1);
dft12((int16_t *)idft_in2,(int16_t *)idft_out2);
#if defined(__x86_64__)||defined(__i386__)
norm128 = _mm_set1_epi16(9459);
#elif defined(__arm__)
norm128 = vdupq_n_s16(9459);
#endif
for (i=0; i<12; i++) {
#if defined(__x86_64__)||defined(__i386__)
((__m128i*)idft_out0)[i] = _mm_slli_epi16(_mm_mulhi_epi16(((__m128i*)idft_out0)[i],norm128),1);
((__m128i*)idft_out1)[i] = _mm_slli_epi16(_mm_mulhi_epi16(((__m128i*)idft_out1)[i],norm128),1);
((__m128i*)idft_out2)[i] = _mm_slli_epi16(_mm_mulhi_epi16(((__m128i*)idft_out2)[i],norm128),1);
#elif defined(__arm__)
((int16x8_t*)idft_out0)[i] = vqdmulhq_s16(((int16x8_t*)idft_out0)[i],norm128);
((int16x8_t*)idft_out1)[i] = vqdmulhq_s16(((int16x8_t*)idft_out1)[i],norm128);
((int16x8_t*)idft_out2)[i] = vqdmulhq_s16(((int16x8_t*)idft_out2)[i],norm128);
#endif
}
break;
// case 24:
// dft24(idft_in0,idft_out0,1);
// dft24(idft_in1,idft_out1,1);
// dft24(idft_in2,idft_out2,1);
// break;
// case 36:
// dft36(idft_in0,idft_out0,1);
// dft36(idft_in1,idft_out1,1);
// dft36(idft_in2,idft_out2,1);
// break;
// case 48:
// dft48(idft_in0,idft_out0,1);
// dft48(idft_in1,idft_out1,1);
// dft48(idft_in2,idft_out2,1);
// break;
// case 60:
// dft60(idft_in0,idft_out0,1);
// dft60(idft_in1,idft_out1,1);
// dft60(idft_in2,idft_out2,1);
// break;
// case 72:
// dft72(idft_in0,idft_out0,1);
// dft72(idft_in1,idft_out1,1);
// dft72(idft_in2,idft_out2,1);
// break;
// case 96:
// dft96(idft_in0,idft_out0,1);
// dft96(idft_in1,idft_out1,1);
// dft96(idft_in2,idft_out2,1);
// break;
// case 108:
// dft108(idft_in0,idft_out0,1);
// dft108(idft_in1,idft_out1,1);
// dft108(idft_in2,idft_out2,1);
// break;
// case 120:
// dft120(idft_in0,idft_out0,1);
// dft120(idft_in1,idft_out1,1);
// dft120(idft_in2,idft_out2,1);
// break;
// case 144:
// dft144(idft_in0,idft_out0,1);
// dft144(idft_in1,idft_out1,1);
// dft144(idft_in2,idft_out2,1);
// break;
// case 180:
// dft180(idft_in0,idft_out0,1);
// dft180(idft_in1,idft_out1,1);
// dft180(idft_in2,idft_out2,1);
// break;
// case 192:
// dft192(idft_in0,idft_out0,1);
// dft192(idft_in1,idft_out1,1);
// dft192(idft_in2,idft_out2,1);
// break;
// case 216:
// dft216(idft_in0,idft_out0,1);
// dft216(idft_in1,idft_out1,1);
// dft216(idft_in2,idft_out2,1);
// break;
// case 240:
// dft240(idft_in0,idft_out0,1);
// dft240(idft_in1,idft_out1,1);
// dft240(idft_in2,idft_out2,1);
// break;
// case 288:
// dft288(idft_in0,idft_out0,1);
// dft288(idft_in1,idft_out1,1);
// dft288(idft_in2,idft_out2,1);
// break;
// case 300:
// dft300(idft_in0,idft_out0,1);
// dft300(idft_in1,idft_out1,1);
// dft300(idft_in2,idft_out2,1);
// break;
// case 324:
// dft324((int16_t*)idft_in0,(int16_t*)idft_out0,1);
// dft324((int16_t*)idft_in1,(int16_t*)idft_out1,1);
// dft324((int16_t*)idft_in2,(int16_t*)idft_out2,1);
// break;
// case 360:
// dft360((int16_t*)idft_in0,(int16_t*)idft_out0,1);
// dft360((int16_t*)idft_in1,(int16_t*)idft_out1,1);
// dft360((int16_t*)idft_in2,(int16_t*)idft_out2,1);
// break;
// case 384:
// dft384((int16_t*)idft_in0,(int16_t*)idft_out0,1);
// dft384((int16_t*)idft_in1,(int16_t*)idft_out1,1);
// dft384((int16_t*)idft_in2,(int16_t*)idft_out2,1);
// break;
// case 432:
// dft432((int16_t*)idft_in0,(int16_t*)idft_out0,1);
// dft432((int16_t*)idft_in1,(int16_t*)idft_out1,1);
// dft432((int16_t*)idft_in2,(int16_t*)idft_out2,1);
// break;
// case 480:
// dft480((int16_t*)idft_in0,(int16_t*)idft_out0,1);
// dft480((int16_t*)idft_in1,(int16_t*)idft_out1,1);
// dft480((int16_t*)idft_in2,(int16_t*)idft_out2,1);
// break;
// case 540:
// dft540((int16_t*)idft_in0,(int16_t*)idft_out0,1);
// dft540((int16_t*)idft_in1,(int16_t*)idft_out1,1);
// dft540((int16_t*)idft_in2,(int16_t*)idft_out2,1);
// break;
// case 576:
// dft576((int16_t*)idft_in0,(int16_t*)idft_out0,1);
// dft576((int16_t*)idft_in1,(int16_t*)idft_out1,1);
// dft576((int16_t*)idft_in2,(int16_t*)idft_out2,1);
// break;
// case 600:
// dft600((int16_t*)idft_in0,(int16_t*)idft_out0,1);
// dft600((int16_t*)idft_in1,(int16_t*)idft_out1,1);
// dft600((int16_t*)idft_in2,(int16_t*)idft_out2,1);
// break;
// case 648:
// dft648((int16_t*)idft_in0,(int16_t*)idft_out0,1);
// dft648((int16_t*)idft_in1,(int16_t*)idft_out1,1);
// dft648((int16_t*)idft_in2,(int16_t*)idft_out2,1);
// break;
// case 720:
// dft720((int16_t*)idft_in0,(int16_t*)idft_out0,1);
// dft720((int16_t*)idft_in1,(int16_t*)idft_out1,1);
// dft720((int16_t*)idft_in2,(int16_t*)idft_out2,1);
// break;
// case 864:
// dft864((int16_t*)idft_in0,(int16_t*)idft_out0,1);
// dft864((int16_t*)idft_in1,(int16_t*)idft_out1,1);
// dft864((int16_t*)idft_in2,(int16_t*)idft_out2,1);
// break;
// case 900:
// dft900((int16_t*)idft_in0,(int16_t*)idft_out0,1);
// dft900((int16_t*)idft_in1,(int16_t*)idft_out1,1);
// dft900((int16_t*)idft_in2,(int16_t*)idft_out2,1);
// break;
// case 960:
// dft960((int16_t*)idft_in0,(int16_t*)idft_out0,1);
// dft960((int16_t*)idft_in1,(int16_t*)idft_out1,1);
// dft960((int16_t*)idft_in2,(int16_t*)idft_out2,1);
// break;
// case 972:
// dft972((int16_t*)idft_in0,(int16_t*)idft_out0,1);
// dft972((int16_t*)idft_in1,(int16_t*)idft_out1,1);
// dft972((int16_t*)idft_in2,(int16_t*)idft_out2,1);
// break;
// case 1080:
// dft1080((int16_t*)idft_in0,(int16_t*)idft_out0,1);
// dft1080((int16_t*)idft_in1,(int16_t*)idft_out1,1);
// dft1080((int16_t*)idft_in2,(int16_t*)idft_out2,1);
// break;
// case 1152:
// dft1152((int16_t*)idft_in0,(int16_t*)idft_out0,1);
// dft1152((int16_t*)idft_in1,(int16_t*)idft_out1,1);
// dft1152((int16_t*)idft_in2,(int16_t*)idft_out2,1);
// break;
// case 1200:
// dft1200(idft_in0,idft_out0,1);
// dft1200(idft_in1,idft_out1,1);
// dft1200(idft_in2,idft_out2,1);
// break;
default:
// should not be reached
LOG_E( PHY, "Unsupported Msc_PUSCH value of %"PRIu16"\n", Msc_PUSCH );
return;
}
for (i=0,ip=0; i<Msc_PUSCH; i++,ip+=4) {
z0[i] = ((uint32_t*)idft_out0)[ip];
/*
printf("out0 (%d,%d),(%d,%d),(%d,%d),(%d,%d)\n",
((int16_t*)&idft_out0[ip])[0],((int16_t*)&idft_out0[ip])[1],
((int16_t*)&idft_out0[ip+1])[0],((int16_t*)&idft_out0[ip+1])[1],
((int16_t*)&idft_out0[ip+2])[0],((int16_t*)&idft_out0[ip+2])[1],
((int16_t*)&idft_out0[ip+3])[0],((int16_t*)&idft_out0[ip+3])[1]);
*/
z1[i] = ((uint32_t*)idft_out0)[ip+1];
z2[i] = ((uint32_t*)idft_out0)[ip+2];
z3[i] = ((uint32_t*)idft_out0)[ip+3];
z4[i] = ((uint32_t*)idft_out1)[ip+0];
z5[i] = ((uint32_t*)idft_out1)[ip+1];
z6[i] = ((uint32_t*)idft_out1)[ip+2];
z7[i] = ((uint32_t*)idft_out1)[ip+3];
z8[i] = ((uint32_t*)idft_out2)[ip];
z9[i] = ((uint32_t*)idft_out2)[ip+1];
// if (frame_parms->Ncp==0) {
z10[i] = ((uint32_t*)idft_out2)[ip+2];
z11[i] = ((uint32_t*)idft_out2)[ip+3];
// }
}
// conjugate output
for (i=0; i<(Msc_PUSCH>>2); i++) {
#if defined(__x86_64__) || defined(__i386__)
((__m128i*)z0)[i]=_mm_sign_epi16(((__m128i*)z0)[i],*(__m128i*)&conjugate2[0]);
((__m128i*)z1)[i]=_mm_sign_epi16(((__m128i*)z1)[i],*(__m128i*)&conjugate2[0]);
((__m128i*)z2)[i]=_mm_sign_epi16(((__m128i*)z2)[i],*(__m128i*)&conjugate2[0]);
((__m128i*)z3)[i]=_mm_sign_epi16(((__m128i*)z3)[i],*(__m128i*)&conjugate2[0]);
((__m128i*)z4)[i]=_mm_sign_epi16(((__m128i*)z4)[i],*(__m128i*)&conjugate2[0]);
((__m128i*)z5)[i]=_mm_sign_epi16(((__m128i*)z5)[i],*(__m128i*)&conjugate2[0]);
((__m128i*)z6)[i]=_mm_sign_epi16(((__m128i*)z6)[i],*(__m128i*)&conjugate2[0]);
((__m128i*)z7)[i]=_mm_sign_epi16(((__m128i*)z7)[i],*(__m128i*)&conjugate2[0]);
((__m128i*)z8)[i]=_mm_sign_epi16(((__m128i*)z8)[i],*(__m128i*)&conjugate2[0]);
((__m128i*)z9)[i]=_mm_sign_epi16(((__m128i*)z9)[i],*(__m128i*)&conjugate2[0]);
// if (frame_parms->Ncp==NORMAL_NB_IoT) {
((__m128i*)z10)[i]=_mm_sign_epi16(((__m128i*)z10)[i],*(__m128i*)&conjugate2[0]);
((__m128i*)z11)[i]=_mm_sign_epi16(((__m128i*)z11)[i],*(__m128i*)&conjugate2[0]);
// }
#elif defined(__arm__)
*&(((int16x8_t*)z0)[i])=vmulq_s16(*&(((int16x8_t*)z0)[i]),*(int16x8_t*)&conjugate2[0]);
*&(((int16x8_t*)z1)[i])=vmulq_s16(*&(((int16x8_t*)z1)[i]),*(int16x8_t*)&conjugate2[0]);
*&(((int16x8_t*)z2)[i])=vmulq_s16(*&(((int16x8_t*)z2)[i]),*(int16x8_t*)&conjugate2[0]);
*&(((int16x8_t*)z3)[i])=vmulq_s16(*&(((int16x8_t*)z3)[i]),*(int16x8_t*)&conjugate2[0]);
*&(((int16x8_t*)z4)[i])=vmulq_s16(*&(((int16x8_t*)z4)[i]),*(int16x8_t*)&conjugate2[0]);
*&(((int16x8_t*)z5)[i])=vmulq_s16(*&(((int16x8_t*)z5)[i]),*(int16x8_t*)&conjugate2[0]);
*&(((int16x8_t*)z6)[i])=vmulq_s16(*&(((int16x8_t*)z6)[i]),*(int16x8_t*)&conjugate2[0]);
*&(((int16x8_t*)z7)[i])=vmulq_s16(*&(((int16x8_t*)z7)[i]),*(int16x8_t*)&conjugate2[0]);
*&(((int16x8_t*)z8)[i])=vmulq_s16(*&(((int16x8_t*)z8)[i]),*(int16x8_t*)&conjugate2[0]);
*&(((int16x8_t*)z9)[i])=vmulq_s16(*&(((int16x8_t*)z9)[i]),*(int16x8_t*)&conjugate2[0]);
// if (frame_parms->Ncp==NORMAL_NB_IoT) {
*&(((int16x8_t*)z10)[i])=vmulq_s16(*&(((int16x8_t*)z10)[i]),*(int16x8_t*)&conjugate2[0]);
*&(((int16x8_t*)z11)[i])=vmulq_s16(*&(((int16x8_t*)z11)[i]),*(int16x8_t*)&conjugate2[0]);
// }
#endif
}
#if defined(__x86_64__) || defined(__i386__)
_mm_empty();
_m_empty();
#endif
}
#endif
int32_t ulsch_bpsk_llr_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
int16_t *ulsch_llr,
uint8_t symbol,
uint16_t ul_sc_start,
uint8_t UE_id,
int16_t **llrp)
{
int16_t *rxF;
// uint32_t I_sc = 11;//eNB->ulsch_NB_IoT[UE_id]->harq_process->I_sc; // NB_IoT: subcarrier indication field: must be defined in higher layer
// uint16_t ul_sc_start; // subcarrier start index into UL RB
// int i;
//ul_sc_start = get_UL_sc_start_NB_IoT(I_sc); // NB-IoT: get the used subcarrier in RB
rxF = (int16_t *)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12) + ul_sc_start];
// printf("qpsk llr for symbol %d (pos %d), llr offset %d\n",symbol,(symbol*frame_parms->N_RB_DL*12),llr128U-(__m128i*)ulsch_llr);
//printf("%d,%d,%d,%d,%d,%d,%d,%d\n",((int16_t *)rxF)[0],((int16_t *)rxF)[1],((int16_t *)rxF)[2],((int16_t *)rxF)[3],((int16_t *)rxF)[4],((int16_t *)rxF)[5],((int16_t *)rxF)[6],((int16_t *)rxF)[7]);
*(*llrp) = *rxF;
//rxF++;
(*llrp)++;
return(0);
}
// int32_t ulsch_qpsk_llr_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
// int32_t **rxdataF_comp,
// int16_t *ulsch_llr,
// uint8_t symbol,
// uint16_t nb_rb,
// int16_t **llrp)
// {
// #if defined(__x86_64__) || defined(__i386__)
// __m128i *rxF=(__m128i*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)];
// __m128i **llrp128 = (__m128i **)llrp;
// #elif defined(__arm__)
// int16x8_t *rxF= (int16x8_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)];
// int16x8_t **llrp128 = (int16x8_t **)llrp;
// #endif
// int i;
// // printf("qpsk llr for symbol %d (pos %d), llr offset %d\n",symbol,(symbol*frame_parms->N_RB_DL*12),llr128U-(__m128i*)ulsch_llr);
// for (i=0; i<(nb_rb*3); i++) {
// //printf("%d,%d,%d,%d,%d,%d,%d,%d\n",((int16_t *)rxF)[0],((int16_t *)rxF)[1],((int16_t *)rxF)[2],((int16_t *)rxF)[3],((int16_t *)rxF)[4],((int16_t *)rxF)[5],((int16_t *)rxF)[6],((int16_t *)rxF)[7]);
// *(*llrp128) = *rxF;
// rxF++;
// (*llrp128)++;
// }
// #if defined(__x86_64__) || defined(__i386__)
// _mm_empty();
// _m_empty();
// #endif
// return(0);
// }
int32_t ulsch_qpsk_llr_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
int16_t *ulsch_llr,
uint8_t symbol,
uint8_t UE_id,
uint16_t ul_sc_start,
uint8_t Nsc_RU,
int16_t *llrp)
{
int32_t *rxF;
int32_t *llrp32; // = (int32_t *)llrp;
//uint32_t I_sc = 11;//eNB->ulsch_NB_IoT[UE_id]->harq_process->I_sc; // NB_IoT: subcarrier indication field: must be defined in higher layer
//uint16_t ul_sc_start; // subcarrier start index into UL RB
//uint8_t Nsc_RU = 1;//eNB->ulsch_NB_IoT[UE_id]->harq_process->N_sc_RU; // Vincent: number of sc 1,3,6,12
int i;
llrp32 = (int32_t *)&llrp[0];
//ul_sc_start = get_UL_sc_start_NB_IoT(I_sc); // NB-IoT: get the used subcarrier in RB
rxF = (int32_t *)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12) + ul_sc_start];
// printf("qpsk llr for symbol %d (pos %d), llr offset %d\n",symbol,(symbol*frame_parms->N_RB_DL*12),llr128U-(__m128i*)ulsch_llr);
for (i=0; i<Nsc_RU; i++) {
//printf("%d,%d,%d,%d,%d,%d,%d,%d\n",((int16_t *)rxF)[0],((int16_t *)rxF)[1],((int16_t *)rxF)[2],((int16_t *)rxF)[3],((int16_t *)rxF)[4],((int16_t *)rxF)[5],((int16_t *)rxF)[6],((int16_t *)rxF)[7]);
/**(*llrp32) = *rxF;
rxF++;
(*llrp32)++;*/
llrp32[i] = rxF[i];
/*printf("\nin llr_%d === %d",ul_sc_start,(int32_t)llrp[i]);
printf("\n in llr_%d === %d",ul_sc_start,llrp32[i]);*/
}
return(0);
}
void ulsch_detection_mrc_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
int32_t **ul_ch_mag,
int32_t **ul_ch_magb,
uint8_t symbol,
uint16_t nb_rb)
{
#if defined(__x86_64__) || defined(__i386__)
__m128i *rxdataF_comp128_0,*ul_ch_mag128_0,*ul_ch_mag128_0b;
__m128i *rxdataF_comp128_1,*ul_ch_mag128_1,*ul_ch_mag128_1b;
#elif defined(__arm__)
int16x8_t *rxdataF_comp128_0,*ul_ch_mag128_0,*ul_ch_mag128_0b;
int16x8_t *rxdataF_comp128_1,*ul_ch_mag128_1,*ul_ch_mag128_1b;
#endif
int32_t i;
if (frame_parms->nb_antennas_rx>1) {
#if defined(__x86_64__) || defined(__i386__)
rxdataF_comp128_0 = (__m128i *)&rxdataF_comp[0][symbol*frame_parms->N_RB_DL*12];
rxdataF_comp128_1 = (__m128i *)&rxdataF_comp[1][symbol*frame_parms->N_RB_DL*12];
ul_ch_mag128_0 = (__m128i *)&ul_ch_mag[0][symbol*frame_parms->N_RB_DL*12];
ul_ch_mag128_1 = (__m128i *)&ul_ch_mag[1][symbol*frame_parms->N_RB_DL*12];
ul_ch_mag128_0b = (__m128i *)&ul_ch_magb[0][symbol*frame_parms->N_RB_DL*12];
ul_ch_mag128_1b = (__m128i *)&ul_ch_magb[1][symbol*frame_parms->N_RB_DL*12];
// MRC on each re of rb, both on MF output and magnitude (for 16QAM/64QAM llr computation)
for (i=0; i<nb_rb*3; i++) {
rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1));
ul_ch_mag128_0[i] = _mm_adds_epi16(_mm_srai_epi16(ul_ch_mag128_0[i],1),_mm_srai_epi16(ul_ch_mag128_1[i],1));
ul_ch_mag128_0b[i] = _mm_adds_epi16(_mm_srai_epi16(ul_ch_mag128_0b[i],1),_mm_srai_epi16(ul_ch_mag128_1b[i],1));
rxdataF_comp128_0[i] = _mm_add_epi16(rxdataF_comp128_0[i],(*(__m128i*)&jitterc[0]));
}
#elif defined(__arm__)
rxdataF_comp128_0 = (int16x8_t *)&rxdataF_comp[0][symbol*frame_parms->N_RB_DL*12];
rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[1][symbol*frame_parms->N_RB_DL*12];
ul_ch_mag128_0 = (int16x8_t *)&ul_ch_mag[0][symbol*frame_parms->N_RB_DL*12];
ul_ch_mag128_1 = (int16x8_t *)&ul_ch_mag[1][symbol*frame_parms->N_RB_DL*12];
ul_ch_mag128_0b = (int16x8_t *)&ul_ch_magb[0][symbol*frame_parms->N_RB_DL*12];
ul_ch_mag128_1b = (int16x8_t *)&ul_ch_magb[1][symbol*frame_parms->N_RB_DL*12];
// MRC on each re of rb, both on MF output and magnitude (for 16QAM/64QAM llr computation)
for (i=0; i<nb_rb*3; i++) {
rxdataF_comp128_0[i] = vhaddq_s16(rxdataF_comp128_0[i],rxdataF_comp128_1[i]);
ul_ch_mag128_0[i] = vhaddq_s16(ul_ch_mag128_0[i],ul_ch_mag128_1[i]);
ul_ch_mag128_0b[i] = vhaddq_s16(ul_ch_mag128_0b[i],ul_ch_mag128_1b[i]);
rxdataF_comp128_0[i] = vqaddq_s16(rxdataF_comp128_0[i],(*(int16x8_t*)&jitterc[0]));
}
#endif
}
#if defined(__x86_64__) || defined(__i386__)
_mm_empty();
_m_empty();
#endif
}
void ulsch_extract_rbs_single_NB_IoT(int32_t **rxdataF,
int32_t **rxdataF_ext,
uint16_t UL_RB_ID_NB_IoT, // index of UL NB_IoT resource block !!! may be defined twice : in frame_parms and in NB_IoT_UL_eNB_HARQ_t
uint16_t N_sc_RU, // number of subcarriers in UL
uint8_t l,
uint8_t Ns,
NB_IoT_DL_FRAME_PARMS *frame_parms)
{
uint16_t nb_rb1;
// uint16_t nb_rb2;
uint8_t aarx,n;
// int32_t *rxF,*rxF_ext;
//uint8_t symbol = l+Ns*frame_parms->symbols_per_tti/2;
uint8_t symbol = l+(7*(Ns&1)); ///symbol within sub-frame
// uint16_t ul_sc_start; // subcarrier start index into UL RB
//unsigned short UL_RB_ID_NB_IoT;
// ul_sc_start = get_UL_sc_start_NB_IoT(I_sc);
//UL_RB_ID_NB_IoT = frame_parms->NB_IoT_RB_ID;
////////////////////////////////////////////////////// if NB_IoT_start is used , no need for nb_rb1 and nb_rb2
for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
nb_rb1 = cmin(cmax((int)(frame_parms->N_RB_UL) - (int)(2*UL_RB_ID_NB_IoT),(int)0),(int)(2)); // 2 times no. RBs before the DC
// 2 times no. RBs after the DC
// rxF_ext = &rxdataF_ext[aarx][(symbol*frame_parms->N_RB_UL*12)];
/* for (n=0;n<12;n++){
rxdataF_ext[aarx][symbol*frame_parms->N_RB_UL*12 + n] = rxdataF[aarx][NB_IoT_start_UL + (symbol)*frame_parms->ofdm_symbol_size + n];
// since NB_IoT_start -1 is to apply for UPLINK, in this case the computation of start ul and dl should be done during the initializaiton
}*/
if (nb_rb1) { // RB NB-IoT is in the first half
for (n=0;n<12;n++){ // extract whole RB of 12 subcarriers
// Note that FFT splits the RBs
// !!! Note that frame_parms->N_RB_UL is the number of RB in LTE
// rxdataF_ext[aarx][symbol*frame_parms->N_RB_UL*12 + n] = rxdataF[aarx][UL_RB_ID_NB_IoT*12 + ul_sc_start + frame_parms->first_carrier_offset + symbol*frame_parms->ofdm_symbol_size + n];
rxdataF_ext[aarx][symbol*frame_parms->N_RB_UL*12 + n] = rxdataF[aarx][UL_RB_ID_NB_IoT*12 + frame_parms->first_carrier_offset + (symbol)*frame_parms->ofdm_symbol_size + n];
//rxdataF_ext[aarx][symbol*12 + n] = rxdataF[aarx][UL_RB_ID_NB_IoT*12 + frame_parms->first_carrier_offset + symbol*frame_parms->ofdm_symbol_size + n];
//// RB 22
}
// rxF = &rxdataF[aarx][(first_rb*12 + frame_parms->first_carrier_offset + symbol*frame_parms->ofdm_symbol_size)];
// memcpy(rxF_ext, rxF, nb_rb1*6*sizeof(int));
// rxF_ext += nb_rb1*6;
// if (nb_rb2) {
// //#ifdef OFDMA_ULSCH
// // rxF = &rxdataF[aarx][(1 + symbol*frame_parms->ofdm_symbol_size)*2];
// //#else
// rxF = &rxdataF[aarx][(symbol*frame_parms->ofdm_symbol_size)];
// //#endif
// memcpy(rxF_ext, rxF, nb_rb2*6*sizeof(int));
// rxF_ext += nb_rb2*6;
// }
} else { // RB NB-IoT is in the second half
// RB 2
for (n=0;n<12;n++){ // extract whole RB of 12 subcarriers
// Note that FFT splits the RBs
// rxdataF_ext[aarx][symbol*frame_parms->N_RB_UL*12 + n] = rxdataF[aarx][6*(2*UL_RB_ID_NB_IoT - frame_parms->N_RB_UL) + ul_sc_start + symbol*frame_parms->ofdm_symbol_size + n];
rxdataF_ext[aarx][symbol*frame_parms->N_RB_UL*12 + n] = rxdataF[aarx][6*(2*UL_RB_ID_NB_IoT - frame_parms->N_RB_UL) + (symbol)*frame_parms->ofdm_symbol_size + n];
//printf(" rx_22_%d = %d ",n,rxdataF[aarx][6*(2*UL_RB_ID_NB_IoT - frame_parms->N_RB_UL) + (subframe*14+symbol)*frame_parms->ofdm_symbol_size + n]);
//printf(" rx_20_%d = %d ",n,rxdataF[aarx][6*(2*(UL_RB_ID_NB_IoT-7) - frame_parms->N_RB_UL) + (subframe*14+symbol)*frame_parms->ofdm_symbol_size + n]);
//rxdataF_ext[aarx][symbol*12 + n] = rxdataF[aarx][6*(2*UL_RB_ID_NB_IoT - frame_parms->N_RB_UL) + symbol*frame_parms->ofdm_symbol_size + n];
}
//#ifdef OFDMA_ULSCH
// rxF = &rxdataF[aarx][(1 + 6*(2*first_rb - frame_parms->N_RB_UL) + symbol*frame_parms->ofdm_symbol_size)*2];
//#else
// rxF = &rxdataF[aarx][(6*(2*first_rb - frame_parms->N_RB_UL) + symbol*frame_parms->ofdm_symbol_size)];
// //#endif
// memcpy(rxF_ext, rxF, nb_rb2*6*sizeof(int));
// rxF_ext += nb_rb2*6;
}
}
}
void ulsch_channel_compensation_NB_IoT(int32_t **rxdataF_ext,
int32_t **ul_ch_estimates_ext,
int32_t **ul_ch_mag,
int32_t **ul_ch_magb,
int32_t **rxdataF_comp,
NB_IoT_DL_FRAME_PARMS *frame_parms,
uint8_t symbol,
uint8_t Qm,
uint16_t nb_rb,
uint8_t output_shift)
{
// uint16_t rb;
#if defined(__x86_64__) || defined(__i386__)
__m128i *ul_ch128,*ul_ch_mag128,*ul_ch_mag128b,*rxdataF128,*rxdataF_comp128;
uint8_t aarx;//,symbol_mod;
__m128i mmtmpU0,mmtmpU1,mmtmpU2,mmtmpU3;
#ifdef OFDMA_ULSCH
__m128i QAM_amp128U,QAM_amp128bU;
#endif
#elif defined(__arm__)
int16x4_t *ul_ch128,*rxdataF128;
int16x8_t *ul_ch_mag128,*ul_ch_mag128b,*rxdataF_comp128;
uint8_t aarx;//,symbol_mod;
int32x4_t mmtmpU0,mmtmpU1,mmtmpU0b,mmtmpU1b;
#ifdef OFDMA_ULSCH
int16x8_t mmtmpU2,mmtmpU3;
int16x8_t QAM_amp128U,QAM_amp128bU;
#endif
int16_t conj[4]__attribute__((aligned(16))) = {1,-1,1,-1};
int32x4_t output_shift128 = vmovq_n_s32(-(int32_t)output_shift);
#endif
for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
#if defined(__x86_64__) || defined(__i386__)
ul_ch128 = (__m128i *)&ul_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12];
ul_ch_mag128 = (__m128i *)&ul_ch_mag[aarx][symbol*frame_parms->N_RB_DL*12];
ul_ch_mag128b = (__m128i *)&ul_ch_magb[aarx][symbol*frame_parms->N_RB_DL*12];
rxdataF128 = (__m128i *)&rxdataF_ext[aarx][symbol*frame_parms->N_RB_DL*12];
rxdataF_comp128 = (__m128i *)&rxdataF_comp[aarx][symbol*frame_parms->N_RB_DL*12];
#elif defined(__arm__)
ul_ch128 = (int16x4_t *)&ul_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12];
ul_ch_mag128 = (int16x8_t *)&ul_ch_mag[aarx][symbol*frame_parms->N_RB_DL*12];
ul_ch_mag128b = (int16x8_t *)&ul_ch_magb[aarx][symbol*frame_parms->N_RB_DL*12];
rxdataF128 = (int16x4_t *)&rxdataF_ext[aarx][symbol*frame_parms->N_RB_DL*12];
rxdataF_comp128 = (int16x8_t *)&rxdataF_comp[aarx][symbol*frame_parms->N_RB_DL*12];
#endif
#if defined(__x86_64__) || defined(__i386__)
mmtmpU0 = _mm_madd_epi16(ul_ch128[0],ul_ch128[0]);
mmtmpU0 = _mm_srai_epi32(mmtmpU0,output_shift);
mmtmpU1 = _mm_madd_epi16(ul_ch128[1],ul_ch128[1]);
mmtmpU1 = _mm_srai_epi32(mmtmpU1,output_shift);
mmtmpU0 = _mm_packs_epi32(mmtmpU0,mmtmpU1);
ul_ch_mag128[0] = _mm_unpacklo_epi16(mmtmpU0,mmtmpU0);
ul_ch_mag128[1] = _mm_unpackhi_epi16(mmtmpU0,mmtmpU0);
mmtmpU0 = _mm_madd_epi16(ul_ch128[2],ul_ch128[2]);
mmtmpU0 = _mm_srai_epi32(mmtmpU0,output_shift);
mmtmpU1 = _mm_packs_epi32(mmtmpU0,mmtmpU0);
ul_ch_mag128[2] = _mm_unpacklo_epi16(mmtmpU1,mmtmpU1);
// printf("comp: symbol %d rb %d => %d,%d,%d (output_shift %d)\n",symbol,rb,*((int16_t*)&ul_ch_mag128[0]),*((int16_t*)&ul_ch_mag128[1]),*((int16_t*)&ul_ch_mag128[2]),output_shift);
#elif defined(__arm__)
mmtmpU0 = vmull_s16(ul_ch128[0], ul_ch128[0]);
mmtmpU0 = vqshlq_s32(vqaddq_s32(mmtmpU0,vrev64q_s32(mmtmpU0)),-output_shift128);
mmtmpU1 = vmull_s16(ul_ch128[1], ul_ch128[1]);
mmtmpU1 = vqshlq_s32(vqaddq_s32(mmtmpU1,vrev64q_s32(mmtmpU1)),-output_shift128);
ul_ch_mag128[0] = vcombine_s16(vmovn_s32(mmtmpU0),vmovn_s32(mmtmpU1));
mmtmpU0 = vmull_s16(ul_ch128[2], ul_ch128[2]);
mmtmpU0 = vqshlq_s32(vqaddq_s32(mmtmpU0,vrev64q_s32(mmtmpU0)),-output_shift128);
mmtmpU1 = vmull_s16(ul_ch128[3], ul_ch128[3]);
mmtmpU1 = vqshlq_s32(vqaddq_s32(mmtmpU1,vrev64q_s32(mmtmpU1)),-output_shift128);
ul_ch_mag128[1] = vcombine_s16(vmovn_s32(mmtmpU0),vmovn_s32(mmtmpU1));
mmtmpU0 = vmull_s16(ul_ch128[4], ul_ch128[4]);
mmtmpU0 = vqshlq_s32(vqaddq_s32(mmtmpU0,vrev64q_s32(mmtmpU0)),-output_shift128);
mmtmpU1 = vmull_s16(ul_ch128[5], ul_ch128[5]);
mmtmpU1 = vqshlq_s32(vqaddq_s32(mmtmpU1,vrev64q_s32(mmtmpU1)),-output_shift128);
ul_ch_mag128[2] = vcombine_s16(vmovn_s32(mmtmpU0),vmovn_s32(mmtmpU1));
#endif
// #endif
#if defined(__x86_64__) || defined(__i386__)
// multiply by conjugated channel
mmtmpU0 = _mm_madd_epi16(ul_ch128[0],rxdataF128[0]);
// print_ints("re",&mmtmpU0);
// mmtmpU0 contains real part of 4 consecutive outputs (32-bit)
mmtmpU1 = _mm_shufflelo_epi16(ul_ch128[0],_MM_SHUFFLE(2,3,0,1));
mmtmpU1 = _mm_shufflehi_epi16(mmtmpU1,_MM_SHUFFLE(2,3,0,1));
mmtmpU1 = _mm_sign_epi16(mmtmpU1,*(__m128i*)&conjugate[0]);
mmtmpU1 = _mm_madd_epi16(mmtmpU1,rxdataF128[0]);
// print_ints("im",&mmtmpU1);
// mmtmpU1 contains imag part of 4 consecutive outputs (32-bit)
mmtmpU0 = _mm_srai_epi32(mmtmpU0,output_shift);
// print_ints("re(shift)",&mmtmpU0);
mmtmpU1 = _mm_srai_epi32(mmtmpU1,output_shift);
// print_ints("im(shift)",&mmtmpU1);
mmtmpU2 = _mm_unpacklo_epi32(mmtmpU0,mmtmpU1);
mmtmpU3 = _mm_unpackhi_epi32(mmtmpU0,mmtmpU1);
// print_ints("c0",&mmtmpU2);
// print_ints("c1",&mmtmpU3);
rxdataF_comp128[0] = _mm_packs_epi32(mmtmpU2,mmtmpU3);
/*
print_shorts("rx:",&rxdataF128[0]);
print_shorts("ch:",&ul_ch128[0]);
print_shorts("pack:",&rxdataF_comp128[0]);
*/
// multiply by conjugated channel
mmtmpU0 = _mm_madd_epi16(ul_ch128[1],rxdataF128[1]);
// mmtmpU0 contains real part of 4 consecutive outputs (32-bit)
mmtmpU1 = _mm_shufflelo_epi16(ul_ch128[1],_MM_SHUFFLE(2,3,0,1));
mmtmpU1 = _mm_shufflehi_epi16(mmtmpU1,_MM_SHUFFLE(2,3,0,1));
mmtmpU1 = _mm_sign_epi16(mmtmpU1,*(__m128i*)conjugate);
mmtmpU1 = _mm_madd_epi16(mmtmpU1,rxdataF128[1]);
// mmtmpU1 contains imag part of 4 consecutive outputs (32-bit)
mmtmpU0 = _mm_srai_epi32(mmtmpU0,output_shift);
mmtmpU1 = _mm_srai_epi32(mmtmpU1,output_shift);
mmtmpU2 = _mm_unpacklo_epi32(mmtmpU0,mmtmpU1);
mmtmpU3 = _mm_unpackhi_epi32(mmtmpU0,mmtmpU1);
rxdataF_comp128[1] = _mm_packs_epi32(mmtmpU2,mmtmpU3);
// print_shorts("rx:",rxdataF128[1]);
// print_shorts("ch:",ul_ch128[1]);
// print_shorts("pack:",rxdataF_comp128[1]);
// multiply by conjugated channel
mmtmpU0 = _mm_madd_epi16(ul_ch128[2],rxdataF128[2]);
// mmtmpU0 contains real part of 4 consecutive outputs (32-bit)
mmtmpU1 = _mm_shufflelo_epi16(ul_ch128[2],_MM_SHUFFLE(2,3,0,1));
mmtmpU1 = _mm_shufflehi_epi16(mmtmpU1,_MM_SHUFFLE(2,3,0,1));
mmtmpU1 = _mm_sign_epi16(mmtmpU1,*(__m128i*)conjugate);
mmtmpU1 = _mm_madd_epi16(mmtmpU1,rxdataF128[2]);
// mmtmpU1 contains imag part of 4 consecutive outputs (32-bit)
mmtmpU0 = _mm_srai_epi32(mmtmpU0,output_shift);
mmtmpU1 = _mm_srai_epi32(mmtmpU1,output_shift);
mmtmpU2 = _mm_unpacklo_epi32(mmtmpU0,mmtmpU1);
mmtmpU3 = _mm_unpackhi_epi32(mmtmpU0,mmtmpU1);
rxdataF_comp128[2] = _mm_packs_epi32(mmtmpU2,mmtmpU3);
// print_shorts("rx:",rxdataF128[2]);
// print_shorts("ch:",ul_ch128[2]);
// print_shorts("pack:",rxdataF_comp128[2]);
// Add a jitter to compensate for the saturation in "packs" resulting in a bias on the DC after IDFT
rxdataF_comp128[0] = _mm_add_epi16(rxdataF_comp128[0],(*(__m128i*)&jitter[0]));
rxdataF_comp128[1] = _mm_add_epi16(rxdataF_comp128[1],(*(__m128i*)&jitter[0]));
rxdataF_comp128[2] = _mm_add_epi16(rxdataF_comp128[2],(*(__m128i*)&jitter[0]));
ul_ch128+=3;
ul_ch_mag128+=3;
ul_ch_mag128b+=3;
rxdataF128+=3;
rxdataF_comp128+=3;
#elif defined(__arm__)
mmtmpU0 = vmull_s16(ul_ch128[0], rxdataF128[0]);
//mmtmpU0 = [Re(ch[0])Re(rx[0]) Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1]) Im(ch[1])Im(ch[1])]
mmtmpU1 = vmull_s16(ul_ch128[1], rxdataF128[1]);
//mmtmpU1 = [Re(ch[2])Re(rx[2]) Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3]) Im(ch[3])Im(ch[3])]
mmtmpU0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpU0),vget_high_s32(mmtmpU0)),
vpadd_s32(vget_low_s32(mmtmpU1),vget_high_s32(mmtmpU1)));
//mmtmpU0 = [Re(ch[0])Re(rx[0])+Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1])+Im(ch[1])Im(ch[1]) Re(ch[2])Re(rx[2])+Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3])+Im(ch[3])Im(ch[3])]
mmtmpU0b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[0],*(int16x4_t*)conj)), rxdataF128[0]);
//mmtmpU0 = [-Im(ch[0])Re(rx[0]) Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1]) Re(ch[1])Im(rx[1])]
mmtmpU1b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[1],*(int16x4_t*)conj)), rxdataF128[1]);
//mmtmpU0 = [-Im(ch[2])Re(rx[2]) Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3]) Re(ch[3])Im(rx[3])]
mmtmpU1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpU0b),vget_high_s32(mmtmpU0b)),
vpadd_s32(vget_low_s32(mmtmpU1b),vget_high_s32(mmtmpU1b)));
//mmtmpU1 = [-Im(ch[0])Re(rx[0])+Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1])+Re(ch[1])Im(rx[1]) -Im(ch[2])Re(rx[2])+Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3])+Re(ch[3])Im(rx[3])]
mmtmpU0 = vqshlq_s32(mmtmpU0,-output_shift128);
mmtmpU1 = vqshlq_s32(mmtmpU1,-output_shift128);
rxdataF_comp128[0] = vcombine_s16(vmovn_s32(mmtmpU0),vmovn_s32(mmtmpU1));
mmtmpU0 = vmull_s16(ul_ch128[2], rxdataF128[2]);
mmtmpU1 = vmull_s16(ul_ch128[3], rxdataF128[3]);
mmtmpU0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpU0),vget_high_s32(mmtmpU0)),
vpadd_s32(vget_low_s32(mmtmpU1),vget_high_s32(mmtmpU1)));
mmtmpU0b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[2],*(int16x4_t*)conj)), rxdataF128[2]);
mmtmpU1b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[3],*(int16x4_t*)conj)), rxdataF128[3]);
mmtmpU1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpU0b),vget_high_s32(mmtmpU0b)),
vpadd_s32(vget_low_s32(mmtmpU1b),vget_high_s32(mmtmpU1b)));
mmtmpU0 = vqshlq_s32(mmtmpU0,-output_shift128);
mmtmpU1 = vqshlq_s32(mmtmpU1,-output_shift128);
rxdataF_comp128[1] = vcombine_s16(vmovn_s32(mmtmpU0),vmovn_s32(mmtmpU1));
mmtmpU0 = vmull_s16(ul_ch128[4], rxdataF128[4]);
mmtmpU1 = vmull_s16(ul_ch128[5], rxdataF128[5]);
mmtmpU0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpU0),vget_high_s32(mmtmpU0)),
vpadd_s32(vget_low_s32(mmtmpU1),vget_high_s32(mmtmpU1)));
mmtmpU0b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[4],*(int16x4_t*)conj)), rxdataF128[4]);
mmtmpU1b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[5],*(int16x4_t*)conj)), rxdataF128[5]);
mmtmpU1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpU0b),vget_high_s32(mmtmpU0b)),
vpadd_s32(vget_low_s32(mmtmpU1b),vget_high_s32(mmtmpU1b)));
mmtmpU0 = vqshlq_s32(mmtmpU0,-output_shift128);
mmtmpU1 = vqshlq_s32(mmtmpU1,-output_shift128);
rxdataF_comp128[2] = vcombine_s16(vmovn_s32(mmtmpU0),vmovn_s32(mmtmpU1));
// Add a jitter to compensate for the saturation in "packs" resulting in a bias on the DC after IDFT
rxdataF_comp128[0] = vqaddq_s16(rxdataF_comp128[0],(*(int16x8_t*)&jitter[0]));
rxdataF_comp128[1] = vqaddq_s16(rxdataF_comp128[1],(*(int16x8_t*)&jitter[0]));
rxdataF_comp128[2] = vqaddq_s16(rxdataF_comp128[2],(*(int16x8_t*)&jitter[0]));
ul_ch128+=6;
ul_ch_mag128+=3;
ul_ch_mag128b+=3;
rxdataF128+=6;
rxdataF_comp128+=3;
#endif
// }
}
#if defined(__x86_64__) || defined(__i386__)
_mm_empty();
_m_empty();
#endif
}
void fill_rbs_zeros_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
uint16_t ul_sc_start,
uint8_t UE_id,
uint8_t symbol)
{
//uint32_t I_sc = 11;//eNB->ulsch[UE_id]->harq_process->I_sc; // NB_IoT: subcarrier indication field: must be defined in higher layer
uint8_t Nsc_RU = 1;//eNB->ulsch[UE_id]->harq_process->N_sc_RU; // Vincent: number of sc 1,3,6,12
//uint16_t ul_sc_start; // subcarrier start index into UL RB
int32_t *rxdataF_comp32;
uint8_t m; // index of subcarrier
// ul_sc_start = get_UL_sc_start_NB_IoT(I_sc); // NB-IoT: get the used subcarrier in RB
rxdataF_comp32 = (int32_t *)&rxdataF_comp[0][symbol*frame_parms->N_RB_DL*12];
if (Nsc_RU != 12){
for (m=0;m<12;m++)
{ // 12 is the number of subcarriers per RB
if (m == ul_sc_start)
{
m = m + Nsc_RU; // skip non-zeros subcarriers
}
if(m<12)
{
rxdataF_comp32[m] = 0;
}
}
}
}
/*
void rotate_single_carrier_NB_IoT(PHY_VARS_eNB *eNB,
LTE_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
uint8_t eNB_id, // to be removed ??? since not used
uint8_t l, //symbol within subframe
uint8_t counter_msg3, /// to be replaced by the number of received part
uint16_t ul_sc_start,
uint8_t Qm,
uint8_t option) // 0 for data and 1 for ACK
{
//uint32_t I_sc = 11;//eNB->ulsch_NB_IoT[UE_id]->harq_process->I_sc; // NB_IoT: subcarrier indication field: must be defined in higher layer
//uint16_t ul_sc_start; // subcarrier start index into UL RB
int16_t pi_2_re[2] = {32767 , 0};
int16_t pi_2_im[2] = {0 , 32767};
//int16_t pi_4_re[2] = {32767 , 25735};
//int16_t pi_4_im[2] = {0 , 25736};
int16_t pi_4_re[2] = {32767 , 23170};
int16_t pi_4_im[2] = {0 , 23170};
int16_t e_phi_re[120] = {32767, 24811, 4807, -17531, -31357, -29956, -14010, 0, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, 0, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, 0, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, -1, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, 0, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, 0, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, -1, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, 0, -21403, -32413, -27684, -9512, 13278, 29621};
int16_t e_phi_im[120] = {0, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, -1, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, 0, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, 0, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, -1, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, 0, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, 0, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, -1, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009};
int16_t e_phi_re_m6[120] = {32767, 24811, 4807, -17531, -31357, -29956, -14010, 0, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, 0, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, 0, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, -1, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, 0, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, 0, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, -1, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, 0, -21403, -32413, -27684, -9512, 13278, 29621};
int16_t e_phi_im_m6[120] = {0, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, 0, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, -1, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, -1, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, 0, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, -1, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, -1, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, 0, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010};
int16_t *rxdataF_comp16;
int16_t rxdataF_comp16_re, rxdataF_comp16_im,rxdataF_comp16_re_2,rxdataF_comp16_im_2;
//ul_sc_start = get_UL_sc_start_NB_IoT(I_sc); // NB-IoT: get the used subcarrier in RB
rxdataF_comp16 = (int16_t *)&rxdataF_comp[eNB_id][l*frame_parms->N_RB_DL*12 + ul_sc_start];
rxdataF_comp16_re = rxdataF_comp16[0];
rxdataF_comp16_im = rxdataF_comp16[1];
rxdataF_comp16_re_2 = rxdataF_comp16_re;
rxdataF_comp16_im_2 = rxdataF_comp16_re;
if (Qm == 1){
rxdataF_comp16_re_2 = (int16_t)(((int32_t)pi_2_re[l%2] * (int32_t)rxdataF_comp16_re +
(int32_t)pi_2_im[l%2] * (int32_t)rxdataF_comp16_im)>>15);
rxdataF_comp16_im_2 = (int16_t)(((int32_t)pi_2_re[l%2] * (int32_t)rxdataF_comp16_im -
(int32_t)pi_2_im[l%2] * (int32_t)rxdataF_comp16_re)>>15);
}
if(Qm == 2){
rxdataF_comp16_re_2 = (int16_t)(((int32_t)pi_4_re[l%2] * (int32_t)rxdataF_comp16_re +
(int32_t)pi_4_im[l%2] * (int32_t)rxdataF_comp16_im)>>15);
rxdataF_comp16_im_2 = (int16_t)(((int32_t)pi_4_re[l%2] * (int32_t)rxdataF_comp16_im -
(int32_t)pi_4_im[l%2] * (int32_t)rxdataF_comp16_re)>>15);
}
if (option ==0)
{
rxdataF_comp16[0] = (int16_t)(((int32_t)e_phi_re[14*(8-counter_msg3) + l] * (int32_t)rxdataF_comp16_re_2 +
(int32_t)e_phi_im[14*(8-counter_msg3) + l] * (int32_t)rxdataF_comp16_im_2)>>15);
rxdataF_comp16[1] = (int16_t)(((int32_t)e_phi_re[14*(8-counter_msg3) + l] * (int32_t)rxdataF_comp16_im_2 -
(int32_t)e_phi_im[14*(8-counter_msg3) + l] * (int32_t)rxdataF_comp16_re_2)>>15);
} else {
rxdataF_comp16[0] = (int16_t)(((int32_t)e_phi_re_m6[14*(2-counter_msg3) + l] * (int32_t)rxdataF_comp16_re_2 +
(int32_t)e_phi_im_m6[14*(2-counter_msg3) + l] * (int32_t)rxdataF_comp16_im_2)>>15);
rxdataF_comp16[1] = (int16_t)(((int32_t)e_phi_re_m6[14*(2-counter_msg3) + l] * (int32_t)rxdataF_comp16_im_2 -
(int32_t)e_phi_im_m6[14*(2-counter_msg3) + l] * (int32_t)rxdataF_comp16_re_2)>>15);
// }
//}*/
//////////////////////////////////////////////////////////////////////
void rotate_single_carrier_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
uint8_t eNB_id,
uint8_t symbol, //symbol within subframe
uint8_t counter_msg3, /// to be replaced by the number of received part
uint16_t ul_sc_start,
uint8_t Qm,
uint16_t N_SF_per_word,
uint8_t option)
{
//uint32_t I_sc = 10;//eNB->ulsch_NB_IoT[UE_id]->harq_process->I_sc; // NB_IoT: subcarrier indication field: must be defined in higher layer
//uint16_t ul_sc_start; // subcarrier start index into UL RB
int16_t pi_2_re[2] = {32767 , 0};
int16_t pi_2_im[2] = {0 , 32767};
int16_t pi_4_re[2] = {32767 , 23170};
int16_t pi_4_im[2] = {0 , 23170};
int16_t *e_phi_re,*e_phi_im;
int16_t *rxdataF_comp16;
int16_t rxdataF_comp16_re, rxdataF_comp16_im,rxdataF_comp16_re_2,rxdataF_comp16_im_2;
int32_t sign_pm[2] = {1,-1};
int8_t ind_sign_pm; // index for above table
switch(ul_sc_start)
{
case 0:
e_phi_re = e_phi_re_m6;
e_phi_im = e_phi_im_m6;
break;
case 1:
e_phi_re = e_phi_re_m5;
e_phi_im = e_phi_im_m5;
break;
case 2:
e_phi_re = e_phi_re_m4;
e_phi_im = e_phi_im_m4;
break;
case 3:
e_phi_re = e_phi_re_m3;
e_phi_im = e_phi_im_m3;
break;
case 4:
e_phi_re = e_phi_re_m2;
e_phi_im = e_phi_im_m2;
break;
case 5:
e_phi_re = e_phi_re_m1;
e_phi_im = e_phi_im_m1;
break;
case 6:
e_phi_re = e_phi_re_0;
e_phi_im = e_phi_im_0;
break;
case 7:
e_phi_re = e_phi_re_p1;
e_phi_im = e_phi_im_p1;
break;
case 8:
e_phi_re = e_phi_re_p2;
e_phi_im = e_phi_im_p2;
break;
case 9:
e_phi_re = e_phi_re_p3;
e_phi_im = e_phi_im_p3;
break;
case 10:
e_phi_re = e_phi_re_p4;
e_phi_im = e_phi_im_p4;
break;
case 11:
e_phi_re = e_phi_re_p5;
e_phi_im = e_phi_im_p5;
break;
}
ind_sign_pm = ((14*(N_SF_per_word-counter_msg3) + symbol)/14)%2;
//ul_sc_start = get_UL_sc_start_NB_IoT(I_sc); // NB-IoT: get the used subcarrier in RB
rxdataF_comp16 = (int16_t *)&rxdataF_comp[0][symbol*frame_parms->N_RB_DL*12 + ul_sc_start];
rxdataF_comp16_re = rxdataF_comp16[0];
rxdataF_comp16_im = rxdataF_comp16[1];
rxdataF_comp16_re_2 = rxdataF_comp16_re;
rxdataF_comp16_im_2 = rxdataF_comp16_re;
/// Apply two rotations, see section 10.1.5 in TS 36.211
if (Qm == 1){ // rotation due to pi/2 BPSK
rxdataF_comp16_re_2 = (int16_t)(((int32_t)pi_2_re[symbol%2] * (int32_t)rxdataF_comp16_re +
(int32_t)pi_2_im[symbol%2] * (int32_t)rxdataF_comp16_im)>>15);
rxdataF_comp16_im_2 = (int16_t)(((int32_t)pi_2_re[symbol%2] * (int32_t)rxdataF_comp16_im -
(int32_t)pi_2_im[symbol%2] * (int32_t)rxdataF_comp16_re)>>15);
}
if(Qm == 2){ // rotation due to pi/4 QPSK
rxdataF_comp16_re_2 = (int16_t)(((int32_t)pi_4_re[symbol%2] * (int32_t)rxdataF_comp16_re +
(int32_t)pi_4_im[symbol%2] * (int32_t)rxdataF_comp16_im)>>15);
rxdataF_comp16_im_2 = (int16_t)(((int32_t)pi_4_re[symbol%2] * (int32_t)rxdataF_comp16_im -
(int32_t)pi_4_im[symbol%2] * (int32_t)rxdataF_comp16_re)>>15);
}
if(option==0) // rotation for msg3 (NPUSCH format 1)
{
rxdataF_comp16[0] = (int16_t)(((int32_t)e_phi_re[(14*(N_SF_per_word-counter_msg3) + symbol)%14] * sign_pm[ind_sign_pm] * (int32_t)rxdataF_comp16_re_2 +
(int32_t)e_phi_im[(14*(N_SF_per_word-counter_msg3) + symbol)%14] * sign_pm[ind_sign_pm] * (int32_t)rxdataF_comp16_im_2)>>15);
rxdataF_comp16[1] = (int16_t)(((int32_t)e_phi_re[(14*(N_SF_per_word-counter_msg3) + symbol)%14] * sign_pm[ind_sign_pm] * (int32_t)rxdataF_comp16_im_2 -
(int32_t)e_phi_im[(14*(N_SF_per_word-counter_msg3) + symbol)%14] * sign_pm[ind_sign_pm] * (int32_t)rxdataF_comp16_re_2)>>15);
}
if(option==1) // rotation for msg5 (NPUSCH format 1)
{
rxdataF_comp16[0] = (int16_t)(((int32_t)e_phi_re[14*(2-counter_msg3) + symbol] * (int32_t)rxdataF_comp16_re_2 +
(int32_t)e_phi_im[14*(2-counter_msg3) + symbol] * (int32_t)rxdataF_comp16_im_2)>>15);
rxdataF_comp16[1] = (int16_t)(((int32_t)e_phi_re[14*(2-counter_msg3) + symbol] * (int32_t)rxdataF_comp16_im_2 -
(int32_t)e_phi_im[14*(2-counter_msg3) + symbol] * (int32_t)rxdataF_comp16_re_2)>>15);
}
}
//////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
void rotate_bpsk_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
uint16_t ul_sc_start,
uint8_t UE_id,
uint8_t symbol)
{
//uint32_t I_sc = eNB->ulsch_NB_IoT[UE_id]->harq_process->I_sc; // NB_IoT: subcarrier indication field: must be defined in higher layer
//uint16_t ul_sc_start; // subcarrier start index into UL RB
int16_t m_pi_4_re = 25735; // cos(pi/4)
int16_t m_pi_4_im = 25736; // sin(pi/4)
int16_t *rxdataF_comp16;
int16_t rxdataF_comp16_re, rxdataF_comp16_im;
//ul_sc_start = get_UL_sc_start_NB_IoT(I_sc); // NB-IoT: get the used subcarrier in RB
rxdataF_comp16 = (int16_t *)&rxdataF_comp[0][symbol*frame_parms->N_RB_DL*12 + ul_sc_start];
rxdataF_comp16_re = rxdataF_comp16[0];
rxdataF_comp16_im = rxdataF_comp16[1];
rxdataF_comp16[0] = (int16_t)(((int32_t)m_pi_4_re * (int32_t)rxdataF_comp16_re +
(int32_t)m_pi_4_im * (int32_t)rxdataF_comp16_im)>>15);
rxdataF_comp16[1] = (int16_t)(((int32_t)m_pi_4_re * (int32_t)rxdataF_comp16_im -
(int32_t)m_pi_4_im * (int32_t)rxdataF_comp16_re)>>15);
}
#if defined(__x86_64__) || defined(__i386__)
__m128i avg128U;
#elif defined(__arm__)
int32x4_t avg128U;
#endif
void ulsch_channel_level_NB_IoT(int32_t **drs_ch_estimates_ext,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t *avg,
uint16_t nb_rb)
{
// int16_t rb;
uint8_t aarx;
#if defined(__x86_64__) || defined(__i386__)
__m128i *ul_ch128;
#elif defined(__arm__)
int16x4_t *ul_ch128;
#endif
for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
//clear average level
#if defined(__x86_64__) || defined(__i386__)
avg128U = _mm_setzero_si128();
ul_ch128=(__m128i *)drs_ch_estimates_ext[aarx];
// for (rb=0; rb<nb_rb; rb++) {
avg128U = _mm_add_epi32(avg128U,_mm_madd_epi16(ul_ch128[0],ul_ch128[0]));
avg128U = _mm_add_epi32(avg128U,_mm_madd_epi16(ul_ch128[1],ul_ch128[1]));
avg128U = _mm_add_epi32(avg128U,_mm_madd_epi16(ul_ch128[2],ul_ch128[2]));
ul_ch128+=3;
// }
#elif defined(__arm__)
avg128U = vdupq_n_s32(0);
ul_ch128=(int16x4_t *)drs_ch_estimates_ext[aarx];
// for (rb=0; rb<nb_rb; rb++) {
avg128U = vqaddq_s32(avg128U,vmull_s16(ul_ch128[0],ul_ch128[0]));
avg128U = vqaddq_s32(avg128U,vmull_s16(ul_ch128[1],ul_ch128[1]));
avg128U = vqaddq_s32(avg128U,vmull_s16(ul_ch128[2],ul_ch128[2]));
avg128U = vqaddq_s32(avg128U,vmull_s16(ul_ch128[3],ul_ch128[3]));
avg128U = vqaddq_s32(avg128U,vmull_s16(ul_ch128[4],ul_ch128[4]));
avg128U = vqaddq_s32(avg128U,vmull_s16(ul_ch128[5],ul_ch128[5]));
ul_ch128+=6;
// }
#endif
DevAssert( nb_rb );
avg[aarx] = (((int*)&avg128U)[0] +
((int*)&avg128U)[1] +
((int*)&avg128U)[2] +
((int*)&avg128U)[3])/(nb_rb*12);
}
#if defined(__x86_64__) || defined(__i386__)
_mm_empty();
_m_empty();
#endif
}
//////////////////////////////////////////////////////////////////////////////////////
void get_pilots_position(uint8_t npusch_format,uint8_t subcarrier_spacing,uint8_t *pilot_pos1,uint8_t *pilot_pos2,uint8_t *pilots_slot)
{
uint8_t pilot_pos1_format1_15k = 3, pilot_pos2_format1_15k = 10; // holds for npusch format 1, and 15 kHz subcarrier bandwidth
uint8_t pilot_pos1_format2_15k = 2, pilot_pos2_format2_15k = 9; // holds for npusch format 2, and 15 kHz subcarrier bandwidth
uint8_t pilot_pos1_format1_3_75k = 4, pilot_pos2_format1_3_75k = 11; // holds for npusch format 1, and 3.75 kHz subcarrier bandwidth
uint8_t pilot_pos1_format2_3_75k = 0, pilot_pos2_format2_3_75k = 7; // holds for npusch format 2, and 3.75 kHz subcarrier bandwidth
switch(npusch_format + subcarrier_spacing*2)
{
case 0: // data
*pilot_pos1 = pilot_pos1_format1_3_75k;
*pilot_pos2 = pilot_pos2_format1_3_75k;
*pilots_slot=1;
break;
case 1: // ACK
*pilot_pos1 = pilot_pos1_format2_3_75k;
*pilot_pos2 = pilot_pos2_format2_3_75k;
*pilots_slot=3;
break;
case 2: // data
*pilot_pos1 = pilot_pos1_format1_15k;
*pilot_pos2 = pilot_pos2_format1_15k;
*pilots_slot=1;
break;
case 3: // ACK
*pilot_pos1 = pilot_pos1_format2_15k;
*pilot_pos2 = pilot_pos2_format2_15k;
*pilots_slot=3;
break;
default:
printf("Error in rx_ulsch_NB_IoT");
break;
}
}
//////////////////////////////////////////////////////////////////////////////////////
void UL_channel_estimation_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_FRAME_PARMS *fp,
uint16_t UL_RB_ID_NB_IoT,
uint16_t Nsc_RU,
uint8_t pilot_pos1,
uint8_t pilot_pos2,
uint16_t ul_sc_start,
uint8_t Qm,
uint16_t N_SF_per_word,
uint8_t rx_subframe)
{
NB_IoT_eNB_PUSCH *pusch_vars = eNB->pusch_vars[0]; // UE_id
NB_IoT_eNB_COMMON *common_vars = &eNB->common_vars;
NB_IoT_eNB_NULSCH_t *ulsch_NB_IoT = eNB->ulsch_NB_IoT[0];
int l=0;
for (l=0; l<fp->symbols_per_tti; l++)
{
ulsch_extract_rbs_single_NB_IoT(common_vars->rxdataF[0], // common_vars->rxdataF[eNB_id],
pusch_vars->rxdataF_ext[0], // pusch_vars->rxdataF_ext[eNB_id]
UL_RB_ID_NB_IoT, //ulsch[UE_id]->harq_process->UL_RB_ID_NB_IoT, // index of UL NB_IoT resource block
Nsc_RU, //1, //ulsch_NB_IoT[0]->harq_process->N_sc_RU, // number of subcarriers in UL //////////////// high level parameter
l%(fp->symbols_per_tti/2), // (0..13)
l/(fp->symbols_per_tti/2), // (0,1)
fp);
if(ulsch_NB_IoT->npusch_format == 0) // format 1
{
ul_chest_tmp_NB_IoT(pusch_vars->rxdataF_ext[0], // pusch_vars->rxdataF_ext[eNB_id],
pusch_vars->drs_ch_estimates[0], // pusch_vars->drs_ch_estimates[eNB_id]
l%(fp->symbols_per_tti/2), //symbol within slot
l/(fp->symbols_per_tti/2),
ulsch_NB_IoT->counter_sf, // counter_msg
pilot_pos1,
pilot_pos2,
ul_sc_start,
Qm,
N_SF_per_word,
fp);
} else {
/// Channel Estimation (NPUSCH format 2)
ul_chest_tmp_f2_NB_IoT(pusch_vars->rxdataF_ext[0],
pusch_vars->drs_ch_estimates[0],
l%(fp->symbols_per_tti/2), //symbol within slot
l/(fp->symbols_per_tti/2),
ulsch_NB_IoT->counter_sf, //counter_msg,
ulsch_NB_IoT->npusch_format, // proc->flag_msg5,
rx_subframe,
Qm, // =1
ul_sc_start, // = 0
fp);
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void get_llr_per_sf_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_FRAME_PARMS *fp,
uint8_t npusch_format,
uint8_t counter_sf,
uint16_t N_SF_per_word,
uint8_t pilot_pos1,
uint8_t pilot_pos2,
uint16_t ul_sc_start,
uint16_t Nsc_RU)
{
NB_IoT_eNB_PUSCH *pusch_vars = eNB->pusch_vars[0]; // UE_id
int16_t *llrp;
uint32_t l,ii=0;
if(npusch_format == 0) // format 1
{
llrp = (int16_t*)&pusch_vars->llr[0+ (N_SF_per_word-counter_sf)*24]; /// 24= 12 symbols/SF * 2 // since Real and im
} else { // format 2
llrp = (int16_t*)&pusch_vars->llr[0+ (2-counter_sf)*16]; // 16 = 8 symbols/SF * 2 // since real and im
}
for (l=0; l<fp->symbols_per_tti; l++)
{
if (l==pilot_pos1 || l==pilot_pos2) // skip pilots // option 0 pilots = x,y, for option 1 pilots = 2,9 (subcarrier_spacing=1, npush_format=1)
{
if(npusch_format == 0)
{
l++;
} else {
l=l+3;
}
}
ulsch_qpsk_llr_NB_IoT(eNB,
fp,
pusch_vars->rxdataF_comp[0], // pusch_vars->rxdataF_comp[eNB_id],
pusch_vars->llr,
l,
0, // UE ID
ul_sc_start,
Nsc_RU,
&llrp[ii*2]);
ii++;
}
}
////////////////////////////////////descrambling NPUSCH //////////////////////////////////////////
void descrambling_NPUSCH_data_NB_IoT(NB_IoT_DL_FRAME_PARMS *fp,
int16_t *ulsch_llr,
int16_t *y,
uint8_t Qm,
unsigned int Cmux,
uint32_t rnti_tmp,
uint8_t rx_subframe,
uint32_t rx_frame)
{
unsigned int j,jj;
uint32_t x1, x2, s=0;
uint8_t reset;
x2 = (rnti_tmp<<14) + (rx_subframe<<9) + ((rx_frame%2)<<13) + fp->Nid_cell; //this is c_init in 36.211 Sec 10.1.3.1
reset = 1;
switch (Qm)
{
case 1:
jj=0;
for (j=0; j<Cmux; j++)
{
if (j%32==0)
{
s = lte_gold_generic(&x1, &x2, reset);
// printf("lte_gold[%d]=%x\n",i,s);
reset = 0;
}
if (((s>>(j%32))&1)==0)
{
y[j] = (ulsch_llr[jj<<1]>>1) + (ulsch_llr[(jj<<1)+1]>>1);
jj+=2;
} else {
y[j] = -(ulsch_llr[jj<<1]>>1) + (ulsch_llr[(jj<<1)+1]>>1);
jj+=2;
}
}
break;
case 2:
for (j=0; j<Cmux*2; j++)
{
if (j%32==0)
{
s = lte_gold_generic(&x1, &x2, reset);
// printf("lte_gold[%d]=%x\n",i,s);
reset = 0;
}
if (((s>>(j%32))&1)==0)
{
y[j] = -ulsch_llr[j];
} else {
y[j] = ulsch_llr[j];
}
}
break;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
void descrambling_NPUSCH_ack_NB_IoT(NB_IoT_DL_FRAME_PARMS *fp,
int32_t *y_msg5,
int32_t *llr_msg5,
uint32_t rnti_tmp,
uint16_t *counter_ack,
uint8_t rx_subframe,
uint32_t rx_frame)
{
int l = 0;
uint32_t x1, x2, s=0;
uint8_t reset = 1;
x2 = (rnti_tmp<<14) + (rx_subframe<<9) + ((rx_frame%2)<<13) + fp->Nid_cell;
s = lte_gold_generic(&x1, &x2, reset);
reset = 0;
for (l=0;l<16;l++)
{
if (((s>>(l%32))&1)==1) //xor
{
y_msg5[l] = -llr_msg5[l];
} else {
y_msg5[l] = llr_msg5[l];
}
*counter_ack += (y_msg5[l]>>31)&1;
}
}
//////////////////////////////////////////////////////////////////////////////////////////
uint32_t turbo_decoding_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_eNB_NULSCH_t *ulsch_NB_IoT,
eNB_rxtx_proc_NB_IoT_t *proc,
uint8_t npusch_format,
unsigned int G,
uint8_t rvdx,
uint8_t Qm,
uint32_t rx_frame,
uint8_t rx_subframe)
{
NB_IoT_UL_eNB_HARQ_t *ulsch_harq = ulsch_NB_IoT->harq_process;
int r = 0, Kr = 0;
unsigned int r_offset=0,Kr_bytes,iind=0;
uint8_t crc_type;
int offset = 0;
int16_t dummy_w[MAX_NUM_ULSCH_SEGMENTS_NB_IoT][3*(6144+64)];
int ret = 1;
unsigned int E;
uint8_t (*tc)(int16_t *y,
uint8_t *,
uint16_t,
uint16_t,
uint16_t,
uint8_t,
uint8_t,
uint8_t,
time_stats_t *,
time_stats_t *,
time_stats_t *,
time_stats_t *,
time_stats_t *,
time_stats_t *,
time_stats_t *);
tc = phy_threegpplte_turbo_decoder16;
for (r=0; r<ulsch_harq->C; r++)
{
// Get Turbo interleaver parameters
if (r<ulsch_harq->Cminus)
{
Kr = ulsch_harq->Kminus;
} else{
Kr = ulsch_harq->Kplus;
}
Kr_bytes = Kr>>3;
if (Kr_bytes<=64)
{
iind = (Kr_bytes-5);
} else if (Kr_bytes <=128) {
iind = 59 + ((Kr_bytes-64)>>1);
} else if (Kr_bytes <= 256) {
iind = 91 + ((Kr_bytes-128)>>2);
} else if (Kr_bytes <= 768) {
iind = 123 + ((Kr_bytes-256)>>3);
} else {
LOG_E(PHY,"ulsch_decoding: Illegal codeword size %d!!!\n",Kr_bytes);
}
memset(&dummy_w[r][0],0,3*(6144+64)*sizeof(short));
ulsch_harq->RTC[r] = generate_dummy_w(4+(Kr_bytes*8),
(uint8_t*)&dummy_w[r][0],
(r==0) ? ulsch_harq->F : 0);
if (lte_rate_matching_turbo_rx(ulsch_harq->RTC[r],
G,
ulsch_harq->w[r],
(uint8_t*) &dummy_w[r][0],
ulsch_harq->e+r_offset,
ulsch_harq->C,
1, ////// not used
0, //Uplink
1,
rvdx, //ulsch_harq->rvidx,
(ulsch_harq->round==0)?1:0, // clear
Qm, //2 //get_Qm_ul(ulsch_harq->mcs),
1,
r,
&E)==-1)
{
LOG_E(PHY,"ulsch_decoding.c: Problem in rate matching\n");
}
r_offset += E;
sub_block_deinterleaving_turbo(4+Kr,
&ulsch_harq->d[r][96],
ulsch_harq->w[r]);
if (ulsch_harq->C == 1)
{
crc_type = CRC24_A;
}else{
crc_type = CRC24_B;
}
// turbo decoding and CRC
ret = tc(&ulsch_harq->d[r][96],
ulsch_harq->c[r],
Kr,
f1f2mat_old[iind*2],
f1f2mat_old[(iind*2)+1],
ulsch_NB_IoT->max_turbo_iterations, // MAX_TURBO_ITERATIONS,
crc_type,
(r==0) ? ulsch_harq->F : 0,
&eNB->ulsch_tc_init_stats,
&eNB->ulsch_tc_alpha_stats,
&eNB->ulsch_tc_beta_stats,
&eNB->ulsch_tc_gamma_stats,
&eNB->ulsch_tc_ext_stats,
&eNB->ulsch_tc_intl1_stats,
&eNB->ulsch_tc_intl2_stats);
///////////////end decoding /////////////
if (ret != (1+ulsch_NB_IoT->max_turbo_iterations))
{
if (r<ulsch_harq->Cminus)
{
Kr = ulsch_harq->Kminus;
} else {
Kr = ulsch_harq->Kplus;
Kr_bytes = Kr>>3;
}
if (r==0)
{
memcpy(ulsch_harq->b,
&ulsch_harq->c[0][(ulsch_harq->F>>3)],
Kr_bytes - (ulsch_harq->F>>3) - ((ulsch_harq->C>1)?3:0));
offset = Kr_bytes - (ulsch_harq->F>>3) - ((ulsch_harq->C>1)?3:0);
} else {
memcpy(ulsch_harq->b+offset,
ulsch_harq->c[r],
Kr_bytes - ((ulsch_harq->C>1)?3:0));
offset += (Kr_bytes- ((ulsch_harq->C>1)?3:0));
}
fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,1); // indicate ACK to MAC
fill_rx_indication_NB_IoT(eNB,proc,npusch_format,1);
printf(" MSG3 OK");
} else {
fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,0); // indicate NAK to MAC
fill_rx_indication_NB_IoT(eNB,proc,npusch_format,0);
printf(" MSG3 NOT OK");
}
} //////////// r loop end ////////////
}
//////////////////////////////////////////////////////////////////////////////////////////
void deinterleaving_NPUSCH_data_NB_IoT(NB_IoT_UL_eNB_HARQ_t *ulsch_harq, int16_t *y, unsigned int G)
{
unsigned int j2=0;
int16_t *yp,*ep;
int iprime;
for (iprime=0,yp=&y[j2],ep=&ulsch_harq->e[0]; iprime<G; iprime+=8,j2+=8,ep+=8,yp+=8)
{
ep[0] = yp[0];
ep[1] = yp[1];
ep[2] = yp[2];
ep[3] = yp[3];
ep[4] = yp[4];
ep[5] = yp[5];
ep[6] = yp[6];
ep[7] = yp[7];
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void decode_NPUSCH_msg_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_FRAME_PARMS *fp,
eNB_rxtx_proc_NB_IoT_t *proc,
uint8_t npusch_format,
uint16_t N_SF_per_word,
uint16_t Nsc_RU,
uint16_t N_UL_slots,
uint8_t Qm,
uint8_t pilots_slot,
uint32_t rnti_tmp,
uint8_t rx_subframe,
uint32_t rx_frame)
{
NB_IoT_eNB_PUSCH *pusch_vars = eNB->pusch_vars[0]; // eNB->pusch_vars[UE_id];
NB_IoT_eNB_NULSCH_t *ulsch_NB_IoT = eNB->ulsch_NB_IoT[0];
NB_IoT_UL_eNB_HARQ_t *ulsch_harq = ulsch_NB_IoT->harq_process;
unsigned int A = (ulsch_harq->TBS)*8;
uint8_t rvdx = ulsch_harq->rvidx;
if (npusch_format == 0)
{
int16_t *ulsch_llr = eNB->pusch_vars[0]->llr; // eNB->pusch_vars[eNB_id]->llr; //UE_id=0
unsigned int G,H,Hprime,Hpp,Cmux,Rmux_prime;
int16_t y[6*14*1200] __attribute__((aligned(32)));
uint8_t ytag[14*1200];
G = (7-pilots_slot) * Qm * N_UL_slots * Nsc_RU; //(1 * Q_m) * 6 * 16; // Vincent : see 36.212, Section 5.1.4.1.2 // 16 slot(total number of slots) * 6 symboles (7-pilots_slot) * Qm*1
// x1 is set in lte_gold_generic
// x2 should not reinitialized each subframe
// x2 should be reinitialized according to 36.211 Sections 10.1.3.1 and 10.1.3.6
if (ulsch_harq->round == 0)
{
// This is a new packet, so compute quantities regarding segmentation
ulsch_harq->B = A+24;
lte_segmentation_NB_IoT(NULL,
NULL,
ulsch_harq->B,
&ulsch_harq->C,
&ulsch_harq->Cplus,
&ulsch_harq->Cminus,
&ulsch_harq->Kplus,
&ulsch_harq->Kminus,
&ulsch_harq->F);
}
ulsch_harq->G = G;
H = G ;
Hprime = H/Qm;
Hpp = Hprime; // => Hprime = G/Qm
Cmux = (7-pilots_slot) * N_UL_slots * Nsc_RU;
Rmux_prime = Hpp/Cmux;
// Clear "tag" interleaving matrix to allow for CQI/DATA identification
memset(ytag,0,Cmux*Rmux_prime);
memset(y,LTE_NULL_NB_IoT,Qm*Hpp);
descrambling_NPUSCH_data_NB_IoT(fp,
ulsch_llr,
y,
Qm,
Cmux,
rnti_tmp,
ulsch_NB_IoT->Msg3_subframe,
ulsch_NB_IoT->Msg3_frame);
/// deinterleaving
deinterleaving_NPUSCH_data_NB_IoT(ulsch_harq,y,G);
/// turbo decoding NPUSCH data
turbo_decoding_NB_IoT(eNB,
ulsch_NB_IoT,
proc,
npusch_format,
G,
rvdx,
Qm,
rx_frame,
rx_subframe);
} else { //////////////////// ACK ///////////////////
int32_t llr_msg5[16];
int32_t y_msg5[16];
int16_t *llrp2;
int l = 0;
uint16_t counter_ack = 0; // ack counter for decision ack/nack
llrp2 = (int16_t*)&pusch_vars->llr[0];
for (l=0;l<16;l++) // putting reanl and im over 32 bits /// Add real and imaginary parts of BPSK constellation
{
llr_msg5[l] = llrp2[l<<1] + llrp2[(l<<1)+1];
}
/////////////////////////////////////// descrambling + pre-decision /////////////////////////
descrambling_NPUSCH_ack_NB_IoT(fp,
y_msg5,
llr_msg5,
rnti_tmp,
&counter_ack,
ulsch_NB_IoT->Msg3_subframe,
ulsch_NB_IoT->Msg3_frame);
///////////////////////////////// Decision ACK/NACK /////////////////////////////////////
printf("\n\n\n");
if (counter_ack>8) //hard decision
{
//fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,1); // indicate ACK to MAC
fill_rx_indication_NB_IoT(eNB,proc,npusch_format,1);
printf(" decoded msg5: ACK ");
} else if (counter_ack<8) { //hard decision
//fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,0); // indicate NAK to MAC
fill_rx_indication_NB_IoT(eNB,proc,npusch_format,0);
printf(" decoded msg5: NACK ");
} else { //when equality (8 bits 0 vs 8 bits 1), soft decision
int32_t counter_ack_soft = 0;
for (l=0;l<16;l++)
{
counter_ack_soft += y_msg5[l];
}
if (counter_ack_soft>=0) // decision
{
// fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,1); // indicate ACK to MAC
fill_rx_indication_NB_IoT(eNB,proc,npusch_format,1);
printf(" decoded msg5 (soft): ACK ");
} else {
//fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,0); // indicate NAK to MAC
fill_rx_indication_NB_IoT(eNB,proc,npusch_format,0);
printf(" decoded msg5 (soft): NACK ");
}
}
printf("\n\n\n"); // end decision for ACK/NACK
}
///// if last sf of the word
ulsch_NB_IoT->counter_repetitions--;
if (npusch_format == 0) // rvidx is used for data and not used otherwise
{
if(ulsch_NB_IoT->Msg3_flag == 1) // case of msg3
{
ulsch_harq->rvidx = (ulsch_NB_IoT->counter_repetitions % 2)*2; // rvidx toogle for new code word
} else { /// other NPUSCH cases
ulsch_harq->rvidx = (((ulsch_harq->rvidx / 2) ^ 1) * 2); // rvidx toogle for new code word
}
}
if( (ulsch_NB_IoT->counter_sf == 1) && (ulsch_NB_IoT->counter_repetitions == 0) )
{
ulsch_NB_IoT->Msg3_active = 0;
ulsch_NB_IoT->Msg3_flag = 0;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////// generalization of RX procedures //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
uint8_t rx_ulsch_Gen_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
eNB_rxtx_proc_NB_IoT_t *proc,
uint8_t eNB_id, // this is the effective sector id
uint8_t UE_id,
uint16_t UL_RB_ID_NB_IoT, // 22 , to be included in // to be replaced by NB_IoT_start ??
uint8_t rx_subframe, // received subframe
uint32_t rx_frame) // received frame
{
NB_IoT_eNB_PUSCH *pusch_vars = eNB->pusch_vars[UE_id];
//LTE_eNB_COMMON *common_vars = &eNB->common_vars;
//NB_IoT_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
NB_IoT_DL_FRAME_PARMS *fp = &eNB->frame_parms;
// NB_IoT_eNB_NULSCH_t **ulsch_NB_IoT = &eNB->ulsch_NB_IoT[0];//[0][0];
NB_IoT_eNB_NULSCH_t *ulsch_NB_IoT = eNB->ulsch_NB_IoT[0];
NB_IoT_UL_eNB_HARQ_t *ulsch_harq = ulsch_NB_IoT->harq_process;
if( (7 < ((rx_frame*10 + rx_subframe)%160)) && ( ((rx_frame*10 + rx_subframe)%160) < (8+6)) )
{
return 0;
} else {
if (ulsch_NB_IoT->Msg3_active == 1)
{
uint8_t npusch_format = ulsch_NB_IoT->npusch_format; /// 0 or 1 -> format 1 or format 2
uint8_t subcarrier_spacing = ulsch_harq->subcarrier_spacing; // can be set as fix value //values are OK // 0 (3.75 KHz) or 1 (15 KHz)
uint16_t I_sc = ulsch_harq->subcarrier_indication; // Isc =0->18 , or 0->47 // format 2, 0->3 or 0->7
uint16_t I_mcs = ulsch_harq->mcs; // values 0->10
uint16_t Nsc_RU = get_UL_N_ru_NB_IoT(I_mcs,ulsch_harq->resource_assignment,ulsch_NB_IoT->Msg3_flag);
uint16_t N_UL_slots = get_UL_slots_per_RU_NB_IoT(subcarrier_spacing,I_sc,npusch_format)*Nsc_RU; // N_UL_slots per word
uint16_t N_SF_per_word = N_UL_slots/2;
uint16_t ul_sc_start = 0;//nulsch->HARQ_ACK_resource
if(ulsch_NB_IoT->flag_vars == 1)
{
ulsch_NB_IoT->counter_sf = N_SF_per_word;
ulsch_NB_IoT->counter_repetitions = get_UL_N_rep_NB_IoT(ulsch_harq->repetition_number);
ulsch_NB_IoT->flag_vars = 0;
}
if(ulsch_NB_IoT->counter_sf == N_SF_per_word) // initialization for scrambling
{
ulsch_NB_IoT->Msg3_subframe = rx_subframe; // first received subframe
ulsch_NB_IoT->Msg3_frame = rx_frame; // first received frame
}
uint8_t pilot_pos1, pilot_pos2, pilots_slot; // holds for npusch format 1, and 15 kHz subcarrier bandwidth
uint32_t l;
uint32_t rnti_tmp = ulsch_NB_IoT->rnti;
if( npusch_format == 1) // format 2 // ACK part
{
ul_sc_start = get_UL_sc_ACK_NB_IoT(subcarrier_spacing,I_sc);
} else {
ul_sc_start = get_UL_sc_index_start_NB_IoT(subcarrier_spacing,I_sc,npusch_format);
}
uint8_t Qm = get_Qm_UL_NB_IoT(I_mcs,Nsc_RU,I_sc,ulsch_NB_IoT->Msg3_flag);
get_pilots_position(npusch_format, subcarrier_spacing, &pilot_pos1, &pilot_pos2, &pilots_slot);
////////////////////// channel estimation per SF ////////////////////
UL_channel_estimation_NB_IoT(eNB, fp, UL_RB_ID_NB_IoT, Nsc_RU, pilot_pos1, pilot_pos2, ul_sc_start, Qm, N_SF_per_word, rx_subframe);
//////////////////////// Equalization per SF ///////////////////////
for (l=0; l<fp->symbols_per_tti; l++)
{
ul_chequal_tmp_NB_IoT(pusch_vars->rxdataF_ext[eNB_id],
pusch_vars->rxdataF_comp[eNB_id],
pusch_vars->drs_ch_estimates[eNB_id],
l%(fp->symbols_per_tti/2), //symbol within slot
l/(fp->symbols_per_tti/2),
fp);
}
///////////////////// Rotation /////////////////
for (l=0; l<fp->symbols_per_tti; l++)
{
/// In case of 1 subcarrier: BPSK and QPSK should be rotated by pi/2 and pi/4, respectively
rotate_single_carrier_NB_IoT(eNB,
fp,
pusch_vars->rxdataF_comp[eNB_id],
UE_id, // UE ID
l,
ulsch_NB_IoT->counter_sf, //counter_msg,
ul_sc_start,
Qm,
N_SF_per_word,
npusch_format); // or data
}
////////////////////// get LLR values per SF /////////////////////////
get_llr_per_sf_NB_IoT(eNB,
fp,
npusch_format,
ulsch_NB_IoT->counter_sf,
N_SF_per_word,
pilot_pos1,
pilot_pos2,
ul_sc_start,
Nsc_RU);
///////////////////////////////////////////////// NPUSH DECOD //////////////////////////////////////
if(ulsch_NB_IoT->counter_sf == 1)
{
decode_NPUSCH_msg_NB_IoT(eNB,
fp,
proc,
npusch_format,
N_SF_per_word,
Nsc_RU,
N_UL_slots,
Qm,
pilots_slot,
rnti_tmp,
rx_subframe,
rx_frame);
} // NPUSH decode end
/// update conter sf after every call
ulsch_NB_IoT->counter_sf--;
if( (ulsch_NB_IoT->counter_sf == 0) && (ulsch_NB_IoT->counter_repetitions > 0) )
{
ulsch_NB_IoT->counter_sf = N_SF_per_word;
}
return 1;
/////////////////////////////////////////END/////////////////////////////////////////////////////////////////////////////////////
} else {
return 0; // create void function for NPUSCH ?
}
}
}
\ No newline at end of file
/*
* 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_EXTERN_NB_IOT_H__
#define __PHY_EXTERN_NB_IOT_H__
//#include "PHY/defs.h"
#include "PHY/defs_L1_NB_IoT.h"
//#include "openair2/PHY_INTERFACE/defs_NB_IoT.h"
//#include "PHY_INTERFACE/IF_Module_NB_IoT.h"
/*
extern char* namepointer_chMag ;
extern char* namepointer_log2;
extern char fmageren_name2[512];
extern unsigned int RX_DMA_BUFFER[4][NB_ANTENNAS_RX];
extern unsigned int TX_DMA_BUFFER[4][NB_ANTENNAS_TX];
*/
#include "PHY/NBIoT_TRANSPORT/extern_NB_IoT.h"
//#include "SIMULATION/ETH_TRANSPORT/extern.h"
extern unsigned int DAQ_MBOX_NB_IoT;
extern int number_of_cards_NB_IoT;
//extern PHY_CONFIG *PHY_config;
//extern PHY_VARS *PHY_vars;
#ifndef OCP_FRAMEWORK
extern PHY_VARS_UE_NB_IoT ***PHY_vars_UE_NB_IoT_g;
extern PHY_VARS_eNB_NB_IoT ***PHY_vars_eNB_NB_IoT_g;
extern PHY_VARS_RN_NB_IoT **PHY_vars_RN_NB_IoT_g;
extern NB_IoT_DL_FRAME_PARMS *nb_iot_frame_parms_g;
#else
#define MAX_UE 10
#define MAX_eNB_NB_IoT 20
extern PHY_VARS_UE_NB_IoT *PHY_vars_UE_NB_IoT_g[MAX_UE][MAX_NUM_CCs];
extern PHY_VARS_eNB_NB_IoT *PHY_vars_eNB_NB_IoT_g[MAX_eNB_NB_IoT][MAX_NUM_CCs];
#endif
//extern MAC_xface_NB_IoT *mac_xface_NB_IoT;
extern short primary_synch_NB_IoT[264];
/*
extern short primary_synch1[144];
extern short primary_synch2[144];
extern unsigned char primary_synch0_tab[72];
extern unsigned char primary_synch1_tab[72];
extern unsigned char primary_synch2_tab[72]; */
extern int16_t *primary_synch0_time_NB_IoT; //!< index: [0..ofdm_symbol_size*2[
// extern int16_t *primary_synch1_time; //!< index: [0..ofdm_symbol_size*2[
// extern int16_t *primary_synch2_time; //!< index: [0..ofdm_symbol_size*2[
extern int *sync_corr_ue0_NB_IoT; //!< index [0..10*samples_per_tti[
/*
extern int *sync_corr_ue1; //!< index [0..10*samples_per_tti[
extern int *sync_corr_ue2; //!< index [0..10*samples_per_tti[
extern int flagMag;
//extern short **txdataF_rep_tmp;
extern char mode_string[4][20];
*/
/*
#ifndef OPENAIR2
extern unsigned char NB_eNB_INST;
extern unsigned char NB_UE_INST;
extern unsigned char NB_RN_INST;
#endif
extern unsigned int ULSCH_max_consecutive_errors;
extern int flag_LA;
extern double sinr_bler_map[MCS_COUNT][2][MCS_TABLE_LENGTH_MAX];
extern double sinr_bler_map_up[MCS_COUNT][2][16];
extern int table_length[MCS_COUNT];
extern double sinr_to_cqi[4][16];
extern int cqi_to_mcs[16];
//for MU-MIMO abstraction using MIESM
//this 2D arrarays contains SINR, MI and RBIR in rows 1, 2, and 3 respectively
extern double MI_map_4qam[3][162];
extern double MI_map_16qam[3][197];
extern double MI_map_64qam[3][227];
extern double beta1_dlsch_MI[6][MCS_COUNT];
extern double beta2_dlsch_MI[6][MCS_COUNT];
extern double q_qpsk[8];
extern double q_qam16[8];
extern double q_qam64[8];
extern double p_qpsk[8];
extern double p_qam16[8];
extern double p_qam64[8];
extern double beta1_dlsch[6][MCS_COUNT];
extern double beta2_dlsch[6][MCS_COUNT];
extern char eNB_functions[6][20];
extern char eNB_timing[2][20];
*/
extern int16_t unscrambling_lut_NB_IoT[65536*16];
/*
extern uint8_t scrambling_lut[65536*16];
extern unsigned short msrsb_6_40[8][4];
extern unsigned short msrsb_41_60[8][4];
extern unsigned short msrsb_61_80[8][4];
extern unsigned short msrsb_81_110[8][4];
extern unsigned short Nb_6_40[8][4];
extern unsigned short Nb_41_60[8][4];
extern unsigned short Nb_61_80[8][4];
extern unsigned short Nb_81_110[8][4];
extern uint16_t hundred_times_log10_NPRB[100];
extern uint8_t alpha_lut[8];
*/
#endif /*__PHY_EXTERN_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment