lte_param_init.c 4.42 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
 */

Raymond Knopp's avatar
Raymond Knopp committed
22
23
24
25
26
27
28
29
30
31
32
#include <string.h>
#include <math.h>
#include <unistd.h>
#include <execinfo.h>
#include <signal.h>

#include "SIMULATION/TOOLS/defs.h"
#include "PHY/types.h"
#include "PHY/defs.h"
#include "PHY/extern.h"

33
34
extern PHY_VARS_eNB *eNB;
extern PHY_VARS_UE *UE;
Raymond Knopp's avatar
Raymond Knopp committed
35

36
37
void lte_param_init(unsigned char N_tx_port_eNB, 
                    unsigned char N_tx_phy,
Raymond Knopp's avatar
Raymond Knopp committed
38
39
40
41
42
43
44
45
46
47
48
49
		    unsigned char N_rx,
		    unsigned char transmission_mode,
		    uint8_t extended_prefix_flag,
		    frame_t frame_type, 
		    uint16_t Nid_cell,
		    uint8_t tdd_config,
		    uint8_t N_RB_DL,
		    uint8_t threequarter_fs,
                    uint8_t osf,
		    uint32_t perfect_ce)
{

50
  LTE_DL_FRAME_PARMS *frame_parms;
Raymond Knopp's avatar
Raymond Knopp committed
51
52
53
  int i;

  printf("Start lte_param_init\n");
54
55
  eNB = malloc(sizeof(PHY_VARS_eNB));
  UE = malloc(sizeof(PHY_VARS_UE));
knopp's avatar
knopp committed
56
57
  memset((void*)eNB,0,sizeof(PHY_VARS_eNB));
  memset((void*)UE,0,sizeof(PHY_VARS_UE));
Raymond Knopp's avatar
Raymond Knopp committed
58
59
60
61
62
63
64
  //PHY_config = malloc(sizeof(PHY_CONFIG));
  mac_xface = malloc(sizeof(MAC_xface));

  srand(0);
  randominit(0);
  set_taus_seed(0);

65
  frame_parms = &(eNB->frame_parms);
66

67
68
69
70
71
72
73
  frame_parms->N_RB_DL            = N_RB_DL;   //50 for 10MHz and 25 for 5 MHz
  frame_parms->N_RB_UL            = N_RB_DL;
  frame_parms->threequarter_fs    = threequarter_fs;
  frame_parms->Ncp                = extended_prefix_flag;
  frame_parms->Ncp_UL             = extended_prefix_flag;
  frame_parms->Nid_cell           = Nid_cell;
  frame_parms->nushift            = Nid_cell%6;
74
  frame_parms->nb_antennas_tx     = N_tx_phy;
75
  frame_parms->nb_antennas_rx     = N_rx;
76
  frame_parms->nb_antenna_ports_eNB = N_tx_port_eNB;
77
78
  frame_parms->phich_config_common.phich_resource         = oneSixth;
  frame_parms->phich_config_common.phich_duration         = normal;
79
80
81
82
83
84
  frame_parms->tdd_config         = tdd_config;
  frame_parms->frame_type         = frame_type;
  //  frame_parms->Csrs = 2;
  //  frame_parms->Bsrs = 0;
  //  frame_parms->kTC = 0;44
  //  frame_parms->n_RRC = 0;
85
  frame_parms->mode1_flag = (transmission_mode == 1 || transmission_mode ==7)? 1 : 0;
Raymond Knopp's avatar
Raymond Knopp committed
86

87
  init_frame_parms(frame_parms,osf);
Raymond Knopp's avatar
Raymond Knopp committed
88

89
  //copy_lte_parms_to_phy_framing(frame_parms, &(PHY_config->PHY_framing));
Raymond Knopp's avatar
Raymond Knopp committed
90

91
  //  phy_init_top(frame_parms); //allocation
Raymond Knopp's avatar
Raymond Knopp committed
92

93
94
95
  UE->is_secondary_ue = 0;
  UE->frame_parms = *frame_parms;
  eNB->frame_parms = *frame_parms;
Raymond Knopp's avatar
Raymond Knopp committed
96

97
98
  eNB->transmission_mode[0] = transmission_mode;
  UE->transmission_mode[0] = transmission_mode;
99

100
101
  phy_init_lte_top(frame_parms);
  dump_frame_parms(frame_parms);
Raymond Knopp's avatar
Raymond Knopp committed
102

103
104
105
  UE->measurements.n_adj_cells=0;
  UE->measurements.adj_cell_id[0] = Nid_cell+1;
  UE->measurements.adj_cell_id[1] = Nid_cell+2;
Raymond Knopp's avatar
Raymond Knopp committed
106
107

  for (i=0; i<3; i++)
108
    lte_gold(frame_parms,UE->lte_gold_table[i],Nid_cell+i);
Raymond Knopp's avatar
Raymond Knopp committed
109

110
  phy_init_lte_ue(UE,1,0);
knopp's avatar
knopp committed
111
  phy_init_lte_eNB(eNB,0,0);
Raymond Knopp's avatar
Raymond Knopp committed
112

113
114
  generate_pcfich_reg_mapping(&UE->frame_parms);
  generate_phich_reg_mapping(&UE->frame_parms);
Raymond Knopp's avatar
Raymond Knopp committed
115
116

  // DL power control init
117
118
  //if (transmission_mode == 1) {
  if (transmission_mode == 1 || transmission_mode ==7) {
119
120
121
122
    eNB->pdsch_config_dedicated->p_a  = dB0; // 4 = 0dB
    ((eNB->frame_parms).pdsch_config_common).p_b = 0;
    UE->pdsch_config_dedicated->p_a  = dB0; // 4 = 0dB
    ((UE->frame_parms).pdsch_config_common).p_b = 0;
Raymond Knopp's avatar
Raymond Knopp committed
123
  } else { // rho_a = rhob
124
    eNB->pdsch_config_dedicated->p_a  = dBm3; // 4 = 0dB
125
    ((eNB->frame_parms).pdsch_config_common).p_b = 1;
126
    UE->pdsch_config_dedicated->p_a  = dBm3; // 4 = 0dB
127
    ((UE->frame_parms).pdsch_config_common).p_b = 1;
Raymond Knopp's avatar
Raymond Knopp committed
128
129
  }

130
  UE->perfect_ce = perfect_ce;
Raymond Knopp's avatar
Raymond Knopp committed
131
132
133
134
135

  printf("Done lte_param_init\n");


}