defs.h 24.6 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
Cedric Roux's avatar
Cedric Roux committed
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 23 24
/* file: PHY/CODING/defs.h
   purpose: Top-level definitions, data types and function prototypes for openairinterface coding blocks
   author: raymond.knopp@eurecom.fr
25
   date: 21.10.2009
26 27 28 29 30 31 32 33 34
*/
#ifndef __CODING_DEFS__H__
#define __CODING_DEFS__H__

#include <stdint.h>

#ifndef NO_OPENAIR1
#include "PHY/defs.h"
#else
35
#include "PHY/TOOLS/time_meas.h"
36
#endif
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

#define CRC24_A 0
#define CRC24_B 1
#define CRC16 2
#define CRC8 3

#define MAX_TURBO_ITERATIONS_MBSFN 8
#define MAX_TURBO_ITERATIONS 4

#define LTE_NULL 2

/** @addtogroup _PHY_CODING_BLOCKS_
 * @{
*/

/** \fn lte_segmentation(uint8_t *input_buffer,
53 54 55 56 57 58 59 60
              uint8_t **output_buffers,
            uint32_t B,
            uint32_t *C,
            uint32_t *Cplus,
            uint32_t *Cminus,
            uint32_t *Kplus,
            uint32_t *Kminus,
            uint32_t *F)
61 62 63 64 65 66 67 68 69 70 71 72
\brief This function implements the LTE transport block segmentation algorithm from 36-212, V8.6 2009-03.
@param input_buffer
@param output_buffers
@param B
@param C
@param Cplus
@param Cminus
@param Kplus
@param Kminus
@param F
*/
int32_t lte_segmentation(uint8_t *input_buffer,
73 74 75 76 77 78 79 80
                         uint8_t **output_buffers,
                         uint32_t B,
                         uint32_t *C,
                         uint32_t *Cplus,
                         uint32_t *Cminus,
                         uint32_t *Kplus,
                         uint32_t *Kminus,
                         uint32_t *F);
81

82 83 84 85 86 87 88 89 90
/** \fn int16_t estimate_ue_tx_power(uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs)
    \brief this functions calculates the delta MCS in dB based on the lte_segmentation function
\param tbs transport block size
\param nb_rb number of required rb
\param control_only a flag for the type of data
\param ncp cyclic prefix
\param use_srs a flag indicating the use of srs in the current SF
\returns ue_tx_power estimated ue tx power = delat_ mcs + bw_factor
*/
91 92 93 94 95
int16_t estimate_ue_tx_power(uint32_t tbs,
                             uint32_t nb_rb,
                             uint8_t control_only,
                             lte_prefix_type_t ncp,
                             uint8_t use_srs);
96

97
/** \fn uint32_t sub_block_interleaving_turbo(uint32_t D, uint8_t *d,uint8_t *w)
98
\brief This is the subblock interleaving algorithm from 36-212 (Release 8, 8.6 2009-03), pages 15-16.
99 100 101 102 103 104 105 106 107
This function takes the d-sequence and generates the w-sequence.  The nu-sequence from 36-212 is implicit.
\param D Number of systematic bits plus 4 (plus 4 for termination)
\param d Pointer to input (d-sequence, turbo code output)
\param w Pointer to output (w-sequence, interleaver output)
\returns Interleaving matrix cardinality (\f$K_{\pi}\f$  from 36-212)
*/
uint32_t sub_block_interleaving_turbo(uint32_t D, uint8_t *d,uint8_t *w);

/** \fn uint32_t sub_block_interleaving_cc(uint32_t D, uint8_t *d,uint8_t *w)
108
\brief This is the subblock interleaving algorithm for convolutionally coded blocks from 36-212 (Release 8, 8.6 2009-03), pages 15-16.
109
This function takes the d-sequence and generates the w-sequence.  The nu-sequence from 36-212 is implicit.
110
\param D Number of input bits
111 112 113 114 115 116 117 118
\param d Pointer to input (d-sequence, convolutional code output)
\param w Pointer to output (w-sequence, interleaver output)
\returns Interleaving matrix cardinality (\f$K_{\pi}\f$  from 36-212)
*/
uint32_t sub_block_interleaving_cc(uint32_t D, uint8_t *d,uint8_t *w);


/** \fn void sub_block_deinterleaving_turbo(uint32_t D, int16_t *d,int16_t *w)
119
\brief This is the subblock deinterleaving algorithm from 36-212 (Release 8, 8.6 2009-03), pages 15-16.
120 121 122 123 124 125 126 127
This function takes the w-sequence and generates the d-sequence.  The nu-sequence from 36-212 is implicit.
\param D Number of systematic bits plus 4 (plus 4 for termination)
\param d Pointer to output (d-sequence, turbo code output)
\param w Pointer to input (w-sequence, interleaver output)
*/
void sub_block_deinterleaving_turbo(uint32_t D, int16_t *d,int16_t *w);

/** \fn void sub_block_deinterleaving_cc(uint32_t D, int8_t *d,int8_t *w)
128
\brief This is the subblock deinterleaving algorithm for convolutionally-coded data from 36-212 (Release 8, 8.6 2009-03), pages 15-16.
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
This function takes the w-sequence and generates the d-sequence.  The nu-sequence from 36-212 is implicit.
\param D Number of input bits
\param d Pointer to output (d-sequence, turbo code output)
\param w Pointer to input (w-sequence, interleaver output)
*/
void sub_block_deinterleaving_cc(uint32_t D,int8_t *d,int8_t *w);

/** \fn generate_dummy_w(uint32_t D, uint8_t *w,uint8_t F)
\brief This function generates a dummy interleaved sequence (first row) for receiver, in order to identify
the NULL positions used to make the matrix complete.
\param D Number of systematic bits plus 4 (plus 4 for termination)
\param w This is the dummy sequence (first row), it will contain zeros and at most 31 "LTE_NULL" values
\param F Number of filler bits due added during segmentation
\returns Interleaving matrix cardinality (\f$K_{\pi}\f$ from 36-212)
*/

uint32_t generate_dummy_w(uint32_t D, uint8_t *w, uint8_t F);

/** \fn generate_dummy_w_cc(uint32_t D, uint8_t *w)
\brief This function generates a dummy interleaved sequence (first row) for receiver (convolutionally-coded data), in order to identify the NULL positions used to make the matrix complete.
\param D Number of systematic bits plus 4 (plus 4 for termination)
\param w This is the dummy sequence (first row), it will contain zeros and at most 31 "LTE_NULL" values
\returns Interleaving matrix cardinality (\f$K_{\pi}\f$ from 36-212)
*/
uint32_t generate_dummy_w_cc(uint32_t D, uint8_t *w);

/** \fn uint32_t lte_rate_matching_turbo(uint32_t RTC,
156 157 158 159 160 161 162 163 164 165 166
           uint32_t G,
           uint8_t *w,
           uint8_t *e,
           uint8_t C,
           uint32_t Nsoft,
           uint8_t Mdlharq,
           uint8_t Kmimo,
           uint8_t rvidx,
           uint8_t Qm,
           uint8_t Nl,
           uint8_t r)
167 168 169 170 171 172 173 174

\brief This is the LTE rate matching algorithm for Turbo-coded channels (e.g. DLSCH,ULSCH).  It is taken directly from 36-212 (Rel 8 8.6, 2009-03), pages 16-18 )
\param RTC R^TC_subblock from subblock interleaver (number of rows in interleaving matrix) for up to 8 segments
\param G This the number of coded transport bits allocated in sub-frame
\param w This is a pointer to the w-sequence (second interleaver output)
\param e This is a pointer to the e-sequence (rate matching output, channel input/output bits)
\param C Number of segments (codewords) in the sub-frame
\param Nsoft Total number of soft bits (from UE capabilities in 36-306)
175
\param Mdlharq Number of HARQ rounds
176 177 178 179 180
\param Kmimo MIMO capability for this DLSCH (0 = no MIMO)
\param rvidx round index (0-3)
\param Qm modulation order (2,4,6)
\param Nl number of layers (1,2)
\param r segment number
181
\param nb_rb Number of PRBs
182 183 184 185
\returns \f$E\f$, the number of coded bits per segment */


uint32_t lte_rate_matching_turbo(uint32_t RTC,
186 187 188 189 190 191 192 193 194 195 196
                                 uint32_t G,
                                 uint8_t *w,
                                 uint8_t *e,
                                 uint8_t C,
                                 uint32_t Nsoft,
                                 uint8_t Mdlharq,
                                 uint8_t Kmimo,
                                 uint8_t rvidx,
                                 uint8_t Qm,
                                 uint8_t Nl,
                                 uint8_t r,
197
                                 uint8_t nb_rb);
198 199

/**
200 201 202 203 204 205 206 207
\brief This is the LTE rate matching algorithm for Convolutionally-coded channels (e.g. BCH,DCI,UCI).  It is taken directly from 36-212 (Rel 8 8.6, 2009-03), pages 16-18 )
\param RCC R^CC_subblock from subblock interleaver (number of rows in interleaving matrix) for up to 8 segments
\param E Number of coded channel bits
\param w This is a pointer to the w-sequence (second interleaver output)
\param e This is a pointer to the e-sequence (rate matching output, channel input/output bits)
\returns \f$E\f$, the number of coded bits per segment */

uint32_t lte_rate_matching_cc(uint32_t RCC,
208 209 210
                              uint16_t E,
                              uint8_t *w,
                              uint8_t *e);
211

212
/**
213 214 215
\brief This is the LTE rate matching algorithm for Turbo-coded channels (e.g. DLSCH,ULSCH).  It is taken directly from 36-212 (Rel 8 8.6, 2009-03), pages 16-18 )
\param RTC R^TC_subblock from subblock interleaver (number of rows in interleaving matrix)
\param G This the number of coded transport bits allocated in sub-frame
216
\param w This is a pointer to the soft w-sequence (second interleaver output) with soft-combined outputs from successive HARQ rounds
217
\param dummy_w This is the first row of the interleaver matrix for identifying/discarding the "LTE-NULL" positions
218
\param soft_input This is a pointer to the soft channel output
219 220
\param C Number of segments (codewords) in the sub-frame
\param Nsoft Total number of soft bits (from UE capabilities in 36-306)
221
\param Mdlharq Number of HARQ rounds
222 223 224 225 226 227
\param Kmimo MIMO capability for this DLSCH (0 = no MIMO)
\param rvidx round index (0-3)
\param clear 1 means clear soft buffer (start of HARQ round)
\param Qm modulation order (2,4,6)
\param Nl number of layers (1,2)
\param r segment number
228
\param E_out the number of coded bits per segment
229 230 231 232
\returns 0 on success, -1 on failure
*/

int lte_rate_matching_turbo_rx(uint32_t RTC,
233 234 235 236 237 238 239 240 241 242 243 244 245 246
                               uint32_t G,
                               int16_t *w,
                               uint8_t *dummy_w,
                               int16_t *soft_input,
                               uint8_t C,
                               uint32_t Nsoft,
                               uint8_t Mdlharq,
                               uint8_t Kmimo,
                               uint8_t rvidx,
                               uint8_t clear,
                               uint8_t Qm,
                               uint8_t Nl,
                               uint8_t r,
                               uint32_t *E_out);
247 248

uint32_t lte_rate_matching_turbo_rx_abs(uint32_t RTC,
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
                                        uint32_t G,
                                        double *w,
                                        uint8_t *dummy_w,
                                        double *soft_input,
                                        uint8_t C,
                                        uint32_t Nsoft,
                                        uint8_t Mdlharq,
                                        uint8_t Kmimo,
                                        uint8_t rvidx,
                                        uint8_t clear,
                                        uint8_t Qm,
                                        uint8_t Nl,
                                        uint8_t r,
                                        uint32_t *E_out);
/**
264 265 266 267

\brief This is the LTE rate matching algorithm for Convolutionally-coded channels (e.g. BCH,DCI,UCI).  It is taken directly from 36-212 (Rel 8 8.6, 2009-03), pages 16-18 )
\param RCC R^CC_subblock from subblock interleaver (number of rows in interleaving matrix)
\param E This the number of coded bits allocated for channel
268
\param w This is a pointer to the soft w-sequence (second interleaver output) with soft-combined outputs from successive HARQ rounds
269
\param dummy_w This is the first row of the interleaver matrix for identifying/discarding the "LTE-NULL" positions
270 271
\param soft_input This is a pointer to the soft channel output
\returns \f$E\f$, the number of coded bits per segment
272 273
*/
void lte_rate_matching_cc_rx(uint32_t RCC,
274 275 276 277
                             uint16_t E,
                             int8_t *w,
                             uint8_t *dummy_w,
                             int8_t *soft_input);
278 279 280 281 282 283 284 285

/** \fn void ccodedot11_encode(uint32_t numbytes,uint8_t *inPtr,uint8_t *outPtr,uint8_t puncturing)
\brief This function implements a rate 1/2 constraint length 7 convolutional code.
@param numbytes Number of bytes to encode
@param inPtr Pointer to input buffer
@param outPtr Pointer to output buffer
@param puncturing Puncturing pattern (Not used at present, to be removed)
*/
286 287 288 289
void ccodedot11_encode (uint32_t numbytes,
                        uint8_t *inPtr,
                        uint8_t *outPtr,
                        uint8_t puncturing);
290 291 292

/*!\fn void ccodedot11_init(void)
\brief This function initializes the generator polynomials for an 802.11 convolutional code.*/
293
void ccodedot11_init(void);
294 295 296

/*!\fn void ccodedot11_init_inv(void)
\brief This function initializes the trellis structure for decoding an 802.11 convolutional code.*/
297
void ccodedot11_init_inv(void);
298

299 300 301 302
/*!\fn void teillis_table_init(void)
\brief This function initializes the trellis structure for 3GPP LTE Turbo code.*/
void treillis_table_init(void);

303 304 305 306 307 308 309 310 311 312
/*\fn void threegpplte_turbo_encoder(uint8_t *input,uint16_t input_length_bytes,uint8_t *output,uint8_t F,uint16_t interleaver_f1,uint16_t interleaver_f2)
\brief This function implements a rate 1/3 8-state parralel concatenated turbo code (3GPP-LTE).
@param input Pointer to input buffer
@param input_length_bytes Number of bytes to encode
@param output Pointer to output buffer
@param F Number of filler bits at input
@param interleaver_f1 F1 generator
@param interleaver_f2 F2 generator
*/
void threegpplte_turbo_encoder(uint8_t *input,
313 314 315 316 317
                               uint16_t input_length_bytes,
                               uint8_t *output,
                               uint8_t F,
                               uint16_t interleaver_f1,
                               uint16_t interleaver_f2);
318 319


320
/** \fn void ccodelte_encode(int32_t numbits,uint8_t add_crc, uint8_t *inPtr,uint8_t *outPtr,uint16_t rnti)
321
\brief This function implements the LTE convolutional code of rate 1/3
322
  with a constraint length of 7 bits. The inputs are bit packed in octets
323 324 325 326 327 328 329 330
(from MSB to LSB). Trellis tail-biting is included here.
@param numbits Number of bits to encode
@param add_crc crc to be appended (8 bits) if add_crc = 1
@param inPtr Pointer to input buffer
@param outPtr Pointer to output buffer
@param rnti RNTI for CRC scrambling
*/
void
331
ccodelte_encode (int32_t numbits,
332 333 334 335
                 uint8_t add_crc,
                 uint8_t *inPtr,
                 uint8_t *outPtr,
                 uint16_t rnti);
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352

/*!\fn void ccodelte_init(void)
\brief This function initializes the generator polynomials for an LTE convolutional code.*/
void ccodelte_init(void);

/*!\fn void ccodelte_init_inv(void)
\brief This function initializes the trellis structure for decoding an LTE convolutional code.*/
void ccodelte_init_inv(void);

/*!\fn void ccodelte_init(void)
\brief This function initializes the generator polynomials for an DAB convolutional code (first 3 bits).*/
void ccodedab_init(void);

/*!\fn void ccodelte_init_inv(void)
\brief This function initializes the trellis structure for decoding an DAB convolutional code (first 3 bits).*/
void ccodedab_init_inv(void);

353 354


355 356 357 358
/*!\fn void crcTableInit(void)
\brief This function initializes the different crc tables.*/
void crcTableInit (void);

359 360 361 362
/*!\fn void free_td8(void)
\brief This function frees the tables for 8-bit LLR Turbo decoder.*/
void free_td8(void);

363 364 365 366
/*!\fn void init_td8(void)
\brief This function initializes the tables for 8-bit LLR Turbo decoder.*/
void init_td8 (void);

367 368 369
/*!\fn void free_td16(void)
\brief This function frees the tables for 16-bit LLR Turbo decoder.*/
void free_td16(void);
370 371 372 373 374

/*!\fn void init_td16(void)
\brief This function initializes the tables for 16-bit LLR Turbo decoder.*/
void init_td16 (void);

375 376 377 378 379
#ifdef __AVX2__
/*!\fn void init_td8(void)
\brief This function initializes the tables for 8-bit LLR Turbo decoder (AVX2).*/
void init_td8avx2 (void);

380 381 382
/*!\fn void free_td16avx2(void)
\brief This function frees the tables for 16-bit LLR Turbo decoder (AVX2).*/
void free_td16avx2(void);
383 384 385 386 387 388

/*!\fn void init_td16(void)
\brief This function initializes the tables for 16-bit LLR Turbo decoder (AVX2).*/
void init_td16avx2 (void);
#endif

389
/*!\fn uint32_t crc24a(uint8_t *inPtr, int32_t bitlen)
390
\brief This computes a 24-bit crc ('a' variant for overall transport block)
391 392 393 394 395 396 397
based on 3GPP UMTS/LTE specifications.
@param inPtr Pointer to input byte stream
@param bitlen length of inputs in bits
*/
uint32_t crc24a (uint8_t *inPtr, int32_t bitlen);

/*!\fn uint32_t crc24b(uint8_t *inPtr, int32_t bitlen)
398
\brief This computes a 24-bit crc ('b' variant for transport-block segments)
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
based on 3GPP UMTS/LTE specifications.
@param inPtr Pointer to input byte stream
@param bitlen length of inputs in bits
*/
uint32_t crc24b (uint8_t *inPtr, int32_t bitlen);

/*!\fn uint32_t crc16(uint8_t *inPtr, int32_t bitlen)
\brief This computes a 16-bit crc based on 3GPP UMTS specifications.
@param inPtr Pointer to input byte stream
@param bitlen length of inputs in bits*/
uint32_t crc16 (uint8_t *inPtr, int32_t bitlen);

/*!\fn uint32_t crc12(uint8_t *inPtr, int32_t bitlen)
\brief This computes a 12-bit crc based on 3GPP UMTS specifications.
@param inPtr Pointer to input byte stream
@param bitlen length of inputs in bits*/
uint32_t crc12 (uint8_t *inPtr, int32_t bitlen);

/*!\fn uint32_t crc8(uint8_t *inPtr, int32_t bitlen)
\brief This computes a 8-bit crc based on 3GPP UMTS specifications.
@param inPtr Pointer to input byte stream
@param bitlen length of inputs in bits*/
uint32_t crc8  (uint8_t *inPtr, int32_t bitlen);

/*!\fn void phy_viterbi_dot11_sse2(int8_t *y, uint8_t *decoded_bytes, uint16_t n,int offset,int traceback)
\brief This routine performs a SIMD optmized Viterbi decoder for the 802.11 64-state convolutional code. It can be
run in segments with final trace back after last segment.
@param y Pointer to soft input (coded on 8-bits but should be limited to 4-bit precision to avoid overflow)
@param decoded_bytes Pointer to decoded output
@param n Length of input/trellis depth in bits for this run
@param offset offset in receive buffer for segment on which to operate
@param traceback flag to indicate that traceback should be performed*/
void phy_viterbi_dot11_sse2(int8_t *y,uint8_t *decoded_bytes,uint16_t n);

433
/*!\fn void phy_viterbi_lte_sse2(int8_t *y, uint8_t *decoded_bytes, uint16_t n)
434 435 436 437
\brief This routine performs a SIMD optmized Viterbi decoder for the LTE 64-state tail-biting convolutional code.
@param y Pointer to soft input (coded on 8-bits but should be limited to 4-bit precision to avoid overflow)
@param decoded_bytes Pointer to decoded output
@param n Length of input/trellis depth in bits*/
438
//void phy_viterbi_lte_sse2(int8_t *y,uint8_t *decoded_bytes,uint16_t n);
439
void phy_viterbi_lte_sse2(int8_t *y,uint8_t *decoded_bytes,uint16_t n);
440 441 442 443 444 445 446 447 448 449 450 451

/*!\fn void phy_generate_viterbi_tables(void)
\brief This routine initializes metric tables for the optimized Viterbi decoder.
*/
void phy_generate_viterbi_tables( void );

/*!\fn void phy_generate_viterbi_tables_lte(void)
\brief This routine initializes metric tables for the optimized LTE Viterbi decoder.
*/
void phy_generate_viterbi_tables_lte( void );


452 453 454 455 456
/*!\fn int32_t rate_matching(uint32_t N_coded,
             uint32_t N_input,
             uint8_t *inPtr,
             uint8_t N_bps,
             uint32_t off)
457 458 459 460 461 462 463 464
\brief This routine performs random puncturing of a coded sequence.
@param N_coded Number of coding bits to be output
@param N_input Number of input bits
@param *inPtr Pointer to coded input
@param N_bps Number of modulation bits per symbol (1,2,4)
@param off Offset for seed

*/
465 466 467 468 469
int32_t rate_matching(uint32_t N_coded,
                      uint32_t N_input,
                      uint8_t *inPtr,
                      uint8_t N_bps,
                      uint32_t off);
470

471 472 473 474
int32_t rate_matching_lte(uint32_t N_coded,
                          uint32_t N_input,
                          uint8_t *inPtr,
                          uint32_t off);
475 476 477 478 479 480 481 482 483 484 485 486


/*!
\brief This routine performs max-logmap detection for the 3GPP turbo code (with termination).  It is optimized for SIMD processing and 16-bit
LLR arithmetic, and requires SSE2,SSSE3 and SSE4.1 (gcc >=4.3 and appropriate CPU)
@param y LLR input (16-bit precision)
@param decoded_bytes Pointer to decoded output
@param n number of coded bits (including tail bits)
@param max_iterations The maximum number of iterations to perform
@param interleaver_f1 F1 generator
@param interleaver_f2 F2 generator
@param crc_type Length of 3GPPLTE crc (CRC24a,CRC24b,CRC16,CRC8)
487
@param F Number of filler bits at start of packet
488 489 490
@returns number of iterations used (this is 1+max if incorrect crc or if crc_len=0)
*/
uint8_t phy_threegpplte_turbo_decoder16(int16_t *y,
491 492 493 494 495 496 497 498 499 500 501 502 503 504
                                        uint8_t *decoded_bytes,
                                        uint16_t n,
                                        uint16_t interleaver_f1,
                                        uint16_t interleaver_f2,
                                        uint8_t max_iterations,
                                        uint8_t crc_type,
                                        uint8_t F,
                                        time_stats_t *init_stats,
                                        time_stats_t *alpha_stats,
                                        time_stats_t *beta_stats,
                                        time_stats_t *gamma_stats,
                                        time_stats_t *ext_stats,
                                        time_stats_t *intl1_stats,
                                        time_stats_t *intl2_stats);
505

506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523
uint8_t phy_threegpplte_turbo_decoder16avx2(int16_t *y,
					    int16_t *y2,
					    uint8_t *decoded_bytes,
					    uint8_t *decoded_bytes2,
					    uint16_t n,
					    uint16_t interleaver_f1,
					    uint16_t interleaver_f2,
					    uint8_t max_iterations,
					    uint8_t crc_type,
					    uint8_t F,
					    time_stats_t *init_stats,
					    time_stats_t *alpha_stats,
					    time_stats_t *beta_stats,
					    time_stats_t *gamma_stats,
					    time_stats_t *ext_stats,
					    time_stats_t *intl1_stats,
					    time_stats_t *intl2_stats);

524 525 526 527 528 529 530 531 532 533
/*!
\brief This routine performs max-logmap detection for the 3GPP turbo code (with termination).  It is optimized for SIMD processing and 8-bit
LLR arithmetic, and requires SSE2,SSSE3 and SSE4.1 (gcc >=4.3 and appropriate CPU)
@param y LLR input (16-bit precision)
@param decoded_bytes Pointer to decoded output
@param n number of coded bits (including tail bits)
@param max_iterations The maximum number of iterations to perform
@param interleaver_f1 F1 generator
@param interleaver_f2 F2 generator
@param crc_type Length of 3GPPLTE crc (CRC24a,CRC24b,CRC16,CRC8)
534
@param F Number of filler bits at start of packet
535 536 537
@returns number of iterations used (this is 1+max if incorrect crc or if crc_len=0)
*/
uint8_t phy_threegpplte_turbo_decoder8(int16_t *y,
538 539 540 541 542 543 544 545 546 547 548 549 550 551
                                       uint8_t *decoded_bytes,
                                       uint16_t n,
                                       uint16_t interleaver_f1,
                                       uint16_t interleaver_f2,
                                       uint8_t max_iterations,
                                       uint8_t crc_type,
                                       uint8_t F,
                                       time_stats_t *init_stats,
                                       time_stats_t *alpha_stats,
                                       time_stats_t *beta_stats,
                                       time_stats_t *gamma_stats,
                                       time_stats_t *ext_stats,
                                       time_stats_t *intl1_stats,
                                       time_stats_t *intl2_stats);
552 553

uint8_t phy_threegpplte_turbo_decoder_scalar(int16_t *y,
554 555 556 557 558 559 560 561
    uint8_t *decoded_bytes,
    uint16_t n,
    uint16_t interleaver_f1,
    uint16_t interleaver_f2,
    uint8_t max_iterations,
    uint8_t crc_type,
    uint8_t F,
    uint8_t inst);
562 563 564 565 566



/** @} */

567 568 569
uint32_t crcbit (uint8_t * ,
                 int32_t,
                 uint32_t);
570 571 572 573 574

int16_t reverseBits(int32_t ,int32_t);
void phy_viterbi_dot11(int8_t *,uint8_t *,uint16_t);

#endif