beamforming.c 6.21 KB
Newer Older
Cedric Roux's avatar
Cedric Roux committed
1
2
3
4
5
/*
 * 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
Cedric Roux's avatar
Cedric Roux committed
6
 * the OAI Public License, Version 1.1  (the "License"); you may not use this file
Cedric Roux's avatar
Cedric Roux committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 * 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
 */
Xiwen JIANG's avatar
Xiwen JIANG committed
21

22
/*! \file PHY/MODULATION/beamforming.c
Xiwen JIANG's avatar
Xiwen JIANG committed
23
 * \brief 
24
25
 * \author X. JIANG, F. Kaltenberger, R. KNOPP
 * \date 2016
Xiwen JIANG's avatar
Xiwen JIANG committed
26
27
 * \version 0.1
 * \company Eurecom
28
 * \email: xiwen.jiang@eurecom.fr,florian.kaltenberger@eurecom.fr,raymond.knopp@eurecom.fr
Xiwen JIANG's avatar
Xiwen JIANG committed
29
30
31
 * \note
 * \warning
 */
32
33
34
35
36
37
 
 /*! \function beam_precoding_one_eNB
 * \brief Create and Implementation of beamforming in one eNB
 * \author TY Hsu, SY Yeh(fdragon), TH Wang(Judy)
 * \date 2018
 * \version 0.1
38
 * \company ISIP@NCTU and Eurecom
39
40
41
42
 * \email: tyhsu@cs.nctu.edu.tw,fdragon.cs96g@g2.nctu.edu.tw,Tsu-Han.Wang@eurecom.fr
 * \note
 * \warning
 */
43

44
 
45
46
47
48
49
#include "PHY/defs_common.h"
#include "PHY/defs_eNB.h"
#include "PHY/phy_extern.h"
#include "PHY/CODING/coding_defs.h"
#include "PHY/CODING/coding_extern.h"
Xiwen JIANG's avatar
Xiwen JIANG committed
50
#include "PHY/CODING/lte_interleaver_inline.h"
51
52
#include "PHY/LTE_TRANSPORT/transport_eNB.h"
#include "modulation_eNB.h"
53
#include "nr_modulation.h"
54
#include "common/utils/LOG/vcd_signal_dumper.h"
Xiwen JIANG's avatar
Xiwen JIANG committed
55

56
57
int beam_precoding(int32_t **txdataF,
	           int32_t **txdataF_BF,
58
		   int subframe,
59
                   LTE_DL_FRAME_PARMS *frame_parms,
60
                   int32_t **beam_weights[NUMBER_OF_eNB_MAX+1][15],
61
                   int symbol,
62
		   int aa,
63
64
		   int p,
                   int l1_id)
Xiwen JIANG's avatar
Xiwen JIANG committed
65
{
66
67
68
  int rb_offset_neg0 = frame_parms->ofdm_symbol_size - (6*frame_parms->N_RB_DL);
  int rb_offset_neg  = (subframe*frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti) + rb_offset_neg0;
  int rb_offset_pos  = (subframe*frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti);
69

Xiwen JIANG's avatar
Xiwen JIANG committed
70

71
  multadd_cpx_vector((int16_t*)&txdataF[p][rb_offset_neg+(symbol*frame_parms->ofdm_symbol_size)],
72
		     (int16_t*)&beam_weights[l1_id][p][aa][rb_offset_neg0], 
73
	             (int16_t*)&txdataF_BF[aa][rb_offset_neg0+(symbol*frame_parms->ofdm_symbol_size)], 
74
75
76
		     0, 
                     6*frame_parms->N_RB_DL, 
		     15);
77
  multadd_cpx_vector((int16_t*)&txdataF[p][rb_offset_pos+(symbol*frame_parms->ofdm_symbol_size)],
78
                     (int16_t*)&beam_weights[l1_id][p][aa][0], 
79
80
81
82
                     (int16_t*)&txdataF_BF[aa][(symbol*frame_parms->ofdm_symbol_size)], 
                     0, 
                     7*frame_parms->N_RB_DL, // to allow for extra RE at the end, 12 useless multipy-adds (first one at DC and 11 at end)
                     15);
Xiwen JIANG's avatar
Xiwen JIANG committed
83

84
      return 0;
Xiwen JIANG's avatar
Xiwen JIANG committed
85
}
86

87

88
89
int beam_precoding_one_eNB(int32_t **txdataF,
                           int32_t **txdataF_BF,
90
                           int32_t **beam_weights[NUMBER_OF_eNB_MAX+1][15],
91
92
93
94
95
96
						   int subframe,
						   int nb_antenna_ports,
						   int nb_tx, // total physical antenna
						   LTE_DL_FRAME_PARMS *frame_parms
						   )
{
knopp's avatar
knopp committed
97
  int p, symbol, aa; // loop index
98
99
100
101
102
103
104
  int re_offset;
  int ofdm_symbol_size     = frame_parms->ofdm_symbol_size;
  int symbols_per_tti      = frame_parms->symbols_per_tti;
  int nb_antenna_ports_eNB = frame_parms->nb_antenna_ports_eNB; // logic antenna ports
  
  
  re_offset = ofdm_symbol_size*symbols_per_tti*subframe;
knopp's avatar
knopp committed
105
  
106
107
108
109
110
  
  // txdataF_BF[aa][re] = sum(beam_weghts[p][aa][re]*txdataF[p][re]), p=0~nb_antenna_ports-1
  // real part and image part need to compute separately
  
  for (aa=0; aa<nb_tx; aa++) {
knopp's avatar
knopp committed
111
112
113
114
    memset(txdataF_BF[aa],0,sizeof(int32_t)*(ofdm_symbol_size*symbols_per_tti));
    for(p=0;p<nb_antenna_ports;p++){
      if (p<nb_antenna_ports_eNB || p==5){
	for (symbol=0; symbol<symbols_per_tti; symbol++){
115
	  
knopp's avatar
knopp committed
116
117
118
119
120
121
	  multadd_cpx_vector((int16_t*)&txdataF[p][symbol*ofdm_symbol_size+re_offset],
			     (int16_t*)beam_weights[0][p][aa], 
			     (int16_t*)&txdataF_BF[aa][symbol*ofdm_symbol_size], 
			     0, 
			     ofdm_symbol_size, 
			     15);
122
123
	  
	  
knopp's avatar
knopp committed
124
125
126
127
128
129
130
131
132
133
134
	  /*
	    for (re=0; re<ofdm_symbol_size; re++){
	    // direct
	    ((int16_t*)&txdataF_BF[aa][re])[0] += (int16_t)((((int16_t*)&txdataF[p][re+symbol*ofdm_symbol_size+re_offset])[0]*((int16_t*)&beam_weights[p][aa][re])[0])>>15);
	    ((int16_t*)&txdataF_BF[aa][re])[0] -= (int16_t)((((int16_t*)&txdataF[p][re+symbol*ofdm_symbol_size+re_offset])[1]*((int16_t*)&beam_weights[p][aa][re])[1])>>15);
	    ((int16_t*)&txdataF_BF[aa][re])[1] += (int16_t)((((int16_t*)&txdataF[p][re+symbol*ofdm_symbol_size+re_offset])[0]*((int16_t*)&beam_weights[p][aa][re])[1])>>15);
	    ((int16_t*)&txdataF_BF[aa][re])[1] += (int16_t)((((int16_t*)&txdataF[p][re+symbol*ofdm_symbol_size+re_offset])[1]*((int16_t*)&beam_weights[p][aa][re])[0])>>15);
	    }
	  */
	}
      }
135
    }
Xiwen JIANG's avatar
Xiwen JIANG committed
136
  }
137
  return 0;
Xiwen JIANG's avatar
Xiwen JIANG committed
138
}
139
140
141
142
143
144
145
146


int nr_beam_precoding(int32_t **txdataF,
	              int32_t **txdataF_BF,
                      NR_DL_FRAME_PARMS *frame_parms,
	              int32_t ***beam_weights,
                      int slot,
                      int symbol,
147
                      int aa,
148
149
                      int nb_antenna_ports,
                      int offset)
150
151
152
153
{


  uint8_t p;
154

155
  // clear txdata_BF[aa][re] for each call of ue_spec_beamforming
Florian Kaltenberger's avatar
Florian Kaltenberger committed
156
  memset(&txdataF_BF[aa][symbol*frame_parms->ofdm_symbol_size],0,sizeof(int32_t)*(frame_parms->ofdm_symbol_size));
157
158

  for (p=0; p<nb_antenna_ports; p++) {
159
160
    //if ((frame_parms->L_ssb >> (63-p)) & 0x01)  {
      multadd_cpx_vector((int16_t*)&txdataF[p][(symbol*frame_parms->ofdm_symbol_size)+offset],
161
162
163
164
165
			 (int16_t*)beam_weights[p][aa], 
			 (int16_t*)&txdataF_BF[aa][symbol*frame_parms->ofdm_symbol_size], 
			 0, 
			 frame_parms->ofdm_symbol_size, 
			 15);
166
    //}
167
  }
168
  return 0;
169
}