dlsch_llr_computation.c 440 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

Elena Lukashova's avatar
Elena Lukashova committed
40 41 42
//#define DEBUG_LLR_SIC


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 596 597 598
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)));
599 600 601 602 603


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

604
// calculates psi_a = psi_r*a_r + psi_i*a_i
605 606 607
#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
608
#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);
609 610

// calculate interference magnitude
611 612
// 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);
613

614
// calculates a_sq = int_ch_mag*(a_r^2 + a_i^2)*scale_factor
615 616 617 618 619
#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);

620 621 622 623
#elif defined(__arm__)

#endif

624 625 626 627 628 629 630 631 632
//==============================================================================================
// SINGLE-STREAM
//==============================================================================================

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

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

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

  if (first_symbol_flag==1) {
649 650 651
    llr32 = (uint32_t*)dlsch_llr;
  } else {
    llr32 = (uint32_t*)(*llr32p);
652
  }
653

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


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

673

674 675
  //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);
676 677
  for (i=0; i<len; i++) {
    *llr32 = *rxF;
678
     //printf("llr %d : (%d,%d)\n",i,((int16_t*)llr32)[0],((int16_t*)llr32)[1]);
679 680
    rxF++;
    llr32++;
681 682
  }

683
  *llr32p = (int16_t *)llr32;
684 685 686 687

  return(0);
}

Elena Lukashova's avatar
Elena Lukashova committed
688
int32_t dlsch_qpsk_llr_SIC(LTE_DL_FRAME_PARMS *frame_parms,
Elena Lukashova's avatar
Elena Lukashova committed
689
                           int32_t **rxdataF_comp,
Elena Lukashova's avatar
Elena Lukashova committed
690 691
                           int32_t **sic_buffer,  //Q15
                           int32_t **rho_i,
Elena Lukashova's avatar
Elena Lukashova committed
692
                           short *dlsch_llr,
Elena Lukashova's avatar
Elena Lukashova committed
693
                           uint8_t num_pdcch_symbols,
Elena Lukashova's avatar
Elena Lukashova committed
694
                           uint16_t nb_rb,
Elena Lukashova's avatar
Elena Lukashova committed
695
                           uint8_t subframe,
696
                           uint32_t rb_alloc)
Elena Lukashova's avatar
Elena Lukashova committed
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;
  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

Elena Lukashova's avatar
Elena Lukashova committed
721 722 723 724
    if ((symbol_mod == 0) || (symbol_mod == (4-frame_parms->Ncp))) //pilots=1
      amp_tmp=0x1fff;//dlsch0->sqrt_rho_b; already taken into account
    else //pilots=0
      amp_tmp=0x1fff;//1.5*dlsch0->sqrt_rho_a; already taken into account
725

726

727
    pbch_pss_sss_adjust=adjust_G2(frame_parms,&rb_alloc,2,subframe,symbol);
Elena Lukashova's avatar
Elena Lukashova committed
728 729 730 731 732 733 734 735 736

    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;
    }
737

738
   //  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
739 740

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

Elena Lukashova's avatar
Elena Lukashova committed
742
    multadd_complex_vector_real_scalar((int16_t *)sic_data,
Elena Lukashova's avatar
Elena Lukashova committed
743 744 745 746
                                       amp_tmp,
                                       (int16_t *)rho_amp_x0, //this is in Q13
                                       1,
                                       len);
747

748 749
    mult_cpx_vector((int16_t *)rho_1, //Q15
                    (int16_t *)rho_amp_x0, //Q13
Elena Lukashova's avatar
Elena Lukashova committed
750 751
                    (int16_t*)rho_rho_amp_x0,
                    len,
752
                    13);
Elena Lukashova's avatar
Elena Lukashova committed
753 754 755

#ifdef DEBUG_LLR_SIC
    write_output("rho_for_multipl.m","rho_for_m", rho_1,len,1,
Elena Lukashova's avatar
Elena Lukashova committed
756
     symbol==num_pdcch_symbols ? 15 :
757
     symbol==nsymb-1 ? 14 : 13);
758 759

    write_output("rho_rho_in_llr.m","rho2", rho_rho_amp_x0,len,1,
Elena Lukashova's avatar
Elena Lukashova committed
760 761
     symbol==num_pdcch_symbols ? 15 :
     symbol==nsymb-1 ? 14 : 13);
Elena Lukashova's avatar
Elena Lukashova committed
762
#endif
763

Elena Lukashova's avatar
Elena Lukashova committed
764
    sub_cpx_vector16((int16_t *)rxF,
Elena Lukashova's avatar
Elena Lukashova committed
765 766 767
                     (int16_t *)rho_rho_amp_x0,
                     //(int16_t *)clean_x1,
                     (int16_t *)rxF,
768
                     len*2);
Elena Lukashova's avatar
Elena Lukashova committed
769

Elena Lukashova's avatar
Elena Lukashova committed
770 771 772 773 774 775
#ifdef DEBUG_LLR_SIC
    write_output("rxFdata_comp1_after.m","rxF_a", rxF,len,1,1);
    write_output("rxF_comp1.m","rxF_1_comp", rxF,len,1,
                 symbol==num_pdcch_symbols ? 15 :
                 symbol==nsymb-1 ? 14 : 13);
#endif
776

Elena Lukashova's avatar
Elena Lukashova committed
777 778
    //this is for QPSK only!!!
    for (i=0; i<len*2; i++) {
Elena Lukashova's avatar
Elena Lukashova committed
779
      *llr16 =rxF[i];
Elena Lukashova's avatar
Elena Lukashova committed
780 781 782
      //printf("llr %d : (%d,%d)\n",i,((int16_t*)llr32)[0],((int16_t*)llr32)[1]);
      llr16++;
    }
783

Elena Lukashova's avatar
Elena Lukashova committed
784 785
  }

786
 // printf("dlsch_qpsk_llr_SIC: acc_len=%d\n",len_acc);
Elena Lukashova's avatar
Elena Lukashova committed
787 788 789 790 791

  return(0);
}


792 793 794 795 796
//----------------------------------------------------------------------------------------------
// 16-QAM
//----------------------------------------------------------------------------------------------

void dlsch_16qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
797 798 799 800
                     int32_t **rxdataF_comp,
                     int16_t *dlsch_llr,
                     int32_t **dl_ch_mag,
                     uint8_t symbol,
gauthier's avatar
gauthier committed
801
                     uint8_t first_symbol_flag,
802
                     uint16_t nb_rb,
gauthier's avatar
gauthier committed
803
                     uint16_t pbch_pss_sss_adjust,
804 805
                     int16_t **llr32p,
                     uint8_t beamforming_mode)
806 807
{

808
#if defined(__x86_64__) || defined(__i386__)
809 810 811
  __m128i *rxF = (__m128i*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)];
  __m128i *ch_mag;
  __m128i llr128[2];
812 813 814 815 816 817 818 819 820
  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


821 822 823 824
  int i,len;
  unsigned char symbol_mod,len_mod4=0;


Elena Lukashova's avatar
Elena Lukashova committed
825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847
#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)
848
      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
Elena Lukashova's avatar
Elena Lukashova committed
849
    else
850 851 852 853 854
      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
855
  } else {
856
    len = (nb_rb*12) - pbch_pss_sss_adjust;
Elena Lukashova's avatar
Elena Lukashova committed
857 858 859 860 861 862 863 864
  }

  // 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);

865
 // printf("len=%d\n", len);
Elena Lukashova's avatar
Elena Lukashova committed
866
  len_mod4 = len&3;
867
 // printf("len_mod4=%d\n", len_mod4);
Elena Lukashova's avatar
Elena Lukashova committed
868
  len>>=2;  // length in quad words (4 REs)
869
 // printf("len>>=2=%d\n", len);
Elena Lukashova's avatar
Elena Lukashova committed
870
  len+=(len_mod4==0 ? 0 : 1);
871
 // printf("len+=%d\n", len);
Elena Lukashova's avatar
Elena Lukashova committed
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 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
  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
}

922
void dlsch_16qam_llr_SIC (LTE_DL_FRAME_PARMS *frame_parms,
Elena Lukashova's avatar
Elena Lukashova committed
923
                          int32_t **rxdataF_comp,
Elena Lukashova's avatar
Elena Lukashova committed
924 925 926 927 928 929 930
                          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,
931
                          uint32_t rb_alloc)
Elena Lukashova's avatar
Elena Lukashova committed
932
{
933 934 935 936 937 938 939 940 941 942
  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;
  int len_acc=0;
  uint16_t *sic_data;
  uint16_t pbch_pss_sss_adjust;
  unsigned char len_mod4=0;
943 944
  __m128i llr128[2];
  __m128i *ch_mag;
945
  nsymb = (frame_parms->Ncp==0) ? 14:12;
Elena Lukashova's avatar
Elena Lukashova committed
946

947 948 949 950
    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)]);
951 952
    sic_data = (uint16_t*)(&sic_buffer[0][((int16_t)len_acc)]);

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

955 956
    pbch_pss_sss_adjust=adjust_G2(frame_parms,&rb_alloc,4,subframe,symbol);

Elena Lukashova's avatar
Elena Lukashova committed
957 958 959 960 961 962 963 964 965 966
    if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
      amp_tmp=0x1fff;//dlsch0->sqrt_rho_b; already taken into account
      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 {
      amp_tmp=0x1fff;;//dlsch0->sqrt_rho_a; already taken into account
      len = nb_rb*12 - pbch_pss_sss_adjust;
    }
967

968
    len_acc+=len;
969

970
    multadd_complex_vector_real_scalar((int16_t *)sic_data,
Elena Lukashova's avatar
Elena Lukashova committed
971 972 973 974
                                       amp_tmp,
                                       (int16_t *)rho_amp_x0, //this is in Q13
                                       1,
                                       len);
975

976 977 978 979 980
     mult_cpx_vector((int16_t *)rho_1, //Q15
                    (int16_t *)rho_amp_x0, //Q13
                    (int16_t*)rho_rho_amp_x0,
                    len,
                    13);
981

982
     sub_cpx_vector16((int16_t *)rxF,
Elena Lukashova's avatar
Elena Lukashova committed
983 984 985
                      (int16_t *)rho_rho_amp_x0,
                      //(int16_t *)clean_x1,
                      (int16_t *)rxF,
986
                      len*2);
987

988 989 990 991 992
    len_mod4 = len&3;
    len>>=2;  // length in quad words (4 REs)
    len+=(len_mod4==0 ? 0 : 1);

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

994 995 996 997 998 999

    __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);
1000
    xmm0 = _mm_abs_epi16(x1[i]);
1001 1002 1003
    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
1004 1005
    llr128[0] = _mm_unpacklo_epi32(x1[i],xmm0);
    llr128[1] = _mm_unpackhi_epi32(x1[i],xmm0);
1006 1007 1008 1009 1010 1011 1012 1013 1014
    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;
1015

1016 1017 1018 1019
  }
  _mm_empty();
  _m_empty();
}
1020
}
1021 1022 1023 1024 1025 1026

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

void dlsch_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
1027 1028 1029 1030 1031
                     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
1032
                     uint8_t first_symbol_flag,
1033
                     uint16_t nb_rb,
gauthier's avatar
gauthier committed
1034
                     uint16_t pbch_pss_sss_adjust,
1035
                     int16_t **llr_save,
1036
                     uint8_t beamforming_mode)
1037
{
1038
#if defined(__x86_64__) || defined(__i386__)
1039 1040
  __m128i *rxF = (__m128i*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)];
  __m128i *ch_mag,*ch_magb;
1041 1042 1043 1044
#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
1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056
  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;

1057
#if defined(__x86_64__) || defined(__i386__)
1058 1059
  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)];
1060 1061 1062 1063
#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
1064 1065
  if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
    if (frame_parms->mode1_flag==0)
1066
      len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
1067
    else
1068 1069 1070 1071 1072
      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);
1073
  } else {
1074
    len = (nb_rb*12) - pbch_pss_sss_adjust;
1075 1076 1077 1078 1079 1080 1081
  }

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

  len_mod4 =len&3;
  len2=len>>2;  // length in quad words (4 REs)
knopp's avatar
knopp committed
1082
  len2+=((len_mod4==0)?0:1);
1083 1084 1085

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

1086
#if defined(__x86_64__) || defined(__i386__)
1087 1088 1089 1090
    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);
1091 1092 1093 1094 1095 1096
#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
1097 1098
    // loop over all LLRs in quad word (24 coded bits)
    /*
1099 1100 1101 1102 1103 1104 1105 1106
      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
1107
     llr2+=6;
1108
      }
1109 1110 1111
    */
    llr2[0] = ((short *)&rxF[i])[0];
    llr2[1] = ((short *)&rxF[i])[1];
1112
#if defined(__x86_64__) || defined(__i386__)
1113 1114 1115 1116
    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];
1117 1118 1119 1120 1121 1122
#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
1123 1124 1125 1126

    llr2+=6;
    llr2[0] = ((short *)&rxF[i])[2];
    llr2[1] = ((short *)&rxF[i])[3];
1127
#if defined(__x86_64__) || defined(__i386__)
1128 1129 1130 1131
    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];
1132 1133 1134 1135 1136 1137
#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
1138 1139 1140 1141

    llr2+=6;
    llr2[0] = ((short *)&rxF[i])[4];
    llr2[1] = ((short *)&rxF[i])[5];
1142
#if defined(__x86_64__) || defined(__i386__)
1143 1144 1145 1146
    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];
1147 1148 1149 1150 1151 1152
#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
1153 1154 1155
    llr2+=6;
    llr2[0] = ((short *)&rxF[i])[6];
    llr2[1] = ((short *)&rxF[i])[7];
1156
#if defined(__x86_64__) || defined(__i386__)
1157 1158 1159 1160
    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];
1161 1162 1163 1164 1165 1166
#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
1167 1168 1169 1170 1171
    llr2+=6;

  }

  *llr_save = llr;
1172
#if defined(__x86_64__) || defined(__i386__)
1173 1174
  _mm_empty();
  _m_empty();
1175
#endif
1176 1177
}

1178
//#if 0
Elena Lukashova's avatar
Elena Lukashova committed
1179
void dlsch_64qam_llr_SIC(LTE_DL_FRAME_PARMS *frame_parms,
Elena Lukashova's avatar
Elena Lukashova committed
1180
                         int32_t **rxdataF_comp,
Elena Lukashova's avatar
Elena Lukashova committed
1181 1182 1183 1184 1185 1186 1187 1188
                         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,
1189
                         uint32_t rb_alloc)
Elena Lukashova's avatar
Elena Lukashova committed
1190
{
1191 1192 1193 1194 1195 1196 1197 1198 1199 1200
  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;
1201
  uint16_t *llr2;
1202
  __m128i *ch_mag,*ch_magb;
1203

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

1206 1207 1208 1209 1210
  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)]);
1211 1212
    sic_data = (uint16_t*)(&sic_buffer[0][((int16_t)len_acc)]);

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

1215 1216
    pbch_pss_sss_adjust=adjust_G2(frame_parms,&rb_alloc,6,subframe,symbol);

Elena Lukashova's avatar
Elena Lukashova committed
1217
    if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
Elena Lukashova's avatar
Elena Lukashova committed
1218 1219 1220 1221 1222
      amp_tmp = 0x1fff;//dlsch0->sqrt_rho_b; already taken into account
      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);
1223
      } else {
Elena Lukashova's avatar
Elena Lukashova committed
1224 1225
        amp_tmp = 0x1fff; //dlsch0->sqrt_rho_a; already taken into account
        len = nb_rb*12 - pbch_pss_sss_adjust;
1226
      }
1227

1228
    len_acc+=len;
1229