lte_mcs_NB_IoT.c 5.37 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * 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
 */

22
/*! \file PHY/LTE_TRANSPORT/lte_mcs_NB_IoT.c
23
* \brief Some support routines for MCS computations
Matthieu Kanj's avatar
Matthieu Kanj committed
24
* \author V. Savaux , M. KANJ
25
* \date 2017
26
* \version 0.1
27 28
* \company b<>com
* \email: 
29 30 31 32 33 34
* \note
* \warning
*/

//#include "PHY/defs.h"
//#include "PHY/extern.h"
Matthieu Kanj's avatar
Matthieu Kanj committed
35

36
#include "PHY/LTE_TRANSPORT/proto_NB_IoT.h"
Matthieu Kanj's avatar
Matthieu Kanj committed
37 38
#include "PHY/LTE_TRANSPORT/extern_NB_IoT.h"

Matthieu Kanj's avatar
Matthieu Kanj committed
39 40

uint8_t get_Qm_UL_NB_IoT(unsigned char I_mcs, uint8_t N_sc_RU, uint8_t I_sc, uint8_t Msg3_flag)
41
{
Matthieu Kanj's avatar
Matthieu Kanj committed
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
	if (Msg3_flag == 1)    /////////////////////////// case of Msg3
    {
    	
        if(I_mcs > 0)
        {
            return  2;

        } else if (I_mcs == 0 && I_sc <12) {

            return 1;

        } else {           ////// I_mcs == 0 && I_sc >11

            return 2;
        }

    } else {                 /////////////////////// case of other NPUSCH config

        if(N_sc_RU == 1)
        {
            if(I_mcs <2)
            {
                return 1;
            } else {
                return 2;
            }

        } else {     /////////////// N_sc_RU > 1

            return 2;
        }

    }
Matthieu Kanj's avatar
Matthieu Kanj committed
75
	
76 77
}

Matthieu Kanj's avatar
Matthieu Kanj committed
78 79 80
int get_G_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms)
{
  
Matthieu Kanj's avatar
Matthieu Kanj committed
81
	uint16_t num_ctrl_symbols = frame_parms->control_region_size;  // eutra_control_region_size values are 0,1,2
Matthieu Kanj's avatar
Matthieu Kanj committed
82 83 84 85 86 87 88 89

    uint8_t nb_antennas_tx_LTE = frame_parms->nb_antennas_tx;
    uint8_t nb_antennas_tx_NB_IoT = frame_parms->nb_antennas_tx_NB_IoT;

    int G_value=0;

    switch (nb_antennas_tx_NB_IoT + (2*nb_antennas_tx_LTE)) {

Matthieu Kanj's avatar
Matthieu Kanj committed
90 91
		case 10:
			G_value = G_tab[(1*3)-num_ctrl_symbols-1];	
Matthieu Kanj's avatar
Matthieu Kanj committed
92 93 94
		break;

		case 6:
Matthieu Kanj's avatar
Matthieu Kanj committed
95
			G_value = G_tab[(2*3)-num_ctrl_symbols-1];
Matthieu Kanj's avatar
Matthieu Kanj committed
96 97 98
		break;

		case 4 :
Matthieu Kanj's avatar
Matthieu Kanj committed
99
			G_value = G_tab[(3*3)-num_ctrl_symbols-1];
Matthieu Kanj's avatar
Matthieu Kanj committed
100 101 102
		break;

		case 9 :
Matthieu Kanj's avatar
Matthieu Kanj committed
103
			G_value = G_tab[(4*3)-num_ctrl_symbols-1];	
Matthieu Kanj's avatar
Matthieu Kanj committed
104 105 106
		break;

		case 5:
Matthieu Kanj's avatar
Matthieu Kanj committed
107
			G_value = G_tab[(5*3)-num_ctrl_symbols-1];
Matthieu Kanj's avatar
Matthieu Kanj committed
108 109 110
		break;

		case 3 :
Matthieu Kanj's avatar
Matthieu Kanj committed
111
			G_value = G_tab[(6*3)-num_ctrl_symbols-1];
Matthieu Kanj's avatar
Matthieu Kanj committed
112 113 114 115 116 117 118 119 120 121 122 123
		break;

		default: 

			printf("Error getting G");

	}
  
    return(G_value);
  
}

Matthieu Kanj's avatar
Matthieu Kanj committed
124 125 126 127
int get_G_SIB1_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms, uint8_t operation_mode_info)
{
  
    uint16_t num_ctrl_symbols = 0;  // eutra_control_region_size values are 0,1,2
Matthieu Kanj's avatar
Matthieu Kanj committed
128
    if(operation_mode_info<2)        /// operation_mode_info, in-band (two value 0,1), stand-alone(3), guard band (2)
Matthieu Kanj's avatar
Matthieu Kanj committed
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
    {
        num_ctrl_symbols = 2;
    }
    uint8_t nb_antennas_tx_LTE = frame_parms->nb_antennas_tx;
    uint8_t nb_antennas_tx_NB_IoT = frame_parms->nb_antennas_tx_NB_IoT;

    int G_value=0;

    switch (nb_antennas_tx_NB_IoT + (2*nb_antennas_tx_LTE)) {

        case 10:
            G_value = G_tab[(1*3)-num_ctrl_symbols-1];  
        break;

        case 6:
            G_value = G_tab[(2*3)-num_ctrl_symbols-1];
        break;

        case 4 :
            G_value = G_tab[(3*3)-num_ctrl_symbols-1];
        break;

        case 9 :
            G_value = G_tab[(4*3)-num_ctrl_symbols-1];  
        break;

        case 5:
            G_value = G_tab[(5*3)-num_ctrl_symbols-1];
        break;

        case 3 :
            G_value = G_tab[(6*3)-num_ctrl_symbols-1];
        break;

        default: 

            printf("Error getting G");

    }
  
    return(G_value);
  
}

int get_rep_num_SIB1_NB_IoT(uint8_t scheduling_info_sib1)
{

    int value=0;

    if(scheduling_info_sib1 >11)
    {
        printf("value not allowed for schedulinginfo for sib1");

    } else {
   
        switch(scheduling_info_sib1 % 3)
        {
            case 0:
                value =4;
            break;

            case 1:
                value =8;
            break;

            case 2:
                value =16;
            break;
        }
   }
   
    return(value);
  
}

int get_start_frame_SIB1_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,uint8_t repetition)
{

    int value=0;

    uint16_t cell_id = frame_parms->Nid_cell ;

    if(repetition == 4)
    {
    	switch(cell_id %4)
    	{
    		case 0:
    			value =0;
    		break;

    		case 1:
    			value =16;
    		break;

    		case 2:
    			value =32;
    		break;

    		case 3:
    			value =48;
    		break;
    	}

    } else if(repetition == 8) {

    	switch(cell_id %2)
    	{
    		case 0:
    			value =0;
    		break;

    		case 1:
    			value =16;
    		break;
    	}

    } else if(repetition == 16) {

    	switch(cell_id %2)
    	{
    		case 0:
    			value =0;
    		break;

    		case 1:
    			value =1;
    		break;
    	}


    } else {
    	printf("Error in getting the starting frame of SIB1 ");
    }
  
    return(value);
  
}
Matthieu Kanj's avatar
Matthieu Kanj committed
266