lte_Isc_NB_IoT.c 4.86 KB
Newer Older
Vincent Savaux's avatar
Vincent Savaux committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*
 * 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/lte_mcs_NB_IoT.c
* \brief Some support routines for subcarrier start into UL RB for ULSCH
Matthieu Kanj's avatar
Matthieu Kanj committed
24
* \author M. KANJ
Vincent Savaux's avatar
Vincent Savaux committed
25 26 27 28 29 30 31 32 33 34 35 36
* \date 2017
* \version 0.1
* \company b<>com
* \email: 
* \note
* \warning
*/

//#include "PHY/defs.h"
//#include "PHY/extern.h"
#include "PHY/LTE_TRANSPORT/proto_NB_IoT.h"

Matthieu Kanj's avatar
Matthieu Kanj committed
37 38 39 40 41
uint8_t tab_ack_15khz[16]= {0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3};
uint8_t tab_ack_3_75khz[16]= {38,39,40,41,42,43,44,45,38,39,40,41,42,43,44,45};
uint8_t tab_I_ru_N_ru_UL[8]= {1,2,3,4,5,6,8,10};
uint8_t tab_I_rep_N_rep_UL[8]={1,2,4,8,16,32,64,128};

Matthieu Kanj's avatar
Matthieu Kanj committed
42 43 44
/// 
uint8_t tab_ack_sc_format1[16]={0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3};
uint8_t tab_ack_sc_format2[16]={38,39,40,41,42,43,44,45,38,39,40,41,42,43,44,45};
45
/*
Vincent Savaux's avatar
Vincent Savaux committed
46 47 48 49
// Section 16.5.1.1 in 36.213
uint16_t get_UL_sc_start_NB_IoT(uint16_t I_sc)
{

Matthieu Kanj's avatar
Matthieu Kanj committed
50 51 52 53 54 55
	if (0<=I_sc && I_sc<=11)
	{
		return I_sc;

	} else if (12<=I_sc && I_sc<=15) {

Vincent Savaux's avatar
Vincent Savaux committed
56
		return 3*(I_sc-12); 
Matthieu Kanj's avatar
Matthieu Kanj committed
57 58 59 60 61 62 63

	}  else if (16<=I_sc && I_sc<=17) {

		return 6*(I_sc-16);

	} else if (I_sc==18){

Vincent Savaux's avatar
Vincent Savaux committed
64
		return 0; 
Matthieu Kanj's avatar
Matthieu Kanj committed
65 66 67 68 69

	} else if (I_sc>18 || I_sc<0){

		return -1;   /// error msg is needed for this case

70 71
	} else {

Matthieu Kanj's avatar
Matthieu Kanj committed
72
		return -1;   /// error msg is needed for this case
Vincent Savaux's avatar
Vincent Savaux committed
73 74 75
	}

}
76
*/
Vincent Savaux's avatar
Vincent Savaux committed
77

Matthieu Kanj's avatar
Matthieu Kanj committed
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
uint16_t get_UL_N_rep_NB_IoT(uint8_t I_rep)
{
   return tab_I_rep_N_rep_UL[I_rep];
}

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

	if(flag_msg3 ==1)      // msg3
	{

		if(I_mcs == 0)
		{
			return 4;

		} else if(I_mcs == 1) {

			return 3;

		} else if(I_mcs == 2) {

			return 1;
		} else {
			printf("error in I_mcs value from nfapi");
			return 0;
		}

	} else {      // other NPUSCH

		return tab_I_ru_N_ru_UL[I_ru];

	}

}

Matthieu Kanj's avatar
Matthieu Kanj committed
113 114 115 116 117 118 119 120 121
uint16_t get_UL_sc_ACK_NB_IoT(uint8_t subcarrier_spacing,uint16_t harq_ack_resource)
{

   if(subcarrier_spacing == 1)   /// 15KHz
   {

   	 return tab_ack_sc_format1[harq_ack_resource];

   } else {    // 3.75 KHz
Matthieu Kanj's avatar
Matthieu Kanj committed
122

Matthieu Kanj's avatar
Matthieu Kanj committed
123 124 125 126 127
   	 return tab_ack_sc_format2[harq_ack_resource];

   }

}
Matthieu Kanj's avatar
Matthieu Kanj committed
128 129 130 131 132


uint16_t get_UL_sc_index_start_NB_IoT(uint8_t subcarrier_spacing, uint16_t I_sc, uint8_t npush_format)
{

Matthieu Kanj's avatar
Matthieu Kanj committed
133
	if(npush_format == 0)    // format 1
Matthieu Kanj's avatar
Matthieu Kanj committed
134 135
	{

Matthieu Kanj's avatar
Matthieu Kanj committed
136
		if(subcarrier_spacing == 1)  ////////// 15 KHz
Matthieu Kanj's avatar
Matthieu Kanj committed
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
		{

			if (0<=I_sc && I_sc<12)
			{
				return I_sc;

			} else if (12<=I_sc && I_sc<16) {

				return 3*(I_sc-12); 

			}  else if (16<=I_sc && I_sc<18) {

				return 6*(I_sc-16);

			} else if (I_sc==18){

				return 0; 

			} else {

				return -1;  
				printf("Error in passed nfapi parameters (I_sc)");

			} 

		} else {      //////////// 3.75 KHz

			return I_sc;       /// values 0-47
		}

	} else {       /////////////////////////////////////// format 2

Matthieu Kanj's avatar
Matthieu Kanj committed
169
		if(subcarrier_spacing == 1)  ////////// 15 KHz
Matthieu Kanj's avatar
Matthieu Kanj committed
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
		{
			
			return(tab_ack_15khz[I_sc]);   

		} else {      //////////// 3.75 KHz

            return(tab_ack_3_75khz[I_sc]);
		}

	}

}

///////////////////////////////////////////////
uint8_t get_numb_UL_sc_NB_IoT(uint8_t subcarrier_spacing, uint8_t I_sc, uint8_t npush_format) 
{
			
Matthieu Kanj's avatar
Matthieu Kanj committed
187
	if(npush_format == 0)    // format 1
Matthieu Kanj's avatar
Matthieu Kanj committed
188
	{
Matthieu Kanj's avatar
Matthieu Kanj committed
189
		if(subcarrier_spacing == 1)  // 15 KHz
Matthieu Kanj's avatar
Matthieu Kanj committed
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
		{

			if(I_sc >= 0 && I_sc < 12)
			{
				return 1;
			} else if (I_sc >= 12 && I_sc < 16) {
				return 3;
			} else if (I_sc >= 16 && I_sc < 18) {
				return 6;
			} else if (I_sc == 18) {
				return 12;
			} else {
				return 0;
			}
		} else {
			return 1;
		}

	} else {
		return 1;
	}

}

////////////////////////////////////////////////////
uint8_t get_UL_slots_per_RU_NB_IoT(uint8_t subcarrier_spacing, uint8_t subcarrier_indcation, uint8_t UL_format)
{
	uint8_t subcarrier_number = get_numb_UL_sc_NB_IoT(subcarrier_spacing, subcarrier_indcation, UL_format);

Matthieu Kanj's avatar
Matthieu Kanj committed
219
	if(UL_format == 0) // format 1
Matthieu Kanj's avatar
Matthieu Kanj committed
220
	{
Matthieu Kanj's avatar
Matthieu Kanj committed
221
		if(subcarrier_spacing == 1) // 15 KHz
Matthieu Kanj's avatar
Matthieu Kanj committed
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
		{
			if (subcarrier_number == 1 )
			{
				return 16;

			} else if (subcarrier_number == 3) {

				return 8;

			} else if (subcarrier_number == 6) {

				return 4;

			} else {

				return 2;
			}

		} else {         // 3.75 KHz

			return 16;
		}

	} else {   // format 2

		return 4;

	}

}