5G FEC extension

This commit is contained in:
Xavier Arteaga 2020-11-05 18:51:41 +01:00 committed by Andre Puschmann
parent 30037d9223
commit 766a43225d
3 changed files with 32 additions and 10 deletions

View File

@ -39,6 +39,9 @@ typedef struct SRSLTE_API {
uint32_t C1; ///< \brief Number of code blocks of size 1 uint32_t C1; ///< \brief Number of code blocks of size 1
uint32_t C2; ///< \brief Number of code blocks of size 2 uint32_t C2; ///< \brief Number of code blocks of size 2
uint32_t tbs; ///< \brief Actual transport block size uint32_t tbs; ///< \brief Actual transport block size
uint32_t L_tb; ///< \brief Transport block CRC length
uint32_t L_cb; ///< \brief Code block CRC length
uint32_t Z; ///< \brief Lifting size, LDPC only
} srslte_cbsegm_t; } srslte_cbsegm_t;
/** /**
@ -97,6 +100,6 @@ SRSLTE_API int srslte_cbsegm_ldpc_bg1(srslte_cbsegm_t* s, uint32_t tbs);
* @param[in] tbs Input Transport Block Size in bits. CRC's will be added to this * @param[in] tbs Input Transport Block Size in bits. CRC's will be added to this
* @return It returns SRSLTE_SUCCESS if the provided arguments are valid, otherwise it returns SRSLTE_ERROR code * @return It returns SRSLTE_SUCCESS if the provided arguments are valid, otherwise it returns SRSLTE_ERROR code
*/ */
SRSLTE_API int srslte_cbsegm_nr_bg2(srslte_cbsegm_t* s, uint32_t tbs); SRSLTE_API int srslte_cbsegm_ldpc_bg2(srslte_cbsegm_t* s, uint32_t tbs);
#endif // SRSLTE_CBSEGM_H #endif // SRSLTE_CBSEGM_H

View File

@ -97,6 +97,8 @@ int srslte_cbsegm(srslte_cbsegm_t* s, uint32_t tbs)
s->C2 = (s->C * s->K1 - Bp) / (s->K1 - s->K2); s->C2 = (s->C * s->K1 - Bp) / (s->K1 - s->K2);
s->C1 = s->C - s->C2; s->C1 = s->C - s->C2;
} }
s->L_tb = 24; // 24 bit CRC always
s->L_cb = 24; // 24 bit CRC always
s->F = s->C1 * s->K1 + s->C2 * s->K2 - Bp; s->F = s->C1 * s->K1 + s->C2 * s->K2 - Bp;
INFO("CB Segmentation: TBS: %d, C=%d, C+=%d K+=%d, C-=%d, K-=%d, F=%d, Bp=%d\n", INFO("CB Segmentation: TBS: %d, C=%d, C+=%d K+=%d, C-=%d, K-=%d, F=%d, Bp=%d\n",
tbs, tbs,
@ -187,6 +189,23 @@ static int cbsegm_ldpc_select_ls(uint32_t Kp, uint32_t K_b, uint32_t* Z_c, uint8
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
/**
* @brief Calculate the transport block (TB) CRC length for LDPC based shared
*
* @remark Implemented according to TS 38.212 V15.9.0 7.2.1 Transport block CRC attachment
*
* @param tbs Transport block size
* @return The TB CRC length L
*/
static uint32_t srslte_cbsegm_ldpc_L(uint32_t tbs)
{
if (tbs <= 3824) {
return 16;
}
return 24;
}
static int srslte_cbsegm_ldpc(srslte_cbsegm_t* s, srslte_basegraph_t bg, uint32_t tbs) static int srslte_cbsegm_ldpc(srslte_cbsegm_t* s, srslte_basegraph_t bg, uint32_t tbs)
{ {
// Check input pointer // Check input pointer
@ -200,11 +219,14 @@ static int srslte_cbsegm_ldpc(srslte_cbsegm_t* s, srslte_basegraph_t bg, uint32_
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
// Calculate TB CRC length
uint32_t L = srslte_cbsegm_ldpc_L(tbs);
// Select maximum code block size // Select maximum code block size
uint32_t K_cb = (bg == BG1) ? SRSLTE_LDPC_BG1_MAX_LEN_CB : SRSLTE_LDPC_BG2_MAX_LEN_CB; uint32_t K_cb = (bg == BG1) ? SRSLTE_LDPC_BG1_MAX_LEN_CB : SRSLTE_LDPC_BG2_MAX_LEN_CB;
// Calculate CB sizes // Calculate CB sizes
uint32_t B = tbs + 24; uint32_t B = tbs + L;
uint32_t C = 0; uint32_t C = 0;
uint32_t Bp = 0; uint32_t Bp = 0;
cbsegm_cb_size(B, K_cb, &C, &Bp); cbsegm_cb_size(B, K_cb, &C, &Bp);
@ -235,11 +257,14 @@ static int srslte_cbsegm_ldpc(srslte_cbsegm_t* s, srslte_basegraph_t bg, uint32_
// Save segmentation // Save segmentation
s->tbs = tbs; s->tbs = tbs;
s->L_tb = L;
s->L_cb = C > 1 ? 24 : 0;
s->C = C; s->C = C;
s->F = K * C; s->F = K * C;
s->C1 = C; s->C1 = C;
s->K1 = K; s->K1 = K;
s->K1_idx = i_ls; s->K1_idx = i_ls;
s->Z = Z_c;
// Only one CB size is used // Only one CB size is used
s->C2 = 0; s->C2 = 0;

View File

@ -61,12 +61,6 @@ static const uint32_t BASEN[2] = {66, 50};
*/ */
static const uint32_t BASEK[2] = {22, 10}; static const uint32_t BASEK[2] = {22, 10};
/*!
* \brief Look-up table: Retuns the mod order associated to a srslte_mod_t
*
*/
static const uint32_t MODORD[5] = {1, 2, 4, 6, 8};
/*! /*!
* \brief Look-up table: Maximum number of coded bits available for transmission in a * \brief Look-up table: Maximum number of coded bits available for transmission in a
* transport block * transport block
@ -130,7 +124,7 @@ static int init_rm(srslte_ldpc_rm_t* p,
} }
uint32_t basek0 = BASEK0[rv][bg]; uint32_t basek0 = BASEK0[rv][bg];
uint32_t mod_order = MODORD[mod_type]; uint32_t mod_order = srslte_mod_bits_x_symbol(mod_type);
uint32_t N = ls * BASEN[bg]; uint32_t N = ls * BASEN[bg];
uint32_t K = ls * BASEK[bg]; uint32_t K = ls * BASEK[bg];