2019-04-26 12:27:38 -07:00
|
|
|
/*
|
2020-03-13 04:12:52 -07:00
|
|
|
* Copyright 2013-2020 Software Radio Systems Limited
|
2014-03-03 11:09:26 -08:00
|
|
|
*
|
2019-04-26 12:27:38 -07:00
|
|
|
* This file is part of srsLTE.
|
2014-03-03 11:09:26 -08:00
|
|
|
*
|
2015-03-18 05:31:13 -07:00
|
|
|
* srsLTE is free software: you can redistribute it and/or modify
|
2015-05-08 08:05:40 -07:00
|
|
|
* it under the terms of the GNU Affero General Public License as
|
2014-03-03 11:09:26 -08:00
|
|
|
* published by the Free Software Foundation, either version 3 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
2015-03-18 05:31:13 -07:00
|
|
|
* srsLTE is distributed in the hope that it will be useful,
|
2014-03-03 11:09:26 -08:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2015-05-08 08:05:40 -07:00
|
|
|
* GNU Affero General Public License for more details.
|
2014-03-03 11:09:26 -08:00
|
|
|
*
|
2015-05-08 08:05:40 -07:00
|
|
|
* A copy of the GNU Affero General Public License can be found in
|
2014-03-03 11:09:26 -08:00
|
|
|
* the LICENSE file in the top-level directory of this distribution
|
|
|
|
* and at http://www.gnu.org/licenses/.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-04-03 05:49:12 -07:00
|
|
|
/******************************************************************************
|
|
|
|
* File: bit.h
|
|
|
|
*
|
|
|
|
* Description: Bit-level utilities.
|
|
|
|
*
|
|
|
|
* Reference:
|
|
|
|
*****************************************************************************/
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2018-03-31 10:04:04 -07:00
|
|
|
#ifndef SRSLTE_BIT_H
|
|
|
|
#define SRSLTE_BIT_H
|
2014-03-03 11:09:26 -08:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2015-03-18 05:16:28 -07:00
|
|
|
#include "srslte/config.h"
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2017-10-23 05:23:03 -07:00
|
|
|
typedef struct {
|
2019-12-16 07:04:22 -08:00
|
|
|
uint32_t nof_bits;
|
|
|
|
uint16_t* interleaver;
|
|
|
|
uint16_t* byte_idx;
|
|
|
|
uint8_t* bit_mask;
|
|
|
|
uint8_t n_128;
|
2017-10-23 05:23:03 -07:00
|
|
|
} srslte_bit_interleaver_t;
|
|
|
|
|
2019-12-16 07:04:22 -08:00
|
|
|
SRSLTE_API void srslte_bit_interleaver_init(srslte_bit_interleaver_t* q, uint16_t* interleaver, uint32_t nof_bits);
|
|
|
|
|
|
|
|
SRSLTE_API void srslte_bit_interleaver_free(srslte_bit_interleaver_t* q);
|
|
|
|
|
|
|
|
SRSLTE_API void
|
|
|
|
srslte_bit_interleaver_run(srslte_bit_interleaver_t* q, uint8_t* input, uint8_t* output, uint16_t w_offset);
|
|
|
|
|
|
|
|
SRSLTE_API void srslte_bit_interleave(uint8_t* input, uint8_t* output, uint16_t* interleaver, uint32_t nof_bits);
|
|
|
|
|
|
|
|
SRSLTE_API void
|
|
|
|
srslte_bit_copy(uint8_t* dst, uint32_t dst_offset, uint8_t* src, uint32_t src_offset, uint32_t nof_bits);
|
|
|
|
|
|
|
|
SRSLTE_API void srslte_bit_interleave_i(uint8_t* input, uint8_t* output, uint32_t* interleaver, uint32_t nof_bits);
|
|
|
|
|
|
|
|
SRSLTE_API void srslte_bit_interleave_i_w_offset(uint8_t* input,
|
|
|
|
uint8_t* output,
|
|
|
|
uint32_t* interleaver,
|
|
|
|
uint32_t nof_bits,
|
|
|
|
uint32_t w_offset);
|
|
|
|
|
|
|
|
SRSLTE_API void srslte_bit_interleave_w_offset(uint8_t* input,
|
|
|
|
uint8_t* output,
|
|
|
|
uint16_t* interleaver,
|
|
|
|
uint32_t nof_bits,
|
|
|
|
uint32_t w_offset);
|
|
|
|
|
2020-11-05 09:54:43 -08:00
|
|
|
SRSLTE_API void srslte_bit_unpack_vector(const uint8_t* packed, uint8_t* unpacked, int nof_bits);
|
2019-12-16 07:04:22 -08:00
|
|
|
|
|
|
|
SRSLTE_API void srslte_bit_pack_vector(uint8_t* unpacked, uint8_t* packed, int nof_bits);
|
|
|
|
|
|
|
|
SRSLTE_API uint32_t srslte_bit_pack(uint8_t** bits, int nof_bits);
|
|
|
|
|
|
|
|
SRSLTE_API uint64_t srslte_bit_pack_l(uint8_t** bits, int nof_bits);
|
|
|
|
|
|
|
|
SRSLTE_API void srslte_bit_unpack_l(uint64_t value, uint8_t** bits, int nof_bits);
|
|
|
|
|
|
|
|
SRSLTE_API void srslte_bit_unpack(uint32_t value, uint8_t** bits, int nof_bits);
|
|
|
|
|
|
|
|
SRSLTE_API void srslte_bit_fprint(FILE* stream, uint8_t* bits, int nof_bits);
|
|
|
|
|
2020-01-10 04:56:13 -08:00
|
|
|
SRSLTE_API uint32_t srslte_bit_diff(const uint8_t* x, const uint8_t* y, int nbits);
|
2014-10-18 09:26:21 -07:00
|
|
|
|
2015-03-18 11:14:24 -07:00
|
|
|
SRSLTE_API uint32_t srslte_bit_count(uint32_t n);
|
2014-06-13 04:42:29 -07:00
|
|
|
|
2018-03-31 10:04:04 -07:00
|
|
|
#endif // SRSLTE_BIT_H
|