lte_parms.c 5.35 KB
Newer Older
1
#include "defs.h"
kaltenbe's avatar
kaltenbe committed
2
#include "log.h"
3

4 5
int init_frame_parms(LTE_DL_FRAME_PARMS *frame_parms,uint8_t osf)
{
6

7
  uint8_t log2_osf;
8

9 10
  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);

11 12 13 14
  if (frame_parms->Ncp==1) {
    frame_parms->nb_prefix_samples0=512;
    frame_parms->nb_prefix_samples = 512;
    frame_parms->symbols_per_tti = 12;
15
  } else {
16 17 18 19 20 21 22 23 24
    frame_parms->nb_prefix_samples0 = 160;
    frame_parms->nb_prefix_samples = 144;
    frame_parms->symbols_per_tti = 14;
  }

  switch(osf) {
  case 1:
    log2_osf = 0;
    break;
25

26 27 28
  case 2:
    log2_osf = 1;
    break;
29

30 31 32
  case 4:
    log2_osf = 2;
    break;
33

34 35 36
  case 8:
    log2_osf = 3;
    break;
37

38 39 40
  case 16:
    log2_osf = 4;
    break;
41

42
  default:
43
    printf("Illegal oversampling %d\n",osf);
44 45 46 47
    return(-1);
  }

  switch (frame_parms->N_RB_DL) {
48

49 50
  case 100:
    if (osf>1) {
51
      printf("Illegal oversampling %d for N_RB_DL %d\n",osf,frame_parms->N_RB_DL);
52 53
      return(-1);
    }
54

55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
    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;
83 84
    frame_parms->N_RBGS = 4;
    frame_parms->N_RBG = 25;
85
    break;
86

87 88
  case 50:
    if (osf>1) {
89
      printf("Illegal oversampling %d for N_RB_DL %d\n",osf,frame_parms->N_RB_DL);
90 91
      return(-1);
    }
92

93 94
    frame_parms->ofdm_symbol_size = 1024*osf;
    frame_parms->samples_per_tti = 15360*osf;
95
    frame_parms->first_carrier_offset = frame_parms->ofdm_symbol_size - 300;
96 97
    frame_parms->nb_prefix_samples>>=(1-log2_osf);
    frame_parms->nb_prefix_samples0>>=(1-log2_osf);
98 99
    frame_parms->N_RBGS = 3;
    frame_parms->N_RBG = 17;
100 101
    break;

102 103
  case 25:
    if (osf>2) {
104
      printf("Illegal oversampling %d for N_RB_DL %d\n",osf,frame_parms->N_RB_DL);
105 106
      return(-1);
    }
107

108
    frame_parms->ofdm_symbol_size = 512*osf;
109

110

111
    frame_parms->samples_per_tti = 7680*osf;
112
    frame_parms->first_carrier_offset = frame_parms->ofdm_symbol_size - 150;
113 114
    frame_parms->nb_prefix_samples>>=(2-log2_osf);
    frame_parms->nb_prefix_samples0>>=(2-log2_osf);
115 116
    frame_parms->N_RBGS = 2;
    frame_parms->N_RBG = 13;
117 118


119
    break;
120

121 122 123 124 125 126
  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);
127 128
    frame_parms->N_RBGS = 2;
    frame_parms->N_RBG = 8;
129
    break;
130

131 132 133 134 135 136
  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);
137 138
    frame_parms->N_RBGS = 1;
    frame_parms->N_RBG = 6;
139 140 141
    break;

  default:
142
    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);
143 144 145 146
    return(-1);
    break;
  }

147 148
  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);

149 150 151 152 153 154 155
  //  frame_parms->tdd_config=3;
  return(0);
}


void dump_frame_parms(LTE_DL_FRAME_PARMS *frame_parms)
{
156 157 158 159 160 161 162 163 164 165
  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);
166
  printf("frame_parms->nb_antennas_tx_eNB(nb_antenna_ports)=%d\n",frame_parms->nb_antennas_tx_eNB);
167 168 169 170 171 172 173 174
  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);
175
}