Commit 6f351c3d authored by sebastian's avatar sebastian

Fixed bug in llr2CnProcBuf, started updating documentation

parent d2875d02
......@@ -38,7 +38,7 @@
#include "nrLDPC_cnProc.h"
#include "nrLDPC_bnProc.h"
#define NR_LDPC_ENABLE_PARITY_CHECK
//#define NR_LDPC_ENABLE_PARITY_CHECK
//#define NR_LDPC_PROFILER_DETAIL
#ifdef NR_LDPC_DEBUG_MODE
......@@ -96,6 +96,8 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP
{
// Use LLR processing buffer as temporary output buffer
p_llrOut = p_procBuf->llrProcBuf;
// Clear llrProcBuf
memset(p_llrOut,0, NR_LDPC_MAX_NUM_LLR*sizeof(int8_t));
}
......@@ -232,7 +234,6 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP
while ( (i < (numMaxIter-1)) && (pcRes != 0) )
{
//mexPrintf("Start Main Loop: i=%d, numMaxIter=%d, pcRes = %d\n",i,numMaxIter,pcRes);
// Increase iteration counter
i++;
......@@ -334,12 +335,10 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP
{
pcRes = nrLDPC_cnProcPc_BG2(p_lut, p_procBuf, Z);
}
//mexPrintf("End Main Loop: Iter: i=%d, pcRes=%d\n",i,pcRes);
#ifdef NR_LDPC_PROFILER_DETAIL
stop_meas(&p_profiler->cnProcPc);
#endif
#endif
}
// Last iteration
......@@ -347,7 +346,6 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP
{
// Increase iteration counter
i++;
//mexPrintf("Start Last Iter: i=%d, numMaxIter=%d, pcRes = %d\n",i,numMaxIter,pcRes);
// CN processing
#ifdef NR_LDPC_PROFILER_DETAIL
......@@ -458,11 +456,13 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP
// If maximum number of iterations reached an PC still fails increase number of iterations
// Thus, i > numMaxIter indicates that PC has failed
//mexPrintf("End: Iter: i=%d, pcRes=%d\n",i,pcRes);
#ifdef NR_LDPC_ENABLE_PARITY_CHECK
if (pcRes != 0)
{
i++;
}
#endif
// Assign results from processing buffer to output
#ifdef NR_LDPC_PROFILER_DETAIL
......
......@@ -197,5 +197,6 @@ static const int8_t ones256_epi8[32] __attribute__ ((aligned(32))) = {1,1,1,1,1,
static const int8_t zeros256_epi8[32] __attribute__ ((aligned(32))) = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
/** Vector of 32 '127' in int8 for application with AVX2 */
static const int8_t maxLLR256_epi8[32] __attribute__ ((aligned(32))) = {127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127};
static const int8_t minLLR256_epi8[32] __attribute__ ((aligned(32))) = {-127,-127,-127,-127,-127,-127,-127,-127,-127,-127,-127,-127,-127,-127,-127,-127,-127,-127,-127,-127,-127,-127,-127,-127,-127,-127,-127,-127,-127,-127,-127,-127};
#endif
......@@ -86,15 +86,13 @@ static inline uint32_t nrLDPC_init(t_nrLDPC_dec_params* p_decParams, t_nrLDPC_lu
p_lut->bnPosBnProcBuf[8] = NULL;
p_lut->llr2llrProcBufAddr = llr2llrProcBufAddr_BG2_R15;
p_lut->llr2llrProcBufNumBn = llr2llrProcBufNumBn_BG2_R15;
p_lut->llr2llrProcBufNumEl = &llr2llrProcBufNumEl_BG2_R15;
p_lut->llr2llrProcBufBnPos = llr2llrProcBufBnPos_BG2_R15;
p_lut->numCnInCnGroups = lut_numCnInCnGroups_BG2_R15;
p_lut->numBnInBnGroups = lut_numBnInBnGroups_BG2_R15;
p_lut->startAddrBnGroups = lut_startAddrBnGroups_BG2_R15;
p_lut->startAddrBnGroupsLlr = lut_startAddrBnGroupsLlr_BG2_R15;
p_lut->numEdgesPerBn = lut_numEdgesPerBn_BG2_R15;
numLLR = NR_LDPC_NCOL_BG2_R15*Z;
}
else if (R == 13)
......@@ -120,14 +118,13 @@ static inline uint32_t nrLDPC_init(t_nrLDPC_dec_params* p_decParams, t_nrLDPC_lu
p_lut->bnPosBnProcBuf[8] = NULL;
p_lut->llr2llrProcBufAddr = llr2llrProcBufAddr_BG2_R13;
p_lut->llr2llrProcBufNumBn = llr2llrProcBufNumBn_BG2_R13;
p_lut->llr2llrProcBufNumEl = &llr2llrProcBufNumEl_BG2_R13;
p_lut->llr2llrProcBufBnPos = llr2llrProcBufBnPos_BG2_R13;
p_lut->numCnInCnGroups = lut_numCnInCnGroups_BG2_R13;
p_lut->numBnInBnGroups = lut_numBnInBnGroups_BG2_R13;
p_lut->startAddrBnGroups = lut_startAddrBnGroups_BG2_R13;
p_lut->startAddrBnGroupsLlr = lut_startAddrBnGroupsLlr_BG2_R13;
p_lut->numEdgesPerBn = lut_numEdgesPerBn_BG2_R13;
numLLR = NR_LDPC_NCOL_BG2_R13*Z;
}
else if (R == 23)
......@@ -153,14 +150,13 @@ static inline uint32_t nrLDPC_init(t_nrLDPC_dec_params* p_decParams, t_nrLDPC_lu
p_lut->bnPosBnProcBuf[8] = NULL;
p_lut->llr2llrProcBufAddr = llr2llrProcBufAddr_BG2_R23;
p_lut->llr2llrProcBufNumBn = llr2llrProcBufNumBn_BG2_R23;
p_lut->llr2llrProcBufNumEl = &llr2llrProcBufNumEl_BG2_R23;
p_lut->llr2llrProcBufBnPos = llr2llrProcBufBnPos_BG2_R23;
p_lut->numCnInCnGroups = lut_numCnInCnGroups_BG2_R23;
p_lut->numBnInBnGroups = lut_numBnInBnGroups_BG2_R23;
p_lut->startAddrBnGroups = lut_startAddrBnGroups_BG2_R23;
p_lut->startAddrBnGroupsLlr = lut_startAddrBnGroupsLlr_BG2_R23;
p_lut->numEdgesPerBn = lut_numEdgesPerBn_BG2_R23;
numLLR = NR_LDPC_NCOL_BG2_R23*Z;
}
......@@ -883,8 +879,7 @@ static inline uint32_t nrLDPC_init(t_nrLDPC_dec_params* p_decParams, t_nrLDPC_lu
p_lut->bnPosBnProcBuf[8] = (const uint8_t**) bnPosBnProcBuf_BG1_R13_CNG19;
p_lut->llr2llrProcBufAddr = llr2llrProcBufAddr_BG1_R13;
p_lut->llr2llrProcBufNumBn = llr2llrProcBufNumBn_BG1_R13;
p_lut->llr2llrProcBufNumEl = &llr2llrProcBufNumEl_BG1_R13;
p_lut->llr2llrProcBufBnPos = llr2llrProcBufBnPos_BG1_R13;
p_lut->numCnInCnGroups = lut_numCnInCnGroups_BG1_R13;
p_lut->numBnInBnGroups = lut_numBnInBnGroups_BG1_R13;
......@@ -916,8 +911,7 @@ static inline uint32_t nrLDPC_init(t_nrLDPC_dec_params* p_decParams, t_nrLDPC_lu
p_lut->bnPosBnProcBuf[8] = (const uint8_t**) bnPosBnProcBuf_BG1_R23_CNG19;
p_lut->llr2llrProcBufAddr = llr2llrProcBufAddr_BG1_R23;
p_lut->llr2llrProcBufNumBn = llr2llrProcBufNumBn_BG1_R23;
p_lut->llr2llrProcBufNumEl = &llr2llrProcBufNumEl_BG1_R23;
p_lut->llr2llrProcBufBnPos = llr2llrProcBufBnPos_BG1_R23;
p_lut->numCnInCnGroups = lut_numCnInCnGroups_BG1_R23;
p_lut->numBnInBnGroups = lut_numBnInBnGroups_BG1_R23;
......@@ -949,8 +943,7 @@ static inline uint32_t nrLDPC_init(t_nrLDPC_dec_params* p_decParams, t_nrLDPC_lu
p_lut->bnPosBnProcBuf[8] = (const uint8_t**) bnPosBnProcBuf_BG1_R89_CNG19;
p_lut->llr2llrProcBufAddr = llr2llrProcBufAddr_BG1_R89;
p_lut->llr2llrProcBufNumBn = llr2llrProcBufNumBn_BG1_R89;
p_lut->llr2llrProcBufNumEl = &llr2llrProcBufNumEl_BG1_R89;
p_lut->llr2llrProcBufBnPos = llr2llrProcBufBnPos_BG1_R89;
p_lut->numCnInCnGroups = lut_numCnInCnGroups_BG1_R89;
p_lut->numBnInBnGroups = lut_numBnInBnGroups_BG1_R89;
......
......@@ -951,31 +951,25 @@ static const uint8_t bnPosBnProcBuf_BG2_R23_CNG10[10][2] = {{0, 0},{0, 0},{1, 1}
// LUT for llr2llrProcBuf
// BG1
// R13
static const uint16_t llr2llrProcBufAddr_BG1_R13[24] = {25728,25344,17664,22272,20352,16128,19200,23424,19584,18048,23808,20736,24192,22656,21120,18432,21504,24960,18816,19968,23040,24576,16512,17280};
static const uint8_t llr2llrProcBufNumBn_BG1_R13[24] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,2,1};
static const uint8_t llr2llrProcBufNumEl_BG1_R13 = 24;
static const uint16_t llr2llrProcBufAddr_BG1_R13[26] = {25728,25344,17664,22272,20352,16128,19200,23424,19200,17664,23424,20736,23424,22272,20736,17664,20736,20736,24960,17664,19200,22272,23424,16512,16896,16896};
static const uint8_t llr2llrProcBufBnPos_BG1_R13[26] = {0,0,0,0,0,0,0,0,1,1,1,0,2,1,1,2,2,3,0,3,2,2,3,0,0,1};
// R23
static const uint16_t llr2llrProcBufAddr_BG1_R23[19] = {13056,12672,5760,6912,3840,6144,7680,4224,9600,8448,4608,11136,8832,11520,6528,9216,11904,4992,3456};
static const uint8_t llr2llrProcBufNumBn_BG1_R23[19] = {1,1,1,2,1,1,2,1,4,1,1,1,1,1,1,1,2,2,1};
static const uint8_t llr2llrProcBufNumEl_BG1_R23 = 19;
static const uint16_t llr2llrProcBufAddr_BG1_R23[26] = {13056,12672,5760,6912,6912,3840,5760,6912,6912,3840,9600,9600,9600,9600,6912,3840,9600,6912,9600,5760,6912,9600,9600,3840,3840,3456};
static const uint8_t llr2llrProcBufBnPos_BG1_R23[26] = {0,0,0,0,1,0,1,2,3,1,0,1,2,3,4,2,4,5,5,2,6,6,7,3,4,0};
// R89
static const uint16_t llr2llrProcBufAddr_BG1_R89[4] = {9984,9600,1536,384};
static const uint8_t llr2llrProcBufNumBn_BG1_R89[4] = {1,1,21,3};
static const uint8_t llr2llrProcBufNumEl_BG1_R89 = 4;
static const uint16_t llr2llrProcBufAddr_BG1_R89[26] = {9984,9600,1536,1536,1536,1536,1536,1536,1536,1536,1536,1536,1536,1536,1536,1536,1536,1536,1536,1536,1536,1536,1536,384,384,384};
static const uint8_t llr2llrProcBufBnPos_BG1_R89[26] = {0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,0,1,2};
// BG2
// R15
static const uint16_t llr2llrProcBufAddr_BG2_R15[13] = {19200,19584,17280,14592,18432,15744,18048,15360,16128,16512,18816,16896,17664};
static const uint8_t llr2llrProcBufNumBn_BG2_R15[13] = {1,1,1,2,1,1,1,1,1,1,1,1,1};
static const uint8_t llr2llrProcBufNumEl_BG2_R15 = 13;
static const uint16_t llr2llrProcBufAddr_BG2_R15[14] = {19200,19584,17280,14592,14592,18432,15744,18048,15360,16128,16512,18816,16512,17664};
static const uint8_t llr2llrProcBufBnPos_BG2_R15[14] = {0,0,0,0,1,0,0,0,0,0,0,0,1,0};
// R13
static const uint16_t llr2llrProcBufAddr_BG2_R13[10] = {11520,11904,6912,7296,8448,10752,9216,11136,8064,10368};
static const uint8_t llr2llrProcBufNumBn_BG2_R13[10] = {1,1,1,2,2,1,3,1,1,1};
static const uint8_t llr2llrProcBufNumEl_BG2_R13 = 10;
static const uint16_t llr2llrProcBufAddr_BG2_R13[14] = {11520,11904,6912,7296,7296,8448,8448,10752,8448,8448,8448,11136,8064,10368};
static const uint8_t llr2llrProcBufBnPos_BG2_R13[14] = {0,0,0,0,1,0,1,0,2,3,4,0,0,0};
// R23
static const uint16_t llr2llrProcBufAddr_BG2_R23[12] = {6144,5376,1152,2304,4224,3072,4608,3456,4992,3840,5760,1536};
static const uint8_t llr2llrProcBufNumBn_BG2_R23[12] = {1,1,1,2,1,1,1,1,1,1,1,2};
static const uint8_t llr2llrProcBufNumEl_BG2_R23 = 12;
static const uint16_t llr2llrProcBufAddr_BG2_R23[14] = {6144,5376,1152,2304,2304,4224,2304,4224,2304,4224,2304,5376,1152,1152};
static const uint8_t llr2llrProcBufBnPos_BG2_R23[14] = {0,0,0,0,1,0,2,1,3,2,4,1,1,2};
// LUT for llr2cnProcBuf
// LUTs are not rate dependent, however the number of CN in a CNG varies with rate
......
......@@ -84,19 +84,15 @@ static inline void nrLDPC_llr2llrProcBuf(t_nrLDPC_lut* p_lut, int8_t* llr, t_nrL
{
uint32_t i;
const uint8_t numBn2CnG1 = p_lut->numBnInBnGroups[0];
uint32_t colG1 = NR_LDPC_START_COL_PARITY_BG1*Z;
uint32_t startColParity = (BG ==1 ) ? (NR_LDPC_START_COL_PARITY_BG1) : (NR_LDPC_START_COL_PARITY_BG2);
const uint16_t* lut_llr2llrProcBufAddr = p_lut->llr2llrProcBufAddr;
const uint8_t* lut_llr2llrProcBufNumBn = p_lut->llr2llrProcBufNumBn;
const uint8_t* lut_llr2llrProcBufNumEl = p_lut->llr2llrProcBufNumEl;
uint32_t colG1 = startColParity*Z;
uint16_t numLlr = 0;
int8_t* llrProcBuf = p_procBuf->llrProcBuf;
const uint16_t* lut_llr2llrProcBufAddr = p_lut->llr2llrProcBufAddr;
const uint8_t* lut_llr2llrProcBufBnPos = p_lut->llr2llrProcBufBnPos;
if (BG == 2)
{
colG1 = NR_LDPC_START_COL_PARITY_BG2*Z;
}
uint32_t idxBn;
int8_t* llrProcBuf = p_procBuf->llrProcBuf;
// Copy LLRs connected to 1 CN
if (numBn2CnG1 > 0)
......@@ -105,11 +101,11 @@ static inline void nrLDPC_llr2llrProcBuf(t_nrLDPC_lut* p_lut, int8_t* llr, t_nrL
}
// First 2 columns might be set to zero directly if it's true they always belong to the groups with highest number of connected CNs...
for (i=0; i<(*lut_llr2llrProcBufNumEl); i++)
for (i=0; i<startColParity; i++)
{
numLlr = lut_llr2llrProcBufNumBn[i]*Z;
memcpy(&llrProcBuf[lut_llr2llrProcBufAddr[i]], llr, numLlr);
llr+=numLlr;
idxBn = lut_llr2llrProcBufAddr[i] + lut_llr2llrProcBufBnPos[i]*Z;
memcpy(&llrProcBuf[idxBn], llr, Z);
llr += Z;
}
}
......@@ -835,7 +831,7 @@ static inline void nrLDPC_bn2cnProcBuf_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf
for (j=0; j<2; j++)
{
p_cnProcBuf = &cnProcBuf[lut_startAddrCnGroups[0] + j*bitOffsetInGroup];
for (i=0; i<lut_numCnInCnGroups[0]; i++)
{
idxBn = lut_startAddrBnProcBuf_CNG3[j][i] + lut_bnPosBnProcBuf_CNG3[j][i]*Z;
......@@ -927,7 +923,7 @@ static inline void nrLDPC_bn2cnProcBuf_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf
nrLDPC_inv_circ_memcpy(p_cnProcBuf, &bnProcBufRes[idxBn], Z, lut_circShift_CNG10[j][i]);
p_cnProcBuf += Z;
}
}
}
}
/**
......@@ -1141,20 +1137,16 @@ static inline void nrLDPC_llrRes2llrOut(t_nrLDPC_lut* p_lut, int8_t* llrOut, t_n
{
uint32_t i;
const uint8_t numBn2CnG1 = p_lut->numBnInBnGroups[0];
uint32_t colG1 = NR_LDPC_START_COL_PARITY_BG1*Z;
uint32_t startColParity = (BG ==1 ) ? (NR_LDPC_START_COL_PARITY_BG1) : (NR_LDPC_START_COL_PARITY_BG2);
uint32_t colG1 = startColParity*Z;
const uint16_t* lut_llr2llrProcBufAddr = p_lut->llr2llrProcBufAddr;
const uint8_t* lut_llr2llrProcBufNumBn = p_lut->llr2llrProcBufNumBn;
const uint8_t* lut_llr2llrProcBufNumEl = p_lut->llr2llrProcBufNumEl;
const uint8_t* lut_llr2llrProcBufBnPos = p_lut->llr2llrProcBufBnPos;
uint16_t numLlr = 0;
int8_t* llrRes = p_procBuf->llrRes;
int8_t* p_llrOut = &llrOut[0];
if (BG == 2)
{
colG1 = NR_LDPC_START_COL_PARITY_BG2*Z;
}
uint32_t idxBn;
// Copy LLRs connected to 1 CN
if (numBn2CnG1 > 0)
......@@ -1162,13 +1154,14 @@ static inline void nrLDPC_llrRes2llrOut(t_nrLDPC_lut* p_lut, int8_t* llrOut, t_n
memcpy(&llrOut[colG1], llrRes, numBn2CnG1*Z);
}
// First 2 columns might be set to zero directly if it's true they always belong to the groups with highest number of connected CNs...
for (i=0; i<(*lut_llr2llrProcBufNumEl); i++)
for (i=0; i<startColParity; i++)
{
numLlr = lut_llr2llrProcBufNumBn[i]*Z;
memcpy(p_llrOut, &llrRes[lut_llr2llrProcBufAddr[i]], numLlr);
p_llrOut+=numLlr;
idxBn = lut_llr2llrProcBufAddr[i] + lut_llr2llrProcBufBnPos[i]*Z;
memcpy(p_llrOut, &llrRes[idxBn], Z);
p_llrOut += Z;
}
}
#endif
......@@ -46,16 +46,11 @@ typedef struct nrLDPC_lut {
const uint8_t* numBnInBnGroups; /**< Number of CNs in every BN group */
const uint32_t* startAddrBnGroups; /**< Start addresses for BN groups in BN processing buffer */
const uint16_t* startAddrBnGroupsLlr; /**< Start addresses for BN groups in LLR processing buffer */
const uint32_t* llr2CnProcBuf; /**< LUT for input LLRs to CN processing buffer */
const uint8_t* numEdgesPerBn; /**< LUT with number of edges per BN */
const uint32_t* cn2bnProcBuf; /**< LUT for transferring CN processing results to BN processing buffer */
const uint16_t* llr2llrProcBuf; /**< LUT for transferring input LLRs to LLR processing buffer */
const uint16_t** circShift[NR_LDPC_NUM_CN_GROUPS_BG1]; /**< LUT for circular shift values for all CN groups and Z's */
const uint32_t** startAddrBnProcBuf[NR_LDPC_NUM_CN_GROUPS_BG1]; /**< LUT for circular shift values for all CN groups and Z's */
const uint8_t** bnPosBnProcBuf[NR_LDPC_NUM_CN_GROUPS_BG1]; /**< LUT for circular shift values for all CN groups and Z's */
const uint16_t* llr2llrProcBufAddr; /**< LUT for transferring input LLRs to LLR processing buffer */
const uint8_t* llr2llrProcBufNumBn; /**< LUT for transferring input LLRs to LLR processing buffer */
const uint8_t* llr2llrProcBufNumEl; /**< LUT for transferring input LLRs to LLR processing buffer */
const uint8_t* llr2llrProcBufBnPos; /**< LUT for transferring input LLRs to LLR processing buffer */
const uint8_t** posBnInCnProcBuf[NR_LDPC_NUM_CN_GROUPS_BG1]; /**< LUT for llr2cnProcBuf */
} t_nrLDPC_lut;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment