d8bd8592afc49761a69cac49589e540c7385c922
[o-du/phy.git] / fhi_lib / app / gen_test.m
1 %/******************************************************************************
2 %*
3 %*   Copyright (c) 2019 Intel.
4 %*
5 %*   Licensed under the Apache License, Version 2.0 (the "License");
6 %*   you may not use this file except in compliance with the License.
7 %*   You may obtain a copy of the License at
8 %*
9 %*       http://www.apache.org/licenses/LICENSE-2.0
10 %*
11 %*   Unless required by applicable law or agreed to in writing, software
12 %*   distributed under the License is distributed on an "AS IS" BASIS,
13 %*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 %*   See the License for the specific language governing permissions and
15 %*   limitations under the License.
16 %*
17 %*******************************************************************************/
18
19 close all;
20 clear all;
21
22 %select mu and bw to generate test files
23 sub6=false;  %false
24 mu=3; % 0,1, or 3
25 bw=100; %5,10,20,100 MHz
26
27 nSlots=160; % any 40 and 160
28
29      %  5MHz    10MHz   15MHz   20 MHz  25 MHz  30 MHz  40 MHz  50MHz   60 MHz  70 MHz  80 MHz   90 MHz  100 MHz
30 nNumRbsPerSymF1 = ...
31 [
32      %  5MHz    10MHz   15MHz   20 MHz  25 MHz  30 MHz  40 MHz  50MHz   60 MHz  70 MHz  80 MHz   90 MHz  100 MHz
33         [25,    52,     79,     106,    133,    160,    216,    270,    0,         0,      0,      0,      0]         % Numerology 0 (15KHz)
34         [11,    24,     38,     51,     65,     78,     106,    133,    162,       0,    217,    245,    273]         % Numerology 1 (30KHz)
35         [0,     11,     18,     24,     31,     38,     51,     65,     79,        0,    107,    121,    135]         % Numerology 2 (60KHz)
36 ];
37
38 nNumRbsPerSymF2 = ...
39 [
40     %  50Mhz  100MHz  200MHz   400MHz
41         [66,    132,    264,     0]        % Numerology 2 (60KHz)
42         [32,    66,     132,     264]      % Numerology 3 (120KHz)
43 ];
44
45 if sub6
46     disp('Sub6')
47     if mu < 3
48         nNumerology = mu+1;
49         switch (bw)
50             case {5}
51                 numRBs = nNumRbsPerSymF1(nNumerology,0+1);
52             case {10}
53                 numRBs = nNumRbsPerSymF1(nNumerology,1+1);
54             case {15}
55                 numRBs = nNumRbsPerSymF1(nNumerology,2+1);
56             case {20}
57                 numRBs = nNumRbsPerSymF1(nNumerology,3+1);
58             case {25}
59                 numRBs = nNumRbsPerSymF1(nNumerology,4+1);
60             case {30}
61                 numRBs = nNumRbsPerSymF1(nNumerology,5+1);
62             case {40}
63                 numRBs = nNumRbsPerSymF1(nNumerology,6+1);
64             case {50}
65                 numRBs = nNumRbsPerSymF1(nNumerology,7+1);
66             case {60}
67                 numRBs = nNumRbsPerSymF1(nNumerology,8+1);
68             case {70}
69                 numRBs = nNumRbsPerSymF1(nNumerology,9+1);
70             case {80}
71                 numRBs = nNumRbsPerSymF1(nNumerology,10+1);
72             case {90}
73                 numRBs = nNumRbsPerSymF1(nNumerology,11+1);
74             case {100}
75                 numRBs = nNumRbsPerSymF1(nNumerology,12+1);
76             otherwise
77                 disp('Unknown BW && mu')
78         end
79     end
80 else
81     disp('mmWave')
82     if  (mu >=2) && (mu <= 3)
83         nNumerology = mu;
84         switch (bw)
85             case {50}
86                 numRBs = nNumRbsPerSymF2(nNumerology-1,0+1);
87             case {100}
88                 numRBs = nNumRbsPerSymF2(nNumerology-1,1+1);
89             case {200}
90                 numRBs = nNumRbsPerSymF2(nNumerology-1,2+1);
91             case {400}
92                 numRBs = nNumRbsPerSymF2(nNumerology-1,3+1);
93             otherwise
94                 disp('Unknown BW && mu')
95         end
96     end
97 end
98
99 if numRBs ==0
100     disp('Incorrect Numerology and BW combination.')
101     return
102 end
103
104 bw
105 numRBs
106 nSlots
107
108 %use file as input
109 %ifft_in = load('ifft_in.txt')
110
111 %gen IQs
112 ifft_in = [[1:1:(numRBs*12)]', [1:1:(numRBs*12)]'];
113
114 ant_c = ifft_in;
115 for (i=1:1:nSlots*14-1)
116     ifft_in_1 = ifft_in + i;
117     ant_c = [ant_c; ifft_in_1];
118 end
119
120 ant0=ant_c;
121 ant1=ant_c*10;
122 ant2=ant_c*20;
123 ant3=ant_c*30;
124 ant4=ant_c*40;
125 ant5=ant_c*50;
126 ant6=ant_c*60;
127 ant7=ant_c*70;
128 ant8=ant_c*80;
129 ant9=ant_c*90;
130 ant10=ant_c*100;
131 ant11=ant_c*110;
132 ant12=ant_c*120;
133 ant13=ant_c*130;
134 ant14=ant_c*140;
135 ant15=ant_c*150;
136
137
138 ant0_16=int16(ant0.');
139 fileID = fopen('ant_0.bin','w');
140 fwrite(fileID,ant0_16, 'int16');
141 fclose(fileID);
142
143 ant1_16=int16(ant1.');
144 fileID = fopen('ant_1.bin','w');
145 fwrite(fileID,ant1_16, 'int16');
146 fclose(fileID);
147
148 ant2_16=int16(ant2.');
149 fileID = fopen('ant_2.bin','w');
150 fwrite(fileID,ant2_16, 'int16');
151 fclose(fileID);
152
153 ant3_16=int16(ant3.');
154 fileID = fopen('ant_3.bin','w');
155 fwrite(fileID,ant3_16, 'int16');
156 fclose(fileID);
157
158 ant4_16=int16(ant4.');
159 fileID = fopen('ant_4.bin','w');
160 fwrite(fileID,ant4_16, 'int16');
161 fclose(fileID);
162
163 ant5_16=int16(ant5.');
164 fileID = fopen('ant_5.bin','w');
165 fwrite(fileID,ant5_16, 'int16');
166 fclose(fileID);
167
168 ant6_16=int16(ant6.');
169 fileID = fopen('ant_6.bin','w');
170 fwrite(fileID,ant6_16, 'int16');
171 fclose(fileID);
172
173 ant7_16=int16(ant7.');
174 fileID = fopen('ant_7.bin','w');
175 fwrite(fileID,ant7_16, 'int16');
176 fclose(fileID);
177
178 ant8_16=int16(ant8.');
179 fileID = fopen('ant_8.bin','w');
180 fwrite(fileID,ant8_16, 'int16');
181 fclose(fileID);
182
183 ant9_16=int16(ant9.');
184 fileID = fopen('ant_9.bin','w');
185 fwrite(fileID,ant9_16, 'int16');
186 fclose(fileID);
187
188 ant10_16=int16(ant10.');
189 fileID = fopen('ant_10.bin','w');
190 fwrite(fileID,ant10_16, 'int16');
191 fclose(fileID);
192
193 ant11_16=int16(ant11.');
194 fileID = fopen('ant_11.bin','w');
195 fwrite(fileID,ant11_16, 'int16');
196 fclose(fileID);
197
198 ant12_16=int16(ant12.');
199 fileID = fopen('ant_12.bin','w');
200 fwrite(fileID,ant12_16, 'int16');
201 fclose(fileID);
202
203 ant13_16=int16(ant13.');
204 fileID = fopen('ant_13.bin','w');
205 fwrite(fileID,ant13_16, 'int16');
206 fclose(fileID);
207
208 ant14_16=int16(ant14.');
209 fileID = fopen('ant_14.bin','w');
210 fwrite(fileID,ant14_16, 'int16');
211 fclose(fileID);
212
213 ant15_16=int16(ant15.');
214 fileID = fopen('ant_15.bin','w');
215 fwrite(fileID,ant15_16, 'int16');
216 fclose(fileID);