lte_parms.c 7.06 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 * 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
 */
ghaddab's avatar
ghaddab committed
21

22
#include "defs.h"
kaltenbe's avatar
kaltenbe committed
23
#include "log.h"
24

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
uint16_t dl_S_table_normal[10]={3,9,10,11,12,3,9,10,11,6};
uint16_t dl_S_table_extended[10]={3,8,9,10,3,8,9,5,0,0};

void set_S_config(LTE_DL_FRAME_PARMS *fp) {

  int X = fp->srsX;

  fp->ul_symbols_in_S_subframe=(1+X);

  if ((fp->Ncp==EXTENDED) && (fp->tdd_config_S>7))
    AssertFatal(1==0,"Illegal S subframe configuration for Extended Prefix mode\n");

  fp->dl_symbols_in_S_subframe = (fp->Ncp==NORMAL)?dl_S_table_normal[fp->tdd_config_S] : dl_S_table_extended[fp->tdd_config_S];

  
}

42
43
int init_frame_parms(LTE_DL_FRAME_PARMS *frame_parms,uint8_t osf)
{
44

gauthier's avatar
gauthier committed
45
  uint8_t log2_osf;
46

Cedric Roux's avatar
Cedric Roux committed
47
#if DISABLE_LOG_X
48
  printf("Initializing frame parms for N_RB_DL %d, Ncp %d, osf %d\n",frame_parms->N_RB_DL,frame_parms->Ncp,osf);
Cedric Roux's avatar
Cedric Roux committed
49
50
51
#else
  LOG_I(PHY,"Initializing frame parms for N_RB_DL %d, Ncp %d, osf %d\n",frame_parms->N_RB_DL,frame_parms->Ncp,osf);
#endif
52

53
  if (frame_parms->Ncp==EXTENDED) {
54
55
56
    frame_parms->nb_prefix_samples0=512;
    frame_parms->nb_prefix_samples = 512;
    frame_parms->symbols_per_tti = 12;
57
  } else {
58
59
60
    frame_parms->nb_prefix_samples0 = 160;
    frame_parms->nb_prefix_samples = 144;
    frame_parms->symbols_per_tti = 14;
61
      
62
63
  }

64

65
66
67
68
  switch(osf) {
  case 1:
    log2_osf = 0;
    break;
69

70
71
72
  case 2:
    log2_osf = 1;
    break;
73

74
75
76
  case 4:
    log2_osf = 2;
    break;
77

78
79
80
  case 8:
    log2_osf = 3;
    break;
81

82
83
84
  case 16:
    log2_osf = 4;
    break;
85

86
  default:
87
    printf("Illegal oversampling %d\n",osf);
88
89
90
91
    return(-1);
  }

  switch (frame_parms->N_RB_DL) {
92

93
94
  case 100:
    if (osf>1) {
95
      printf("Illegal oversampling %d for N_RB_DL %d\n",osf,frame_parms->N_RB_DL);
96
97
      return(-1);
    }
98

99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
    if (frame_parms->threequarter_fs) {
      frame_parms->ofdm_symbol_size = 1536;
      frame_parms->samples_per_tti = 23040;
      frame_parms->first_carrier_offset = 1536-600;
      frame_parms->nb_prefix_samples=(frame_parms->nb_prefix_samples*3)>>2;
      frame_parms->nb_prefix_samples0=(frame_parms->nb_prefix_samples0*3)>>2;
    }
    else {
      frame_parms->ofdm_symbol_size = 2048;
      frame_parms->samples_per_tti = 30720;
      frame_parms->first_carrier_offset = 2048-600;
    }
    frame_parms->N_RBGS = 4;
    frame_parms->N_RBG = 25;
    break;

  case 75:
    if (osf>1) {
      printf("Illegal oversampling %d for N_RB_DL %d\n",osf,frame_parms->N_RB_DL);
      return(-1);
    }


    frame_parms->ofdm_symbol_size = 1536;
    frame_parms->samples_per_tti = 23040;
    frame_parms->first_carrier_offset = 1536-450;
    frame_parms->nb_prefix_samples=(frame_parms->nb_prefix_samples*3)>>2;
    frame_parms->nb_prefix_samples0=(frame_parms->nb_prefix_samples0*3)>>2;
127
128
    frame_parms->N_RBGS = 4;
    frame_parms->N_RBG = 25;
129
    break;
130

131
132
  case 50:
    if (osf>1) {
133
      printf("Illegal oversampling %d for N_RB_DL %d\n",osf,frame_parms->N_RB_DL);
134
135
      return(-1);
    }
136

137
138
    frame_parms->ofdm_symbol_size = 1024*osf;
    frame_parms->samples_per_tti = 15360*osf;
139
    frame_parms->first_carrier_offset = frame_parms->ofdm_symbol_size - 300;
140
141
    frame_parms->nb_prefix_samples>>=(1-log2_osf);
    frame_parms->nb_prefix_samples0>>=(1-log2_osf);
142
143
    frame_parms->N_RBGS = 3;
    frame_parms->N_RBG = 17;
144
145
    break;

146
147
  case 25:
    if (osf>2) {
148
      printf("Illegal oversampling %d for N_RB_DL %d\n",osf,frame_parms->N_RB_DL);
149
150
      return(-1);
    }
151

152
    frame_parms->ofdm_symbol_size = 512*osf;
153

154

155
    frame_parms->samples_per_tti = 7680*osf;
156
    frame_parms->first_carrier_offset = frame_parms->ofdm_symbol_size - 150;
157
158
    frame_parms->nb_prefix_samples>>=(2-log2_osf);
    frame_parms->nb_prefix_samples0>>=(2-log2_osf);
159
160
    frame_parms->N_RBGS = 2;
    frame_parms->N_RBG = 13;
knopp's avatar
   
knopp committed
161
162


163
    break;
164

165
166
167
168
169
170
  case 15:
    frame_parms->ofdm_symbol_size = 256*osf;
    frame_parms->samples_per_tti = 3840*osf;
    frame_parms->first_carrier_offset = frame_parms->ofdm_symbol_size - 90;
    frame_parms->nb_prefix_samples>>=(3-log2_osf);
    frame_parms->nb_prefix_samples0>>=(3-log2_osf);
171
172
    frame_parms->N_RBGS = 2;
    frame_parms->N_RBG = 8;
173
    break;
174

175
176
177
178
179
180
  case 6:
    frame_parms->ofdm_symbol_size = 128*osf;
    frame_parms->samples_per_tti = 1920*osf;
    frame_parms->first_carrier_offset = frame_parms->ofdm_symbol_size - 36;
    frame_parms->nb_prefix_samples>>=(4-log2_osf);
    frame_parms->nb_prefix_samples0>>=(4-log2_osf);
181
182
    frame_parms->N_RBGS = 1;
    frame_parms->N_RBG = 6;
183
184
185
    break;

  default:
186
    printf("init_frame_parms: Error: Number of resource blocks (N_RB_DL %d) undefined, frame_parms = %p \n",frame_parms->N_RB_DL, frame_parms);
187
188
189
190
    return(-1);
    break;
  }

knopp's avatar
   
knopp committed
191
192
  printf("lte_parms.c: Setting N_RB_DL to %d, ofdm_symbol_size %d\n",frame_parms->N_RB_DL, frame_parms->ofdm_symbol_size);

193
194
  if (frame_parms->frame_type == TDD) set_S_config(frame_parms);

195
196
197
198
199
200
201
  //  frame_parms->tdd_config=3;
  return(0);
}


void dump_frame_parms(LTE_DL_FRAME_PARMS *frame_parms)
{
202
203
204
205
206
207
208
209
210
211
  printf("frame_parms->N_RB_DL=%d\n",frame_parms->N_RB_DL);
  printf("frame_parms->N_RB_UL=%d\n",frame_parms->N_RB_UL);
  printf("frame_parms->Nid_cell=%d\n",frame_parms->Nid_cell);
  printf("frame_parms->Ncp=%d\n",frame_parms->Ncp);
  printf("frame_parms->Ncp_UL=%d\n",frame_parms->Ncp_UL);
  printf("frame_parms->nushift=%d\n",frame_parms->nushift);
  printf("frame_parms->frame_type=%d\n",frame_parms->frame_type);
  printf("frame_parms->tdd_config=%d\n",frame_parms->tdd_config);
  printf("frame_parms->tdd_config_S=%d\n",frame_parms->tdd_config_S);
  printf("frame_parms->mode1_flag=%d\n",frame_parms->mode1_flag);
Xiwen JIANG's avatar
Xiwen JIANG committed
212
  printf("frame_parms->nb_antenna_ports_eNB=%d\n",frame_parms->nb_antenna_ports_eNB);
213
214
215
216
217
218
219
220
  printf("frame_parms->nb_antennas_tx=%d\n",frame_parms->nb_antennas_tx);
  printf("frame_parms->nb_antennas_rx=%d\n",frame_parms->nb_antennas_rx);
  printf("frame_parms->ofdm_symbol_size=%d\n",frame_parms->ofdm_symbol_size);
  printf("frame_parms->nb_prefix_samples=%d\n",frame_parms->nb_prefix_samples);
  printf("frame_parms->nb_prefix_samples0=%d\n",frame_parms->nb_prefix_samples0);
  printf("frame_parms->first_carrier_offset=%d\n",frame_parms->first_carrier_offset);
  printf("frame_parms->samples_per_tti=%d\n",frame_parms->samples_per_tti);
  printf("frame_parms->symbols_per_tti=%d\n",frame_parms->symbols_per_tti);
221
}