Commit 9223c956 authored by root's avatar root

Bug fix in ldpc decoder for small TBS

parent d3970219
......@@ -2763,113 +2763,4 @@ static inline void nrLDPC_llr2bitPacked(int8_t* out, int8_t* llrOut, uint16_t nu
*p_bits = bitsTmp;
}
/*
static inline void nrLDPC_bnProcPc_test(t_nrLDPC_lut* p_lut, int8_t* llrIn, int8_t* llrOut, uint16_t numLLR, uint16_t Z, uint8_t BG)
{
// Sum all edges and store in llrRes
const uint32_t* lut_llr2CnProcBuf = p_lut->llr2CnProcBuf;
const uint8_t* lut_numEdgesPerBn = p_lut->numEdgesPerBn;
uint32_t idxLut = 0;
uint32_t idxCnProcBuf = 0;
uint8_t numEdges;
uint32_t i;
uint32_t j;
uint32_t k;
uint8_t startColParity = NR_LDPC_START_COL_PARITY_BG1;
uint32_t colG1;
uint16_t bnSum[16] __attribute__ ((aligned(32))) = {0};
uint16_t llrTmp[16] __attribute__ ((aligned(32))) = {0};
__m256i* p_bnSum256 = (__m256i*) &bnSum[0];
__m256i* p_llrOut256 = (__m256i*) &llrTmp[0];
if (BG == 2)
{
startColParity = NR_LDPC_START_COL_PARITY_BG2;
}
colG1 = startColParity*Z;
// BNs connected to more than 1 CN
for (k=0; k<startColParity; k++)
{
numEdges = lut_numEdgesPerBn[k];
for (i=0; i<Z; i++)
{
bnSum[0] = 0;
// Sum all edges
for (j=0; j<numEdges; j++)
{
idxCnProcBuf = lut_llr2CnProcBuf[idxLut++];
bnSum[0] += cnProcBufRes[idxCnProcBuf];
}
// Add LLR from receiver input
bnSum[0] += llrIn[k*Z + i];
// Signed saturation
*p_llrOut256 = _mm256_packs_epi16(*p_bnSum256, *p_llrOut256);
llrOut[k*Z + i] = llrTmp[0];
}
}
// BNs connected to 1 CN
for (i=colG1; i<numLLR; i++)
{
idxCnProcBuf = lut_llr2CnProcBuf[idxLut++];
bnSum[0] = cnProcBufRes[idxCnProcBuf];
cnProcBuf[idxCnProcBuf] = llrIn[i];
// Add LLR from receiver input
bnSum[0] += llrIn[i];
// Signed saturation
*p_llrOut256 = _mm256_packs_epi16(*p_bnSum256, *p_llrOut256);
llrOut[i] = llrTmp[0];
}
}
*/
/*
static inline void nrLDPC_bnProc_test(t_nrLDPC_lut* p_lut, int8_t* llrOut, uint16_t numLLR, uint16_t Z, uint8_t BG)
{
// Sum all edges and store in llrRes
const uint32_t* lut_llr2CnProcBuf = p_lut->llr2CnProcBuf;
const uint8_t* lut_numEdgesPerBn = p_lut->numEdgesPerBn;
uint32_t idxLut = 0;
uint32_t idxCnProcBuf = 0;
uint8_t numEdges;
uint32_t i;
uint32_t j;
uint32_t k;
uint8_t startColParity = NR_LDPC_START_COL_PARITY_BG1;
uint32_t colG1;
if (BG == 2)
{
startColParity = NR_LDPC_START_COL_PARITY_BG2;
}
colG1 = startColParity*Z;
// BNs connected to more than 1 CN
for (k=0; k<startColParity; k++)
{
numEdges = lut_numEdgesPerBn[k];
for (i=0; i<Z; i++)
{
for (j=0; j<numEdges; j++)
{
idxCnProcBuf = lut_llr2CnProcBuf[idxLut++];
cnProcBuf[idxCnProcBuf] = llrOut[k*Z + i] - cnProcBufRes[idxCnProcBuf];
}
}
}
}
*/
#endif
This diff is collapsed.
......@@ -18,6 +18,12 @@
#include "nrLDPC_cnProc.h"
#include "nrLDPC_bnProc.h"
#define NR_LDPC_ENABLE_PARITY_CHECK
#ifdef NR_LDPC_DEBUG_MODE
#include "nrLDPC_tools/nrLDPC_debug.h"
#endif
static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_t numLLR, t_nrLDPC_lut* p_lut, t_nrLDPC_dec_params* p_decParams, t_nrLDPC_time_stats* p_profiler);
int32_t nrLDPC_decoder(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_out, t_nrLDPC_time_stats* p_profiler)
......@@ -70,6 +76,11 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_
stop_meas(&p_profiler->llr2llrProcBuf);
#endif
#ifdef NR_LDPC_DEBUG_MODE
nrLDPC_debug_initBuffer2File(nrLDPC_buffers_LLR_PROC);
nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_PROC);
#endif
#ifdef NR_LDPC_PROFILER_DETAIL
start_meas(&p_profiler->llr2CnProcBuf);
#endif
......@@ -78,6 +89,11 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_
stop_meas(&p_profiler->llr2CnProcBuf);
#endif
#ifdef NR_LDPC_DEBUG_MODE
nrLDPC_debug_initBuffer2File(nrLDPC_buffers_CN_PROC);
nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC);
#endif
// First iteration
// CN processing
......@@ -96,6 +112,11 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_
stop_meas(&p_profiler->cnProc);
#endif
#ifdef NR_LDPC_DEBUG_MODE
nrLDPC_debug_initBuffer2File(nrLDPC_buffers_CN_PROC_RES);
nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC_RES);
#endif
#ifdef NR_LDPC_PROFILER_DETAIL
start_meas(&p_profiler->cn2bnProcBuf);
#endif
......@@ -111,6 +132,11 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_
stop_meas(&p_profiler->cn2bnProcBuf);
#endif
#ifdef NR_LDPC_DEBUG_MODE
nrLDPC_debug_initBuffer2File(nrLDPC_buffers_BN_PROC);
nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC);
#endif
// BN processing
#ifdef NR_LDPC_PROFILER_DETAIL
start_meas(&p_profiler->bnProcPc);
......@@ -120,6 +146,11 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_
stop_meas(&p_profiler->bnProcPc);
#endif
#ifdef NR_LDPC_DEBUG_MODE
nrLDPC_debug_initBuffer2File(nrLDPC_buffers_LLR_RES);
nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_RES);
#endif
#ifdef NR_LDPC_PROFILER_DETAIL
start_meas(&p_profiler->bnProc);
#endif
......@@ -128,6 +159,11 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_
stop_meas(&p_profiler->bnProc);
#endif
#ifdef NR_LDPC_DEBUG_MODE
nrLDPC_debug_initBuffer2File(nrLDPC_buffers_BN_PROC_RES);
nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC_RES);
#endif
// BN results to CN processing buffer
#ifdef NR_LDPC_PROFILER_DETAIL
start_meas(&p_profiler->bn2cnProcBuf);
......@@ -144,6 +180,10 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_
stop_meas(&p_profiler->bn2cnProcBuf);
#endif
#ifdef NR_LDPC_DEBUG_MODE
nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC);
#endif
// Parity Check not necessary here since it will fail
// because first 2 cols/BNs in BG are punctured and cannot be
// estimated after only one iteration
......@@ -171,6 +211,10 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_
stop_meas(&p_profiler->cnProc);
#endif
#ifdef NR_LDPC_DEBUG_MODE
nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC_RES);
#endif
// Send CN results back to BNs
#ifdef NR_LDPC_PROFILER_DETAIL
start_meas(&p_profiler->cn2bnProcBuf);
......@@ -187,6 +231,10 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_
stop_meas(&p_profiler->cn2bnProcBuf);
#endif
#ifdef NR_LDPC_DEBUG_MODE
nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC);
#endif
// BN Processing
#ifdef NR_LDPC_PROFILER_DETAIL
start_meas(&p_profiler->bnProcPc);
......@@ -196,6 +244,10 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_
stop_meas(&p_profiler->bnProcPc);
#endif
#ifdef NR_LDPC_DEBUG_MODE
nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_RES);
#endif
#ifdef NR_LDPC_PROFILER_DETAIL
start_meas(&p_profiler->bnProc);
#endif
......@@ -204,6 +256,10 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_
stop_meas(&p_profiler->bnProc);
#endif
#ifdef NR_LDPC_DEBUG_MODE
nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC_RES);
#endif
// BN results to CN processing buffer
#ifdef NR_LDPC_PROFILER_DETAIL
start_meas(&p_profiler->bn2cnProcBuf);
......@@ -220,6 +276,10 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_
stop_meas(&p_profiler->bn2cnProcBuf);
#endif
#ifdef NR_LDPC_DEBUG_MODE
nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC);
#endif
// Parity Check
#ifdef NR_LDPC_ENABLE_PARITY_CHECK
#ifdef NR_LDPC_PROFILER_DETAIL
......@@ -262,6 +322,10 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_
stop_meas(&p_profiler->cnProc);
#endif
#ifdef NR_LDPC_DEBUG_MODE
nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC_RES);
#endif
// Send CN results back to BNs
#ifdef NR_LDPC_PROFILER_DETAIL
start_meas(&p_profiler->cn2bnProcBuf);
......@@ -278,6 +342,10 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_
stop_meas(&p_profiler->cn2bnProcBuf);
#endif
#ifdef NR_LDPC_DEBUG_MODE
nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC);
#endif
// BN Processing
#ifdef NR_LDPC_PROFILER_DETAIL
start_meas(&p_profiler->bnProcPc);
......@@ -287,6 +355,10 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_
stop_meas(&p_profiler->bnProcPc);
#endif
#ifdef NR_LDPC_DEBUG_MODE
nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_RES);
#endif
// If parity check not enabled, no need to send the BN proc results
// back to CNs
#ifdef NR_LDPC_ENABLE_PARITY_CHECK
......@@ -298,6 +370,10 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_
stop_meas(&p_profiler->bnProc);
#endif
#ifdef NR_LDPC_DEBUG_MODE
nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC_RES);
#endif
// BN results to CN processing buffer
#ifdef NR_LDPC_PROFILER_DETAIL
start_meas(&p_profiler->bn2cnProcBuf);
......@@ -314,6 +390,10 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_
stop_meas(&p_profiler->bn2cnProcBuf);
#endif
#ifdef NR_LDPC_DEBUG_MODE
nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC);
#endif
// Parity Check
#ifdef NR_LDPC_PROFILER_DETAIL
start_meas(&p_profiler->cnProcPc);
......
......@@ -122,6 +122,28 @@ static inline uint32_t nrLDPC_init(t_nrLDPC_dec_params* p_decParams, t_nrLDPC_lu
p_lut->llr2llrProcBuf = lut_llr2llrProcBuf_BG2_Z128_R23;
}
}
else if (Z == 208)
{
if (R == 15)
{
p_lut->llr2CnProcBuf = lut_llr2CnProcBuf_BG2_Z208_R15;
p_lut->cn2bnProcBuf = lut_cn2bnProcBuf_BG2_Z208_R15;
p_lut->llr2llrProcBuf = lut_llr2llrProcBuf_BG2_Z208_R15;
}
else if (R == 13)
{
p_lut->llr2CnProcBuf = lut_llr2CnProcBuf_BG2_Z208_R13;
p_lut->cn2bnProcBuf = lut_cn2bnProcBuf_BG2_Z208_R13;
p_lut->llr2llrProcBuf = lut_llr2llrProcBuf_BG2_Z208_R13;
}
else if (R == 23)
{
p_lut->llr2CnProcBuf = lut_llr2CnProcBuf_BG2_Z208_R23;
p_lut->cn2bnProcBuf = lut_cn2bnProcBuf_BG2_Z208_R23;
p_lut->llr2llrProcBuf = lut_llr2llrProcBuf_BG2_Z208_R23;
}
}
else if (Z == 384)
{
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -626,6 +626,7 @@
#include "lut_llr2llrProcBuf_BG1_Z384_R89.h"
// BG2
// Z = 2
#include "lut_llr2CnProcBuf_BG2_Z2_R15.h"
#include "lut_cn2bnProcBuf_BG2_Z2_R15.h"
#include "lut_llr2llrProcBuf_BG2_Z2_R15.h"
......@@ -637,7 +638,7 @@
#include "lut_llr2CnProcBuf_BG2_Z2_R23.h"
#include "lut_cn2bnProcBuf_BG2_Z2_R23.h"
#include "lut_llr2llrProcBuf_BG2_Z2_R23.h"
// Z = 80
#include "lut_llr2CnProcBuf_BG2_Z80_R15.h"
#include "lut_cn2bnProcBuf_BG2_Z80_R15.h"
#include "lut_llr2llrProcBuf_BG2_Z80_R15.h"
......@@ -649,7 +650,7 @@
#include "lut_llr2CnProcBuf_BG2_Z80_R23.h"
#include "lut_cn2bnProcBuf_BG2_Z80_R23.h"
#include "lut_llr2llrProcBuf_BG2_Z80_R23.h"
// Z = 128
#include "lut_llr2CnProcBuf_BG2_Z128_R15.h"
#include "lut_cn2bnProcBuf_BG2_Z128_R15.h"
#include "lut_llr2llrProcBuf_BG2_Z128_R15.h"
......@@ -661,7 +662,19 @@
#include "lut_llr2CnProcBuf_BG2_Z128_R23.h"
#include "lut_cn2bnProcBuf_BG2_Z128_R23.h"
#include "lut_llr2llrProcBuf_BG2_Z128_R23.h"
// Z = 208
#include "lut_llr2CnProcBuf_BG2_Z208_R15.h"
#include "lut_cn2bnProcBuf_BG2_Z208_R15.h"
#include "lut_llr2llrProcBuf_BG2_Z208_R15.h"
#include "lut_llr2CnProcBuf_BG2_Z208_R13.h"
#include "lut_cn2bnProcBuf_BG2_Z208_R13.h"
#include "lut_llr2llrProcBuf_BG2_Z208_R13.h"
#include "lut_llr2CnProcBuf_BG2_Z208_R23.h"
#include "lut_cn2bnProcBuf_BG2_Z208_R23.h"
#include "lut_llr2llrProcBuf_BG2_Z208_R23.h"
// Z = 384
#include "lut_llr2CnProcBuf_BG2_Z384_R15.h"
#include "lut_cn2bnProcBuf_BG2_Z384_R15.h"
#include "lut_llr2llrProcBuf_BG2_Z384_R15.h"
......
/*==============================================================================
* nrLDPC_debug.h
*
* Defines the debugging functions
*
* Author: Sebastian Wagner
* Date: 15-01-2018
*
===============================================================================*/
#ifndef __NR_LDPC_DEBUG__H__
#define __NR_LDPC_DEBUG__H__
#include <stdio.h>
typedef enum nrLDPC_buffers {
nrLDPC_buffers_LLR_PROC,
nrLDPC_buffers_CN_PROC,
nrLDPC_buffers_CN_PROC_RES,
nrLDPC_buffers_BN_PROC,
nrLDPC_buffers_BN_PROC_RES,
nrLDPC_buffers_LLR_RES
} e_nrLDPC_buffers;
static inline void nrLDPC_writeFile(const char* fileName, int8_t* p_data, const uint32_t N)
{
FILE *f;
uint32_t i;
f = fopen(fileName, "a");
// Newline indicating new data
fprintf(f, "\n");
for (i=0; i < N; i++)
{
fprintf(f, "%d, ", p_data[i]);
}
fclose(f);
}
static inline void nrLDPC_initFile(const char* fileName)
{
FILE *f;
f = fopen(fileName, "w");
fprintf(f, " ");
fclose(f);
}
static inline void nrLDPC_debug_writeBuffer2File(e_nrLDPC_buffers buffer)
{
switch (buffer)
{
case nrLDPC_buffers_LLR_PROC:
{
nrLDPC_writeFile("llrProcBuf.txt", llrProcBuf, NR_LDPC_MAX_NUM_LLR);
break;
}
case nrLDPC_buffers_CN_PROC:
{
nrLDPC_writeFile("cnProcBuf.txt", cnProcBuf, NR_LDPC_SIZE_CN_PROC_BUF);
break;
}
case nrLDPC_buffers_CN_PROC_RES:
{
nrLDPC_writeFile("cnProcBufRes.txt", cnProcBufRes, NR_LDPC_SIZE_CN_PROC_BUF);
break;
}
case nrLDPC_buffers_BN_PROC:
{
nrLDPC_writeFile("bnProcBuf.txt", bnProcBuf, NR_LDPC_SIZE_BN_PROC_BUF);
break;
}
case nrLDPC_buffers_BN_PROC_RES:
{
nrLDPC_writeFile("bnProcBufRes.txt", bnProcBufRes, NR_LDPC_SIZE_BN_PROC_BUF);
break;
}
case nrLDPC_buffers_LLR_RES:
{
nrLDPC_writeFile("llrRes.txt", llrRes, NR_LDPC_MAX_NUM_LLR);
break;
}
}
}
static inline void nrLDPC_debug_initBuffer2File(e_nrLDPC_buffers buffer)
{
switch (buffer)
{
case nrLDPC_buffers_LLR_PROC:
{
nrLDPC_initFile("llrProcBuf.txt");
break;
}
case nrLDPC_buffers_CN_PROC:
{
nrLDPC_initFile("cnProcBuf.txt");
break;
}
case nrLDPC_buffers_CN_PROC_RES:
{
nrLDPC_initFile("cnProcBufRes.txt");
break;
}
case nrLDPC_buffers_BN_PROC:
{
nrLDPC_initFile("bnProcBuf.txt");
break;
}
case nrLDPC_buffers_BN_PROC_RES:
{
nrLDPC_initFile("bnProcBufRes.txt");
break;
}
case nrLDPC_buffers_LLR_RES:
{
nrLDPC_initFile("llrRes.txt");
break;
}
}
}
static inline void nrLDPC_debug_print256i_epi8(__m256i* in)
{
uint32_t i;
for (i=0; i<32; i++)
{
mexPrintf("%d ", ((int8_t*)&in)[i]);
}
}
#endif
......@@ -712,7 +712,7 @@ int dlsch_encoding(PHY_VARS_eNB *eNB,
printf("start ldpc encoder\n");
printf("input %d %d %d %d %d \n", dlsch->harq_processes[harq_pid]->c[r][0], dlsch->harq_processes[harq_pid]->c[r][1], dlsch->harq_processes[harq_pid]->c[r][2],dlsch->harq_processes[harq_pid]->c[r][3], dlsch->harq_processes[harq_pid]->c[r][4]);
ldpc_encoder((char*)dlsch->harq_processes[harq_pid]->c[r],(char*)&dlsch->harq_processes[harq_pid]->d[r][96],dlsch->harq_processes[harq_pid]->B,rate);
//ldpc_encoder((char*)dlsch->harq_processes[harq_pid]->c[r],(char*)&dlsch->harq_processes[harq_pid]->d[r][96],dlsch->harq_processes[harq_pid]->B,rate);
ldpc_encoder((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],&dlsch->harq_processes[harq_pid]->d[r][96],dlsch->harq_processes[harq_pid]->B,rate);
......
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