proto_NB_IoT.h 33.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
/*
 * 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/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
Matthieu Kanj's avatar
Matthieu Kanj committed
29 30 31 32
 * \last changes: M. Kanj, V. Savaux
 * \date: 2018
 * \company: b<>com
 * \email: matthieu.kanj@b-com.com, vincent.savaux@b-com.com
33 34 35 36 37
 * \note
 * \warning
 */
#ifndef __LTE_TRANSPORT_PROTO_NB_IOT__H__
#define __LTE_TRANSPORT_PROTO_NB_IOT__H__
38
#include "PHY/defs_NB_IoT.h"
39
#include "PHY/impl_defs_lte.h"
40
#include "PHY/defs.h"
Matthieu Kanj's avatar
Matthieu Kanj committed
41
//#include "PHY/LTE_TRANSPORT/defs_NB_IoT.h"
42
//#include <math.h>
43

44
//NPSS
Matthieu Kanj's avatar
Matthieu Kanj committed
45
void free_eNB_dlsch_NB_IoT(NB_IoT_eNB_NDLSCH_t *dlsch);
46
void free_eNB_dlcch_NB_IoT(NB_IoT_eNB_NPDCCH_t *dlcch);
Matthieu Kanj's avatar
Matthieu Kanj committed
47

Matthieu Kanj's avatar
Matthieu Kanj committed
48
void init_unscrambling_lut_NB_IoT(void);
49

50 51
int generate_npss_NB_IoT(int32_t                **txdataF,
                         short                  amp,
52
                         LTE_DL_FRAME_PARMS  *frame_parms,
53 54 55
                         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
56 57 58

//NSSS

59 60
int generate_sss_NB_IoT(int32_t                **txdataF,
                        int16_t                amp,
61
                        LTE_DL_FRAME_PARMS  *frame_parms, 
62 63 64
                        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
65 66 67 68 69 70 71 72 73 74
                        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);
75 76 77

//NRS

78
void generate_pilots_NB_IoT(PHY_VARS_eNB  *phy_vars_eNB,
79 80 81 82 83
                            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
84 85 86 87


//NPBCH

88
int allocate_npbch_REs_in_RB(LTE_DL_FRAME_PARMS  *frame_parms,
89 90 91 92 93 94 95 96 97
                             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);

98 99 100 101 102 103 104 105 106 107 108 109
// NPDSCH
int allocate_REs_in_RB_NB_IoT(LTE_DL_FRAME_PARMS    *frame_parms,
                              int32_t               **txdataF,
                              uint32_t              *jj,
                              uint32_t              symbol_offset,
                              uint8_t               *x0,
                              uint8_t               pilots,
                              int16_t               amp,
                              unsigned short        id_offset,
                              uint8_t               pilot_shift,
                              uint32_t              *re_allocated); 

110 111
int generate_NDLSCH_NB_IoT(PHY_VARS_eNB               *eNB,
                           NB_IoT_eNB_NDLSCH_t        *RAR,
Matthieu Kanj's avatar
Matthieu Kanj committed
112 113 114 115 116
                           int32_t                    **txdataF,
                           int16_t                    amp,
                           LTE_DL_FRAME_PARMS         *frame_parms,
                           uint32_t                   frame,
                           uint32_t                   subframe,
117 118
                           int                        RB_IoT_ID,
                           uint8_t                    release_v13_5_0);
Matthieu Kanj's avatar
Matthieu Kanj committed
119

120 121 122 123 124 125 126 127
int generate_NPDCCH_NB_IoT(NB_IoT_eNB_NPDCCH_t    *DCI,
                           int32_t                **txdataF,
                           int16_t                amp,
                           LTE_DL_FRAME_PARMS     *frame_parms,
                           uint32_t               frame,
                           uint32_t               subframe,
                           int                    RB_IoT_ID);

Matthieu Kanj's avatar
Matthieu Kanj committed
128 129 130 131 132 133
int generate_SIB23(NB_IoT_eNB_NDLSCH_t    *SIB23,
                   int32_t                **txdataF,
                   int16_t                amp,
                   LTE_DL_FRAME_PARMS     *frame_parms,
                   uint32_t               frame,
                   uint32_t               subframe,
134 135
                   int                    RB_IoT_ID,
                   uint8_t                release_v13_5_0);
Matthieu Kanj's avatar
Matthieu Kanj committed
136

Matthieu Kanj's avatar
Matthieu Kanj committed
137 138 139 140 141 142
int generate_SIB1(NB_IoT_eNB_NDLSCH_t     *sib1_struct,
                   int32_t                **txdataF,
                   int16_t                amp,
                   LTE_DL_FRAME_PARMS     *frame_parms,
                   uint32_t               frame,
                   uint32_t               subframe,
Matthieu Kanj's avatar
Matthieu Kanj committed
143
                   int                    RB_IoT_ID,
144 145
                   uint8_t                operation_mode,
                   uint8_t                release_v13_5_0);
146 147 148 149

int generate_npbch(NB_IoT_eNB_NPBCH_t     *eNB_npbch,
                   int32_t                **txdataF,
                   int                    amp,
150
                   LTE_DL_FRAME_PARMS     *frame_parms,
151 152
                   uint8_t                *npbch_pdu,
                   uint8_t                frame_mod64,
153 154
                   unsigned short         NB_IoT_RB_ID,
                   uint8_t                release_v13_5_0);
155 156


157
void npbch_scrambling(LTE_DL_FRAME_PARMS  *frame_parms,
158 159
                      uint8_t                *npbch_e,
                      uint32_t               length);
160

Matthieu Kanj's avatar
Matthieu Kanj committed
161 162 163 164 165 166

void dlsch_scrambling_Gen_NB_IoT(LTE_DL_FRAME_PARMS         *frame_parms,
                                  NB_IoT_eNB_NDLSCH_t       *dlsch,
                                  int                       tot_bits,            // total number of bits to transmit
                                  uint16_t                  Nf,                  // Nf is the frame number (0..9)
                                  uint8_t                   Ns,
167 168 169
                                  uint32_t                  rnti,
                                  uint8_t                   release_v13_5_0,
                                  uint8_t                   SIB); 
Matthieu Kanj's avatar
Matthieu Kanj committed
170 171 172

NB_IoT_eNB_NDLSCH_t *new_eNB_dlsch_NB_IoT(uint8_t length, LTE_DL_FRAME_PARMS* frame_parms);

173 174
NB_IoT_eNB_NPDCCH_t *new_eNB_dlcch_NB_IoT(LTE_DL_FRAME_PARMS* frame_parms);

Matthieu Kanj's avatar
Matthieu Kanj committed
175 176 177 178 179 180 181
/*void dlsch_scrambling_Gen_NB_IoT(LTE_DL_FRAME_PARMS      *frame_parms,
                                  NB_IoT_eNB_NDLSCH_t    *dlsch,
                                  int                    tot_bits,         // total number of bits to transmit
                                  uint16_t               Nf,               // Nf is the frame number (0..9)
                                  uint8_t                Ns,
                                  uint32_t               rnti,     /// for SIB1 the SI_RNTI should be get from the DL request
                                  uint8_t                type);*/
Matthieu Kanj's avatar
Matthieu Kanj committed
182 183 184 185 186 187 188 189 190 191 192 193 194
/*
int scrambling_npbch_REs_rel_14(LTE_DL_FRAME_PARMS      *frame_parms,
                                int32_t                 **txdataF,
                                uint32_t                *jj,
                                int                     l,
                                uint32_t                symbol_offset,
                                uint8_t                 pilots,
                                unsigned short          id_offset,
                                uint8_t                 *reset,
                                uint32_t                *x1,
                                uint32_t                *x2,
                                uint32_t                *s);
*/
195 196
// Functions below implement 36-211 and 36-212

197
/*Use the UL DCI Information to configure PHY and also Pack the DCI*/
198 199 200
int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB            *eNB,
                                              int                     frame,
                                              uint8_t                 subframe,
201 202
                                              DCI_CONTENT             *DCI_Content,
                                              uint16_t                rnti,
203
                                              NB_IoT_eNB_NPDCCH_t     *ndlcch,
204
                                              uint8_t                 aggregation,
205 206
                                              uint8_t                 npdcch_start_symbol,
                                              uint8_t                 ncce_index);
207

208

209
/*Use the DL DCI Information to configure PHY and also Pack the DCI*/
210
int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB    *eNB,
211 212 213 214 215
                                              int                    frame,
                                              uint8_t                subframe,
                                              DCI_CONTENT            *DCI_Content,
                                              uint16_t               rnti,
                                              DCI_format_NB_IoT_t    dci_format,
Matthieu Kanj's avatar
Matthieu Kanj committed
216
                                              NB_IoT_eNB_NPDCCH_t      *ndlcch,
217
                                              LTE_DL_FRAME_PARMS  *frame_parms,
218
                                              uint8_t                aggregation,
219 220
									                            uint8_t                npdcch_start_symbol,
                                              uint8_t                ncce_index);
221

222

223
/*Function for DCI encoding, scrambling, modulation*/
224 225 226 227 228 229 230 231
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);
232

233 234 235 236 237 238 239 240 241 242 243
/*!
  \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
*/
Matthieu Kanj's avatar
Matthieu Kanj committed
244
/*unsigned int  ulsch_decoding_NB_IoT(PHY_VARS_eNB     *phy_vars_eNB,
Matthieu Kanj's avatar
Matthieu Kanj committed
245
                                    eNB_rxtx_proc_t  *proc,
246 247 248 249
                                    uint8_t                 UE_id,
                                    uint8_t                 control_only_flag,
                                    uint8_t                 Nbundled,
                                    uint8_t                 llr8_flag);
Matthieu Kanj's avatar
Matthieu Kanj committed
250
*/
251

Matthieu Kanj's avatar
Matthieu Kanj committed
252
//  NB_IoT_eNB_NULSCH_t *new_eNB_ulsch_NB_IoT(uint8_t abstraction_flag);
253

254

Matthieu Kanj's avatar
Matthieu Kanj committed
255
uint8_t subframe2harq_pid_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t subframe);
256

257 258 259

/** \brief Compute Q (modulation order) based on I_MCS for PUSCH.  Implements table 8.6.1-1 from 36.213.
    @param I_MCS */
260 261

//uint8_t get_Qm_ul_NB_IoT(uint8_t I_MCS);
262

263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
/** \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
*/

Matthieu Kanj's avatar
Matthieu Kanj committed
289 290 291 292 293 294 295 296 297 298
int dci_modulation_NB_IoT(int32_t              **txdataF,
                          int16_t              amp,
                          LTE_DL_FRAME_PARMS   *frame_parms,
                          uint8_t              control_region_size,      
                          NB_IoT_eNB_NPDCCH_t  *dlcch,            
                          unsigned int         npdsch_data_subframe,        
                          uint8_t              agr_level,
                          uint8_t              ncce_index,
                          unsigned int         subframe,
                          unsigned short       NB_IoT_RB_ID);
Matthieu Kanj's avatar
Matthieu Kanj committed
299 300

int dci_allocate_REs_in_RB_NB_IoT(LTE_DL_FRAME_PARMS  *frame_parms,
Matthieu Kanj's avatar
Matthieu Kanj committed
301 302 303 304 305 306 307
                                  int32_t             **txdataF,
                                  uint32_t            *jj,
                                  uint32_t            symbol_offset,
                                  uint8_t             *x0,
                                  uint8_t             pilots,
                                  uint8_t             pilot_shift,
                                  int16_t             amp,
Matthieu Kanj's avatar
Matthieu Kanj committed
308
                                  unsigned short      id_offset,
Matthieu Kanj's avatar
Matthieu Kanj committed
309
                                  uint8_t             ncce_index,
Matthieu Kanj's avatar
Matthieu Kanj committed
310 311 312 313 314 315 316
                                  uint8_t             agr_level,
                                  uint32_t            *re_allocated);


void dci_encoding_NB_IoT(uint8_t                  *a,
                         NB_IoT_eNB_NPDCCH_t      *dlcch,                  
                         uint8_t                  A,
Matthieu Kanj's avatar
Matthieu Kanj committed
317
                         uint16_t                 G,              
Matthieu Kanj's avatar
Matthieu Kanj committed
318 319 320
                         uint8_t                  ncce_index,
                         uint8_t                  agr_level);

Matthieu Kanj's avatar
Matthieu Kanj committed
321 322

void npdcch_scrambling_NB_IoT(LTE_DL_FRAME_PARMS     *frame_parms,
Matthieu Kanj's avatar
Matthieu Kanj committed
323 324 325 326 327
                              NB_IoT_eNB_NPDCCH_t     *dlcch,     // Input data
                              int                     G,          // Total number of bits to transmit in one subframe(case of DCI = G)
                              uint8_t                 Ns,       //XXX we pass the subframe  // Slot number (0..19)
                              uint8_t                 ncce_index,
                              uint8_t                 agr_level); 
Matthieu Kanj's avatar
Matthieu Kanj committed
328 329


330 331
int dlsch_modulation_NB_IoT(int32_t               **txdataF,
                            int16_t               amp,
Matthieu Kanj's avatar
Matthieu Kanj committed
332
                            LTE_DL_FRAME_PARMS    *frame_parms,
333
                            uint8_t               control_region_size,      // control region size for LTE , values between 0..3, (0 for stand-alone / 1, 2 or 3 for in-band)
Matthieu Kanj's avatar
Matthieu Kanj committed
334
                            NB_IoT_eNB_NDLSCH_t   *dlsch0,  //NB_IoT_eNB_NDLSCH_t
335
                            int                   G,              // number of bits per subframe
Matthieu Kanj's avatar
Matthieu Kanj committed
336 337
                            unsigned int          npdsch_data_subframe,     // subframe index of the data table of npdsch channel (G*Nsf)  , values are between 0..Nsf        
                            unsigned int          subframe,
338
                            unsigned short        NB_IoT_RB_ID);
Matthieu Kanj's avatar
Matthieu Kanj committed
339
/*
Matthieu Kanj's avatar
Matthieu Kanj committed
340
int dlsch_modulation_rar_NB_IoT(int32_t         **txdataF,
Matthieu Kanj's avatar
Matthieu Kanj committed
341 342 343 344 345 346 347 348 349
                                int16_t         amp,
                                LTE_DL_FRAME_PARMS      *frame_parms,
                                uint8_t         control_region_size,      // control region size for LTE , values between 0..3, (0 for stand-alone / 1, 2 or 3 for in-band)
                                NB_IoT_DL_eNB_HARQ_t      *dlsch0, //NB_IoT_eNB_NDLSCH_t
                                int           G,              // number of bits per subframe
                                unsigned int        npdsch_data_subframe,     // subframe index of the data table of npdsch channel (G*Nsf)  , values are between 0..Nsf        
                                unsigned int        subframe,
                                unsigned short      NB_IoT_RB_ID,
                                uint8_t             option);
Matthieu Kanj's avatar
Matthieu Kanj committed
350
*/
351
int32_t dlsch_encoding_NB_IoT(unsigned char              *a,
Matthieu Kanj's avatar
Matthieu Kanj committed
352
                              NB_IoT_eNB_NDLSCH_t        *dlsch, // NB_IoT_eNB_NDLSCH_t
353
                              uint8_t                    Nsf,        // number of subframes required for npdsch pdu transmission calculated from Isf (3GPP spec table)
Matthieu Kanj's avatar
Matthieu Kanj committed
354
                              unsigned int               G);         // G (number of available RE) is implicitly multiplied by 2 (since only QPSK modulation)
355
 
Matthieu Kanj's avatar
Matthieu Kanj committed
356

Matthieu Kanj's avatar
Matthieu Kanj committed
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
void get_pilots_position(uint8_t npusch_format,uint8_t  subcarrier_spacing,uint8_t *pilot_pos1,uint8_t *pilot_pos2,uint8_t *pilots_slot);

void UL_channel_estimation_NB_IoT(PHY_VARS_eNB        *eNB,
                                  LTE_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);

void get_llr_per_sf_NB_IoT(PHY_VARS_eNB        *eNB,
                           LTE_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);
379

Matthieu Kanj's avatar
Matthieu Kanj committed
380 381 382 383 384 385 386 387 388
void descrambling_NPUSCH_data_NB_IoT(LTE_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);

389 390 391 392 393 394 395 396
void descrambling_NPUSCH_ack_NB_IoT(LTE_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);

Matthieu Kanj's avatar
Matthieu Kanj committed
397 398 399 400 401 402 403 404 405 406
uint32_t  turbo_decoding_NB_IoT(PHY_VARS_eNB           *eNB,
                                NB_IoT_eNB_NULSCH_t    *ulsch_NB_IoT,
                                eNB_rxtx_proc_t        *proc,
                                uint8_t                 npusch_format,
                                unsigned int            G,
                                uint8_t                 rvdx,
                                uint8_t                 Qm,
                                uint32_t                rx_frame,
                                uint8_t                 rx_subframe);

Matthieu Kanj's avatar
Matthieu Kanj committed
407 408 409 410 411 412 413 414 415 416 417 418 419
void decode_NPUSCH_msg_NB_IoT(PHY_VARS_eNB        *eNB,
                              LTE_DL_FRAME_PARMS  *fp,
                              eNB_rxtx_proc_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);

Matthieu Kanj's avatar
Matthieu Kanj committed
420 421
void deinterleaving_NPUSCH_data_NB_IoT(NB_IoT_UL_eNB_HARQ_t *ulsch_harq, int16_t *y, unsigned int G);

Matthieu Kanj's avatar
Matthieu Kanj committed
422

423 424 425 426 427 428 429
uint8_t rx_ulsch_Gen_NB_IoT(PHY_VARS_eNB             *eNB,
                             eNB_rxtx_proc_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                 subframe,
                             uint32_t                frame);
Matthieu Kanj's avatar
Matthieu Kanj committed
430

Matthieu Kanj's avatar
Matthieu Kanj committed
431
void ulsch_extract_rbs_single_NB_IoT(int32_t **rxdataF,
Matthieu Kanj's avatar
Matthieu Kanj committed
432
                                     int32_t **rxdataF_ext, 
Matthieu Kanj's avatar
Matthieu Kanj committed
433
                                     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
Matthieu Kanj's avatar
Matthieu Kanj committed
434
                                     uint16_t N_sc_RU, // number of subcarriers in UL 
Matthieu Kanj's avatar
Matthieu Kanj committed
435 436 437
                                     uint8_t l,
                                     uint8_t Ns,
                                     LTE_DL_FRAME_PARMS *frame_parms);
Matthieu Kanj's avatar
Matthieu Kanj committed
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455

void ulsch_channel_level_NB_IoT(int32_t **drs_ch_estimates_ext,
                                LTE_DL_FRAME_PARMS *frame_parms,
                                int32_t *avg,
                                uint16_t nb_rb);

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,
                                LTE_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);
456

457 458
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);

459
//*****************Vincent part for nprach ******************//
Matthieu Kanj's avatar
Matthieu Kanj committed
460
uint32_t process_nprach_NB_IoT(PHY_VARS_eNB *eNB, int frame, uint8_t subframe,uint16_t *rnti, uint16_t *preamble_index, uint16_t *timing_advance); 
461

462
uint32_t TA_estimation_NB_IoT(PHY_VARS_eNB *eNB, 
463 464 465 466
                              int16_t *Rx_sub_sampled_buffer, 
                              uint16_t sub_sampling_rate, 
                              uint16_t FRAME_LENGTH_COMPLEX_SUB_SAMPLES, 
                              uint32_t estimated_TA_coarse, 
467
                              uint8_t coarse); 
468

469
uint8_t NPRACH_detection_NB_IoT(int16_t *input_buffer,uint32_t FRAME_LENGTH_COMPLEX_SAMPLESx); 
470

471 472 473
int16_t* sub_sampling_NB_IoT(int16_t *input_buffer, uint32_t length_input, uint32_t *length_ouput, uint16_t sub_sampling_rate); 

void filtering_signal(int16_t *input_buffer, int16_t *filtered_buffer, uint32_t FRAME_LENGTH_COMPLEX_SAMPLESx); 
474
//************************************************************//
Matthieu Kanj's avatar
Matthieu Kanj committed
475 476 477 478 479 480 481
///////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//uint8_t get_UL_I_TBS_from_MCS_NB_IoT(uint8_t I_mcs, uint8_t N_sc_RU, uint8_t Msg3_flag);

uint8_t get_Qm_UL_NB_IoT(unsigned char I_mcs, uint8_t N_sc_RU, uint8_t I_sc, uint8_t Msg3_flag);

Matthieu Kanj's avatar
Matthieu Kanj committed
482 483 484
//uint16_t get_UL_sc_start_NB_IoT(uint16_t I_sc);

uint16_t get_UL_sc_ACK_NB_IoT(uint8_t subcarrier_spacing,uint16_t harq_ack_resource); 
485

Matthieu Kanj's avatar
Matthieu Kanj committed
486 487 488 489 490 491 492 493 494 495
uint16_t get_UL_sc_index_start_NB_IoT(uint8_t subcarrier_spacing, uint16_t I_sc, uint8_t npush_format);

uint16_t get_UL_N_ru_NB_IoT(uint8_t I_mcs, uint8_t I_ru, uint8_t flag_msg3);

uint16_t get_UL_N_rep_NB_IoT(uint8_t I_rep);

uint8_t get_numb_UL_sc_NB_IoT(uint8_t subcarrier_spacing, uint8_t I_sc, uint8_t npush_format);

uint8_t get_UL_slots_per_RU_NB_IoT(uint8_t subcarrier_spacing, uint8_t subcarrier_indcation, uint8_t UL_format);

Matthieu Kanj's avatar
Matthieu Kanj committed
496 497 498 499
///////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////

Matthieu Kanj's avatar
Matthieu Kanj committed
500
void generate_grouphop_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms); 
501 502

void init_ul_hopping_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms); 
503

Matthieu Kanj's avatar
Matthieu Kanj committed
504 505 506
void rotate_single_carrier_NB_IoT(PHY_VARS_eNB          *eNB, 
                                  LTE_DL_FRAME_PARMS    *frame_parms,
                                  int32_t               **rxdataF_comp, 
Matthieu Kanj's avatar
Matthieu Kanj committed
507 508 509
                                  uint8_t               eNB_id,
                                  uint8_t               symbol, //symbol within subframe
                                  uint8_t               counter_msg3,          ///  to be replaced by the number of received part
Matthieu Kanj's avatar
Matthieu Kanj committed
510
                                  uint16_t              ul_sc_start,
Matthieu Kanj's avatar
Matthieu Kanj committed
511
                                  uint8_t               Qm,
Matthieu Kanj's avatar
Matthieu Kanj committed
512 513
                                  uint16_t              N_SF_per_word, 
                                  uint8_t               option);
514

Matthieu Kanj's avatar
Matthieu Kanj committed
515 516
void fill_rbs_zeros_NB_IoT(PHY_VARS_eNB *eNB, 
                                  LTE_DL_FRAME_PARMS *frame_parms,
517 518
                                  int32_t **rxdataF_comp,
                                  uint16_t ul_sc_start, 
519 520 521
                                  uint8_t UE_id,
                                  uint8_t symbol); 

Matthieu Kanj's avatar
Matthieu Kanj committed
522 523
int32_t ulsch_bpsk_llr_NB_IoT(PHY_VARS_eNB *eNB, 
                              LTE_DL_FRAME_PARMS *frame_parms,
524 525 526
                              int32_t **rxdataF_comp,
                              int16_t *ulsch_llr,
                              uint8_t symbol, 
527 528
                              uint16_t ul_sc_start,
                              uint8_t UE_id, 
529 530
                              int16_t **llrp); 

Matthieu Kanj's avatar
Matthieu Kanj committed
531 532
int32_t ulsch_qpsk_llr_NB_IoT(PHY_VARS_eNB *eNB, 
                              LTE_DL_FRAME_PARMS *frame_parms,
533 534 535
                              int32_t **rxdataF_comp,
                              int16_t *ulsch_llr, 
                              uint8_t symbol, 
Matthieu Kanj's avatar
Matthieu Kanj committed
536
                              uint8_t UE_id,
537
                              uint16_t ul_sc_start,
Matthieu Kanj's avatar
Matthieu Kanj committed
538
                              uint8_t Nsc_RU, 
Matthieu Kanj's avatar
Matthieu Kanj committed
539
                              int16_t *llrp);
540

Matthieu Kanj's avatar
Matthieu Kanj committed
541 542
void rotate_bpsk_NB_IoT(PHY_VARS_eNB *eNB, 
                        LTE_DL_FRAME_PARMS *frame_parms,
543 544
                        int32_t **rxdataF_comp,
                        uint16_t ul_sc_start, 
545 546
                        uint8_t UE_id,
                        uint8_t symbol); 
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568
//************************************************************// 


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,
569
                                        uint32_t frame,
570 571 572
                                        uint32_t high_speed_flag,
                                        NB_IoT_DL_FRAME_PARMS *frame_parms); 

573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592
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); 

Vincent Savaux's avatar
Vincent Savaux committed
593 594 595 596 597 598 599 600 601
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); 

Matthieu Kanj's avatar
Matthieu Kanj committed
602 603
/// Vincent: temporary functions 

Matthieu Kanj's avatar
Matthieu Kanj committed
604 605 606 607 608 609 610
int ul_chest_tmp_NB_IoT(int32_t             **rxdataF_ext,
                        int32_t             **ul_ch_estimates,
                        uint8_t             l, //symbol within slot 
                        uint8_t             Ns,
                        uint8_t             counter_msg3,
                        uint8_t             pilot_pos1,
                        uint8_t             pilot_pos2,
Matthieu Kanj's avatar
Matthieu Kanj committed
611
                        uint16_t            ul_sc_start,
Matthieu Kanj's avatar
Matthieu Kanj committed
612
                        uint8_t             Qm,
Matthieu Kanj's avatar
Matthieu Kanj committed
613
                        uint16_t            N_SF_per_word,
Matthieu Kanj's avatar
Matthieu Kanj committed
614
                        LTE_DL_FRAME_PARMS  *frame_parms); 
Matthieu Kanj's avatar
Matthieu Kanj committed
615

Matthieu Kanj's avatar
Matthieu Kanj committed
616 617 618 619 620 621 622 623 624
/// Channel estimation for NPUSCH format 2
int ul_chest_tmp_f2_NB_IoT(int32_t **rxdataF_ext,
                           int32_t **ul_ch_estimates,
                           uint8_t l, //symbol within slot 
                           uint8_t Ns,
                           uint8_t counter_msg3,
                           uint8_t flag,
                           uint8_t subframerx,
                           uint8_t Qm, 
Matthieu Kanj's avatar
Matthieu Kanj committed
625
                           uint16_t ul_sc_start,
Matthieu Kanj's avatar
Matthieu Kanj committed
626 627
                           LTE_DL_FRAME_PARMS *frame_parms);

Matthieu Kanj's avatar
Matthieu Kanj committed
628
void rotate_channel_sc_tmp_NB_IoT(int16_t *estimated_channel,
Matthieu Kanj's avatar
Matthieu Kanj committed
629 630
                                  uint8_t l, 
                                  uint8_t Qm, 
Matthieu Kanj's avatar
Matthieu Kanj committed
631
                                  uint8_t counter_msg3,
Matthieu Kanj's avatar
Matthieu Kanj committed
632
                                  uint16_t N_SF_per_word,
633
                                  uint16_t  ul_sc_start,
Matthieu Kanj's avatar
Matthieu Kanj committed
634
                                  uint8_t flag); 
Matthieu Kanj's avatar
Matthieu Kanj committed
635 636 637 638 639 640 641 642

int ul_chequal_tmp_NB_IoT(int32_t **rxdataF_ext,
      int32_t **rxdataF_comp,
      int32_t **ul_ch_estimates,
      uint8_t l, //symbol within slot 
      uint8_t Ns,
      LTE_DL_FRAME_PARMS *frame_parms);
///
Matthieu Kanj's avatar
Matthieu Kanj committed
643 644 645 646

////////////////////////////NB-IoT testing ///////////////////////////////
void clean_eNb_ulsch_NB_IoT(NB_IoT_eNB_NULSCH_t *ulsch);

Matthieu Kanj's avatar
Matthieu Kanj committed
647
int get_G_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms);
Matthieu Kanj's avatar
Matthieu Kanj committed
648

Matthieu Kanj's avatar
Matthieu Kanj committed
649 650 651 652 653 654
int get_G_SIB1_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms, uint8_t operation_mode_info);

int get_rep_num_SIB1_NB_IoT(uint8_t scheduling_info_sib1);

int get_start_frame_SIB1_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,uint8_t repetition);

Matthieu Kanj's avatar
Matthieu Kanj committed
655
NB_IoT_eNB_NULSCH_t *new_eNB_ulsch_NB_IoT(uint8_t max_turbo_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag);
Matthieu Kanj's avatar
Matthieu Kanj committed
656

657 658


659
#endif