mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
4.4 KiB
C
112 lines
4.4 KiB
C
4 years ago
|
/**
|
||
4 years ago
|
*
|
||
4 years ago
|
* \section COPYRIGHT
|
||
4 years ago
|
*
|
||
4 years ago
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||
4 years ago
|
*
|
||
4 years ago
|
* By using this file, you agree to the terms and conditions set
|
||
|
* forth in the LICENSE file which can be found at the top level of
|
||
|
* the distribution.
|
||
4 years ago
|
*
|
||
|
*/
|
||
|
|
||
|
/*!
|
||
|
* \file ldpc_encoder.h
|
||
|
* \brief Declaration of the LDPC encoder.
|
||
4 years ago
|
* \author David Gregoratti and Jesus Gomez
|
||
4 years ago
|
* \date 2020
|
||
|
*
|
||
|
* \copyright Software Radio Systems Limited
|
||
|
*
|
||
|
*/
|
||
|
|
||
4 years ago
|
#ifndef SRSRAN_LDPCENCODER_H
|
||
|
#define SRSRAN_LDPCENCODER_H
|
||
4 years ago
|
|
||
4 years ago
|
#include "srsran/phy/fec/ldpc/base_graph.h"
|
||
4 years ago
|
|
||
|
/*!
|
||
|
* \brief Types of LDPC encoder.
|
||
|
*/
|
||
4 years ago
|
typedef enum SRSRAN_API {
|
||
|
SRSRAN_LDPC_ENCODER_C = 0, /*!< \brief Non-optimized encoder. */
|
||
4 years ago
|
#if LV_HAVE_AVX2
|
||
4 years ago
|
SRSRAN_LDPC_ENCODER_AVX2, /*!< \brief SIMD-optimized encoder. */
|
||
4 years ago
|
#endif // LV_HAVE_AVX2
|
||
4 years ago
|
#if LV_HAVE_AVX512
|
||
4 years ago
|
SRSRAN_LDPC_ENCODER_AVX512, /*!< \brief SIMD-optimized encoder. */
|
||
4 years ago
|
#endif // LV_HAVE_AVX512
|
||
4 years ago
|
} srsran_ldpc_encoder_type_t;
|
||
4 years ago
|
|
||
|
/*!
|
||
|
* \brief Describes an LDPC encoder.
|
||
|
*/
|
||
4 years ago
|
typedef struct SRSRAN_API {
|
||
4 years ago
|
void* ptr; /*!< \brief %Encoder auxiliary registers. */
|
||
4 years ago
|
srsran_basegraph_t bg; /*!< \brief Current base graph. */
|
||
4 years ago
|
uint16_t ls; /*!< \brief Current lifting size. */
|
||
|
uint8_t bgN; /*!< \brief Number of variable nodes in the BG. */
|
||
|
uint16_t liftN; /*!< \brief Number of variable nodes in the lifted graph. */
|
||
|
uint8_t bgM; /*!< \brief Number of check nodes in the BG. */
|
||
|
uint16_t liftM; /*!< \brief Number of check nodes in the lifted graph. */
|
||
|
uint8_t bgK; /*!< \brief Number of "uncoded bits" in the BG. */
|
||
|
uint16_t liftK; /*!< \brief Number of uncoded bits in the lifted graph. */
|
||
|
uint16_t* pcm; /*!< \brief Pointer to the parity check matrix (compact form). */
|
||
|
void (*free)(void*); /*!< \brief Pointer to a "destructor". */
|
||
|
/*! \brief Pointer to the encoder function. */
|
||
|
int (*encode)(void*, const uint8_t*, uint8_t*, uint32_t, uint32_t);
|
||
|
/*! \brief Pointer to the encoder for the high-rate region. */
|
||
|
void (*encode_high_rate)(void*, uint8_t*);
|
||
|
/*! \brief Pointer to the encoder for the high-rate region (SIMD-optimized version). */
|
||
|
void (*encode_high_rate_avx2)(void*);
|
||
4 years ago
|
/*! \brief Pointer to the encoder for the high-rate region (SIMD-AVX512-optimized version). */
|
||
|
void (*encode_high_rate_avx512)(void*);
|
||
4 years ago
|
|
||
4 years ago
|
} srsran_ldpc_encoder_t;
|
||
4 years ago
|
|
||
|
/*!
|
||
|
* Initializes all the LDPC encoder variables according to the given base graph
|
||
|
* and lifting size.
|
||
4 years ago
|
* \param[out] q A pointer to a srsran_ldpc_encoder_t structure.
|
||
4 years ago
|
* \param[in] type The encoder type.
|
||
|
* \param[in] bg The desired base graph (BG1 or BG2).
|
||
|
* \param[in] ls The desired lifting size.
|
||
|
* \return An integer: 0 if the function executes correctly, -1 otherwise.
|
||
|
*/
|
||
4 years ago
|
SRSRAN_API int
|
||
|
srsran_ldpc_encoder_init(srsran_ldpc_encoder_t* q, srsran_ldpc_encoder_type_t type, srsran_basegraph_t bg, uint16_t ls);
|
||
4 years ago
|
|
||
|
/*!
|
||
|
* The LDPC encoder "destructor": it frees all the resources allocated to the encoder.
|
||
|
* \param[in] q A pointer to the dismantled encoder.
|
||
|
*/
|
||
4 years ago
|
SRSRAN_API void srsran_ldpc_encoder_free(srsran_ldpc_encoder_t* q);
|
||
4 years ago
|
|
||
4 years ago
|
/*!
|
||
|
* Encodes a message into a codeword with the specified encoder.
|
||
|
* \param[in] q A pointer to the desired encoder.
|
||
|
* \param[in] input The message to encode.
|
||
|
* \param[out] output The resulting codeword.
|
||
|
* \param[in] input_length The number of uncoded bits in the input message.
|
||
|
* \return An integer: 0 if the function executes correctly, -1 otherwise.
|
||
|
*/
|
||
4 years ago
|
SRSRAN_API int
|
||
|
srsran_ldpc_encoder_encode(srsran_ldpc_encoder_t* q, const uint8_t* input, uint8_t* output, uint32_t input_length);
|
||
4 years ago
|
|
||
4 years ago
|
/*!
|
||
|
* Encodes a message into a codeword with the specified encoder.
|
||
|
* \param[in] q A pointer to the desired encoder.
|
||
|
* \param[in] input The message to encode.
|
||
|
* \param[out] output The resulting codeword.
|
||
|
* \param[in] input_length The number of uncoded bits in the input message.
|
||
|
* \param[in] cdwd_rm_length The codeword length after rate matching.
|
||
|
* \return An integer: 0 if the function executes correctly, -1 otherwise.
|
||
|
*/
|
||
4 years ago
|
SRSRAN_API int srsran_ldpc_encoder_encode_rm(srsran_ldpc_encoder_t* q,
|
||
4 years ago
|
const uint8_t* input,
|
||
|
uint8_t* output,
|
||
|
uint32_t input_length,
|
||
|
uint32_t cdwd_rm_length);
|
||
4 years ago
|
|
||
4 years ago
|
#endif // SRSRAN_LDPCENCODER_H
|