dlsch_llr_computation.c 439 KB
Newer Older
1
/*
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 * 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
 */
21
22

/*! \file PHY/LTE_TRANSPORT/dlsch_llr_computation.c
23
 * \brief Top-level routines for LLR computation of the PDSCH physical channel from 36-211, V8.6 2009-03
24
 * \author R. Knopp, F. Kaltenberger,A. Bhamri, S. Aubert, S. Wagner, X Jiang
25
26
27
28
29
30
31
 * \date 2011
 * \version 0.1
 * \company Eurecom
 * \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr,ankit.bhamri@eurecom.fr,sebastien.aubert@eurecom.fr, sebastian.wagner@eurecom.fr
 * \note
 * \warning
 */
32
33

#include "PHY/defs.h"
Elena Lukashova's avatar
Elena Lukashova committed
34
#include "PHY/TOOLS/defs.h"
35
36
37
#include "PHY/extern.h"
#include "defs.h"
#include "extern.h"
38
#include "PHY/sse_intrin.h"
39

40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
int16_t zero[8] __attribute__ ((aligned(16))) = {0,0,0,0,0,0,0,0};
int16_t ones[8] __attribute__ ((aligned(16))) = {0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff};
#if defined(__x86_64__) || defined(__i386__)
__m128i rho_rpi __attribute__ ((aligned(16)));
__m128i rho_rmi __attribute__ ((aligned(16)));
__m128i rho_rpi_1_1 __attribute__ ((aligned(16)));
__m128i rho_rpi_1_3 __attribute__ ((aligned(16)));
__m128i rho_rpi_1_5 __attribute__ ((aligned(16)));
__m128i rho_rpi_1_7 __attribute__ ((aligned(16)));
__m128i rho_rpi_3_1 __attribute__ ((aligned(16)));
__m128i rho_rpi_3_3 __attribute__ ((aligned(16)));
__m128i rho_rpi_3_5 __attribute__ ((aligned(16)));
__m128i rho_rpi_3_7 __attribute__ ((aligned(16)));
__m128i rho_rpi_5_1 __attribute__ ((aligned(16)));
__m128i rho_rpi_5_3 __attribute__ ((aligned(16)));
__m128i rho_rpi_5_5 __attribute__ ((aligned(16)));
__m128i rho_rpi_5_7 __attribute__ ((aligned(16)));
__m128i rho_rpi_7_1 __attribute__ ((aligned(16)));
__m128i rho_rpi_7_3 __attribute__ ((aligned(16)));
__m128i rho_rpi_7_5 __attribute__ ((aligned(16)));
__m128i rho_rpi_7_7 __attribute__ ((aligned(16)));
__m128i rho_rmi_1_1 __attribute__ ((aligned(16)));
__m128i rho_rmi_1_3 __attribute__ ((aligned(16)));
__m128i rho_rmi_1_5 __attribute__ ((aligned(16)));
__m128i rho_rmi_1_7 __attribute__ ((aligned(16)));
__m128i rho_rmi_3_1 __attribute__ ((aligned(16)));
__m128i rho_rmi_3_3 __attribute__ ((aligned(16)));
__m128i rho_rmi_3_5 __attribute__ ((aligned(16)));
__m128i rho_rmi_3_7 __attribute__ ((aligned(16)));
__m128i rho_rmi_5_1 __attribute__ ((aligned(16)));
__m128i rho_rmi_5_3 __attribute__ ((aligned(16)));
__m128i rho_rmi_5_5 __attribute__ ((aligned(16)));
__m128i rho_rmi_5_7 __attribute__ ((aligned(16)));
__m128i rho_rmi_7_1 __attribute__ ((aligned(16)));
__m128i rho_rmi_7_3 __attribute__ ((aligned(16)));
__m128i rho_rmi_7_5 __attribute__ ((aligned(16)));
__m128i rho_rmi_7_7 __attribute__ ((aligned(16)));

__m128i psi_r_m7_m7 __attribute__ ((aligned(16)));
__m128i psi_r_m7_m5 __attribute__ ((aligned(16)));
__m128i psi_r_m7_m3 __attribute__ ((aligned(16)));
__m128i psi_r_m7_m1 __attribute__ ((aligned(16)));
__m128i psi_r_m7_p1 __attribute__ ((aligned(16)));
__m128i psi_r_m7_p3 __attribute__ ((aligned(16)));
__m128i psi_r_m7_p5 __attribute__ ((aligned(16)));
__m128i psi_r_m7_p7 __attribute__ ((aligned(16)));
__m128i psi_r_m5_m7 __attribute__ ((aligned(16)));
__m128i psi_r_m5_m5 __attribute__ ((aligned(16)));
__m128i psi_r_m5_m3 __attribute__ ((aligned(16)));
__m128i psi_r_m5_m1 __attribute__ ((aligned(16)));
__m128i psi_r_m5_p1 __attribute__ ((aligned(16)));
__m128i psi_r_m5_p3 __attribute__ ((aligned(16)));
__m128i psi_r_m5_p5 __attribute__ ((aligned(16)));
__m128i psi_r_m5_p7 __attribute__ ((aligned(16)));
__m128i psi_r_m3_m7 __attribute__ ((aligned(16)));
__m128i psi_r_m3_m5 __attribute__ ((aligned(16)));
__m128i psi_r_m3_m3 __attribute__ ((aligned(16)));
__m128i psi_r_m3_m1 __attribute__ ((aligned(16)));
__m128i psi_r_m3_p1 __attribute__ ((aligned(16)));
__m128i psi_r_m3_p3 __attribute__ ((aligned(16)));
__m128i psi_r_m3_p5 __attribute__ ((aligned(16)));
__m128i psi_r_m3_p7 __attribute__ ((aligned(16)));
__m128i psi_r_m1_m7 __attribute__ ((aligned(16)));
__m128i psi_r_m1_m5 __attribute__ ((aligned(16)));
__m128i psi_r_m1_m3 __attribute__ ((aligned(16)));
__m128i psi_r_m1_m1 __attribute__ ((aligned(16)));
__m128i psi_r_m1_p1 __attribute__ ((aligned(16)));
__m128i psi_r_m1_p3 __attribute__ ((aligned(16)));
__m128i psi_r_m1_p5 __attribute__ ((aligned(16)));
__m128i psi_r_m1_p7 __attribute__ ((aligned(16)));
__m128i psi_r_p1_m7 __attribute__ ((aligned(16)));
__m128i psi_r_p1_m5 __attribute__ ((aligned(16)));
__m128i psi_r_p1_m3 __attribute__ ((aligned(16)));
__m128i psi_r_p1_m1 __attribute__ ((aligned(16)));
__m128i psi_r_p1_p1 __attribute__ ((aligned(16)));
__m128i psi_r_p1_p3 __attribute__ ((aligned(16)));
__m128i psi_r_p1_p5 __attribute__ ((aligned(16)));
__m128i psi_r_p1_p7 __attribute__ ((aligned(16)));
__m128i psi_r_p3_m7 __attribute__ ((aligned(16)));
__m128i psi_r_p3_m5 __attribute__ ((aligned(16)));
__m128i psi_r_p3_m3 __attribute__ ((aligned(16)));
__m128i psi_r_p3_m1 __attribute__ ((aligned(16)));
__m128i psi_r_p3_p1 __attribute__ ((aligned(16)));
__m128i psi_r_p3_p3 __attribute__ ((aligned(16)));
__m128i psi_r_p3_p5 __attribute__ ((aligned(16)));
__m128i psi_r_p3_p7 __attribute__ ((aligned(16)));
__m128i psi_r_p5_m7 __attribute__ ((aligned(16)));
__m128i psi_r_p5_m5 __attribute__ ((aligned(16)));
__m128i psi_r_p5_m3 __attribute__ ((aligned(16)));
__m128i psi_r_p5_m1 __attribute__ ((aligned(16)));
__m128i psi_r_p5_p1 __attribute__ ((aligned(16)));
__m128i psi_r_p5_p3 __attribute__ ((aligned(16)));
__m128i psi_r_p5_p5 __attribute__ ((aligned(16)));
__m128i psi_r_p5_p7 __attribute__ ((aligned(16)));
__m128i psi_r_p7_m7 __attribute__ ((aligned(16)));
__m128i psi_r_p7_m5 __attribute__ ((aligned(16)));
__m128i psi_r_p7_m3 __attribute__ ((aligned(16)));
__m128i psi_r_p7_m1 __attribute__ ((aligned(16)));
__m128i psi_r_p7_p1 __attribute__ ((aligned(16)));
__m128i psi_r_p7_p3 __attribute__ ((aligned(16)));
__m128i psi_r_p7_p5 __attribute__ ((aligned(16)));
__m128i psi_r_p7_p7 __attribute__ ((aligned(16)));

__m128i psi_i_m7_m7 __attribute__ ((aligned(16)));
__m128i psi_i_m7_m5 __attribute__ ((aligned(16)));
__m128i psi_i_m7_m3 __attribute__ ((aligned(16)));
__m128i psi_i_m7_m1 __attribute__ ((aligned(16)));
__m128i psi_i_m7_p1 __attribute__ ((aligned(16)));
__m128i psi_i_m7_p3 __attribute__ ((aligned(16)));
__m128i psi_i_m7_p5 __attribute__ ((aligned(16)));
__m128i psi_i_m7_p7 __attribute__ ((aligned(16)));
__m128i psi_i_m5_m7 __attribute__ ((aligned(16)));
__m128i psi_i_m5_m5 __attribute__ ((aligned(16)));
__m128i psi_i_m5_m3 __attribute__ ((aligned(16)));
__m128i psi_i_m5_m1 __attribute__ ((aligned(16)));
__m128i psi_i_m5_p1 __attribute__ ((aligned(16)));
__m128i psi_i_m5_p3 __attribute__ ((aligned(16)));
__m128i psi_i_m5_p5 __attribute__ ((aligned(16)));
__m128i psi_i_m5_p7 __attribute__ ((aligned(16)));
__m128i psi_i_m3_m7 __attribute__ ((aligned(16)));
__m128i psi_i_m3_m5 __attribute__ ((aligned(16)));
__m128i psi_i_m3_m3 __attribute__ ((aligned(16)));
__m128i psi_i_m3_m1 __attribute__ ((aligned(16)));
__m128i psi_i_m3_p1 __attribute__ ((aligned(16)));
__m128i psi_i_m3_p3 __attribute__ ((aligned(16)));
__m128i psi_i_m3_p5 __attribute__ ((aligned(16)));
__m128i psi_i_m3_p7 __attribute__ ((aligned(16)));
__m128i psi_i_m1_m7 __attribute__ ((aligned(16)));
__m128i psi_i_m1_m5 __attribute__ ((aligned(16)));
__m128i psi_i_m1_m3 __attribute__ ((aligned(16)));
__m128i psi_i_m1_m1 __attribute__ ((aligned(16)));
__m128i psi_i_m1_p1 __attribute__ ((aligned(16)));
__m128i psi_i_m1_p3 __attribute__ ((aligned(16)));
__m128i psi_i_m1_p5 __attribute__ ((aligned(16)));
__m128i psi_i_m1_p7 __attribute__ ((aligned(16)));
__m128i psi_i_p1_m7 __attribute__ ((aligned(16)));
__m128i psi_i_p1_m5 __attribute__ ((aligned(16)));
__m128i psi_i_p1_m3 __attribute__ ((aligned(16)));
__m128i psi_i_p1_m1 __attribute__ ((aligned(16)));
__m128i psi_i_p1_p1 __attribute__ ((aligned(16)));
__m128i psi_i_p1_p3 __attribute__ ((aligned(16)));
__m128i psi_i_p1_p5 __attribute__ ((aligned(16)));
__m128i psi_i_p1_p7 __attribute__ ((aligned(16)));
__m128i psi_i_p3_m7 __attribute__ ((aligned(16)));
__m128i psi_i_p3_m5 __attribute__ ((aligned(16)));
__m128i psi_i_p3_m3 __attribute__ ((aligned(16)));
__m128i psi_i_p3_m1 __attribute__ ((aligned(16)));
__m128i psi_i_p3_p1 __attribute__ ((aligned(16)));
__m128i psi_i_p3_p3 __attribute__ ((aligned(16)));
__m128i psi_i_p3_p5 __attribute__ ((aligned(16)));
__m128i psi_i_p3_p7 __attribute__ ((aligned(16)));
__m128i psi_i_p5_m7 __attribute__ ((aligned(16)));
__m128i psi_i_p5_m5 __attribute__ ((aligned(16)));
__m128i psi_i_p5_m3 __attribute__ ((aligned(16)));
__m128i psi_i_p5_m1 __attribute__ ((aligned(16)));
__m128i psi_i_p5_p1 __attribute__ ((aligned(16)));
__m128i psi_i_p5_p3 __attribute__ ((aligned(16)));
__m128i psi_i_p5_p5 __attribute__ ((aligned(16)));
__m128i psi_i_p5_p7 __attribute__ ((aligned(16)));
__m128i psi_i_p7_m7 __attribute__ ((aligned(16)));
__m128i psi_i_p7_m5 __attribute__ ((aligned(16)));
__m128i psi_i_p7_m3 __attribute__ ((aligned(16)));
__m128i psi_i_p7_m1 __attribute__ ((aligned(16)));
__m128i psi_i_p7_p1 __attribute__ ((aligned(16)));
__m128i psi_i_p7_p3 __attribute__ ((aligned(16)));
__m128i psi_i_p7_p5 __attribute__ ((aligned(16)));
__m128i psi_i_p7_p7 __attribute__ ((aligned(16)));

__m128i a_r_m7_m7 __attribute__ ((aligned(16)));
__m128i a_r_m7_m5 __attribute__ ((aligned(16)));
__m128i a_r_m7_m3 __attribute__ ((aligned(16)));
__m128i a_r_m7_m1 __attribute__ ((aligned(16)));
__m128i a_r_m7_p1 __attribute__ ((aligned(16)));
__m128i a_r_m7_p3 __attribute__ ((aligned(16)));
__m128i a_r_m7_p5 __attribute__ ((aligned(16)));
__m128i a_r_m7_p7 __attribute__ ((aligned(16)));
__m128i a_r_m5_m7 __attribute__ ((aligned(16)));
__m128i a_r_m5_m5 __attribute__ ((aligned(16)));
__m128i a_r_m5_m3 __attribute__ ((aligned(16)));
__m128i a_r_m5_m1 __attribute__ ((aligned(16)));
__m128i a_r_m5_p1 __attribute__ ((aligned(16)));
__m128i a_r_m5_p3 __attribute__ ((aligned(16)));
__m128i a_r_m5_p5 __attribute__ ((aligned(16)));
__m128i a_r_m5_p7 __attribute__ ((aligned(16)));
__m128i a_r_m3_m7 __attribute__ ((aligned(16)));
__m128i a_r_m3_m5 __attribute__ ((aligned(16)));
__m128i a_r_m3_m3 __attribute__ ((aligned(16)));
__m128i a_r_m3_m1 __attribute__ ((aligned(16)));
__m128i a_r_m3_p1 __attribute__ ((aligned(16)));
__m128i a_r_m3_p3 __attribute__ ((aligned(16)));
__m128i a_r_m3_p5 __attribute__ ((aligned(16)));
__m128i a_r_m3_p7 __attribute__ ((aligned(16)));
__m128i a_r_m1_m7 __attribute__ ((aligned(16)));
__m128i a_r_m1_m5 __attribute__ ((aligned(16)));
__m128i a_r_m1_m3 __attribute__ ((aligned(16)));
__m128i a_r_m1_m1 __attribute__ ((aligned(16)));
__m128i a_r_m1_p1 __attribute__ ((aligned(16)));
__m128i a_r_m1_p3 __attribute__ ((aligned(16)));
__m128i a_r_m1_p5 __attribute__ ((aligned(16)));
__m128i a_r_m1_p7 __attribute__ ((aligned(16)));
__m128i a_r_p1_m7 __attribute__ ((aligned(16)));
__m128i a_r_p1_m5 __attribute__ ((aligned(16)));
__m128i a_r_p1_m3 __attribute__ ((aligned(16)));
__m128i a_r_p1_m1 __attribute__ ((aligned(16)));
__m128i a_r_p1_p1 __attribute__ ((aligned(16)));
__m128i a_r_p1_p3 __attribute__ ((aligned(16)));
__m128i a_r_p1_p5 __attribute__ ((aligned(16)));
__m128i a_r_p1_p7 __attribute__ ((aligned(16)));
__m128i a_r_p3_m7 __attribute__ ((aligned(16)));
__m128i a_r_p3_m5 __attribute__ ((aligned(16)));
__m128i a_r_p3_m3 __attribute__ ((aligned(16)));
__m128i a_r_p3_m1 __attribute__ ((aligned(16)));
__m128i a_r_p3_p1 __attribute__ ((aligned(16)));
__m128i a_r_p3_p3 __attribute__ ((aligned(16)));
__m128i a_r_p3_p5 __attribute__ ((aligned(16)));
__m128i a_r_p3_p7 __attribute__ ((aligned(16)));
__m128i a_r_p5_m7 __attribute__ ((aligned(16)));
__m128i a_r_p5_m5 __attribute__ ((aligned(16)));
__m128i a_r_p5_m3 __attribute__ ((aligned(16)));
__m128i a_r_p5_m1 __attribute__ ((aligned(16)));
__m128i a_r_p5_p1 __attribute__ ((aligned(16)));
__m128i a_r_p5_p3 __attribute__ ((aligned(16)));
__m128i a_r_p5_p5 __attribute__ ((aligned(16)));
__m128i a_r_p5_p7 __attribute__ ((aligned(16)));
__m128i a_r_p7_m7 __attribute__ ((aligned(16)));
__m128i a_r_p7_m5 __attribute__ ((aligned(16)));
__m128i a_r_p7_m3 __attribute__ ((aligned(16)));
__m128i a_r_p7_m1 __attribute__ ((aligned(16)));
__m128i a_r_p7_p1 __attribute__ ((aligned(16)));
__m128i a_r_p7_p3 __attribute__ ((aligned(16)));
__m128i a_r_p7_p5 __attribute__ ((aligned(16)));
__m128i a_r_p7_p7 __attribute__ ((aligned(16)));

__m128i a_i_m7_m7 __attribute__ ((aligned(16)));
__m128i a_i_m7_m5 __attribute__ ((aligned(16)));
__m128i a_i_m7_m3 __attribute__ ((aligned(16)));
__m128i a_i_m7_m1 __attribute__ ((aligned(16)));
__m128i a_i_m7_p1 __attribute__ ((aligned(16)));
__m128i a_i_m7_p3 __attribute__ ((aligned(16)));
__m128i a_i_m7_p5 __attribute__ ((aligned(16)));
__m128i a_i_m7_p7 __attribute__ ((aligned(16)));
__m128i a_i_m5_m7 __attribute__ ((aligned(16)));
__m128i a_i_m5_m5 __attribute__ ((aligned(16)));
__m128i a_i_m5_m3 __attribute__ ((aligned(16)));
__m128i a_i_m5_m1 __attribute__ ((aligned(16)));
__m128i a_i_m5_p1 __attribute__ ((aligned(16)));
__m128i a_i_m5_p3 __attribute__ ((aligned(16)));
__m128i a_i_m5_p5 __attribute__ ((aligned(16)));
__m128i a_i_m5_p7 __attribute__ ((aligned(16)));
__m128i a_i_m3_m7 __attribute__ ((aligned(16)));
__m128i a_i_m3_m5 __attribute__ ((aligned(16)));
__m128i a_i_m3_m3 __attribute__ ((aligned(16)));
__m128i a_i_m3_m1 __attribute__ ((aligned(16)));
__m128i a_i_m3_p1 __attribute__ ((aligned(16)));
__m128i a_i_m3_p3 __attribute__ ((aligned(16)));
__m128i a_i_m3_p5 __attribute__ ((aligned(16)));
__m128i a_i_m3_p7 __attribute__ ((aligned(16)));
__m128i a_i_m1_m7 __attribute__ ((aligned(16)));
__m128i a_i_m1_m5 __attribute__ ((aligned(16)));
__m128i a_i_m1_m3 __attribute__ ((aligned(16)));
__m128i a_i_m1_m1 __attribute__ ((aligned(16)));
__m128i a_i_m1_p1 __attribute__ ((aligned(16)));
__m128i a_i_m1_p3 __attribute__ ((aligned(16)));
__m128i a_i_m1_p5 __attribute__ ((aligned(16)));
__m128i a_i_m1_p7 __attribute__ ((aligned(16)));
__m128i a_i_p1_m7 __attribute__ ((aligned(16)));
__m128i a_i_p1_m5 __attribute__ ((aligned(16)));
__m128i a_i_p1_m3 __attribute__ ((aligned(16)));
__m128i a_i_p1_m1 __attribute__ ((aligned(16)));
__m128i a_i_p1_p1 __attribute__ ((aligned(16)));
__m128i a_i_p1_p3 __attribute__ ((aligned(16)));
__m128i a_i_p1_p5 __attribute__ ((aligned(16)));
__m128i a_i_p1_p7 __attribute__ ((aligned(16)));
__m128i a_i_p3_m7 __attribute__ ((aligned(16)));
__m128i a_i_p3_m5 __attribute__ ((aligned(16)));
__m128i a_i_p3_m3 __attribute__ ((aligned(16)));
__m128i a_i_p3_m1 __attribute__ ((aligned(16)));
__m128i a_i_p3_p1 __attribute__ ((aligned(16)));
__m128i a_i_p3_p3 __attribute__ ((aligned(16)));
__m128i a_i_p3_p5 __attribute__ ((aligned(16)));
__m128i a_i_p3_p7 __attribute__ ((aligned(16)));
__m128i a_i_p5_m7 __attribute__ ((aligned(16)));
__m128i a_i_p5_m5 __attribute__ ((aligned(16)));
__m128i a_i_p5_m3 __attribute__ ((aligned(16)));
__m128i a_i_p5_m1 __attribute__ ((aligned(16)));
__m128i a_i_p5_p1 __attribute__ ((aligned(16)));
__m128i a_i_p5_p3 __attribute__ ((aligned(16)));
__m128i a_i_p5_p5 __attribute__ ((aligned(16)));
__m128i a_i_p5_p7 __attribute__ ((aligned(16)));
__m128i a_i_p7_m7 __attribute__ ((aligned(16)));
__m128i a_i_p7_m5 __attribute__ ((aligned(16)));
__m128i a_i_p7_m3 __attribute__ ((aligned(16)));
__m128i a_i_p7_m1 __attribute__ ((aligned(16)));
__m128i a_i_p7_p1 __attribute__ ((aligned(16)));
__m128i a_i_p7_p3 __attribute__ ((aligned(16)));
__m128i a_i_p7_p5 __attribute__ ((aligned(16)));
__m128i a_i_p7_p7 __attribute__ ((aligned(16)));

__m128i psi_a_m7_m7 __attribute__ ((aligned(16)));
__m128i psi_a_m7_m5 __attribute__ ((aligned(16)));
__m128i psi_a_m7_m3 __attribute__ ((aligned(16)));
__m128i psi_a_m7_m1 __attribute__ ((aligned(16)));
__m128i psi_a_m7_p1 __attribute__ ((aligned(16)));
__m128i psi_a_m7_p3 __attribute__ ((aligned(16)));
__m128i psi_a_m7_p5 __attribute__ ((aligned(16)));
__m128i psi_a_m7_p7 __attribute__ ((aligned(16)));
__m128i psi_a_m5_m7 __attribute__ ((aligned(16)));
__m128i psi_a_m5_m5 __attribute__ ((aligned(16)));
__m128i psi_a_m5_m3 __attribute__ ((aligned(16)));
__m128i psi_a_m5_m1 __attribute__ ((aligned(16)));
__m128i psi_a_m5_p1 __attribute__ ((aligned(16)));
__m128i psi_a_m5_p3 __attribute__ ((aligned(16)));
__m128i psi_a_m5_p5 __attribute__ ((aligned(16)));
__m128i psi_a_m5_p7 __attribute__ ((aligned(16)));
__m128i psi_a_m3_m7 __attribute__ ((aligned(16)));
__m128i psi_a_m3_m5 __attribute__ ((aligned(16)));
__m128i psi_a_m3_m3 __attribute__ ((aligned(16)));
__m128i psi_a_m3_m1 __attribute__ ((aligned(16)));
__m128i psi_a_m3_p1 __attribute__ ((aligned(16)));
__m128i psi_a_m3_p3 __attribute__ ((aligned(16)));
__m128i psi_a_m3_p5 __attribute__ ((aligned(16)));
__m128i psi_a_m3_p7 __attribute__ ((aligned(16)));
__m128i psi_a_m1_m7 __attribute__ ((aligned(16)));
__m128i psi_a_m1_m5 __attribute__ ((aligned(16)));
__m128i psi_a_m1_m3 __attribute__ ((aligned(16)));
__m128i psi_a_m1_m1 __attribute__ ((aligned(16)));
__m128i psi_a_m1_p1 __attribute__ ((aligned(16)));
__m128i psi_a_m1_p3 __attribute__ ((aligned(16)));
__m128i psi_a_m1_p5 __attribute__ ((aligned(16)));
__m128i psi_a_m1_p7 __attribute__ ((aligned(16)));
__m128i psi_a_p1_m7 __attribute__ ((aligned(16)));
__m128i psi_a_p1_m5 __attribute__ ((aligned(16)));
__m128i psi_a_p1_m3 __attribute__ ((aligned(16)));
__m128i psi_a_p1_m1 __attribute__ ((aligned(16)));
__m128i psi_a_p1_p1 __attribute__ ((aligned(16)));
__m128i psi_a_p1_p3 __attribute__ ((aligned(16)));
__m128i psi_a_p1_p5 __attribute__ ((aligned(16)));
__m128i psi_a_p1_p7 __attribute__ ((aligned(16)));
__m128i psi_a_p3_m7 __attribute__ ((aligned(16)));
__m128i psi_a_p3_m5 __attribute__ ((aligned(16)));
__m128i psi_a_p3_m3 __attribute__ ((aligned(16)));
__m128i psi_a_p3_m1 __attribute__ ((aligned(16)));
__m128i psi_a_p3_p1 __attribute__ ((aligned(16)));
__m128i psi_a_p3_p3 __attribute__ ((aligned(16)));
__m128i psi_a_p3_p5 __attribute__ ((aligned(16)));
__m128i psi_a_p3_p7 __attribute__ ((aligned(16)));
__m128i psi_a_p5_m7 __attribute__ ((aligned(16)));
__m128i psi_a_p5_m5 __attribute__ ((aligned(16)));
__m128i psi_a_p5_m3 __attribute__ ((aligned(16)));
__m128i psi_a_p5_m1 __attribute__ ((aligned(16)));
__m128i psi_a_p5_p1 __attribute__ ((aligned(16)));
__m128i psi_a_p5_p3 __attribute__ ((aligned(16)));
__m128i psi_a_p5_p5 __attribute__ ((aligned(16)));
__m128i psi_a_p5_p7 __attribute__ ((aligned(16)));
__m128i psi_a_p7_m7 __attribute__ ((aligned(16)));
__m128i psi_a_p7_m5 __attribute__ ((aligned(16)));
__m128i psi_a_p7_m3 __attribute__ ((aligned(16)));
__m128i psi_a_p7_m1 __attribute__ ((aligned(16)));
__m128i psi_a_p7_p1 __attribute__ ((aligned(16)));
__m128i psi_a_p7_p3 __attribute__ ((aligned(16)));
__m128i psi_a_p7_p5 __attribute__ ((aligned(16)));
__m128i psi_a_p7_p7 __attribute__ ((aligned(16)));

__m128i a_sq_m7_m7 __attribute__ ((aligned(16)));
__m128i a_sq_m7_m5 __attribute__ ((aligned(16)));
__m128i a_sq_m7_m3 __attribute__ ((aligned(16)));
__m128i a_sq_m7_m1 __attribute__ ((aligned(16)));
__m128i a_sq_m7_p1 __attribute__ ((aligned(16)));
__m128i a_sq_m7_p3 __attribute__ ((aligned(16)));
__m128i a_sq_m7_p5 __attribute__ ((aligned(16)));
__m128i a_sq_m7_p7 __attribute__ ((aligned(16)));
__m128i a_sq_m5_m7 __attribute__ ((aligned(16)));
__m128i a_sq_m5_m5 __attribute__ ((aligned(16)));
__m128i a_sq_m5_m3 __attribute__ ((aligned(16)));
__m128i a_sq_m5_m1 __attribute__ ((aligned(16)));
__m128i a_sq_m5_p1 __attribute__ ((aligned(16)));
__m128i a_sq_m5_p3 __attribute__ ((aligned(16)));
__m128i a_sq_m5_p5 __attribute__ ((aligned(16)));
__m128i a_sq_m5_p7 __attribute__ ((aligned(16)));
__m128i a_sq_m3_m7 __attribute__ ((aligned(16)));
__m128i a_sq_m3_m5 __attribute__ ((aligned(16)));
__m128i a_sq_m3_m3 __attribute__ ((aligned(16)));
__m128i a_sq_m3_m1 __attribute__ ((aligned(16)));
__m128i a_sq_m3_p1 __attribute__ ((aligned(16)));
__m128i a_sq_m3_p3 __attribute__ ((aligned(16)));
__m128i a_sq_m3_p5 __attribute__ ((aligned(16)));
__m128i a_sq_m3_p7 __attribute__ ((aligned(16)));
__m128i a_sq_m1_m7 __attribute__ ((aligned(16)));
__m128i a_sq_m1_m5 __attribute__ ((aligned(16)));
__m128i a_sq_m1_m3 __attribute__ ((aligned(16)));
__m128i a_sq_m1_m1 __attribute__ ((aligned(16)));
__m128i a_sq_m1_p1 __attribute__ ((aligned(16)));
__m128i a_sq_m1_p3 __attribute__ ((aligned(16)));
__m128i a_sq_m1_p5 __attribute__ ((aligned(16)));
__m128i a_sq_m1_p7 __attribute__ ((aligned(16)));
__m128i a_sq_p1_m7 __attribute__ ((aligned(16)));
__m128i a_sq_p1_m5 __attribute__ ((aligned(16)));
__m128i a_sq_p1_m3 __attribute__ ((aligned(16)));
__m128i a_sq_p1_m1 __attribute__ ((aligned(16)));
__m128i a_sq_p1_p1 __attribute__ ((aligned(16)));
__m128i a_sq_p1_p3 __attribute__ ((aligned(16)));
__m128i a_sq_p1_p5 __attribute__ ((aligned(16)));
__m128i a_sq_p1_p7 __attribute__ ((aligned(16)));
__m128i a_sq_p3_m7 __attribute__ ((aligned(16)));
__m128i a_sq_p3_m5 __attribute__ ((aligned(16)));
__m128i a_sq_p3_m3 __attribute__ ((aligned(16)));
__m128i a_sq_p3_m1 __attribute__ ((aligned(16)));
__m128i a_sq_p3_p1 __attribute__ ((aligned(16)));
__m128i a_sq_p3_p3 __attribute__ ((aligned(16)));
__m128i a_sq_p3_p5 __attribute__ ((aligned(16)));
__m128i a_sq_p3_p7 __attribute__ ((aligned(16)));
__m128i a_sq_p5_m7 __attribute__ ((aligned(16)));
__m128i a_sq_p5_m5 __attribute__ ((aligned(16)));
__m128i a_sq_p5_m3 __attribute__ ((aligned(16)));
__m128i a_sq_p5_m1 __attribute__ ((aligned(16)));
__m128i a_sq_p5_p1 __attribute__ ((aligned(16)));
__m128i a_sq_p5_p3 __attribute__ ((aligned(16)));
__m128i a_sq_p5_p5 __attribute__ ((aligned(16)));
__m128i a_sq_p5_p7 __attribute__ ((aligned(16)));
__m128i a_sq_p7_m7 __attribute__ ((aligned(16)));
__m128i a_sq_p7_m5 __attribute__ ((aligned(16)));
__m128i a_sq_p7_m3 __attribute__ ((aligned(16)));
__m128i a_sq_p7_m1 __attribute__ ((aligned(16)));
__m128i a_sq_p7_p1 __attribute__ ((aligned(16)));
__m128i a_sq_p7_p3 __attribute__ ((aligned(16)));
__m128i a_sq_p7_p5 __attribute__ ((aligned(16)));
__m128i a_sq_p7_p7 __attribute__ ((aligned(16)));

__m128i bit_met_m7_m7 __attribute__ ((aligned(16)));
__m128i bit_met_m7_m5 __attribute__ ((aligned(16)));
__m128i bit_met_m7_m3 __attribute__ ((aligned(16)));
__m128i bit_met_m7_m1 __attribute__ ((aligned(16)));
__m128i bit_met_m7_p1 __attribute__ ((aligned(16)));
__m128i bit_met_m7_p3 __attribute__ ((aligned(16)));
__m128i bit_met_m7_p5 __attribute__ ((aligned(16)));
__m128i bit_met_m7_p7 __attribute__ ((aligned(16)));
__m128i bit_met_m5_m7 __attribute__ ((aligned(16)));
__m128i bit_met_m5_m5 __attribute__ ((aligned(16)));
__m128i bit_met_m5_m3 __attribute__ ((aligned(16)));
__m128i bit_met_m5_m1 __attribute__ ((aligned(16)));
__m128i bit_met_m5_p1 __attribute__ ((aligned(16)));
__m128i bit_met_m5_p3 __attribute__ ((aligned(16)));
__m128i bit_met_m5_p5 __attribute__ ((aligned(16)));
__m128i bit_met_m5_p7 __attribute__ ((aligned(16)));
__m128i bit_met_m3_m7 __attribute__ ((aligned(16)));
__m128i bit_met_m3_m5 __attribute__ ((aligned(16)));
__m128i bit_met_m3_m3 __attribute__ ((aligned(16)));
__m128i bit_met_m3_m1 __attribute__ ((aligned(16)));
__m128i bit_met_m3_p1 __attribute__ ((aligned(16)));
__m128i bit_met_m3_p3 __attribute__ ((aligned(16)));
__m128i bit_met_m3_p5 __attribute__ ((aligned(16)));
__m128i bit_met_m3_p7 __attribute__ ((aligned(16)));
__m128i bit_met_m1_m7 __attribute__ ((aligned(16)));
__m128i bit_met_m1_m5 __attribute__ ((aligned(16)));
__m128i bit_met_m1_m3 __attribute__ ((aligned(16)));
__m128i bit_met_m1_m1 __attribute__ ((aligned(16)));
__m128i bit_met_m1_p1 __attribute__ ((aligned(16)));
__m128i bit_met_m1_p3 __attribute__ ((aligned(16)));
__m128i bit_met_m1_p5 __attribute__ ((aligned(16)));
__m128i bit_met_m1_p7 __attribute__ ((aligned(16)));
__m128i bit_met_p1_m7 __attribute__ ((aligned(16)));
__m128i bit_met_p1_m5 __attribute__ ((aligned(16)));
__m128i bit_met_p1_m3 __attribute__ ((aligned(16)));
__m128i bit_met_p1_m1 __attribute__ ((aligned(16)));
__m128i bit_met_p1_p1 __attribute__ ((aligned(16)));
__m128i bit_met_p1_p3 __attribute__ ((aligned(16)));
__m128i bit_met_p1_p5 __attribute__ ((aligned(16)));
__m128i bit_met_p1_p7 __attribute__ ((aligned(16)));
__m128i bit_met_p3_m7 __attribute__ ((aligned(16)));
__m128i bit_met_p3_m5 __attribute__ ((aligned(16)));
__m128i bit_met_p3_m3 __attribute__ ((aligned(16)));
__m128i bit_met_p3_m1 __attribute__ ((aligned(16)));
__m128i bit_met_p3_p1 __attribute__ ((aligned(16)));
__m128i bit_met_p3_p3 __attribute__ ((aligned(16)));
__m128i bit_met_p3_p5 __attribute__ ((aligned(16)));
__m128i bit_met_p3_p7 __attribute__ ((aligned(16)));
__m128i bit_met_p5_m7 __attribute__ ((aligned(16)));
__m128i bit_met_p5_m5 __attribute__ ((aligned(16)));
__m128i bit_met_p5_m3 __attribute__ ((aligned(16)));
__m128i bit_met_p5_m1 __attribute__ ((aligned(16)));
__m128i bit_met_p5_p1 __attribute__ ((aligned(16)));
__m128i bit_met_p5_p3 __attribute__ ((aligned(16)));
__m128i bit_met_p5_p5 __attribute__ ((aligned(16)));
__m128i bit_met_p5_p7 __attribute__ ((aligned(16)));
__m128i bit_met_p7_m7 __attribute__ ((aligned(16)));
__m128i bit_met_p7_m5 __attribute__ ((aligned(16)));
__m128i bit_met_p7_m3 __attribute__ ((aligned(16)));
__m128i bit_met_p7_m1 __attribute__ ((aligned(16)));
__m128i bit_met_p7_p1 __attribute__ ((aligned(16)));
__m128i bit_met_p7_p3 __attribute__ ((aligned(16)));
__m128i bit_met_p7_p5 __attribute__ ((aligned(16)));
__m128i bit_met_p7_p7 __attribute__ ((aligned(16)));

__m128i  y0_p_1_1 __attribute__ ((aligned(16)));
__m128i  y0_p_1_3 __attribute__ ((aligned(16)));
__m128i  y0_p_1_5 __attribute__ ((aligned(16)));
__m128i  y0_p_1_7 __attribute__ ((aligned(16)));
__m128i  y0_p_3_1 __attribute__ ((aligned(16)));
__m128i  y0_p_3_3 __attribute__ ((aligned(16)));
__m128i  y0_p_3_5 __attribute__ ((aligned(16)));
__m128i  y0_p_3_7 __attribute__ ((aligned(16)));
__m128i  y0_p_5_1 __attribute__ ((aligned(16)));
__m128i  y0_p_5_3 __attribute__ ((aligned(16)));
__m128i  y0_p_5_5 __attribute__ ((aligned(16)));
__m128i  y0_p_5_7 __attribute__ ((aligned(16)));
__m128i  y0_p_7_1 __attribute__ ((aligned(16)));
__m128i  y0_p_7_3 __attribute__ ((aligned(16)));
__m128i  y0_p_7_5 __attribute__ ((aligned(16)));
__m128i  y0_p_7_7 __attribute__ ((aligned(16)));
__m128i  y0_m_1_1 __attribute__ ((aligned(16)));
__m128i  y0_m_1_3 __attribute__ ((aligned(16)));
__m128i  y0_m_1_5 __attribute__ ((aligned(16)));
__m128i  y0_m_1_7 __attribute__ ((aligned(16)));
__m128i  y0_m_3_1 __attribute__ ((aligned(16)));
__m128i  y0_m_3_3 __attribute__ ((aligned(16)));
__m128i  y0_m_3_5 __attribute__ ((aligned(16)));
__m128i  y0_m_3_7 __attribute__ ((aligned(16)));
__m128i  y0_m_5_1 __attribute__ ((aligned(16)));
__m128i  y0_m_5_3 __attribute__ ((aligned(16)));
__m128i  y0_m_5_5 __attribute__ ((aligned(16)));
__m128i  y0_m_5_7 __attribute__ ((aligned(16)));
__m128i  y0_m_7_1 __attribute__ ((aligned(16)));
__m128i  y0_m_7_3 __attribute__ ((aligned(16)));
__m128i  y0_m_7_5 __attribute__ ((aligned(16)));
__m128i  y0_m_7_7 __attribute__ ((aligned(16)));

__m128i  xmm0 __attribute__ ((aligned(16)));
__m128i  xmm1 __attribute__ ((aligned(16)));
__m128i  xmm2 __attribute__ ((aligned(16)));
__m128i  xmm3 __attribute__ ((aligned(16)));
__m128i  xmm4 __attribute__ ((aligned(16)));
__m128i  xmm5 __attribute__ ((aligned(16)));
__m128i  xmm6 __attribute__ ((aligned(16)));
__m128i  xmm7 __attribute__ ((aligned(16)));
__m128i  xmm8 __attribute__ ((aligned(16)));

__m128i  y0r __attribute__ ((aligned(16)));
__m128i  y0i __attribute__ ((aligned(16)));
__m128i  y1r __attribute__ ((aligned(16)));
__m128i  y1i __attribute__ ((aligned(16)));
__m128i  y2r __attribute__ ((aligned(16)));
__m128i  y2i __attribute__ ((aligned(16)));

__m128i  logmax_num_re0 __attribute__ ((aligned(16)));
__m128i  logmax_num_im0 __attribute__ ((aligned(16)));
__m128i  logmax_den_re0 __attribute__ ((aligned(16)));
__m128i  logmax_den_im0 __attribute__ ((aligned(16)));
__m128i  logmax_num_re1 __attribute__ ((aligned(16)));
__m128i  logmax_num_im1 __attribute__ ((aligned(16)));
__m128i  logmax_den_re1 __attribute__ ((aligned(16)));
__m128i  logmax_den_im1 __attribute__ ((aligned(16)));

__m128i tmp_result  __attribute__ ((aligned(16)));
__m128i tmp_result2 __attribute__ ((aligned(16)));
__m128i tmp_result3 __attribute__ ((aligned(16)));
__m128i tmp_result4 __attribute__ ((aligned(16)));
596
597
598
599
600


//==============================================================================================
// Auxiliary Makros

601
// calculates psi_a = psi_r*a_r + psi_i*a_i
602
603
604
#define prodsum_psi_a_epi16(psi_r,a_r,psi_i,a_i,psi_a) tmp_result = _mm_mulhi_epi16(psi_r,a_r); tmp_result = _mm_slli_epi16(tmp_result,1); tmp_result2 = _mm_mulhi_epi16(psi_i,a_i); tmp_result2 = _mm_slli_epi16(tmp_result2,1); psi_a = _mm_adds_epi16(tmp_result,tmp_result2);

// calculate interference magnitude
605
#define interference_abs_epi16(psi,int_ch_mag,int_mag,c1,c2) tmp_result = _mm_cmplt_epi16(psi,int_ch_mag); tmp_result2 = _mm_xor_si128(tmp_result,(*(__m128i*)&ones[0])); tmp_result = _mm_and_si128(tmp_result,c1); tmp_result2 = _mm_and_si128(tmp_result2,c2); int_mag = _mm_or_si128(tmp_result,tmp_result2);
606
607

// calculate interference magnitude
608
609
// tmp_result = ones in shorts corr. to interval 2<=x<=4, tmp_result2 interval < 2, tmp_result3 interval 4<x<6 and tmp_result4 interval x>6
#define interference_abs_64qam_epi16(psi,int_ch_mag,int_two_ch_mag,int_three_ch_mag,a,c1,c3,c5,c7) tmp_result = _mm_cmplt_epi16(psi,int_two_ch_mag); tmp_result3 = _mm_xor_si128(tmp_result,(*(__m128i*)&ones[0])); tmp_result2 = _mm_cmplt_epi16(psi,int_ch_mag); tmp_result = _mm_xor_si128(tmp_result,tmp_result2); tmp_result4 = _mm_cmpgt_epi16(psi,int_three_ch_mag); tmp_result3 = _mm_xor_si128(tmp_result3,tmp_result4); tmp_result = _mm_and_si128(tmp_result,c3); tmp_result2 = _mm_and_si128(tmp_result2,c1); tmp_result3 = _mm_and_si128(tmp_result3,c5); tmp_result4 = _mm_and_si128(tmp_result4,c7); tmp_result = _mm_or_si128(tmp_result,tmp_result2); tmp_result3 = _mm_or_si128(tmp_result3,tmp_result4); a = _mm_or_si128(tmp_result,tmp_result3);
610

611
// calculates a_sq = int_ch_mag*(a_r^2 + a_i^2)*scale_factor
612
613
614
615
616
#define square_a_epi16(a_r,a_i,int_ch_mag,scale_factor,a_sq) tmp_result = _mm_mulhi_epi16(a_r,a_r); tmp_result = _mm_slli_epi16(tmp_result,1); tmp_result = _mm_mulhi_epi16(tmp_result,scale_factor); tmp_result = _mm_slli_epi16(tmp_result,1); tmp_result = _mm_mulhi_epi16(tmp_result,int_ch_mag); tmp_result = _mm_slli_epi16(tmp_result,1); tmp_result2 = _mm_mulhi_epi16(a_i,a_i); tmp_result2 = _mm_slli_epi16(tmp_result2,1); tmp_result2 = _mm_mulhi_epi16(tmp_result2,scale_factor); tmp_result2 = _mm_slli_epi16(tmp_result2,1); tmp_result2 = _mm_mulhi_epi16(tmp_result2,int_ch_mag); tmp_result2 = _mm_slli_epi16(tmp_result2,1); a_sq = _mm_adds_epi16(tmp_result,tmp_result2);

// calculates a_sq = int_ch_mag*(a_r^2 + a_i^2)*scale_factor for 64-QAM
#define square_a_64qam_epi16(a_r,a_i,int_ch_mag,scale_factor,a_sq)  tmp_result = _mm_mulhi_epi16(a_r,a_r); tmp_result = _mm_slli_epi16(tmp_result,1); tmp_result = _mm_mulhi_epi16(tmp_result,scale_factor); tmp_result = _mm_slli_epi16(tmp_result,3); tmp_result = _mm_mulhi_epi16(tmp_result,int_ch_mag); tmp_result = _mm_slli_epi16(tmp_result,1); tmp_result2 = _mm_mulhi_epi16(a_i,a_i); tmp_result2 = _mm_slli_epi16(tmp_result2,1); tmp_result2 = _mm_mulhi_epi16(tmp_result2,scale_factor); tmp_result2 = _mm_slli_epi16(tmp_result2,3); tmp_result2 = _mm_mulhi_epi16(tmp_result2,int_ch_mag); tmp_result2 = _mm_slli_epi16(tmp_result2,1); a_sq = _mm_adds_epi16(tmp_result,tmp_result2);

617
618
619
620
#elif defined(__arm__)

#endif

621
622
623
624
625
626
627
628
629
//==============================================================================================
// SINGLE-STREAM
//==============================================================================================

//----------------------------------------------------------------------------------------------
// QPSK
//----------------------------------------------------------------------------------------------

int dlsch_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms,
630
631
632
                   int32_t **rxdataF_comp,
                   int16_t *dlsch_llr,
                   uint8_t symbol,
gauthier's avatar
gauthier committed
633
634
635
                   uint8_t first_symbol_flag,
                   uint16_t nb_rb,
                   uint16_t pbch_pss_sss_adjust,
636
                   int16_t **llr32p,
637
		   uint8_t beamforming_mode)
638
{
639

640
  uint32_t *rxF = (uint32_t*)&rxdataF_comp[0][((int32_t)symbol*frame_parms->N_RB_DL*12)];
gauthier's avatar
gauthier committed
641
  uint32_t *llr32;
642
  int i,len;
gauthier's avatar
gauthier committed
643
  uint8_t symbol_mod = (symbol >= (7-frame_parms->Ncp))? (symbol-(7-frame_parms->Ncp)) : symbol;
644
645

  if (first_symbol_flag==1) {
646
647
648
    llr32 = (uint32_t*)dlsch_llr;
  } else {
    llr32 = (uint32_t*)(*llr32p);
649
  }
650

651
  if (!llr32) {
652
653
654
    msg("dlsch_qpsk_llr: llr is null, symbol %d, llr32=%p\n",symbol, llr32);
    return(-1);
  }
655
656
657


  if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
658
    if (frame_parms->mode1_flag==0)
659
      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
660
    else
661
      len = (nb_rb*10) - (5*pbch_pss_sss_adjust/6);
662
  } else if((beamforming_mode==7) && (frame_parms->Ncp==0) && (symbol==3 || symbol==6 || symbol==9 || symbol==12)){
663
      len = (nb_rb*9) - (3*pbch_pss_sss_adjust/4);
664
  } else if((beamforming_mode==7) && (frame_parms->Ncp==1) && (symbol==4 || symbol==7 || symbol==10)){
665
      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
666
  } else {
667
    len = (nb_rb*12) - pbch_pss_sss_adjust;
668
669
  }

670

671
672
  //printf("dlsch_qpsk_llr: symbol %d,nb_rb %d, len %d,pbch_pss_sss_adjust %d\n",symbol,nb_rb,len,pbch_pss_sss_adjust);
  //printf("ll32p=%p , dlsch_llr=%p, symbol=%d, flag=%d \n", llr32, dlsch_llr, symbol, first_symbol_flag);
673
674
  for (i=0; i<len; i++) {
    *llr32 = *rxF;
675
     //printf("llr %d : (%d,%d)\n",i,((int16_t*)llr32)[0],((int16_t*)llr32)[1]);
676
677
    rxF++;
    llr32++;
678
679
  }

680
  *llr32p = (int16_t *)llr32;
681
682
683
684

  return(0);
}

Elena Lukashova's avatar
Elena Lukashova committed
685
int32_t dlsch_qpsk_llr_SIC(LTE_DL_FRAME_PARMS *frame_parms,
Elena Lukashova's avatar
Elena Lukashova committed
686
                           int32_t **rxdataF_comp,
Elena Lukashova's avatar
Elena Lukashova committed
687
688
                           int32_t **sic_buffer,  //Q15
                           int32_t **rho_i,
Elena Lukashova's avatar
Elena Lukashova committed
689
                           short *dlsch_llr,
Elena Lukashova's avatar
Elena Lukashova committed
690
                           uint8_t num_pdcch_symbols,
Elena Lukashova's avatar
Elena Lukashova committed
691
                           uint16_t nb_rb,
Elena Lukashova's avatar
Elena Lukashova committed
692
693
                           uint8_t subframe,
                           uint32_t rb_alloc,
694
                           uint16_t mod_order_0,
Elena Lukashova's avatar
Elena Lukashova committed
695
                           LTE_UE_DLSCH_t *dlsch0)
Elena Lukashova's avatar
Elena Lukashova committed
696
697
698
699
700
701
702
703
704
705
706
{

  int16_t rho_amp_x0[2*frame_parms->N_RB_DL*12];
  int16_t rho_rho_amp_x0[2*frame_parms->N_RB_DL*12];
  uint16_t amp_tmp;
  uint16_t *llr16=(uint16_t*)dlsch_llr;
  int i, len,  nsymb;
  uint8_t symbol, symbol_mod;
  //uint8_t pilots;
  int len_acc=0;
  uint16_t *sic_data;
707
  uint16_t pbch_pss_sss_adjust;
Elena Lukashova's avatar
Elena Lukashova committed
708
709
710
711

  nsymb = (frame_parms->Ncp==0) ? 14:12;

  for (symbol=num_pdcch_symbols; symbol<nsymb; symbol++) {
712
713
    uint16_t *rxF = (uint16_t*)(&rxdataF_comp[0][((int16_t)symbol*frame_parms->N_RB_DL*12)]);
    int16_t *rho_1=(int16_t*)(&rho_i[0][((int16_t)symbol*frame_parms->N_RB_DL*12)]);
714
    sic_data = (uint16_t*)&sic_buffer[0][((int16_t)len_acc)];
Elena Lukashova's avatar
Elena Lukashova committed
715
716
717

    symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;

718

719

720
721

      if ((symbol_mod == 0) || (symbol_mod == (4-frame_parms->Ncp))) //pilots=1
722
        amp_tmp=dlsch0->sqrt_rho_b;
723
724
725
      else //pilots=0
        amp_tmp=dlsch0->sqrt_rho_a;

726
        if (mod_order_0==6)
727
         amp_tmp=amp_tmp<<1; // to compensate for >> 1 shift in modulation
728
729


730
    pbch_pss_sss_adjust=adjust_G2(frame_parms,&rb_alloc,2,subframe,symbol);
Elena Lukashova's avatar
Elena Lukashova committed
731
732

  // printf("amp_tmp=%d\n", amp_tmp);
733

Elena Lukashova's avatar
Elena Lukashova committed
734
735
736
737
738
739
740
741
    if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
      if (frame_parms->mode1_flag==0)
        len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
      else
        len = (nb_rb*10) - (5*pbch_pss_sss_adjust/6);
    } else {
      len = (nb_rb*12) - pbch_pss_sss_adjust;
    }
742

743
   //  printf("dlsch_qpsk_llr: symbol %d,nb_rb %d, len %d,pbch_pss_sss_adjust %d\n",symbol,nb_rb,len,pbch_pss_sss_adjust);
Elena Lukashova's avatar
Elena Lukashova committed
744
745

    len_acc+=len; //accumulated length; this is done because in sic_buffer we have only data symbols
746

Elena Lukashova's avatar
Elena Lukashova committed
747
    multadd_complex_vector_real_scalar((int16_t *)sic_data,
Elena Lukashova's avatar
Elena Lukashova committed
748
749
750
751
                                       amp_tmp,
                                       (int16_t *)rho_amp_x0, //this is in Q13
                                       1,
                                       len);
752
753


754
 //   printf ("Got x0*rho_a\n");
755

756
757
    mult_cpx_vector((int16_t *)rho_1, //Q15
                    (int16_t *)rho_amp_x0, //Q13
Elena Lukashova's avatar
Elena Lukashova committed
758
759
                    (int16_t*)rho_rho_amp_x0,
                    len,
760
761
                    13);
  /*  write_output("rho_for_multipl.m","rho_for_multipl", rho_1,len,1,
Elena Lukashova's avatar
Elena Lukashova committed
762
     symbol==num_pdcch_symbols ? 15 :
763
     symbol==nsymb-1 ? 14 : 13);
764
765

    write_output("rho_rho_in_llr.m","rho2", rho_rho_amp_x0,len,1,
Elena Lukashova's avatar
Elena Lukashova committed
766
767
     symbol==num_pdcch_symbols ? 15 :
     symbol==nsymb-1 ? 14 : 13);
768
 //   printf ("Computed  rho*rho_a*x0\n");*/
769
770


771
    //rho_rho_amp_x0_512 = (int16_t)((512*(int16_t *)rho_rho_amp_x0)>>15);
772
773


Elena Lukashova's avatar
Elena Lukashova committed
774
    sub_cpx_vector16((int16_t *)rxF,
Elena Lukashova's avatar
Elena Lukashova committed
775
776
777
                     (int16_t *)rho_rho_amp_x0,
                     //(int16_t *)clean_x1,
                     (int16_t *)rxF,
778
                     len*2);
Elena Lukashova's avatar
Elena Lukashova committed
779

780
  //  write_output("rxFdata_comp1_after.m","rxF_a", rxF,len,1,1);
781
   // write_output("clean_x1.m","x1", clean_x1,len,1,1);
782
  //  printf ("Interference removed \n");
783
      /*  write_output("clean_x1.m","x1", clean_x1,len,1,
Elena Lukashova's avatar
Elena Lukashova committed
784
785
     symbol==num_pdcch_symbols ? 15 :
     symbol==nsymb-1 ? 14 : 13);
786

Elena Lukashova's avatar
Elena Lukashova committed
787
788
789
  write_output("rxF_comp1.m","rxF_1_comp", rxF,len,1,
     symbol==num_pdcch_symbols ? 15 :
     symbol==nsymb-1 ? 14 : 13);*/
Elena Lukashova's avatar
Elena Lukashova committed
790

791
  //  printf("dlsch_qpsk_llr_SIC: symbol %d,nb_rb %d, len %d,pbch_pss_sss_adjust %d\n",symbol,nb_rb,len,pbch_pss_sss_adjust);
Elena Lukashova's avatar
Elena Lukashova committed
792

793

Elena Lukashova's avatar
Elena Lukashova committed
794
795
    //this is for QPSK only!!!
    for (i=0; i<len*2; i++) {
796
      *llr16 =rxF[i]; //clean_x1[i];//(int16_t *)rxF[i];//clean_x1[i]; //(int16_t *)rxF[i];//; //rxF[i];
Elena Lukashova's avatar
Elena Lukashova committed
797
798
799
      //printf("llr %d : (%d,%d)\n",i,((int16_t*)llr32)[0],((int16_t*)llr32)[1]);
      llr16++;
    }
800

Elena Lukashova's avatar
Elena Lukashova committed
801
802
  }

803
 // printf("dlsch_qpsk_llr_SIC: acc_len=%d\n",len_acc);
Elena Lukashova's avatar
Elena Lukashova committed
804
805
806
807
808

  return(0);
}


809
810
811
812
813
//----------------------------------------------------------------------------------------------
// 16-QAM
//----------------------------------------------------------------------------------------------

void dlsch_16qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
814
815
816
817
                     int32_t **rxdataF_comp,
                     int16_t *dlsch_llr,
                     int32_t **dl_ch_mag,
                     uint8_t symbol,
gauthier's avatar
gauthier committed
818
                     uint8_t first_symbol_flag,
819
                     uint16_t nb_rb,
gauthier's avatar
gauthier committed
820
                     uint16_t pbch_pss_sss_adjust,
821
822
                     int16_t **llr32p,
                     uint8_t beamforming_mode)
823
824
{

825
#if defined(__x86_64__) || defined(__i386__)
826
827
828
  __m128i *rxF = (__m128i*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)];
  __m128i *ch_mag;
  __m128i llr128[2];
829
830
831
832
833
834
835
836
837
  uint32_t *llr32;
#elif defined(__arm__)
  int16x8_t *rxF = (int16x8_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)];
  int16x8_t *ch_mag;
  int16x8_t xmm0;
  int16_t *llr16;
#endif


838
839
840
841
  int i,len;
  unsigned char symbol_mod,len_mod4=0;


Elena Lukashova's avatar
Elena Lukashova committed
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
#if defined(__x86_64__) || defined(__i386__)
  if (first_symbol_flag==1) {
    llr32 = (uint32_t*)dlsch_llr;
  } else {
    llr32 = (uint32_t*)*llr32p;
  }
#elif defined(__arm__)
  if (first_symbol_flag==1) {
    llr16 = (int16_t*)dlsch_llr;
  } else {
    llr16 = (int16_t*)*llr32p;
  }
#endif

  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;

#if defined(__x86_64__) || defined(__i386__)
  ch_mag = (__m128i*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)];
#elif defined(__arm__)
  ch_mag = (int16x8_t*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)];
#endif
  if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
    if (frame_parms->mode1_flag==0)
865
      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
Elena Lukashova's avatar
Elena Lukashova committed
866
    else
867
868
869
870
871
      len = (nb_rb*10) - (5*pbch_pss_sss_adjust/6);
  } else if((beamforming_mode==7) && (frame_parms->Ncp==0) && (symbol==3 || symbol==6 || symbol==9 || symbol==12)){
      len = (nb_rb*9) - (3*pbch_pss_sss_adjust/4);
  } else if((beamforming_mode==7) && (frame_parms->Ncp==1) && (symbol==4 || symbol==7 || symbol==10)){
      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
Elena Lukashova's avatar
Elena Lukashova committed
872
  } else {
873
    len = (nb_rb*12) - pbch_pss_sss_adjust;
Elena Lukashova's avatar
Elena Lukashova committed
874
875
876
877
878
879
880
881
  }

  // update output pointer according to number of REs in this symbol (<<2 because 4 bits per RE)
  if (first_symbol_flag == 1)
    *llr32p = dlsch_llr + (len<<2);
  else
    *llr32p += (len<<2);

882
 // printf("len=%d\n", len);
Elena Lukashova's avatar
Elena Lukashova committed
883
  len_mod4 = len&3;
884
 // printf("len_mod4=%d\n", len_mod4);
Elena Lukashova's avatar
Elena Lukashova committed
885
  len>>=2;  // length in quad words (4 REs)
886
 // printf("len>>=2=%d\n", len);
Elena Lukashova's avatar
Elena Lukashova committed
887
  len+=(len_mod4==0 ? 0 : 1);
888
 // printf("len+=%d\n", len);
Elena Lukashova's avatar
Elena Lukashova committed
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
  for (i=0; i<len; i++) {

#if defined(__x86_64__) || defined(__i386)
    xmm0 = _mm_abs_epi16(rxF[i]);
    xmm0 = _mm_subs_epi16(ch_mag[i],xmm0);

    // lambda_1=y_R, lambda_2=|y_R|-|h|^2, lamda_3=y_I, lambda_4=|y_I|-|h|^2
    llr128[0] = _mm_unpacklo_epi32(rxF[i],xmm0);
    llr128[1] = _mm_unpackhi_epi32(rxF[i],xmm0);
    llr32[0] = _mm_extract_epi32(llr128[0],0); //((uint32_t *)&llr128[0])[0];
    llr32[1] = _mm_extract_epi32(llr128[0],1); //((uint32_t *)&llr128[0])[1];
    llr32[2] = _mm_extract_epi32(llr128[0],2); //((uint32_t *)&llr128[0])[2];
    llr32[3] = _mm_extract_epi32(llr128[0],3); //((uint32_t *)&llr128[0])[3];
    llr32[4] = _mm_extract_epi32(llr128[1],0); //((uint32_t *)&llr128[1])[0];
    llr32[5] = _mm_extract_epi32(llr128[1],1); //((uint32_t *)&llr128[1])[1];
    llr32[6] = _mm_extract_epi32(llr128[1],2); //((uint32_t *)&llr128[1])[2];
    llr32[7] = _mm_extract_epi32(llr128[1],3); //((uint32_t *)&llr128[1])[3];
    llr32+=8;
#elif defined(__arm__)
    xmm0 = vabsq_s16(rxF[i]);
    xmm0 = vqsubq_s16(ch_mag[i],xmm0);
    // lambda_1=y_R, lambda_2=|y_R|-|h|^2, lamda_3=y_I, lambda_4=|y_I|-|h|^2

    llr16[0] = vgetq_lane_s16(rxF[i],0);
    llr16[1] = vgetq_lane_s16(rxF[i],1);
    llr16[2] = vgetq_lane_s16(xmm0,0);
    llr16[3] = vgetq_lane_s16(xmm0,1);
    llr16[4] = vgetq_lane_s16(rxF[i],2);
    llr16[5] = vgetq_lane_s16(rxF[i],3);
    llr16[6] = vgetq_lane_s16(xmm0,2);
    llr16[7] = vgetq_lane_s16(xmm0,3);
    llr16[8] = vgetq_lane_s16(rxF[i],4);
    llr16[9] = vgetq_lane_s16(rxF[i],5);
    llr16[10] = vgetq_lane_s16(xmm0,4);
    llr16[11] = vgetq_lane_s16(xmm0,5);
    llr16[12] = vgetq_lane_s16(rxF[i],6);
    llr16[13] = vgetq_lane_s16(rxF[i],6);
    llr16[14] = vgetq_lane_s16(xmm0,7);
    llr16[15] = vgetq_lane_s16(xmm0,7);
    llr16+=16;
#endif

  }

#if defined(__x86_64__) || defined(__i386__)
  _mm_empty();
  _m_empty();
#endif
}

939
void dlsch_16qam_llr_SIC (LTE_DL_FRAME_PARMS *frame_parms,
Elena Lukashova's avatar
Elena Lukashova committed
940
                          int32_t **rxdataF_comp,
Elena Lukashova's avatar
Elena Lukashova committed
941
942
943
944
945
946
947
948
                          int32_t **sic_buffer,  //Q15
                          int32_t **rho_i,
                          int16_t *dlsch_llr,
                          uint8_t num_pdcch_symbols,
                          int32_t **dl_ch_mag,
                          uint16_t nb_rb,
                          uint8_t subframe,
                          uint32_t rb_alloc,
949
                          uint16_t mod_order_0,
Elena Lukashova's avatar
Elena Lukashova committed
950
951
                          LTE_UE_DLSCH_t *dlsch0
                          )
Elena Lukashova's avatar
Elena Lukashova committed
952
{
953
954
955
956
957
958
959
960
961
962
963
  int16_t rho_amp_x0[2*frame_parms->N_RB_DL*12];
  int16_t rho_rho_amp_x0[2*frame_parms->N_RB_DL*12];
  uint16_t amp_tmp;
  uint32_t *llr32=(uint32_t*)dlsch_llr;
  int i, len,  nsymb;
  uint8_t symbol, symbol_mod;
  //uint8_t pilots;
  int len_acc=0;
  uint16_t *sic_data;
  uint16_t pbch_pss_sss_adjust;
  unsigned char len_mod4=0;
964
965
  __m128i llr128[2];
  __m128i *ch_mag;
966
  nsymb = (frame_parms->Ncp==0) ? 14:12;
Elena Lukashova's avatar
Elena Lukashova committed
967

968
969
970
971
    for (symbol=num_pdcch_symbols; symbol<nsymb; symbol++) {
    uint16_t *rxF = (uint16_t*)(&rxdataF_comp[0][((int16_t)symbol*frame_parms->N_RB_DL*12)]);
    int16_t *rho_1=(int16_t*)(&rho_i[0][((int16_t)symbol*frame_parms->N_RB_DL*12)]);
    ch_mag = (__m128i*)(&dl_ch_mag[0][((int16_t)symbol*frame_parms->N_RB_DL*12)]);
972
973
    sic_data = (uint16_t*)(&sic_buffer[0][((int16_t)len_acc)]);

974
    symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
975

976
977
978
    pbch_pss_sss_adjust=adjust_G2(frame_parms,&rb_alloc,4,subframe,symbol);


979
      if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
980

981
        amp_tmp=dlsch0->sqrt_rho_b;
982
983
984
985
          if (frame_parms->mode1_flag==0)
            len = nb_rb*8 - (2*pbch_pss_sss_adjust/3);
          else
            len = nb_rb*10 - (5*pbch_pss_sss_adjust/6);
986
      } else {
987

988
989
        amp_tmp=dlsch0->sqrt_rho_a;
        len = nb_rb*12 - pbch_pss_sss_adjust;
990
      }
991

992
      if (mod_order_0==6)
993
        amp_tmp=amp_tmp<<1; // to compensate for >> 1 shift in modulation
994

995
    len_acc+=len;
996

997
    multadd_complex_vector_real_scalar((int16_t *)sic_data,
Elena Lukashova's avatar
Elena Lukashova committed
998
999
1000
1001
                                       amp_tmp,
                                       (int16_t *)rho_amp_x0, //this is in Q13
                                       1,
                                       len);
1002

1003
1004
1005
1006
1007
     mult_cpx_vector((int16_t *)rho_1, //Q15
                    (int16_t *)rho_amp_x0, //Q13
                    (int16_t*)rho_rho_amp_x0,
                    len,
                    13);
1008

1009
     sub_cpx_vector16((int16_t *)rxF,
Elena Lukashova's avatar
Elena Lukashova committed
1010
1011
1012
                      (int16_t *)rho_rho_amp_x0,
                      //(int16_t *)clean_x1,
                      (int16_t *)rxF,
1013
                      len*2);
1014

1015
1016
1017
1018
1019
    len_mod4 = len&3;
    len>>=2;  // length in quad words (4 REs)
    len+=(len_mod4==0 ? 0 : 1);

    for (i=0; i<len; i++) {
1020

1021
1022
1023
1024
1025
1026

    __m128i *x1 = (__m128i*)rxF;//clean_x1;
//printf("%p %p %p\n", clean_x1, &clean_x1, &clean_x1[0]);
//int *a = malloc(10*sizeof(int));
//printf("%p %p\n", a, &a);
//exit(0);
1027
    xmm0 = _mm_abs_epi16(x1[i]);
1028
1029
1030
    xmm0 = _mm_subs_epi16(ch_mag[i],xmm0);

    // lambda_1=y_R, lambda_2=|y_R|-|h|^2, lamda_3=y_I, lambda_4=|y_I|-|h|^2
1031
1032
    llr128[0] = _mm_unpacklo_epi32(x1[i],xmm0);
    llr128[1] = _mm_unpackhi_epi32(x1[i],xmm0);
1033
1034
1035
1036
1037
1038
1039
1040
1041
    llr32[0] = _mm_extract_epi32(llr128[0],0); //((uint32_t *)&llr128[0])[0];
    llr32[1] = _mm_extract_epi32(llr128[0],1); //((uint32_t *)&llr128[0])[1];
    llr32[2] = _mm_extract_epi32(llr128[0],2); //((uint32_t *)&llr128[0])[2];
    llr32[3] = _mm_extract_epi32(llr128[0],3); //((uint32_t *)&llr128[0])[3];
    llr32[4] = _mm_extract_epi32(llr128[1],0); //((uint32_t *)&llr128[1])[0];
    llr32[5] = _mm_extract_epi32(llr128[1],1); //((uint32_t *)&llr128[1])[1];
    llr32[6] = _mm_extract_epi32(llr128[1],2); //((uint32_t *)&llr128[1])[2];
    llr32[7] = _mm_extract_epi32(llr128[1],3); //((uint32_t *)&llr128[1])[3];
    llr32+=8;
1042

1043
1044
1045
1046
  }
  _mm_empty();
  _m_empty();
}
1047
}
1048
1049
1050
1051
1052
1053

//----------------------------------------------------------------------------------------------
// 64-QAM
//----------------------------------------------------------------------------------------------

void dlsch_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
1054
1055
1056
1057
1058
                     int32_t **rxdataF_comp,
                     int16_t *dlsch_llr,
                     int32_t **dl_ch_mag,
                     int32_t **dl_ch_magb,
                     uint8_t symbol,
gauthier's avatar
gauthier committed
1059
                     uint8_t first_symbol_flag,
1060
                     uint16_t nb_rb,
gauthier's avatar
gauthier committed
1061
                     uint16_t pbch_pss_sss_adjust,
1062
                     int16_t **llr_save,
1063
                     uint8_t beamforming_mode)
1064
{
1065
#if defined(__x86_64__) || defined(__i386__)
1066
1067
  __m128i *rxF = (__m128i*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)];
  __m128i *ch_mag,*ch_magb;
1068
1069
1070
1071
#elif defined(__arm__)
  int16x8_t *rxF = (int16x8_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)];
  int16x8_t *ch_mag,*ch_magb,xmm1,xmm2;
#endif
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
  int i,len,len2;
  unsigned char symbol_mod,len_mod4;
  short *llr;
  int16_t *llr2;

  if (first_symbol_flag==1)
    llr = dlsch_llr;
  else
    llr = *llr_save;

  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;

1084
#if defined(__x86_64__) || defined(__i386__)
1085
1086
  ch_mag = (__m128i*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)];
  ch_magb = (__m128i*)&dl_ch_magb[0][(symbol*frame_parms->N_RB_DL*12)];
1087
1088
1089
1090
#elif defined(__arm__)
  ch_mag = (int16x8_t*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)];
  ch_magb = (int16x8_t*)&dl_ch_magb[0][(symbol*frame_parms->N_RB_DL*12)];
#endif
1091
1092
  if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
    if (frame_parms->mode1_flag==0)
1093
      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
1094
    else
1095
1096
1097
1098
1099
      len = (nb_rb*10) - (5*pbch_pss_sss_adjust/6);
  } else if((beamforming_mode==7) && (frame_parms->Ncp==0) && (symbol==3 || symbol==6 || symbol==9 || symbol==12)){
      len = (nb_rb*9) - (3*pbch_pss_sss_adjust/4);
  } else if((beamforming_mode==7) && (frame_parms->Ncp==1) && (symbol==4 || symbol==7 || symbol==10)){
      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
1100
  } else {
1101
    len = (nb_rb*12) - pbch_pss_sss_adjust;
1102
1103
1104
1105
1106
1107
1108
  }

  llr2 = llr;
  llr += (len*6);

  len_mod4 =len&3;
  len2=len>>2;  // length in quad words (4 REs)
knopp's avatar
knopp committed
1109
  len2+=((len_mod4==0)?0:1);
1110
1111
1112

  for (i=0; i<len2; i++) {

1113
#if defined(__x86_64__) || defined(__i386__)
1114
1115
1116
1117
    xmm1 = _mm_abs_epi16(rxF[i]);
    xmm1 = _mm_subs_epi16(ch_mag[i],xmm1);
    xmm2 = _mm_abs_epi16(xmm1);
    xmm2 = _mm_subs_epi16(ch_magb[i],xmm2);
1118
1119
1120
1121
1122
1123
#elif defined(__arm__)
    xmm1 = vabsq_s16(rxF[i]);
    xmm1 = vsubq_s16(ch_mag[i],xmm1);
    xmm2 = vabsq_s16(xmm1);
    xmm2 = vsubq_s16(ch_magb[i],xmm2);
#endif
1124
1125
    // loop over all LLRs in quad word (24 coded bits)
    /*
1126
1127
1128
1129
1130
1131
1132
1133
      for (j=0;j<8;j+=2) {
      llr2[0] = ((short *)&rxF[i])[j];
      llr2[1] = ((short *)&rxF[i])[j+1];
      llr2[2] = ((short *)&xmm1)[j];
      llr2[3] = ((short *)&xmm1)[j+1];
      llr2[4] = ((short *)&xmm2)[j];
      llr2[5] = ((short *)&xmm2)[j+1];

Elena Lukashova's avatar
Elena Lukashova committed
1134
     llr2+=6;
1135
      }
1136
1137
1138
    */
    llr2[0] = ((short *)&rxF[i])[0];
    llr2[1] = ((short *)&rxF[i])[1];
1139
#if defined(__x86_64__) || defined(__i386__)
1140
1141
1142
1143
    llr2[2] = _mm_extract_epi16(xmm1,0);
    llr2[3] = _mm_extract_epi16(xmm1,1);//((short *)&xmm1)[j+1];
    llr2[4] = _mm_extract_epi16(xmm2,0);//((short *)&xmm2)[j];
    llr2[5] = _mm_extract_epi16(xmm2,1);//((short *)&xmm2)[j+1];
1144
1145
1146
1147
1148
1149
#elif defined(__arm__)
    llr2[2] = vgetq_lane_s16(xmm1,0);
    llr2[3] = vgetq_lane_s16(xmm1,1);//((short *)&xmm1)[j+1];
    llr2[4] = vgetq_lane_s16(xmm2,0);//((short *)&xmm2)[j];
    llr2[5] = vgetq_lane_s16(xmm2,1);//((short *)&xmm2)[j+1];
#endif
1150
1151
1152
1153

    llr2+=6;
    llr2[0] = ((short *)&rxF[i])[2];
    llr2[1] = ((short *)&rxF[i])[3];
1154
#if defined(__x86_64__) || defined(__i386__)
1155
1156
1157
1158
    llr2[2] = _mm_extract_epi16(xmm1,2);
    llr2[3] = _mm_extract_epi16(xmm1,3);//((short *)&xmm1)[j+1];
    llr2[4] = _mm_extract_epi16(xmm2,2);//((short *)&xmm2)[j];
    llr2[5] = _mm_extract_epi16(xmm2,3);//((short *)&xmm2)[j+1];
1159
1160
1161
1162
1163
1164
#elif defined(__arm__)
    llr2[2] = vgetq_lane_s16(xmm1,2);
    llr2[3] = vgetq_lane_s16(xmm1,3);//((short *)&xmm1)[j+1];
    llr2[4] = vgetq_lane_s16(xmm2,2);//((short *)&xmm2)[j];
    llr2[5] = vgetq_lane_s16(xmm2,3);//((short *)&xmm2)[j+1];
#endif
1165
1166
1167
1168

    llr2+=6;
    llr2[0] = ((short *)&rxF[i])[4];
    llr2[1] = ((short *)&rxF[i])[5];
1169
#if defined(__x86_64__) || defined(__i386__)
1170
1171
1172
1173
    llr2[2] = _mm_extract_epi16(xmm1,4);
    llr2[3] = _mm_extract_epi16(xmm1,5);//((short *)&xmm1)[j+1];
    llr2[4] = _mm_extract_epi16(xmm2,4);//((short *)&xmm2)[j];
    llr2[5] = _mm_extract_epi16(xmm2,5);//((short *)&xmm2)[j+1];
1174
1175
1176
1177
1178
1179
#elif defined(__arm__)
    llr2[2] = vgetq_lane_s16(xmm1,4);
    llr2[3] = vgetq_lane_s16(xmm1,5);//((short *)&xmm1)[j+1];
    llr2[4] = vgetq_lane_s16(xmm2,4);//((short *)&xmm2)[j];
    llr2[5] = vgetq_lane_s16(xmm2,5);//((short *)&xmm2)[j+1];
#endif
1180
1181
1182
    llr2+=6;
    llr2[0] = ((short *)&rxF[i])[6];
    llr2[1] = ((short *)&rxF[i])[7];
1183
#if defined(__x86_64__) || defined(__i386__)
1184
1185
1186
1187
    llr2[2] = _mm_extract_epi16(xmm1,6);
    llr2[3] = _mm_extract_epi16(xmm1,7);//((short *)&xmm1)[j+1];
    llr2[4] = _mm_extract_epi16(xmm2,6);//((short *)&xmm2)[j];
    llr2[5] = _mm_extract_epi16(xmm2,7);//((short *)&xmm2)[j+1];
1188
1189
1190
1191
1192
1193
#elif defined(__arm__)
    llr2[2] = vgetq_lane_s16(xmm1,6);
    llr2[3] = vgetq_lane_s16(xmm1,7);//((short *)&xmm1)[j+1];
    llr2[4] = vgetq_lane_s16(xmm2,6);//((short *)&xmm2)[j];
    llr2[5] = vgetq_lane_s16(xmm2,7);//((short *)&xmm2)[j+1];
#endif
1194
1195
1196
1197
1198
    llr2+=6;

  }

  *llr_save = llr;
1199
#if defined(__x86_64__) || defined(__i386__)
1200
1201
  _mm_empty();
  _m_empty();
1202
#endif
1203
1204
}

1205
//#if 0
Elena Lukashova's avatar
Elena Lukashova committed
1206
void dlsch_64qam_llr_SIC(LTE_DL_FRAME_PARMS *frame_parms,
Elena Lukashova's avatar
Elena Lukashova committed
1207
                         int32_t **rxdataF_comp,
Elena Lukashova's avatar
Elena Lukashova committed
1208
1209
1210
1211
1212
1213
1214
1215
1216
                         int32_t **sic_buffer,  //Q15
                         int32_t **rho_i,
                         int16_t *dlsch_llr,
                         uint8_t num_pdcch_symbols,
                         int32_t **dl_ch_mag,
                         int32_t **dl_ch_magb,
                         uint16_t nb_rb,
                         uint8_t subframe,
                         uint32_t rb_alloc,
1217
                         uint16_t mod_order_0,
Elena Lukashova's avatar
Elena Lukashova committed
1218
1219
                         LTE_UE_DLSCH_t *dlsch0
                         )
Elena Lukashova's avatar
Elena Lukashova committed
1220
{
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
  int16_t rho_amp_x0[2*frame_parms->N_RB_DL*12];
  int16_t rho_rho_amp_x0[2*frame_parms->N_RB_DL*12];
  uint16_t amp_tmp;
  uint16_t *llr32=(uint16_t*)dlsch_llr;
  int i, len,  nsymb, len2;
  uint8_t symbol, symbol_mod;
  int len_acc=0;
  uint16_t *sic_data;
  uint16_t pbch_pss_sss_adjust;
  unsigned char len_mod4=0;
1231
  uint16_t *llr2;
1232
  __m128i *ch_mag,*ch_magb;
1233

Elena Lukashova's avatar
Elena Lukashova committed
1234
  nsymb = (frame_parms->Ncp==0) ? 14:12;
Elena Lukashova's avatar
Elena Lukashova committed
1235

1236
1237
1238
1239
1240
  for (symbol=num_pdcch_symbols; symbol<nsymb; symbol++) {
    uint16_t *rxF = (uint16_t*)(&rxdataF_comp[0][((int16_t)symbol*frame_parms->N_RB_DL*12)]);
    int16_t *rho_1=(int16_t*)(&rho_i[0][((int16_t)symbol*frame_parms->N_RB_DL*12)]);
    ch_mag = (__m128i*)(&dl_ch_mag[0][((int16_t)symbol*frame_parms->N_RB_DL*12)]);
    ch_magb = (__m128i*)(&dl_ch_magb[0][((int16_t)symbol*frame_parms->N_RB_DL*12)]);
1241
1242
    sic_data = (uint16_t*)(&sic_buffer[0][((int16_t)len_acc)]);

1243
    symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
Elena Lukashova's avatar
Elena Lukashova committed
1244

1245
1246
    pbch_pss_sss_adjust=adjust_G2(frame_parms,&rb_alloc,6,subframe,symbol);

Elena Lukashova's avatar
Elena Lukashova committed
1247
    if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
1248

Elena Lukashova's avatar
Elena Lukashova committed
1249
1250
1251
1252
1253
      amp_tmp = dlsch0->sqrt_rho_b;
          if (frame_parms->mode1_flag==0)
            len = nb_rb*8 - (2*pbch_pss_sss_adjust/3);
          else
            len = nb_rb*10 - (5*pbch_pss_sss_adjust/6);
1254
      } else {
1255

Elena Lukashova's avatar
Elena Lukashova committed
1256
1257
          amp_tmp = dlsch0->sqrt_rho_a;
          len = nb_rb*12 - pbch_pss_sss_adjust;
1258
      }
1259

1260
      if (mod_order_0==6)
1261
        amp_tmp=amp_tmp<<1; // to compensate for >> 1 shift in modulation
1262

1263
    len_acc+=len;
1264

1265
    multadd_complex_vector_real_scalar((int16_t *)sic_data,
Elena Lukashova's avatar
Elena Lukashova committed
1266
1267
1268
1269
                                        amp_tmp,
                                        (int16_t *)rho_amp_x0, //this is in Q13
                                        1,
                                        len);
1270

1271
1272
1273
1274
1275
     mult_cpx_vector((int16_t *)rho_1, //Q15
                    (int16_t *)rho_amp_x0, //Q13
                    (int16_t*)rho_rho_amp_x0,
                    len,
                    13);
1276

1277
     sub_cpx_vector16((int16_t *)rxF,
Elena Lukashova's avatar
Elena Lukashova committed
1278
1279
1280
1281
                      (int16_t *)rho_rho_amp_x0,
                      //(int16_t *)clean_x1,
                      (int16_t *)rxF,
                      len*2);
Elena Lukashova's avatar
Elena Lukashova committed
1282

1283
1284
  llr2 = llr32;
  llr32 += (len*6);
Elena Lukashova's avatar
Elena Lukashova committed
1285
1286
1287
1288

  len_mod4 =len&3;
  len2=len>>2;  // length in quad words (4 REs)
  len2+=(len_mod4?0:1);
1289
1290


Elena Lukashova's avatar
Elena Lukashova committed
1291
1292

  for (i=0; i<len2; i++) {
1293