transport_proto_ue.h 77.7 KB
Newer Older
1 2 3 4 5
/*
 * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The OpenAirInterface Software Alliance licenses this file to You under
6
 * the OAI Public License, Version 1.1  (the "License"); you may not use this file
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 * 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
 */

22
/*! \file PHY/LTE_UE_TRANSPORT/transport_proto_ue.h
23 24 25 26 27 28 29 30 31
 * \brief Function prototypes for PHY physical/transport channel processing and generation V8.6 2009-03
 * \author R. Knopp, F. Kaltenberger
 * \date 2011
 * \version 0.1
 * \company Eurecom
 * \email: knopp@eurecom.fr
 * \note
 * \warning
 */
32 33 34
#ifndef __LTE_TRANSPORT_PROTO_UE__H__
#define __LTE_TRANSPORT_PROTO_UE__H__
#include "PHY/defs_UE.h"
35
#include "PHY/LTE_TRANSPORT/transport_common_proto.h"
36
#include <math.h>
37
#include "nfapi_interface.h"
38 39 40 41 42 43 44 45 46 47 48 49 50

// Functions below implement 36-211 and 36-212

/** @addtogroup _PHY_TRANSPORT_
 * @{
 */

/** \fn free_ue_dlsch(LTE_UE_DLSCH_t *dlsch)
    \brief This function frees memory allocated for a particular DLSCH at UE
    @param dlsch Pointer to DLSCH to be removed
*/
void free_ue_dlsch(LTE_UE_DLSCH_t *dlsch);

51
/** \fn new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t abstraction_flag)
52
    \brief This function allocates structures for a particular DLSCH at UE
53 54 55 56 57 58 59 60
    @returns Pointer to DLSCH to be removed
    @param Kmimo Kmimo factor from 36-212/36-213
    @param Mdlharq Maximum number of HARQ rounds (36-212/36-213)
    @param Nsoft Soft-LLR buffer size from UE-Category
    @params N_RB_DL total number of resource blocks (determine the operating BW)
    @param abstraction_flag Flag to indicate abstracted interface
*/
LTE_UE_DLSCH_t *new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_turbo_iterations,uint8_t N_RB_DL, uint8_t abstraction_flag);
61 62 63 64 65


void free_ue_ulsch(LTE_UE_ULSCH_t *ulsch);


66
LTE_UE_ULSCH_t *new_ue_ulsch(unsigned char N_RB_UL, uint8_t abstraction_flag);
67

68
void fill_UE_dlsch_MCH(PHY_VARS_UE *ue,int mcs,int ndi,int rvidx,int eNB_id);
69 70

int rx_pmch(PHY_VARS_UE *phy_vars_ue,
71 72 73
            unsigned char eNB_id,
            uint8_t subframe,
            unsigned char symbol);
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91

/** \brief Dump OCTAVE/MATLAB files for PMCH debugging
    @param phy_vars_ue Pointer to UE variables
    @param eNB_id index of eNB in ue variables
    @param coded_bits_per_codeword G from 36.211
    @param subframe Index of subframe
    @returns 0 on success
*/
void dump_mch(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint16_t coded_bits_per_codeword,int subframe);



/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream QPSK/QPSK reception.
    @param stream0_in Input from channel compensated (MR combined) stream 0
    @param stream1_in Input from channel compensated (MR combined) stream 1
    @param stream0_out Output from LLR unit for stream0
    @param rho01 Cross-correlation between channels (MR combined)
    @param length in complex channel outputs*/
92
void qpsk_qpsk(int16_t *stream0_in,
93 94 95 96
               int16_t *stream1_in,
               int16_t *stream0_out,
               int16_t *rho01,
               int32_t length);
97 98 99 100 101 102 103 104 105 106 107 108

/** \brief This function perform LLR computation for dual-stream (QPSK/QPSK) transmission.
    @param frame_parms Frame descriptor structure
    @param rxdataF_comp Compensated channel output
    @param rxdataF_comp_i Compensated channel output for interference
    @param rho_i Correlation between channel of signal and inteference
    @param dlsch_llr llr output
    @param symbol OFDM symbol index in sub-frame
    @param first_symbol_flag flag to indicate this is the first symbol of the dlsch
    @param nb_rb number of RBs for this allocation
    @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS
    @param llr128p pointer to pointer to symbol in dlsch_llr*/
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124

void qpsk_llr(int16_t *stream0_in,
              int16_t *stream0_out,
              int length);

void qam16_llr(int16_t *stream0_in,
               int16_t *chan_magn,
               int16_t *llr,
               int length);

void qam64_llr(int16_t *stream0_in,
               int16_t *chan_magn,
               int16_t *chan_magn_b,
               int16_t *llr,
               int length);

125
int32_t dlsch_qpsk_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms,
126 127 128 129 130 131 132 133 134
                            int32_t **rxdataF_comp,
                            int32_t **rxdataF_comp_i,
                            int32_t **rho_i,
                            int16_t *dlsch_llr,
                            uint8_t symbol,
                            uint8_t first_symbol_flag,
                            uint16_t nb_rb,
                            uint16_t pbch_pss_sss_adj,
                            int16_t **llr128p);
135 136 137 138 139 140 141 142

/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream QPSK/16QAM reception.
    @param stream0_in Input from channel compensated (MR combined) stream 0
    @param stream1_in Input from channel compensated (MR combined) stream 1
    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
    @param stream0_out Output from LLR unit for stream0
    @param rho01 Cross-correlation between channels (MR combined)
    @param length in complex channel outputs*/
143 144
void qpsk_qam16(int16_t *stream0_in,
                int16_t *stream1_in,
145
                short *ch_mag_i,
146 147 148
                int16_t *stream0_out,
                int16_t *rho01,
                int32_t length);
149 150 151 152 153 154 155 156 157 158 159 160

/** \brief This function perform LLR computation for dual-stream (QPSK/16QAM) transmission.
    @param frame_parms Frame descriptor structure
    @param rxdataF_comp Compensated channel output
    @param rxdataF_comp_i Compensated channel output for interference
    @param rho_i Correlation between channel of signal and inteference
    @param dlsch_llr llr output
    @param symbol OFDM symbol index in sub-frame
    @param first_symbol_flag flag to indicate this is the first symbol of the dlsch
    @param nb_rb number of RBs for this allocation
    @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS
    @param llr128p pointer to pointer to symbol in dlsch_llr*/
161
int32_t dlsch_qpsk_16qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
162 163 164 165 166 167 168 169 170 171
                             int32_t **rxdataF_comp,
                             int32_t **rxdataF_comp_i,
                             int **dl_ch_mag_i, //|h_1|^2*(2/sqrt{10})
                             int32_t **rho_i,
                             int16_t *dlsch_llr,
                             uint8_t symbol,
                             uint8_t first_symbol_flag,
                             uint16_t nb_rb,
                             uint16_t pbch_pss_sss_adj,
                             int16_t **llr128p);
172 173 174 175 176 177 178 179

/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream QPSK/64QAM reception.
    @param stream0_in Input from channel compensated (MR combined) stream 0
    @param stream1_in Input from channel compensated (MR combined) stream 1
    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
    @param stream0_out Output from LLR unit for stream0
    @param rho01 Cross-correlation between channels (MR combined)
    @param length in complex channel outputs*/
180 181
void qpsk_qam64(int16_t *stream0_in,
                int16_t *stream1_in,
182
                short *ch_mag_i,
183 184 185
                int16_t *stream0_out,
                int16_t *rho01,
                int32_t length);
186 187 188 189 190 191 192 193 194 195 196 197

/** \brief This function perform LLR computation for dual-stream (QPSK/64QAM) transmission.
    @param frame_parms Frame descriptor structure
    @param rxdataF_comp Compensated channel output
    @param rxdataF_comp_i Compensated channel output for interference
    @param rho_i Correlation between channel of signal and inteference
    @param dlsch_llr llr output
    @param symbol OFDM symbol index in sub-frame
    @param first_symbol_flag flag to indicate this is the first symbol of the dlsch
    @param nb_rb number of RBs for this allocation
    @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS
    @param llr128p pointer to pointer to symbol in dlsch_llr*/
198
int32_t dlsch_qpsk_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
199 200 201 202 203 204 205 206 207 208
                             int32_t **rxdataF_comp,
                             int32_t **rxdataF_comp_i,
                             int **dl_ch_mag_i, //|h_1|^2*(2/sqrt{10})
                             int32_t **rho_i,
                             int16_t *dlsch_llr,
                             uint8_t symbol,
                             uint8_t first_symbol_flag,
                             uint16_t nb_rb,
                             uint16_t pbch_pss_sss_adj,
                             int16_t **llr128p);
209 210 211 212 213 214 215 216 217 218 219 220 221 222


/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 16QAM/QPSK reception.
    @param stream0_in Input from channel compensated (MR combined) stream 0
    @param stream1_in Input from channel compensated (MR combined) stream 1
    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
    @param stream0_out Output from LLR unit for stream0
    @param rho01 Cross-correlation between channels (MR combined)
    @param length in complex channel outputs*/
void qam16_qpsk(short *stream0_in,
                short *stream1_in,
                short *ch_mag,
                short *stream0_out,
                short *rho01,
223
                int length);
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
/** \brief This function perform LLR computation for dual-stream (16QAM/QPSK) transmission.
    @param frame_parms Frame descriptor structure
    @param rxdataF_comp Compensated channel output
    @param rxdataF_comp_i Compensated channel output for interference
    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
    @param rho_i Correlation between channel of signal and inteference
    @param dlsch_llr llr output
    @param symbol OFDM symbol index in sub-frame
    @param first_symbol_flag flag to indicate this is the first symbol of the dlsch
    @param nb_rb number of RBs for this allocation
    @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS
    @param llr16p pointer to pointer to symbol in dlsch_llr*/
int dlsch_16qam_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms,
                         int **rxdataF_comp,
                         int **rxdataF_comp_i,
                         int **dl_ch_mag,   //|h_0|^2*(2/sqrt{10})
                         int **rho_i,
                         short *dlsch_llr,
                         unsigned char symbol,
                         unsigned char first_symbol_flag,
                         unsigned short nb_rb,
                         uint16_t pbch_pss_sss_adjust,
                         short **llr16p);

/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 16QAM/16QAM reception.
    @param stream0_in Input from channel compensated (MR combined) stream 0
    @param stream1_in Input from channel compensated (MR combined) stream 1
    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
    @param stream0_out Output from LLR unit for stream0
    @param rho01 Cross-correlation between channels (MR combined)
    @param length in complex channel outputs*/
void qam16_qam16(short *stream0_in,
                 short *stream1_in,
                 short *ch_mag,
                 short *ch_mag_i,
                 short *stream0_out,
                 short *rho01,
                 int length);

/** \brief This function perform LLR computation for dual-stream (16QAM/16QAM) transmission.
    @param frame_parms Frame descriptor structure
    @param rxdataF_comp Compensated channel output
    @param rxdataF_comp_i Compensated channel output for interference
    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
    @param rho_i Correlation between channel of signal and inteference
    @param dlsch_llr llr output
    @param symbol OFDM symbol index in sub-frame
    @param first_symbol_flag flag to indicate this is the first symbol of the dlsch
    @param nb_rb number of RBs for this allocation
    @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS
    @param llr16p pointer to pointer to symbol in dlsch_llr*/
int dlsch_16qam_16qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
                          int **rxdataF_comp,
                          int **rxdataF_comp_i,
                          int **dl_ch_mag,   //|h_0|^2*(2/sqrt{10})
                          int **dl_ch_mag_i, //|h_1|^2*(2/sqrt{10})
                          int **rho_i,
                          short *dlsch_llr,
                          unsigned char symbol,
                          unsigned char first_symbol_flag,
                          unsigned short nb_rb,
                          uint16_t pbch_pss_sss_adjust,
                          short **llr16p);

/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 16QAM/64QAM reception.
    @param stream0_in Input from channel compensated (MR combined) stream 0
    @param stream1_in Input from channel compensated (MR combined) stream 1
    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
    @param stream0_out Output from LLR unit for stream0
    @param rho01 Cross-correlation between channels (MR combined)
    @param length in complex channel outputs*/
void qam16_qam64(short *stream0_in,
                 short *stream1_in,
                 short *ch_mag,
                 short *ch_mag_i,
                 short *stream0_out,
                 short *rho01,
                 int length);

/** \brief This function perform LLR computation for dual-stream (16QAM/64QAM) transmission.
    @param frame_parms Frame descriptor structure
    @param rxdataF_comp Compensated channel output
    @param rxdataF_comp_i Compensated channel output for interference
    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
    @param rho_i Correlation between channel of signal and inteference
    @param dlsch_llr llr output
    @param symbol OFDM symbol index in sub-frame
    @param first_symbol_flag flag to indicate this is the first symbol of the dlsch
    @param nb_rb number of RBs for this allocation
    @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS
    @param llr16p pointer to pointer to symbol in dlsch_llr*/
int dlsch_16qam_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
                          int **rxdataF_comp,
                          int **rxdataF_comp_i,
                          int **dl_ch_mag,   //|h_0|^2*(2/sqrt{10})
                          int **dl_ch_mag_i, //|h_1|^2*(2/sqrt{10})
                          int **rho_i,
                          short *dlsch_llr,
                          unsigned char symbol,
                          unsigned char first_symbol_flag,
                          unsigned short nb_rb,
                          uint16_t pbch_pss_sss_adjust,
                          short **llr16p);

/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 64QAM/64QAM reception.
    @param stream0_in Input from channel compensated (MR combined) stream 0
    @param stream1_in Input from channel compensated (MR combined) stream 1
    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
    @param stream0_out Output from LLR unit for stream0
    @param rho01 Cross-correlation between channels (MR combined)
    @param length in complex channel outputs*/
void qam64_qpsk(short *stream0_in,
                short *stream1_in,
                short *ch_mag,
                short *stream0_out,
                short *rho01,
                int length);

/** \brief This function perform LLR computation for dual-stream (64QAM/64QAM) transmission.
    @param frame_parms Frame descriptor structure
    @param rxdataF_comp Compensated channel output
    @param rxdataF_comp_i Compensated channel output for interference
    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
    @param rho_i Correlation between channel of signal and inteference
    @param dlsch_llr llr output
    @param symbol OFDM symbol index in sub-frame
    @param first_symbol_flag flag to indicate this is the first symbol of the dlsch
    @param nb_rb number of RBs for this allocation
    @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS
    @param llr16p pointer to pointer to symbol in dlsch_llr*/
int dlsch_64qam_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms,
                         int **rxdataF_comp,
                         int **rxdataF_comp_i,
                         int **dl_ch_mag,
                         int **rho_i,
                         short *dlsch_llr,
                         unsigned char symbol,
                         unsigned char first_symbol_flag,
                         unsigned short nb_rb,
                         uint16_t pbch_pss_sss_adjust,
                         short **llr16p);

/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 64QAM/16QAM reception.
    @param stream0_in Input from channel compensated (MR combined) stream 0
    @param stream1_in Input from channel compensated (MR combined) stream 1
    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
    @param stream0_out Output from LLR unit for stream0
    @param rho01 Cross-correlation between channels (MR combined)
    @param length in complex channel outputs*/
void qam64_qam16(short *stream0_in,
                 short *stream1_in,
                 short *ch_mag,
                 short *ch_mag_i,
                 short *stream0_out,
                 short *rho01,
                 int length);

386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401
/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 64QAM/16QAM reception.
    @param stream0_in Input from channel compensated (MR combined) stream 0
    @param stream1_in Input from channel compensated (MR combined) stream 1
    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
    @param stream0_out Output from LLR unit for stream0
    @param rho01 Cross-correlation between channels (MR combined)
    @param length in complex channel outputs*/
void qam64_qam16_avx2(short *stream0_in,
                      short *stream1_in,
                      short *ch_mag,
                      short *ch_mag_i,
                      short *stream0_out,
                      short *rho01,
                      int length);

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
/** \brief This function perform LLR computation for dual-stream (64QAM/16QAM) transmission.
    @param frame_parms Frame descriptor structure
    @param rxdataF_comp Compensated channel output
    @param rxdataF_comp_i Compensated channel output for interference
    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
    @param rho_i Correlation between channel of signal and inteference
    @param dlsch_llr llr output
    @param symbol OFDM symbol index in sub-frame
    @param first_symbol_flag flag to indicate this is the first symbol of the dlsch
    @param nb_rb number of RBs for this allocation
    @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS
    @param llr16p pointer to pointer to symbol in dlsch_llr*/
int dlsch_64qam_16qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
                          int **rxdataF_comp,
                          int **rxdataF_comp_i,
                          int **dl_ch_mag,
                          int **dl_ch_mag_i,
                          int **rho_i,
                          short *dlsch_llr,
                          unsigned char symbol,
                          unsigned char first_symbol_flag,
                          unsigned short nb_rb,
                          uint16_t pbch_pss_sss_adjust,
                          short **llr16p);

/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 64QAM/64QAM reception.
    @param stream0_in Input from channel compensated (MR combined) stream 0
    @param stream1_in Input from channel compensated (MR combined) stream 1
    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
    @param stream0_out Output from LLR unit for stream0
    @param rho01 Cross-correlation between channels (MR combined)
    @param length in complex channel outputs*/
void qam64_qam64(short *stream0_in,
                 short *stream1_in,
                 short *ch_mag,
                 short *ch_mag_i,
                 short *stream0_out,
                 short *rho01,
                 int length);

444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 64QAM/64QAM reception.
    @param stream0_in Input from channel compensated (MR combined) stream 0
    @param stream1_in Input from channel compensated (MR combined) stream 1
    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
    @param stream0_out Output from LLR unit for stream0
    @param rho01 Cross-correlation between channels (MR combined)
    @param length in complex channel outputs*/
void qam64_qam64_avx2(int32_t *stream0_in,
                      int32_t *stream1_in,
                      int32_t *ch_mag,
                      int32_t *ch_mag_i,
                      int16_t *stream0_out,
                      int32_t *rho01,
                      int length);

460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483
/** \brief This function perform LLR computation for dual-stream (64QAM/64QAM) transmission.
    @param frame_parms Frame descriptor structure
    @param rxdataF_comp Compensated channel output
    @param rxdataF_comp_i Compensated channel output for interference
    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
    @param rho_i Correlation between channel of signal and inteference
    @param dlsch_llr llr output
    @param symbol OFDM symbol index in sub-frame
    @param first_symbol_flag flag to indicate this is the first symbol of the dlsch
    @param nb_rb number of RBs for this allocation
    @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS
    @param llr16p pointer to pointer to symbol in dlsch_llr*/
int dlsch_64qam_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
                          int **rxdataF_comp,
                          int **rxdataF_comp_i,
                          int **dl_ch_mag,
                          int **dl_ch_mag_i,
                          int **rho_i,
                          short *dlsch_llr,
                          unsigned char symbol,
                          unsigned char first_symbol_flag,
                          unsigned short nb_rb,
                          uint16_t pbch_pss_sss_adjust,
484 485
                          //short **llr16p,
                          uint32_t llr_offset);
486 487 488 489 490 491 492


/** \brief This function generates log-likelihood ratios (decoder input) for single-stream QPSK received waveforms.
    @param frame_parms Frame descriptor structure
    @param rxdataF_comp Compensated channel output
    @param dlsch_llr llr output
    @param symbol OFDM symbol index in sub-frame
493
    @param first_symbol_flag
494 495 496
    @param nb_rb number of RBs for this allocation
    @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS
    @param llr128p pointer to pointer to symbol in dlsch_llr
497
    @param beamforming_mode beamforming mode
498
*/
499
int32_t dlsch_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms,
500 501 502 503 504 505
                       int32_t **rxdataF_comp,
                       int16_t *dlsch_llr,
                       uint8_t symbol,
                       uint8_t first_symbol_flag,
                       uint16_t nb_rb,
                       uint16_t pbch_pss_sss_adj,
506
                       //int16_t **llr128p,
507
                       uint8_t beamforming_mode);
508 509 510 511 512 513 514 515 516 517 518 519

/**
   \brief This function generates log-likelihood ratios (decoder input) for single-stream 16QAM received waveforms
   @param frame_parms Frame descriptor structure
   @param rxdataF_comp Compensated channel output
   @param dlsch_llr llr output
   @param dl_ch_mag Squared-magnitude of channel in each resource element position corresponding to allocation and weighted for mid-point in 16QAM constellation
   @param symbol OFDM symbol index in sub-frame
   @param first_symbol_flag
   @param nb_rb number of RBs for this allocation
   @param pbch_pss_sss_adjust  Adjustment factor in RE for PBCH/PSS/SSS allocations
   @param llr128p pointer to pointer to symbol in dlsch_llr
520
   @param beamforming_mode beamforming mode
521 522
*/

lukashov's avatar
lukashov committed
523
int32_t dlsch_qpsk_llr_SIC(LTE_DL_FRAME_PARMS *frame_parms,
524 525 526 527 528 529 530
                           int **rxdataF_comp,
                           int32_t **sic_buffer,
                           int **rho_i,
                           short *dlsch_llr,
                           uint8_t num_pdcch_symbols,
                           uint16_t nb_rb,
                           uint8_t subframe,
Elena_Lukashova's avatar
Elena_Lukashova committed
531
                           uint16_t mod_order_0,
532
                           uint32_t rb_alloc);
lukashov's avatar
lukashov committed
533

534
void dlsch_16qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
535 536 537 538 539 540 541
                     int32_t **rxdataF_comp,
                     int16_t *dlsch_llr,
                     int32_t **dl_ch_mag,
                     uint8_t symbol,
                     uint8_t first_symbol_flag,
                     uint16_t nb_rb,
                     uint16_t pbch_pss_sss_adjust,
542 543
                     int16_t **llr128p,
                     uint8_t beamforming_mode);
544 545 546 547 548 549 550 551 552 553 554
/**
   \brief This function generates log-likelihood ratios (decoder input) for single-stream 16QAM received waveforms
   @param frame_parms Frame descriptor structure
   @param rxdataF_comp Compensated channel output
   @param dlsch_llr llr output
   @param dl_ch_mag Squared-magnitude of channel in each resource element position corresponding to allocation, weighted by first mid-point of 64-QAM constellation
   @param dl_ch_magb Squared-magnitude of channel in each resource element position corresponding to allocation, weighted by second mid-point of 64-QAM constellation
   @param symbol OFDM symbol index in sub-frame
   @param first_symbol_flag
   @param nb_rb number of RBs for this allocation
   @param pbch_pss_sss_adjust PBCH/PSS/SSS RE adjustment (in REs)
555
   @param beamforming_mode beamforming mode
556
*/
lukashov's avatar
lukashov committed
557 558
void dlsch_16qam_llr_SIC (LTE_DL_FRAME_PARMS *frame_parms,
                          int32_t **rxdataF_comp,
559 560 561 562 563 564 565
                          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,
566
                          uint16_t mod_order_0,
567
                          uint32_t rb_alloc);
lukashov's avatar
lukashov committed
568

569
void dlsch_64qam_llr_SIC(LTE_DL_FRAME_PARMS *frame_parms,
lukashov's avatar
lukashov committed
570
                         int32_t **rxdataF_comp,
571 572 573 574 575 576 577 578
                         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,
579
                         uint16_t mod_order_0,
580
                         uint32_t rb_alloc);
581

lukashov's avatar
lukashov committed
582

583
void dlsch_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms,
584 585 586 587 588 589 590 591
                     int32_t **rxdataF_comp,
                     int16_t *dlsch_llr,
                     int32_t **dl_ch_mag,
                     int32_t **dl_ch_magb,
                     uint8_t symbol,
                     uint8_t first_symbol_flag,
                     uint16_t nb_rb,
                     uint16_t pbch_pss_sss_adjust,
592 593
                     //int16_t **llr_save,
                     uint32_t llr_offset,
594
                     uint8_t beamforming_mode);
595

lukashov's avatar
lukashov committed
596

597
/** \fn dlsch_siso(LTE_DL_FRAME_PARMS *frame_parms,
598 599
    int32_t **rxdataF_comp,
    int32_t **rxdataF_comp_i,
600 601 602 603 604 605 606 607 608 609 610
    uint8_t l,
    uint16_t nb_rb)
    \brief This function does the first stage of llr computation for SISO, by just extracting the pilots, PBCH and primary/secondary synchronization sequences.
    @param frame_parms Frame descriptor structure
    @param rxdataF_comp Compensated channel output
    @param rxdataF_comp_i Compensated channel output for interference
    @param l symbol in sub-frame
    @param nb_rb Number of RBs in this allocation
*/

void dlsch_siso(LTE_DL_FRAME_PARMS *frame_parms,
611 612 613 614
                int32_t **rxdataF_comp,
                int32_t **rxdataF_comp_i,
                uint8_t l,
                uint16_t nb_rb);
615 616

/** \fn dlsch_alamouti(LTE_DL_FRAME_PARMS *frame_parms,
617 618 619
    int32_t **rxdataF_comp,
    int32_t **dl_ch_mag,
    int32_t **dl_ch_magb,
620 621 622 623 624 625 626 627 628 629 630
    uint8_t symbol,
    uint16_t nb_rb)
    \brief This function does Alamouti combining on RX and prepares LLR inputs by skipping pilots, PBCH and primary/secondary synchronization signals.
    @param frame_parms Frame descriptor structure
    @param rxdataF_comp Compensated channel output
    @param dl_ch_mag First squared-magnitude of channel (16QAM and 64QAM) for LLR computation.  Alamouti combining should be performed on this as well. Result is stored in first antenna position
    @param dl_ch_magb Second squared-magnitude of channel (64QAM only) for LLR computation.  Alamouti combining should be performed on this as well. Result is stored in first antenna position
    @param symbol Symbol in sub-frame
    @param nb_rb Number of RBs in this allocation
*/
void dlsch_alamouti(LTE_DL_FRAME_PARMS *frame_parms,
631 632 633 634 635
                    int32_t **rxdataF_comp,
                    int32_t **dl_ch_mag,
                    int32_t **dl_ch_magb,
                    uint8_t symbol,
                    uint16_t nb_rb);
636 637

/** \fn dlsch_antcyc(LTE_DL_FRAME_PARMS *frame_parms,
638 639 640
    int32_t **rxdataF_comp,
    int32_t **dl_ch_mag,
    int32_t **dl_ch_magb,
641 642 643 644 645 646 647 648 649 650 651
    uint8_t symbol,
    uint16_t nb_rb)
    \brief This function does antenna selection (based on antenna cycling pattern) on RX and prepares LLR inputs by skipping pilots, PBCH and primary/secondary synchronization signals.  Note that this is not LTE, it is just included for comparison purposes.
    @param frame_parms Frame descriptor structure
    @param rxdataF_comp Compensated channel output
    @param dl_ch_mag First squared-magnitude of channel (16QAM and 64QAM) for LLR computation.  Alamouti combining should be performed on this as well. Result is stored in first antenna position
    @param dl_ch_magb Second squared-magnitude of channel (64QAM only) for LLR computation.  Alamouti combining should be performed on this as well. Result is stored in first antenna position
    @param symbol Symbol in sub-frame
    @param nb_rb Number of RBs in this allocation
*/
void dlsch_antcyc(LTE_DL_FRAME_PARMS *frame_parms,
652 653 654 655 656
                  int32_t **rxdataF_comp,
                  int32_t **dl_ch_mag,
                  int32_t **dl_ch_magb,
                  uint8_t symbol,
                  uint16_t nb_rb);
657 658

/** \fn dlsch_detection_mrc(LTE_DL_FRAME_PARMS *frame_parms,
659 660 661 662 663 664
    int32_t **rxdataF_comp,
    int32_t **rxdataF_comp_i,
    int32_t **rho,
    int32_t **rho_i,
    int32_t **dl_ch_mag,
    int32_t **dl_ch_magb,
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681
    uint8_t symbol,
    uint16_t nb_rb,
    uint8_t dual_stream_UE)

    \brief This function does maximal-ratio combining for dual-antenna receivers.
    @param frame_parms Frame descriptor structure
    @param rxdataF_comp Compensated channel output
    @param rxdataF_comp_i Compensated channel output for interference
    @param rho Cross correlation between spatial channels
    @param rho_i Cross correlation between signal and inteference channels
    @param dl_ch_mag First squared-magnitude of channel (16QAM and 64QAM) for LLR computation.  Alamouti combining should be performed on this as well. Result is stored in first antenna position
    @param dl_ch_magb Second squared-magnitude of channel (64QAM only) for LLR computation.  Alamouti combining should be performed on this as well. Result is stored in first antenna position
    @param symbol Symbol in sub-frame
    @param nb_rb Number of RBs in this allocation
    @param dual_stream_UE Flag to indicate dual-stream detection
*/
void dlsch_detection_mrc(LTE_DL_FRAME_PARMS *frame_parms,
682 683 684 685 686 687 688 689 690 691 692
                         int32_t **rxdataF_comp,
                         int32_t **rxdataF_comp_i,
                         int32_t **rho,
                         int32_t **rho_i,
                         int32_t **dl_ch_mag,
                         int32_t **dl_ch_magb,
                         int32_t **dl_ch_mag_i,
                         int32_t **dl_ch_magb_i,
                         uint8_t symbol,
                         uint16_t nb_rb,
                         uint8_t dual_stream_UE);
693

694
void dlsch_detection_mrc_TM34(LTE_DL_FRAME_PARMS *frame_parms,
695 696 697 698 699 700
                              LTE_UE_PDSCH *lte_ue_pdsch_vars,
                              int harq_pid,
                              int round,
                              unsigned char symbol,
                              unsigned short nb_rb,
                              unsigned char dual_stream_UE);
701

702 703 704 705
/** \fn dlsch_extract_rbs_single(int32_t **rxdataF,
    int32_t **dl_ch_estimates,
    int32_t **rxdataF_ext,
    int32_t **dl_ch_estimates_ext,
706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722
    uint16_t pmi,
    uint8_t *pmi_ext,
    uint32_t *rb_alloc,
    uint8_t symbol,
    uint8_t subframe,
    LTE_DL_FRAME_PARMS *frame_parms)
    \brief This function extracts the received resource blocks, both channel estimates and data symbols,
    for the current allocation and for single antenna eNB transmission.
    @param rxdataF Raw FFT output of received signal
    @param dl_ch_estimates Channel estimates of current slot
    @param rxdataF_ext FFT output for RBs in this allocation
    @param dl_ch_estimates_ext Channel estimates for RBs in this allocation
    @param pmi subband Precoding matrix indicator
    @param pmi_ext Extracted PMI for chosen RBs
    @param rb_alloc RB allocation vector
    @param symbol Symbol to extract
    @param subframe Subframe number
723
    @param vrb_type Flag to indicate distributed VRB type
724
    @param high_speed_flag
725 726
    @param frame_parms Pointer to frame descriptor
*/
727
uint16_t dlsch_extract_rbs_single(int32_t **rxdataF,
728 729 730 731 732 733 734 735 736 737
                                  int32_t **dl_ch_estimates,
                                  int32_t **rxdataF_ext,
                                  int32_t **dl_ch_estimates_ext,
                                  uint16_t pmi,
                                  uint8_t *pmi_ext,
                                  uint32_t *rb_alloc,
                                  uint8_t symbol,
                                  uint8_t subframe,
                                  uint32_t high_speed_flag,
                                  LTE_DL_FRAME_PARMS *frame_parms);
738

739 740 741 742
/** \fn dlsch_extract_rbs_dual(int32_t **rxdataF,
    int32_t **dl_ch_estimates,
    int32_t **rxdataF_ext,
    int32_t **dl_ch_estimates_ext,
743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758
    uint16_t pmi,
    uint8_t *pmi_ext,
    uint32_t *rb_alloc,
    uint8_t symbol,
    LTE_DL_FRAME_PARMS *frame_parms)
    \brief This function extracts the received resource blocks, both channel estimates and data symbols,
    for the current allocation and for dual antenna eNB transmission.
    @param rxdataF Raw FFT output of received signal
    @param dl_ch_estimates Channel estimates of current slot
    @param rxdataF_ext FFT output for RBs in this allocation
    @param dl_ch_estimates_ext Channel estimates for RBs in this allocation
    @param pmi subband Precoding matrix indicator
    @param pmi_ext Extracted PMI for chosen RBs
    @param rb_alloc RB allocation vector
    @param symbol Symbol to extract
    @param subframe Subframe index
759
    @param high_speed_flag
760 761
    @param frame_parms Pointer to frame descriptor
*/
762
uint16_t dlsch_extract_rbs_dual(int32_t **rxdataF,
763 764 765 766 767 768 769 770 771
                                int32_t **dl_ch_estimates,
                                int32_t **rxdataF_ext,
                                int32_t **dl_ch_estimates_ext,
                                uint16_t pmi,
                                uint8_t *pmi_ext,
                                uint32_t *rb_alloc,
                                uint8_t symbol,
                                uint8_t subframe,
                                uint32_t high_speed_flag,
772 773
                                LTE_DL_FRAME_PARMS *frame_parms,
                                MIMO_mode_t mimo_mode);
774

Xiwen JIANG's avatar
Xiwen JIANG committed
775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795
/** \fn dlsch_extract_rbs_TM7(int32_t **rxdataF,
    int32_t **dl_bf_ch_estimates,
    int32_t **rxdataF_ext,
    int32_t **dl_bf_ch_estimates_ext,
    uint32_t *rb_alloc,
    uint8_t symbol,
    uint8_t subframe,
    uint32_t high_speed_flag,
    LTE_DL_FRAME_PARMS *frame_parms)
    \brief This function extracts the received resource blocks, both channel estimates and data symbols,
    for the current allocation and for single antenna eNB transmission.
    @param rxdataF Raw FFT output of received signal
    @param dl_bf_ch_estimates Beamforming channel estimates of current slot
    @param rxdataF_ext FFT output for RBs in this allocation
    @param dl_bf_ch_estimates_ext Beamforming channel estimates for RBs in this allocation
    @param rb_alloc RB allocation vector
    @param symbol Symbol to extract
    @param subframe Subframe number
    @param high_speed_flag
    @param frame_parms Pointer to frame descriptor
*/
796 797 798 799 800 801 802 803 804 805
uint16_t dlsch_extract_rbs_TM7(int32_t **rxdataF,
                               int32_t **dl_bf_ch_estimates,
                               int32_t **rxdataF_ext,
                               int32_t **dl_bf_ch_estimates_ext,
                               uint32_t *rb_alloc,
                               uint8_t symbol,
                               uint8_t subframe,
                               uint32_t high_speed_flag,
                               LTE_DL_FRAME_PARMS *frame_parms);

806 807 808 809 810
/** \brief This function performs channel compensation (matched filtering) on the received RBs for this allocation.  In addition, it computes the squared-magnitude of the channel with weightings for 16QAM/64QAM detection as well as dual-stream detection (cross-correlation)
    @param rxdataF_ext Frequency-domain received signal in RBs to be demodulated
    @param dl_ch_estimates_ext Frequency-domain channel estimates in RBs to be demodulated
    @param dl_ch_mag First Channel magnitudes (16QAM/64QAM)
    @param dl_ch_magb Second weighted Channel magnitudes (64QAM)
811
    @param rxdataF_comp Compensated received waveform
812 813 814 815 816 817 818 819 820
    @param rho Cross-correlation between two spatial channels on each RX antenna
    @param frame_parms Pointer to frame descriptor
    @param symbol Symbol on which to operate
    @param first_symbol_flag set to 1 on first DLSCH symbol
    @param mod_order Modulation order of allocation
    @param nb_rb Number of RBs in allocation
    @param output_shift Rescaling for compensated output (should be energy-normalizing)
    @param phy_measurements Pointer to UE PHY measurements
*/
821
void dlsch_channel_compensation(int32_t **rxdataF_ext,
822 823 824 825 826 827 828 829 830 831 832 833
                                int32_t **dl_ch_estimates_ext,
                                int32_t **dl_ch_mag,
                                int32_t **dl_ch_magb,
                                int32_t **rxdataF_comp,
                                int32_t **rho,
                                LTE_DL_FRAME_PARMS *frame_parms,
                                uint8_t symbol,
                                uint8_t first_symbol_flag,
                                uint8_t mod_order,
                                uint16_t nb_rb,
                                uint8_t output_shift,
                                PHY_MEASUREMENTS *phy_measurements);
834

835 836 837 838 839 840 841 842 843 844 845 846 847
void dlsch_channel_compensation_core(int **rxdataF_ext,
                                     int **dl_ch_estimates_ext,
                                     int **dl_ch_mag,
                                     int **dl_ch_magb,
                                     int **rxdataF_comp,
                                     int **rho,
                                     unsigned char n_tx,
                                     unsigned char n_rx,
                                     unsigned char mod_order,
                                     unsigned char output_shift,
                                     int length,
                                     int start_point);

848 849 850 851 852 853 854 855
void dlsch_dual_stream_correlation(LTE_DL_FRAME_PARMS *frame_parms,
                                   unsigned char symbol,
                                   unsigned short nb_rb,
                                   int **dl_ch_estimates_ext,
                                   int **dl_ch_estimates_ext_i,
                                   int **dl_ch_rho_ext,
                                   unsigned char output_shift);

856 857 858 859 860 861 862
void dlsch_dual_stream_correlationTM34(LTE_DL_FRAME_PARMS *frame_parms,
                                   unsigned char symbol,
                                   unsigned short nb_rb,
                                   int **dl_ch_estimates_ext,
                                   int **dl_ch_estimates_ext_i,
                                   int **dl_ch_rho_ext,
                                   unsigned char output_shift0,
863
                                   unsigned char output_shift1);
864 865 866 867 868 869 870 871 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
//This function is used to compute multiplications in Hhermitian * H matrix
void conjch0_mult_ch1(int *ch0,
                      int *ch1,
                      int32_t *ch0conj_ch1,
                      unsigned short nb_rb,
                      unsigned char output_shift0);

void construct_HhH_elements(int *ch0conj_ch0,
                         int *ch1conj_ch1,
                         int *ch2conj_ch2,
                         int *ch3conj_ch3,
                         int *ch0conj_ch1,
                         int *ch1conj_ch0,
                         int *ch2conj_ch3,
                         int *ch3conj_ch2,
                         int32_t *after_mf_00,
                         int32_t *after_mf_01,
                         int32_t *after_mf_10,
                         int32_t *after_mf_11,
                         unsigned short nb_rb);

void squared_matrix_element(int32_t *Hh_h_00,
                            int32_t *Hh_h_00_sq,
                            unsigned short nb_rb);

void dlsch_channel_level_TM34_meas(int *ch00,
                                   int *ch01,
                                   int *ch10,
                                   int *ch11,
                                   int *avg_0,
                                   int *avg_1,
                                   unsigned short nb_rb);

void det_HhH(int32_t *after_mf_00,
             int32_t *after_mf_01,
             int32_t *after_mf_10,
             int32_t *after_mf_11,
             int32_t *det_fin_128,
             unsigned short nb_rb);

void numer(int32_t *Hh_h_00_sq,
           int32_t *Hh_h_01_sq,
           int32_t *Hh_h_10_sq,
           int32_t *Hh_h_11_sq,
           int32_t *num_fin,
           unsigned short nb_rb);

911 912 913 914 915
uint8_t rank_estimation_tm3_tm4(int *dl_ch_estimates_00,
                                int *dl_ch_estimates_01,
                                int *dl_ch_estimates_10,
                                int *dl_ch_estimates_11,
                                unsigned short nb_rb);
916

917
void dlsch_channel_compensation_TM56(int **rxdataF_ext,
918 919 920 921 922 923 924 925 926 927 928 929 930
                                     int **dl_ch_estimates_ext,
                                     int **dl_ch_mag,
                                     int **dl_ch_magb,
                                     int **rxdataF_comp,
                                     unsigned char *pmi_ext,
                                     LTE_DL_FRAME_PARMS *frame_parms,
                                     PHY_MEASUREMENTS *phy_measurements,
                                     int eNB_id,
                                     unsigned char symbol,
                                     unsigned char mod_order,
                                     unsigned short nb_rb,
                                     unsigned char output_shift,
                                     unsigned char dl_power_off);
931 932


933
void dlsch_channel_compensation_TM34(LTE_DL_FRAME_PARMS *frame_parms,
934 935 936 937 938 939
                                    LTE_UE_PDSCH *lte_ue_pdsch_vars,
                                    PHY_MEASUREMENTS *phy_measurements,
                                    int eNB_id,
                                    unsigned char symbol,
                                    unsigned char mod_order0,
                                    unsigned char mod_order1,
940
                                    int harq_pid,
941
                                    int round,
942
                                    MIMO_mode_t mimo_mode,
943
                                    unsigned short nb_rb,
944
                                    unsigned short mmse_flag,
945 946
                                    unsigned char output_shift0,
                                    unsigned char output_shift1);
947 948


949 950 951 952 953 954 955
/** \brief This function computes the average channel level over all allocated RBs and antennas (TX/RX) in order to compute output shift for compensated signal
    @param dl_ch_estimates_ext Channel estimates in allocated RBs
    @param frame_parms Pointer to frame descriptor
    @param avg Pointer to average signal strength
    @param pilots_flag Flag to indicate pilots in symbol
    @param nb_rb Number of allocated RBs
*/
956
void dlsch_channel_level(int32_t **dl_ch_estimates_ext,
957 958 959 960
                         LTE_DL_FRAME_PARMS *frame_parms,
                         int32_t *avg,
                         uint8_t pilots_flag,
                         uint16_t nb_rb);
961

962 963 964 965 966 967 968
void dlsch_channel_level_core(int32_t **dl_ch_estimates_ext,
                              int32_t *avg,
                              int n_tx,
                              int n_rx,
                              int length,
                              int start_point);

969

970
void dlsch_channel_level_TM34(int **dl_ch_estimates_ext,
971 972 973 974 975 976
                              LTE_DL_FRAME_PARMS *frame_parms,
                              unsigned char *pmi_ext,
                              int *avg_0,
                              int *avg_1,
                              uint8_t symbol,
                              unsigned short nb_rb,
977
                              unsigned int mmse_flag,
978
                              MIMO_mode_t mimo_mode);
979 980 981


void dlsch_channel_level_TM56(int32_t **dl_ch_estimates_ext,
982 983
                              LTE_DL_FRAME_PARMS *frame_parms,
                              unsigned char *pmi_ext,
984
                              int32_t *avg,
985 986 987
                              uint8_t symbol_mod,
                              uint16_t nb_rb);

988 989 990 991 992 993
void dlsch_channel_level_TM7(int32_t **dl_bf_ch_estimates_ext,
                         LTE_DL_FRAME_PARMS *frame_parms,
                         int32_t *avg,
                         uint8_t pilots_flag,
                         uint16_t nb_rb);

994
void dlsch_scale_channel(int32_t **dl_ch_estimates_ext,
995 996 997 998 999 1000
                         LTE_DL_FRAME_PARMS *frame_parms,
                         LTE_UE_DLSCH_t **dlsch_ue,
                         uint8_t symbol_mod,
                         uint16_t nb_rb);

/** \brief This is the top-level entry point for DLSCH decoding in UE.  It should be replicated on several
1001
    threads (on multi-core machines) corresponding to different HARQ processes. The routine first
1002 1003 1004 1005 1006 1007 1008 1009 1010
    computes the segmentation information, followed by rate dematching and sub-block deinterleaving the of the
    received LLRs computed by dlsch_demodulation for each transport block segment. It then calls the
    turbo-decoding algorithm for each segment and stops after either after unsuccesful decoding of at least
    one segment or correct decoding of all segments.  Only the segment CRCs are check for the moment, the
    overall CRC is ignored.  Finally transport block reassembly is performed.
    @param phy_vars_ue Pointer to ue variables
    @param dlsch_llr Pointer to LLR values computed by dlsch_demodulation
    @param lte_frame_parms Pointer to frame descriptor
    @param dlsch Pointer to DLSCH descriptor
1011
    @param frame Frame number
1012 1013 1014 1015 1016 1017 1018
    @param subframe Subframe number
    @param num_pdcch_symbols Number of PDCCH symbols
    @param is_crnti indicates if PDSCH belongs to a CRNTI (necessary for parallelizing decoding threads)
    @param llr8_flag If 1, indicate that the 8-bit turbo decoder should be used
    @returns 0 on success, 1 on unsuccessful decoding
*/
uint32_t dlsch_decoding(PHY_VARS_UE *phy_vars_ue,
1019 1020 1021 1022
                        int16_t *dlsch_llr,
                        LTE_DL_FRAME_PARMS *lte_frame_parms,
                        LTE_UE_DLSCH_t *dlsch,
                        LTE_DL_UE_HARQ_t *harq_process,
1023
                        uint32_t frame,
1024 1025 1026 1027
                        uint8_t subframe,
                        uint8_t harq_pid,
                        uint8_t is_crnti,
                        uint8_t llr8_flag);
1028

1029

1030
uint32_t dlsch_decoding_emul(PHY_VARS_UE *phy_vars_ue,
1031
                             uint8_t subframe,
1032
                             PDSCH_t dlsch_id,
1033
                             uint8_t eNB_id);
1034 1035 1036 1037 1038 1039 1040

/** \brief This function is the top-level entry point to PDSCH demodulation, after frequency-domain transformation and channel estimation.  It performs
    - RB extraction (signal and channel estimates)
    - channel compensation (matched filtering)
    - RE extraction (pilot, PBCH, synch. signals)
    - antenna combining (MRC, Alamouti, cycling)
    - LLR computation
1041
    This function supports TM1, 2, 3, 5, and 6.
1042 1043 1044 1045 1046 1047 1048
    @param phy_vars_ue Pointer to PHY variables
    @param type Type of PDSCH (SI_PDSCH,RA_PDSCH,PDSCH,PMCH)
    @param eNB_id eNb index (Nid1) 0,1,2
    @param eNB_id_i Interfering eNB index (Nid1) 0,1,2, or 3 in case of MU-MIMO IC receiver
    @param subframe Subframe number
    @param symbol Symbol on which to act (within sub-frame)
    @param first_symbol_flag set to 1 on first DLSCH symbol
1049
    @param rx_type. rx_type=RX_IC_single_stream will enable interference cancellation of a second stream when decoding the first stream. In case of TM1, 2, 5, and this can cancel interference from a neighbouring cell given by eNB_id_i. In case of TM5, eNB_id_i should be set to n_connected_eNB to perform multi-user interference cancellation. In case of TM3, eNB_id_i should be set to eNB_id to perform co-channel interference cancellation; this option should be used together with an interference cancellation step [...]. In case of TM3, if rx_type=RX_IC_dual_stream, both streams will be decoded by applying the IC single stream receiver twice.
1050 1051
    @param i_mod Modulation order of the interfering stream
*/
1052
int32_t rx_pdsch(PHY_VARS_UE *phy_vars_ue,
1053 1054 1055
                 PDSCH_t type,
                 uint8_t eNB_id,
                 uint8_t eNB_id_i,
1056
                 uint32_t frame,
1057 1058 1059
                 uint8_t subframe,
                 uint8_t symbol,
                 uint8_t first_symbol_flag,
1060
                 RX_type_t rx_type,
1061 1062
                 uint8_t i_mod,
                 uint8_t harq_pid);
1063

hbilel's avatar
hbilel committed
1064
int32_t rx_pdcch(PHY_VARS_UE *ue,
1065
                 uint32_t frame,
1066 1067 1068
                 uint8_t subframe,
                 uint8_t eNB_id,
                 MIMO_mode_t mimo_mode,
1069
                 uint32_t high_speed_flag);
1070 1071 1072 1073 1074 1075 1076 1077 1078

/*! \brief Extract PSS and SSS resource elements
  @param phy_vars_ue Pointer to UE variables
  @param[out] pss_ext contain the PSS signals after the extraction
  @param[out] sss_ext contain the SSS signals after the extraction
  @returns 0 on success
*/
int pss_sss_extract(PHY_VARS_UE *phy_vars_ue,
                    int32_t pss_ext[4][72],
1079
                    int32_t sss_ext[4][72],
1080
                                        uint8_t subframe);
1081 1082 1083 1084 1085 1086 1087

/*! \brief Extract only PSS resource elements
  @param phy_vars_ue Pointer to UE variables
  @param[out] pss_ext contain the PSS signals after the extraction
  @returns 0 on success
*/
int pss_only_extract(PHY_VARS_UE *phy_vars_ue,
hbilel's avatar
hbilel committed
1088 1089
                    int32_t pss_ext[4][72],
                    uint8_t subframe);
1090 1091 1092 1093 1094 1095 1096

/*! \brief Extract only SSS resource elements
  @param phy_vars_ue Pointer to UE variables
  @param[out] sss_ext contain the SSS signals after the extraction
  @returns 0 on success
*/
int sss_only_extract(PHY_VARS_UE *phy_vars_ue,
hbilel's avatar
hbilel committed
1097 1098
                    int32_t sss_ext[4][72],
                    uint8_t subframe);
1099

1100 1101 1102 1103 1104 1105 1106 1107
/*! \brief Performs detection of SSS to find cell ID and other framing parameters (FDD/TDD, normal/extended prefix)
  @param phy_vars_ue Pointer to UE variables
  @param tot_metric Pointer to variable containing maximum metric under framing hypothesis (to be compared to other hypotheses
  @param flip_max Pointer to variable indicating if start of frame is in second have of RX buffer (i.e. PSS/SSS is flipped)
  @param phase_max Pointer to variable (0 ... 6) containing rought phase offset between PSS and SSS (can be used for carrier
  frequency adjustment. 0 means -pi/3, 6 means pi/3.
  @returns 0 on success
*/
1108
int rx_sss(PHY_VARS_UE *phy_vars_ue,int32_t *tot_metric,uint8_t *flip_max,uint8_t *phase_max);
1109 1110 1111 1112 1113

/*! \brief receiver for the PBCH
  \returns number of tx antennas or -1 if error
*/
uint16_t rx_pbch(LTE_UE_COMMON *lte_ue_common_vars,
1114 1115 1116 1117 1118 1119
                 LTE_UE_PBCH *lte_ue_pbch_vars,
                 LTE_DL_FRAME_PARMS *frame_parms,
                 uint8_t eNB_id,
                 MIMO_mode_t mimo_mode,
                 uint32_t high_speed_flag,
                 uint8_t frame_mod4);
1120 1121

uint16_t rx_pbch_emul(PHY_VARS_UE *phy_vars_ue,
1122 1123
                      uint8_t eNB_id,
                      uint8_t pbch_phase);
1124 1125 1126 1127 1128 1129 1130


/*! \brief PBCH unscrambling
  This is similar to pbch_scrabling with the difference that inputs are signed s16s (llr values) and instead of flipping bits we change signs.
  \param frame_parms Pointer to frame descriptor
  \param llr Output of the demodulator
  \param length Length of the sequence
1131
  \param frame_mod4 Frame number modulo 4*/
1132
void pbch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms,
1133 1134 1135
                       int8_t* llr,
                       uint32_t length,
                       uint8_t frame_mod4);
1136

1137 1138 1139 1140 1141
/*! \brief Top-level generation route for Sidelink BCH,PSS and SSS
  \param ue pointer to UE descriptor
  \param slss pointer to SLSS configuration and payload
  \param frame_tx Frame number
  \param subframe_tx subframe number
1142
*/
1143
void generate_slss(PHY_VARS_UE *ue,SLSS_t *slss,int frame_tx,int subframe_tx);
1144

1145 1146 1147 1148 1149 1150 1151
/*! \brief Top-level generation route for Sidelink Discovery Channel
  \param ue pointer to UE descriptor
  \param sldch pointer to SLDCH configuration and payload
  \param frame_tx Frame number
  \param subframe_tx subframe number
*/
void generate_sldch(PHY_VARS_UE *ue,SLDCH_t *sldch,int frame_tx,int subframe_tx);
1152

1153 1154 1155 1156 1157 1158 1159
/*! \brief Top-level generation route for Sidelink Shared Channel
  \param ue pointer to UE descriptor
  \param slsch pointer to SLSCH configuration and payload
  \param frame_tx Frame number
  \param subframe_tx subframe number
*/
void generate_slsch(PHY_VARS_UE *ue,SLSCH_t *slss,int frame_tx,int subframe_tx);
1160 1161 1162

void generate_64qam_table(void);
void generate_16qam_table(void);
1163
void generate_qpsk_table(void);
1164 1165 1166 1167 1168 1169 1170 1171

uint16_t extract_crc(uint8_t *dci,uint8_t DCI_LENGTH);

/*! \brief LLR from two streams. This function takes two streams (qpsk modulated) and calculates the LLR, considering one stream as interference.
  \param stream0_in pointer to first stream0
  \param stream1_in pointer to first stream1
  \param stream0_out pointer to output stream
  \param rho01 pointer to correlation matrix
1172
  \param length*/
1173
void qpsk_qpsk_TM3456(short *stream0_in,
1174 1175 1176 1177 1178
                      short *stream1_in,
                      short *stream0_out,
                      short *rho01,
                      int length
                     );
1179 1180 1181 1182 1183 1184 1185 1186

/** \brief Attempt decoding of a particular DCI with given length and format.
    @param DCI_LENGTH length of DCI in bits
    @param DCI_FMT Format of DCI
    @param e e-sequence (soft bits)
    @param decoded_output Output of Viterbi decoder
*/
void dci_decoding(uint8_t DCI_LENGTH,
1187 1188 1189
                  uint8_t DCI_FMT,
                  int8_t *e,
                  uint8_t *decoded_output);
1190 1191 1192 1193 1194

/** \brief Do 36.213 DCI decoding procedure by searching different RNTI options and aggregation levels.  Currently does
    not employ the complexity reducing procedure based on RNTI.
    @param phy_vars_ue UE variables
    @param dci_alloc Pointer to DCI_ALLOC_t array to store results for DLSCH/ULSCH programming
1195
    @param do_common If 1 perform search in common search-space else ue-specific search-space
1196 1197 1198 1199 1200
    @param eNB_id eNB Index on which to act
    @param subframe Index of subframe
    @returns bitmap of occupied CCE positions (i.e. those detected)
*/
uint16_t dci_decoding_procedure(PHY_VARS_UE *phy_vars_ue,
1201 1202 1203 1204
                                DCI_ALLOC_t *dci_alloc,
                                int do_common,
                                int16_t eNB_id,
                                uint8_t subframe);
1205

1206 1207 1208 1209 1210 1211
uint16_t dci_CRNTI_decoding_procedure(PHY_VARS_UE *ue,
                                DCI_ALLOC_t *dci_alloc,
                                uint8_t DCIFormat,
                                uint8_t agregationLevel,
                                int16_t eNB_id,
                                uint8_t subframe);
1212 1213

uint16_t dci_decoding_procedure_emul(LTE_UE_PDCCH **lte_ue_pdcch_vars,
1214 1215 1216 1217 1218
                                     uint8_t num_ue_spec_dci,
                                     uint8_t num_common_dci,
                                     DCI_ALLOC_t *dci_alloc_tx,
                                     DCI_ALLOC_t *dci_alloc_rx,
                                     int16_t eNB_id);
1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239

/** \brief Compute Q (modulation order) based on I_MCS PDSCH.  Implements table 7.1.7.1-1 from 36.213.
    @param I_MCS */
uint8_t get_Qm(uint8_t I_MCS);

/** \brief Compute Q (modulation order) based on I_MCS for PUSCH.  Implements table 8.6.1-1 from 36.213.
    @param I_MCS */
uint8_t get_Qm_ul(uint8_t I_MCS);

/** \brief Compute I_TBS (transport-block size) based on I_MCS for PDSCH.  Implements table 7.1.7.1-1 from 36.213.
    @param I_MCS */
uint8_t get_I_TBS(uint8_t I_MCS);

/** \brief Compute I_TBS (transport-block size) based on I_MCS for PUSCH.  Implements table 8.6.1-1 from 36.213.
    @param I_MCS */
unsigned char get_I_TBS_UL(unsigned char I_MCS);

/** \brief Compute Q (modulation order) based on downlink I_MCS. Implements table 7.1.7.1-1 from 36.213.
    @param I_MCS
    @param nb_rb
    @return Transport block size */
1240
uint32_t get_TBS_DL(uint8_t mcs, uint16_t nb_rb);
1241 1242 1243 1244 1245

/** \brief Compute Q (modulation order) based on uplink I_MCS. Implements table 7.1.7.1-1 from 36.213.
    @param I_MCS
    @param nb_rb
    @return Transport block size */
1246
uint32_t get_TBS_UL(uint8_t mcs, uint16_t nb_rb);
1247 1248

/* \brief Return bit-map of resource allocation for a given DCI rballoc (RIV format) and vrb type
1249 1250 1251 1252 1253 1254 1255
   @param N_RB_DL number of PRB on DL
   @param indicator for even/odd slot
   @param vrb vrb index
   @param Ngap Gap indicator
*/
uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap);

1256
/* \brief Return prb for a given vrb index
1257 1258 1259
   @param vrb_type VRB type (0=localized,1=distributed)
   @param rb_alloc_dci rballoc field from DCI
*/
1260
uint32_t get_rballoc(vrb_t vrb_type,uint16_t rb_alloc_dci);
1261

1262

1263 1264 1265
/* \brief Return bit-map of resource allocation for a given DCI rballoc (RIV format) and vrb type
   @returns Transmission mode (1-7)
*/
1266
uint8_t get_transmission_mode(module_id_t Mod_id, uint8_t CC_id, rnti_t rnti);
1267

1268

1269
/* \brief
1270
   @param ra_header Header of resource allocation (0,1) (See sections 7.1.6.1/7.1.6.2 of 36.213 Rel8.6)
1271
   @param rb_alloc Bitmap allocation from DCI (format 1,2)
1272 1273 1274 1275
   @returns number of physical resource blocks
*/
uint32_t conv_nprb(uint8_t ra_header,uint32_t rb_alloc,int N_RB_DL);

1276
int get_G(LTE_DL_FRAME_PARMS *frame_parms,uint16_t nb_rb,uint32_t *rb_alloc,uint8_t mod_order,uint8_t Nl,uint8_t num_pdcch_symbols,int frame,uint8_t subframe, uint8_t beamforming_mode);
1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302

int adjust_G(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_order,uint8_t subframe);
int adjust_G2(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_order,uint8_t subframe,uint8_t symbol);


#ifndef modOrder
#define modOrder(I_MCS,I_TBS) ((I_MCS-I_TBS)*2+2) // Find modulation order from I_TBS and I_MCS
#endif

/** \fn uint8_t I_TBS2I_MCS(uint8_t I_TBS);
    \brief This function maps I_tbs to I_mcs according to Table 7.1.7.1-1 in 3GPP TS 36.213 V8.6.0. Where there is two supported modulation orders for the same I_TBS then either high or low modulation is chosen by changing the equality of the two first comparisons in the if-else statement.
    \param I_TBS Index of Transport Block Size
    \return I_MCS given I_TBS
*/
uint8_t I_TBS2I_MCS(uint8_t I_TBS);

/** \fn uint8_t SE2I_TBS(float SE,
    uint8_t N_PRB,
    uint8_t symbPerRB);
    \brief This function maps a requested throughput in number of bits to I_tbs. The throughput is calculated as a function of modulation order, RB allocation and number of symbols per RB. The mapping orginates in the "Transport block size table" (Table 7.1.7.2.1-1 in 3GPP TS 36.213 V8.6.0)
    \param SE Spectral Efficiency (before casting to integer, multiply by 1024, remember to divide result by 1024!)
    \param N_PRB Number of PhysicalResourceBlocks allocated \sa lte_frame_parms->N_RB_DL
    \param symbPerRB Number of symbols per resource block allocated to this channel
    \return I_TBS given an SE and an N_PRB
*/
uint8_t SE2I_TBS(float SE,
1303 1304
                 uint8_t N_PRB,
                 uint8_t symbPerRB);
1305 1306 1307 1308 1309
/** \brief This function generates the sounding reference symbol (SRS) for the uplink according to 36.211 v8.6.0. If IFFT_FPGA is defined, the SRS is quantized to a QPSK sequence.
    @param frame_parms LTE DL Frame Parameters
    @param soundingrs_ul_config_dedicated Dynamic configuration from RRC during Connection Establishment
    @param txdataF pointer to the frequency domain TX signal
    @returns 0 on success*/
1310 1311 1312 1313 1314
int generate_srs(LTE_DL_FRAME_PARMS *frame_parms,
		 SOUNDINGRS_UL_CONFIG_DEDICATED *soundingrs_ul_config_dedicated,
		 int *txdataF,
		 int16_t amp,
		 uint32_t subframe);
1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325


/*!
  \brief This function is similar to generate_srs_tx but generates a conjugate sequence for channel estimation. If IFFT_FPGA is defined, the SRS is quantized to a QPSK sequence.
  @param phy_vars_ue Pointer to PHY_VARS structure
  @param eNB_id Index of destination eNB for this SRS
  @param amp Linear amplitude of SRS
  @param subframe Index of subframe on which to act
  @returns 0 on success, -1 on error with message
*/

1326
int32_t generate_srs_tx(PHY_VARS_UE *phy_vars_ue,
1327 1328 1329
                        uint8_t eNB_id,
                        int16_t amp,
                        uint32_t subframe);
1330 1331 1332 1333 1334

/*!
  \brief This function generates the downlink reference signal for the PUSCH according to 36.211 v8.6.0. The DRS occuies the RS defined by rb_alloc and the symbols 2 and 8 for extended CP and 3 and 10 for normal CP.
*/

1335
int32_t generate_drs_pusch(PHY_VARS_UE *phy_vars_ue,
1336
                           UE_rxtx_proc_t *proc,
1337 1338 1339 1340 1341 1342
                           uint8_t eNB_id,
                           int16_t amp,
                           uint32_t subframe,
                           uint32_t first_rb,
                           uint32_t nb_rb,
                           uint8_t ant);
1343 1344 1345 1346 1347 1348

/*!
  \brief This function initializes the Group Hopping, Sequence Hopping and nPRS sequences for PUCCH/PUSCH according to 36.211 v8.6.0. It should be called after configuration of UE (reception of SIB2/3) and initial configuration of eNB (or after reconfiguration of cell-specific parameters).
  @param frame_parms Pointer to a LTE_DL_FRAME_PARMS structure (eNB or UE)*/
void init_ul_hopping(LTE_DL_FRAME_PARMS *frame_parms);

1349 1350 1351 1352 1353 1354 1355 1356

/*!
  \brief This function implements the initialization of paging parameters for UE (See Section 7, 36.304).It must be called after setting IMSImod1024 during UE startup and after receiving SIB2
  @param ue Pointer to UE context
  @param defaultPagingCycle T from 36.304 (0=32,1=64,2=128,3=256)
  @param nB nB from 36.304 (0=4T,1=2T,2=T,3=T/2,4=T/4,5=T/8,6=T/16,7=T/32*/
int init_ue_paging_info(PHY_VARS_UE *ue, long defaultPagingCycle, long nB);

1357
int32_t compareints (const void * a, const void * b);
1358 1359


1360
void ulsch_modulation(int32_t **txdataF,
1361 1362 1363 1364 1365
                      int16_t amp,
                      frame_t frame,
                      uint32_t subframe,
                      LTE_DL_FRAME_PARMS *frame_parms,
                      LTE_UE_ULSCH_t *ulsch);
1366 1367 1368



1369 1370


1371

1372
int generate_ue_dlsch_params_from_dci(int frame,
1373
                                      uint8_t subframe,
1374
                                      void *dci_pdu,
1375
                                      rnti_t rnti,
1376
                                      DCI_format_t dci_format,
1377 1378
                                      LTE_UE_PDCCH *pdcch_vars,
                                      LTE_UE_PDSCH *pdsch_vars,
1379 1380 1381 1382 1383
                                      LTE_UE_DLSCH_t **dlsch,
                                      LTE_DL_FRAME_PARMS *frame_parms,
                                      PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated,
                                      uint16_t si_rnti,
                                      uint16_t ra_rnti,
1384
                                      uint16_t p_rnti,
1385 1386
                                      uint8_t beamforming_mode,
                                      uint16_t tc_rnti);
1387 1388 1389


int generate_ue_ulsch_params_from_dci(void *dci_pdu,
1390
                                      rnti_t rnti,
1391 1392 1393
                                      uint8_t subframe,
                                      DCI_format_t dci_format,
                                      PHY_VARS_UE *phy_vars_ue,
1394
                                      UE_rxtx_proc_t *proc,
1395
                                      uint16_t si_rnti,
1396 1397 1398 1399 1400
                                      uint16_t ra_rnti,
                                      uint16_t p_rnti,
                                      uint16_t cba_rnti,
                                      uint8_t eNB_id,
                                      uint8_t use_srs);
1401

1402
int32_t generate_ue_ulsch_params_from_rar(PHY_VARS_UE *phy_vars_ue,
1403 1404
                                          UE_rxtx_proc_t *proc,
                                          uint8_t eNB_id);
1405
double sinr_eff_cqi_calc(PHY_VARS_UE *phy_vars_ue,
1406
                         uint8_t eNB_id,
1407
                                                 uint8_t subframe);
Raymond Knopp's avatar
Raymond Knopp committed
1408 1409 1410

uint8_t sinr2cqi(double sinr,uint8_t trans_mode);

1411 1412 1413

int dump_dci(LTE_DL_FRAME_PARMS *frame_parms, DCI_ALLOC_t *dci);

1414
int dump_ue_stats(PHY_VARS_UE *phy_vars_ue, UE_rxtx_proc_t *proc, char* buffer, int length, runmode_t mode, int input_level_dBm);
1415 1416 1417 1418 1419 1420 1421



void generate_pcfich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms);


void pcfich_unscrambling(LTE_DL_FRAME_PARMS *frame_parms,
1422 1423
                         uint8_t subframe,
                         int16_t *d);
1424 1425 1426


uint8_t rx_pcfich(LTE_DL_FRAME_PARMS *frame_parms,
1427 1428 1429
                  uint8_t subframe,
                  LTE_UE_PDCCH *lte_ue_pdcch_vars,
                  MIMO_mode_t mimo_mode);
1430 1431 1432 1433 1434 1435 1436 1437 1438

void generate_phich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms);


void init_transport_channels(uint8_t);

void generate_RIV_tables(void);

/*!
1439 1440
  \brief This function performs the initial cell search procedure - PSS detection, SSS detection and PBCH detection.  At the
  end, the basic frame parameters are known (Frame configuration - TDD/FDD and cyclic prefix length,
1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458
  N_RB_DL, PHICH_CONFIG and Nid_cell) and the UE can begin decoding PDCCH and DLSCH SI to retrieve the rest.  Once these
  parameters are know, the routine calls some basic initialization routines (cell-specific reference signals, etc.)
  @param phy_vars_ue Pointer to UE variables
*/
int initial_sync(PHY_VARS_UE *phy_vars_ue, runmode_t mode);


/*!
  \brief Encoding of PUSCH/ACK/RI/ACK from 36-212.
  @param a Pointer to ulsch SDU
  @param frame_parms Pointer to Frame parameters
  @param ulsch Pointer to ulsch descriptor
  @param harq_pid HARQ process ID
  @param tmode Transmission mode (1-7)
  @param control_only_flag Generate PUSCH with control information only
  @param Nbundled Parameter for ACK/NAK bundling (36.213 Section 7.3)
*/
uint32_t ulsch_encoding(uint8_t *a,
1459 1460 1461
                        PHY_VARS_UE *phy_vars_ue,
                        uint8_t harq_pid,
                        uint8_t eNB_id,
hbilel's avatar
hbilel committed
1462
                        uint8_t subframe_rx,
1463 1464 1465
                        uint8_t tmode,
                        uint8_t control_only_flag,
                        uint8_t Nbundled);
1466

1467

1468 1469 1470 1471


/* \brief  This routine demodulates the PHICH and updates PUSCH/ULSCH parameters.
   @param phy_vars_ue Pointer to UE variables
1472
   @param proc Pointer to RXN_TXNp4 proc
1473 1474 1475 1476 1477
   @param subframe Subframe of received PDCCH/PHICH
   @param eNB_id Index of eNB
*/

void rx_phich(PHY_VARS_UE *phy_vars_ue,
1478
              UE_rxtx_proc_t *proc,
1479 1480
              uint8_t subframe,
              uint8_t eNB_id);
1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495


/** \brief  This routine provides the relationship between a PHICH TXOp and its corresponding PUSCH subframe (Table 8.3.-1 from 36.213).
    @param frame_parms Pointer to DL frame configuration parameters
    @param subframe Subframe of received/transmitted PHICH
    @returns subframe of PUSCH transmission
*/
uint8_t phich_subframe2_pusch_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe);

/** \brief  This routine provides the relationship between a PHICH TXOp and its corresponding PUSCH frame (Table 8.3.-1 from 36.213).
    @param frame_parms Pointer to DL frame configuration parameters
    @param frame Frame of received/transmitted PHICH
    @param subframe Subframe of received/transmitted PHICH
    @returns frame of PUSCH transmission
*/
1496
int phich_frame2_pusch_frame(LTE_DL_FRAME_PARMS *frame_parms, int frame, int subframe);
1497

Raymond Knopp's avatar
 
Raymond Knopp committed
1498
void print_CQI(void *o,UCI_format_t uci_format,uint8_t eNB_id,int N_RB_DL);
1499

1500
void fill_CQI(LTE_UE_ULSCH_t *ulsch,PHY_MEASUREMENTS *meas,uint8_t eNB_id, uint8_t harq_pid,int N_RB_DL, rnti_t rnti, uint8_t trans_mode,double sinr_eff);
Florian Kaltenberger's avatar
Florian Kaltenberger committed
1501

1502 1503
void reset_cba_uci(void *o);

Florian Kaltenberger's avatar
Florian Kaltenberger committed
1504 1505 1506 1507 1508 1509
/** \brief  This routine computes the subband PMI bitmap based on measurements (0,1,2,3 for rank 0 and 0,1 for rank 1) in the format needed for UCI
    @param meas pointer to measurements
    @param eNB_id eNB_id
    @param nb_subbands number of subbands
    @returns subband PMI bitmap
*/
Raymond Knopp's avatar
 
Raymond Knopp committed
1510
uint16_t quantize_subband_pmi(PHY_MEASUREMENTS *meas,uint8_t eNB_id,int nb_subbands);
Florian Kaltenberger's avatar
Florian Kaltenberger committed
1511

1512 1513
int32_t pmi_convert_rank1_from_rank2(uint16_t pmi_alloc, int tpmi, int nb_rb);

Raymond Knopp's avatar
 
Raymond Knopp committed
1514
uint16_t quantize_subband_pmi2(PHY_MEASUREMENTS *meas,uint8_t eNB_id,uint8_t a_id,int nb_subbands);
1515 1516 1517



Raymond Knopp's avatar
 
Raymond Knopp committed
1518
uint64_t cqi2hex(uint32_t cqi);
1519 1520 1521

uint16_t computeRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs);

Florian Kaltenberger's avatar
Florian Kaltenberger committed
1522 1523 1524

/** \brief  This routine extracts a single subband PMI from a bitmap coming from UCI or the pmi_extend function
    @param N_RB_DL number of resource blocks
1525
    @param mimo_mode
Florian Kaltenberger's avatar
Florian Kaltenberger committed
1526
    @param pmi_alloc subband PMI bitmap
Florian Kaltenberger's avatar
Florian Kaltenberger committed
1527 1528 1529
    @param rb resource block for which to extract PMI
    @returns subband PMI
*/
Florian Kaltenberger's avatar
Florian Kaltenberger committed
1530
uint8_t get_pmi(uint8_t N_RB_DL,MIMO_mode_t mode, uint32_t pmi_alloc,uint16_t rb);
1531

1532
int get_nCCE_offset_l1(int *CCE_table,
1533 1534 1535 1536 1537
                       const unsigned char L,
                       const int nCCE,
                       const int common_dci,
                       const unsigned short rnti,
                       const unsigned char subframe);
1538 1539 1540 1541 1542 1543 1544

uint16_t get_nCCE(uint8_t num_pdcch_symbols,LTE_DL_FRAME_PARMS *frame_parms,uint8_t mi);

uint16_t get_nquad(uint8_t num_pdcch_symbols,LTE_DL_FRAME_PARMS *frame_parms,uint8_t mi);

uint8_t get_mi(LTE_DL_FRAME_PARMS *frame,uint8_t subframe);

1545
uint16_t get_nCCE_mac(uint8_t Mod_id,uint8_t CC_id,int num_pdcch_symbols,int subframe);
1546 1547 1548

uint8_t get_num_pdcch_symbols(uint8_t num_dci,DCI_ALLOC_t *dci_alloc,LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe);

1549
void pdcch_interleaving(LTE_DL_FRAME_PARMS *frame_parms,int32_t **z, int32_t **wbar,uint8_t n_symbols_pdcch,uint8_t mi);
1550 1551

void pdcch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms,
1552 1553 1554
                        uint8_t subframe,
                        int8_t* llr,
                        uint32_t length);
1555

1556

1557 1558

void dlsch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms,
1559 1560 1561 1562 1563 1564
                        int mbsfn_flag,
                        LTE_UE_DLSCH_t *dlsch,
                        int G,
                        int16_t* llr,
                        uint8_t q,
                        uint8_t Ns);
1565 1566 1567

void init_ncs_cell(LTE_DL_FRAME_PARMS *frame_parms,uint8_t ncs_cell[20][7]);

Raymond Knopp's avatar
Raymond Knopp committed
1568
void generate_pucch1x(int32_t **txdataF,
1569 1570 1571 1572 1573 1574 1575 1576 1577
                      LTE_DL_FRAME_PARMS *frame_parms,
                      uint8_t ncs_cell[20][7],
                      PUCCH_FMT_t fmt,
                      PUCCH_CONFIG_DEDICATED *pucch_config_dedicated,
                      uint16_t n1_pucch,
                      uint8_t shortened_format,
                      uint8_t *payload,
                      int16_t amp,
                      uint8_t subframe);
1578

Raymond Knopp's avatar
Raymond Knopp committed
1579
void generate_pucch2x(int32_t **txdataF,
1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590
                      LTE_DL_FRAME_PARMS *fp,
                      uint8_t ncs_cell[20][7],
                      PUCCH_FMT_t fmt,
                      PUCCH_CONFIG_DEDICATED *pucch_config_dedicated,
                      uint16_t n2_pucch,
                      uint8_t *payload,
                      int A,
                      int B2,
                      int16_t amp,
                      uint8_t subframe,
                      uint16_t rnti);
Raymond Knopp's avatar
Raymond Knopp committed
1591

1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602
void generate_pucch3x(int32_t **txdataF,
                    LTE_DL_FRAME_PARMS *frame_parms,
                    uint8_t ncs_cell[20][7],
                    PUCCH_FMT_t fmt,
                    PUCCH_CONFIG_DEDICATED *pucch_config_dedicated,
                    uint16_t n3_pucch,
                    uint8_t shortened_format,
                    uint8_t *payload,
                    int16_t amp,
                    uint8_t subframe,
                    uint16_t rnti);
Raymond Knopp's avatar
Raymond Knopp committed
1603

1604

1605 1606
void init_ulsch_power_LUT(void);

1607 1608 1609 1610 1611 1612 1613
/*!
  \brief Check for PRACH TXop in subframe
  @param frame_parms Pointer to LTE_DL_FRAME_PARMS
  @param frame frame index to check
  @param subframe subframe index to check
  @returns 0 on success
*/
1614
int is_prach_subframe(LTE_DL_FRAME_PARMS *frame_parms,frame_t frame, uint8_t subframe);
1615 1616 1617 1618 1619 1620 1621 1622 1623

/*!
  \brief Generate PRACH waveform
  @param phy_vars_ue Pointer to ue top-level descriptor
  @param eNB_id Index of destination eNB
  @param subframe subframe index to operate on
  @param index of preamble (0-63)
  @param Nf System frame number
  @returns 0 on success
1624

1625
*/
1626
int32_t generate_prach(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t subframe,uint16_t Nf);
1627

1628

1629 1630 1631 1632 1633
/*!
  \brief Helper for MAC, returns number of available PRACH in TDD for a particular configuration index
  @param frame_parms Pointer to LTE_DL_FRAME_PARMS structure
  @returns 0-5 depending on number of available prach
*/
1634
uint8_t get_num_prach_tdd(module_id_t Mod_id);
1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648

/*!
  \brief Return the PRACH format as a function of the Configuration Index and Frame type.
  @param prach_ConfigIndex PRACH Configuration Index
  @param frame_type 0-FDD, 1-TDD
  @returns 0-1 accordingly
*/
uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,lte_frame_type_t frame_type);

/*!
  \brief Helper for MAC, returns frequency index of PRACH resource in TDD for a particular configuration index
  @param frame_parms Pointer to LTE_DL_FRAME_PARMS structure
  @returns 0-5 depending on number of available prach
*/
1649
uint8_t get_fid_prach_tdd(module_id_t Mod_id,uint8_t tdd_map_index);
1650 1651 1652

/*!
  \brief Comp ute DFT of PRACH ZC sequences.  Used for generation of prach in UE and reception of PRACH in eNB.
1653 1654 1655 1656 1657
  @param rootSequenceIndex PRACH root sequence
  #param prach_ConfigIndex PRACH Configuration Index
  @param zeroCorrelationZoneConfig PRACH ncs_config
  @param highSpeedFlat PRACH High-Speed Flag
  @param frame_type TDD/FDD flag
1658
  @param Xu DFT output
1659
*/
1660 1661 1662 1663 1664 1665 1666
void compute_prach_seq(uint16_t rootSequenceIndex,
		       uint8_t prach_ConfigIndex,
		       uint8_t zeroCorrelationZoneConfig,
		       uint8_t highSpeedFlag,
		       lte_frame_type_t frame_type,
		       uint32_t X_u[64][839]);

1667 1668 1669

void init_prach_tables(int N_ZC);

1670 1671 1672
void init_unscrambling_lut(void);
void init_scrambling_lut(void);

1673 1674 1675 1676 1677 1678 1679
/*!
  \brief Return the status of MBSFN in this frame/subframe
  @param frame Frame index
  @param subframe Subframe index
  @param frame_parms Pointer to frame parameters
  @returns 1 if subframe is for MBSFN
*/
1680
int is_pmch_subframe(frame_t frame, int subframe, LTE_DL_FRAME_PARMS *frame_parms);
1681

1682
uint8_t is_not_pilot(uint8_t pilots, uint8_t re, uint8_t nushift, uint8_t use2ndpilots);
1683

1684 1685
uint8_t is_not_UEspecRS(int8_t lprime, uint8_t re, uint8_t nushift, uint8_t Ncp, uint8_t beamforming_mode);

1686
uint32_t dlsch_decoding_abstraction(double *dlsch_MIPB,
1687 1688 1689 1690
                                    LTE_DL_FRAME_PARMS *lte_frame_parms,
                                    LTE_UE_DLSCH_t *dlsch,
                                    uint8_t subframe,
                                    uint8_t num_pdcch_symbols);
1691 1692

// DL power control functions
1693
double get_pa_dB(uint8_t pa);
1694 1695


1696
double computeRhoA_UE(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated,
1697
                      LTE_UE_DLSCH_t *dlsch_ue,
1698
                      uint8_t dl_power_off,
1699
                      uint8_t n_antenna_port);
1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711

double computeRhoB_UE(PDSCH_CONFIG_DEDICATED  *pdsch_config_dedicated,
                      PDSCH_CONFIG_COMMON *pdsch_config_common,
                      uint8_t n_antenna_port,
                      LTE_UE_DLSCH_t *dlsch_ue,
                      uint8_t dl_power_off);

/*void compute_sqrt_RhoAoRhoB(PDSCH_CONFIG_DEDICATED  *pdsch_config_dedicated,
  PDSCH_CONFIG_COMMON *pdsch_config_common,
  uint8_t n_antenna_port,
  LTE_UE_DLSCH_t *dlsch_ue);
*/
1712

1713 1714
uint8_t get_prach_prb_offset(LTE_DL_FRAME_PARMS *frame_parms,
			     uint8_t prach_ConfigIndex,
1715 1716
			     uint8_t n_ra_prboffset,
			     uint8_t tdd_mapindex, uint16_t Nf);
Florian Kaltenberger's avatar
Florian Kaltenberger committed
1717

1718 1719
/**@}*/
#endif