o-du/phy
Intel O-RAN/X-RAN Generated Doxygen Documentation
gen_test.m
Go to the documentation of this file.
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %
3 % <COPYRIGHT_TAG>
4 %
5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 
7 %This script was tested with GNU Octave, version 3.8.2 or Matlab 9.2.0.538062 (R2017a)
8 
9 close all;
10 clear all;
11 
12  % 5MHz 10MHz 15MHz 20 MHz 25 MHz 30 MHz 40 MHz 50MHz 60 MHz 70 MHz 80 MHz 90 MHz 100 MHz
14 [
15  % 5MHz 10MHz 15MHz 20 MHz 25 MHz 30 MHz 40 MHz 50MHz 60 MHz 70 MHz 80 MHz 90 MHz 100 MHz
16  [25, 52, 79, 106, 133, 160, 216, 270, 0, 0, 0, 0, 0] % Numerology 0 (15KHz)
17  [11, 24, 38, 51, 65, 78, 106, 133, 162, 0, 217, 245, 273] % Numerology 1 (30KHz)
18  [0, 11, 18, 24, 31, 38, 51, 65, 79, 0, 107, 121, 135] % Numerology 2 (60KHz)
19 ];
20 
22 [
23  % 50Mhz 100MHz 200MHz 400MHz
24  [66, 132, 264, 0] % Numerology 2 (60KHz)
25  [32, 66, 132, 264] % Numerology 3 (120KHz)
26 ];
27 
28 % total number of tests
30 sub6_all = ...
31  [
32  true, true, true, true, false, true,
33  ]
34 
35 mu_all = ...
36  [
37  0, 0, 0, 1, 3, 1
38  ]
39 
40 bw_all = ...
41  [
42  5, 10, 20, 100, 100, 100
43  ]
44 
45 ant_num_all = ...
46  [
47  4, 4, 4, 4, 4, 8
48  ]
49 
50 bfw_gen_all = ...
51  [
52  false, false, false, false, false, true
53  ]
54 
55 trx_all = ...
56  [
57  32, 32, 32, 32, 32, 32
58  ]
60  [
61  "./usecase/mu0_5mhz/";
62  "./usecase/mu0_10mhz/";
63  "./usecase/mu0_20mhz/";
64  "./usecase/mu1_100mhz/";
65  "./usecase/mu3_100mhz/";
66  "./usecase/cat_b/mu1_100mhz/";
67  ]
68 
70 
71 nSlots_all = ...
72  [
73  40,40,40,40,40,10
74  ]
75 
76 %select mu and bw to generate test files
77 for test_num =(1:1:tests_total)
78  test_num
79  sub6=sub6_all(test_num) %false
80  mu=mu_all(test_num) % 0,1, or 3
81  bw=bw_all(test_num) %5,10,20,100 MHz
82  ant_num = ant_num_all(test_num)
83  bfw_gen=bfw_gen_all(test_num)
84  trx = trx_all(test_num)
86  path_to_usecase = path_to_usecase_all(test_num)
87 
88  nSlots=nSlots_all(test_num) % any 40 and 160
89 
90  if sub6
91  disp('Sub6')
92  if mu < 3
93  nNumerology = mu+1;
95  case {5}
96  numRBs = nNumRbsPerSymF1(nNumerology,0+1);
97  case {10}
98  numRBs = nNumRbsPerSymF1(nNumerology,1+1);
99  case {15}
100  numRBs = nNumRbsPerSymF1(nNumerology,2+1);
101  case {20}
102  numRBs = nNumRbsPerSymF1(nNumerology,3+1);
103  case {25}
104  numRBs = nNumRbsPerSymF1(nNumerology,4+1);
105  case {30}
106  numRBs = nNumRbsPerSymF1(nNumerology,5+1);
107  case {40}
108  numRBs = nNumRbsPerSymF1(nNumerology,6+1);
109  case {50}
110  numRBs = nNumRbsPerSymF1(nNumerology,7+1);
111  case {60}
112  numRBs = nNumRbsPerSymF1(nNumerology,8+1);
113  case {70}
114  numRBs = nNumRbsPerSymF1(nNumerology,9+1);
115  case {80}
116  numRBs = nNumRbsPerSymF1(nNumerology,10+1);
117  case {90}
118  numRBs = nNumRbsPerSymF1(nNumerology,11+1);
119  case {100}
120  numRBs = nNumRbsPerSymF1(nNumerology,12+1);
121  otherwise
122  disp('Unknown BW && mu')
123  end
124  end
125  else
126  disp('mmWave')
127  if (mu >=2) && (mu <= 3)
128  nNumerology = mu;
129  switch (bw)
130  case {50}
131  numRBs = nNumRbsPerSymF2(nNumerology-1,0+1);
132  case {100}
133  numRBs = nNumRbsPerSymF2(nNumerology-1,1+1);
134  case {200}
135  numRBs = nNumRbsPerSymF2(nNumerology-1,2+1);
136  case {400}
137  numRBs = nNumRbsPerSymF2(nNumerology-1,3+1);
138  otherwise
139  disp('Unknown BW && mu')
140  end
141  end
142  end
143 
144  if numRBs ==0
145  disp('Incorrect Numerology and BW combination.')
146  return
147  end
148 
149  bw
150  numRBs
151  nSlots
152 
153  %use file as input
154  %ifft_in = load('ifft_in.txt')
155 
156  %gen IQs
157  ifft_in = [[1:1:(numRBs*12)]', [1:1:(numRBs*12)]'];
158 
159  ant_c = ifft_in;
160  for (i=1:1:nSlots*14-1)
161  ifft_in_1 = ifft_in + i;
162  ant_c = [ant_c; ifft_in_1];
163  end
164 
165  %write files for IQ samples
166  for ant = 1:1:ant_num
167  antX=ant_c*(ant*10);
168  antX_16=int16(antX.');
169  file_name = strcat(path_to_usecase,"ant_", num2str(ant-1),".bin");
170  disp(file_name)
171  fileID = fopen(file_name,'w');
172  fwrite(fileID, antX_16, 'int16');
173  fclose(fileID);
174  end
175 
176  if bfw_gen
177  disp('Generate BF Weights per RB')
178 
179  %seed to make it repeatable
180  rand('seed',47)
181 
182  %random channel matrix for single sym on syngle RB
183  H = (rand(trx,ant_num) + 1j*rand(trx,ant_num));
184 
185  %calculate weights
186  % W_dl = H^*(H^TH^*)^-1
187  % W_ul = ((H^H*H)^-1)H^H
188  % where H^* - conjugate
189  % H^T - transpose
190  % H^H - conjugate transpose
191  W_dl = conj(H)*(transpose(H)*conj(H))^-1; %weights for DL
192  W_ul = ((ctranspose(H)*H)^-1)*ctranspose(H); %weights for UL
193 
194  W_ul = W_ul.';
195 
196  for ant = 1:1:ant_num
197  %DL
198 
199  bfw_per_sym = [];
200  % adjust channel per each RB
201  for iPrb = 1:1:numRBs
202  bfw_per_sym = [ bfw_per_sym, [real((W_dl(:, ant).'))*iPrb; imag((W_dl(:, ant).'))*iPrb]];
203  end
204 
206  %reuse channel for all symbols
207  for (slot_idx=1:1:nSlots*14)
209  end
210 
211  bfw_all_slots_int = int16(bfw_all_slots./max(max(abs((bfw_all_slots.')))).*2^15);
212 
213  %write files for IQ samples
214  antX_16=bfw_all_slots_int.';
215  file_name = strcat(path_to_usecase,"dl_bfw_ue_", num2str(ant-1),".bin");
216  disp(file_name)
217  fileID = fopen(file_name,'w');
218  fwrite(fileID,antX_16, 'int16');
219  fclose(fileID);
220 
221  %UL
223  % adjust channel per each RB
224  for iPrb = 1:1:numRBs
225  bfw_per_sym = [ bfw_per_sym, [real((W_ul(:, ant).'))*iPrb; imag((W_ul(:, ant).'))*iPrb]];
226  end
227 
228  bfw_all_slots = [];
229  %reuse channel for all symbols
230  for (slot_idx=1:1:nSlots*14)
231  bfw_all_slots = [bfw_all_slots, bfw_per_sym];
232  end
233 
234  bfw_all_slots_int = int16(bfw_all_slots./max(max(abs((bfw_all_slots.')))).*2^15);
235 
236  %write files for IQ samples
237  antX_16=bfw_all_slots_int.';
238  file_name = strcat(path_to_usecase,"ul_bfw_ue_", num2str(ant-1),".bin");
239  disp(file_name)
240  fileID = fopen(file_name,'w');
241  fwrite(fileID,antX_16, 'int16');
242  fclose(fileID);
243  end
244  end
245 end
end bfw_all_slots
Definition: gen_test.m:205
file_name
Definition: gen_test.m:169
fclose(fileID)
or bw
Definition: gen_test.m:81
end write files for IQ samples for ant
Definition: gen_test.m:166
MHz MHz MHz MHz MHz MHz MHz MHz MHz nNumRbsPerSymF1
Definition: gen_test.m:13
ant_c
Definition: gen_test.m:159
otherwise disp('Unknown BW &&mu') end end else disp('mmWave') if(mu >
antX_16
Definition: gen_test.m:168
nNumRbsPerSymF2
Definition: gen_test.m:21
fwrite(fileID, antX_16, 'int16')
ifft_in_1
Definition: gen_test.m:162
numRBs
Definition: gen_test.m:96
UL bfw_per_sym
Definition: gen_test.m:222
< COPYRIGHT_TAG > This script was tested with GNU version or Matlab(R2017a) close all
case
Definition: gen_test.m:97
calculate weights W_dl
Definition: gen_test.m:186
total number of tests tests_total
Definition: gen_test.m:29
adjust channel per each RB for iPrb
Definition: gen_test.m:201
or MHz ant_num
Definition: gen_test.m:82
end bfw_all_slots_int
Definition: gen_test.m:211
switch(bw) case
Definition: gen_test.m:94
< COPYRIGHT_TAG > This script was tested with GNU Octave
Definition: gen_test.m:7
clear all
Definition: gen_test.m:10
path_to_usecase_all
Definition: gen_test.m:69